@wocker/ws 1.0.21 → 1.0.22
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/README.md +8 -0
- package/lib/AppModule.js +17 -53
- package/lib/controllers/DebugController.d.ts +2 -1
- package/lib/controllers/DebugController.js +13 -5
- package/lib/controllers/KeystoreController.d.ts +11 -0
- package/lib/controllers/KeystoreController.js +106 -0
- package/lib/controllers/PluginController.d.ts +3 -5
- package/lib/controllers/PluginController.js +11 -57
- package/lib/controllers/PresetController.d.ts +4 -2
- package/lib/controllers/PresetController.js +50 -44
- package/lib/controllers/ProjectController.d.ts +1 -0
- package/lib/controllers/ProjectController.js +45 -36
- package/lib/controllers/ProxyController.js +37 -31
- package/lib/controllers/index.d.ts +1 -1
- package/lib/controllers/index.js +1 -1
- package/lib/env.d.ts +2 -1
- package/lib/env.js +3 -2
- package/lib/keystore/KeystoreService.d.ts +12 -0
- package/lib/keystore/KeystoreService.js +70 -0
- package/lib/keystore/index.d.ts +1 -0
- package/lib/keystore/index.js +17 -0
- package/lib/keystore/providers/FileKeystoreProvider.d.ts +16 -0
- package/lib/keystore/providers/FileKeystoreProvider.js +97 -0
- package/lib/keystore/providers/KeytarKeystoreProvider.d.ts +9 -0
- package/lib/keystore/providers/KeytarKeystoreProvider.js +74 -0
- package/lib/keystore/types/Encryption.d.ts +9 -0
- package/lib/keystore/types/Encryption.js +81 -0
- package/lib/keystore/types/Encryptor.d.ts +10 -0
- package/lib/keystore/types/Encryptor.js +59 -0
- package/lib/keystore/types/FileKeystore.d.ts +17 -0
- package/lib/keystore/types/FileKeystore.js +33 -0
- package/lib/keystore/types/Keytar.d.ts +8 -0
- package/lib/keystore/types/Keytar.js +2 -0
- package/lib/keystore/utils/createEncryptionKey.d.ts +1 -0
- package/lib/keystore/utils/createEncryptionKey.js +46 -0
- package/lib/keystore/utils/createPasswordHash.d.ts +1 -0
- package/lib/keystore/utils/createPasswordHash.js +20 -0
- package/lib/keystore/utils/decrypt.d.ts +1 -0
- package/lib/keystore/utils/decrypt.js +15 -0
- package/lib/keystore/utils/encrypt.d.ts +1 -0
- package/lib/keystore/utils/encrypt.js +19 -0
- package/lib/keystore/utils/index.d.ts +5 -0
- package/lib/keystore/utils/index.js +21 -0
- package/lib/keystore/utils/verifyPasswordHash.d.ts +1 -0
- package/lib/keystore/utils/verifyPasswordHash.js +9 -0
- package/lib/main.js +10 -5
- package/lib/makes/FS.d.ts +1 -1
- package/lib/makes/GithubClient.d.ts +14 -0
- package/lib/makes/GithubClient.js +65 -0
- package/lib/makes/Plugin.d.ts +6 -0
- package/lib/makes/Plugin.js +16 -0
- package/lib/makes/index.d.ts +1 -0
- package/lib/makes/index.js +1 -0
- package/lib/plugins/index.d.ts +0 -2
- package/lib/plugins/index.js +0 -2
- package/lib/repositories/PresetRepository.d.ts +23 -0
- package/lib/repositories/PresetRepository.js +115 -0
- package/lib/repositories/index.d.ts +1 -0
- package/lib/repositories/index.js +17 -0
- package/lib/services/AppConfigService.d.ts +16 -1
- package/lib/services/AppConfigService.js +71 -55
- package/lib/services/AppEventsService.d.ts +4 -4
- package/lib/services/AppEventsService.js +14 -10
- package/lib/services/CertService.js +2 -2
- package/lib/services/DockerService.js +6 -3
- package/lib/services/LogService.d.ts +3 -1
- package/lib/services/LogService.js +12 -10
- package/lib/services/PluginService.d.ts +8 -2
- package/lib/services/PluginService.js +71 -16
- package/lib/services/PresetService.d.ts +9 -8
- package/lib/services/PresetService.js +144 -258
- package/lib/services/ProjectService.d.ts +5 -2
- package/lib/services/ProjectService.js +37 -10
- package/lib/services/ProxyService.js +6 -6
- package/lib/utils/index.d.ts +0 -2
- package/lib/utils/index.js +0 -2
- package/package.json +23 -13
- package/lib/controllers/ImageController.d.ts +0 -7
- package/lib/controllers/ImageController.js +0 -46
- package/lib/makes/Model.d.ts +0 -5
- package/lib/makes/Model.js +0 -12
- package/lib/plugins/elastic-search/controllers/ElasticSearchController.d.ts +0 -10
- package/lib/plugins/elastic-search/controllers/ElasticSearchController.js +0 -91
- package/lib/plugins/elastic-search/index.d.ts +0 -2
- package/lib/plugins/elastic-search/index.js +0 -22
- package/lib/plugins/proxmox/controllers/ProxmoxController.d.ts +0 -14
- package/lib/plugins/proxmox/controllers/ProxmoxController.js +0 -127
- package/lib/plugins/proxmox/index.d.ts +0 -2
- package/lib/plugins/proxmox/index.js +0 -23
- package/lib/utils/volumeFormat.d.ts +0 -6
- package/lib/utils/volumeFormat.js +0 -8
- package/lib/utils/volumeParse.d.ts +0 -2
- package/lib/utils/volumeParse.js +0 -13
- package/presets/bun/Dockerfile +0 -11
- package/presets/bun/config.json +0 -4
|
@@ -56,20 +56,22 @@ const Path = __importStar(require("path"));
|
|
|
56
56
|
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
57
57
|
const env_1 = require("../env");
|
|
58
58
|
const utils_3 = require("../utils");
|
|
59
|
+
const repositories_1 = require("../repositories");
|
|
59
60
|
const services_1 = require("../services");
|
|
60
61
|
let PresetController = class PresetController {
|
|
61
|
-
constructor(appConfigService, appEventsService, projectService, presetService, dockerService) {
|
|
62
|
+
constructor(appConfigService, appEventsService, projectService, presetService, presetRepository, dockerService) {
|
|
62
63
|
this.appConfigService = appConfigService;
|
|
63
64
|
this.appEventsService = appEventsService;
|
|
64
65
|
this.projectService = projectService;
|
|
65
66
|
this.presetService = presetService;
|
|
67
|
+
this.presetRepository = presetRepository;
|
|
66
68
|
this.dockerService = dockerService;
|
|
67
69
|
this.appEventsService.on("project:init", (project) => this.onInit(project));
|
|
68
70
|
this.appEventsService.on("project:beforeStart", (project) => this.onBeforeStart(project));
|
|
69
71
|
this.appEventsService.on("project:rebuild", (project) => this.onRebuild(project));
|
|
70
72
|
}
|
|
71
73
|
async presets() {
|
|
72
|
-
const presets =
|
|
74
|
+
const presets = this.presetRepository.search();
|
|
73
75
|
return presets.map((preset) => {
|
|
74
76
|
return preset.name;
|
|
75
77
|
});
|
|
@@ -78,12 +80,12 @@ let PresetController = class PresetController {
|
|
|
78
80
|
if (project.type !== core_1.PROJECT_TYPE_PRESET) {
|
|
79
81
|
return;
|
|
80
82
|
}
|
|
81
|
-
const presets =
|
|
83
|
+
const presets = this.presetRepository.search();
|
|
82
84
|
if (presets.length === 0) {
|
|
83
85
|
throw new Error("No presets");
|
|
84
86
|
}
|
|
85
87
|
project.preset = await (0, utils_1.promptSelect)({
|
|
86
|
-
message: "Choose preset
|
|
88
|
+
message: "Choose preset",
|
|
87
89
|
options: presets.map((preset) => {
|
|
88
90
|
return {
|
|
89
91
|
label: preset.name,
|
|
@@ -93,7 +95,7 @@ let PresetController = class PresetController {
|
|
|
93
95
|
default: project.preset
|
|
94
96
|
});
|
|
95
97
|
project.presetMode = await (0, utils_1.promptSelect)({
|
|
96
|
-
message: "Preset mode
|
|
98
|
+
message: "Preset mode",
|
|
97
99
|
options: [
|
|
98
100
|
{
|
|
99
101
|
label: "For project only",
|
|
@@ -106,15 +108,15 @@ let PresetController = class PresetController {
|
|
|
106
108
|
],
|
|
107
109
|
default: project.presetMode
|
|
108
110
|
});
|
|
109
|
-
const preset =
|
|
111
|
+
const preset = this.presetService.get(project.preset);
|
|
110
112
|
if (!preset) {
|
|
111
113
|
throw new Error("Preset not found");
|
|
112
114
|
}
|
|
113
115
|
if (preset.buildArgsOptions) {
|
|
114
|
-
project.buildArgs = await
|
|
116
|
+
project.buildArgs = await this.presetService.prompt(preset.buildArgsOptions, project.buildArgs);
|
|
115
117
|
}
|
|
116
118
|
if (preset.envOptions) {
|
|
117
|
-
project.env = await
|
|
119
|
+
project.env = await this.presetService.prompt(preset.envOptions, project.env);
|
|
118
120
|
}
|
|
119
121
|
if (preset.volumeOptions) {
|
|
120
122
|
for (let volume of preset.volumeOptions) {
|
|
@@ -122,15 +124,15 @@ let PresetController = class PresetController {
|
|
|
122
124
|
...project.buildArgs || {},
|
|
123
125
|
...project.env || {}
|
|
124
126
|
});
|
|
125
|
-
const { source, destination, options } = (0,
|
|
127
|
+
const { source, destination, options } = (0, utils_2.volumeParse)(volume);
|
|
126
128
|
let projectVolume = project.getVolumeByDestination(destination);
|
|
127
|
-
const newSource = await (0, utils_1.
|
|
128
|
-
message: "Volume
|
|
129
|
+
const newSource = await (0, utils_1.promptInput)({
|
|
130
|
+
message: "Volume",
|
|
129
131
|
required: true,
|
|
130
132
|
suffix: `:${destination}`,
|
|
131
|
-
default: projectVolume ? (0,
|
|
133
|
+
default: projectVolume ? (0, utils_2.volumeParse)(projectVolume).source : source
|
|
132
134
|
});
|
|
133
|
-
projectVolume = (0,
|
|
135
|
+
projectVolume = (0, utils_2.volumeFormat)({
|
|
134
136
|
source: newSource,
|
|
135
137
|
destination,
|
|
136
138
|
options
|
|
@@ -146,7 +148,7 @@ let PresetController = class PresetController {
|
|
|
146
148
|
if (project.type !== core_1.PROJECT_TYPE_PRESET) {
|
|
147
149
|
return;
|
|
148
150
|
}
|
|
149
|
-
const preset =
|
|
151
|
+
const preset = this.presetService.get(project.preset);
|
|
150
152
|
if (!preset) {
|
|
151
153
|
throw new Error(`Preset ${project.preset} not found`);
|
|
152
154
|
}
|
|
@@ -161,7 +163,7 @@ let PresetController = class PresetController {
|
|
|
161
163
|
if (project.type !== core_1.PROJECT_TYPE_PRESET) {
|
|
162
164
|
return;
|
|
163
165
|
}
|
|
164
|
-
const preset =
|
|
166
|
+
const preset = this.presetService.get(project.preset);
|
|
165
167
|
if (preset.dockerfile) {
|
|
166
168
|
project.imageName = this.presetService.getImageNameForProject(project, preset);
|
|
167
169
|
if (!await this.dockerService.imageExists(project.imageName)) {
|
|
@@ -180,27 +182,32 @@ let PresetController = class PresetController {
|
|
|
180
182
|
async init() {
|
|
181
183
|
await this.presetService.init();
|
|
182
184
|
}
|
|
183
|
-
async
|
|
185
|
+
async destroy() {
|
|
184
186
|
await this.presetService.deinit();
|
|
185
187
|
}
|
|
186
188
|
async add(name, version) {
|
|
187
189
|
await this.presetService.addPreset(name, version);
|
|
188
190
|
}
|
|
189
191
|
async list() {
|
|
190
|
-
const presets =
|
|
192
|
+
const presets = this.presetRepository.search();
|
|
191
193
|
const table = new cli_table3_1.default({
|
|
192
194
|
head: [
|
|
193
195
|
"Name",
|
|
194
|
-
"Source"
|
|
196
|
+
"Source",
|
|
197
|
+
"Path"
|
|
195
198
|
]
|
|
196
199
|
});
|
|
197
200
|
for (const preset of presets) {
|
|
198
|
-
table.push([
|
|
201
|
+
table.push([
|
|
202
|
+
preset.name,
|
|
203
|
+
preset.source,
|
|
204
|
+
preset.source === core_1.PRESET_SOURCE_EXTERNAL ? preset.path : ""
|
|
205
|
+
]);
|
|
199
206
|
}
|
|
200
207
|
return table.toString();
|
|
201
208
|
}
|
|
202
209
|
async delete(name, confirm) {
|
|
203
|
-
const preset =
|
|
210
|
+
const preset = this.presetService.get(name);
|
|
204
211
|
if (typeof confirm === "undefined" || confirm === null) {
|
|
205
212
|
confirm = await (0, utils_2.promptConfirm)({
|
|
206
213
|
message: `Delete preset ${name}?`,
|
|
@@ -211,14 +218,14 @@ let PresetController = class PresetController {
|
|
|
211
218
|
return;
|
|
212
219
|
}
|
|
213
220
|
console.info("Deleting...");
|
|
214
|
-
|
|
221
|
+
preset.delete();
|
|
215
222
|
}
|
|
216
223
|
async eject(name) {
|
|
217
224
|
if (name) {
|
|
218
225
|
this.projectService.cdProject(name);
|
|
219
226
|
}
|
|
220
227
|
const project = this.projectService.get();
|
|
221
|
-
const preset =
|
|
228
|
+
const preset = this.presetService.get(project.preset);
|
|
222
229
|
if (!preset) {
|
|
223
230
|
throw new Error("Preset not found");
|
|
224
231
|
}
|
|
@@ -256,17 +263,17 @@ let PresetController = class PresetController {
|
|
|
256
263
|
recursive: true
|
|
257
264
|
});
|
|
258
265
|
}
|
|
259
|
-
|
|
266
|
+
copier.copy(path);
|
|
260
267
|
}
|
|
261
268
|
delete project.preset;
|
|
262
269
|
delete project.imageName;
|
|
263
|
-
|
|
270
|
+
project.save();
|
|
264
271
|
}
|
|
265
272
|
async build(presetName, rebuild) {
|
|
266
|
-
const preset =
|
|
273
|
+
const preset = this.presetService.get(presetName);
|
|
267
274
|
let buildArgs = {};
|
|
268
275
|
if (preset.buildArgsOptions) {
|
|
269
|
-
buildArgs = await
|
|
276
|
+
buildArgs = await this.presetService.prompt(preset.buildArgsOptions);
|
|
270
277
|
}
|
|
271
278
|
const imageName = this.presetService.getImageName(preset, buildArgs);
|
|
272
279
|
if (rebuild) {
|
|
@@ -286,19 +293,21 @@ let PresetController = class PresetController {
|
|
|
286
293
|
exports.PresetController = PresetController;
|
|
287
294
|
__decorate([
|
|
288
295
|
(0, core_1.Command)("preset:init"),
|
|
296
|
+
(0, core_1.Description)("Creates preset config for current dir"),
|
|
289
297
|
__metadata("design:type", Function),
|
|
290
298
|
__metadata("design:paramtypes", []),
|
|
291
299
|
__metadata("design:returntype", Promise)
|
|
292
300
|
], PresetController.prototype, "init", null);
|
|
293
301
|
__decorate([
|
|
294
|
-
(0, core_1.Command)("preset:
|
|
302
|
+
(0, core_1.Command)("preset:destroy"),
|
|
295
303
|
__metadata("design:type", Function),
|
|
296
304
|
__metadata("design:paramtypes", []),
|
|
297
305
|
__metadata("design:returntype", Promise)
|
|
298
|
-
], PresetController.prototype, "
|
|
306
|
+
], PresetController.prototype, "destroy", null);
|
|
299
307
|
__decorate([
|
|
300
|
-
(0, core_1.Command)("preset:
|
|
301
|
-
(0, core_1.Command)("preset:
|
|
308
|
+
(0, core_1.Command)("preset:install <preset>"),
|
|
309
|
+
(0, core_1.Command)("preset:install <preset>@<version>"),
|
|
310
|
+
(0, core_1.Description)("Adding preset from github repository"),
|
|
302
311
|
__param(0, (0, core_1.Param)("preset")),
|
|
303
312
|
__param(1, (0, core_1.Param)("version")),
|
|
304
313
|
__metadata("design:type", Function),
|
|
@@ -307,6 +316,7 @@ __decorate([
|
|
|
307
316
|
], PresetController.prototype, "add", null);
|
|
308
317
|
__decorate([
|
|
309
318
|
(0, core_1.Command)("preset:ls"),
|
|
319
|
+
(0, core_1.Description)("List of all available presets"),
|
|
310
320
|
__metadata("design:type", Function),
|
|
311
321
|
__metadata("design:paramtypes", []),
|
|
312
322
|
__metadata("design:returntype", Promise)
|
|
@@ -314,42 +324,38 @@ __decorate([
|
|
|
314
324
|
__decorate([
|
|
315
325
|
(0, core_1.Command)("preset:delete <preset>"),
|
|
316
326
|
__param(0, (0, core_1.Param)("preset")),
|
|
317
|
-
__param(1, (0, core_1.Option)("yes",
|
|
318
|
-
|
|
319
|
-
description: "Confirm deletion"
|
|
320
|
-
})),
|
|
327
|
+
__param(1, (0, core_1.Option)("yes", "y")),
|
|
328
|
+
__param(1, (0, core_1.Description)("Confirm deletion")),
|
|
321
329
|
__metadata("design:type", Function),
|
|
322
330
|
__metadata("design:paramtypes", [String, Boolean]),
|
|
323
331
|
__metadata("design:returntype", Promise)
|
|
324
332
|
], PresetController.prototype, "delete", null);
|
|
325
333
|
__decorate([
|
|
326
334
|
(0, core_1.Command)("preset:eject"),
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
description: "Project name"
|
|
331
|
-
})),
|
|
335
|
+
(0, core_1.Description)("Eject preset files into the project"),
|
|
336
|
+
__param(0, (0, core_1.Option)("name", "n")),
|
|
337
|
+
__param(0, (0, core_1.Description)("The name of the project")),
|
|
332
338
|
__metadata("design:type", Function),
|
|
333
339
|
__metadata("design:paramtypes", [String]),
|
|
334
340
|
__metadata("design:returntype", Promise)
|
|
335
341
|
], PresetController.prototype, "eject", null);
|
|
336
342
|
__decorate([
|
|
337
343
|
(0, core_1.Command)("preset:build <preset>"),
|
|
344
|
+
(0, core_1.Description)("Build docker image form a preset"),
|
|
338
345
|
__param(0, (0, core_1.Param)("preset")),
|
|
339
|
-
__param(1, (0, core_1.Option)("rebuild",
|
|
340
|
-
|
|
341
|
-
alias: "r",
|
|
342
|
-
description: "Rebuild image"
|
|
343
|
-
})),
|
|
346
|
+
__param(1, (0, core_1.Option)("rebuild", "r")),
|
|
347
|
+
__param(1, (0, core_1.Description)("Rebuild image")),
|
|
344
348
|
__metadata("design:type", Function),
|
|
345
349
|
__metadata("design:paramtypes", [String, Boolean]),
|
|
346
350
|
__metadata("design:returntype", Promise)
|
|
347
351
|
], PresetController.prototype, "build", null);
|
|
348
352
|
exports.PresetController = PresetController = __decorate([
|
|
349
353
|
(0, core_1.Controller)(),
|
|
354
|
+
(0, core_1.Description)("Preset commands"),
|
|
350
355
|
__metadata("design:paramtypes", [services_1.AppConfigService,
|
|
351
356
|
services_1.AppEventsService,
|
|
352
357
|
services_1.ProjectService,
|
|
353
358
|
services_1.PresetService,
|
|
359
|
+
repositories_1.PresetRepository,
|
|
354
360
|
services_1.DockerService])
|
|
355
361
|
], PresetController);
|
|
@@ -10,6 +10,7 @@ export declare class ProjectController {
|
|
|
10
10
|
protected getProjectNames(): Promise<string[]>;
|
|
11
11
|
getScriptNames(): Promise<string[]>;
|
|
12
12
|
init(name: string, type: ProjectType): Promise<void>;
|
|
13
|
+
destroy(name?: string): Promise<void>;
|
|
13
14
|
projectList(all: boolean): Promise<string>;
|
|
14
15
|
start(name?: string, detach?: boolean, attach?: boolean, rebuild?: boolean, restart?: boolean): Promise<void>;
|
|
15
16
|
stop(name: string): Promise<void>;
|
|
@@ -52,7 +52,7 @@ exports.ProjectController = void 0;
|
|
|
52
52
|
const core_1 = require("@wocker/core");
|
|
53
53
|
const utils_1 = require("@wocker/utils");
|
|
54
54
|
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
55
|
-
const
|
|
55
|
+
const yoctocolors_cjs_1 = __importDefault(require("yoctocolors-cjs"));
|
|
56
56
|
const Path = __importStar(require("path"));
|
|
57
57
|
const async_mutex_1 = require("async-mutex");
|
|
58
58
|
const makes_1 = require("../makes");
|
|
@@ -95,11 +95,23 @@ let ProjectController = class ProjectController {
|
|
|
95
95
|
project.name = name;
|
|
96
96
|
}
|
|
97
97
|
if (!name || !project.name) {
|
|
98
|
-
project.name = await (0, utils_1.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
default: project.name || Path.basename(project.path)
|
|
98
|
+
project.name = await (0, utils_1.promptInput)({
|
|
99
|
+
required: "Project name is required",
|
|
100
|
+
message: "Project name",
|
|
101
|
+
type: "text",
|
|
102
|
+
default: project.name || Path.basename(project.path),
|
|
103
|
+
validate: (name) => {
|
|
104
|
+
if (typeof name !== "string") {
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
const otherProject = this.projectService.searchOne({
|
|
108
|
+
name
|
|
109
|
+
});
|
|
110
|
+
if (otherProject && otherProject.path !== project.path) {
|
|
111
|
+
return `Project "${name}" already exists`;
|
|
112
|
+
}
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
103
115
|
});
|
|
104
116
|
project.addDomain(project.containerName);
|
|
105
117
|
}
|
|
@@ -108,11 +120,11 @@ let ProjectController = class ProjectController {
|
|
|
108
120
|
}
|
|
109
121
|
const mapTypes = this.appConfigService.getProjectTypes();
|
|
110
122
|
if (!type || !project.type || !mapTypes[project.type]) {
|
|
111
|
-
project.type =
|
|
112
|
-
message: "Project type
|
|
123
|
+
project.type = await (0, utils_1.promptSelect)({
|
|
124
|
+
message: "Project type",
|
|
113
125
|
options: mapTypes,
|
|
114
126
|
default: project.type
|
|
115
|
-
})
|
|
127
|
+
});
|
|
116
128
|
}
|
|
117
129
|
switch (project.type) {
|
|
118
130
|
case core_1.PROJECT_TYPE_DOCKERFILE: {
|
|
@@ -127,7 +139,7 @@ let ProjectController = class ProjectController {
|
|
|
127
139
|
throw new Error("Dockerfiles not found");
|
|
128
140
|
}
|
|
129
141
|
project.dockerfile = await (0, utils_1.promptSelect)({
|
|
130
|
-
message: "Dockerfile
|
|
142
|
+
message: "Dockerfile",
|
|
131
143
|
options: dockerfiles.map((dockerfile) => {
|
|
132
144
|
return {
|
|
133
145
|
value: dockerfile
|
|
@@ -138,8 +150,8 @@ let ProjectController = class ProjectController {
|
|
|
138
150
|
break;
|
|
139
151
|
}
|
|
140
152
|
case core_1.PROJECT_TYPE_IMAGE: {
|
|
141
|
-
project.imageName = await (0, utils_1.
|
|
142
|
-
message: "Image name
|
|
153
|
+
project.imageName = await (0, utils_1.promptInput)({
|
|
154
|
+
message: "Image name",
|
|
143
155
|
required: true,
|
|
144
156
|
default: project.imageName
|
|
145
157
|
});
|
|
@@ -153,6 +165,9 @@ let ProjectController = class ProjectController {
|
|
|
153
165
|
await this.appEventsService.emit("project:init", project);
|
|
154
166
|
await project.save();
|
|
155
167
|
}
|
|
168
|
+
async destroy(name) {
|
|
169
|
+
const project = this.projectService.get(name);
|
|
170
|
+
}
|
|
156
171
|
async projectList(all) {
|
|
157
172
|
const table = new cli_table3_1.default({
|
|
158
173
|
head: ["Name", "Type", "Status"],
|
|
@@ -179,7 +194,7 @@ let ProjectController = class ProjectController {
|
|
|
179
194
|
await this.dockerService.attach(project.containerName);
|
|
180
195
|
}
|
|
181
196
|
if (detach) {
|
|
182
|
-
console.info(
|
|
197
|
+
console.info(yoctocolors_cjs_1.default.yellow("Warning: Detach option is deprecated"));
|
|
183
198
|
}
|
|
184
199
|
}
|
|
185
200
|
async stop(name) {
|
|
@@ -195,7 +210,7 @@ let ProjectController = class ProjectController {
|
|
|
195
210
|
}
|
|
196
211
|
const project = this.projectService.get();
|
|
197
212
|
const table = new cli_table3_1.default({
|
|
198
|
-
head: [
|
|
213
|
+
head: [yoctocolors_cjs_1.default.yellow("Domain")]
|
|
199
214
|
});
|
|
200
215
|
for (const domain of project.domains) {
|
|
201
216
|
table.push([domain]);
|
|
@@ -330,7 +345,7 @@ let ProjectController = class ProjectController {
|
|
|
330
345
|
for (const variable of variables) {
|
|
331
346
|
const [key, value] = variable.split("=");
|
|
332
347
|
if (!value) {
|
|
333
|
-
console.info(
|
|
348
|
+
console.info(yoctocolors_cjs_1.default.yellow(`No value for "${key}"`));
|
|
334
349
|
continue;
|
|
335
350
|
}
|
|
336
351
|
config.setEnv(key.trim(), value.trim());
|
|
@@ -561,16 +576,16 @@ let ProjectController = class ProjectController {
|
|
|
561
576
|
return str.replace(/^\[.*]\s([^:]+):\s.*$/gm, (substring, type) => {
|
|
562
577
|
switch (type) {
|
|
563
578
|
case "debug":
|
|
564
|
-
return
|
|
579
|
+
return yoctocolors_cjs_1.default.gray(substring);
|
|
565
580
|
case "log":
|
|
566
|
-
return
|
|
581
|
+
return yoctocolors_cjs_1.default.white(substring);
|
|
567
582
|
case "info":
|
|
568
|
-
return
|
|
583
|
+
return yoctocolors_cjs_1.default.green(substring);
|
|
569
584
|
case "warn":
|
|
570
585
|
case "warning":
|
|
571
|
-
return
|
|
586
|
+
return yoctocolors_cjs_1.default.yellow(substring);
|
|
572
587
|
case "error":
|
|
573
|
-
return
|
|
588
|
+
return yoctocolors_cjs_1.default.red(substring);
|
|
574
589
|
default:
|
|
575
590
|
return substring;
|
|
576
591
|
}
|
|
@@ -608,22 +623,7 @@ let ProjectController = class ProjectController {
|
|
|
608
623
|
if (name) {
|
|
609
624
|
this.projectService.cdProject(name);
|
|
610
625
|
}
|
|
611
|
-
|
|
612
|
-
const container = await this.dockerService.getContainer(project.containerName);
|
|
613
|
-
if (!container) {
|
|
614
|
-
throw new Error("Project not started");
|
|
615
|
-
}
|
|
616
|
-
if (!detach) {
|
|
617
|
-
await this.dockerService.logs(container);
|
|
618
|
-
}
|
|
619
|
-
else {
|
|
620
|
-
let data = await container.logs({
|
|
621
|
-
stdout: true,
|
|
622
|
-
stderr: true,
|
|
623
|
-
follow: false
|
|
624
|
-
});
|
|
625
|
-
process.stdout.write(data);
|
|
626
|
-
}
|
|
626
|
+
await this.projectService.logs(detach);
|
|
627
627
|
}
|
|
628
628
|
};
|
|
629
629
|
exports.ProjectController = ProjectController;
|
|
@@ -656,6 +656,14 @@ __decorate([
|
|
|
656
656
|
__metadata("design:paramtypes", [String, String]),
|
|
657
657
|
__metadata("design:returntype", Promise)
|
|
658
658
|
], ProjectController.prototype, "init", null);
|
|
659
|
+
__decorate([
|
|
660
|
+
(0, core_1.Command)("destroy [name]"),
|
|
661
|
+
(0, core_1.Description)("Permanently destroy a project"),
|
|
662
|
+
__param(0, (0, core_1.Param)("name")),
|
|
663
|
+
__metadata("design:type", Function),
|
|
664
|
+
__metadata("design:paramtypes", [String]),
|
|
665
|
+
__metadata("design:returntype", Promise)
|
|
666
|
+
], ProjectController.prototype, "destroy", null);
|
|
659
667
|
__decorate([
|
|
660
668
|
(0, core_1.Command)("ps"),
|
|
661
669
|
(0, core_1.Description)("Projects list"),
|
|
@@ -1072,6 +1080,7 @@ __decorate([
|
|
|
1072
1080
|
], ProjectController.prototype, "logs", null);
|
|
1073
1081
|
exports.ProjectController = ProjectController = __decorate([
|
|
1074
1082
|
(0, core_1.Controller)(),
|
|
1083
|
+
(0, core_1.Description)("Project commands"),
|
|
1075
1084
|
__metadata("design:paramtypes", [services_1.AppConfigService,
|
|
1076
1085
|
services_1.AppEventsService,
|
|
1077
1086
|
services_1.ProjectService,
|
|
@@ -18,7 +18,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
exports.ProxyController = void 0;
|
|
19
19
|
const core_1 = require("@wocker/core");
|
|
20
20
|
const utils_1 = require("@wocker/utils");
|
|
21
|
-
const
|
|
21
|
+
const yoctocolors_cjs_1 = __importDefault(require("yoctocolors-cjs"));
|
|
22
22
|
const services_1 = require("../services");
|
|
23
23
|
let ProxyController = class ProxyController {
|
|
24
24
|
constructor(appConfigService, appEventsService, projectService, proxyService) {
|
|
@@ -35,9 +35,9 @@ let ProxyController = class ProxyController {
|
|
|
35
35
|
if (project.domains.length === 0) {
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
|
-
console.info(
|
|
38
|
+
console.info(yoctocolors_cjs_1.default.green("Don't forget to add these lines into hosts file:"));
|
|
39
39
|
for (const domain of project.domains) {
|
|
40
|
-
console.info(
|
|
40
|
+
console.info(yoctocolors_cjs_1.default.gray(`127.0.0.1 ${domain}`));
|
|
41
41
|
}
|
|
42
42
|
await this.start();
|
|
43
43
|
}
|
|
@@ -48,47 +48,47 @@ let ProxyController = class ProxyController {
|
|
|
48
48
|
return projects.map((project) => project.name);
|
|
49
49
|
}
|
|
50
50
|
async init(httpPort, httpsPort, sshPort, sshPassword) {
|
|
51
|
-
const config = this.appConfigService.
|
|
51
|
+
const config = this.appConfigService.config;
|
|
52
52
|
if (httpPort === null || typeof httpPort === "undefined" || isNaN(httpPort)) {
|
|
53
|
-
httpPort = await (0, utils_1.
|
|
53
|
+
httpPort = await (0, utils_1.promptInput)({
|
|
54
54
|
required: true,
|
|
55
|
-
message: "Http port
|
|
55
|
+
message: "Http port",
|
|
56
56
|
type: "number",
|
|
57
|
-
default: config.getMeta("PROXY_HTTP_PORT", "80")
|
|
57
|
+
default: parseInt(config.getMeta("PROXY_HTTP_PORT", "80"))
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
config.setMeta("PROXY_HTTP_PORT", httpPort.toString());
|
|
61
61
|
if (httpsPort === null || typeof httpsPort === "undefined" || isNaN(httpsPort)) {
|
|
62
|
-
httpsPort = await (0, utils_1.
|
|
62
|
+
httpsPort = await (0, utils_1.promptInput)({
|
|
63
63
|
required: true,
|
|
64
|
-
message: "Https port
|
|
64
|
+
message: "Https port",
|
|
65
65
|
type: "number",
|
|
66
|
-
default: config.getMeta("PROXY_HTTPS_PORT", "443")
|
|
66
|
+
default: parseInt(config.getMeta("PROXY_HTTPS_PORT", "443"))
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
config.setMeta("PROXY_HTTPS_PORT", httpsPort.toString());
|
|
70
|
-
let enableSsh =
|
|
71
|
-
|
|
72
|
-
enableSsh = await (0, utils_1.promptConfirm)({
|
|
70
|
+
let enableSsh = !sshPassword && !sshPort
|
|
71
|
+
? await (0, utils_1.promptConfirm)({
|
|
73
72
|
message: "Enable ssh proxy?",
|
|
74
73
|
default: false
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
if (enableSsh && !sshPassword) {
|
|
78
|
-
sshPassword = await (0, utils_1.promptText)({
|
|
79
|
-
message: "SSH Password:",
|
|
80
|
-
type: "string",
|
|
81
|
-
default: config.getMeta("PROXY_SSH_PASSWORD")
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
if (enableSsh && !sshPort) {
|
|
85
|
-
sshPort = await (0, utils_1.promptText)({
|
|
86
|
-
message: "SSH port:",
|
|
87
|
-
type: "number",
|
|
88
|
-
default: config.getMeta("PROXY_SSH_PORT", "22")
|
|
89
|
-
});
|
|
90
|
-
}
|
|
74
|
+
})
|
|
75
|
+
: true;
|
|
91
76
|
if (enableSsh) {
|
|
77
|
+
if (!sshPassword) {
|
|
78
|
+
sshPassword = await (0, utils_1.promptInput)({
|
|
79
|
+
message: "SSH Password",
|
|
80
|
+
type: "password",
|
|
81
|
+
required: true,
|
|
82
|
+
default: config.getMeta("PROXY_SSH_PASSWORD")
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
if (!sshPort) {
|
|
86
|
+
sshPort = await (0, utils_1.promptInput)({
|
|
87
|
+
message: "SSH port",
|
|
88
|
+
type: "number",
|
|
89
|
+
default: parseInt(config.getMeta("PROXY_SSH_PORT", "22"))
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
92
|
config.setMeta("PROXY_SSH_PASSWORD", sshPassword);
|
|
93
93
|
config.setMeta("PROXY_SSH_PORT", sshPort.toString());
|
|
94
94
|
}
|
|
@@ -118,6 +118,7 @@ __decorate([
|
|
|
118
118
|
], ProxyController.prototype, "getProjectNames", null);
|
|
119
119
|
__decorate([
|
|
120
120
|
(0, core_1.Command)("proxy:init"),
|
|
121
|
+
(0, core_1.Description)("Initializes proxy configurations"),
|
|
121
122
|
__param(0, (0, core_1.Option)("http-port", {
|
|
122
123
|
type: "number",
|
|
123
124
|
description: "Http port"
|
|
@@ -131,6 +132,7 @@ __decorate([
|
|
|
131
132
|
description: "SSH port"
|
|
132
133
|
})),
|
|
133
134
|
__param(3, (0, core_1.Option)("ssh-password", {
|
|
135
|
+
type: "string",
|
|
134
136
|
description: "SSH password"
|
|
135
137
|
})),
|
|
136
138
|
__metadata("design:type", Function),
|
|
@@ -139,15 +141,16 @@ __decorate([
|
|
|
139
141
|
], ProxyController.prototype, "init", null);
|
|
140
142
|
__decorate([
|
|
141
143
|
(0, core_1.Command)("proxy:start"),
|
|
144
|
+
(0, core_1.Description)("This command starts the proxy for the project. Options are available to restart or rebuild the proxy if needed."),
|
|
142
145
|
__param(0, (0, core_1.Option)("restart", {
|
|
143
146
|
type: "boolean",
|
|
144
147
|
alias: "r",
|
|
145
|
-
description: "
|
|
148
|
+
description: "Restarts the proxy before starting it"
|
|
146
149
|
})),
|
|
147
150
|
__param(1, (0, core_1.Option)("rebuild", {
|
|
148
151
|
type: "boolean",
|
|
149
152
|
alias: "b",
|
|
150
|
-
description: "
|
|
153
|
+
description: "Rebuilds the proxy before starting it"
|
|
151
154
|
})),
|
|
152
155
|
__metadata("design:type", Function),
|
|
153
156
|
__metadata("design:paramtypes", [Boolean, Boolean]),
|
|
@@ -155,18 +158,21 @@ __decorate([
|
|
|
155
158
|
], ProxyController.prototype, "start", null);
|
|
156
159
|
__decorate([
|
|
157
160
|
(0, core_1.Command)("proxy:stop"),
|
|
161
|
+
(0, core_1.Description)("This command stops the currently running proxy for the project. It ensures that all proxy-related services are properly halted."),
|
|
158
162
|
__metadata("design:type", Function),
|
|
159
163
|
__metadata("design:paramtypes", []),
|
|
160
164
|
__metadata("design:returntype", Promise)
|
|
161
165
|
], ProxyController.prototype, "stop", null);
|
|
162
166
|
__decorate([
|
|
163
167
|
(0, core_1.Command)("proxy:logs"),
|
|
168
|
+
(0, core_1.Description)("Displays the proxy logs"),
|
|
164
169
|
__metadata("design:type", Function),
|
|
165
170
|
__metadata("design:paramtypes", []),
|
|
166
171
|
__metadata("design:returntype", Promise)
|
|
167
172
|
], ProxyController.prototype, "logs", null);
|
|
168
173
|
exports.ProxyController = ProxyController = __decorate([
|
|
169
174
|
(0, core_1.Controller)(),
|
|
175
|
+
(0, core_1.Description)("Proxy commands"),
|
|
170
176
|
__metadata("design:paramtypes", [services_1.AppConfigService,
|
|
171
177
|
services_1.AppEventsService,
|
|
172
178
|
services_1.ProjectService,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from "./CertController";
|
|
2
2
|
export * from "./CompletionController";
|
|
3
3
|
export * from "./DebugController";
|
|
4
|
-
export * from "./
|
|
4
|
+
export * from "./KeystoreController";
|
|
5
5
|
export * from "./PluginController";
|
|
6
6
|
export * from "./PresetController";
|
|
7
7
|
export * from "./ProjectController";
|
package/lib/controllers/index.js
CHANGED
|
@@ -17,7 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./CertController"), exports);
|
|
18
18
|
__exportStar(require("./CompletionController"), exports);
|
|
19
19
|
__exportStar(require("./DebugController"), exports);
|
|
20
|
-
__exportStar(require("./
|
|
20
|
+
__exportStar(require("./KeystoreController"), exports);
|
|
21
21
|
__exportStar(require("./PluginController"), exports);
|
|
22
22
|
__exportStar(require("./PresetController"), exports);
|
|
23
23
|
__exportStar(require("./ProjectController"), exports);
|
package/lib/env.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const WOCKER_VERSION = "1.0.
|
|
1
|
+
export declare const WOCKER_VERSION = "1.0.22";
|
|
2
2
|
export declare const NODE_ENV: string;
|
|
3
3
|
export declare const ROOT_DIR: string;
|
|
4
4
|
export declare const PRESETS_DIR: string;
|
|
@@ -6,3 +6,4 @@ export declare const SERVICES_DIR: string;
|
|
|
6
6
|
export declare const PLUGINS_DIR: string;
|
|
7
7
|
export declare const DATA_DIR: string;
|
|
8
8
|
export declare const VIRTUAL_HOST_KEY = "VIRTUAL_HOST";
|
|
9
|
+
export declare const KEYTAR_SERVICE: string;
|
package/lib/env.js
CHANGED
|
@@ -33,10 +33,10 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.VIRTUAL_HOST_KEY = exports.DATA_DIR = exports.PLUGINS_DIR = exports.SERVICES_DIR = exports.PRESETS_DIR = exports.ROOT_DIR = exports.NODE_ENV = exports.WOCKER_VERSION = void 0;
|
|
36
|
+
exports.KEYTAR_SERVICE = exports.VIRTUAL_HOST_KEY = exports.DATA_DIR = exports.PLUGINS_DIR = exports.SERVICES_DIR = exports.PRESETS_DIR = exports.ROOT_DIR = exports.NODE_ENV = exports.WOCKER_VERSION = void 0;
|
|
37
37
|
const OS = __importStar(require("os"));
|
|
38
38
|
const Path = __importStar(require("path"));
|
|
39
|
-
exports.WOCKER_VERSION = "1.0.
|
|
39
|
+
exports.WOCKER_VERSION = "1.0.22";
|
|
40
40
|
exports.NODE_ENV = process.env.NODE_ENV;
|
|
41
41
|
exports.ROOT_DIR = Path.join(__dirname, "..");
|
|
42
42
|
exports.PRESETS_DIR = Path.join(exports.ROOT_DIR, "presets");
|
|
@@ -44,3 +44,4 @@ exports.SERVICES_DIR = Path.join(exports.ROOT_DIR, "services");
|
|
|
44
44
|
exports.PLUGINS_DIR = Path.join(exports.ROOT_DIR, "plugins");
|
|
45
45
|
exports.DATA_DIR = process.env.WS_DIR || Path.join(OS.homedir(), ".workspace");
|
|
46
46
|
exports.VIRTUAL_HOST_KEY = "VIRTUAL_HOST";
|
|
47
|
+
exports.KEYTAR_SERVICE = process.env.WOCKER_KEYTAR_SERVICE || "wocker";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { KeystoreService as CoreKeystoreService, KeystoreProvider } from "@wocker/core";
|
|
2
|
+
import { AppConfigService } from "../services/AppConfigService";
|
|
3
|
+
export declare class KeystoreService extends CoreKeystoreService {
|
|
4
|
+
protected readonly appConfigService: AppConfigService;
|
|
5
|
+
protected providers: Map<string, KeystoreProvider>;
|
|
6
|
+
constructor(appConfigService: AppConfigService);
|
|
7
|
+
hasProvider(name: string): boolean;
|
|
8
|
+
provider(name?: string): KeystoreProvider;
|
|
9
|
+
get(keys: string | string[], byDefault?: string): Promise<string | undefined>;
|
|
10
|
+
set(key: string, value: string): Promise<void>;
|
|
11
|
+
registerProvider(name: string, provider: KeystoreProvider): void;
|
|
12
|
+
}
|