@wocker/ws 1.0.21 → 1.0.23
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 +46 -75
- package/lib/controllers/DebugController.d.ts +4 -2
- package/lib/controllers/DebugController.js +19 -11
- package/lib/controllers/ExperimentalController.d.ts +8 -0
- package/lib/controllers/ExperimentalController.js +77 -0
- package/lib/controllers/PluginController.d.ts +4 -5
- package/lib/controllers/PluginController.js +14 -59
- package/lib/controllers/PresetController.d.ts +9 -3
- package/lib/controllers/PresetController.js +61 -52
- package/lib/controllers/ProjectController.d.ts +7 -2
- package/lib/controllers/ProjectController.js +124 -94
- package/lib/controllers/index.d.ts +1 -3
- package/lib/controllers/index.js +1 -3
- package/lib/env.d.ts +2 -2
- package/lib/env.js +3 -3
- package/lib/main.js +16 -7
- package/lib/makes/GithubClient.d.ts +14 -0
- package/lib/makes/GithubClient.js +65 -0
- package/lib/makes/Logger.d.ts +1 -1
- package/lib/makes/Plugin.d.ts +5 -0
- package/lib/makes/Plugin.js +15 -0
- package/lib/makes/index.d.ts +1 -1
- package/lib/makes/index.js +1 -1
- package/lib/modules/app/index.d.ts +2 -0
- package/lib/{plugins/proxmox → modules/app}/index.js +6 -13
- package/lib/modules/docker/index.d.ts +8 -0
- package/lib/modules/docker/index.js +41 -0
- package/lib/modules/docker/services/ContainerService.d.ts +14 -0
- package/lib/modules/docker/services/ContainerService.js +115 -0
- package/lib/{services → modules/docker/services}/DockerService.d.ts +12 -5
- package/lib/{services → modules/docker/services}/DockerService.js +33 -117
- package/lib/modules/docker/services/ImageService.d.ts +18 -0
- package/lib/modules/docker/services/ImageService.js +68 -0
- package/lib/modules/docker/services/ModemService.d.ts +14 -0
- package/lib/modules/docker/services/ModemService.js +137 -0
- package/lib/modules/docker/services/ProtoService.d.ts +6 -0
- package/lib/modules/docker/services/ProtoService.js +20 -0
- package/lib/modules/index.d.ts +3 -0
- package/lib/{plugins → modules}/index.js +3 -3
- package/lib/modules/keystore/controllers/KeystoreController.d.ts +11 -0
- package/lib/modules/keystore/controllers/KeystoreController.js +106 -0
- package/lib/modules/keystore/index.d.ts +4 -0
- package/lib/{plugins/elastic-search → modules/keystore}/index.js +16 -9
- package/lib/modules/keystore/providers/FileKeystoreProvider.d.ts +16 -0
- package/lib/modules/keystore/providers/FileKeystoreProvider.js +97 -0
- package/lib/modules/keystore/providers/KeytarKeystoreProvider.d.ts +9 -0
- package/lib/modules/keystore/providers/KeytarKeystoreProvider.js +74 -0
- package/lib/modules/keystore/services/KeystoreService.d.ts +12 -0
- package/lib/modules/keystore/services/KeystoreService.js +70 -0
- package/lib/modules/keystore/types/FileKeystore.d.ts +17 -0
- package/lib/modules/keystore/types/FileKeystore.js +33 -0
- package/lib/modules/keystore/types/Keytar.d.ts +8 -0
- package/lib/modules/keystore/types/Keytar.js +2 -0
- package/lib/modules/keystore/utils/createEncryptionKey.d.ts +1 -0
- package/lib/modules/keystore/utils/createEncryptionKey.js +46 -0
- package/lib/modules/keystore/utils/createPasswordHash.d.ts +1 -0
- package/lib/modules/keystore/utils/createPasswordHash.js +20 -0
- package/lib/modules/keystore/utils/decrypt.d.ts +1 -0
- package/lib/modules/keystore/utils/decrypt.js +15 -0
- package/lib/modules/keystore/utils/encrypt.d.ts +1 -0
- package/lib/modules/keystore/utils/encrypt.js +19 -0
- package/lib/modules/keystore/utils/index.d.ts +5 -0
- package/lib/{services → modules/keystore/utils}/index.js +5 -10
- package/lib/modules/keystore/utils/verifyPasswordHash.d.ts +1 -0
- package/lib/modules/keystore/utils/verifyPasswordHash.js +9 -0
- package/lib/{controllers → modules/proxy/controllers}/CertController.d.ts +2 -1
- package/lib/{controllers → modules/proxy/controllers}/CertController.js +4 -3
- package/lib/{controllers → modules/proxy/controllers}/ProxyController.d.ts +4 -1
- package/lib/{controllers → modules/proxy/controllers}/ProxyController.js +46 -37
- package/lib/modules/proxy/index.d.ts +5 -0
- package/lib/modules/proxy/index.js +39 -0
- package/lib/{services → modules/proxy/services}/CertService.d.ts +3 -3
- package/lib/{services → modules/proxy/services}/CertService.js +11 -11
- package/lib/{services → modules/proxy/services}/ProxyService.d.ts +2 -2
- package/lib/{services → modules/proxy/services}/ProxyService.js +21 -13
- 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 +6 -2
- package/lib/services/AppConfigService.js +60 -53
- package/lib/services/AppEventsService.d.ts +4 -4
- package/lib/services/AppEventsService.js +14 -10
- 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 +69 -16
- package/lib/services/PresetService.d.ts +9 -8
- package/lib/services/PresetService.js +145 -260
- package/lib/services/ProjectService.d.ts +8 -5
- package/lib/services/ProjectService.js +44 -18
- package/lib/utils/followProgress2.d.ts +1 -0
- package/lib/utils/followProgress2.js +63 -0
- package/lib/utils/index.d.ts +1 -4
- package/lib/utils/index.js +1 -4
- package/package.json +24 -15
- package/proto/buildkit.proto +55 -0
- package/proto/solver/pb/ops.proto +443 -0
- package/lib/controllers/ImageController.d.ts +0 -7
- package/lib/controllers/ImageController.js +0 -46
- package/lib/makes/FS.d.ts +0 -27
- package/lib/makes/FS.js +0 -284
- package/lib/makes/LineConvertStream.d.ts +0 -11
- package/lib/makes/LineConvertStream.js +0 -42
- package/lib/makes/Model.d.ts +0 -5
- package/lib/makes/Model.js +0 -12
- package/lib/plugins/MongodbPlugin.d.ts +0 -20
- package/lib/plugins/MongodbPlugin.js +0 -288
- 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/index.d.ts +0 -3
- 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/services/index.d.ts +0 -10
- package/lib/utils/followProgress.d.ts +0 -1
- package/lib/utils/followProgress.js +0 -73
- 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
- /package/lib/{utils/format-size-units.d.ts → modules/docker/utils/formatSizeUnits.d.ts} +0 -0
- /package/lib/{utils/format-size-units.js → modules/docker/utils/formatSizeUnits.js} +0 -0
|
@@ -52,11 +52,15 @@ 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
|
-
const
|
|
59
|
-
const
|
|
58
|
+
const AppConfigService_1 = require("../services/AppConfigService");
|
|
59
|
+
const AppEventsService_1 = require("../services/AppEventsService");
|
|
60
|
+
const ProjectService_1 = require("../services/ProjectService");
|
|
61
|
+
const LogService_1 = require("../services/LogService");
|
|
62
|
+
const modules_1 = require("../modules");
|
|
63
|
+
const process = __importStar(require("node:process"));
|
|
60
64
|
let ProjectController = class ProjectController {
|
|
61
65
|
constructor(appConfigService, appEventsService, projectService, logService, dockerService) {
|
|
62
66
|
this.appConfigService = appConfigService;
|
|
@@ -81,25 +85,37 @@ let ProjectController = class ProjectController {
|
|
|
81
85
|
}
|
|
82
86
|
}
|
|
83
87
|
async init(name, type) {
|
|
88
|
+
const fs = new core_1.FileSystem(this.appConfigService.pwd());
|
|
84
89
|
let project = this.projectService.searchOne({
|
|
85
|
-
path:
|
|
90
|
+
path: fs.path()
|
|
86
91
|
});
|
|
87
|
-
const fs = new core_1.FileSystem(this.appConfigService.pwd());
|
|
88
92
|
if (!project) {
|
|
89
93
|
project = this.projectService.fromObject({
|
|
90
|
-
path:
|
|
94
|
+
path: fs.path()
|
|
91
95
|
});
|
|
92
96
|
}
|
|
93
|
-
project.path =
|
|
97
|
+
project.path = fs.path();
|
|
94
98
|
if (name) {
|
|
95
99
|
project.name = name;
|
|
96
100
|
}
|
|
97
101
|
if (!name || !project.name) {
|
|
98
|
-
project.name = await (0, utils_1.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
default: project.name || Path.basename(project.path)
|
|
102
|
+
project.name = await (0, utils_1.promptInput)({
|
|
103
|
+
required: "Project name is required",
|
|
104
|
+
message: "Project name",
|
|
105
|
+
type: "text",
|
|
106
|
+
default: project.name || Path.basename(project.path),
|
|
107
|
+
validate: (name) => {
|
|
108
|
+
if (typeof name !== "string") {
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
const otherProject = this.projectService.searchOne({
|
|
112
|
+
name
|
|
113
|
+
});
|
|
114
|
+
if (otherProject && otherProject.path !== project.path) {
|
|
115
|
+
return `Project "${name}" already exists`;
|
|
116
|
+
}
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
103
119
|
});
|
|
104
120
|
project.addDomain(project.containerName);
|
|
105
121
|
}
|
|
@@ -108,15 +124,16 @@ let ProjectController = class ProjectController {
|
|
|
108
124
|
}
|
|
109
125
|
const mapTypes = this.appConfigService.getProjectTypes();
|
|
110
126
|
if (!type || !project.type || !mapTypes[project.type]) {
|
|
111
|
-
project.type =
|
|
112
|
-
message: "Project type
|
|
127
|
+
project.type = await (0, utils_1.promptSelect)({
|
|
128
|
+
message: "Project type",
|
|
129
|
+
required: true,
|
|
113
130
|
options: mapTypes,
|
|
114
131
|
default: project.type
|
|
115
|
-
})
|
|
132
|
+
});
|
|
116
133
|
}
|
|
117
134
|
switch (project.type) {
|
|
118
135
|
case core_1.PROJECT_TYPE_DOCKERFILE: {
|
|
119
|
-
const files =
|
|
136
|
+
const files = fs.readdir();
|
|
120
137
|
const dockerfiles = files.filter((fileName) => {
|
|
121
138
|
if (new RegExp("^(.*)\\.dockerfile$").test(fileName)) {
|
|
122
139
|
return true;
|
|
@@ -127,7 +144,8 @@ let ProjectController = class ProjectController {
|
|
|
127
144
|
throw new Error("Dockerfiles not found");
|
|
128
145
|
}
|
|
129
146
|
project.dockerfile = await (0, utils_1.promptSelect)({
|
|
130
|
-
message: "Dockerfile
|
|
147
|
+
message: "Dockerfile",
|
|
148
|
+
required: true,
|
|
131
149
|
options: dockerfiles.map((dockerfile) => {
|
|
132
150
|
return {
|
|
133
151
|
value: dockerfile
|
|
@@ -138,8 +156,8 @@ let ProjectController = class ProjectController {
|
|
|
138
156
|
break;
|
|
139
157
|
}
|
|
140
158
|
case core_1.PROJECT_TYPE_IMAGE: {
|
|
141
|
-
project.imageName = await (0, utils_1.
|
|
142
|
-
message: "Image name
|
|
159
|
+
project.imageName = await (0, utils_1.promptInput)({
|
|
160
|
+
message: "Image name",
|
|
143
161
|
required: true,
|
|
144
162
|
default: project.imageName
|
|
145
163
|
});
|
|
@@ -151,7 +169,16 @@ let ProjectController = class ProjectController {
|
|
|
151
169
|
throw new Error("Invalid project type");
|
|
152
170
|
}
|
|
153
171
|
await this.appEventsService.emit("project:init", project);
|
|
154
|
-
|
|
172
|
+
project.save();
|
|
173
|
+
}
|
|
174
|
+
async destroy(name) {
|
|
175
|
+
const project = this.projectService.get(name);
|
|
176
|
+
await this.projectService.stop(project);
|
|
177
|
+
this.appConfigService.removeProject(project.id);
|
|
178
|
+
this.appConfigService.save();
|
|
179
|
+
this.appConfigService.fs.rm(`projects/${project.id}`, {
|
|
180
|
+
recursive: true
|
|
181
|
+
});
|
|
155
182
|
}
|
|
156
183
|
async projectList(all) {
|
|
157
184
|
const table = new cli_table3_1.default({
|
|
@@ -175,12 +202,12 @@ let ProjectController = class ProjectController {
|
|
|
175
202
|
async start(name, detach, attach, rebuild, restart) {
|
|
176
203
|
const project = this.projectService.get(name);
|
|
177
204
|
await this.projectService.start(project, restart, rebuild);
|
|
205
|
+
if (detach) {
|
|
206
|
+
console.info(yoctocolors_cjs_1.default.yellow("Warning: Detach option is deprecated"));
|
|
207
|
+
}
|
|
178
208
|
if (attach) {
|
|
179
209
|
await this.dockerService.attach(project.containerName);
|
|
180
210
|
}
|
|
181
|
-
if (detach) {
|
|
182
|
-
console.info(chalk_1.default.yellow("Warning: Detach option is deprecated"));
|
|
183
|
-
}
|
|
184
211
|
}
|
|
185
212
|
async stop(name) {
|
|
186
213
|
if (name) {
|
|
@@ -195,7 +222,7 @@ let ProjectController = class ProjectController {
|
|
|
195
222
|
}
|
|
196
223
|
const project = this.projectService.get();
|
|
197
224
|
const table = new cli_table3_1.default({
|
|
198
|
-
head: [
|
|
225
|
+
head: [yoctocolors_cjs_1.default.yellow("Domain")]
|
|
199
226
|
});
|
|
200
227
|
for (const domain of project.domains) {
|
|
201
228
|
table.push([domain]);
|
|
@@ -210,7 +237,7 @@ let ProjectController = class ProjectController {
|
|
|
210
237
|
for (const domain of addDomains) {
|
|
211
238
|
project.addDomain(domain);
|
|
212
239
|
}
|
|
213
|
-
|
|
240
|
+
project.save();
|
|
214
241
|
}
|
|
215
242
|
async setDomains(domains, name) {
|
|
216
243
|
if (name) {
|
|
@@ -221,7 +248,7 @@ let ProjectController = class ProjectController {
|
|
|
221
248
|
for (const domain of domains) {
|
|
222
249
|
project.addDomain(domain);
|
|
223
250
|
}
|
|
224
|
-
|
|
251
|
+
project.save();
|
|
225
252
|
}
|
|
226
253
|
async removeDomain(removeDomains, name) {
|
|
227
254
|
if (name) {
|
|
@@ -231,7 +258,7 @@ let ProjectController = class ProjectController {
|
|
|
231
258
|
for (const domain of removeDomains) {
|
|
232
259
|
project.removeDomain(domain);
|
|
233
260
|
}
|
|
234
|
-
|
|
261
|
+
project.save();
|
|
235
262
|
}
|
|
236
263
|
async clearDomain(name) {
|
|
237
264
|
if (name) {
|
|
@@ -239,7 +266,7 @@ let ProjectController = class ProjectController {
|
|
|
239
266
|
}
|
|
240
267
|
const project = this.projectService.get();
|
|
241
268
|
project.clearDomains();
|
|
242
|
-
|
|
269
|
+
project.save();
|
|
243
270
|
}
|
|
244
271
|
async ports(name) {
|
|
245
272
|
if (name) {
|
|
@@ -260,7 +287,7 @@ let ProjectController = class ProjectController {
|
|
|
260
287
|
}
|
|
261
288
|
const project = this.projectService.get();
|
|
262
289
|
project.linkPort(parseInt(hostPort), parseInt(containerPort));
|
|
263
|
-
|
|
290
|
+
project.save();
|
|
264
291
|
}
|
|
265
292
|
async removePort(hostPort, containerPort, name) {
|
|
266
293
|
if (name) {
|
|
@@ -268,7 +295,7 @@ let ProjectController = class ProjectController {
|
|
|
268
295
|
}
|
|
269
296
|
const project = this.projectService.get();
|
|
270
297
|
project.unlinkPort(parseInt(hostPort), parseInt(containerPort));
|
|
271
|
-
|
|
298
|
+
project.save();
|
|
272
299
|
}
|
|
273
300
|
async clearPorts(name) {
|
|
274
301
|
if (name) {
|
|
@@ -277,7 +304,7 @@ let ProjectController = class ProjectController {
|
|
|
277
304
|
const project = this.projectService.get();
|
|
278
305
|
if (project.ports) {
|
|
279
306
|
delete project.ports;
|
|
280
|
-
|
|
307
|
+
project.save();
|
|
281
308
|
}
|
|
282
309
|
}
|
|
283
310
|
async configList(name, global) {
|
|
@@ -290,7 +317,7 @@ let ProjectController = class ProjectController {
|
|
|
290
317
|
env = project.env || {};
|
|
291
318
|
}
|
|
292
319
|
else {
|
|
293
|
-
const config = this.appConfigService.
|
|
320
|
+
const config = this.appConfigService.config;
|
|
294
321
|
env = config.env || {};
|
|
295
322
|
}
|
|
296
323
|
const table = new cli_table3_1.default({
|
|
@@ -306,7 +333,7 @@ let ProjectController = class ProjectController {
|
|
|
306
333
|
this.projectService.cdProject(name);
|
|
307
334
|
}
|
|
308
335
|
let config = global
|
|
309
|
-
? this.appConfigService.
|
|
336
|
+
? this.appConfigService.config
|
|
310
337
|
: this.projectService.get();
|
|
311
338
|
const table = new cli_table3_1.default({
|
|
312
339
|
head: ["KEY", "VALUE"]
|
|
@@ -321,27 +348,33 @@ let ProjectController = class ProjectController {
|
|
|
321
348
|
return table.toString();
|
|
322
349
|
}
|
|
323
350
|
async configSet(variables, name, global) {
|
|
324
|
-
if (
|
|
351
|
+
if (global) {
|
|
352
|
+
for (const variable of variables) {
|
|
353
|
+
const [key, value] = variable.split("=");
|
|
354
|
+
if (!value) {
|
|
355
|
+
console.info(yoctocolors_cjs_1.default.yellow(`No value for "${key}"`));
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
this.appConfigService.config.setEnv(key.trim(), value.trim());
|
|
359
|
+
}
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
if (name) {
|
|
325
363
|
this.projectService.cdProject(name);
|
|
326
364
|
}
|
|
327
|
-
const
|
|
328
|
-
? this.appConfigService.getConfig()
|
|
329
|
-
: this.projectService.get();
|
|
365
|
+
const project = this.projectService.get();
|
|
330
366
|
for (const variable of variables) {
|
|
331
367
|
const [key, value] = variable.split("=");
|
|
332
368
|
if (!value) {
|
|
333
|
-
console.info(
|
|
369
|
+
console.info(yoctocolors_cjs_1.default.yellow(`No value for "${key}"`));
|
|
334
370
|
continue;
|
|
335
371
|
}
|
|
336
|
-
|
|
372
|
+
project.setEnv(key, value);
|
|
337
373
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
if (container) {
|
|
343
|
-
await this.projectService.start(project, true);
|
|
344
|
-
}
|
|
374
|
+
project.save();
|
|
375
|
+
const container = await this.dockerService.getContainer(project.containerName);
|
|
376
|
+
if (container) {
|
|
377
|
+
await this.projectService.start(project, true);
|
|
345
378
|
}
|
|
346
379
|
}
|
|
347
380
|
async configUnset(configs, name, global) {
|
|
@@ -360,7 +393,7 @@ let ProjectController = class ProjectController {
|
|
|
360
393
|
for (const i in env) {
|
|
361
394
|
project.unsetEnv(i);
|
|
362
395
|
}
|
|
363
|
-
|
|
396
|
+
project.save();
|
|
364
397
|
if (!global) {
|
|
365
398
|
const project = this.projectService.get();
|
|
366
399
|
const container = await this.dockerService.getContainer(project.containerName);
|
|
@@ -399,7 +432,7 @@ let ProjectController = class ProjectController {
|
|
|
399
432
|
}
|
|
400
433
|
return table.toString();
|
|
401
434
|
}
|
|
402
|
-
async buildArgsSet(
|
|
435
|
+
async buildArgsSet(args, name) {
|
|
403
436
|
if (name) {
|
|
404
437
|
this.projectService.cdProject(name);
|
|
405
438
|
}
|
|
@@ -419,7 +452,7 @@ let ProjectController = class ProjectController {
|
|
|
419
452
|
}
|
|
420
453
|
project.buildArgs[key] = buildArgs[key];
|
|
421
454
|
}
|
|
422
|
-
|
|
455
|
+
project.save();
|
|
423
456
|
}
|
|
424
457
|
async buildArgsUnset(args, name) {
|
|
425
458
|
if (name) {
|
|
@@ -441,7 +474,7 @@ let ProjectController = class ProjectController {
|
|
|
441
474
|
delete project.buildArgs[key];
|
|
442
475
|
}
|
|
443
476
|
}
|
|
444
|
-
|
|
477
|
+
project.save();
|
|
445
478
|
}
|
|
446
479
|
async volumeList(name) {
|
|
447
480
|
if (name) {
|
|
@@ -464,7 +497,7 @@ let ProjectController = class ProjectController {
|
|
|
464
497
|
const project = this.projectService.get();
|
|
465
498
|
if (Array.isArray(volumes) && volumes.length > 0) {
|
|
466
499
|
project.volumeMount(...volumes);
|
|
467
|
-
|
|
500
|
+
project.save();
|
|
468
501
|
}
|
|
469
502
|
}
|
|
470
503
|
async volumeUnmount(volumes, name) {
|
|
@@ -474,7 +507,7 @@ let ProjectController = class ProjectController {
|
|
|
474
507
|
const project = this.projectService.get();
|
|
475
508
|
if (Array.isArray(volumes) && volumes.length > 0) {
|
|
476
509
|
project.volumeUnmount(...volumes);
|
|
477
|
-
|
|
510
|
+
project.save();
|
|
478
511
|
}
|
|
479
512
|
}
|
|
480
513
|
async extraHostList(name) {
|
|
@@ -501,7 +534,7 @@ let ProjectController = class ProjectController {
|
|
|
501
534
|
}
|
|
502
535
|
const project = this.projectService.get();
|
|
503
536
|
project.addExtraHost(extraHost, extraDomain);
|
|
504
|
-
|
|
537
|
+
project.save();
|
|
505
538
|
}
|
|
506
539
|
async removeExtraHost(extraHost, name) {
|
|
507
540
|
if (name) {
|
|
@@ -509,7 +542,7 @@ let ProjectController = class ProjectController {
|
|
|
509
542
|
}
|
|
510
543
|
const project = this.projectService.get();
|
|
511
544
|
project.removeExtraHost(extraHost);
|
|
512
|
-
|
|
545
|
+
project.save();
|
|
513
546
|
}
|
|
514
547
|
async attach(name) {
|
|
515
548
|
if (name) {
|
|
@@ -556,46 +589,48 @@ let ProjectController = class ProjectController {
|
|
|
556
589
|
if (clear) {
|
|
557
590
|
this.logService.clear();
|
|
558
591
|
}
|
|
559
|
-
const logFilepath = this.appConfigService.dataPath("ws.log");
|
|
560
592
|
const prepareLog = (str) => {
|
|
561
593
|
return str.replace(/^\[.*]\s([^:]+):\s.*$/gm, (substring, type) => {
|
|
562
594
|
switch (type) {
|
|
563
595
|
case "debug":
|
|
564
|
-
return
|
|
596
|
+
return yoctocolors_cjs_1.default.gray(substring);
|
|
565
597
|
case "log":
|
|
566
|
-
return
|
|
598
|
+
return yoctocolors_cjs_1.default.white(substring);
|
|
567
599
|
case "info":
|
|
568
|
-
return
|
|
600
|
+
return yoctocolors_cjs_1.default.green(substring);
|
|
569
601
|
case "warn":
|
|
570
602
|
case "warning":
|
|
571
|
-
return
|
|
603
|
+
return yoctocolors_cjs_1.default.yellow(substring);
|
|
572
604
|
case "error":
|
|
573
|
-
return
|
|
605
|
+
return yoctocolors_cjs_1.default.red(substring);
|
|
574
606
|
default:
|
|
575
607
|
return substring;
|
|
576
608
|
}
|
|
577
609
|
});
|
|
578
610
|
};
|
|
579
|
-
const
|
|
580
|
-
stream.
|
|
581
|
-
|
|
611
|
+
const file = this.appConfigService.fs.open("ws.log", "r");
|
|
612
|
+
const stream = file.createReadlineStream({
|
|
613
|
+
start: -10
|
|
614
|
+
});
|
|
615
|
+
stream.on("data", (line) => {
|
|
616
|
+
process.stdout.write(prepareLog(line));
|
|
582
617
|
process.stdout.write("\n");
|
|
583
618
|
});
|
|
584
619
|
if (follow) {
|
|
585
|
-
const stats =
|
|
586
|
-
const watcher =
|
|
620
|
+
const stats = file.stat();
|
|
621
|
+
const watcher = this.appConfigService.fs.watch("ws.log");
|
|
587
622
|
const mutex = new async_mutex_1.Mutex();
|
|
588
|
-
let position =
|
|
623
|
+
let position = stats.size;
|
|
589
624
|
watcher.on("change", async () => {
|
|
590
625
|
await mutex.acquire();
|
|
591
626
|
try {
|
|
592
|
-
const stats =
|
|
593
|
-
if (
|
|
627
|
+
const stats = file.stat();
|
|
628
|
+
if (stats.size < position) {
|
|
594
629
|
console.info("file truncated");
|
|
595
|
-
position =
|
|
630
|
+
position = 0;
|
|
596
631
|
}
|
|
597
|
-
const buffer =
|
|
598
|
-
position +=
|
|
632
|
+
const buffer = file.readBytes(position);
|
|
633
|
+
position += buffer.length;
|
|
599
634
|
process.stdout.write(prepareLog(buffer.toString("utf-8")));
|
|
600
635
|
}
|
|
601
636
|
finally {
|
|
@@ -608,22 +643,7 @@ let ProjectController = class ProjectController {
|
|
|
608
643
|
if (name) {
|
|
609
644
|
this.projectService.cdProject(name);
|
|
610
645
|
}
|
|
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
|
-
}
|
|
646
|
+
await this.projectService.logs(detach);
|
|
627
647
|
}
|
|
628
648
|
};
|
|
629
649
|
exports.ProjectController = ProjectController;
|
|
@@ -656,6 +676,14 @@ __decorate([
|
|
|
656
676
|
__metadata("design:paramtypes", [String, String]),
|
|
657
677
|
__metadata("design:returntype", Promise)
|
|
658
678
|
], ProjectController.prototype, "init", null);
|
|
679
|
+
__decorate([
|
|
680
|
+
(0, core_1.Command)("destroy [name]"),
|
|
681
|
+
(0, core_1.Description)("Permanently destroy a project"),
|
|
682
|
+
__param(0, (0, core_1.Param)("name")),
|
|
683
|
+
__metadata("design:type", Function),
|
|
684
|
+
__metadata("design:paramtypes", [String]),
|
|
685
|
+
__metadata("design:returntype", Promise)
|
|
686
|
+
], ProjectController.prototype, "destroy", null);
|
|
659
687
|
__decorate([
|
|
660
688
|
(0, core_1.Command)("ps"),
|
|
661
689
|
(0, core_1.Description)("Projects list"),
|
|
@@ -913,13 +941,14 @@ __decorate([
|
|
|
913
941
|
], ProjectController.prototype, "buildArgsGet", null);
|
|
914
942
|
__decorate([
|
|
915
943
|
(0, core_1.Command)("build-args:set [...buildArgs]"),
|
|
916
|
-
__param(0, (0, core_1.
|
|
944
|
+
__param(0, (0, core_1.Param)("buildArgs")),
|
|
945
|
+
__param(1, (0, core_1.Option)("name", {
|
|
917
946
|
type: "string",
|
|
918
947
|
alias: "n",
|
|
919
948
|
description: "The name of the project"
|
|
920
949
|
})),
|
|
921
950
|
__metadata("design:type", Function),
|
|
922
|
-
__metadata("design:paramtypes", [
|
|
951
|
+
__metadata("design:paramtypes", [Array, String]),
|
|
923
952
|
__metadata("design:returntype", Promise)
|
|
924
953
|
], ProjectController.prototype, "buildArgsSet", null);
|
|
925
954
|
__decorate([
|
|
@@ -1072,9 +1101,10 @@ __decorate([
|
|
|
1072
1101
|
], ProjectController.prototype, "logs", null);
|
|
1073
1102
|
exports.ProjectController = ProjectController = __decorate([
|
|
1074
1103
|
(0, core_1.Controller)(),
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1104
|
+
(0, core_1.Description)("Project commands"),
|
|
1105
|
+
__metadata("design:paramtypes", [AppConfigService_1.AppConfigService,
|
|
1106
|
+
AppEventsService_1.AppEventsService,
|
|
1107
|
+
ProjectService_1.ProjectService,
|
|
1108
|
+
LogService_1.LogService,
|
|
1109
|
+
modules_1.DockerService])
|
|
1080
1110
|
], ProjectController);
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
export * from "./CertController";
|
|
2
1
|
export * from "./CompletionController";
|
|
3
2
|
export * from "./DebugController";
|
|
4
|
-
export * from "./
|
|
3
|
+
export * from "./ExperimentalController";
|
|
5
4
|
export * from "./PluginController";
|
|
6
5
|
export * from "./PresetController";
|
|
7
6
|
export * from "./ProjectController";
|
|
8
|
-
export * from "./ProxyController";
|
package/lib/controllers/index.js
CHANGED
|
@@ -14,11 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./CertController"), exports);
|
|
18
17
|
__exportStar(require("./CompletionController"), exports);
|
|
19
18
|
__exportStar(require("./DebugController"), exports);
|
|
20
|
-
__exportStar(require("./
|
|
19
|
+
__exportStar(require("./ExperimentalController"), exports);
|
|
21
20
|
__exportStar(require("./PluginController"), exports);
|
|
22
21
|
__exportStar(require("./PresetController"), exports);
|
|
23
22
|
__exportStar(require("./ProjectController"), exports);
|
|
24
|
-
__exportStar(require("./ProxyController"), exports);
|
package/lib/env.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export declare const WOCKER_VERSION = "1.0.
|
|
1
|
+
export declare const WOCKER_VERSION = "1.0.23";
|
|
2
2
|
export declare const NODE_ENV: string;
|
|
3
3
|
export declare const ROOT_DIR: string;
|
|
4
4
|
export declare const PRESETS_DIR: string;
|
|
5
|
-
export declare const SERVICES_DIR: string;
|
|
6
5
|
export declare const PLUGINS_DIR: string;
|
|
7
6
|
export declare const DATA_DIR: string;
|
|
8
7
|
export declare const VIRTUAL_HOST_KEY = "VIRTUAL_HOST";
|
|
8
|
+
export declare const KEYTAR_SERVICE: string;
|
package/lib/env.js
CHANGED
|
@@ -33,14 +33,14 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
36
|
+
exports.KEYTAR_SERVICE = exports.VIRTUAL_HOST_KEY = exports.DATA_DIR = exports.PLUGINS_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.23";
|
|
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");
|
|
43
|
-
exports.SERVICES_DIR = Path.join(exports.ROOT_DIR, "services");
|
|
44
43
|
exports.PLUGINS_DIR = Path.join(exports.ROOT_DIR, "plugins");
|
|
45
44
|
exports.DATA_DIR = process.env.WS_DIR || Path.join(OS.homedir(), ".workspace");
|
|
46
45
|
exports.VIRTUAL_HOST_KEY = "VIRTUAL_HOST";
|
|
46
|
+
exports.KEYTAR_SERVICE = process.env.WOCKER_KEYTAR_SERVICE || "wocker";
|
package/lib/main.js
CHANGED
|
@@ -5,14 +5,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.app = void 0;
|
|
7
7
|
const core_1 = require("@wocker/core");
|
|
8
|
-
const
|
|
8
|
+
const yoctocolors_cjs_1 = __importDefault(require("yoctocolors-cjs"));
|
|
9
9
|
const AppModule_1 = require("./AppModule");
|
|
10
|
-
const
|
|
10
|
+
const AppConfigService_1 = require("./services/AppConfigService");
|
|
11
|
+
const LogService_1 = require("./services/LogService");
|
|
11
12
|
exports.app = {
|
|
12
13
|
async run(args) {
|
|
13
14
|
const app = await core_1.Factory.create(AppModule_1.AppModule);
|
|
14
|
-
const
|
|
15
|
-
const logger = app.get(
|
|
15
|
+
const configService = app.get(AppConfigService_1.AppConfigService);
|
|
16
|
+
const logger = app.get(LogService_1.LogService);
|
|
16
17
|
try {
|
|
17
18
|
const res = await app.run(args);
|
|
18
19
|
if (res) {
|
|
@@ -21,9 +22,17 @@ exports.app = {
|
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
catch (err) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
if (typeof err.name === "string" && ["ExitPromptError", "CancelPromptError", "AbortPromptError"].includes(err.name)) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
console.error(yoctocolors_cjs_1.default.red(err.message));
|
|
29
|
+
if (err instanceof core_1.UsageException || err.name === "UsageException") {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (err instanceof core_1.CommandNotFoundError) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (configService.config.debug) {
|
|
27
36
|
logger.error(err.stack || err.toString());
|
|
28
37
|
}
|
|
29
38
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
type RepositoryInfo = {
|
|
3
|
+
default_branch: string;
|
|
4
|
+
};
|
|
5
|
+
export declare class GithubClient {
|
|
6
|
+
owner: string;
|
|
7
|
+
repository: string;
|
|
8
|
+
constructor(owner: string, repository: string);
|
|
9
|
+
get axios(): AxiosInstance;
|
|
10
|
+
getInfo(): Promise<RepositoryInfo>;
|
|
11
|
+
getFile(branch: string, path: string): Promise<any>;
|
|
12
|
+
download(branch: string, dirPath: string): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.GithubClient = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const core_1 = require("@wocker/core");
|
|
9
|
+
class GithubClient {
|
|
10
|
+
constructor(owner, repository) {
|
|
11
|
+
this.owner = owner;
|
|
12
|
+
this.repository = repository;
|
|
13
|
+
}
|
|
14
|
+
get axios() {
|
|
15
|
+
return axios_1.default.create({
|
|
16
|
+
headers: {
|
|
17
|
+
"User-Agent": "Wocker"
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
async getInfo() {
|
|
22
|
+
const response = await this.axios.get(`https://api.github.com/repos/${this.owner}/${this.repository}`, {
|
|
23
|
+
headers: {
|
|
24
|
+
"Accept": "application/vnd.github+json"
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return response.data;
|
|
28
|
+
}
|
|
29
|
+
async getFile(branch, path) {
|
|
30
|
+
const response = await this.axios.get(`https://raw.githubusercontent.com/${this.owner}/${this.repository}/${branch}/${path}`, {
|
|
31
|
+
headers: {
|
|
32
|
+
"Accept": "application/vnd.github+json"
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return response.data;
|
|
36
|
+
}
|
|
37
|
+
async download(branch, dirPath) {
|
|
38
|
+
const res = await this.axios.get(`https://github.com/${this.owner}/${this.repository}/archive/refs/heads/${branch}.zip`, {
|
|
39
|
+
responseType: "stream"
|
|
40
|
+
});
|
|
41
|
+
const fs = new core_1.FileSystem(dirPath);
|
|
42
|
+
if (!fs.exists()) {
|
|
43
|
+
fs.mkdir("", {
|
|
44
|
+
recursive: true
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
const { Parse } = require("unzipper"), pipe = res.data.pipe(Parse());
|
|
49
|
+
pipe.on("entry", (entry) => {
|
|
50
|
+
const path = entry.path.replace(/^[^\/]+\//, "");
|
|
51
|
+
if (entry.type === "File") {
|
|
52
|
+
entry.pipe(fs.createWriteStream(path));
|
|
53
|
+
}
|
|
54
|
+
else if (entry.type === "Directory") {
|
|
55
|
+
fs.mkdir(path, {
|
|
56
|
+
recursive: true
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
pipe.on("end", () => resolve());
|
|
61
|
+
pipe.on("error", reject);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.GithubClient = GithubClient;
|
package/lib/makes/Logger.d.ts
CHANGED