@wocker/ws 1.0.7 → 1.0.9

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.
Files changed (118) hide show
  1. package/bin/ws.js +2 -13
  2. package/lib/AppModule.d.ts +6 -0
  3. package/lib/AppModule.js +100 -0
  4. package/lib/controllers/CompletionController.d.ts +6 -0
  5. package/lib/controllers/CompletionController.js +32 -0
  6. package/lib/controllers/DebugController.d.ts +7 -0
  7. package/lib/controllers/DebugController.js +44 -0
  8. package/lib/controllers/ImageController.d.ts +5 -8
  9. package/lib/controllers/ImageController.js +27 -12
  10. package/lib/controllers/PluginController.d.ts +11 -13
  11. package/lib/controllers/PluginController.js +93 -54
  12. package/lib/controllers/PresetController.d.ts +10 -15
  13. package/lib/controllers/PresetController.js +111 -27
  14. package/lib/controllers/ProjectController.d.ts +27 -70
  15. package/lib/controllers/ProjectController.js +357 -306
  16. package/lib/controllers/ProxyController.d.ts +15 -25
  17. package/lib/controllers/ProxyController.js +157 -102
  18. package/lib/controllers/index.d.ts +2 -0
  19. package/lib/controllers/index.js +2 -0
  20. package/lib/main.d.ts +3 -0
  21. package/lib/main.js +30 -0
  22. package/lib/makes/FS.d.ts +15 -5
  23. package/lib/makes/FS.js +42 -9
  24. package/lib/makes/Http.d.ts +18 -0
  25. package/lib/makes/{Plugin.js → Http.js} +45 -34
  26. package/lib/makes/Logger.d.ts +2 -2
  27. package/lib/makes/Logger.js +19 -8
  28. package/lib/makes/Preset.d.ts +5 -6
  29. package/lib/makes/Preset.js +19 -8
  30. package/lib/makes/index.d.ts +1 -6
  31. package/lib/makes/index.js +1 -6
  32. package/lib/plugins/ElasticSearchPlugin.d.ts +5 -6
  33. package/lib/plugins/ElasticSearchPlugin.js +19 -8
  34. package/lib/plugins/LocaltunnelPlugin.d.ts +8 -8
  35. package/lib/plugins/LocaltunnelPlugin.js +25 -10
  36. package/lib/plugins/MaildevPlugin.d.ts +5 -6
  37. package/lib/plugins/MaildevPlugin.js +21 -8
  38. package/lib/plugins/MongodbPlugin.d.ts +5 -5
  39. package/lib/plugins/MongodbPlugin.js +26 -11
  40. package/lib/plugins/NgrokPlugin.d.ts +7 -6
  41. package/lib/plugins/NgrokPlugin.js +32 -17
  42. package/lib/plugins/PageKitePlugin.d.ts +10 -8
  43. package/lib/plugins/PageKitePlugin.js +36 -20
  44. package/lib/plugins/ProxmoxPlugin.d.ts +8 -5
  45. package/lib/plugins/ProxmoxPlugin.js +25 -9
  46. package/lib/plugins/RedisPlugin.d.ts +4 -6
  47. package/lib/plugins/RedisPlugin.js +19 -8
  48. package/lib/plugins/index.d.ts +0 -2
  49. package/lib/plugins/index.js +0 -2
  50. package/lib/services/AppConfigService.d.ts +7 -17
  51. package/lib/services/AppConfigService.js +44 -114
  52. package/lib/services/AppEventsService.d.ts +1 -2
  53. package/lib/services/AppEventsService.js +11 -2
  54. package/lib/services/DockerService.d.ts +9 -39
  55. package/lib/services/DockerService.js +122 -4
  56. package/lib/services/LogService.d.ts +3 -5
  57. package/lib/services/LogService.js +19 -4
  58. package/lib/services/PluginService.d.ts +11 -9
  59. package/lib/services/PluginService.js +100 -8
  60. package/lib/services/PresetService.d.ts +4 -5
  61. package/lib/services/PresetService.js +26 -5
  62. package/lib/services/ProjectService.d.ts +9 -6
  63. package/lib/services/ProjectService.js +72 -37
  64. package/lib/utils/exec.d.ts +4 -1
  65. package/lib/utils/exec.js +16 -31
  66. package/lib/utils/followProgress.js +49 -45
  67. package/lib/utils/index.d.ts +0 -7
  68. package/lib/utils/index.js +0 -7
  69. package/lib/utils/spawn.d.ts +1 -1
  70. package/lib/utils/spawn.js +20 -12
  71. package/package.json +5 -7
  72. package/presets/node/config.json +1 -1
  73. package/presets/php-apache/Dockerfile +1 -1
  74. package/presets/php-apache/config.json +2 -1
  75. package/presets/php-fpm/Dockerfile +1 -1
  76. package/lib/App.d.ts +0 -16
  77. package/lib/App.js +0 -107
  78. package/lib/decorators/Inject.d.ts +0 -1
  79. package/lib/decorators/Inject.js +0 -8
  80. package/lib/decorators/Injectable.d.ts +0 -4
  81. package/lib/decorators/Injectable.js +0 -17
  82. package/lib/decorators/index.d.ts +0 -1
  83. package/lib/decorators/index.js +0 -17
  84. package/lib/index.d.ts +0 -6
  85. package/lib/index.js +0 -33
  86. package/lib/makes/Controller.d.ts +0 -5
  87. package/lib/makes/Controller.js +0 -8
  88. package/lib/makes/DI.d.ts +0 -7
  89. package/lib/makes/DI.js +0 -27
  90. package/lib/makes/Docker.d.ts +0 -58
  91. package/lib/makes/Docker.js +0 -320
  92. package/lib/makes/Plugin.d.ts +0 -13
  93. package/lib/makes/Project.d.ts +0 -45
  94. package/lib/makes/Project.js +0 -127
  95. package/lib/makes/Repository.d.ts +0 -11
  96. package/lib/makes/Repository.js +0 -22
  97. package/lib/plugins/PostgresPlugin.d.ts +0 -16
  98. package/lib/plugins/PostgresPlugin.js +0 -121
  99. package/lib/types/Config.d.ts +0 -12
  100. package/lib/types/Config.js +0 -2
  101. package/lib/types/EnvConfig.d.ts +0 -3
  102. package/lib/types/EnvConfig.js +0 -2
  103. package/lib/types/index.d.ts +0 -2
  104. package/lib/types/index.js +0 -18
  105. package/lib/utils/buildOptions.d.ts +0 -1
  106. package/lib/utils/buildOptions.js +0 -9
  107. package/lib/utils/demuxOutput.d.ts +0 -2
  108. package/lib/utils/demuxOutput.js +0 -19
  109. package/lib/utils/fetch.d.ts +0 -5
  110. package/lib/utils/fetch.js +0 -52
  111. package/lib/utils/get-config.d.ts +0 -2
  112. package/lib/utils/get-config.js +0 -17
  113. package/lib/utils/image-build.d.ts +0 -13
  114. package/lib/utils/image-build.js +0 -46
  115. package/lib/utils/set-config.d.ts +0 -2
  116. package/lib/utils/set-config.js +0 -15
  117. package/lib/utils/tty.d.ts +0 -2
  118. package/lib/utils/tty.js +0 -6
