@wocker/ws 1.0.20 → 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 -39
- 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 +5 -3
- package/lib/controllers/PresetController.js +73 -55
- package/lib/controllers/ProjectController.d.ts +5 -3
- package/lib/controllers/ProjectController.js +71 -46
- package/lib/controllers/ProxyController.d.ts +1 -1
- package/lib/controllers/ProxyController.js +56 -14
- 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 +20 -9
- 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 +2 -2
- package/lib/makes/FS.js +19 -9
- package/lib/makes/GithubClient.d.ts +14 -0
- package/lib/makes/GithubClient.js +65 -0
- package/lib/makes/Http.js +17 -7
- 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/MongodbPlugin.js +17 -7
- 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 +88 -62
- package/lib/services/AppEventsService.d.ts +4 -4
- package/lib/services/AppEventsService.js +14 -10
- package/lib/services/CertService.js +18 -8
- package/lib/services/DockerService.d.ts +2 -2
- package/lib/services/DockerService.js +14 -8
- package/lib/services/LogService.d.ts +4 -1
- package/lib/services/LogService.js +14 -8
- package/lib/services/PluginService.d.ts +8 -2
- package/lib/services/PluginService.js +88 -23
- package/lib/services/PresetService.d.ts +9 -8
- package/lib/services/PresetService.js +144 -248
- package/lib/services/ProjectService.d.ts +5 -2
- package/lib/services/ProjectService.js +37 -10
- package/lib/services/ProxyService.d.ts +3 -2
- package/lib/services/ProxyService.js +43 -25
- package/lib/utils/index.d.ts +0 -2
- package/lib/utils/index.js +0 -2
- package/package.json +30 -15
- package/plugins/proxy/Dockerfile +17 -1
- package/plugins/proxy/Procfile +2 -0
- 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/ElasticSearchPlugin.d.ts +0 -15
- package/lib/plugins/ElasticSearchPlugin.js +0 -72
- package/lib/plugins/ProxmoxPlugin.d.ts +0 -12
- package/lib/plugins/ProxmoxPlugin.js +0 -83
- 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/plugins/proxy/config.json +0 -3
- package/presets/bun/Dockerfile +0 -11
- package/presets/bun/config.json +0 -4
|
@@ -21,13 +21,23 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
21
21
|
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;
|
|
22
22
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
23
|
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
31
41
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
42
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
43
|
};
|
|
@@ -46,20 +56,22 @@ const Path = __importStar(require("path"));
|
|
|
46
56
|
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
47
57
|
const env_1 = require("../env");
|
|
48
58
|
const utils_3 = require("../utils");
|
|
59
|
+
const repositories_1 = require("../repositories");
|
|
49
60
|
const services_1 = require("../services");
|
|
50
61
|
let PresetController = class PresetController {
|
|
51
|
-
constructor(appConfigService, appEventsService, projectService, presetService, dockerService) {
|
|
62
|
+
constructor(appConfigService, appEventsService, projectService, presetService, presetRepository, dockerService) {
|
|
52
63
|
this.appConfigService = appConfigService;
|
|
53
64
|
this.appEventsService = appEventsService;
|
|
54
65
|
this.projectService = projectService;
|
|
55
66
|
this.presetService = presetService;
|
|
67
|
+
this.presetRepository = presetRepository;
|
|
56
68
|
this.dockerService = dockerService;
|
|
57
69
|
this.appEventsService.on("project:init", (project) => this.onInit(project));
|
|
58
70
|
this.appEventsService.on("project:beforeStart", (project) => this.onBeforeStart(project));
|
|
59
71
|
this.appEventsService.on("project:rebuild", (project) => this.onRebuild(project));
|
|
60
72
|
}
|
|
61
73
|
async presets() {
|
|
62
|
-
const presets =
|
|
74
|
+
const presets = this.presetRepository.search();
|
|
63
75
|
return presets.map((preset) => {
|
|
64
76
|
return preset.name;
|
|
65
77
|
});
|
|
@@ -68,12 +80,12 @@ let PresetController = class PresetController {
|
|
|
68
80
|
if (project.type !== core_1.PROJECT_TYPE_PRESET) {
|
|
69
81
|
return;
|
|
70
82
|
}
|
|
71
|
-
const presets =
|
|
83
|
+
const presets = this.presetRepository.search();
|
|
72
84
|
if (presets.length === 0) {
|
|
73
85
|
throw new Error("No presets");
|
|
74
86
|
}
|
|
75
87
|
project.preset = await (0, utils_1.promptSelect)({
|
|
76
|
-
message: "Choose preset
|
|
88
|
+
message: "Choose preset",
|
|
77
89
|
options: presets.map((preset) => {
|
|
78
90
|
return {
|
|
79
91
|
label: preset.name,
|
|
@@ -83,7 +95,7 @@ let PresetController = class PresetController {
|
|
|
83
95
|
default: project.preset
|
|
84
96
|
});
|
|
85
97
|
project.presetMode = await (0, utils_1.promptSelect)({
|
|
86
|
-
message: "Preset mode
|
|
98
|
+
message: "Preset mode",
|
|
87
99
|
options: [
|
|
88
100
|
{
|
|
89
101
|
label: "For project only",
|
|
@@ -96,15 +108,15 @@ let PresetController = class PresetController {
|
|
|
96
108
|
],
|
|
97
109
|
default: project.presetMode
|
|
98
110
|
});
|
|
99
|
-
const preset =
|
|
111
|
+
const preset = this.presetService.get(project.preset);
|
|
100
112
|
if (!preset) {
|
|
101
113
|
throw new Error("Preset not found");
|
|
102
114
|
}
|
|
103
115
|
if (preset.buildArgsOptions) {
|
|
104
|
-
project.buildArgs = await
|
|
116
|
+
project.buildArgs = await this.presetService.prompt(preset.buildArgsOptions, project.buildArgs);
|
|
105
117
|
}
|
|
106
118
|
if (preset.envOptions) {
|
|
107
|
-
project.env = await
|
|
119
|
+
project.env = await this.presetService.prompt(preset.envOptions, project.env);
|
|
108
120
|
}
|
|
109
121
|
if (preset.volumeOptions) {
|
|
110
122
|
for (let volume of preset.volumeOptions) {
|
|
@@ -112,15 +124,15 @@ let PresetController = class PresetController {
|
|
|
112
124
|
...project.buildArgs || {},
|
|
113
125
|
...project.env || {}
|
|
114
126
|
});
|
|
115
|
-
const { source, destination, options } = (0,
|
|
127
|
+
const { source, destination, options } = (0, utils_2.volumeParse)(volume);
|
|
116
128
|
let projectVolume = project.getVolumeByDestination(destination);
|
|
117
|
-
const newSource = await (0, utils_1.
|
|
118
|
-
message: "Volume
|
|
129
|
+
const newSource = await (0, utils_1.promptInput)({
|
|
130
|
+
message: "Volume",
|
|
119
131
|
required: true,
|
|
120
132
|
suffix: `:${destination}`,
|
|
121
|
-
default: projectVolume ? (0,
|
|
133
|
+
default: projectVolume ? (0, utils_2.volumeParse)(projectVolume).source : source
|
|
122
134
|
});
|
|
123
|
-
projectVolume = (0,
|
|
135
|
+
projectVolume = (0, utils_2.volumeFormat)({
|
|
124
136
|
source: newSource,
|
|
125
137
|
destination,
|
|
126
138
|
options
|
|
@@ -136,7 +148,7 @@ let PresetController = class PresetController {
|
|
|
136
148
|
if (project.type !== core_1.PROJECT_TYPE_PRESET) {
|
|
137
149
|
return;
|
|
138
150
|
}
|
|
139
|
-
const preset =
|
|
151
|
+
const preset = this.presetService.get(project.preset);
|
|
140
152
|
if (!preset) {
|
|
141
153
|
throw new Error(`Preset ${project.preset} not found`);
|
|
142
154
|
}
|
|
@@ -151,7 +163,7 @@ let PresetController = class PresetController {
|
|
|
151
163
|
if (project.type !== core_1.PROJECT_TYPE_PRESET) {
|
|
152
164
|
return;
|
|
153
165
|
}
|
|
154
|
-
const preset =
|
|
166
|
+
const preset = this.presetService.get(project.preset);
|
|
155
167
|
if (preset.dockerfile) {
|
|
156
168
|
project.imageName = this.presetService.getImageNameForProject(project, preset);
|
|
157
169
|
if (!await this.dockerService.imageExists(project.imageName)) {
|
|
@@ -170,27 +182,32 @@ let PresetController = class PresetController {
|
|
|
170
182
|
async init() {
|
|
171
183
|
await this.presetService.init();
|
|
172
184
|
}
|
|
173
|
-
async
|
|
185
|
+
async destroy() {
|
|
174
186
|
await this.presetService.deinit();
|
|
175
187
|
}
|
|
176
|
-
async add(name) {
|
|
177
|
-
await this.presetService.addPreset(name);
|
|
188
|
+
async add(name, version) {
|
|
189
|
+
await this.presetService.addPreset(name, version);
|
|
178
190
|
}
|
|
179
191
|
async list() {
|
|
180
|
-
const presets =
|
|
192
|
+
const presets = this.presetRepository.search();
|
|
181
193
|
const table = new cli_table3_1.default({
|
|
182
194
|
head: [
|
|
183
195
|
"Name",
|
|
184
|
-
"Source"
|
|
196
|
+
"Source",
|
|
197
|
+
"Path"
|
|
185
198
|
]
|
|
186
199
|
});
|
|
187
200
|
for (const preset of presets) {
|
|
188
|
-
table.push([
|
|
201
|
+
table.push([
|
|
202
|
+
preset.name,
|
|
203
|
+
preset.source,
|
|
204
|
+
preset.source === core_1.PRESET_SOURCE_EXTERNAL ? preset.path : ""
|
|
205
|
+
]);
|
|
189
206
|
}
|
|
190
207
|
return table.toString();
|
|
191
208
|
}
|
|
192
209
|
async delete(name, confirm) {
|
|
193
|
-
const preset =
|
|
210
|
+
const preset = this.presetService.get(name);
|
|
194
211
|
if (typeof confirm === "undefined" || confirm === null) {
|
|
195
212
|
confirm = await (0, utils_2.promptConfirm)({
|
|
196
213
|
message: `Delete preset ${name}?`,
|
|
@@ -201,14 +218,14 @@ let PresetController = class PresetController {
|
|
|
201
218
|
return;
|
|
202
219
|
}
|
|
203
220
|
console.info("Deleting...");
|
|
204
|
-
|
|
221
|
+
preset.delete();
|
|
205
222
|
}
|
|
206
223
|
async eject(name) {
|
|
207
224
|
if (name) {
|
|
208
225
|
this.projectService.cdProject(name);
|
|
209
226
|
}
|
|
210
227
|
const project = this.projectService.get();
|
|
211
|
-
const preset =
|
|
228
|
+
const preset = this.presetService.get(project.preset);
|
|
212
229
|
if (!preset) {
|
|
213
230
|
throw new Error("Preset not found");
|
|
214
231
|
}
|
|
@@ -219,10 +236,10 @@ let PresetController = class PresetController {
|
|
|
219
236
|
if (!confirm) {
|
|
220
237
|
return;
|
|
221
238
|
}
|
|
222
|
-
const copier = new core_1.
|
|
239
|
+
const copier = new core_1.FileSystemManager(this.appConfigService.presetPath(preset.name), this.appConfigService.pwd());
|
|
223
240
|
if (preset.dockerfile) {
|
|
224
241
|
if (!copier.destination.exists(preset.dockerfile)) {
|
|
225
|
-
|
|
242
|
+
copier.copy(preset.dockerfile);
|
|
226
243
|
}
|
|
227
244
|
project.type = "dockerfile";
|
|
228
245
|
project.dockerfile = preset.dockerfile;
|
|
@@ -246,17 +263,17 @@ let PresetController = class PresetController {
|
|
|
246
263
|
recursive: true
|
|
247
264
|
});
|
|
248
265
|
}
|
|
249
|
-
|
|
266
|
+
copier.copy(path);
|
|
250
267
|
}
|
|
251
268
|
delete project.preset;
|
|
252
269
|
delete project.imageName;
|
|
253
|
-
|
|
270
|
+
project.save();
|
|
254
271
|
}
|
|
255
272
|
async build(presetName, rebuild) {
|
|
256
|
-
const preset =
|
|
273
|
+
const preset = this.presetService.get(presetName);
|
|
257
274
|
let buildArgs = {};
|
|
258
275
|
if (preset.buildArgsOptions) {
|
|
259
|
-
buildArgs = await
|
|
276
|
+
buildArgs = await this.presetService.prompt(preset.buildArgsOptions);
|
|
260
277
|
}
|
|
261
278
|
const imageName = this.presetService.getImageName(preset, buildArgs);
|
|
262
279
|
if (rebuild) {
|
|
@@ -276,25 +293,30 @@ let PresetController = class PresetController {
|
|
|
276
293
|
exports.PresetController = PresetController;
|
|
277
294
|
__decorate([
|
|
278
295
|
(0, core_1.Command)("preset:init"),
|
|
296
|
+
(0, core_1.Description)("Creates preset config for current dir"),
|
|
279
297
|
__metadata("design:type", Function),
|
|
280
298
|
__metadata("design:paramtypes", []),
|
|
281
299
|
__metadata("design:returntype", Promise)
|
|
282
300
|
], PresetController.prototype, "init", null);
|
|
283
301
|
__decorate([
|
|
284
|
-
(0, core_1.Command)("preset:
|
|
302
|
+
(0, core_1.Command)("preset:destroy"),
|
|
285
303
|
__metadata("design:type", Function),
|
|
286
304
|
__metadata("design:paramtypes", []),
|
|
287
305
|
__metadata("design:returntype", Promise)
|
|
288
|
-
], PresetController.prototype, "
|
|
306
|
+
], PresetController.prototype, "destroy", null);
|
|
289
307
|
__decorate([
|
|
290
|
-
(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"),
|
|
291
311
|
__param(0, (0, core_1.Param)("preset")),
|
|
312
|
+
__param(1, (0, core_1.Param)("version")),
|
|
292
313
|
__metadata("design:type", Function),
|
|
293
|
-
__metadata("design:paramtypes", [String]),
|
|
314
|
+
__metadata("design:paramtypes", [String, String]),
|
|
294
315
|
__metadata("design:returntype", Promise)
|
|
295
316
|
], PresetController.prototype, "add", null);
|
|
296
317
|
__decorate([
|
|
297
318
|
(0, core_1.Command)("preset:ls"),
|
|
319
|
+
(0, core_1.Description)("List of all available presets"),
|
|
298
320
|
__metadata("design:type", Function),
|
|
299
321
|
__metadata("design:paramtypes", []),
|
|
300
322
|
__metadata("design:returntype", Promise)
|
|
@@ -302,42 +324,38 @@ __decorate([
|
|
|
302
324
|
__decorate([
|
|
303
325
|
(0, core_1.Command)("preset:delete <preset>"),
|
|
304
326
|
__param(0, (0, core_1.Param)("preset")),
|
|
305
|
-
__param(1, (0, core_1.Option)("yes",
|
|
306
|
-
|
|
307
|
-
description: "Confirm deletion"
|
|
308
|
-
})),
|
|
327
|
+
__param(1, (0, core_1.Option)("yes", "y")),
|
|
328
|
+
__param(1, (0, core_1.Description)("Confirm deletion")),
|
|
309
329
|
__metadata("design:type", Function),
|
|
310
330
|
__metadata("design:paramtypes", [String, Boolean]),
|
|
311
331
|
__metadata("design:returntype", Promise)
|
|
312
332
|
], PresetController.prototype, "delete", null);
|
|
313
333
|
__decorate([
|
|
314
334
|
(0, core_1.Command)("preset:eject"),
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
description: "Project name"
|
|
319
|
-
})),
|
|
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")),
|
|
320
338
|
__metadata("design:type", Function),
|
|
321
339
|
__metadata("design:paramtypes", [String]),
|
|
322
340
|
__metadata("design:returntype", Promise)
|
|
323
341
|
], PresetController.prototype, "eject", null);
|
|
324
342
|
__decorate([
|
|
325
343
|
(0, core_1.Command)("preset:build <preset>"),
|
|
344
|
+
(0, core_1.Description)("Build docker image form a preset"),
|
|
326
345
|
__param(0, (0, core_1.Param)("preset")),
|
|
327
|
-
__param(1, (0, core_1.Option)("rebuild",
|
|
328
|
-
|
|
329
|
-
alias: "r",
|
|
330
|
-
description: "Rebuild image"
|
|
331
|
-
})),
|
|
346
|
+
__param(1, (0, core_1.Option)("rebuild", "r")),
|
|
347
|
+
__param(1, (0, core_1.Description)("Rebuild image")),
|
|
332
348
|
__metadata("design:type", Function),
|
|
333
349
|
__metadata("design:paramtypes", [String, Boolean]),
|
|
334
350
|
__metadata("design:returntype", Promise)
|
|
335
351
|
], PresetController.prototype, "build", null);
|
|
336
352
|
exports.PresetController = PresetController = __decorate([
|
|
337
353
|
(0, core_1.Controller)(),
|
|
354
|
+
(0, core_1.Description)("Preset commands"),
|
|
338
355
|
__metadata("design:paramtypes", [services_1.AppConfigService,
|
|
339
356
|
services_1.AppEventsService,
|
|
340
357
|
services_1.ProjectService,
|
|
341
358
|
services_1.PresetService,
|
|
359
|
+
repositories_1.PresetRepository,
|
|
342
360
|
services_1.DockerService])
|
|
343
361
|
], PresetController);
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { ProjectType } from "@wocker/core";
|
|
2
|
-
import { AppConfigService, AppEventsService, ProjectService, DockerService } from "../services";
|
|
2
|
+
import { AppConfigService, AppEventsService, ProjectService, LogService, DockerService } from "../services";
|
|
3
3
|
export declare class ProjectController {
|
|
4
4
|
protected readonly appConfigService: AppConfigService;
|
|
5
5
|
protected readonly appEventsService: AppEventsService;
|
|
6
6
|
protected readonly projectService: ProjectService;
|
|
7
|
+
protected readonly logService: LogService;
|
|
7
8
|
protected readonly dockerService: DockerService;
|
|
8
|
-
constructor(appConfigService: AppConfigService, appEventsService: AppEventsService, projectService: ProjectService, dockerService: DockerService);
|
|
9
|
+
constructor(appConfigService: AppConfigService, appEventsService: AppEventsService, projectService: ProjectService, logService: LogService, dockerService: DockerService);
|
|
9
10
|
protected getProjectNames(): Promise<string[]>;
|
|
10
11
|
getScriptNames(): Promise<string[]>;
|
|
11
12
|
init(name: string, type: ProjectType): Promise<void>;
|
|
13
|
+
destroy(name?: string): Promise<void>;
|
|
12
14
|
projectList(all: boolean): Promise<string>;
|
|
13
15
|
start(name?: string, detach?: boolean, attach?: boolean, rebuild?: boolean, restart?: boolean): Promise<void>;
|
|
14
16
|
stop(name: string): Promise<void>;
|
|
@@ -38,5 +40,5 @@ export declare class ProjectController {
|
|
|
38
40
|
attach(name?: string): Promise<void>;
|
|
39
41
|
exec(command?: string[], name?: string): Promise<void>;
|
|
40
42
|
run(script: string, args?: string[], name?: string): Promise<void>;
|
|
41
|
-
logs(name?: string, global?: boolean, detach?: boolean, follow?: boolean): Promise<void>;
|
|
43
|
+
logs(name?: string, global?: boolean, detach?: boolean, follow?: boolean, clear?: boolean): Promise<void>;
|
|
42
44
|
}
|
|
@@ -21,13 +21,23 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
21
21
|
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;
|
|
22
22
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
23
|
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
31
41
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
42
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
43
|
};
|
|
@@ -42,16 +52,17 @@ exports.ProjectController = void 0;
|
|
|
42
52
|
const core_1 = require("@wocker/core");
|
|
43
53
|
const utils_1 = require("@wocker/utils");
|
|
44
54
|
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
45
|
-
const
|
|
55
|
+
const yoctocolors_cjs_1 = __importDefault(require("yoctocolors-cjs"));
|
|
46
56
|
const Path = __importStar(require("path"));
|
|
47
57
|
const async_mutex_1 = require("async-mutex");
|
|
48
58
|
const makes_1 = require("../makes");
|
|
49
59
|
const services_1 = require("../services");
|
|
50
60
|
let ProjectController = class ProjectController {
|
|
51
|
-
constructor(appConfigService, appEventsService, projectService, dockerService) {
|
|
61
|
+
constructor(appConfigService, appEventsService, projectService, logService, dockerService) {
|
|
52
62
|
this.appConfigService = appConfigService;
|
|
53
63
|
this.appEventsService = appEventsService;
|
|
54
64
|
this.projectService = projectService;
|
|
65
|
+
this.logService = logService;
|
|
55
66
|
this.dockerService = dockerService;
|
|
56
67
|
}
|
|
57
68
|
async getProjectNames() {
|
|
@@ -84,11 +95,23 @@ let ProjectController = class ProjectController {
|
|
|
84
95
|
project.name = name;
|
|
85
96
|
}
|
|
86
97
|
if (!name || !project.name) {
|
|
87
|
-
project.name = await (0, utils_1.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
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
|
+
}
|
|
92
115
|
});
|
|
93
116
|
project.addDomain(project.containerName);
|
|
94
117
|
}
|
|
@@ -97,11 +120,11 @@ let ProjectController = class ProjectController {
|
|
|
97
120
|
}
|
|
98
121
|
const mapTypes = this.appConfigService.getProjectTypes();
|
|
99
122
|
if (!type || !project.type || !mapTypes[project.type]) {
|
|
100
|
-
project.type =
|
|
101
|
-
message: "Project type
|
|
123
|
+
project.type = await (0, utils_1.promptSelect)({
|
|
124
|
+
message: "Project type",
|
|
102
125
|
options: mapTypes,
|
|
103
126
|
default: project.type
|
|
104
|
-
})
|
|
127
|
+
});
|
|
105
128
|
}
|
|
106
129
|
switch (project.type) {
|
|
107
130
|
case core_1.PROJECT_TYPE_DOCKERFILE: {
|
|
@@ -116,7 +139,7 @@ let ProjectController = class ProjectController {
|
|
|
116
139
|
throw new Error("Dockerfiles not found");
|
|
117
140
|
}
|
|
118
141
|
project.dockerfile = await (0, utils_1.promptSelect)({
|
|
119
|
-
message: "Dockerfile
|
|
142
|
+
message: "Dockerfile",
|
|
120
143
|
options: dockerfiles.map((dockerfile) => {
|
|
121
144
|
return {
|
|
122
145
|
value: dockerfile
|
|
@@ -127,8 +150,8 @@ let ProjectController = class ProjectController {
|
|
|
127
150
|
break;
|
|
128
151
|
}
|
|
129
152
|
case core_1.PROJECT_TYPE_IMAGE: {
|
|
130
|
-
project.imageName = await (0, utils_1.
|
|
131
|
-
message: "Image name
|
|
153
|
+
project.imageName = await (0, utils_1.promptInput)({
|
|
154
|
+
message: "Image name",
|
|
132
155
|
required: true,
|
|
133
156
|
default: project.imageName
|
|
134
157
|
});
|
|
@@ -142,6 +165,9 @@ let ProjectController = class ProjectController {
|
|
|
142
165
|
await this.appEventsService.emit("project:init", project);
|
|
143
166
|
await project.save();
|
|
144
167
|
}
|
|
168
|
+
async destroy(name) {
|
|
169
|
+
const project = this.projectService.get(name);
|
|
170
|
+
}
|
|
145
171
|
async projectList(all) {
|
|
146
172
|
const table = new cli_table3_1.default({
|
|
147
173
|
head: ["Name", "Type", "Status"],
|
|
@@ -168,7 +194,7 @@ let ProjectController = class ProjectController {
|
|
|
168
194
|
await this.dockerService.attach(project.containerName);
|
|
169
195
|
}
|
|
170
196
|
if (detach) {
|
|
171
|
-
console.info(
|
|
197
|
+
console.info(yoctocolors_cjs_1.default.yellow("Warning: Detach option is deprecated"));
|
|
172
198
|
}
|
|
173
199
|
}
|
|
174
200
|
async stop(name) {
|
|
@@ -184,7 +210,7 @@ let ProjectController = class ProjectController {
|
|
|
184
210
|
}
|
|
185
211
|
const project = this.projectService.get();
|
|
186
212
|
const table = new cli_table3_1.default({
|
|
187
|
-
head: [
|
|
213
|
+
head: [yoctocolors_cjs_1.default.yellow("Domain")]
|
|
188
214
|
});
|
|
189
215
|
for (const domain of project.domains) {
|
|
190
216
|
table.push([domain]);
|
|
@@ -319,7 +345,7 @@ let ProjectController = class ProjectController {
|
|
|
319
345
|
for (const variable of variables) {
|
|
320
346
|
const [key, value] = variable.split("=");
|
|
321
347
|
if (!value) {
|
|
322
|
-
console.info(
|
|
348
|
+
console.info(yoctocolors_cjs_1.default.yellow(`No value for "${key}"`));
|
|
323
349
|
continue;
|
|
324
350
|
}
|
|
325
351
|
config.setEnv(key.trim(), value.trim());
|
|
@@ -540,23 +566,26 @@ let ProjectController = class ProjectController {
|
|
|
540
566
|
});
|
|
541
567
|
await this.dockerService.attachStream(stream);
|
|
542
568
|
}
|
|
543
|
-
async logs(name, global, detach, follow) {
|
|
569
|
+
async logs(name, global, detach, follow, clear) {
|
|
544
570
|
if (global) {
|
|
571
|
+
if (clear) {
|
|
572
|
+
this.logService.clear();
|
|
573
|
+
}
|
|
545
574
|
const logFilepath = this.appConfigService.dataPath("ws.log");
|
|
546
575
|
const prepareLog = (str) => {
|
|
547
576
|
return str.replace(/^\[.*]\s([^:]+):\s.*$/gm, (substring, type) => {
|
|
548
577
|
switch (type) {
|
|
549
578
|
case "debug":
|
|
550
|
-
return
|
|
579
|
+
return yoctocolors_cjs_1.default.gray(substring);
|
|
551
580
|
case "log":
|
|
552
|
-
return
|
|
581
|
+
return yoctocolors_cjs_1.default.white(substring);
|
|
553
582
|
case "info":
|
|
554
|
-
return
|
|
583
|
+
return yoctocolors_cjs_1.default.green(substring);
|
|
555
584
|
case "warn":
|
|
556
585
|
case "warning":
|
|
557
|
-
return
|
|
586
|
+
return yoctocolors_cjs_1.default.yellow(substring);
|
|
558
587
|
case "error":
|
|
559
|
-
return
|
|
588
|
+
return yoctocolors_cjs_1.default.red(substring);
|
|
560
589
|
default:
|
|
561
590
|
return substring;
|
|
562
591
|
}
|
|
@@ -594,22 +623,7 @@ let ProjectController = class ProjectController {
|
|
|
594
623
|
if (name) {
|
|
595
624
|
this.projectService.cdProject(name);
|
|
596
625
|
}
|
|
597
|
-
|
|
598
|
-
const container = await this.dockerService.getContainer(project.containerName);
|
|
599
|
-
if (!container) {
|
|
600
|
-
throw new Error("Project not started");
|
|
601
|
-
}
|
|
602
|
-
if (!detach) {
|
|
603
|
-
await this.dockerService.logs(container);
|
|
604
|
-
}
|
|
605
|
-
else {
|
|
606
|
-
let data = await container.logs({
|
|
607
|
-
stdout: true,
|
|
608
|
-
stderr: true,
|
|
609
|
-
follow: false
|
|
610
|
-
});
|
|
611
|
-
process.stdout.write(data);
|
|
612
|
-
}
|
|
626
|
+
await this.projectService.logs(detach);
|
|
613
627
|
}
|
|
614
628
|
};
|
|
615
629
|
exports.ProjectController = ProjectController;
|
|
@@ -642,6 +656,14 @@ __decorate([
|
|
|
642
656
|
__metadata("design:paramtypes", [String, String]),
|
|
643
657
|
__metadata("design:returntype", Promise)
|
|
644
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);
|
|
645
667
|
__decorate([
|
|
646
668
|
(0, core_1.Command)("ps"),
|
|
647
669
|
(0, core_1.Description)("Projects list"),
|
|
@@ -1051,14 +1073,17 @@ __decorate([
|
|
|
1051
1073
|
type: "boolean",
|
|
1052
1074
|
alias: "f"
|
|
1053
1075
|
})),
|
|
1076
|
+
__param(4, (0, core_1.Option)("clear", { alias: "c" })),
|
|
1054
1077
|
__metadata("design:type", Function),
|
|
1055
|
-
__metadata("design:paramtypes", [String, Boolean, Boolean, Boolean]),
|
|
1078
|
+
__metadata("design:paramtypes", [String, Boolean, Boolean, Boolean, Boolean]),
|
|
1056
1079
|
__metadata("design:returntype", Promise)
|
|
1057
1080
|
], ProjectController.prototype, "logs", null);
|
|
1058
1081
|
exports.ProjectController = ProjectController = __decorate([
|
|
1059
1082
|
(0, core_1.Controller)(),
|
|
1083
|
+
(0, core_1.Description)("Project commands"),
|
|
1060
1084
|
__metadata("design:paramtypes", [services_1.AppConfigService,
|
|
1061
1085
|
services_1.AppEventsService,
|
|
1062
1086
|
services_1.ProjectService,
|
|
1087
|
+
services_1.LogService,
|
|
1063
1088
|
services_1.DockerService])
|
|
1064
1089
|
], ProjectController);
|
|
@@ -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(): string[];
|
|
13
|
-
init(httpPort?: number, httpsPort?: number): Promise<void>;
|
|
13
|
+
init(httpPort?: number, httpsPort?: number, sshPort?: number, sshPassword?: string): Promise<void>;
|
|
14
14
|
start(restart?: boolean, rebuild?: boolean): Promise<void>;
|
|
15
15
|
stop(): Promise<void>;
|
|
16
16
|
logs(): Promise<void>;
|