@wocker/ws 1.0.14 → 1.0.16
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/AppModule.js +3 -3
- package/lib/controllers/DebugController.d.ts +3 -0
- package/lib/controllers/DebugController.js +43 -1
- package/lib/controllers/PresetController.d.ts +3 -1
- package/lib/controllers/PresetController.js +42 -7
- package/lib/controllers/ProjectController.d.ts +2 -1
- package/lib/controllers/ProjectController.js +17 -13
- package/lib/controllers/ProxyController.d.ts +1 -1
- package/lib/controllers/ProxyController.js +4 -4
- package/lib/env.d.ts +0 -1
- package/lib/env.js +1 -2
- package/lib/plugins/index.d.ts +0 -1
- package/lib/plugins/index.js +0 -1
- package/lib/services/AppConfigService.d.ts +6 -6
- package/lib/services/AppConfigService.js +42 -27
- package/lib/services/LogService.d.ts +3 -1
- package/lib/services/LogService.js +9 -1
- package/lib/services/PluginService.js +1 -1
- package/lib/services/PresetService.d.ts +12 -3
- package/lib/services/PresetService.js +256 -20
- package/lib/services/ProjectService.d.ts +2 -3
- package/lib/services/ProjectService.js +32 -26
- package/lib/services/ProxyService.js +10 -20
- package/package.json +5 -3
- package/presets/bun/config.json +1 -0
- package/presets/go/config.json +1 -0
- package/presets/php-fpm/config.json +1 -0
- package/presets/shopify/config.json +2 -0
- package/lib/plugins/PageKitePlugin.d.ts +0 -30
- package/lib/plugins/PageKitePlugin.js +0 -145
- package/plugins/pagekite/Dockerfile +0 -3
- package/presets/node/Dockerfile +0 -39
- package/presets/node/config.json +0 -39
- package/presets/php-apache/Dockerfile +0 -227
- package/presets/php-apache/bin/compare-version +0 -3
- package/presets/php-apache/config.json +0 -64
- package/presets/php-apache/etc/apache2/apache2.conf +0 -230
- package/presets/php-apache/etc/apache2/mods-available/mpm_prefork.conf +0 -16
- package/presets/php-apache/etc/apache2/sites-available/000-default.conf +0 -21
package/lib/AppModule.js
CHANGED
|
@@ -39,15 +39,15 @@ let AppModule = AppModule_1 = class AppModule {
|
|
|
39
39
|
const appConfigService = container.getModule(AppModule_1).get(services_1.AppConfigService);
|
|
40
40
|
const logService = container.getModule(AppModule_1).get(services_1.LogService);
|
|
41
41
|
const pluginService = container.getModule(AppModule_1).get(services_1.PluginService);
|
|
42
|
-
const config =
|
|
42
|
+
const config = appConfigService.getConfig();
|
|
43
43
|
const imports = [];
|
|
44
|
-
for (const plugin of config.plugins) {
|
|
44
|
+
for (const plugin of config.plugins || []) {
|
|
45
45
|
try {
|
|
46
46
|
const { default: Plugin } = await Promise.resolve(`${plugin}`).then(s => __importStar(require(s)));
|
|
47
47
|
if (!Plugin) {
|
|
48
48
|
continue;
|
|
49
49
|
}
|
|
50
|
-
const name = Reflect.getMetadata(core_1.
|
|
50
|
+
const name = Reflect.getMetadata(core_1.PLUGIN_NAME_METADATA, Plugin);
|
|
51
51
|
Reflect.defineMetadata(core_1.MODULE_METADATA.PROVIDERS, [
|
|
52
52
|
...Reflect.getMetadata(core_1.MODULE_METADATA.PROVIDERS, Plugin) || [],
|
|
53
53
|
{
|
|
@@ -4,5 +4,8 @@ export declare class DebugController {
|
|
|
4
4
|
protected readonly logService: LogService;
|
|
5
5
|
constructor(appConfigService: AppConfigService, logService: LogService);
|
|
6
6
|
debug(status: string): Promise<void>;
|
|
7
|
+
setLog(level: string): Promise<void>;
|
|
8
|
+
testLog(level: string, args: string[]): Promise<void>;
|
|
7
9
|
debugCompletion(): Promise<string[]>;
|
|
10
|
+
getLevels(): string[];
|
|
8
11
|
}
|
|
@@ -8,6 +8,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.DebugController = void 0;
|
|
13
16
|
const core_1 = require("@wocker/core");
|
|
@@ -18,27 +21,66 @@ let DebugController = class DebugController {
|
|
|
18
21
|
this.logService = logService;
|
|
19
22
|
}
|
|
20
23
|
async debug(status) {
|
|
21
|
-
const config =
|
|
24
|
+
const config = this.appConfigService.getConfig();
|
|
22
25
|
config.debug = status === "on";
|
|
23
26
|
await config.save();
|
|
24
27
|
}
|
|
28
|
+
async setLog(level) {
|
|
29
|
+
const validLevels = this.getLevels();
|
|
30
|
+
if (!validLevels.includes(level)) {
|
|
31
|
+
throw new Error(`Invalid log level: ${level}. Valid options are ${validLevels.join(', ')}`);
|
|
32
|
+
}
|
|
33
|
+
const config = this.appConfigService.getConfig();
|
|
34
|
+
config.logLevel = level;
|
|
35
|
+
await config.save();
|
|
36
|
+
}
|
|
37
|
+
async testLog(level, args) {
|
|
38
|
+
this.logService._log(level, ...args);
|
|
39
|
+
}
|
|
25
40
|
async debugCompletion() {
|
|
26
41
|
return ["on", "off"];
|
|
27
42
|
}
|
|
43
|
+
getLevels() {
|
|
44
|
+
return ["debug", "info", "warn", "error"];
|
|
45
|
+
}
|
|
28
46
|
};
|
|
29
47
|
exports.DebugController = DebugController;
|
|
30
48
|
__decorate([
|
|
49
|
+
(0, core_1.Command)("debug:<status>"),
|
|
31
50
|
(0, core_1.Command)("debug <status>"),
|
|
51
|
+
__param(0, (0, core_1.Param)("status")),
|
|
32
52
|
__metadata("design:type", Function),
|
|
33
53
|
__metadata("design:paramtypes", [String]),
|
|
34
54
|
__metadata("design:returntype", Promise)
|
|
35
55
|
], DebugController.prototype, "debug", null);
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, core_1.Description)("Set the log level (options: debug, log, info, warn, error)"),
|
|
58
|
+
(0, core_1.Command)("loglevel <level>"),
|
|
59
|
+
__param(0, (0, core_1.Param)("level")),
|
|
60
|
+
__metadata("design:type", Function),
|
|
61
|
+
__metadata("design:paramtypes", [String]),
|
|
62
|
+
__metadata("design:returntype", Promise)
|
|
63
|
+
], DebugController.prototype, "setLog", null);
|
|
64
|
+
__decorate([
|
|
65
|
+
(0, core_1.Command)("log:<level> [...args]"),
|
|
66
|
+
__param(0, (0, core_1.Param)("level")),
|
|
67
|
+
__param(1, (0, core_1.Param)("args")),
|
|
68
|
+
__metadata("design:type", Function),
|
|
69
|
+
__metadata("design:paramtypes", [String, Array]),
|
|
70
|
+
__metadata("design:returntype", Promise)
|
|
71
|
+
], DebugController.prototype, "testLog", null);
|
|
36
72
|
__decorate([
|
|
37
73
|
(0, core_1.Completion)("status"),
|
|
38
74
|
__metadata("design:type", Function),
|
|
39
75
|
__metadata("design:paramtypes", []),
|
|
40
76
|
__metadata("design:returntype", Promise)
|
|
41
77
|
], DebugController.prototype, "debugCompletion", null);
|
|
78
|
+
__decorate([
|
|
79
|
+
(0, core_1.Completion)("level"),
|
|
80
|
+
__metadata("design:type", Function),
|
|
81
|
+
__metadata("design:paramtypes", []),
|
|
82
|
+
__metadata("design:returntype", Array)
|
|
83
|
+
], DebugController.prototype, "getLevels", null);
|
|
42
84
|
exports.DebugController = DebugController = __decorate([
|
|
43
85
|
(0, core_1.Controller)(),
|
|
44
86
|
__metadata("design:paramtypes", [services_1.AppConfigService,
|
|
@@ -11,7 +11,9 @@ export declare class PresetController {
|
|
|
11
11
|
protected onInit(project: Project): Promise<void>;
|
|
12
12
|
protected onRebuild(project: Project): Promise<void>;
|
|
13
13
|
protected onBeforeStart(project: Project): Promise<void>;
|
|
14
|
-
|
|
14
|
+
init(): Promise<void>;
|
|
15
|
+
add(name: string): Promise<void>;
|
|
16
|
+
delete(name: string, confirm?: boolean): Promise<void>;
|
|
15
17
|
eject(name?: string): Promise<void>;
|
|
16
18
|
build(rebuild: boolean, presetName: string): Promise<void>;
|
|
17
19
|
}
|
|
@@ -50,7 +50,6 @@ let PresetController = class PresetController {
|
|
|
50
50
|
this.projectService = projectService;
|
|
51
51
|
this.presetService = presetService;
|
|
52
52
|
this.dockerService = dockerService;
|
|
53
|
-
this.appConfigService.registerProjectType("preset", "Preset");
|
|
54
53
|
this.appEventsService.on("project:init", (project) => this.onInit(project));
|
|
55
54
|
this.appEventsService.on("project:beforeStart", (project) => this.onBeforeStart(project));
|
|
56
55
|
this.appEventsService.on("project:rebuild", (project) => this.onRebuild(project));
|
|
@@ -62,7 +61,7 @@ let PresetController = class PresetController {
|
|
|
62
61
|
});
|
|
63
62
|
}
|
|
64
63
|
async onInit(project) {
|
|
65
|
-
if (project.type !==
|
|
64
|
+
if (project.type !== core_1.PROJECT_TYPE_PRESET) {
|
|
66
65
|
return;
|
|
67
66
|
}
|
|
68
67
|
const presets = await this.presetService.search();
|
|
@@ -115,7 +114,7 @@ let PresetController = class PresetController {
|
|
|
115
114
|
}
|
|
116
115
|
}
|
|
117
116
|
async onRebuild(project) {
|
|
118
|
-
if (project.type !==
|
|
117
|
+
if (project.type !== core_1.PROJECT_TYPE_PRESET) {
|
|
119
118
|
return;
|
|
120
119
|
}
|
|
121
120
|
const preset = await this.presetService.get(project.preset);
|
|
@@ -130,7 +129,7 @@ let PresetController = class PresetController {
|
|
|
130
129
|
}
|
|
131
130
|
}
|
|
132
131
|
async onBeforeStart(project) {
|
|
133
|
-
if (project.type !==
|
|
132
|
+
if (project.type !== core_1.PROJECT_TYPE_PRESET) {
|
|
134
133
|
return;
|
|
135
134
|
}
|
|
136
135
|
const preset = await this.presetService.get(project.preset);
|
|
@@ -143,13 +142,31 @@ let PresetController = class PresetController {
|
|
|
143
142
|
presetName: preset.name
|
|
144
143
|
},
|
|
145
144
|
buildArgs: project.buildArgs,
|
|
146
|
-
context:
|
|
145
|
+
context: preset.path,
|
|
147
146
|
src: preset.dockerfile
|
|
148
147
|
});
|
|
149
148
|
}
|
|
150
149
|
}
|
|
151
150
|
}
|
|
152
|
-
async
|
|
151
|
+
async init() {
|
|
152
|
+
await this.presetService.init();
|
|
153
|
+
}
|
|
154
|
+
async add(name) {
|
|
155
|
+
await this.presetService.addPreset(name);
|
|
156
|
+
}
|
|
157
|
+
async delete(name, confirm) {
|
|
158
|
+
const preset = await this.presetService.get(name);
|
|
159
|
+
if (typeof confirm === "undefined" || confirm === null) {
|
|
160
|
+
confirm = await (0, utils_2.promptConfirm)({
|
|
161
|
+
message: `Delete preset ${name}?`,
|
|
162
|
+
default: false
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
if (!confirm) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
console.info("Deleting...");
|
|
169
|
+
await preset.delete();
|
|
153
170
|
}
|
|
154
171
|
async eject(name) {
|
|
155
172
|
if (name) {
|
|
@@ -167,7 +184,7 @@ let PresetController = class PresetController {
|
|
|
167
184
|
if (!confirm) {
|
|
168
185
|
return;
|
|
169
186
|
}
|
|
170
|
-
const copier = new core_1.FSManager(this.appConfigService.presetPath(preset.name), this.appConfigService.
|
|
187
|
+
const copier = new core_1.FSManager(this.appConfigService.presetPath(preset.name), this.appConfigService.pwd());
|
|
171
188
|
if (preset.dockerfile) {
|
|
172
189
|
if (!copier.destination.exists(preset.dockerfile)) {
|
|
173
190
|
await copier.copy(preset.dockerfile);
|
|
@@ -219,12 +236,30 @@ let PresetController = class PresetController {
|
|
|
219
236
|
}
|
|
220
237
|
};
|
|
221
238
|
exports.PresetController = PresetController;
|
|
239
|
+
__decorate([
|
|
240
|
+
(0, core_1.Command)("preset:init"),
|
|
241
|
+
__metadata("design:type", Function),
|
|
242
|
+
__metadata("design:paramtypes", []),
|
|
243
|
+
__metadata("design:returntype", Promise)
|
|
244
|
+
], PresetController.prototype, "init", null);
|
|
222
245
|
__decorate([
|
|
223
246
|
(0, core_1.Command)("preset:add <preset>"),
|
|
247
|
+
__param(0, (0, core_1.Param)("preset")),
|
|
224
248
|
__metadata("design:type", Function),
|
|
225
249
|
__metadata("design:paramtypes", [String]),
|
|
226
250
|
__metadata("design:returntype", Promise)
|
|
227
251
|
], PresetController.prototype, "add", null);
|
|
252
|
+
__decorate([
|
|
253
|
+
(0, core_1.Command)("preset:delete <preset>"),
|
|
254
|
+
__param(0, (0, core_1.Param)("preset")),
|
|
255
|
+
__param(1, (0, core_1.Option)("yes", {
|
|
256
|
+
alias: "y",
|
|
257
|
+
description: "Confirm deletion"
|
|
258
|
+
})),
|
|
259
|
+
__metadata("design:type", Function),
|
|
260
|
+
__metadata("design:paramtypes", [String, Boolean]),
|
|
261
|
+
__metadata("design:returntype", Promise)
|
|
262
|
+
], PresetController.prototype, "delete", null);
|
|
228
263
|
__decorate([
|
|
229
264
|
(0, core_1.Command)("preset:eject"),
|
|
230
265
|
__param(0, (0, core_1.Option)("name", {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ProjectType } from "@wocker/core";
|
|
1
2
|
import { AppConfigService, AppEventsService, ProjectService, DockerService, LogService } from "../services";
|
|
2
3
|
export declare class ProjectController {
|
|
3
4
|
protected readonly appConfigService: AppConfigService;
|
|
@@ -8,7 +9,7 @@ export declare class ProjectController {
|
|
|
8
9
|
constructor(appConfigService: AppConfigService, appEventsService: AppEventsService, projectService: ProjectService, dockerService: DockerService, logService: LogService);
|
|
9
10
|
protected getProjectNames(): Promise<string[]>;
|
|
10
11
|
getScriptNames(): Promise<string[]>;
|
|
11
|
-
init(name: string, type:
|
|
12
|
+
init(name: string, type: ProjectType, preset: string): Promise<void>;
|
|
12
13
|
projectList(all: boolean): Promise<string>;
|
|
13
14
|
start(name?: string, detach?: boolean, attach?: boolean, rebuild?: boolean, restart?: boolean): Promise<void>;
|
|
14
15
|
stop(name: string): Promise<void>;
|
|
@@ -73,13 +73,15 @@ let ProjectController = class ProjectController {
|
|
|
73
73
|
}
|
|
74
74
|
async init(name, type, preset) {
|
|
75
75
|
let project = await this.projectService.searchOne({
|
|
76
|
-
path: this.appConfigService.
|
|
76
|
+
path: this.appConfigService.pwd()
|
|
77
77
|
});
|
|
78
|
+
const fs = new core_1.FileSystem(this.appConfigService.pwd());
|
|
78
79
|
if (!project) {
|
|
79
80
|
project = this.projectService.fromObject({
|
|
80
|
-
path: this.appConfigService.
|
|
81
|
+
path: this.appConfigService.pwd()
|
|
81
82
|
});
|
|
82
83
|
}
|
|
84
|
+
project.path = this.appConfigService.pwd();
|
|
83
85
|
if (name) {
|
|
84
86
|
project.name = name;
|
|
85
87
|
}
|
|
@@ -97,15 +99,15 @@ let ProjectController = class ProjectController {
|
|
|
97
99
|
}
|
|
98
100
|
const mapTypes = this.appConfigService.getProjectTypes();
|
|
99
101
|
if (!type || !project.type || !mapTypes[project.type]) {
|
|
100
|
-
project.type = await (0, utils_1.promptSelect)({
|
|
102
|
+
project.type = (await (0, utils_1.promptSelect)({
|
|
101
103
|
message: "Project type:",
|
|
102
104
|
options: mapTypes,
|
|
103
105
|
default: project.type
|
|
104
|
-
});
|
|
106
|
+
}));
|
|
105
107
|
}
|
|
106
108
|
switch (project.type) {
|
|
107
109
|
case core_1.PROJECT_TYPE_DOCKERFILE: {
|
|
108
|
-
const files = await
|
|
110
|
+
const files = await fs.readdirFiles();
|
|
109
111
|
const dockerfiles = files.filter((fileName) => {
|
|
110
112
|
if (new RegExp("^(.*)\\.dockerfile$").test(fileName)) {
|
|
111
113
|
return true;
|
|
@@ -113,28 +115,30 @@ let ProjectController = class ProjectController {
|
|
|
113
115
|
return new RegExp("^Dockerfile(\\..*)?").test(fileName);
|
|
114
116
|
});
|
|
115
117
|
project.dockerfile = await (0, utils_1.promptSelect)({
|
|
118
|
+
message: "Dockerfile:",
|
|
116
119
|
options: dockerfiles.map((dockerfile) => {
|
|
117
120
|
return {
|
|
118
121
|
value: dockerfile
|
|
119
122
|
};
|
|
120
123
|
}),
|
|
121
|
-
message: "Dockerfile",
|
|
122
124
|
default: project.dockerfile
|
|
123
125
|
});
|
|
124
126
|
break;
|
|
125
127
|
}
|
|
126
128
|
case core_1.PROJECT_TYPE_IMAGE: {
|
|
127
129
|
project.imageName = await (0, utils_1.promptText)({
|
|
128
|
-
message: "Image
|
|
130
|
+
message: "Image name:",
|
|
131
|
+
required: true,
|
|
129
132
|
default: project.imageName
|
|
130
133
|
});
|
|
131
134
|
break;
|
|
132
135
|
}
|
|
133
|
-
|
|
136
|
+
case core_1.PROJECT_TYPE_PRESET:
|
|
134
137
|
break;
|
|
138
|
+
default:
|
|
139
|
+
throw new Error("Invalid project type");
|
|
135
140
|
}
|
|
136
141
|
await this.appEventsService.emit("project:init", project);
|
|
137
|
-
project.path = this.appConfigService.getPWD();
|
|
138
142
|
await project.save();
|
|
139
143
|
}
|
|
140
144
|
async projectList(all) {
|
|
@@ -161,19 +165,18 @@ let ProjectController = class ProjectController {
|
|
|
161
165
|
await this.projectService.cdProject(name);
|
|
162
166
|
}
|
|
163
167
|
const project = await this.projectService.get();
|
|
164
|
-
await this.projectService.start(project,
|
|
168
|
+
await this.projectService.start(project, restart, rebuild);
|
|
165
169
|
if (detach) {
|
|
166
170
|
console.info(chalk_1.default.yellow("Warning: Detach option is deprecated"));
|
|
167
171
|
}
|
|
168
172
|
if (attach) {
|
|
169
173
|
const project = await this.projectService.get();
|
|
170
|
-
const
|
|
171
|
-
const container = await this.dockerService.getContainer(containerName);
|
|
174
|
+
const container = await this.dockerService.getContainer(project.containerName);
|
|
172
175
|
await container.resize({
|
|
173
176
|
w: process.stdout.columns,
|
|
174
177
|
h: process.stdout.rows
|
|
175
178
|
});
|
|
176
|
-
await this.dockerService.attach(containerName);
|
|
179
|
+
await this.dockerService.attach(project.containerName);
|
|
177
180
|
}
|
|
178
181
|
}
|
|
179
182
|
async stop(name) {
|
|
@@ -820,6 +823,7 @@ __decorate([
|
|
|
820
823
|
type: "boolean",
|
|
821
824
|
alias: "g"
|
|
822
825
|
})),
|
|
826
|
+
__param(2, (0, core_1.Param)("configs")),
|
|
823
827
|
__metadata("design:type", Function),
|
|
824
828
|
__metadata("design:paramtypes", [String, Boolean, Array]),
|
|
825
829
|
__metadata("design:returntype", Promise)
|
|
@@ -10,7 +10,7 @@ export declare class ProxyController {
|
|
|
10
10
|
onProjectStart(project: Project): Promise<void>;
|
|
11
11
|
onProjectStop(project: Project): Promise<void>;
|
|
12
12
|
getProjectNames(): Promise<string[]>;
|
|
13
|
-
init(httpPort
|
|
13
|
+
init(httpPort?: number, httpsPort?: number): Promise<void>;
|
|
14
14
|
start(restart?: boolean): Promise<void>;
|
|
15
15
|
stop(): Promise<void>;
|
|
16
16
|
logs(): Promise<void>;
|
|
@@ -49,20 +49,20 @@ let ProxyController = class ProxyController {
|
|
|
49
49
|
}
|
|
50
50
|
async init(httpPort, httpsPort) {
|
|
51
51
|
const config = await this.appConfigService.getConfig();
|
|
52
|
-
if (typeof httpPort === "undefined" || isNaN(httpPort)) {
|
|
52
|
+
if (httpPort === null || typeof httpPort === "undefined" || isNaN(httpPort)) {
|
|
53
53
|
httpPort = await (0, utils_1.promptText)({
|
|
54
54
|
required: true,
|
|
55
55
|
message: "Http port:",
|
|
56
|
-
type: "
|
|
56
|
+
type: "number",
|
|
57
57
|
default: config.getMeta("PROXY_HTTP_PORT", "80")
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
config.setMeta("PROXY_HTTP_PORT", httpPort.toString());
|
|
61
|
-
if (typeof httpsPort === "undefined" || isNaN(httpsPort)) {
|
|
61
|
+
if (httpsPort === null || typeof httpsPort === "undefined" || isNaN(httpsPort)) {
|
|
62
62
|
httpsPort = await (0, utils_1.promptText)({
|
|
63
63
|
required: true,
|
|
64
64
|
message: "Https port:",
|
|
65
|
-
type: "
|
|
65
|
+
type: "number",
|
|
66
66
|
default: config.getMeta("PROXY_HTTPS_PORT", "443")
|
|
67
67
|
});
|
|
68
68
|
}
|
package/lib/env.d.ts
CHANGED
package/lib/env.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.VIRTUAL_HOST_KEY = exports.
|
|
26
|
+
exports.VIRTUAL_HOST_KEY = exports.DATA_DIR = exports.PLUGINS_DIR = exports.SERVICES_DIR = exports.PRESETS_DIR = exports.ROOT_DIR = exports.NODE_ENV = void 0;
|
|
27
27
|
const OS = __importStar(require("os"));
|
|
28
28
|
const Path = __importStar(require("path"));
|
|
29
29
|
exports.NODE_ENV = process.env.NODE_ENV;
|
|
@@ -32,5 +32,4 @@ exports.PRESETS_DIR = Path.join(exports.ROOT_DIR, "presets");
|
|
|
32
32
|
exports.SERVICES_DIR = Path.join(exports.ROOT_DIR, "services");
|
|
33
33
|
exports.PLUGINS_DIR = Path.join(exports.ROOT_DIR, "plugins");
|
|
34
34
|
exports.DATA_DIR = process.env.WS_DIR || Path.join(OS.homedir(), ".workspace");
|
|
35
|
-
exports.MAP_PATH = Path.join(exports.DATA_DIR, "data.json");
|
|
36
35
|
exports.VIRTUAL_HOST_KEY = "VIRTUAL_HOST";
|
package/lib/plugins/index.d.ts
CHANGED
package/lib/plugins/index.js
CHANGED
|
@@ -16,5 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./ElasticSearchPlugin"), exports);
|
|
18
18
|
__exportStar(require("./MongodbPlugin"), exports);
|
|
19
|
-
__exportStar(require("./PageKitePlugin"), exports);
|
|
20
19
|
__exportStar(require("./ProxmoxPlugin"), exports);
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AppConfig, AppConfigService as CoreAppConfigService } from "@wocker/core";
|
|
2
2
|
type TypeMap = {
|
|
3
3
|
[type: string]: string;
|
|
4
4
|
};
|
|
5
5
|
export declare class AppConfigService extends CoreAppConfigService {
|
|
6
|
-
protected
|
|
6
|
+
protected _pwd: string;
|
|
7
7
|
protected mapTypes: TypeMap;
|
|
8
8
|
constructor();
|
|
9
|
+
setPWD(pwd: string): void;
|
|
10
|
+
getPWD(...parts: string[]): string;
|
|
11
|
+
pwd(...parts: string[]): string;
|
|
9
12
|
dataPath(...parts: string[]): string;
|
|
10
13
|
pluginsPath(...parts: string[]): string;
|
|
11
14
|
presetPath(...parts: string[]): string;
|
|
12
|
-
getPWD(): string;
|
|
13
|
-
setPWD(pwd: string): void;
|
|
14
15
|
getProjectTypes(): TypeMap;
|
|
15
|
-
|
|
16
|
-
protected loadConfig(): Promise<Config>;
|
|
16
|
+
protected loadConfig(): AppConfig;
|
|
17
17
|
}
|
|
18
18
|
export {};
|
|
@@ -36,15 +36,24 @@ exports.AppConfigService = void 0;
|
|
|
36
36
|
const core_1 = require("@wocker/core");
|
|
37
37
|
const Path = __importStar(require("path"));
|
|
38
38
|
const env_1 = require("../env");
|
|
39
|
-
const makes_1 = require("../makes");
|
|
40
39
|
let AppConfigService = class AppConfigService extends core_1.AppConfigService {
|
|
41
40
|
constructor() {
|
|
42
41
|
super();
|
|
43
42
|
this.mapTypes = {
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
[core_1.PROJECT_TYPE_IMAGE]: "Image",
|
|
44
|
+
[core_1.PROJECT_TYPE_DOCKERFILE]: "Dockerfile",
|
|
45
|
+
[core_1.PROJECT_TYPE_PRESET]: "Preset"
|
|
46
46
|
};
|
|
47
|
-
this.
|
|
47
|
+
this._pwd = (process.cwd() || process.env.PWD);
|
|
48
|
+
}
|
|
49
|
+
setPWD(pwd) {
|
|
50
|
+
this._pwd = pwd;
|
|
51
|
+
}
|
|
52
|
+
getPWD(...parts) {
|
|
53
|
+
return this.pwd(...parts);
|
|
54
|
+
}
|
|
55
|
+
pwd(...parts) {
|
|
56
|
+
return Path.join(this._pwd, ...parts);
|
|
48
57
|
}
|
|
49
58
|
dataPath(...parts) {
|
|
50
59
|
return Path.join(env_1.DATA_DIR, ...parts);
|
|
@@ -55,37 +64,43 @@ let AppConfigService = class AppConfigService extends core_1.AppConfigService {
|
|
|
55
64
|
presetPath(...parts) {
|
|
56
65
|
return Path.join(env_1.PRESETS_DIR, ...parts);
|
|
57
66
|
}
|
|
58
|
-
getPWD() {
|
|
59
|
-
return this.pwd;
|
|
60
|
-
}
|
|
61
|
-
setPWD(pwd) {
|
|
62
|
-
this.pwd = pwd;
|
|
63
|
-
}
|
|
64
67
|
getProjectTypes() {
|
|
65
68
|
return this.mapTypes;
|
|
66
69
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
loadConfig() {
|
|
71
|
+
const fs = new core_1.FileSystem(env_1.DATA_DIR);
|
|
72
|
+
let data = {};
|
|
73
|
+
if (fs.exists("wocker.config.js")) {
|
|
74
|
+
try {
|
|
75
|
+
const { config } = require(fs.path("wocker.config.js"));
|
|
76
|
+
data = config;
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
if (fs.exists("wocker.json")) {
|
|
80
|
+
data = fs.readJSON("wocker.json");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
else if (fs.exists("wocker.json")) {
|
|
85
|
+
data = fs.readJSON("wocker.json");
|
|
86
|
+
}
|
|
87
|
+
else if (fs.exists("data.json")) {
|
|
88
|
+
data = fs.readJSON("data.json");
|
|
89
|
+
}
|
|
90
|
+
return new class extends core_1.AppConfig {
|
|
75
91
|
constructor(data) {
|
|
76
92
|
super(data);
|
|
77
93
|
}
|
|
78
|
-
|
|
79
|
-
if (!
|
|
80
|
-
|
|
94
|
+
async save() {
|
|
95
|
+
if (!fs.exists()) {
|
|
96
|
+
fs.mkdir("");
|
|
81
97
|
}
|
|
82
|
-
|
|
83
|
-
|
|
98
|
+
const json = JSON.stringify(this.toJson(), null, 4);
|
|
99
|
+
await fs.writeFile("wocker.config.js", `// Wocker config\nexports.config = ${json};`);
|
|
100
|
+
await fs.writeJSON("wocker.json", json);
|
|
101
|
+
if (fs.exists("data.json")) {
|
|
102
|
+
await fs.rm("data.json");
|
|
84
103
|
}
|
|
85
|
-
this.plugins.push(plugin);
|
|
86
|
-
}
|
|
87
|
-
async save() {
|
|
88
|
-
await makes_1.FS.writeJSON(env_1.MAP_PATH, this.toJson());
|
|
89
104
|
}
|
|
90
105
|
}(data);
|
|
91
106
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { LogService as CoreLogService } from "@wocker/core";
|
|
1
2
|
import { AppConfigService } from "./AppConfigService";
|
|
2
|
-
export declare class LogService {
|
|
3
|
+
export declare class LogService extends CoreLogService {
|
|
3
4
|
protected readonly appConfigService: AppConfigService;
|
|
4
5
|
constructor(appConfigService: AppConfigService);
|
|
6
|
+
debug(...data: any[]): void;
|
|
5
7
|
log(...data: any[]): void;
|
|
6
8
|
info(...data: any[]): void;
|
|
7
9
|
warn(...data: any[]): void;
|
|
@@ -17,11 +17,15 @@ const core_1 = require("@wocker/core");
|
|
|
17
17
|
const format_1 = __importDefault(require("date-fns/format"));
|
|
18
18
|
const makes_1 = require("../makes");
|
|
19
19
|
const AppConfigService_1 = require("./AppConfigService");
|
|
20
|
-
let LogService = class LogService {
|
|
20
|
+
let LogService = class LogService extends core_1.LogService {
|
|
21
21
|
constructor(appConfigService) {
|
|
22
|
+
super();
|
|
22
23
|
this.appConfigService = appConfigService;
|
|
23
24
|
makes_1.Logger.install(this);
|
|
24
25
|
}
|
|
26
|
+
debug(...data) {
|
|
27
|
+
this._log("debug", ...data);
|
|
28
|
+
}
|
|
25
29
|
log(...data) {
|
|
26
30
|
this._log("log", ...data);
|
|
27
31
|
}
|
|
@@ -35,6 +39,10 @@ let LogService = class LogService {
|
|
|
35
39
|
this._log("error", ...data);
|
|
36
40
|
}
|
|
37
41
|
_log(type, ...data) {
|
|
42
|
+
const config = this.appConfigService.getConfig();
|
|
43
|
+
if (type === "debug" && !config.debug) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
38
46
|
const time = (0, format_1.default)(new Date(), "yyyy-MM-dd hh:mm:ss");
|
|
39
47
|
const logPath = this.appConfigService.dataPath("ws.log");
|
|
40
48
|
const logData = data.map((item) => {
|
|
@@ -47,7 +47,7 @@ let PluginService = class PluginService {
|
|
|
47
47
|
async checkPlugin(pluginName) {
|
|
48
48
|
try {
|
|
49
49
|
const { default: Plugin } = await Promise.resolve(`${pluginName}`).then(s => __importStar(require(s)));
|
|
50
|
-
const name = Reflect.getMetadata(core_1.
|
|
50
|
+
const name = Reflect.getMetadata(core_1.PLUGIN_NAME_METADATA, Plugin);
|
|
51
51
|
if (!name) {
|
|
52
52
|
console.log("No name");
|
|
53
53
|
}
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import { EnvConfig, Preset } from "@wocker/core";
|
|
1
|
+
import { EnvConfig, Preset, AppConfig, PresetProperties } from "@wocker/core";
|
|
2
|
+
import { AppConfigService } from "./AppConfigService";
|
|
3
|
+
import { LogService } from "./LogService";
|
|
2
4
|
type SearchOptions = Partial<{
|
|
3
5
|
name: string;
|
|
6
|
+
source: string;
|
|
7
|
+
path: string;
|
|
4
8
|
}>;
|
|
5
9
|
export declare class PresetService {
|
|
6
|
-
|
|
10
|
+
protected readonly appConfigService: AppConfigService;
|
|
11
|
+
protected readonly logService: LogService;
|
|
12
|
+
constructor(appConfigService: AppConfigService, logService: LogService);
|
|
13
|
+
protected toObject(config: PresetProperties): Preset;
|
|
14
|
+
protected getList(): Promise<AppConfig["presets"]>;
|
|
7
15
|
getImageName(preset: Preset, buildArgs?: EnvConfig): string;
|
|
8
|
-
|
|
16
|
+
init(): Promise<void>;
|
|
9
17
|
get(name: string): Promise<Preset>;
|
|
18
|
+
addPreset(name: string): Promise<void>;
|
|
10
19
|
search(options?: SearchOptions): Promise<Preset[]>;
|
|
11
20
|
searchOne(options?: SearchOptions): Promise<Preset | null>;
|
|
12
21
|
}
|