@wocker/core
Advanced tools
Comparing version 1.0.10 to 1.0.11
@@ -0,1 +1,2 @@ | ||
import "reflect-metadata"; | ||
export declare const Command: (command: string) => MethodDecorator; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Command = void 0; | ||
require("reflect-metadata"); | ||
const env_1 = require("../env"); | ||
@@ -5,0 +6,0 @@ const Command = (command) => { |
@@ -0,1 +1,2 @@ | ||
import "reflect-metadata"; | ||
export declare const Completion: (name: string, command?: string) => MethodDecorator; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Completion = void 0; | ||
require("reflect-metadata"); | ||
const Completion = (name, command) => { | ||
@@ -5,0 +6,0 @@ return (target, propertyKey, descriptor) => { |
export * from "./Command"; | ||
export * from "./Completion"; | ||
export * from "./Controller"; | ||
export * from "./Description"; | ||
export * from "./Inject"; | ||
@@ -8,2 +9,3 @@ export * from "./Injectable"; | ||
export * from "./Option"; | ||
export * from "./Param"; | ||
export * from "./Plugin"; |
@@ -20,2 +20,3 @@ "use strict"; | ||
__exportStar(require("./Controller"), exports); | ||
__exportStar(require("./Description"), exports); | ||
__exportStar(require("./Inject"), exports); | ||
@@ -25,2 +26,3 @@ __exportStar(require("./Injectable"), exports); | ||
__exportStar(require("./Option"), exports); | ||
__exportStar(require("./Param"), exports); | ||
__exportStar(require("./Plugin"), exports); |
@@ -1,1 +0,2 @@ | ||
export declare const Param: (name: string) => MethodDecorator; | ||
import "reflect-metadata"; | ||
export declare const Param: (name: string) => ParameterDecorator; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Param = void 0; | ||
require("reflect-metadata"); | ||
const env_1 = require("../env"); | ||
const Param = (name) => { | ||
return (target, propertyKey, descriptor) => { | ||
return (target, propertyKey, parameterIndex) => { | ||
if (!propertyKey) { | ||
return; | ||
} | ||
Reflect.defineMetadata(env_1.ARGS_METADATA, [ | ||
...Reflect.getMetadata(env_1.ARGS_METADATA, target.constructor, propertyKey) || [], | ||
{ | ||
type: "param", | ||
name, | ||
index: parameterIndex | ||
} | ||
], target.constructor, propertyKey); | ||
}; | ||
}; | ||
exports.Param = Param; |
@@ -5,2 +5,3 @@ export declare const IS_MODULE = "IS_MODULE"; | ||
export declare const COMMAND_METADATA = "command"; | ||
export declare const COMMAND_DESCRIPTION_METADATA = "__COMMAND_DESCRIPTION__"; | ||
export declare const COMPLETION_METADATA = "completion"; | ||
@@ -7,0 +8,0 @@ export declare const ARGS_METADATA = "__ARGS__"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MODULE_METADATA = exports.PLUGIN_NAME_METADATA = exports.PLUGIN_DIR_KEY = exports.INJECT_TOKEN_METADATA = exports.SELF_DECLARED_DEPS_METADATA = exports.PARAMTYPES_METADATA = exports.OPTION_META = exports.ARGS_METADATA = exports.COMPLETION_METADATA = exports.COMMAND_METADATA = exports.ARGS_META = exports.INJECTABLE_WATERMARK = exports.IS_MODULE = void 0; | ||
exports.MODULE_METADATA = exports.PLUGIN_NAME_METADATA = exports.PLUGIN_DIR_KEY = exports.INJECT_TOKEN_METADATA = exports.SELF_DECLARED_DEPS_METADATA = exports.PARAMTYPES_METADATA = exports.OPTION_META = exports.ARGS_METADATA = exports.COMPLETION_METADATA = exports.COMMAND_DESCRIPTION_METADATA = exports.COMMAND_METADATA = exports.ARGS_META = exports.INJECTABLE_WATERMARK = exports.IS_MODULE = void 0; | ||
exports.IS_MODULE = "IS_MODULE"; | ||
@@ -8,2 +8,3 @@ exports.INJECTABLE_WATERMARK = "__injectable__"; | ||
exports.COMMAND_METADATA = "command"; | ||
exports.COMMAND_DESCRIPTION_METADATA = "__COMMAND_DESCRIPTION__"; | ||
exports.COMPLETION_METADATA = "completion"; | ||
@@ -10,0 +11,0 @@ exports.ARGS_METADATA = "__ARGS__"; |
import { Type } from "../types/Type"; | ||
import { Container } from "./Container"; | ||
export declare class ApplicationContext { | ||
protected module: any; | ||
protected container: Container; | ||
protected readonly module: any; | ||
protected readonly container: Container; | ||
constructor(module: any, container: Container); | ||
get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol): TResult; | ||
run(args: string[]): Promise<any>; | ||
run(args: string[]): Promise<string>; | ||
} |
@@ -20,4 +20,7 @@ "use strict"; | ||
get(typeOrToken) { | ||
var _a; | ||
const res = (_a = this.container.getModule(this.module)) === null || _a === void 0 ? void 0 : _a.get(typeOrToken); | ||
const module = this.container.getModule(this.module); | ||
if (!module) { | ||
throw new Error("Module not found"); | ||
} | ||
const res = module.get(typeOrToken); | ||
if (!res) { | ||
@@ -24,0 +27,0 @@ throw new Error("Instance not found"); |
import { EnvConfig, PickProperties } from "../types"; | ||
export type ConfigProperties = PickProperties<Config>; | ||
export type ConfigProperties = Omit<PickProperties<Config>, "logLevel"> & { | ||
logLevel?: Config["logLevel"]; | ||
}; | ||
export declare abstract class Config { | ||
@@ -4,0 +6,0 @@ debug?: boolean; |
@@ -7,3 +7,2 @@ import { Module } from "./Module"; | ||
addModule(type: any, module: Module): void; | ||
addController(moduleType: any, type: any): void; | ||
} |
@@ -7,2 +7,11 @@ "use strict"; | ||
this.modules = new Map(); | ||
// public addController(moduleType: any, type: any): void { | ||
// const module = this.getModule(moduleType); | ||
// | ||
// if(!module) { | ||
// return; | ||
// } | ||
// | ||
// module.addController(type); | ||
// } | ||
} | ||
@@ -18,10 +27,3 @@ hasModule(type) { | ||
} | ||
addController(moduleType, type) { | ||
const module = this.getModule(moduleType); | ||
if (!module) { | ||
return; | ||
} | ||
module.addController(type); | ||
} | ||
} | ||
exports.Container = Container; |
@@ -15,7 +15,6 @@ import { ApplicationContext } from "./ApplicationContext"; | ||
scanRoutes(): Promise<void>; | ||
log(...args: any[]): void; | ||
init(): Promise<void>; | ||
run(args: string[]): Promise<any>; | ||
run(args: string[]): Promise<string>; | ||
getContainer(): Container; | ||
static create(module: any): Promise<ApplicationContext>; | ||
} |
@@ -61,4 +61,6 @@ "use strict"; | ||
const providers = Reflect.getMetadata(env_1.MODULE_METADATA.PROVIDERS, module.type) || []; | ||
// Logger.info(module.type.name, providers); | ||
module.addProvider(cli_1.Cli, this.cli); | ||
providers.forEach((providerType) => { | ||
// Logger.info(" ->", (providerType as any).name); | ||
module.addProvider(providerType); | ||
@@ -119,2 +121,5 @@ }); | ||
const command = this.cli.command(commandName); | ||
command.help({ | ||
description: "Des" | ||
}); | ||
for (const argMeta of argsMeta) { | ||
@@ -141,8 +146,12 @@ if (argMeta.type === "option") { | ||
this.cli.command(commandName) | ||
.action((options, ...params) => { | ||
.action((input) => { | ||
const args = []; | ||
const params = Object.values(input.arguments()); | ||
argsMeta.forEach((argMeta) => { | ||
if (argMeta.type === "option") { | ||
args[argMeta.index] = options[argMeta.name]; | ||
if (argMeta.type === "param") { | ||
args[argMeta.index] = input.argument(argMeta.name); | ||
} | ||
else if (argMeta.type === "option") { | ||
args[argMeta.index] = input.option(argMeta.name); | ||
} | ||
}); | ||
@@ -172,11 +181,2 @@ return controller.instance[method](...args, ...params); | ||
} | ||
log(...args) { | ||
for (const [, module] of this.container.modules) { | ||
module.providers.forEach((provider) => { | ||
if (provider.instance.info) { | ||
provider.instance.info(...args); | ||
} | ||
}); | ||
} | ||
} | ||
init() { | ||
@@ -183,0 +183,0 @@ return __awaiter(this, void 0, void 0, function* () { |
export * from "./Config"; | ||
export * from "./Container"; | ||
export * from "./DI"; | ||
export * from "./FileSystem"; | ||
@@ -5,0 +4,0 @@ export * from "./FS"; |
@@ -19,3 +19,2 @@ "use strict"; | ||
__exportStar(require("./Container"), exports); | ||
__exportStar(require("./DI"), exports); | ||
__exportStar(require("./FileSystem"), exports); | ||
@@ -22,0 +21,0 @@ __exportStar(require("./FS"), exports); |
@@ -0,10 +1,10 @@ | ||
import "reflect-metadata"; | ||
import { Module } from "./Module"; | ||
export declare class InstanceWrapper { | ||
private readonly module; | ||
private readonly token; | ||
private readonly provider; | ||
private _instance?; | ||
constructor(module: Module, token: any, provider: any, _instance?: any); | ||
constructor(module: Module, provider: any, _instance?: any); | ||
get instance(): any; | ||
set instance(instance: any); | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.InstanceWrapper = void 0; | ||
require("reflect-metadata"); | ||
const env_1 = require("../env"); | ||
class InstanceWrapper { | ||
constructor(module, token, provider, _instance) { | ||
constructor(module, provider, _instance) { | ||
this.module = module; | ||
this.token = token; | ||
this.provider = provider; | ||
@@ -13,5 +13,2 @@ this._instance = _instance; | ||
get instance() { | ||
if (!this.provider) { | ||
return null; | ||
} | ||
if (!this._instance) { | ||
@@ -18,0 +15,0 @@ const types = [ |
@@ -1,2 +0,2 @@ | ||
import { LogService } from "../services/LogService"; | ||
import { LogService } from "../services"; | ||
export declare class Logger { | ||
@@ -3,0 +3,0 @@ static install(ls: LogService): void; |
@@ -37,8 +37,13 @@ "use strict"; | ||
if ("provide" in provider && "useValue" in provider) { | ||
const wrapper = new InstanceWrapper_1.InstanceWrapper(this, provider.provide, provider.provide, provider.useValue); | ||
const wrapper = new InstanceWrapper_1.InstanceWrapper(this, provider.provide, provider.useValue); | ||
this.providers.set(provider.provide, wrapper); | ||
return; | ||
} | ||
if ("provide" in provider && "useClass" in provider) { | ||
const wrapper = new InstanceWrapper_1.InstanceWrapper(this, provider.useClass); | ||
this.providers.set(provider.provide, wrapper); | ||
return; | ||
} | ||
const token = Reflect.getMetadata("INJECT_TOKEN", provider) || provider; | ||
const wrapper = new InstanceWrapper_1.InstanceWrapper(this, token, provider, instance); | ||
const wrapper = new InstanceWrapper_1.InstanceWrapper(this, provider, instance); | ||
this.providers.set(token, wrapper); | ||
@@ -50,3 +55,3 @@ } | ||
addController(type) { | ||
this.controllers.set(type, new InstanceWrapper_1.InstanceWrapper(this, type, type)); | ||
this.controllers.set(type, new InstanceWrapper_1.InstanceWrapper(this, type)); | ||
for (const name of Object.getOwnPropertyNames(type.prototype)) { | ||
@@ -53,0 +58,0 @@ const descriptor = Object.getOwnPropertyDescriptor(type.prototype, name); |
@@ -1,4 +0,1 @@ | ||
import { DI } from "./DI"; | ||
import { PresetServiceSearchOptions as SearchOptions } from "../services/PresetService"; | ||
import { EnvConfig } from "../types"; | ||
type TextOption = { | ||
@@ -26,3 +23,3 @@ type: "string" | "number" | "int"; | ||
type AnyOption = TextOption | ConfirmOption | SelectOption; | ||
declare class Preset { | ||
export declare abstract class Preset { | ||
id: string; | ||
@@ -40,9 +37,5 @@ name: string; | ||
volumeOptions?: string[]; | ||
constructor(data: any); | ||
save(): Promise<void>; | ||
getImageName(buildArgs?: EnvConfig): string; | ||
static install(di: DI): void; | ||
static search(options: SearchOptions): Promise<any[]>; | ||
static searchOne(options: SearchOptions): Promise<any>; | ||
protected constructor(data: any); | ||
abstract save(): Promise<void>; | ||
} | ||
export { Preset }; | ||
export {}; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Preset = void 0; | ||
const PresetService_1 = require("../services/PresetService"); | ||
let _di; | ||
class Preset { | ||
@@ -26,20 +15,3 @@ constructor(data) { | ||
} | ||
save() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return _di.resolveService(PresetService_1.PresetService).save(this); | ||
}); | ||
} | ||
getImageName(buildArgs) { | ||
return _di.resolveService(PresetService_1.PresetService).getImageName(this, buildArgs); | ||
} | ||
static install(di) { | ||
_di = di; | ||
} | ||
static search(options) { | ||
return _di.resolveService(PresetService_1.PresetService).search(options); | ||
} | ||
static searchOne(options) { | ||
return _di.resolveService(PresetService_1.PresetService).searchOne(options); | ||
} | ||
} | ||
exports.Preset = Preset; |
import { PickProperties, EnvConfig } from "../types"; | ||
type ProjectProperties = Omit<PickProperties<Project>, "containerName">; | ||
export type ProjectProperties = Omit<PickProperties<Project>, "containerName">; | ||
export declare abstract class Project { | ||
@@ -36,2 +36,1 @@ id: string; | ||
export declare const PROJECT_TYPE_IMAGE = "image"; | ||
export {}; |
{ | ||
"name": "@wocker/core", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"author": "Kris Papercut <krispcut@gmail.com>", | ||
@@ -22,8 +22,9 @@ "description": "Core of wocker", | ||
"prepare": "npm run build", | ||
"watch": "tsc -w", | ||
"build": "tsc", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"build": "tsc --project tsconfig.build.json", | ||
"watch": "tsc -w --project tsconfig.build.json", | ||
"watch:test": "jest --colors --watchAll --coverage", | ||
"test": "jest --colors" | ||
}, | ||
"dependencies": { | ||
"@kearisp/cli": "^1.0.7", | ||
"@kearisp/cli": "^2.0.4", | ||
"fs": "^0.0.1-security", | ||
@@ -35,5 +36,9 @@ "path": "^0.12.7", | ||
"@types/dockerode": "^3.3.23", | ||
"@types/jest": "^29.5.12", | ||
"@types/node": "^20.11.7", | ||
"typescript": "^5.4.4" | ||
"jest": "^29.7.0", | ||
"ts-jest": "^29.1.2", | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.4.5" | ||
} | ||
} |
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
0
86586
7
2149
+ Added@kearisp/cli@2.0.7(transitive)
- Removed@kearisp/cli@1.0.7(transitive)
Updated@kearisp/cli@^2.0.4