@@ -15,6 +15,12 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
18
24
  var __importStar = (this && this.__importStar) || function (mod) {
19
25
  if (mod && mod.__esModule) return mod;
20
26
  var result = {};
@@ -22,11 +28,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
28
  __setModuleDefault(result, mod);
23
29
  return result;
24
30
  };
31
+ var __metadata = (this && this.__metadata) || function (k, v) {
32
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
33
+ };
34
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
35
+ return function (target, key) { decorator(target, key, paramIndex); }
36
+ };
25
37
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
38
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
39
  };
28
40
  Object.defineProperty(exports, "__esModule", { value: true });
29
41
  exports.ProjectController = void 0;
42
+ const core_1 = require("@wocker/core");
30
43
  const utils_1 = require("@wocker/utils");
31
44
  const cli_table3_1 = __importDefault(require("cli-table3"));
32
45
  const chalk_1 = __importDefault(require("chalk"));
@@ -34,256 +47,54 @@ const Path = __importStar(require("path"));
34
47
  const async_mutex_1 = require("async-mutex");
35
48
  const env_1 = require("../env");
36
49
  const makes_1 = require("../makes");
37
- const makes_2 = require("../makes");
38
50
  const services_1 = require("../services");
39
- const utils_2 = require("../utils");
40
- class ProjectController extends makes_1.Controller {
41
- constructor(di) {
42
- super();
43
- this.di = di;
44
- this.appConfigService = this.di.resolveService(services_1.AppConfigService);
45
- this.appEventsService = this.di.resolveService(services_1.AppEventsService);
46
- this.projectService = this.di.resolveService(services_1.ProjectService);
47
- this.dockerService = this.di.resolveService(services_1.DockerService);
48
- }
49
- install(cli) {
50
- super.install(cli);
51
- cli.command("init")
52
- .help({
53
- description: "Init project"
54
- })
55
- .option("name", {
56
- type: "string",
57
- description: "Ім'я контейнеру",
58
- alias: "n"
59
- })
60
- .option("type", {
61
- type: "string",
62
- description: "Тип запуску контейнеру"
63
- })
64
- .completion("type", () => {
65
- return [];
66
- })
67
- .option("preset", {
68
- type: "string",
69
- description: "Preset",
70
- default: ""
71
- })
72
- .action((options) => this.init(options));
73
- cli.command("ps")
74
- .option("all", {
75
- type: "boolean",
76
- alias: "a",
77
- description: "All projects"
78
- })
79
- .action((options) => this.projectList(options));
80
- cli.command("start")
81
- .help({
82
- description: "Run project"
83
- })
84
- .option("name", {
85
- type: "string",
86
- alias: "n"
87
- })
88
- .completion("name", () => this.getProjectNames())
89
- .option("rebuild", {
90
- type: "boolean",
91
- alias: "r"
92
- })
93
- .option("detach", {
94
- type: "boolean",
95
- alias: "d"
96
- })
97
- .action((options) => this.start(options));
98
- cli.command("stop")
99
- .option("name", {
100
- type: "string",
101
- alias: "n"
102
- })
103
- .completion("name", () => this.getProjectNames())
104
- .action((options) => this.stop(options));
105
- cli.command("run <script>")
106
- .completion("script", (options) => this.getScripts())
107
- .action((options, script) => this.run(script));
108
- cli.command("attach")
109
- .option("name", {
110
- type: "string",
111
- alias: "n"
112
- })
113
- .completion("name", () => this.getProjectNames())
114
- .action((options) => this.attach(options));
115
- cli.command("config")
116
- .option("name", {
117
- type: "string",
118
- alias: "n"
119
- })
120
- .completion("name", () => this.getProjectNames())
121
- .option("global", {
122
- type: "boolean",
123
- alias: "g"
124
- })
125
- .action((options) => this.configList(options));
126
- cli.command("config:get <key>")
127
- .help({
128
- description: "Get project env variable"
129
- })
130
- .option("global", {
131
- alias: "g",
132
- description: "Global"
133
- })
134
- .option("name", {
135
- type: "string",
136
- alias: "n"
137
- })
138
- .completion("name", () => this.getProjectNames())
139
- .action((options, key) => this.configGet(options, key));
140
- cli.command("config:set [...configs]")
141
- .option("name", {
142
- type: "string",
143
- alias: "n"
144
- })
145
- .option("global", {
146
- type: "boolean",
147
- alias: "g"
148
- })
149
- .completion("name", () => this.getProjectNames())
150
- .action((options, configs) => this.configSet(options, configs));
151
- cli.command("config:unset [...configs]")
152
- .option("name", {
153
- type: "string",
154
- alias: "n"
155
- })
156
- .completion("name", () => this.getProjectNames())
157
- .option("global", {
158
- type: "boolean",
159
- alias: "g"
160
- })
161
- .action((options, configs) => this.configUnset(options, configs));
162
- cli.command("build-args")
163
- .option("name", {
164
- type: "string",
165
- alias: "n"
166
- })
167
- .completion("name", () => this.getProjectNames())
168
- .action((options) => this.buildArgsList(options));
169
- cli.command("build-args:get [...buildArgs]")
170
- .option("name", {
171
- type: "string",
172
- alias: "n"
173
- })
174
- .completion("name", () => this.getProjectNames())
175
- .action((options, buildArgs) => this.buildArgsGet(options, buildArgs));
176
- cli.command("build-args:set [...buildArgs]")
177
- .option("name", {
178
- type: "string",
179
- alias: "n"
180
- })
181
- .completion("name", () => this.getProjectNames())
182
- .action((options, buildArgs) => this.buildArgsSet(options, buildArgs));
183
- cli.command("build-args:unset [...buildArgs]")
184
- .option("name", {
185
- type: "string",
186
- alias: "n"
187
- })
188
- .completion("name", () => this.getProjectNames())
189
- .action((options, buildArgs) => this.buildArgsUnset(options, buildArgs));
190
- cli.command("volumes")
191
- .option("name", {
192
- type: "string",
193
- alias: "n"
194
- })
195
- .completion("name", () => this.getProjectNames())
196
- .action((options) => this.volumeList(options));
197
- cli.command("volume:mount [...volumes]")
198
- .option("name", {
199
- type: "string",
200
- alias: "n"
201
- })
202
- .completion("name", () => this.getProjectNames())
203
- .action((options, volumes) => this.volumeMount(options, volumes));
204
- cli.command("volume:unmount [...volumes]")
205
- .option("name", {
206
- type: "string",
207
- alias: "n"
208
- })
209
- .completion("name", () => this.getProjectNames())
210
- .action((options, volumes) => this.volumeUnmount(options, volumes));
211
- cli.command("logs")
212
- .help({
213
- description: "Logs"
214
- })
215
- .option("name", {
216
- type: "boolean",
217
- alias: "n"
218
- })
219
- .option("global", {
220
- type: "boolean",
221
- alias: "g"
222
- })
223
- .option("follow", {
224
- type: "boolean",
225
- alias: "f"
226
- })
227
- .option("detach", {
228
- type: "boolean",
229
- alias: "d"
230
- })
231
- .completion("name", () => this.getProjectNames())
232
- .action((options) => this.logs(options));
233
- cli.command("exec [...command]")
234
- .option("name", {
235
- type: "string",
236
- alias: "n"
237
- })
238
- .completion("name", () => this.getProjectNames())
239
- .action((options, command) => this.exec(options, command));
51
+ let ProjectController = class ProjectController {
52
+ constructor(appConfigService, appEventsService, projectService, dockerService, logService) {
53
+ this.appConfigService = appConfigService;
54
+ this.appEventsService = appEventsService;
55
+ this.projectService = projectService;
56
+ this.dockerService = dockerService;
57
+ this.logService = logService;
240
58
  }
241
59
  async getProjectNames() {
242
- const projects = await makes_2.Project.search();
60
+ const projects = await this.projectService.search();
243
61
  return projects.map((project) => {
244
62
  return project.name;
245
63
  });
246
64
  }
247
- async getScripts() {
248
- try {
249
- const project = await this.projectService.get();
250
- return Object.keys(project.scripts || {});
251
- }
252
- catch (ignore) {
253
- return [];
254
- }
255
- }
256
- async init(options) {
257
- let project = await makes_2.Project.searchOne({
65
+ async init(name, type, preset) {
66
+ let project = await this.projectService.searchOne({
258
67
  path: this.appConfigService.getPWD()
259
68
  });
260
69
  if (!project) {
261
- project = new makes_2.Project({});
70
+ project = this.projectService.fromObject({
71
+ path: this.appConfigService.getPWD()
72
+ });
262
73
  }
263
- if (options.name) {
264
- project.name = options.name;
74
+ if (name) {
75
+ project.name = name;
265
76
  }
266
- if (!options.name || !project.name) {
77
+ if (!name || !project.name) {
267
78
  project.name = await (0, utils_1.promptText)({
268
79
  type: "string",
269
80
  required: true,
270
- message: "Project name",
271
- default: project.name
81
+ message: "Project name:",
82
+ default: project.name || Path.basename(project.path)
272
83
  });
273
84
  }
274
- if (options.type) {
275
- project.type = options.type;
85
+ if (type) {
86
+ project.type = type;
276
87
  }
277
88
  const mapTypes = this.appConfigService.getProjectTypes();
278
- if (!options.type || !project.type || !mapTypes[project.type]) {
89
+ if (!type || !project.type || !mapTypes[project.type]) {
279
90
  project.type = await (0, utils_1.promptSelect)({
280
- message: "Project type",
91
+ message: "Project type:",
281
92
  options: mapTypes,
282
93
  default: project.type
283
94
  });
284
95
  }
285
96
  switch (project.type) {
286
- case makes_2.PROJECT_TYPE_DOCKERFILE: {
97
+ case core_1.PROJECT_TYPE_DOCKERFILE: {
287
98
  const files = await makes_1.FS.readdirFiles(this.appConfigService.getPWD());
288
99
  const dockerfiles = files.filter((fileName) => {
289
100
  if (new RegExp("^(.*)\\.dockerfile$").test(fileName)) {
@@ -302,7 +113,7 @@ class ProjectController extends makes_1.Controller {
302
113
  });
303
114
  break;
304
115
  }
305
- case makes_2.PROJECT_TYPE_IMAGE: {
116
+ case core_1.PROJECT_TYPE_IMAGE: {
306
117
  project.imageName = await (0, utils_1.promptText)({
307
118
  message: "Image Name",
308
119
  default: project.imageName
@@ -316,8 +127,7 @@ class ProjectController extends makes_1.Controller {
316
127
  project.path = this.appConfigService.getPWD();
317
128
  await project.save();
318
129
  }
319
- async projectList(options) {
320
- const { all } = options;
130
+ async projectList(all) {
321
131
  const table = new cli_table3_1.default({
322
132
  head: ["Name", "Type", "Status"],
323
133
  colAligns: ["left", "center", "center"]
@@ -336,35 +146,37 @@ class ProjectController extends makes_1.Controller {
336
146
  }
337
147
  return table.toString() + "\n";
338
148
  }
339
- async start(options) {
340
- const { name, rebuild, detach } = options;
149
+ async start(name, detach, rebuild, restart) {
341
150
  if (name) {
342
151
  await this.projectService.cdProject(name);
343
152
  }
344
153
  const project = await this.projectService.get();
345
154
  if (rebuild) {
155
+ await this.projectService.stop();
346
156
  await this.appEventsService.emit("project:rebuild", project);
347
157
  }
348
- await this.projectService.start();
158
+ await this.projectService.start(restart);
349
159
  if (!detach) {
350
160
  const project = await this.projectService.get();
351
- const containerName = `${project.name}.workspace`;
352
- const container = await makes_1.Docker.getContainer(containerName);
161
+ const containerName = project.containerName;
162
+ const container = await this.dockerService.getContainer(containerName);
353
163
  await container.resize({
354
164
  w: process.stdout.columns,
355
165
  h: process.stdout.rows
356
166
  });
357
- await makes_1.Docker.attach(containerName);
167
+ await this.dockerService.attach(containerName);
358
168
  }
359
169
  }
360
- async stop(options) {
361
- const { name } = options;
170
+ async stop(name) {
362
171
  if (name) {
363
172
  await this.projectService.cdProject(name);
364
173
  }
365
174
  await this.projectService.stop();
366
175
  }
367
- async run(script) {
176
+ async run(name, script) {
177
+ if (name) {
178
+ await this.projectService.cdProject(name);
179
+ }
368
180
  const project = await this.projectService.get();
369
181
  if (!project.scripts || !project.scripts[script]) {
370
182
  throw new Error(`Script ${script} not found`);
@@ -387,26 +199,24 @@ class ProjectController extends makes_1.Controller {
387
199
  });
388
200
  await this.dockerService.attachStream(stream);
389
201
  }
390
- async attach(options) {
391
- const { name } = options;
202
+ async attach(name) {
392
203
  if (name) {
393
204
  await this.projectService.cdProject(name);
394
205
  }
395
206
  const containerName = `${name}.workspace`;
396
- await makes_1.Docker.attach(containerName);
207
+ await this.dockerService.attach(containerName);
397
208
  }
398
- async configList(options) {
399
- const { name, global } = options;
209
+ async configList(name, global) {
400
210
  if (name) {
401
211
  await this.projectService.cdProject(name);
402
212
  }
403
- let env = {};
213
+ let env;
404
214
  if (!global) {
405
215
  const project = await this.projectService.get();
406
216
  env = project.env || {};
407
217
  }
408
218
  else {
409
- const config = await (0, utils_2.getConfig)();
219
+ const config = await this.appConfigService.getConfig();
410
220
  env = config.env || {};
411
221
  }
412
222
  const table = new cli_table3_1.default({
@@ -417,55 +227,43 @@ class ProjectController extends makes_1.Controller {
417
227
  }
418
228
  return table.toString() + "\n";
419
229
  }
420
- async configGet(options, key) {
421
- const { name, global } = options;
230
+ async configGet(name, global, keys) {
422
231
  if (name) {
423
232
  await this.projectService.cdProject(name);
424
233
  }
425
- let value = "";
426
- if (global) {
427
- const config = await (0, utils_2.getConfig)();
428
- value = config[key] || "";
429
- }
430
- else {
431
- const project = await this.projectService.get();
432
- value = project.getEnv(key);
433
- }
234
+ let config = global
235
+ ? await this.appConfigService.getConfig()
236
+ : await this.projectService.get();
434
237
  const table = new cli_table3_1.default({
435
238
  head: ["KEY", "VALUE"]
436
239
  });
437
- table.push([key, value]);
240
+ for (const key of keys) {
241
+ const value = config.getEnv(key, "");
242
+ if (!value) {
243
+ continue;
244
+ }
245
+ table.push([key, value]);
246
+ }
438
247
  return table.toString() + "\n";
439
248
  }
440
- async configSet(options, configs) {
441
- const { name, global } = options;
442
- const env = configs.reduce((env, config) => {
443
- const [key, value] = config.split("=");
444
- env[key.trim()] = value.trim();
445
- return env;
446
- }, {});
447
- if (global) {
448
- const config = await (0, utils_2.getConfig)();
449
- await (0, utils_2.setConfig)({
450
- ...config,
451
- env: {
452
- ...config.env || {},
453
- ...env
454
- }
455
- });
456
- return;
457
- }
458
- if (name) {
249
+ async configSet(name, global, variables) {
250
+ if (!global && name) {
459
251
  await this.projectService.cdProject(name);
460
252
  }
461
- const project = await this.projectService.get();
462
- for (const i in env) {
463
- project.setEnv(i, env[i]);
253
+ const config = global
254
+ ? await this.appConfigService.getConfig()
255
+ : await this.projectService.get();
256
+ for (const variable of variables) {
257
+ const [key, value] = variable.split("=");
258
+ if (!value) {
259
+ console.info(chalk_1.default.yellow(`No value for "${key}"`));
260
+ continue;
261
+ }
262
+ config.setEnv(key.trim(), value.trim());
464
263
  }
465
- await project.save();
264
+ await config.save();
466
265
  }
467
- async configUnset(options, configs) {
468
- const { name, global } = options;
266
+ async configUnset(name, global, configs) {
469
267
  const env = configs.reduce((env, config) => {
470
268
  const [key] = config.split("=");
471
269
  env[key.trim()] = null;
@@ -483,8 +281,7 @@ class ProjectController extends makes_1.Controller {
483
281
  }
484
282
  await project.save();
485
283
  }
486
- async buildArgsList(options) {
487
- const { name } = options;
284
+ async buildArgsList(name) {
488
285
  if (name) {
489
286
  await this.projectService.cdProject(name);
490
287
  }
@@ -498,8 +295,7 @@ class ProjectController extends makes_1.Controller {
498
295
  }
499
296
  return table.toString() + "\n";
500
297
  }
501
- async buildArgsGet(options, args) {
502
- const { name } = options;
298
+ async buildArgsGet(name, args) {
503
299
  if (name) {
504
300
  await this.projectService.cdProject(name);
505
301
  }
@@ -507,7 +303,7 @@ class ProjectController extends makes_1.Controller {
507
303
  const table = new cli_table3_1.default({
508
304
  head: ["KEY", "VALUE"]
509
305
  });
510
- makes_1.Logger.info("...");
306
+ this.logService.info("...");
511
307
  for (const key of args) {
512
308
  if (project.buildArgs && typeof project.buildArgs[key] !== "undefined") {
513
309
  const value = project.buildArgs[key] || "";
@@ -516,8 +312,7 @@ class ProjectController extends makes_1.Controller {
516
312
  }
517
313
  return table.toString() + "\n";
518
314
  }
519
- async buildArgsSet(options, args) {
520
- const { name } = options;
315
+ async buildArgsSet(name, args) {
521
316
  if (name) {
522
317
  await this.projectService.cdProject(name);
523
318
  }
@@ -535,8 +330,7 @@ class ProjectController extends makes_1.Controller {
535
330
  }
536
331
  await project.save();
537
332
  }
538
- async buildArgsUnset(options, args) {
539
- const { name } = options;
333
+ async buildArgsUnset(name, args) {
540
334
  if (name) {
541
335
  await this.projectService.cdProject(name);
542
336
  }
@@ -556,8 +350,7 @@ class ProjectController extends makes_1.Controller {
556
350
  }
557
351
  await project.save();
558
352
  }
559
- async volumeList(options) {
560
- const { name } = options;
353
+ async volumeList(name) {
561
354
  if (name) {
562
355
  await this.projectService.cdProject(name);
563
356
  }
@@ -571,8 +364,7 @@ class ProjectController extends makes_1.Controller {
571
364
  }
572
365
  return table.toString() + "\n";
573
366
  }
574
- async volumeMount(options, volumes) {
575
- const { name } = options;
367
+ async volumeMount(name, volumes) {
576
368
  if (name) {
577
369
  await this.projectService.cdProject(name);
578
370
  }
@@ -582,8 +374,7 @@ class ProjectController extends makes_1.Controller {
582
374
  await project.save();
583
375
  }
584
376
  }
585
- async volumeUnmount(options, volumes) {
586
- const { name } = options;
377
+ async volumeUnmount(name, volumes) {
587
378
  if (name) {
588
379
  await this.projectService.cdProject(name);
589
380
  }
@@ -593,8 +384,7 @@ class ProjectController extends makes_1.Controller {
593
384
  await project.save();
594
385
  }
595
386
  }
596
- async logs(options) {
597
- const { name, global, detach, follow } = options;
387
+ async logs(name, global, detach, follow) {
598
388
  if (global) {
599
389
  const logFilepath = Path.join(env_1.DATA_DIR, "ws.log");
600
390
  const prepareLog = (str) => {
@@ -627,7 +417,7 @@ class ProjectController extends makes_1.Controller {
627
417
  try {
628
418
  const stats = await makes_1.FS.stat(logFilepath);
629
419
  if (BigInt(stats.size) < position) {
630
- console.log("file truncated");
420
+ console.info("file truncated");
631
421
  position = 0n;
632
422
  }
633
423
  const buffer = await makes_1.FS.readBytes(logFilepath, position);
@@ -645,7 +435,7 @@ class ProjectController extends makes_1.Controller {
645
435
  await this.projectService.cdProject(name);
646
436
  }
647
437
  const project = await this.projectService.get();
648
- const container = await makes_1.Docker.getContainer(`${project.name}.workspace`);
438
+ const container = await this.dockerService.getContainer(`${project.name}.workspace`);
649
439
  if (!detach) {
650
440
  const stream = await container.logs({
651
441
  stdout: true,
@@ -653,7 +443,7 @@ class ProjectController extends makes_1.Controller {
653
443
  follow: true
654
444
  });
655
445
  stream.on("data", (data) => {
656
- process.stdout.write((0, utils_2.demuxOutput)(data));
446
+ process.stdout.write((0, utils_1.demuxOutput)(data));
657
447
  });
658
448
  }
659
449
  else {
@@ -662,17 +452,278 @@ class ProjectController extends makes_1.Controller {
662
452
  stderr: true,
663
453
  follow: false
664
454
  });
665
- process.stdout.write((0, utils_2.demuxOutput)(buffer));
455
+ process.stdout.write((0, utils_1.demuxOutput)(buffer));
666
456
  }
667
457
  }
668
- async exec(options, command) {
669
- const { name } = options;
458
+ async exec(name, command) {
670
459
  if (name) {
671
460
  await this.projectService.cdProject(name);
672
461
  }
673
462
  const project = await this.projectService.get();
674
463
  const containerName = `${project.name}.workspace`;
675
- await makes_1.Docker.exec(containerName, command);
464
+ await this.dockerService.exec(containerName, command);
676
465
  }
677
- }
466
+ };
678
467
  exports.ProjectController = ProjectController;
468
+ __decorate([
469
+ (0, core_1.Completion)("name"),
470
+ __metadata("design:type", Function),
471
+ __metadata("design:paramtypes", []),
472
+ __metadata("design:returntype", Promise)
473
+ ], ProjectController.prototype, "getProjectNames", null);
474
+ __decorate([
475
+ (0, core_1.Command)("init"),
476
+ __param(0, (0, core_1.Option)("name", {
477
+ type: "string",
478
+ alias: "n",
479
+ description: "Project name"
480
+ })),
481
+ __param(1, (0, core_1.Option)("type", {
482
+ type: "string",
483
+ alias: "t",
484
+ description: "Project type"
485
+ })),
486
+ __param(2, (0, core_1.Option)("preset", {
487
+ type: "string",
488
+ alias: "p",
489
+ description: "Preset"
490
+ })),
491
+ __metadata("design:type", Function),
492
+ __metadata("design:paramtypes", [String, String, String]),
493
+ __metadata("design:returntype", Promise)
494
+ ], ProjectController.prototype, "init", null);
495
+ __decorate([
496
+ (0, core_1.Command)("ps"),
497
+ __param(0, (0, core_1.Option)("all", {
498
+ type: "boolean",
499
+ alias: "a",
500
+ description: "All projects"
501
+ })),
502
+ __metadata("design:type", Function),
503
+ __metadata("design:paramtypes", [Boolean]),
504
+ __metadata("design:returntype", Promise)
505
+ ], ProjectController.prototype, "projectList", null);
506
+ __decorate([
507
+ (0, core_1.Command)("start"),
508
+ __param(0, (0, core_1.Option)("name", {
509
+ type: "string",
510
+ alias: "n",
511
+ description: "Project name"
512
+ })),
513
+ __param(1, (0, core_1.Option)("detach", {
514
+ type: "boolean",
515
+ alias: "d"
516
+ })),
517
+ __param(2, (0, core_1.Option)("build", {
518
+ type: "boolean",
519
+ alias: "b"
520
+ })),
521
+ __param(3, (0, core_1.Option)("restart", {
522
+ type: "boolean",
523
+ alias: "r"
524
+ })),
525
+ __metadata("design:type", Function),
526
+ __metadata("design:paramtypes", [String, Boolean, Boolean, Boolean]),
527
+ __metadata("design:returntype", Promise)
528
+ ], ProjectController.prototype, "start", null);
529
+ __decorate([
530
+ (0, core_1.Command)("stop"),
531
+ __param(0, (0, core_1.Option)("name", {
532
+ type: "string",
533
+ alias: "n",
534
+ description: "Project name"
535
+ })),
536
+ __metadata("design:type", Function),
537
+ __metadata("design:paramtypes", [String]),
538
+ __metadata("design:returntype", Promise)
539
+ ], ProjectController.prototype, "stop", null);
540
+ __decorate([
541
+ (0, core_1.Command)("run <script>"),
542
+ __param(0, (0, core_1.Option)("name", {
543
+ type: "string",
544
+ alias: "n",
545
+ description: "Project name"
546
+ })),
547
+ __metadata("design:type", Function),
548
+ __metadata("design:paramtypes", [String, String]),
549
+ __metadata("design:returntype", Promise)
550
+ ], ProjectController.prototype, "run", null);
551
+ __decorate([
552
+ (0, core_1.Command)("attach"),
553
+ __param(0, (0, core_1.Option)("name", {
554
+ type: "string",
555
+ alias: "n"
556
+ })),
557
+ __metadata("design:type", Function),
558
+ __metadata("design:paramtypes", [String]),
559
+ __metadata("design:returntype", Promise)
560
+ ], ProjectController.prototype, "attach", null);
561
+ __decorate([
562
+ (0, core_1.Command)("config"),
563
+ __param(0, (0, core_1.Option)("name", {
564
+ type: "string",
565
+ alias: "n",
566
+ description: "Project name"
567
+ })),
568
+ __param(1, (0, core_1.Option)("global", {
569
+ type: "boolean",
570
+ alias: "g"
571
+ })),
572
+ __metadata("design:type", Function),
573
+ __metadata("design:paramtypes", [String, Boolean]),
574
+ __metadata("design:returntype", Promise)
575
+ ], ProjectController.prototype, "configList", null);
576
+ __decorate([
577
+ (0, core_1.Command)("config:get [...key]"),
578
+ __param(0, (0, core_1.Option)("name", {
579
+ type: "string",
580
+ alias: "n"
581
+ })),
582
+ __param(1, (0, core_1.Option)("global", {
583
+ type: "boolean",
584
+ alias: "g"
585
+ })),
586
+ __metadata("design:type", Function),
587
+ __metadata("design:paramtypes", [String, Boolean, Array]),
588
+ __metadata("design:returntype", Promise)
589
+ ], ProjectController.prototype, "configGet", null);
590
+ __decorate([
591
+ (0, core_1.Command)("config:set [...configs]"),
592
+ __param(0, (0, core_1.Option)("name", {
593
+ type: "string",
594
+ alias: "n"
595
+ })),
596
+ __param(1, (0, core_1.Option)("global", {
597
+ type: "boolean",
598
+ alias: "g"
599
+ })),
600
+ __metadata("design:type", Function),
601
+ __metadata("design:paramtypes", [String, Boolean, Array]),
602
+ __metadata("design:returntype", Promise)
603
+ ], ProjectController.prototype, "configSet", null);
604
+ __decorate([
605
+ (0, core_1.Command)("config:unset [...configs]"),
606
+ __param(0, (0, core_1.Option)("name", {
607
+ type: "string",
608
+ alias: "n"
609
+ })),
610
+ __param(1, (0, core_1.Option)("global", {
611
+ type: "boolean",
612
+ alias: "g"
613
+ })),
614
+ __metadata("design:type", Function),
615
+ __metadata("design:paramtypes", [String, Boolean, Array]),
616
+ __metadata("design:returntype", Promise)
617
+ ], ProjectController.prototype, "configUnset", null);
618
+ __decorate([
619
+ (0, core_1.Command)("build-args"),
620
+ __param(0, (0, core_1.Option)("name", {
621
+ type: "string",
622
+ alias: "n"
623
+ })),
624
+ __metadata("design:type", Function),
625
+ __metadata("design:paramtypes", [String]),
626
+ __metadata("design:returntype", Promise)
627
+ ], ProjectController.prototype, "buildArgsList", null);
628
+ __decorate([
629
+ (0, core_1.Command)("build-args:get [...buildArgs]"),
630
+ __param(0, (0, core_1.Option)("name", {
631
+ type: "string",
632
+ alias: "n",
633
+ })),
634
+ __metadata("design:type", Function),
635
+ __metadata("design:paramtypes", [String, Array]),
636
+ __metadata("design:returntype", Promise)
637
+ ], ProjectController.prototype, "buildArgsGet", null);
638
+ __decorate([
639
+ (0, core_1.Command)("build-args:set [...buildArgs]"),
640
+ __param(0, (0, core_1.Option)("name", {
641
+ type: "string",
642
+ alias: "n"
643
+ })),
644
+ __metadata("design:type", Function),
645
+ __metadata("design:paramtypes", [String, Array]),
646
+ __metadata("design:returntype", Promise)
647
+ ], ProjectController.prototype, "buildArgsSet", null);
648
+ __decorate([
649
+ (0, core_1.Command)("build-args:unset [...buildArgs]"),
650
+ __param(0, (0, core_1.Option)("name", {
651
+ type: "string",
652
+ alias: "n"
653
+ })),
654
+ __metadata("design:type", Function),
655
+ __metadata("design:paramtypes", [String, Array]),
656
+ __metadata("design:returntype", Promise)
657
+ ], ProjectController.prototype, "buildArgsUnset", null);
658
+ __decorate([
659
+ (0, core_1.Command)("volumes"),
660
+ __param(0, (0, core_1.Option)("name", {
661
+ type: "string",
662
+ alias: "n"
663
+ })),
664
+ __metadata("design:type", Function),
665
+ __metadata("design:paramtypes", [String]),
666
+ __metadata("design:returntype", Promise)
667
+ ], ProjectController.prototype, "volumeList", null);
668
+ __decorate([
669
+ (0, core_1.Command)("volume:mount [...volumes]"),
670
+ __param(0, (0, core_1.Option)("name", {
671
+ type: "string",
672
+ alias: "n"
673
+ })),
674
+ __metadata("design:type", Function),
675
+ __metadata("design:paramtypes", [String, Array]),
676
+ __metadata("design:returntype", Promise)
677
+ ], ProjectController.prototype, "volumeMount", null);
678
+ __decorate([
679
+ (0, core_1.Command)("volume:unmount [...volumes]"),
680
+ __param(0, (0, core_1.Option)("name", {
681
+ type: "string",
682
+ alias: "n"
683
+ })),
684
+ __metadata("design:type", Function),
685
+ __metadata("design:paramtypes", [String, Array]),
686
+ __metadata("design:returntype", Promise)
687
+ ], ProjectController.prototype, "volumeUnmount", null);
688
+ __decorate([
689
+ (0, core_1.Command)("logs"),
690
+ __param(0, (0, core_1.Option)("name", {
691
+ type: "string",
692
+ alias: "n",
693
+ description: "Project name"
694
+ })),
695
+ __param(1, (0, core_1.Option)("global", {
696
+ type: "boolean",
697
+ alias: "g"
698
+ })),
699
+ __param(2, (0, core_1.Option)("detach", {
700
+ type: "boolean",
701
+ alias: "d"
702
+ })),
703
+ __param(3, (0, core_1.Option)("follow", {
704
+ type: "boolean",
705
+ alias: "f"
706
+ })),
707
+ __metadata("design:type", Function),
708
+ __metadata("design:paramtypes", [String, Boolean, Boolean, Boolean]),
709
+ __metadata("design:returntype", Promise)
710
+ ], ProjectController.prototype, "logs", null);
711
+ __decorate([
712
+ (0, core_1.Command)("exec [...command]"),
713
+ __param(0, (0, core_1.Option)("name", {
714
+ type: "string",
715
+ alias: "n",
716
+ description: "Project name"
717
+ })),
718
+ __metadata("design:type", Function),
719
+ __metadata("design:paramtypes", [String, Array]),
720
+ __metadata("design:returntype", Promise)
721
+ ], ProjectController.prototype, "exec", null);
722
+ exports.ProjectController = ProjectController = __decorate([
723
+ (0, core_1.Controller)(),
724
+ __metadata("design:paramtypes", [services_1.AppConfigService,
725
+ services_1.AppEventsService,
726
+ services_1.ProjectService,
727
+ services_1.DockerService,
728
+ services_1.LogService])
729
+ ], ProjectController);