@wocker/core 1.1.0-beta.5 → 1.1.0-beta.7
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 +4 -3
- package/lib/makes/Project.js +10 -3
- package/lib/makes/ProjectConfig.d.ts +2 -2
- package/lib/makes/ProjectConfig.js +8 -3
- 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,9 +13,10 @@ 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
|
+
set image(image: string | undefined);
|
|
19
20
|
/** @deprecated */
|
|
20
21
|
get imageName(): string | undefined;
|
|
21
22
|
/** @deprecated */
|
package/lib/makes/Project.js
CHANGED
|
@@ -56,13 +56,20 @@ class Project {
|
|
|
56
56
|
get image() {
|
|
57
57
|
return this.configs.app.image || this.configs.project.image;
|
|
58
58
|
}
|
|
59
|
+
set image(image) {
|
|
60
|
+
if (!image) {
|
|
61
|
+
delete this.configs.app.image;
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
this.configs.app.image = image;
|
|
65
|
+
}
|
|
59
66
|
/** @deprecated */
|
|
60
67
|
get imageName() {
|
|
61
|
-
return this.
|
|
68
|
+
return this.image;
|
|
62
69
|
}
|
|
63
70
|
/** @deprecated */
|
|
64
71
|
set imageName(image) {
|
|
65
|
-
this.
|
|
72
|
+
this.image = image;
|
|
66
73
|
}
|
|
67
74
|
get dockerfile() {
|
|
68
75
|
return this.configs.app.dockerfile || this.configs.project.dockerfile;
|
|
@@ -171,7 +178,7 @@ class Project {
|
|
|
171
178
|
this.configs.app.unsetEnv(key, service);
|
|
172
179
|
}
|
|
173
180
|
hasMeta(key) {
|
|
174
|
-
return this.configs.app.metadata
|
|
181
|
+
return key in this.configs.app.metadata || key in this.configs.project.metadata;
|
|
175
182
|
}
|
|
176
183
|
getMeta(key, byDefault) {
|
|
177
184
|
return this.configs.app.metadata[key] || this.configs.project.metadata[key] || byDefault;
|
|
@@ -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
|
};
|
|
@@ -102,7 +102,7 @@ class ProjectConfig extends JsonEditor_1.JsonEditor {
|
|
|
102
102
|
return this.state.cmd;
|
|
103
103
|
}
|
|
104
104
|
set cmd(cmd) {
|
|
105
|
-
this.
|
|
105
|
+
this.set(["cmd"], cmd);
|
|
106
106
|
}
|
|
107
107
|
get scripts() {
|
|
108
108
|
return this.createProxy(["scripts"], {
|
|
@@ -146,7 +146,10 @@ class ProjectConfig extends JsonEditor_1.JsonEditor {
|
|
|
146
146
|
this.set(["services", service, "buildArgs", key], value);
|
|
147
147
|
return;
|
|
148
148
|
}
|
|
149
|
-
this.buildArgs
|
|
149
|
+
if (!this.state.buildArgs) {
|
|
150
|
+
this.set(["buildArgs"], {});
|
|
151
|
+
}
|
|
152
|
+
this.set(["buildArgs", key], value);
|
|
150
153
|
}
|
|
151
154
|
unsetBuildArg(key, service) {
|
|
152
155
|
if (service) {
|
|
@@ -162,7 +165,6 @@ class ProjectConfig extends JsonEditor_1.JsonEditor {
|
|
|
162
165
|
return byDefault;
|
|
163
166
|
}
|
|
164
167
|
hasEnv(key) {
|
|
165
|
-
// return this.env.hasOwnProperty(key);
|
|
166
168
|
return key in this.env;
|
|
167
169
|
}
|
|
168
170
|
setEnv(key, value, service) {
|
|
@@ -173,6 +175,9 @@ class ProjectConfig extends JsonEditor_1.JsonEditor {
|
|
|
173
175
|
this.set(["services", service, "env", key], sValue);
|
|
174
176
|
return;
|
|
175
177
|
}
|
|
178
|
+
if (!this.state.env) {
|
|
179
|
+
this.set(["env"], {});
|
|
180
|
+
}
|
|
176
181
|
this.set(["env", key], sValue);
|
|
177
182
|
}
|
|
178
183
|
unsetEnv(key, service) {
|
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);
|