@wocker/core
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -8,1 +8,2 @@ export * from "./Command"; | ||
export * from "./Option"; | ||
export * from "./Plugin"; |
@@ -24,1 +24,2 @@ "use strict"; | ||
__exportStar(require("./Option"), exports); | ||
__exportStar(require("./Plugin"), exports); |
@@ -1,6 +0,8 @@ | ||
import { MODULE_METADATA } from "../env"; | ||
import { MODULE_METADATA, PLUGIN_NAME_METADATA } from "../env"; | ||
import { Provider } from "../types/Provider"; | ||
import { Type } from "../types/Type"; | ||
type Config = { | ||
[MODULE_METADATA.NAME]?: string; | ||
export type ModuleConfig = { | ||
/** | ||
* @deprecated | ||
*/ | ||
[PLUGIN_NAME_METADATA]?: string; | ||
[MODULE_METADATA.CONTROLLERS]?: any[]; | ||
@@ -11,6 +13,2 @@ [MODULE_METADATA.PROVIDERS]?: Provider[]; | ||
}; | ||
export type DynamicModule = { | ||
providers?: any[]; | ||
}; | ||
export declare const Module: (config: Config) => <T extends Type>(Target: T) => void; | ||
export {}; | ||
export declare const Module: (config: ModuleConfig) => ClassDecorator; |
@@ -6,12 +6,12 @@ "use strict"; | ||
const Module = (config) => { | ||
const { [env_1.MODULE_METADATA.NAME]: name, [env_1.MODULE_METADATA.CONTROLLERS]: controllers = [], [env_1.MODULE_METADATA.PROVIDERS]: providers = [], [env_1.MODULE_METADATA.IMPORTS]: imports = [], [env_1.MODULE_METADATA.EXPORTS]: exports = [] } = config; | ||
return (Target) => { | ||
Reflect.defineMetadata("isModule", true, Target); | ||
Reflect.defineMetadata(env_1.MODULE_METADATA.NAME, name, Target); | ||
Reflect.defineMetadata(env_1.MODULE_METADATA.IMPORTS, imports, Target); | ||
Reflect.defineMetadata(env_1.MODULE_METADATA.CONTROLLERS, controllers, Target); | ||
Reflect.defineMetadata(env_1.MODULE_METADATA.PROVIDERS, providers, Target); | ||
Reflect.defineMetadata(env_1.MODULE_METADATA.EXPORTS, exports, Target); | ||
const { [env_1.PLUGIN_NAME_METADATA]: name, [env_1.MODULE_METADATA.CONTROLLERS]: controllers = [], [env_1.MODULE_METADATA.PROVIDERS]: providers = [], [env_1.MODULE_METADATA.IMPORTS]: imports = [], [env_1.MODULE_METADATA.EXPORTS]: exports = [] } = config; | ||
return (target) => { | ||
Reflect.defineMetadata("isModule", true, target); | ||
Reflect.defineMetadata(env_1.PLUGIN_NAME_METADATA, name, target); | ||
Reflect.defineMetadata(env_1.MODULE_METADATA.IMPORTS, imports, target); | ||
Reflect.defineMetadata(env_1.MODULE_METADATA.CONTROLLERS, controllers, target); | ||
Reflect.defineMetadata(env_1.MODULE_METADATA.PROVIDERS, providers, target); | ||
Reflect.defineMetadata(env_1.MODULE_METADATA.EXPORTS, exports, target); | ||
}; | ||
}; | ||
exports.Module = Module; |
@@ -12,2 +12,3 @@ export declare const IS_MODULE = "IS_MODULE"; | ||
export declare const PLUGIN_DIR_KEY = "PLUGIN_DIR"; | ||
export declare const PLUGIN_NAME_METADATA = "name"; | ||
export declare enum MODULE_METADATA { | ||
@@ -14,0 +15,0 @@ NAME = "name", |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MODULE_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_METADATA = exports.ARGS_META = exports.INJECTABLE_WATERMARK = exports.IS_MODULE = void 0; | ||
exports.IS_MODULE = "IS_MODULE"; | ||
@@ -15,2 +15,3 @@ exports.INJECTABLE_WATERMARK = "__injectable__"; | ||
exports.PLUGIN_DIR_KEY = "PLUGIN_DIR"; | ||
exports.PLUGIN_NAME_METADATA = "name"; | ||
var MODULE_METADATA; | ||
@@ -17,0 +18,0 @@ (function (MODULE_METADATA) { |
@@ -0,1 +1,3 @@ | ||
import { ApplicationContext } from "./ApplicationContext"; | ||
import { Container } from "./Container"; | ||
import { Module } from "./Module"; | ||
@@ -16,3 +18,4 @@ export declare class Factory { | ||
run(args: string[]): Promise<any>; | ||
static create(module: any): Promise<Factory>; | ||
getContainer(): Container; | ||
static create(module: any): Promise<ApplicationContext>; | ||
} |
@@ -14,2 +14,3 @@ "use strict"; | ||
const cli_1 = require("@kearisp/cli"); | ||
const ApplicationContext_1 = require("./ApplicationContext"); | ||
const Container_1 = require("./Container"); | ||
@@ -102,3 +103,4 @@ const Module_1 = require("./Module"); | ||
const commandName = Reflect.getMetadata(env_1.COMMAND_METADATA, descriptor.value); | ||
const completions = (Reflect.getMetadata(env_1.COMPLETION_METADATA, descriptor.value) || []).map((completion) => { | ||
const completions = (Reflect.getMetadata(env_1.COMPLETION_METADATA, descriptor.value) || []) | ||
.map((completion) => { | ||
return Object.assign(Object.assign({}, completion), { method: name }); | ||
@@ -195,2 +197,5 @@ }); | ||
} | ||
getContainer() { | ||
return this.container; | ||
} | ||
static create(module) { | ||
@@ -200,3 +205,3 @@ return __awaiter(this, void 0, void 0, function* () { | ||
yield factory.scan(module); | ||
return factory; | ||
return new ApplicationContext_1.ApplicationContext(module, factory.getContainer()); | ||
}); | ||
@@ -203,0 +208,0 @@ } |
@@ -0,1 +1,2 @@ | ||
export * from "./Config"; | ||
export * from "./Container"; | ||
@@ -6,5 +7,4 @@ export * from "./DI"; | ||
export * from "./Logger"; | ||
export * from "./Plugin"; | ||
export * from "./Preset"; | ||
export * from "./Project"; | ||
export * from "./Factory"; |
@@ -17,2 +17,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./Config"), exports); | ||
__exportStar(require("./Container"), exports); | ||
@@ -23,5 +24,4 @@ __exportStar(require("./DI"), exports); | ||
__exportStar(require("./Logger"), exports); | ||
__exportStar(require("./Plugin"), exports); | ||
__exportStar(require("./Preset"), exports); | ||
__exportStar(require("./Project"), exports); | ||
__exportStar(require("./Factory"), exports); |
import { PickProperties, EnvConfig } from "../types"; | ||
import { DI } from "./DI"; | ||
type SearchOptions = { | ||
export declare abstract class Project { | ||
id: string; | ||
name: string; | ||
path: string; | ||
}; | ||
export declare class Project { | ||
id: string; | ||
name: string; | ||
type: string; | ||
@@ -36,10 +30,5 @@ path: string; | ||
volumeUnmount(...volumes: string[]): void; | ||
save(): Promise<void>; | ||
static install(di: DI): void; | ||
static fromObject(data: any): Project; | ||
static search(params?: Partial<SearchOptions>): Promise<Project[]>; | ||
static searchOne(params: Partial<SearchOptions>): Promise<Project | null>; | ||
abstract save(): Promise<void>; | ||
} | ||
export declare const PROJECT_TYPE_DOCKERFILE = "dockerfile"; | ||
export declare const PROJECT_TYPE_IMAGE = "image"; | ||
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.PROJECT_TYPE_IMAGE = exports.PROJECT_TYPE_DOCKERFILE = exports.Project = void 0; | ||
const volumeParse_1 = require("../utils/volumeParse"); | ||
const services_1 = require("../services"); | ||
let projectService; | ||
class Project { | ||
@@ -120,30 +109,2 @@ constructor(data) { | ||
} | ||
save() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!projectService) { | ||
throw new Error("Dependency is missing"); | ||
} | ||
yield projectService.save(this); | ||
}); | ||
} | ||
static install(di) { | ||
projectService = di.resolveService(services_1.ProjectService); | ||
} | ||
static fromObject(data) { | ||
return new Project(data); | ||
} | ||
static search() { | ||
return __awaiter(this, arguments, void 0, function* (params = {}) { | ||
if (!projectService) { | ||
throw new Error("Dependency is missing"); | ||
} | ||
return projectService.search(params); | ||
}); | ||
} | ||
static searchOne(params) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const [project] = yield Project.search(params); | ||
return project || null; | ||
}); | ||
} | ||
} | ||
@@ -150,0 +111,0 @@ exports.Project = Project; |
@@ -1,2 +0,2 @@ | ||
import { AppConfig } from "../types"; | ||
import { Config } from "../makes"; | ||
type TypeMap = { | ||
@@ -6,2 +6,3 @@ [type: string]: string; | ||
declare abstract class AppConfigService { | ||
protected config?: Config; | ||
abstract dataPath(...args: string[]): string; | ||
@@ -11,14 +12,7 @@ abstract pluginsPath(...args: string[]): string; | ||
abstract setPWD(pwd: string): void; | ||
abstract getAppConfig(): Promise<AppConfig>; | ||
abstract getMeta(name: string, defaultValue?: string): Promise<string | undefined>; | ||
abstract setMeta(name: string, value: string | number | undefined): Promise<void>; | ||
abstract getAllEnvVariables(): Promise<AppConfig["env"]>; | ||
abstract getEnvVariable(name: string, defaultValue?: string): Promise<string | undefined>; | ||
abstract setEnvVariable(name: string, value: string | number): Promise<void>; | ||
abstract setProjectConfig(id: string, path: string): Promise<void>; | ||
abstract getProjectTypes(): TypeMap; | ||
abstract registerProjectType(name: string, title?: string): void; | ||
abstract activatePlugin(name: string): Promise<void>; | ||
abstract deactivatePlugin(name: string): Promise<void>; | ||
protected abstract loadConfig(): Promise<Config>; | ||
getConfig(): Promise<Config>; | ||
} | ||
export { AppConfigService }; |
@@ -8,2 +8,11 @@ "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 }); | ||
@@ -13,2 +22,10 @@ exports.AppConfigService = void 0; | ||
let AppConfigService = class AppConfigService { | ||
getConfig() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!this.config) { | ||
this.config = yield this.loadConfig(); | ||
} | ||
return this.config; | ||
}); | ||
} | ||
}; | ||
@@ -15,0 +32,0 @@ exports.AppConfigService = AppConfigService; |
{ | ||
"name": "@wocker/core", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"author": "Kris Papercut <krispcut@gmail.com>", | ||
@@ -35,4 +35,4 @@ "description": "Core of wocker", | ||
"@types/node": "^20.11.7", | ||
"typescript": "^5.4.3" | ||
"typescript": "^5.4.4" | ||
} | ||
} |
81539
91
2023