@wocker/core 1.0.23-beta.2 → 1.0.24-beta.0
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.
- package/lib/core/Container.d.ts +8 -7
- package/lib/core/Container.js +17 -5
- package/lib/core/ControllerWrapper.d.ts +3 -3
- package/lib/core/ControllerWrapper.js +4 -4
- package/lib/core/InstanceWrapper.d.ts +12 -9
- package/lib/core/InstanceWrapper.js +35 -17
- package/lib/core/{Module.d.ts → ModuleWrapper.d.ts} +5 -4
- package/lib/core/{Module.js → ModuleWrapper.js} +13 -6
- package/lib/core/Scanner.d.ts +6 -6
- package/lib/core/Scanner.js +3 -3
- package/lib/decorators/Module.d.ts +2 -2
- package/lib/env.d.ts +2 -0
- package/lib/env.js +3 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +6 -1
- package/lib/services/AppConfigService.d.ts +40 -7
- package/lib/services/AppConfigService.js +131 -4
- package/lib/services/AppFileSystemService.d.ts +4 -0
- package/lib/services/AppFileSystemService.js +29 -0
- package/lib/services/AppService.d.ts +20 -0
- package/lib/services/AppService.js +62 -0
- package/lib/services/EventService.d.ts +9 -0
- package/lib/services/EventService.js +53 -0
- package/lib/services/LogService.d.ts +14 -6
- package/lib/services/LogService.js +47 -1
- package/lib/services/PluginConfigService.js +3 -1
- package/lib/services/{PluginFileSystem.d.ts → PluginFileSystemService.d.ts} +1 -1
- package/lib/services/{PluginFileSystem.js → PluginFileSystemService.js} +5 -5
- package/lib/services/PresetService.d.ts +5 -2
- package/lib/services/PresetService.js +0 -15
- package/lib/services/ProcessService.d.ts +5 -0
- package/lib/services/{AppEventsService.js → ProcessService.js} +19 -6
- package/lib/services/ProjectService.d.ts +8 -6
- package/lib/services/ProjectService.js +7 -14
- package/lib/services/index.d.ts +5 -1
- package/lib/services/index.js +5 -1
- package/lib/types/{Provider.d.ts → ProviderType.d.ts} +1 -1
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.js +2 -0
- package/package.json +2 -1
- package/lib/services/AppEventsService.d.ts +0 -6
- /package/lib/types/{Provider.js → ProviderType.js} +0 -0
package/lib/core/Container.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { InstanceWrapper } from "./InstanceWrapper";
|
|
2
|
-
import {
|
|
3
|
-
import { InjectionToken } from "../types
|
|
2
|
+
import { ModuleWrapper } from "./ModuleWrapper";
|
|
3
|
+
import { InjectionToken, ProviderType } from "../types";
|
|
4
4
|
import { Type } from "../types/Type";
|
|
5
5
|
export declare class Container {
|
|
6
|
-
readonly modules: Map<Type,
|
|
7
|
-
readonly
|
|
6
|
+
readonly modules: Map<Type, ModuleWrapper>;
|
|
7
|
+
readonly globalProviders: Map<InjectionToken, InstanceWrapper>;
|
|
8
8
|
constructor();
|
|
9
|
-
addModule<TInput = any>(type: Type<TInput>, module:
|
|
9
|
+
addModule<TInput = any>(type: Type<TInput>, module: ModuleWrapper): void;
|
|
10
10
|
hasModule<TInput = any>(type: Type<TInput>): boolean;
|
|
11
|
-
getModule<TInput = any>(type: Type<TInput>):
|
|
12
|
-
addProvider(type:
|
|
11
|
+
getModule<TInput = any>(type: Type<TInput>): ModuleWrapper<TInput>;
|
|
12
|
+
addProvider(type: InjectionToken, wrapper: InstanceWrapper): void;
|
|
13
|
+
replace(type: InjectionToken, provider: ProviderType): void;
|
|
13
14
|
}
|
package/lib/core/Container.js
CHANGED
|
@@ -3,14 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Container = void 0;
|
|
4
4
|
const cli_1 = require("@kearisp/cli");
|
|
5
5
|
const InstanceWrapper_1 = require("./InstanceWrapper");
|
|
6
|
-
const
|
|
6
|
+
const ModuleWrapper_1 = require("./ModuleWrapper");
|
|
7
7
|
const env_1 = require("../env");
|
|
8
8
|
class Container {
|
|
9
9
|
constructor() {
|
|
10
10
|
this.modules = new Map();
|
|
11
|
-
this.
|
|
12
|
-
const cliWrapper = new InstanceWrapper_1.InstanceWrapper(new
|
|
13
|
-
this.
|
|
11
|
+
this.globalProviders = new Map();
|
|
12
|
+
const cliWrapper = new InstanceWrapper_1.InstanceWrapper(new ModuleWrapper_1.ModuleWrapper(this, null), cli_1.Cli);
|
|
13
|
+
this.globalProviders.set(cli_1.Cli, cliWrapper);
|
|
14
14
|
}
|
|
15
15
|
addModule(type, module) {
|
|
16
16
|
this.modules.set(type, module);
|
|
@@ -29,7 +29,19 @@ class Container {
|
|
|
29
29
|
const token = typeof type !== "string"
|
|
30
30
|
? Reflect.getMetadata(env_1.INJECT_TOKEN_METADATA, type) || type
|
|
31
31
|
: type;
|
|
32
|
-
this.
|
|
32
|
+
this.globalProviders.set(token, wrapper);
|
|
33
|
+
}
|
|
34
|
+
replace(type, provider) {
|
|
35
|
+
const token = typeof type !== "string"
|
|
36
|
+
? Reflect.getMetadata(env_1.INJECT_TOKEN_METADATA, type) || type
|
|
37
|
+
: type;
|
|
38
|
+
const wrapper = this.globalProviders.get(token);
|
|
39
|
+
if (wrapper) {
|
|
40
|
+
wrapper.replace(provider);
|
|
41
|
+
}
|
|
42
|
+
this.modules.forEach((moduleRef) => {
|
|
43
|
+
moduleRef.replace(token, provider);
|
|
44
|
+
});
|
|
33
45
|
}
|
|
34
46
|
}
|
|
35
47
|
exports.Container = Container;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
2
|
import { CommandInput } from "@kearisp/cli";
|
|
3
3
|
import { InstanceWrapper } from "./InstanceWrapper";
|
|
4
|
-
import {
|
|
4
|
+
import { ModuleWrapper } from "./ModuleWrapper";
|
|
5
5
|
import { Type } from "../types/Type";
|
|
6
6
|
import { Route } from "./Route";
|
|
7
7
|
export declare class ControllerWrapper<TInput = any> extends InstanceWrapper {
|
|
8
|
-
readonly
|
|
8
|
+
readonly _type: Type<TInput>;
|
|
9
9
|
description?: string;
|
|
10
10
|
commands: Route[];
|
|
11
11
|
completions: Route[];
|
|
12
|
-
constructor(module:
|
|
12
|
+
constructor(module: ModuleWrapper, type: Type<TInput>);
|
|
13
13
|
getCompletionCommands(name: string, command: string): Route[];
|
|
14
14
|
run(route: Route, input: CommandInput): any;
|
|
15
15
|
}
|
|
@@ -10,12 +10,12 @@ class ControllerWrapper extends InstanceWrapper_1.InstanceWrapper {
|
|
|
10
10
|
super(module, type);
|
|
11
11
|
this.commands = [];
|
|
12
12
|
this.completions = [];
|
|
13
|
-
if (!this.
|
|
13
|
+
if (!this._type) {
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
|
-
this.description = Reflect.getMetadata(env_1.DESCRIPTION_METADATA, this.
|
|
17
|
-
for (const method of Object.getOwnPropertyNames(this.
|
|
18
|
-
const route = new Route_1.Route(this.
|
|
16
|
+
this.description = Reflect.getMetadata(env_1.DESCRIPTION_METADATA, this._type) || "";
|
|
17
|
+
for (const method of Object.getOwnPropertyNames(this._type.prototype)) {
|
|
18
|
+
const route = new Route_1.Route(this._type, method);
|
|
19
19
|
if (route.isCommand) {
|
|
20
20
|
this.commands.push(route);
|
|
21
21
|
}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ModuleWrapper } from "./ModuleWrapper";
|
|
2
|
+
import { ProviderType, InjectionToken } from "../types";
|
|
3
3
|
import { Type } from "../types/Type";
|
|
4
|
-
import { InjectionToken } from "../types/InjectionToken";
|
|
5
4
|
export declare class InstanceWrapper<TInput = any> {
|
|
6
|
-
protected readonly module:
|
|
7
|
-
protected readonly provider:
|
|
8
|
-
protected
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
constructor(module:
|
|
5
|
+
protected readonly module: ModuleWrapper;
|
|
6
|
+
protected readonly provider: ProviderType<TInput>;
|
|
7
|
+
protected _token: InjectionToken<TInput>;
|
|
8
|
+
protected _type?: Type<TInput>;
|
|
9
|
+
protected _instance?: TInput;
|
|
10
|
+
constructor(module: ModuleWrapper, provider: ProviderType<TInput>);
|
|
11
|
+
protected normalizeProvider(provider: ProviderType): any[];
|
|
12
|
+
get type(): Type<TInput> | undefined;
|
|
13
|
+
get token(): InjectionToken<TInput>;
|
|
12
14
|
get instance(): TInput;
|
|
15
|
+
replace(provider: ProviderType<TInput>): void;
|
|
13
16
|
}
|
|
@@ -3,30 +3,42 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.InstanceWrapper = void 0;
|
|
4
4
|
const env_1 = require("../env");
|
|
5
5
|
class InstanceWrapper {
|
|
6
|
-
constructor(module, provider
|
|
6
|
+
constructor(module, provider) {
|
|
7
7
|
this.module = module;
|
|
8
8
|
this.provider = provider;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
const [token, type, instance] = this.normalizeProvider(provider);
|
|
10
|
+
this._token = token;
|
|
11
|
+
this._type = type;
|
|
12
|
+
this._instance = instance;
|
|
13
|
+
}
|
|
14
|
+
normalizeProvider(provider) {
|
|
15
|
+
if (provider && typeof provider === "object") {
|
|
16
|
+
if ("provide" in provider && "useValue" in provider) {
|
|
17
|
+
return [provider.provide, null, provider.useValue];
|
|
18
|
+
}
|
|
19
|
+
if ("provide" in provider && "useClass" in provider) {
|
|
20
|
+
return [provider.provide, provider.useClass, null];
|
|
21
|
+
}
|
|
19
22
|
}
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
return [
|
|
24
|
+
Reflect.getMetadata(env_1.INJECT_TOKEN_METADATA, provider) || provider,
|
|
25
|
+
provider,
|
|
26
|
+
null
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
get type() {
|
|
30
|
+
return this._type;
|
|
31
|
+
}
|
|
32
|
+
get token() {
|
|
33
|
+
return this._token;
|
|
22
34
|
}
|
|
23
35
|
get instance() {
|
|
24
36
|
if (!this._instance) {
|
|
25
|
-
if (!this.
|
|
37
|
+
if (!this._type) {
|
|
26
38
|
throw new Error("Type not defined");
|
|
27
39
|
}
|
|
28
|
-
const types = Reflect.getMetadata(env_1.PARAMTYPES_METADATA, this.
|
|
29
|
-
const selfTypes = Reflect.getMetadata(env_1.SELF_DECLARED_DEPS_METADATA, this.
|
|
40
|
+
const types = Reflect.getMetadata(env_1.PARAMTYPES_METADATA, this._type) || [];
|
|
41
|
+
const selfTypes = Reflect.getMetadata(env_1.SELF_DECLARED_DEPS_METADATA, this._type) || [];
|
|
30
42
|
if (selfTypes.length > 0) {
|
|
31
43
|
selfTypes.forEach(({ index, token }) => {
|
|
32
44
|
types[index] = token;
|
|
@@ -35,9 +47,15 @@ class InstanceWrapper {
|
|
|
35
47
|
const params = types.map((type) => {
|
|
36
48
|
return this.module.get(type);
|
|
37
49
|
});
|
|
38
|
-
this._instance = new this.
|
|
50
|
+
this._instance = new this._type(...params);
|
|
39
51
|
}
|
|
40
52
|
return this._instance;
|
|
41
53
|
}
|
|
54
|
+
replace(provider) {
|
|
55
|
+
const [token, type, instance] = this.normalizeProvider(provider);
|
|
56
|
+
this._token = token;
|
|
57
|
+
this._type = type;
|
|
58
|
+
this._instance = instance;
|
|
59
|
+
}
|
|
42
60
|
}
|
|
43
61
|
exports.InstanceWrapper = InstanceWrapper;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InjectionToken, ProviderType } from "../types";
|
|
2
2
|
import { Type } from "../types/Type";
|
|
3
3
|
import { Container } from "./Container";
|
|
4
4
|
import { InstanceWrapper } from "./InstanceWrapper";
|
|
5
5
|
import { ControllerWrapper } from "./ControllerWrapper";
|
|
6
|
-
export declare class
|
|
6
|
+
export declare class ModuleWrapper<TInput = any> {
|
|
7
7
|
readonly container: Container;
|
|
8
8
|
readonly type: TInput;
|
|
9
9
|
imports: Map<any, InstanceWrapper>;
|
|
@@ -12,8 +12,9 @@ export declare class Module<TInput = any> {
|
|
|
12
12
|
exports: Set<any>;
|
|
13
13
|
constructor(container: Container, type: TInput);
|
|
14
14
|
get<TInput = any, TResult = TInput>(type: Type<TInput> | Function | string | symbol): TResult;
|
|
15
|
-
getWrapper(type:
|
|
16
|
-
addProvider(provider:
|
|
15
|
+
getWrapper(type: InjectionToken): InstanceWrapper | undefined;
|
|
16
|
+
addProvider(provider: ProviderType): void;
|
|
17
17
|
addController(type: any): void;
|
|
18
18
|
addExport(type: any): void;
|
|
19
|
+
replace(token: InjectionToken, provider: ProviderType): void;
|
|
19
20
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ModuleWrapper = void 0;
|
|
4
4
|
const InstanceWrapper_1 = require("./InstanceWrapper");
|
|
5
5
|
const ControllerWrapper_1 = require("./ControllerWrapper");
|
|
6
6
|
const env_1 = require("../env");
|
|
7
|
-
class
|
|
7
|
+
class ModuleWrapper {
|
|
8
8
|
constructor(container, type) {
|
|
9
9
|
this.container = container;
|
|
10
10
|
this.type = type;
|
|
@@ -32,12 +32,12 @@ class Module {
|
|
|
32
32
|
: type;
|
|
33
33
|
const wrapper = this.providers.get(token);
|
|
34
34
|
if (!wrapper) {
|
|
35
|
-
return this.container.
|
|
35
|
+
return this.container.globalProviders.get(token);
|
|
36
36
|
}
|
|
37
37
|
return wrapper;
|
|
38
38
|
}
|
|
39
|
-
addProvider(provider
|
|
40
|
-
const wrapper = new InstanceWrapper_1.InstanceWrapper(this, provider
|
|
39
|
+
addProvider(provider) {
|
|
40
|
+
const wrapper = new InstanceWrapper_1.InstanceWrapper(this, provider);
|
|
41
41
|
this.providers.set(wrapper.token, wrapper);
|
|
42
42
|
}
|
|
43
43
|
addController(type) {
|
|
@@ -50,5 +50,12 @@ class Module {
|
|
|
50
50
|
: type;
|
|
51
51
|
this.exports.add(token);
|
|
52
52
|
}
|
|
53
|
+
replace(token, provider) {
|
|
54
|
+
const wrapper = this.getWrapper(token);
|
|
55
|
+
if (!wrapper) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
wrapper.replace(provider);
|
|
59
|
+
}
|
|
53
60
|
}
|
|
54
|
-
exports.
|
|
61
|
+
exports.ModuleWrapper = ModuleWrapper;
|
package/lib/core/Scanner.d.ts
CHANGED
|
@@ -2,16 +2,16 @@ import "reflect-metadata";
|
|
|
2
2
|
import { Cli } from "@kearisp/cli";
|
|
3
3
|
import { Container } from "./Container";
|
|
4
4
|
import { ControllerWrapper } from "./ControllerWrapper";
|
|
5
|
-
import {
|
|
5
|
+
import { ModuleWrapper } from "./ModuleWrapper";
|
|
6
6
|
export declare class Scanner {
|
|
7
7
|
readonly container: Container;
|
|
8
8
|
constructor();
|
|
9
9
|
scan(moduleType: any): Promise<void>;
|
|
10
|
-
protected scanModule(moduleType: any):
|
|
11
|
-
protected scanControllers(module:
|
|
12
|
-
protected scanProviders(module:
|
|
13
|
-
protected scanImports(module:
|
|
14
|
-
protected scanExports(module:
|
|
10
|
+
protected scanModule(moduleType: any): ModuleWrapper;
|
|
11
|
+
protected scanControllers(module: ModuleWrapper): void;
|
|
12
|
+
protected scanProviders(module: ModuleWrapper): void;
|
|
13
|
+
protected scanImports(module: ModuleWrapper): void;
|
|
14
|
+
protected scanExports(module: ModuleWrapper): void;
|
|
15
15
|
protected scanRoutes(): void;
|
|
16
16
|
protected scanControllerRoutes(cli: Cli, wrapper: ControllerWrapper): void;
|
|
17
17
|
protected scanDynamicModules(): Promise<void>;
|
package/lib/core/Scanner.js
CHANGED
|
@@ -13,7 +13,7 @@ exports.Scanner = void 0;
|
|
|
13
13
|
require("reflect-metadata");
|
|
14
14
|
const cli_1 = require("@kearisp/cli");
|
|
15
15
|
const Container_1 = require("./Container");
|
|
16
|
-
const
|
|
16
|
+
const ModuleWrapper_1 = require("./ModuleWrapper");
|
|
17
17
|
const env_1 = require("../env");
|
|
18
18
|
class Scanner {
|
|
19
19
|
constructor() {
|
|
@@ -31,7 +31,7 @@ class Scanner {
|
|
|
31
31
|
? this.container.getModule(moduleType)
|
|
32
32
|
: null;
|
|
33
33
|
if (!module) {
|
|
34
|
-
module = new
|
|
34
|
+
module = new ModuleWrapper_1.ModuleWrapper(this.container, moduleType);
|
|
35
35
|
this.container.addModule(moduleType, module);
|
|
36
36
|
this.scanImports(module);
|
|
37
37
|
this.scanControllers(module);
|
|
@@ -79,7 +79,7 @@ class Scanner {
|
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
scanRoutes() {
|
|
82
|
-
const cliWrapper = this.container.
|
|
82
|
+
const cliWrapper = this.container.globalProviders.get(cli_1.Cli);
|
|
83
83
|
if (!cliWrapper) {
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { MODULE_METADATA } from "../env";
|
|
2
|
-
import {
|
|
2
|
+
import { ProviderType } from "../types/ProviderType";
|
|
3
3
|
export type ModuleMetadata = {
|
|
4
4
|
[MODULE_METADATA.CONTROLLERS]?: any[];
|
|
5
|
-
[MODULE_METADATA.PROVIDERS]?:
|
|
5
|
+
[MODULE_METADATA.PROVIDERS]?: ProviderType[];
|
|
6
6
|
[MODULE_METADATA.IMPORTS]?: any[];
|
|
7
7
|
[MODULE_METADATA.EXPORTS]?: any[];
|
|
8
8
|
};
|
package/lib/env.d.ts
CHANGED
package/lib/env.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DATA_DIR = 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.ALIAS_METADATA = exports.ARGS_METADATA = exports.COMPLETION_METADATA = exports.COMMAND_METADATA = exports.DESCRIPTION_METADATA = exports.INJECTABLE_WATERMARK = exports.IS_MODULE_METADATA = exports.IS_GLOBAL_METADATA = void 0;
|
|
6
|
+
exports.WOCKER_DATA_DIR_KEY = exports.WOCKER_VERSION_KEY = exports.DATA_DIR = 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.ALIAS_METADATA = exports.ARGS_METADATA = exports.COMPLETION_METADATA = exports.COMMAND_METADATA = exports.DESCRIPTION_METADATA = exports.INJECTABLE_WATERMARK = exports.IS_MODULE_METADATA = exports.IS_GLOBAL_METADATA = void 0;
|
|
7
7
|
const os_1 = __importDefault(require("os"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
exports.IS_GLOBAL_METADATA = "IS_GLOBAL";
|
|
@@ -28,3 +28,5 @@ var MODULE_METADATA;
|
|
|
28
28
|
MODULE_METADATA["PROVIDERS"] = "providers";
|
|
29
29
|
})(MODULE_METADATA || (exports.MODULE_METADATA = MODULE_METADATA = {}));
|
|
30
30
|
exports.DATA_DIR = process.env.WS_DIR || path_1.default.join(os_1.default.homedir(), ".workspace");
|
|
31
|
+
exports.WOCKER_VERSION_KEY = "__WOCKER_VERSION__";
|
|
32
|
+
exports.WOCKER_DATA_DIR_KEY = "__WOCKER_DATA_DIR__";
|
package/lib/index.d.ts
CHANGED
|
@@ -5,5 +5,6 @@ export * from "./decorators";
|
|
|
5
5
|
export * from "./exceptions";
|
|
6
6
|
export * from "./makes";
|
|
7
7
|
export * from "./services";
|
|
8
|
+
export { EventService as AppEventsService } from "./services";
|
|
8
9
|
export * from "./types";
|
|
9
|
-
export { IS_MODULE_METADATA, MODULE_METADATA, PLUGIN_NAME_METADATA, PLUGIN_DIR_KEY } from "./env";
|
|
10
|
+
export { IS_MODULE_METADATA, MODULE_METADATA, PLUGIN_NAME_METADATA, PLUGIN_DIR_KEY, WOCKER_VERSION_KEY, WOCKER_DATA_DIR_KEY } from "./env";
|
package/lib/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.PLUGIN_DIR_KEY = exports.PLUGIN_NAME_METADATA = exports.MODULE_METADATA = exports.IS_MODULE_METADATA = exports.CommandNotFoundError = exports.Cli = void 0;
|
|
17
|
+
exports.WOCKER_DATA_DIR_KEY = exports.WOCKER_VERSION_KEY = exports.PLUGIN_DIR_KEY = exports.PLUGIN_NAME_METADATA = exports.MODULE_METADATA = exports.IS_MODULE_METADATA = exports.AppEventsService = exports.CommandNotFoundError = exports.Cli = void 0;
|
|
18
18
|
require("reflect-metadata");
|
|
19
19
|
var cli_1 = require("@kearisp/cli");
|
|
20
20
|
Object.defineProperty(exports, "Cli", { enumerable: true, get: function () { return cli_1.Cli; } });
|
|
@@ -24,9 +24,14 @@ __exportStar(require("./decorators"), exports);
|
|
|
24
24
|
__exportStar(require("./exceptions"), exports);
|
|
25
25
|
__exportStar(require("./makes"), exports);
|
|
26
26
|
__exportStar(require("./services"), exports);
|
|
27
|
+
var services_1 = require("./services");
|
|
28
|
+
// @deprecated
|
|
29
|
+
Object.defineProperty(exports, "AppEventsService", { enumerable: true, get: function () { return services_1.EventService; } });
|
|
27
30
|
__exportStar(require("./types"), exports);
|
|
28
31
|
var env_1 = require("./env");
|
|
29
32
|
Object.defineProperty(exports, "IS_MODULE_METADATA", { enumerable: true, get: function () { return env_1.IS_MODULE_METADATA; } });
|
|
30
33
|
Object.defineProperty(exports, "MODULE_METADATA", { enumerable: true, get: function () { return env_1.MODULE_METADATA; } });
|
|
31
34
|
Object.defineProperty(exports, "PLUGIN_NAME_METADATA", { enumerable: true, get: function () { return env_1.PLUGIN_NAME_METADATA; } });
|
|
32
35
|
Object.defineProperty(exports, "PLUGIN_DIR_KEY", { enumerable: true, get: function () { return env_1.PLUGIN_DIR_KEY; } });
|
|
36
|
+
Object.defineProperty(exports, "WOCKER_VERSION_KEY", { enumerable: true, get: function () { return env_1.WOCKER_VERSION_KEY; } });
|
|
37
|
+
Object.defineProperty(exports, "WOCKER_DATA_DIR_KEY", { enumerable: true, get: function () { return env_1.WOCKER_DATA_DIR_KEY; } });
|
|
@@ -1,12 +1,41 @@
|
|
|
1
1
|
import { AppConfig, PresetSource } from "../makes";
|
|
2
|
-
|
|
2
|
+
import { ProjectRef } from "../types/ProjectRef";
|
|
3
|
+
import { PluginRef } from "../types/PluginRef";
|
|
4
|
+
import { AppFileSystemService } from "./AppFileSystemService";
|
|
5
|
+
import { ProcessService } from "./ProcessService";
|
|
6
|
+
type TypeMap = {
|
|
7
|
+
[type: string]: string;
|
|
8
|
+
};
|
|
9
|
+
export declare class AppConfigService {
|
|
10
|
+
readonly version: string;
|
|
11
|
+
protected readonly processService: ProcessService;
|
|
12
|
+
readonly fs: AppFileSystemService;
|
|
13
|
+
protected _pwd: string;
|
|
14
|
+
protected _config?: AppConfig;
|
|
15
|
+
protected readonly mapTypes: TypeMap;
|
|
16
|
+
constructor(version: string, processService: ProcessService, fs: AppFileSystemService);
|
|
3
17
|
get experimentalFeatures(): string[];
|
|
4
|
-
|
|
5
|
-
|
|
18
|
+
get debug(): boolean;
|
|
19
|
+
set debug(debug: boolean);
|
|
20
|
+
get config(): AppConfig;
|
|
21
|
+
get projects(): ProjectRef[];
|
|
22
|
+
get plugins(): PluginRef[];
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated
|
|
25
|
+
*/
|
|
6
26
|
isVersionGTE(version: string): boolean;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated
|
|
29
|
+
*/
|
|
30
|
+
pwd(...parts: string[]): string;
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated
|
|
33
|
+
*/
|
|
34
|
+
setPWD(pwd: string): void;
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated
|
|
37
|
+
*/
|
|
38
|
+
dataPath(...args: string[]): string;
|
|
10
39
|
/**
|
|
11
40
|
* @deprecated
|
|
12
41
|
*/
|
|
@@ -15,9 +44,13 @@ export declare abstract class AppConfigService {
|
|
|
15
44
|
removeProject(id: string): void;
|
|
16
45
|
registerPreset(name: string, source: PresetSource, path?: string): void;
|
|
17
46
|
unregisterPreset(name: string): void;
|
|
47
|
+
addPlugin(name: string, env?: PluginRef["env"]): void;
|
|
48
|
+
removePlugin(name: string): void;
|
|
18
49
|
getMeta(name: string, byDefault?: string): string | undefined;
|
|
19
50
|
getMeta(name: string, byDefault: string): string;
|
|
20
51
|
setMeta(name: string, value: string): void;
|
|
21
52
|
unsetMeta(name: string): void;
|
|
22
|
-
|
|
53
|
+
getProjectTypes(): TypeMap;
|
|
54
|
+
save(): void;
|
|
23
55
|
}
|
|
56
|
+
export {};
|
|
@@ -5,18 +5,97 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
8
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
18
|
exports.AppConfigService = void 0;
|
|
19
|
+
const path_1 = __importDefault(require("path"));
|
|
10
20
|
const decorators_1 = require("../decorators");
|
|
21
|
+
const makes_1 = require("../makes");
|
|
22
|
+
const AppFileSystemService_1 = require("./AppFileSystemService");
|
|
23
|
+
const ProcessService_1 = require("./ProcessService");
|
|
24
|
+
const env_1 = require("../env");
|
|
11
25
|
let AppConfigService = class AppConfigService {
|
|
26
|
+
constructor(version, processService, fs) {
|
|
27
|
+
this.version = version;
|
|
28
|
+
this.processService = processService;
|
|
29
|
+
this.fs = fs;
|
|
30
|
+
this.mapTypes = {
|
|
31
|
+
[makes_1.PROJECT_TYPE_PRESET]: "Preset",
|
|
32
|
+
[makes_1.PROJECT_TYPE_IMAGE]: "Image",
|
|
33
|
+
[makes_1.PROJECT_TYPE_DOCKERFILE]: "Dockerfile"
|
|
34
|
+
};
|
|
35
|
+
this._pwd = (process.cwd() || process.env.PWD);
|
|
36
|
+
}
|
|
12
37
|
get experimentalFeatures() {
|
|
13
38
|
return [
|
|
14
39
|
"projectComposeType"
|
|
15
40
|
];
|
|
16
41
|
}
|
|
17
|
-
get
|
|
18
|
-
return
|
|
42
|
+
get debug() {
|
|
43
|
+
return this.config.debug || false;
|
|
44
|
+
}
|
|
45
|
+
set debug(debug) {
|
|
46
|
+
this.config.debug = debug;
|
|
19
47
|
}
|
|
48
|
+
get config() {
|
|
49
|
+
if (!this._config) {
|
|
50
|
+
let data = {};
|
|
51
|
+
if (this.fs.exists("wocker.config.js")) {
|
|
52
|
+
try {
|
|
53
|
+
const { config } = require(this.fs.path("wocker.config.js"));
|
|
54
|
+
data = config;
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
// TODO: Log somehow
|
|
58
|
+
// this.logService.error(err);
|
|
59
|
+
if (this.fs.exists("wocker.config.json")) {
|
|
60
|
+
let json = this.fs.readJSON("wocker.config.json");
|
|
61
|
+
if (typeof json === "string") {
|
|
62
|
+
json = JSON.parse(json);
|
|
63
|
+
}
|
|
64
|
+
data = json;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else if (this.fs.exists("wocker.config.json")) {
|
|
69
|
+
data = this.fs.readJSON("wocker.config.json");
|
|
70
|
+
}
|
|
71
|
+
else if (this.fs.exists("wocker.json")) {
|
|
72
|
+
let json = this.fs.readJSON("wocker.json");
|
|
73
|
+
if (typeof json === "string") {
|
|
74
|
+
json = JSON.parse(json);
|
|
75
|
+
}
|
|
76
|
+
data = json;
|
|
77
|
+
}
|
|
78
|
+
else if (this.fs.exists("data.json")) {
|
|
79
|
+
data = this.fs.readJSON("data.json");
|
|
80
|
+
}
|
|
81
|
+
else if (!this.fs.exists()) {
|
|
82
|
+
this.fs.mkdir("", {
|
|
83
|
+
recursive: true
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
this._config = new makes_1.AppConfig(data);
|
|
87
|
+
}
|
|
88
|
+
return this._config;
|
|
89
|
+
}
|
|
90
|
+
get projects() {
|
|
91
|
+
return this.config.projects;
|
|
92
|
+
}
|
|
93
|
+
get plugins() {
|
|
94
|
+
return this.config.plugins;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* @deprecated
|
|
98
|
+
*/
|
|
20
99
|
isVersionGTE(version) {
|
|
21
100
|
const current = this.version.split(".").map(Number);
|
|
22
101
|
const compare = version.split(".").map(Number);
|
|
@@ -30,6 +109,24 @@ let AppConfigService = class AppConfigService {
|
|
|
30
109
|
}
|
|
31
110
|
return true;
|
|
32
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* @deprecated
|
|
114
|
+
*/
|
|
115
|
+
pwd(...parts) {
|
|
116
|
+
return this.processService.pwd(path_1.default.join(...parts));
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* @deprecated
|
|
120
|
+
*/
|
|
121
|
+
setPWD(pwd) {
|
|
122
|
+
this.processService.chdir(pwd);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* @deprecated
|
|
126
|
+
*/
|
|
127
|
+
dataPath(...args) {
|
|
128
|
+
return this.fs.path(...args);
|
|
129
|
+
}
|
|
33
130
|
/**
|
|
34
131
|
* @deprecated
|
|
35
132
|
*/
|
|
@@ -38,7 +135,6 @@ let AppConfigService = class AppConfigService {
|
|
|
38
135
|
}
|
|
39
136
|
addProject(id, name, path) {
|
|
40
137
|
this.config.addProject(id, name, path);
|
|
41
|
-
this.save();
|
|
42
138
|
}
|
|
43
139
|
removeProject(id) {
|
|
44
140
|
this.config.removeProject(id);
|
|
@@ -52,6 +148,12 @@ let AppConfigService = class AppConfigService {
|
|
|
52
148
|
this.config.unregisterPreset(name);
|
|
53
149
|
this.save();
|
|
54
150
|
}
|
|
151
|
+
addPlugin(name, env) {
|
|
152
|
+
this.config.addPlugin(name);
|
|
153
|
+
}
|
|
154
|
+
removePlugin(name) {
|
|
155
|
+
this.config.removePlugin(name);
|
|
156
|
+
}
|
|
55
157
|
getMeta(name, byDefault) {
|
|
56
158
|
return this.config.getMeta(name, byDefault);
|
|
57
159
|
}
|
|
@@ -61,8 +163,33 @@ let AppConfigService = class AppConfigService {
|
|
|
61
163
|
unsetMeta(name) {
|
|
62
164
|
this.config.unsetMeta(name);
|
|
63
165
|
}
|
|
166
|
+
getProjectTypes() {
|
|
167
|
+
if (this.config.getMeta("experimental.projectComposeType")) {
|
|
168
|
+
return Object.assign(Object.assign({}, this.mapTypes), { [makes_1.PROJECT_TYPE_COMPOSE]: "Docker compose" });
|
|
169
|
+
}
|
|
170
|
+
return this.mapTypes;
|
|
171
|
+
}
|
|
172
|
+
save() {
|
|
173
|
+
const fs = this.fs;
|
|
174
|
+
if (!fs.exists()) {
|
|
175
|
+
fs.mkdir("", {
|
|
176
|
+
recursive: true
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
fs.writeFile("wocker.config.js", this.config.toJsString());
|
|
180
|
+
fs.writeFile("wocker.config.json", this.config.toString()); // Backup file
|
|
181
|
+
if (fs.exists("data.json")) {
|
|
182
|
+
fs.rm("data.json");
|
|
183
|
+
}
|
|
184
|
+
if (fs.exists("wocker.json")) {
|
|
185
|
+
fs.rm("wocker.json");
|
|
186
|
+
}
|
|
187
|
+
}
|
|
64
188
|
};
|
|
65
189
|
exports.AppConfigService = AppConfigService;
|
|
66
190
|
exports.AppConfigService = AppConfigService = __decorate([
|
|
67
|
-
(0, decorators_1.Injectable)("APP_CONFIG")
|
|
191
|
+
(0, decorators_1.Injectable)("APP_CONFIG"),
|
|
192
|
+
__param(0, (0, decorators_1.Inject)(env_1.WOCKER_VERSION_KEY)),
|
|
193
|
+
__metadata("design:paramtypes", [String, ProcessService_1.ProcessService,
|
|
194
|
+
AppFileSystemService_1.AppFileSystemService])
|
|
68
195
|
], AppConfigService);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AppFileSystemService = void 0;
|
|
16
|
+
const decorators_1 = require("../decorators");
|
|
17
|
+
const makes_1 = require("../makes");
|
|
18
|
+
const env_1 = require("../env");
|
|
19
|
+
let AppFileSystemService = class AppFileSystemService extends makes_1.FileSystem {
|
|
20
|
+
constructor(dataDir) {
|
|
21
|
+
super(dataDir);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
exports.AppFileSystemService = AppFileSystemService;
|
|
25
|
+
exports.AppFileSystemService = AppFileSystemService = __decorate([
|
|
26
|
+
(0, decorators_1.Injectable)(),
|
|
27
|
+
__param(0, (0, decorators_1.Inject)(env_1.WOCKER_DATA_DIR_KEY)),
|
|
28
|
+
__metadata("design:paramtypes", [String])
|
|
29
|
+
], AppFileSystemService);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AppConfigService } from "./AppConfigService";
|
|
2
|
+
import { AppFileSystemService } from "./AppFileSystemService";
|
|
3
|
+
import { ProjectRef } from "../types/ProjectRef";
|
|
4
|
+
type TypeMap = {
|
|
5
|
+
[type: string]: string;
|
|
6
|
+
};
|
|
7
|
+
export declare class AppService {
|
|
8
|
+
readonly version: string;
|
|
9
|
+
protected readonly appConfigService: AppConfigService;
|
|
10
|
+
protected readonly fs: AppFileSystemService;
|
|
11
|
+
constructor(version: string, appConfigService: AppConfigService, fs: AppFileSystemService);
|
|
12
|
+
get projects(): ProjectRef[];
|
|
13
|
+
isVersionGTE(version: string): boolean;
|
|
14
|
+
get experimentalFeatures(): string[];
|
|
15
|
+
getProjectTypes(): TypeMap;
|
|
16
|
+
addProject(id: string, name: string, path: string): void;
|
|
17
|
+
getMeta(name: string, byDefault?: string): string | undefined;
|
|
18
|
+
getMeta(name: string, byDefault: string): string;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AppService = void 0;
|
|
16
|
+
const decorators_1 = require("../decorators");
|
|
17
|
+
const AppConfigService_1 = require("./AppConfigService");
|
|
18
|
+
const AppFileSystemService_1 = require("./AppFileSystemService");
|
|
19
|
+
const env_1 = require("../env");
|
|
20
|
+
let AppService = class AppService {
|
|
21
|
+
constructor(version, appConfigService, fs) {
|
|
22
|
+
this.version = version;
|
|
23
|
+
this.appConfigService = appConfigService;
|
|
24
|
+
this.fs = fs;
|
|
25
|
+
}
|
|
26
|
+
get projects() {
|
|
27
|
+
return this.appConfigService.projects;
|
|
28
|
+
}
|
|
29
|
+
isVersionGTE(version) {
|
|
30
|
+
const current = this.version.split(".").map(Number);
|
|
31
|
+
const compare = version.split(".").map(Number);
|
|
32
|
+
for (let i = 0; i < 3; i++) {
|
|
33
|
+
if (current[i] > compare[i]) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
else if (current[i] < compare[i]) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
get experimentalFeatures() {
|
|
43
|
+
return this.appConfigService.experimentalFeatures;
|
|
44
|
+
}
|
|
45
|
+
getProjectTypes() {
|
|
46
|
+
return this.appConfigService.getProjectTypes();
|
|
47
|
+
}
|
|
48
|
+
addProject(id, name, path) {
|
|
49
|
+
this.appConfigService.addProject(id, name, path);
|
|
50
|
+
this.appConfigService.save();
|
|
51
|
+
}
|
|
52
|
+
getMeta(name, byDefault) {
|
|
53
|
+
return this.appConfigService.getMeta(name, byDefault);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
exports.AppService = AppService;
|
|
57
|
+
exports.AppService = AppService = __decorate([
|
|
58
|
+
(0, decorators_1.Injectable)("APP_SERVICE"),
|
|
59
|
+
__param(0, (0, decorators_1.Inject)(env_1.WOCKER_VERSION_KEY)),
|
|
60
|
+
__metadata("design:paramtypes", [String, AppConfigService_1.AppConfigService,
|
|
61
|
+
AppFileSystemService_1.AppFileSystemService])
|
|
62
|
+
], AppService);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type EventHandle = (...args: any[]) => Promise<void> | void;
|
|
2
|
+
export declare class EventService {
|
|
3
|
+
protected handles: {
|
|
4
|
+
[event: string]: Set<EventHandle>;
|
|
5
|
+
};
|
|
6
|
+
on(event: string, handle: EventHandle): (() => void);
|
|
7
|
+
off(event: string, handle: EventHandle): void;
|
|
8
|
+
emit(event: string, ...args: any[]): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.EventService = void 0;
|
|
19
|
+
const decorators_1 = require("../decorators");
|
|
20
|
+
let EventService = class EventService {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.handles = {};
|
|
23
|
+
}
|
|
24
|
+
on(event, handle) {
|
|
25
|
+
if (!this.handles[event]) {
|
|
26
|
+
this.handles[event] = new Set();
|
|
27
|
+
}
|
|
28
|
+
this.handles[event].add(handle);
|
|
29
|
+
return () => {
|
|
30
|
+
this.off(event, handle);
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
off(event, handle) {
|
|
34
|
+
if (!this.handles[event]) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
this.handles[event].delete(handle);
|
|
38
|
+
}
|
|
39
|
+
emit(event, ...args) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
if (!this.handles[event]) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
for (const handle of this.handles[event].values()) {
|
|
45
|
+
yield handle(...args);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
exports.EventService = EventService;
|
|
51
|
+
exports.EventService = EventService = __decorate([
|
|
52
|
+
(0, decorators_1.Injectable)("APP_EVENTS_SERVICE")
|
|
53
|
+
], EventService);
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { AppConfigService } from "./AppConfigService";
|
|
2
|
+
import { AppFileSystemService } from "./AppFileSystemService";
|
|
3
|
+
export declare class LogService {
|
|
4
|
+
protected readonly appConfigService: AppConfigService;
|
|
5
|
+
protected readonly fs: AppFileSystemService;
|
|
6
|
+
constructor(appConfigService: AppConfigService, fs: AppFileSystemService);
|
|
7
|
+
protected get logName(): string;
|
|
8
|
+
protected _log(type: string, ...data: any[]): void;
|
|
9
|
+
debug(...data: any[]): void;
|
|
10
|
+
log(...data: any[]): void;
|
|
11
|
+
info(...data: any[]): void;
|
|
12
|
+
warn(...data: any[]): void;
|
|
13
|
+
error(...data: any[]): void;
|
|
14
|
+
clear(): void;
|
|
7
15
|
}
|
|
@@ -5,12 +5,58 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
8
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
12
|
exports.LogService = void 0;
|
|
13
|
+
const format_1 = require("date-fns/format");
|
|
10
14
|
const decorators_1 = require("../decorators");
|
|
15
|
+
const AppConfigService_1 = require("./AppConfigService");
|
|
16
|
+
const AppFileSystemService_1 = require("./AppFileSystemService");
|
|
11
17
|
let LogService = class LogService {
|
|
18
|
+
constructor(appConfigService, fs) {
|
|
19
|
+
this.appConfigService = appConfigService;
|
|
20
|
+
this.fs = fs;
|
|
21
|
+
}
|
|
22
|
+
get logName() {
|
|
23
|
+
return "ws.log";
|
|
24
|
+
}
|
|
25
|
+
_log(type, ...data) {
|
|
26
|
+
if (type === "debug" && !this.appConfigService.config.debug) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const time = (0, format_1.format)(new Date(), "yyyy-MM-dd HH:mm:ss");
|
|
30
|
+
const logData = data.map((item) => {
|
|
31
|
+
return typeof item !== "string" ? JSON.stringify(item) : item;
|
|
32
|
+
}).join(" ");
|
|
33
|
+
if (!this.fs.exists(this.logName)) {
|
|
34
|
+
this.fs.writeFile(this.logName, "");
|
|
35
|
+
}
|
|
36
|
+
this.fs.appendFile(this.logName, `[${time}] ${type}: ${logData}\n`);
|
|
37
|
+
}
|
|
38
|
+
debug(...data) {
|
|
39
|
+
this._log("debug", ...data);
|
|
40
|
+
}
|
|
41
|
+
log(...data) {
|
|
42
|
+
this._log("log", ...data);
|
|
43
|
+
}
|
|
44
|
+
info(...data) {
|
|
45
|
+
this._log("info", ...data);
|
|
46
|
+
}
|
|
47
|
+
warn(...data) {
|
|
48
|
+
this._log("warn", ...data);
|
|
49
|
+
}
|
|
50
|
+
error(...data) {
|
|
51
|
+
this._log("error", ...data);
|
|
52
|
+
}
|
|
53
|
+
clear() {
|
|
54
|
+
this.fs.writeFile(this.logName, "");
|
|
55
|
+
}
|
|
12
56
|
};
|
|
13
57
|
exports.LogService = LogService;
|
|
14
58
|
exports.LogService = LogService = __decorate([
|
|
15
|
-
(0, decorators_1.Injectable)("LOG_SERVICE")
|
|
59
|
+
(0, decorators_1.Injectable)("LOG_SERVICE"),
|
|
60
|
+
__metadata("design:paramtypes", [AppConfigService_1.AppConfigService,
|
|
61
|
+
AppFileSystemService_1.AppFileSystemService])
|
|
16
62
|
], LogService);
|
|
@@ -12,18 +12,18 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
15
|
+
exports.PluginFileSystemService = void 0;
|
|
16
16
|
const decorators_1 = require("../decorators");
|
|
17
17
|
const env_1 = require("../env");
|
|
18
18
|
const makes_1 = require("../makes");
|
|
19
|
-
let
|
|
19
|
+
let PluginFileSystemService = class PluginFileSystemService extends makes_1.FileSystem {
|
|
20
20
|
constructor(pluginDir) {
|
|
21
21
|
super(pluginDir);
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
|
-
exports.
|
|
25
|
-
exports.
|
|
24
|
+
exports.PluginFileSystemService = PluginFileSystemService;
|
|
25
|
+
exports.PluginFileSystemService = PluginFileSystemService = __decorate([
|
|
26
26
|
(0, decorators_1.Injectable)(),
|
|
27
27
|
__param(0, (0, decorators_1.Inject)(env_1.PLUGIN_DIR_KEY)),
|
|
28
28
|
__metadata("design:paramtypes", [String])
|
|
29
|
-
],
|
|
29
|
+
], PluginFileSystemService);
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { EnvConfig } from "../types";
|
|
2
|
+
import { Preset } from "../makes/Preset";
|
|
2
3
|
type SearchOptions = Partial<{
|
|
3
4
|
name: string;
|
|
5
|
+
source: string;
|
|
6
|
+
path: string;
|
|
4
7
|
}>;
|
|
5
8
|
declare abstract class PresetService {
|
|
6
9
|
abstract getImageName(preset: any, buildArgs?: EnvConfig): string;
|
|
7
10
|
abstract save(preset: any): Promise<void>;
|
|
8
11
|
abstract get(name: string): Promise<any | null>;
|
|
9
|
-
abstract search(options?: SearchOptions):
|
|
10
|
-
searchOne(options?: SearchOptions):
|
|
12
|
+
abstract search(options?: SearchOptions): Preset[];
|
|
13
|
+
abstract searchOne(options?: SearchOptions): Preset | null;
|
|
11
14
|
}
|
|
12
15
|
export { PresetService, SearchOptions as PresetServiceSearchOptions };
|
|
@@ -1,21 +1,6 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.PresetService = void 0;
|
|
13
4
|
class PresetService {
|
|
14
|
-
searchOne(options) {
|
|
15
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
const [preset] = yield this.search(options);
|
|
17
|
-
return preset || null;
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
5
|
}
|
|
21
6
|
exports.PresetService = PresetService;
|
|
@@ -5,12 +5,25 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
8
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
12
|
+
exports.ProcessService = void 0;
|
|
13
|
+
const path_1 = __importDefault(require("path"));
|
|
10
14
|
const decorators_1 = require("../decorators");
|
|
11
|
-
let
|
|
15
|
+
let ProcessService = class ProcessService {
|
|
16
|
+
pwd(path = "") {
|
|
17
|
+
return path_1.default.join(process.cwd(), path);
|
|
18
|
+
}
|
|
19
|
+
cd(path) {
|
|
20
|
+
this.chdir(this.pwd(path));
|
|
21
|
+
}
|
|
22
|
+
chdir(path) {
|
|
23
|
+
process.chdir(path);
|
|
24
|
+
}
|
|
12
25
|
};
|
|
13
|
-
exports.
|
|
14
|
-
exports.
|
|
15
|
-
(0, decorators_1.Injectable)(
|
|
16
|
-
],
|
|
26
|
+
exports.ProcessService = ProcessService;
|
|
27
|
+
exports.ProcessService = ProcessService = __decorate([
|
|
28
|
+
(0, decorators_1.Injectable)()
|
|
29
|
+
], ProcessService);
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { Project } from "../makes/Project";
|
|
2
2
|
type SearchParams = Partial<{
|
|
3
|
-
id: string;
|
|
4
3
|
name: string;
|
|
5
4
|
path: string;
|
|
6
5
|
}>;
|
|
7
6
|
export declare abstract class ProjectService {
|
|
8
|
-
abstract
|
|
9
|
-
abstract
|
|
7
|
+
abstract get(name?: string): Project;
|
|
8
|
+
abstract save(project: Project): void;
|
|
9
|
+
abstract search(params: SearchParams): Project[];
|
|
10
10
|
abstract start(project: Project): Promise<void>;
|
|
11
11
|
abstract stop(project: Project): Promise<void>;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
searchOne(params?: SearchParams): Project | null;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated
|
|
15
|
+
*/
|
|
16
|
+
cdProject(name?: string): void;
|
|
15
17
|
}
|
|
16
18
|
export { SearchParams as ProjectServiceSearchParams };
|
|
@@ -5,25 +5,18 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
9
|
exports.ProjectService = void 0;
|
|
19
10
|
const decorators_1 = require("../decorators");
|
|
20
11
|
let ProjectService = class ProjectService {
|
|
21
|
-
searchOne() {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return project || null;
|
|
25
|
-
});
|
|
12
|
+
searchOne(params = {}) {
|
|
13
|
+
const [project] = this.search(params);
|
|
14
|
+
return project || null;
|
|
26
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated
|
|
18
|
+
*/
|
|
19
|
+
cdProject(name) { }
|
|
27
20
|
};
|
|
28
21
|
exports.ProjectService = ProjectService;
|
|
29
22
|
exports.ProjectService = ProjectService = __decorate([
|
package/lib/services/index.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
export * from "./AppConfigService";
|
|
2
|
-
export * from "./
|
|
2
|
+
export * from "./AppFileSystemService";
|
|
3
|
+
export * from "./AppService";
|
|
3
4
|
export * from "./DockerService";
|
|
5
|
+
export * from "./EventService";
|
|
4
6
|
export * from "./KeystoreService";
|
|
5
7
|
export * from "./LogService";
|
|
6
8
|
export * from "./ModemService";
|
|
7
9
|
export * from "./PluginConfigService";
|
|
10
|
+
export * from "./PluginFileSystemService";
|
|
8
11
|
export * from "./PresetService";
|
|
12
|
+
export * from "./ProcessService";
|
|
9
13
|
export * from "./ProjectService";
|
|
10
14
|
export * from "./ProxyService";
|
package/lib/services/index.js
CHANGED
|
@@ -15,12 +15,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./AppConfigService"), exports);
|
|
18
|
-
__exportStar(require("./
|
|
18
|
+
__exportStar(require("./AppFileSystemService"), exports);
|
|
19
|
+
__exportStar(require("./AppService"), exports);
|
|
19
20
|
__exportStar(require("./DockerService"), exports);
|
|
21
|
+
__exportStar(require("./EventService"), exports);
|
|
20
22
|
__exportStar(require("./KeystoreService"), exports);
|
|
21
23
|
__exportStar(require("./LogService"), exports);
|
|
22
24
|
__exportStar(require("./ModemService"), exports);
|
|
23
25
|
__exportStar(require("./PluginConfigService"), exports);
|
|
26
|
+
__exportStar(require("./PluginFileSystemService"), exports);
|
|
24
27
|
__exportStar(require("./PresetService"), exports);
|
|
28
|
+
__exportStar(require("./ProcessService"), exports);
|
|
25
29
|
__exportStar(require("./ProjectService"), exports);
|
|
26
30
|
__exportStar(require("./ProxyService"), exports);
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/index.js
CHANGED
|
@@ -16,5 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./EnvConfig"), exports);
|
|
18
18
|
__exportStar(require("./FileSystemDriver"), exports);
|
|
19
|
+
__exportStar(require("./InjectionToken"), exports);
|
|
19
20
|
__exportStar(require("./PickProperties"), exports);
|
|
20
21
|
__exportStar(require("./Volume"), exports);
|
|
22
|
+
__exportStar(require("./ProviderType"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wocker/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24-beta.0",
|
|
4
4
|
"author": "Kris Papercut <krispcut@gmail.com>",
|
|
5
5
|
"description": "Core of the Wocker",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@kearisp/cli": "^2.0.8",
|
|
30
|
+
"date-fns": "^4.1.0",
|
|
30
31
|
"fs": "^0.0.1-security",
|
|
31
32
|
"os": "^0.1.2",
|
|
32
33
|
"path": "^0.12.7",
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export type AppEventHandle = (...args: any[]) => Promise<void> | void;
|
|
2
|
-
export declare abstract class AppEventsService {
|
|
3
|
-
abstract on(event: string, handle: AppEventHandle): void;
|
|
4
|
-
abstract off(event: string, handle: AppEventHandle): void;
|
|
5
|
-
abstract emit(event: string, ...args: any[]): Promise<void>;
|
|
6
|
-
}
|
|
File without changes
|