@wocker/core 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/README.md +28 -0
  2. package/lib/decorators/Command.d.ts +1 -0
  3. package/lib/decorators/Command.js +10 -0
  4. package/lib/decorators/Completion.d.ts +1 -0
  5. package/lib/decorators/Completion.js +15 -0
  6. package/lib/decorators/Controller.d.ts +5 -0
  7. package/lib/decorators/Controller.js +14 -0
  8. package/lib/decorators/Inject.d.ts +1 -1
  9. package/lib/decorators/Inject.js +10 -2
  10. package/lib/decorators/Injectable.d.ts +1 -4
  11. package/lib/decorators/Injectable.js +7 -12
  12. package/lib/decorators/Module.d.ts +15 -0
  13. package/lib/decorators/Module.js +16 -0
  14. package/lib/decorators/Option.d.ts +4 -0
  15. package/lib/decorators/Option.js +21 -0
  16. package/lib/decorators/Param.d.ts +1 -0
  17. package/lib/decorators/Param.js +8 -0
  18. package/lib/decorators/index.d.ts +7 -0
  19. package/lib/decorators/index.js +23 -0
  20. package/lib/env.d.ts +18 -0
  21. package/lib/env.js +22 -0
  22. package/lib/index.d.ts +5 -17
  23. package/lib/index.js +8 -18
  24. package/lib/makes/Container.d.ts +8 -0
  25. package/lib/makes/Container.js +25 -0
  26. package/lib/makes/FS.d.ts +15 -3
  27. package/lib/makes/FS.js +99 -4
  28. package/lib/makes/FSManager.js +4 -4
  29. package/lib/makes/Factory.d.ts +17 -0
  30. package/lib/makes/Factory.js +201 -0
  31. package/lib/makes/InstanceWrapper.d.ts +10 -0
  32. package/lib/makes/InstanceWrapper.js +41 -0
  33. package/lib/makes/Logger.d.ts +4 -5
  34. package/lib/makes/Logger.js +8 -9
  35. package/lib/makes/Module.d.ts +17 -0
  36. package/lib/makes/Module.js +63 -0
  37. package/lib/makes/Plugin.d.ts +1 -3
  38. package/lib/makes/Plugin.js +2 -3
  39. package/lib/{models → makes}/Preset.d.ts +4 -4
  40. package/lib/{models → makes}/Project.d.ts +14 -10
  41. package/lib/{models → makes}/Project.js +60 -24
  42. package/lib/makes/Scanner.d.ts +4 -0
  43. package/lib/makes/Scanner.js +9 -0
  44. package/lib/makes/index.d.ts +9 -0
  45. package/lib/makes/index.js +25 -0
  46. package/lib/services/AppConfigService.d.ts +1 -1
  47. package/lib/services/AppConfigService.js +12 -2
  48. package/lib/services/AppEventsService.d.ts +2 -2
  49. package/lib/services/AppEventsService.js +12 -2
  50. package/lib/services/DockerService.d.ts +13 -1
  51. package/lib/services/DockerService.js +12 -2
  52. package/lib/services/LogService.d.ts +2 -3
  53. package/lib/services/LogService.js +12 -2
  54. package/lib/services/PluginConfigService.d.ts +5 -0
  55. package/lib/services/PluginConfigService.js +64 -0
  56. package/lib/services/PresetService.d.ts +6 -7
  57. package/lib/services/ProjectService.d.ts +5 -3
  58. package/lib/services/ProjectService.js +14 -4
  59. package/lib/services/index.d.ts +7 -0
  60. package/lib/services/index.js +23 -0
  61. package/lib/types/Abstract.d.ts +3 -0
  62. package/lib/types/Abstract.js +2 -0
  63. package/lib/types/InjectionToken.d.ts +3 -0
  64. package/lib/types/InjectionToken.js +2 -0
  65. package/lib/types/PickProperties.d.ts +3 -0
  66. package/lib/types/PickProperties.js +2 -0
  67. package/lib/types/Provider.d.ts +12 -0
  68. package/lib/types/Provider.js +2 -0
  69. package/lib/types/Type.d.ts +3 -0
  70. package/lib/types/Type.js +2 -0
  71. package/lib/types/index.d.ts +3 -0
  72. package/lib/types/index.js +19 -0
  73. package/package.json +17 -6
  74. package/lib/makes/Controller.d.ts +0 -5
  75. package/lib/makes/Controller.js +0 -9
  76. /package/lib/{models → makes}/Preset.js +0 -0
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Factory = void 0;
13
+ const cli_1 = require("@kearisp/cli");
14
+ const Container_1 = require("./Container");
15
+ const Module_1 = require("./Module");
16
+ const env_1 = require("../env");
17
+ class Factory {
18
+ constructor() {
19
+ this.routes = [];
20
+ this.container = new Container_1.Container();
21
+ this.cli = new cli_1.Cli();
22
+ }
23
+ scan(moduleType) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ if (this.container.modules.has(moduleType)) {
26
+ return;
27
+ }
28
+ yield this.scanModules(moduleType);
29
+ yield this.scanDependencies();
30
+ yield this.scanDynamicModules();
31
+ yield this.scanRoutes();
32
+ yield this.init();
33
+ });
34
+ }
35
+ scanModules(moduleType, parent) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ if (this.container.hasModule(moduleType)) {
38
+ return;
39
+ }
40
+ const module = new Module_1.Module(moduleType, parent);
41
+ this.container.addModule(moduleType, module);
42
+ const modules = Reflect.getMetadata(env_1.MODULE_METADATA.IMPORTS, moduleType) || [];
43
+ for (const subModuleType of modules) {
44
+ yield this.scanModules(subModuleType, module);
45
+ }
46
+ // const exports = Reflect.getMetadata(MODULE_METADATA.EXPORTS, moduleType) || [];
47
+ return module;
48
+ });
49
+ }
50
+ scanDependencies() {
51
+ return __awaiter(this, void 0, void 0, function* () {
52
+ for (const [, module] of this.container.modules) {
53
+ yield this.scanModuleDependencies(module);
54
+ }
55
+ });
56
+ }
57
+ scanModuleDependencies(module) {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ const providers = Reflect.getMetadata(env_1.MODULE_METADATA.PROVIDERS, module.type) || [];
60
+ module.addProvider(cli_1.Cli, this.cli);
61
+ providers.forEach((providerType) => {
62
+ module.addProvider(providerType);
63
+ });
64
+ const controllers = Reflect.getMetadata(env_1.MODULE_METADATA.CONTROLLERS, module.type) || [];
65
+ controllers.forEach((controller) => {
66
+ module.addController(controller);
67
+ });
68
+ });
69
+ }
70
+ scanDynamicModules() {
71
+ return __awaiter(this, void 0, void 0, function* () {
72
+ for (const [moduleType, module] of this.container.modules) {
73
+ if (moduleType.prototype.load) {
74
+ const { imports } = yield moduleType.prototype.load(this.container);
75
+ for (const type of imports) {
76
+ const isModule = Reflect.getMetadata("isModule", type);
77
+ if (!isModule) {
78
+ continue;
79
+ }
80
+ const subModule = yield this.scanModules(type, module);
81
+ if (subModule) {
82
+ yield this.scanModuleDependencies(subModule);
83
+ }
84
+ }
85
+ }
86
+ }
87
+ });
88
+ }
89
+ scanRoutes() {
90
+ return __awaiter(this, void 0, void 0, function* () {
91
+ for (const [, module] of this.container.modules) {
92
+ for (const [type, controller] of module.controllers) {
93
+ const controllerCommands = [];
94
+ const controllerCompletions = [];
95
+ for (const name of Object.getOwnPropertyNames(type.prototype)) {
96
+ const descriptor = Object.getOwnPropertyDescriptor(type.prototype, name);
97
+ if (!descriptor) {
98
+ continue;
99
+ }
100
+ const commandName = Reflect.getMetadata(env_1.COMMAND_METADATA, descriptor.value);
101
+ const completions = (Reflect.getMetadata(env_1.COMPLETION_METADATA, descriptor.value) || []).map((completion) => {
102
+ return Object.assign(Object.assign({}, completion), { method: name });
103
+ });
104
+ if (completions.length > 0) {
105
+ controllerCompletions.push(...completions);
106
+ }
107
+ if (commandName) {
108
+ controllerCommands.push({
109
+ command: commandName,
110
+ controller,
111
+ method: name,
112
+ argsMeta: Reflect.getMetadata(env_1.ARGS_METADATA, type, name) || []
113
+ });
114
+ const argsMeta = Reflect.getMetadata(env_1.ARGS_METADATA, type, name) || [];
115
+ const command = this.cli.command(commandName);
116
+ for (const argMeta of argsMeta) {
117
+ if (argMeta.type === "option") {
118
+ command.option(argMeta.name, argMeta.params);
119
+ }
120
+ }
121
+ // command.action((options, ...params) => {
122
+ // const args: any[] = [];
123
+ //
124
+ // argsMeta.forEach((argMeta: any) => {
125
+ // if(argMeta.type === "option") {
126
+ // args[argMeta.index] = options[argMeta.name];
127
+ // }
128
+ // });
129
+ //
130
+ // return controller.instance[name](...args, ...params);
131
+ // });
132
+ }
133
+ }
134
+ for (const controllerCommand of controllerCommands) {
135
+ const { command: commandName, method, argsMeta } = controllerCommand;
136
+ this.cli.command(commandName)
137
+ .action((options, ...params) => {
138
+ const args = [];
139
+ argsMeta.forEach((argMeta) => {
140
+ if (argMeta.type === "option") {
141
+ args[argMeta.index] = options[argMeta.name];
142
+ }
143
+ });
144
+ return controller.instance[method](...args, ...params);
145
+ });
146
+ }
147
+ for (const controllerCompletion of controllerCompletions) {
148
+ const { name, command: commandName, method } = controllerCompletion;
149
+ if (!commandName) {
150
+ for (const route of controllerCommands) {
151
+ const { command } = route;
152
+ this.cli.command(command).completion(name, () => {
153
+ return controller.instance[method]();
154
+ });
155
+ }
156
+ }
157
+ else {
158
+ this.cli.command(commandName).completion(name, () => {
159
+ return controller.instance[method]();
160
+ });
161
+ }
162
+ }
163
+ }
164
+ }
165
+ });
166
+ }
167
+ log(...args) {
168
+ for (const [, module] of this.container.modules) {
169
+ module.providers.forEach((provider) => {
170
+ if (provider.instance.info) {
171
+ provider.instance.info(...args);
172
+ }
173
+ });
174
+ }
175
+ }
176
+ init() {
177
+ return __awaiter(this, void 0, void 0, function* () {
178
+ for (const [, module] of this.container.modules) {
179
+ module.providers.forEach((provider) => {
180
+ provider.instance;
181
+ });
182
+ module.controllers.forEach((controller) => {
183
+ controller.instance;
184
+ });
185
+ }
186
+ });
187
+ }
188
+ run(args) {
189
+ return __awaiter(this, void 0, void 0, function* () {
190
+ return this.cli.run(args);
191
+ });
192
+ }
193
+ static create(module) {
194
+ return __awaiter(this, void 0, void 0, function* () {
195
+ const factory = new this();
196
+ yield factory.scan(module);
197
+ return factory;
198
+ });
199
+ }
200
+ }
201
+ exports.Factory = Factory;
@@ -0,0 +1,10 @@
1
+ import { Module } from "./Module";
2
+ export declare class InstanceWrapper {
3
+ private readonly module;
4
+ private readonly token;
5
+ private readonly provider;
6
+ private _instance?;
7
+ constructor(module: Module, token: any, provider: any, _instance?: any);
8
+ get instance(): any;
9
+ set instance(instance: any);
10
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InstanceWrapper = void 0;
4
+ const env_1 = require("../env");
5
+ class InstanceWrapper {
6
+ constructor(module, token, provider, _instance) {
7
+ this.module = module;
8
+ this.token = token;
9
+ this.provider = provider;
10
+ this._instance = _instance;
11
+ }
12
+ get instance() {
13
+ if (!this.provider) {
14
+ return null;
15
+ }
16
+ if (!this._instance) {
17
+ const types = [
18
+ ...Reflect.getMetadata(env_1.PARAMTYPES_METADATA, this.provider) || []
19
+ ];
20
+ const selfTypes = Reflect.getMetadata(env_1.SELF_DECLARED_DEPS_METADATA, this.provider) || [];
21
+ if (selfTypes.length > 0) {
22
+ selfTypes.forEach(({ index, token }) => {
23
+ types[index] = token;
24
+ });
25
+ }
26
+ const params = types.map((type) => {
27
+ const wrapper = this.module.getWrapper(type);
28
+ if (!wrapper) {
29
+ return undefined;
30
+ }
31
+ return wrapper.instance;
32
+ });
33
+ this._instance = new this.provider(...params);
34
+ }
35
+ return this._instance;
36
+ }
37
+ set instance(instance) {
38
+ this._instance = instance;
39
+ }
40
+ }
41
+ exports.InstanceWrapper = InstanceWrapper;
@@ -1,9 +1,8 @@
1
- import { DI } from "./DI";
2
- declare class Logger {
3
- static install(di: DI): void;
1
+ import { LogService } from "../services/LogService";
2
+ export declare class Logger {
3
+ static install(ls: LogService): void;
4
4
  static log(...data: any[]): void;
5
5
  static info(...data: any[]): void;
6
- static warning(...data: any[]): void;
6
+ static warn(...data: any[]): void;
7
7
  static error(...data: any[]): void;
8
8
  }
9
- export { Logger };
@@ -1,23 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Logger = void 0;
4
- const LogService_1 = require("../services/LogService");
5
- let _di;
4
+ let loggerService;
6
5
  class Logger {
7
- static install(di) {
8
- _di = di;
6
+ static install(ls) {
7
+ loggerService = ls;
9
8
  }
10
9
  static log(...data) {
11
- _di.resolveService(LogService_1.LogService).log(...data);
10
+ loggerService.log(...data);
12
11
  }
13
12
  static info(...data) {
14
- _di.resolveService(LogService_1.LogService).info(...data);
13
+ loggerService.info(...data);
15
14
  }
16
- static warning(...data) {
17
- _di.resolveService(LogService_1.LogService).warning(...data);
15
+ static warn(...data) {
16
+ loggerService.warn(...data);
18
17
  }
19
18
  static error(...data) {
20
- _di.resolveService(LogService_1.LogService).error(...data);
19
+ loggerService.error(...data);
21
20
  }
22
21
  }
23
22
  exports.Logger = Logger;
@@ -0,0 +1,17 @@
1
+ import { Provider } from "../types/Provider";
2
+ import { InstanceWrapper } from "./InstanceWrapper";
3
+ export declare class Module {
4
+ type: any;
5
+ parent?: Module | undefined;
6
+ imports: Set<any>;
7
+ controllers: Map<any, InstanceWrapper>;
8
+ providers: Map<any, InstanceWrapper>;
9
+ exports: Map<any, any>;
10
+ constructor(type: any, parent?: Module | undefined);
11
+ get<T = any>(type: any): T;
12
+ getWrapper(type: any): InstanceWrapper | undefined;
13
+ addImport(module: any): void;
14
+ addProvider(provider: Provider, instance?: any): void;
15
+ addInjection(): void;
16
+ addController(type: any): void;
17
+ }
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Module = void 0;
4
+ const InstanceWrapper_1 = require("./InstanceWrapper");
5
+ const env_1 = require("../env");
6
+ class Module {
7
+ constructor(type, parent) {
8
+ this.type = type;
9
+ this.parent = parent;
10
+ this.imports = new Set();
11
+ this.controllers = new Map();
12
+ this.providers = new Map();
13
+ this.exports = new Map();
14
+ }
15
+ get(type) {
16
+ const wrapper = this.getWrapper(type);
17
+ if (!wrapper) {
18
+ throw new Error("Provider not found");
19
+ }
20
+ return wrapper.instance;
21
+ }
22
+ getWrapper(type) {
23
+ const token = typeof type !== "string"
24
+ ? Reflect.getMetadata(env_1.INJECT_TOKEN_METADATA, type) || type
25
+ : type;
26
+ const wrapper = this.providers.get(token);
27
+ if (!wrapper && this.parent) {
28
+ return this.parent.getWrapper(type);
29
+ }
30
+ return wrapper;
31
+ }
32
+ addImport(module) {
33
+ this.imports.add(module);
34
+ }
35
+ addProvider(provider, instance) {
36
+ if ("provide" in provider && "useValue" in provider) {
37
+ const wrapper = new InstanceWrapper_1.InstanceWrapper(this, provider.provide, provider.provide, provider.useValue);
38
+ this.providers.set(provider.provide, wrapper);
39
+ return;
40
+ }
41
+ const token = Reflect.getMetadata("INJECT_TOKEN", provider) || provider;
42
+ const wrapper = new InstanceWrapper_1.InstanceWrapper(this, token, provider, instance);
43
+ this.providers.set(token, wrapper);
44
+ }
45
+ addInjection() {
46
+ //
47
+ }
48
+ addController(type) {
49
+ this.controllers.set(type, new InstanceWrapper_1.InstanceWrapper(this, type, type));
50
+ for (const name of Object.getOwnPropertyNames(type.prototype)) {
51
+ const descriptor = Object.getOwnPropertyDescriptor(type.prototype, name);
52
+ if (!descriptor) {
53
+ continue;
54
+ }
55
+ const command = Reflect.getMetadata("command", descriptor.value);
56
+ if (!command) {
57
+ continue;
58
+ }
59
+ // console.log(">", name, command);
60
+ }
61
+ }
62
+ }
63
+ exports.Module = Module;
@@ -1,6 +1,4 @@
1
1
  import { Cli } from "@kearisp/cli";
2
- import { Controller } from "./Controller";
3
- declare class Plugin extends Controller {
2
+ export declare class Plugin {
4
3
  install(cli: Cli): void;
5
4
  }
6
- export { Plugin };
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Plugin = void 0;
4
- const Controller_1 = require("./Controller");
5
- class Plugin extends Controller_1.Controller {
4
+ class Plugin {
6
5
  install(cli) {
7
- super.install(cli);
6
+ //
8
7
  }
9
8
  }
10
9
  exports.Plugin = Plugin;
@@ -1,6 +1,6 @@
1
- import { DI } from "../makes/DI";
1
+ import { DI } from "./DI";
2
2
  import { PresetServiceSearchOptions as SearchOptions } from "../services/PresetService";
3
- import { EnvConfig } from "../types/EnvConfig";
3
+ import { EnvConfig } from "../types";
4
4
  type TextOption = {
5
5
  type: "string" | "number" | "int";
6
6
  message?: string;
@@ -40,7 +40,7 @@ declare class Preset {
40
40
  save(): Promise<void>;
41
41
  getImageName(buildArgs?: EnvConfig): string;
42
42
  static install(di: DI): void;
43
- static search(options: SearchOptions): Promise<Preset[]>;
44
- static searchOne(options: SearchOptions): Promise<Preset | null | undefined>;
43
+ static search(options: SearchOptions): Promise<any[]>;
44
+ static searchOne(options: SearchOptions): Promise<any>;
45
45
  }
46
46
  export { Preset };
@@ -1,12 +1,11 @@
1
- import "reflect-metadata";
2
- import { DI } from "../makes/DI";
3
- import { EnvConfig } from "../types/EnvConfig";
1
+ import { PickProperties, EnvConfig } from "../types";
2
+ import { DI } from "./DI";
4
3
  type SearchOptions = {
5
4
  id: string;
6
5
  name: string;
7
6
  path: string;
8
7
  };
9
- declare class Project {
8
+ export declare class Project {
10
9
  id: string;
11
10
  name: string;
12
11
  type: string;
@@ -16,18 +15,23 @@ declare class Project {
16
15
  dockerfile?: string;
17
16
  scripts?: string[];
18
17
  buildArgs?: EnvConfig;
19
- env: EnvConfig;
20
- volumes?: string[];
18
+ env?: EnvConfig;
21
19
  ports?: string[];
22
- static di?: DI;
23
- constructor(data: any);
20
+ volumes?: string[];
21
+ metadata?: EnvConfig;
22
+ protected constructor(data: PickProperties<Project>);
23
+ get containerName(): string;
24
24
  hasEnv(name: string): boolean;
25
25
  getEnv(name: string, defaultValue?: string): string | undefined;
26
26
  setEnv(name: string, value: string | boolean): void;
27
27
  unsetEnv(name: string): void;
28
- volumeMount(...volumes: string[]): void;
28
+ hasMeta(name: string): boolean;
29
+ getMeta<D = string | undefined>(name: string, defaultValue?: D): D;
30
+ setMeta(name: string, value: string | boolean): void;
31
+ unsetMeta(name: string): void;
29
32
  getVolumeBySource(source: string): string | undefined;
30
33
  getVolumeByDestination(destination: string): string | undefined;
34
+ volumeMount(...volumes: string[]): void;
31
35
  volumeUnmount(...volumes: string[]): void;
32
36
  save(): Promise<void>;
33
37
  static install(di: DI): void;
@@ -35,6 +39,6 @@ declare class Project {
35
39
  static search(params?: Partial<SearchOptions>): Promise<Project[]>;
36
40
  static searchOne(params: Partial<SearchOptions>): Promise<Project | null>;
37
41
  }
38
- export { Project };
39
42
  export declare const PROJECT_TYPE_DOCKERFILE = "dockerfile";
40
43
  export declare const PROJECT_TYPE_IMAGE = "image";
44
+ export {};
@@ -10,11 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.PROJECT_TYPE_IMAGE = exports.PROJECT_TYPE_DOCKERFILE = exports.Project = void 0;
13
- require("reflect-metadata");
14
- const AppConfigService_1 = require("../services/AppConfigService");
15
- const ProjectService_1 = require("../services/ProjectService");
16
13
  const volumeParse_1 = require("../utils/volumeParse");
17
- let appConfig;
14
+ const services_1 = require("../services");
18
15
  let projectService;
19
16
  class Project {
20
17
  constructor(data) {
@@ -23,13 +20,18 @@ class Project {
23
20
  this.type = data.type;
24
21
  this.path = data.path;
25
22
  this.preset = data.preset;
26
- this.dockerfile = data.dockerfile;
27
23
  this.imageName = data.imageName;
24
+ this.dockerfile = data.dockerfile;
28
25
  this.scripts = data.scripts;
29
26
  this.buildArgs = data.buildArgs;
30
- this.env = data.env || {};
27
+ this.env = data.env;
31
28
  this.ports = data.ports;
32
29
  this.volumes = data.volumes;
30
+ this.metadata = data.metadata;
31
+ Object.assign(this, data);
32
+ }
33
+ get containerName() {
34
+ return `${this.name}.workspace`;
33
35
  }
34
36
  hasEnv(name) {
35
37
  if (!this.env) {
@@ -38,18 +40,63 @@ class Project {
38
40
  return this.env.hasOwnProperty(name);
39
41
  }
40
42
  getEnv(name, defaultValue) {
41
- const { [name]: value = defaultValue } = this.env;
43
+ const { [name]: value = defaultValue } = this.env || {};
42
44
  return value;
43
45
  }
44
46
  setEnv(name, value) {
45
- this.env = Object.assign(Object.assign({}, this.env), { [name]: typeof value === "boolean"
46
- ? (value ? "true" : "false")
47
- : value });
47
+ if (!this.env) {
48
+ this.env = {};
49
+ }
50
+ this.env[name] = typeof value === "boolean"
51
+ ? (value ? "true" : "false")
52
+ : value;
48
53
  }
49
54
  unsetEnv(name) {
55
+ if (!this.env) {
56
+ return;
57
+ }
50
58
  if (name in this.env) {
51
59
  delete this.env[name];
52
60
  }
61
+ if (Object.keys(this.env).length === 0) {
62
+ delete this.env;
63
+ }
64
+ }
65
+ hasMeta(name) {
66
+ return !!this.metadata && this.metadata.hasOwnProperty(name);
67
+ }
68
+ getMeta(name, defaultValue) {
69
+ const { [name]: value = defaultValue } = this.metadata || {};
70
+ return value;
71
+ }
72
+ setMeta(name, value) {
73
+ if (!this.metadata) {
74
+ this.metadata = {};
75
+ }
76
+ this.metadata[name] = typeof value === "boolean"
77
+ ? (value ? "true" : "false")
78
+ : value;
79
+ }
80
+ unsetMeta(name) {
81
+ if (!this.metadata) {
82
+ return;
83
+ }
84
+ if (name in this.metadata) {
85
+ delete this.metadata[name];
86
+ }
87
+ if (Object.keys(this.metadata).length === 0) {
88
+ delete this.metadata;
89
+ }
90
+ }
91
+ getVolumeBySource(source) {
92
+ return (this.volumes || []).find((volume) => {
93
+ return (0, volumeParse_1.volumeParse)(volume).source === source;
94
+ });
95
+ }
96
+ getVolumeByDestination(destination) {
97
+ return (this.volumes || []).find((volume) => {
98
+ return (0, volumeParse_1.volumeParse)(volume).destination === destination;
99
+ });
53
100
  }
54
101
  volumeMount(...volumes) {
55
102
  if (volumes.length === 0) {
@@ -65,16 +112,6 @@ class Project {
65
112
  ];
66
113
  this.volumeMount(...restVolumes);
67
114
  }
68
- getVolumeBySource(source) {
69
- return (this.volumes || []).find((volume) => {
70
- return (0, volumeParse_1.volumeParse)(volume).source === source;
71
- });
72
- }
73
- getVolumeByDestination(destination) {
74
- return (this.volumes || []).find((volume) => {
75
- return (0, volumeParse_1.volumeParse)(volume).destination === destination;
76
- });
77
- }
78
115
  volumeUnmount(...volumes) {
79
116
  this.volumes = (this.volumes || []).filter((mounted) => {
80
117
  return !volumes.includes(mounted);
@@ -89,14 +126,13 @@ class Project {
89
126
  });
90
127
  }
91
128
  static install(di) {
92
- appConfig = di.resolveService(AppConfigService_1.AppConfigService);
93
- projectService = di.resolveService(ProjectService_1.ProjectService);
129
+ projectService = di.resolveService(services_1.ProjectService);
94
130
  }
95
131
  static fromObject(data) {
96
132
  return new Project(data);
97
133
  }
98
- static search(params = {}) {
99
- return __awaiter(this, void 0, void 0, function* () {
134
+ static search() {
135
+ return __awaiter(this, arguments, void 0, function* (params = {}) {
100
136
  if (!projectService) {
101
137
  throw new Error("Dependency is missing");
102
138
  }
@@ -0,0 +1,4 @@
1
+ export declare class Scanner {
2
+ constructor();
3
+ scan(module: any): void;
4
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Scanner = void 0;
4
+ class Scanner {
5
+ constructor() { }
6
+ scan(module) {
7
+ }
8
+ }
9
+ exports.Scanner = Scanner;
@@ -0,0 +1,9 @@
1
+ export * from "./Container";
2
+ export * from "./DI";
3
+ export * from "./FS";
4
+ export * from "./FSManager";
5
+ export * from "./Logger";
6
+ export * from "./Plugin";
7
+ export * from "./Preset";
8
+ export * from "./Project";
9
+ export * from "./Factory";
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Container"), exports);
18
+ __exportStar(require("./DI"), exports);
19
+ __exportStar(require("./FS"), exports);
20
+ __exportStar(require("./FSManager"), exports);
21
+ __exportStar(require("./Logger"), exports);
22
+ __exportStar(require("./Plugin"), exports);
23
+ __exportStar(require("./Preset"), exports);
24
+ __exportStar(require("./Project"), exports);
25
+ __exportStar(require("./Factory"), exports);
@@ -1,4 +1,4 @@
1
- import { AppConfig } from "../types/AppConfig";
1
+ import { AppConfig } from "../types";
2
2
  type TypeMap = {
3
3
  [type: string]: string;
4
4
  };