@wocker/core
Advanced tools
Comparing version 1.0.17-dev.2 to 1.0.17-dev.3
@@ -12,2 +12,3 @@ import { InstanceWrapper } from "./InstanceWrapper"; | ||
getModule<TInput = any>(type: Type<TInput>): Module<TInput>; | ||
addProvider(type: Type, wrapper: InstanceWrapper): void; | ||
} |
@@ -7,2 +7,3 @@ "use strict"; | ||
const Module_1 = require("./Module"); | ||
const env_1 = require("../env"); | ||
class Container { | ||
@@ -28,3 +29,9 @@ constructor() { | ||
} | ||
addProvider(type, wrapper) { | ||
const token = typeof type !== "string" | ||
? Reflect.getMetadata(env_1.INJECT_TOKEN_METADATA, type) || type | ||
: type; | ||
this.providers.set(token, wrapper); | ||
} | ||
} | ||
exports.Container = Container; |
@@ -8,3 +8,2 @@ import { Provider } from "../types/Provider"; | ||
type: TInput; | ||
parent?: Module | undefined; | ||
imports: Map<any, InstanceWrapper>; | ||
@@ -14,11 +13,8 @@ controllers: Map<any, InstanceWrapper>; | ||
exports: Set<any>; | ||
constructor(container: Container, type: TInput, parent?: Module | undefined); | ||
constructor(container: Container, type: TInput); | ||
get<TInput = any, TResult = TInput>(type: Type<TInput> | Function | string | symbol): TResult; | ||
getWrapper(type: any): InstanceWrapper | undefined; | ||
addImport(module: any): void; | ||
addProvider(provider: Provider, instance?: any): void; | ||
getProvider(): void; | ||
addInjection(): void; | ||
addController(type: any): void; | ||
addExport(type: any): void; | ||
} |
@@ -7,6 +7,5 @@ "use strict"; | ||
class Module { | ||
constructor(container, type, parent) { | ||
constructor(container, type) { | ||
this.container = container; | ||
this.type = type; | ||
this.parent = parent; | ||
this.imports = new Map(); | ||
@@ -20,2 +19,8 @@ this.controllers = new Map(); | ||
if (!wrapper) { | ||
if (typeof type === "function") { | ||
throw new Error(`Provider "${type.prototype.constructor.name}" not found`); | ||
} | ||
else if (typeof type === "string") { | ||
throw new Error(`Provider "${type}" not found`); | ||
} | ||
throw new Error("Provider not found"); | ||
@@ -30,13 +35,7 @@ } | ||
const wrapper = this.providers.get(token); | ||
if (!wrapper && this.parent) { | ||
return this.parent.getWrapper(type); | ||
} | ||
if (!wrapper) { | ||
return this.container.providers.get(type); | ||
return this.container.providers.get(token); | ||
} | ||
return wrapper; | ||
} | ||
addImport(module) { | ||
// this.imports.add(module); | ||
} | ||
addProvider(provider, instance) { | ||
@@ -46,8 +45,2 @@ const wrapper = new InstanceWrapper_1.InstanceWrapper(this, provider, instance); | ||
} | ||
getProvider() { | ||
// | ||
} | ||
addInjection() { | ||
// | ||
} | ||
addController(type) { | ||
@@ -64,9 +57,11 @@ this.controllers.set(type, new InstanceWrapper_1.InstanceWrapper(this, type)); | ||
} | ||
// console.log(">", name, command); | ||
} | ||
} | ||
addExport(type) { | ||
this.exports.add(type); | ||
const token = typeof type !== "string" | ||
? Reflect.getMetadata(env_1.INJECT_TOKEN_METADATA, type) || type | ||
: type; | ||
this.exports.add(token); | ||
} | ||
} | ||
exports.Module = Module; |
@@ -10,2 +10,3 @@ import { PickProperties, EnvConfig } from "../types"; | ||
preset?: string; | ||
presetMode?: "global" | "project"; | ||
imageName?: string; | ||
@@ -12,0 +13,0 @@ dockerfile?: string; |
@@ -12,2 +12,3 @@ "use strict"; | ||
this.preset = data.preset; | ||
this.presetMode = data.presetMode; | ||
this.imageName = data.imageName; | ||
@@ -181,2 +182,3 @@ this.dockerfile = data.dockerfile; | ||
preset: this.preset, | ||
presetMode: this.presetMode, | ||
imageName: this.imageName, | ||
@@ -183,0 +185,0 @@ dockerfile: this.dockerfile, |
@@ -17,3 +17,2 @@ "use strict"; | ||
const Module_1 = require("./Module"); | ||
const Logger_1 = require("./Logger"); | ||
const env_1 = require("../env"); | ||
@@ -78,3 +77,3 @@ class Scanner { | ||
if (wrapper) { | ||
this.container.providers.set(type, wrapper); | ||
this.container.addProvider(type, wrapper); | ||
} | ||
@@ -90,6 +89,7 @@ } | ||
const cli = cliWrapper.instance; | ||
// Logger.unmute(); | ||
Logger_1.Logger.info(">_<"); | ||
for (const [, module] of this.container.modules) { | ||
for (const [type, controller] of module.controllers) { | ||
if (!controller.instance) { | ||
continue; | ||
} | ||
const controllerCommands = []; | ||
@@ -191,2 +191,3 @@ const controllerCompletions = []; | ||
// console.log(type, ">_<", provider); | ||
return; | ||
} | ||
@@ -193,0 +194,0 @@ // @ts-ignore |
{ | ||
"name": "@wocker/core", | ||
"version": "1.0.17-dev.2", | ||
"version": "1.0.17-dev.3", | ||
"author": "Kris Papercut <krispcut@gmail.com>", | ||
@@ -5,0 +5,0 @@ "description": "Core of the Wocker", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
99824
2513