Socket
Socket
Sign inDemoInstall

@fluent/core

Package Overview
Dependencies
3
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.5

build/application.spec.d.ts

4

build/application-builder.d.ts

@@ -1,5 +0,3 @@

export interface ApplicationBuilder {
use(...args: any[]): void;
}
export declare abstract class ApplicationBuilder {
abstract use(...args: any[]): void;
}
import { ApplicationBuilder } from './application-builder';
import { Environment } from './environment';
import { Configuration } from './configuration';
import { ServiceCollection } from '@fluent/di';
export interface Application<T extends ApplicationBuilder> {
readonly serviceCollection: ServiceCollection;
applicationBuilder: T;
environment: Environment;
configuration: Configuration;
runAsync(): Promise<number>;
}
import { Importer } from './importer';
export declare abstract class Application<T extends ApplicationBuilder> {
readonly serviceCollection: ServiceCollection;
environment: Environment;
configuration: Configuration;
constructor(environmentName?: string);
readonly applicationBuilder: T;
readonly environment: Environment;
readonly importer: Importer;
constructor();
abstract runAsync(): Promise<number>;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Path = require("path");
const environment_1 = require("./environment");
const configuration_1 = require("./configuration");
const di_1 = require("@fluent/di");
const root_dir_1 = require("./root-dir");
const importer_1 = require("./importer");
class Application {
constructor(environmentName) {
constructor() {
this.serviceCollection = new di_1.ServiceCollection();
this.environment = new environment_1.Environment();
const scriptName = process.mainModule && process.mainModule.filename ?
process.mainModule.filename : process.argv[1];
this.environment.name = environmentName || this.environment.name;
this.environment.rootPath = Path.dirname(scriptName);
this.importer = new importer_1.Importer();
this.environment.rootPath = root_dir_1.rootPath;
this.serviceCollection.addSingleton(environment_1.Environment, this.environment);
this.configuration = configuration_1.Configuration.readFromFile(Path.join(this.environment.rootPath, `configuration.${this.environment.name}.json`));
this.serviceCollection.addSingleton(environment_1.Environment, this.environment);
this.serviceCollection.addSingleton(configuration_1.Configuration, this.configuration);
}
}
exports.Application = Application;

@@ -1,3 +0,1 @@

export interface Configuration extends Map<string, any> {
}
export declare class Configuration extends Map<string, any> implements Configuration {

@@ -4,0 +2,0 @@ static readFromFile(filePath: string, encoding?: string): Configuration;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const FileSystem = require("fs");
const fileSystem = require("fs");
class Configuration extends Map {
static readFromFile(filePath, encoding = 'utf8') {
const fileContent = FileSystem.readFileSync(filePath, {
const fileContent = fileSystem.readFileSync(filePath, {
encoding: encoding, flag: 'r'

@@ -8,0 +8,0 @@ });

export declare class Importer {
readonly path: string;
readonly files: Set<string>;
constructor(path: string);
private browse(dirPath);
importAsync(): Promise<void[]>;
readonly filePaths: Set<string>;
readonly exclusion: Set<RegExp>;
readonly inclusion: Set<RegExp>;
constructor();
constructor(directoryToScan: string);
scanDirectory(directoryToScan: string): void;
importAll(): void;
importFile(filePath: string): void;
isExcluded(entryPath: string): boolean;
tryAssert(entryPath: string): boolean;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const FilySystem = require("fs");
const Path = require("path");
const filySystem = require("fs");
const path = require("path");
class Importer {
constructor(path) {
this.files = new Set();
this.path = Path.resolve(path);
this.browse(this.path);
constructor(directoryToScan) {
this.filePaths = new Set();
this.exclusion = new Set([/^node_modules$/i, /^\./, /\.spec\.(js|ts)$/i, /\.d\.ts$/i]);
this.inclusion = new Set([/\.(js|ts)$/i]);
if (directoryToScan) {
this.scanDirectory(directoryToScan);
}
}
browse(dirPath) {
const paths = FilySystem.readdirSync(dirPath);
paths.filter((path) => {
const stats = FilySystem.lstatSync(Path.join(dirPath, path));
if (path.startsWith('.') || path.startsWith('node_modules')) {
return false;
scanDirectory(directoryToScan) {
directoryToScan = path.resolve(directoryToScan);
for (const entryPath of filySystem.readdirSync(directoryToScan)) {
const absolutePath = path.join(directoryToScan, entryPath);
const entryStat = filySystem.lstatSync(absolutePath);
if (!this.isExcluded(entryPath)) {
if (entryStat.isDirectory() && !entryStat.isSymbolicLink()) {
this.scanDirectory(absolutePath);
}
else if (this.tryAssert(entryPath)) {
if (!this.filePaths.has(absolutePath)) {
this.filePaths.add(absolutePath);
}
}
}
if (stats.isDirectory() && !stats.isSymbolicLink()) {
this.browse(Path.join(dirPath, path));
return false;
}
}
importAll() {
for (const filePath of this.filePaths) {
this.importFile(filePath);
}
}
importFile(filePath) {
require(filePath);
}
isExcluded(entryPath) {
for (const exclude of this.exclusion) {
if (exclude.test(entryPath)) {
return true;
}
return (path.endsWith('.ts') && !path.endsWith('.spec.ts') && !path.endsWith('.d.ts'))
|| (path.endsWith('.js') && !path.endsWith('.spec.js'));
}).map((path) => {
this.files.add(Path.join(dirPath, path));
});
}
return false;
}
importAsync() {
const promises = Array.from(this.files).map(file => {
return new Promise(resolve => {
(file);
resolve();
});
});
return Promise.all(promises);
tryAssert(entryPath) {
for (const include of this.inclusion) {
if (include.test(entryPath)) {
return true;
}
}
return false;
}
}
exports.Importer = Importer;

@@ -7,1 +7,3 @@ export * from './application';

export * from './startup';
export * from './importer';
export * from './root-dir';

@@ -12,1 +12,3 @@ "use strict";

__export(require("./startup"));
__export(require("./importer"));
__export(require("./root-dir"));
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Path = require("path");
const importer_1 = require("./importer");
function Main(applicationConstructor) {
return (startupConstructor) => {
const rootPath = Path.dirname(process.argv[1]);
new importer_1.Importer(rootPath)
.importAsync()
.then(() => {
if (!applicationConstructor) {
throw new Error(`Application type not selected. Try use Application from "Application" from "@fluent/console".`);
}
const application = new applicationConstructor();
const startup = new startupConstructor();
if (startup.configureServices) {
startup.configureServices(application.serviceCollection);
}
if (startup.configure) {
startup.configure(application.applicationBuilder);
}
application.runAsync();
});
if (!applicationConstructor) {
throw new Error(`Application type not selected. Try use Application from "Application" from "@fluent/console".`);
}
const application = new applicationConstructor();
const startup = new startupConstructor();
if (startup.configureServices) {
startup.configureServices(application.serviceCollection);
}
if (startup.configure) {
startup.configure(application.applicationBuilder);
}
application.runAsync();
};
}
exports.Main = Main;
import { ApplicationBuilder } from './application-builder';
import { ServiceCollection } from '@fluent/di';
export interface Startup<T extends ApplicationBuilder> {
export declare abstract class Startup<T extends ApplicationBuilder> implements Startup<T> {
configureServices?(services: ServiceCollection): void;
configure?(applicationBuilder: T): void;
}
export declare abstract class Startup<T extends ApplicationBuilder> implements Startup<T> {
}
{
"name": "@fluent/core",
"version": "1.0.1",
"version": "1.0.5",
"description": "Fluent - core component",

@@ -9,3 +9,5 @@ "main": "build/index.js",

"build": "tsc",
"prepublishOnly": "npm run build"
"prepublishOnly": "npm run build",
"pretest": "npm run-script build",
"test": "mocha --exit build/**/*.spec.js"
},

@@ -18,5 +20,5 @@ "keywords": [

"author": "Eugen Melnychenko",
"repository" : {
"type" : "git",
"url" : "https://github.com/emelnychenko/fluent"
"repository": {
"type": "git",
"url": "https://github.com/emelnychenko/fluent"
},

@@ -27,8 +29,12 @@ "dependencies": {

"peerDependencies": {
"@fluent/di": "1.0.*"
"@fluent/di": "^1.0.5"
},
"devDependencies": {
"@types/chai": "^4.1.2",
"@types/node": "^9.3.0",
"chai": "^4.1.2",
"@types/mocha": "^2.2.47",
"mocha": "^5.0.0",
"typescript": "2.6.*"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc