@wocker/core 1.1.0-beta.5 → 1.1.0-beta.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.
- package/lib/core/ApplicationContext.d.ts +1 -0
- package/lib/core/ApplicationContext.js +44 -33
- package/lib/core/Route.js +1 -1
- package/lib/makes/PluginConfig.d.ts +7 -0
- package/lib/makes/PluginConfig.js +31 -0
- package/lib/makes/Project.d.ts +3 -3
- package/lib/makes/ProjectConfig.d.ts +2 -2
- package/lib/makes/index.d.ts +1 -0
- package/lib/makes/index.js +1 -0
- package/lib/modules/plugin/services/PluginConfigService.d.ts +2 -1
- package/lib/modules/plugin/services/PluginConfigService.js +3 -0
- package/lib/types/PresetMode.d.ts +14 -0
- package/lib/types/PresetMode.js +31 -0
- package/lib/types/index.d.ts +1 -5
- package/lib/types/index.js +1 -0
- package/package.json +1 -1
|
@@ -8,4 +8,5 @@ export declare class ApplicationContext {
|
|
|
8
8
|
constructor(module: Type, container: Container, options?: ApplicationOptions);
|
|
9
9
|
get<TInput = any, TResult = TInput>(typeOrToken: InjectionToken<TInput>): TResult;
|
|
10
10
|
run(args: string[]): Promise<string>;
|
|
11
|
+
protected process(args: string[]): Promise<string>;
|
|
11
12
|
}
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.ApplicationContext = void 0;
|
|
13
13
|
const cli_1 = require("@kearisp/cli");
|
|
14
14
|
const AsyncStorage_1 = require("./AsyncStorage");
|
|
15
|
+
const EventService_1 = require("../services/EventService");
|
|
15
16
|
const env_1 = require("../env");
|
|
16
17
|
class ApplicationContext {
|
|
17
18
|
constructor(module, container, options = {}) {
|
|
@@ -34,43 +35,53 @@ class ApplicationContext {
|
|
|
34
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
36
|
return new Promise((resolve) => {
|
|
36
37
|
AsyncStorage_1.AsyncStorage.run(this.container, () => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
return resolve(this.process(args));
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
process(args) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const cli = this.get(cli_1.Cli), eventService = this.get(EventService_1.EventService);
|
|
46
|
+
cli.command("")
|
|
47
|
+
.option("version", {
|
|
48
|
+
type: "boolean",
|
|
49
|
+
alias: "v"
|
|
50
|
+
})
|
|
51
|
+
.action((input) => {
|
|
52
|
+
if (input.option("version")) {
|
|
53
|
+
return env_1.WOCKER_VERSION;
|
|
54
|
+
}
|
|
55
|
+
for (const [, module] of this.container.modules) {
|
|
56
|
+
for (const [, container] of module.controllers) {
|
|
57
|
+
if (!container.description) {
|
|
58
|
+
continue;
|
|
46
59
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
for (const commandName of route.commandNames) {
|
|
63
|
-
const space = " ".repeat(Math.max(0, spaceLength - commandName.length));
|
|
64
|
-
console.info(` ${commandName} ${space} ${route.description}`);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
console.info("");
|
|
60
|
+
console.info(`${container.description}:`);
|
|
61
|
+
const spaceLength = container.commands.reduce((space, route) => {
|
|
62
|
+
return route.commandNames.reduce((space, command) => {
|
|
63
|
+
return Math.max(space, command.length + 2);
|
|
64
|
+
}, space);
|
|
65
|
+
}, 0);
|
|
66
|
+
for (const route of container.commands) {
|
|
67
|
+
if (!route.description) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
for (const commandName of route.commandNames) {
|
|
71
|
+
const space = " ".repeat(Math.max(0, spaceLength - commandName.length));
|
|
72
|
+
console.info(` ${commandName} ${space} ${route.description}`);
|
|
68
73
|
}
|
|
69
74
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
75
|
+
console.info("");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
73
78
|
});
|
|
79
|
+
try {
|
|
80
|
+
return yield cli.run(args);
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
yield eventService.emit("finish");
|
|
84
|
+
}
|
|
74
85
|
});
|
|
75
86
|
}
|
|
76
87
|
}
|
package/lib/core/Route.js
CHANGED
|
@@ -11,7 +11,7 @@ class Route {
|
|
|
11
11
|
this.commandNames = [];
|
|
12
12
|
this.completions = [];
|
|
13
13
|
const descriptor = Object.getOwnPropertyDescriptor(this.type.prototype, this.method);
|
|
14
|
-
if (!descriptor) {
|
|
14
|
+
if (!descriptor || !descriptor.value) {
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
this.description = Reflect.getMetadata(env_1.DESCRIPTION_METADATA, descriptor.value) || "";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PluginConfig = void 0;
|
|
4
|
+
class PluginConfig {
|
|
5
|
+
constructor(_data) { }
|
|
6
|
+
save() {
|
|
7
|
+
throw new Error("Method not implemented");
|
|
8
|
+
}
|
|
9
|
+
toObject() {
|
|
10
|
+
throw new Error("Method not implemented");
|
|
11
|
+
}
|
|
12
|
+
static make(fs, configPath = "config.json") {
|
|
13
|
+
const data = fs.exists(configPath)
|
|
14
|
+
? fs.readJSON(configPath)
|
|
15
|
+
: {};
|
|
16
|
+
return new class extends this {
|
|
17
|
+
constructor(data) {
|
|
18
|
+
super(data);
|
|
19
|
+
}
|
|
20
|
+
save() {
|
|
21
|
+
if (!fs.exists()) {
|
|
22
|
+
fs.mkdir("", {
|
|
23
|
+
recursive: true
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
fs.writeJSON(configPath, this.toObject());
|
|
27
|
+
}
|
|
28
|
+
}(data);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.PluginConfig = PluginConfig;
|
package/lib/makes/Project.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ProjectConfig } from "./ProjectConfig";
|
|
2
|
-
import { EnvConfig, ProjectConfigScope, ProjectRef, ProjectType } from "../types";
|
|
2
|
+
import { EnvConfig, ProjectConfigScope, ProjectRef, ProjectType, PresetMode } from "../types";
|
|
3
3
|
export declare class Project {
|
|
4
4
|
name: string;
|
|
5
5
|
path: string;
|
|
@@ -13,8 +13,8 @@ export declare class Project {
|
|
|
13
13
|
get scripts(): any;
|
|
14
14
|
get preset(): string | undefined;
|
|
15
15
|
set preset(preset: string | undefined);
|
|
16
|
-
get presetMode():
|
|
17
|
-
set presetMode(mode:
|
|
16
|
+
get presetMode(): PresetMode;
|
|
17
|
+
set presetMode(mode: PresetMode);
|
|
18
18
|
get image(): string | undefined;
|
|
19
19
|
/** @deprecated */
|
|
20
20
|
get imageName(): string | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EnvConfig, ProjectType, ProjectConfigScope } from "../types";
|
|
2
1
|
import { JsonEditor } from "./JsonEditor";
|
|
3
2
|
import { ServiceConfig } from "./ServiceConfig";
|
|
3
|
+
import { EnvConfig, ProjectType, ProjectConfigScope, PresetMode } from "../types";
|
|
4
4
|
export declare class ProjectConfig extends JsonEditor<ProjectConfig.Data> {
|
|
5
5
|
readonly _scope: ProjectConfigScope;
|
|
6
6
|
constructor(_scope: ProjectConfigScope, content: string);
|
|
@@ -60,7 +60,7 @@ export declare namespace ProjectConfig {
|
|
|
60
60
|
dockerfile?: string;
|
|
61
61
|
composefile?: string;
|
|
62
62
|
preset?: string;
|
|
63
|
-
presetMode?:
|
|
63
|
+
presetMode?: PresetMode;
|
|
64
64
|
scripts?: {
|
|
65
65
|
[script: string]: string;
|
|
66
66
|
};
|
package/lib/makes/index.d.ts
CHANGED
package/lib/makes/index.js
CHANGED
|
@@ -20,6 +20,7 @@ __exportStar(require("./ConfigCollection"), exports);
|
|
|
20
20
|
__exportStar(require("./FileSystem"), exports);
|
|
21
21
|
__exportStar(require("./FileSystemManager"), exports);
|
|
22
22
|
__exportStar(require("./Logger"), exports);
|
|
23
|
+
__exportStar(require("./PluginConfig"), exports);
|
|
23
24
|
__exportStar(require("./Project"), exports);
|
|
24
25
|
__exportStar(require("./Version"), exports);
|
|
25
26
|
__exportStar(require("./VersionRange"), exports);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WriteFileOptions, MakeDirectoryOptions, RmOptions, WriteStream, ReadStream } from "fs";
|
|
2
2
|
import { FileSystemDriver } from "../../../types";
|
|
3
3
|
import { AppConfigService } from "../../../services/AppConfigService";
|
|
4
|
-
import { FileSystem } from "../../../makes";
|
|
4
|
+
import { FileSystem, PluginConfig } from "../../../makes";
|
|
5
5
|
export declare class PluginConfigService {
|
|
6
6
|
protected readonly appConfigService: AppConfigService;
|
|
7
7
|
protected readonly pluginDir: string;
|
|
@@ -9,6 +9,7 @@ export declare class PluginConfigService {
|
|
|
9
9
|
protected _fs?: FileSystem;
|
|
10
10
|
constructor(appConfigService: AppConfigService, pluginDir: string, driver: FileSystemDriver);
|
|
11
11
|
get fs(): FileSystem;
|
|
12
|
+
getConfig<T extends typeof PluginConfig>(Config: T): InstanceType<T>;
|
|
12
13
|
isVersionGTE(version: string): boolean;
|
|
13
14
|
/** @deprecated */
|
|
14
15
|
dataPath(...parts: string[]): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare enum PresetModeEnum {
|
|
2
|
+
PROJECT = "project",
|
|
3
|
+
GLOBAL = "global"
|
|
4
|
+
}
|
|
5
|
+
export type PresetMode = PresetModeEnum;
|
|
6
|
+
export declare const PresetMode: typeof PresetModeEnum & {
|
|
7
|
+
values: () => PresetModeEnum[];
|
|
8
|
+
options: () => {
|
|
9
|
+
label: string;
|
|
10
|
+
value: PresetModeEnum;
|
|
11
|
+
}[];
|
|
12
|
+
label: (mode: PresetModeEnum) => string;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PresetMode = void 0;
|
|
4
|
+
var PresetModeEnum;
|
|
5
|
+
(function (PresetModeEnum) {
|
|
6
|
+
PresetModeEnum["PROJECT"] = "project";
|
|
7
|
+
PresetModeEnum["GLOBAL"] = "global";
|
|
8
|
+
})(PresetModeEnum || (PresetModeEnum = {}));
|
|
9
|
+
exports.PresetMode = Object.assign({}, PresetModeEnum, {
|
|
10
|
+
values: () => {
|
|
11
|
+
return Object.values(PresetModeEnum);
|
|
12
|
+
},
|
|
13
|
+
options: () => {
|
|
14
|
+
return exports.PresetMode.values().map((mode) => {
|
|
15
|
+
return {
|
|
16
|
+
label: exports.PresetMode.label(mode),
|
|
17
|
+
value: mode
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
label: (mode) => {
|
|
22
|
+
switch (mode) {
|
|
23
|
+
case PresetModeEnum.PROJECT:
|
|
24
|
+
return "For project only";
|
|
25
|
+
case PresetModeEnum.GLOBAL:
|
|
26
|
+
return "Global usage";
|
|
27
|
+
default:
|
|
28
|
+
throw new Error(`Unsupported mode "${mode}"`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
package/lib/types/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from "./PluginMetadata";
|
|
|
11
11
|
export * from "./ProjectConfigScope";
|
|
12
12
|
export * from "./PluginRef";
|
|
13
13
|
export * from "./PresetRef";
|
|
14
|
+
export * from "./PresetMode";
|
|
14
15
|
export * from "./PresetSource";
|
|
15
16
|
export * from "./ProviderType";
|
|
16
17
|
export * from "./ProjectRef";
|
|
@@ -22,8 +23,3 @@ export type {
|
|
|
22
23
|
* @deprecated
|
|
23
24
|
*/
|
|
24
25
|
ModuleMetadata as ModuleConfig } from "./ModuleMetadata";
|
|
25
|
-
export type {
|
|
26
|
-
/**
|
|
27
|
-
* @deprecated
|
|
28
|
-
*/
|
|
29
|
-
PluginMetadata as PluginConfig } from "./PluginMetadata";
|
package/lib/types/index.js
CHANGED
|
@@ -27,6 +27,7 @@ __exportStar(require("./PluginMetadata"), exports);
|
|
|
27
27
|
__exportStar(require("./ProjectConfigScope"), exports);
|
|
28
28
|
__exportStar(require("./PluginRef"), exports);
|
|
29
29
|
__exportStar(require("./PresetRef"), exports);
|
|
30
|
+
__exportStar(require("./PresetMode"), exports);
|
|
30
31
|
__exportStar(require("./PresetSource"), exports);
|
|
31
32
|
__exportStar(require("./ProviderType"), exports);
|
|
32
33
|
__exportStar(require("./ProjectRef"), exports);
|