@wocker/ws 1.0.7 → 1.0.8

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 (96) hide show
  1. package/bin/ws.js +1 -1
  2. package/lib/App.d.ts +1 -6
  3. package/lib/App.js +1 -27
  4. package/lib/AppModule.d.ts +6 -0
  5. package/lib/AppModule.js +97 -0
  6. package/lib/controllers/CompletionController.d.ts +6 -0
  7. package/lib/controllers/CompletionController.js +32 -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 +9 -13
  11. package/lib/controllers/PluginController.js +56 -18
  12. package/lib/controllers/PresetController.d.ts +9 -15
  13. package/lib/controllers/PresetController.js +41 -22
  14. package/lib/controllers/ProjectController.d.ts +27 -69
  15. package/lib/controllers/ProjectController.js +336 -261
  16. package/lib/controllers/ProxyController.d.ts +15 -25
  17. package/lib/controllers/ProxyController.js +142 -96
  18. package/lib/controllers/index.d.ts +1 -0
  19. package/lib/controllers/index.js +1 -0
  20. package/lib/index.d.ts +0 -1
  21. package/lib/index.js +0 -11
  22. package/lib/main.d.ts +3 -0
  23. package/lib/main.js +11 -0
  24. package/lib/makes/Logger.d.ts +2 -2
  25. package/lib/makes/Logger.js +19 -8
  26. package/lib/makes/Preset.d.ts +3 -4
  27. package/lib/makes/Preset.js +19 -8
  28. package/lib/makes/index.d.ts +0 -6
  29. package/lib/makes/index.js +0 -6
  30. package/lib/plugins/ElasticSearchPlugin.d.ts +5 -6
  31. package/lib/plugins/ElasticSearchPlugin.js +19 -8
  32. package/lib/plugins/LocaltunnelPlugin.d.ts +8 -8
  33. package/lib/plugins/LocaltunnelPlugin.js +25 -10
  34. package/lib/plugins/MaildevPlugin.d.ts +5 -6
  35. package/lib/plugins/MaildevPlugin.js +21 -8
  36. package/lib/plugins/MongodbPlugin.d.ts +5 -5
  37. package/lib/plugins/MongodbPlugin.js +26 -11
  38. package/lib/plugins/NgrokPlugin.d.ts +7 -6
  39. package/lib/plugins/NgrokPlugin.js +32 -17
  40. package/lib/plugins/PageKitePlugin.d.ts +10 -8
  41. package/lib/plugins/PageKitePlugin.js +36 -20
  42. package/lib/plugins/ProxmoxPlugin.d.ts +8 -5
  43. package/lib/plugins/ProxmoxPlugin.js +25 -9
  44. package/lib/plugins/RedisPlugin.d.ts +4 -6
  45. package/lib/plugins/RedisPlugin.js +19 -8
  46. package/lib/plugins/index.d.ts +0 -2
  47. package/lib/plugins/index.js +0 -2
  48. package/lib/services/AppConfigService.d.ts +3 -3
  49. package/lib/services/AppConfigService.js +16 -2
  50. package/lib/services/AppEventsService.d.ts +1 -2
  51. package/lib/services/AppEventsService.js +11 -2
  52. package/lib/services/DockerService.d.ts +9 -39
  53. package/lib/services/DockerService.js +122 -4
  54. package/lib/services/LogService.d.ts +3 -5
  55. package/lib/services/LogService.js +19 -4
  56. package/lib/services/PluginService.d.ts +4 -9
  57. package/lib/services/PluginService.js +18 -8
  58. package/lib/services/PresetService.d.ts +5 -5
  59. package/lib/services/PresetService.js +11 -2
  60. package/lib/services/ProjectService.d.ts +9 -6
  61. package/lib/services/ProjectService.js +62 -31
  62. package/lib/utils/get-config.d.ts +2 -2
  63. package/lib/utils/index.d.ts +0 -1
  64. package/lib/utils/index.js +0 -1
  65. package/lib/utils/set-config.d.ts +2 -2
  66. package/package.json +4 -4
  67. package/presets/node/config.json +1 -1
  68. package/presets/php-fpm/Dockerfile +1 -1
  69. package/lib/decorators/Inject.d.ts +0 -1
  70. package/lib/decorators/Inject.js +0 -8
  71. package/lib/decorators/Injectable.d.ts +0 -4
  72. package/lib/decorators/Injectable.js +0 -17
  73. package/lib/decorators/index.d.ts +0 -1
  74. package/lib/decorators/index.js +0 -17
  75. package/lib/makes/Controller.d.ts +0 -5
  76. package/lib/makes/Controller.js +0 -8
  77. package/lib/makes/DI.d.ts +0 -7
  78. package/lib/makes/DI.js +0 -27
  79. package/lib/makes/Docker.d.ts +0 -58
  80. package/lib/makes/Docker.js +0 -320
  81. package/lib/makes/Plugin.d.ts +0 -13
  82. package/lib/makes/Plugin.js +0 -61
  83. package/lib/makes/Project.d.ts +0 -45
  84. package/lib/makes/Project.js +0 -127
  85. package/lib/makes/Repository.d.ts +0 -11
  86. package/lib/makes/Repository.js +0 -22
  87. package/lib/plugins/PostgresPlugin.d.ts +0 -16
  88. package/lib/plugins/PostgresPlugin.js +0 -121
  89. package/lib/types/Config.d.ts +0 -12
  90. package/lib/types/Config.js +0 -2
  91. package/lib/types/EnvConfig.d.ts +0 -3
  92. package/lib/types/EnvConfig.js +0 -2
  93. package/lib/types/index.d.ts +0 -2
  94. package/lib/types/index.js +0 -18
  95. package/lib/utils/demuxOutput.d.ts +0 -2
  96. package/lib/utils/demuxOutput.js +0 -19
@@ -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,217 +47,24 @@ 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
51
  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));
52
+ let ProjectController = class ProjectController {
53
+ constructor(appConfigService, appEventsService, projectService, dockerService, logService) {
54
+ this.appConfigService = appConfigService;
55
+ this.appEventsService = appEventsService;
56
+ this.projectService = projectService;
57
+ this.dockerService = dockerService;
58
+ this.logService = logService;
240
59
  }
241
60
  async getProjectNames() {
242
- const projects = await makes_2.Project.search();
61
+ const projects = await this.projectService.search();
243
62
  return projects.map((project) => {
244
63
  return project.name;
245
64
  });
246
65
  }
247
66
  async getScripts() {
67
+ this.logService.warn(">_<");
248
68
  try {
249
69
  const project = await this.projectService.get();
250
70
  return Object.keys(project.scripts || {});
@@ -253,17 +73,17 @@ class ProjectController extends makes_1.Controller {
253
73
  return [];
254
74
  }
255
75
  }
256
- async init(options) {
257
- let project = await makes_2.Project.searchOne({
76
+ async init(name, type, preset) {
77
+ let project = await this.projectService.searchOne({
258
78
  path: this.appConfigService.getPWD()
259
79
  });
260
80
  if (!project) {
261
- project = new makes_2.Project({});
81
+ project = this.projectService.fromObject({});
262
82
  }
263
- if (options.name) {
264
- project.name = options.name;
83
+ if (name) {
84
+ project.name = name;
265
85
  }
266
- if (!options.name || !project.name) {
86
+ if (!name || !project.name) {
267
87
  project.name = await (0, utils_1.promptText)({
268
88
  type: "string",
269
89
  required: true,
@@ -271,11 +91,11 @@ class ProjectController extends makes_1.Controller {
271
91
  default: project.name
272
92
  });
273
93
  }
274
- if (options.type) {
275
- project.type = options.type;
94
+ if (type) {
95
+ project.type = type;
276
96
  }
277
97
  const mapTypes = this.appConfigService.getProjectTypes();
278
- if (!options.type || !project.type || !mapTypes[project.type]) {
98
+ if (!type || !project.type || !mapTypes[project.type]) {
279
99
  project.type = await (0, utils_1.promptSelect)({
280
100
  message: "Project type",
281
101
  options: mapTypes,
@@ -283,7 +103,7 @@ class ProjectController extends makes_1.Controller {
283
103
  });
284
104
  }
285
105
  switch (project.type) {
286
- case makes_2.PROJECT_TYPE_DOCKERFILE: {
106
+ case core_1.PROJECT_TYPE_DOCKERFILE: {
287
107
  const files = await makes_1.FS.readdirFiles(this.appConfigService.getPWD());
288
108
  const dockerfiles = files.filter((fileName) => {
289
109
  if (new RegExp("^(.*)\\.dockerfile$").test(fileName)) {
@@ -302,7 +122,7 @@ class ProjectController extends makes_1.Controller {
302
122
  });
303
123
  break;
304
124
  }
305
- case makes_2.PROJECT_TYPE_IMAGE: {
125
+ case core_1.PROJECT_TYPE_IMAGE: {
306
126
  project.imageName = await (0, utils_1.promptText)({
307
127
  message: "Image Name",
308
128
  default: project.imageName
@@ -314,10 +134,9 @@ class ProjectController extends makes_1.Controller {
314
134
  }
315
135
  await this.appEventsService.emit("project:init", project);
316
136
  project.path = this.appConfigService.getPWD();
317
- await project.save();
137
+ await this.projectService.save(project);
318
138
  }
319
- async projectList(options) {
320
- const { all } = options;
139
+ async projectList(all) {
321
140
  const table = new cli_table3_1.default({
322
141
  head: ["Name", "Type", "Status"],
323
142
  colAligns: ["left", "center", "center"]
@@ -336,35 +155,37 @@ class ProjectController extends makes_1.Controller {
336
155
  }
337
156
  return table.toString() + "\n";
338
157
  }
339
- async start(options) {
340
- const { name, rebuild, detach } = options;
158
+ async start(name, detach, rebuild, restart) {
341
159
  if (name) {
342
160
  await this.projectService.cdProject(name);
343
161
  }
344
162
  const project = await this.projectService.get();
345
163
  if (rebuild) {
164
+ await this.projectService.stop();
346
165
  await this.appEventsService.emit("project:rebuild", project);
347
166
  }
348
- await this.projectService.start();
167
+ await this.projectService.start(restart);
349
168
  if (!detach) {
350
169
  const project = await this.projectService.get();
351
- const containerName = `${project.name}.workspace`;
352
- const container = await makes_1.Docker.getContainer(containerName);
170
+ const containerName = project.containerName;
171
+ const container = await this.dockerService.getContainer(containerName);
353
172
  await container.resize({
354
173
  w: process.stdout.columns,
355
174
  h: process.stdout.rows
356
175
  });
357
- await makes_1.Docker.attach(containerName);
176
+ await this.dockerService.attach(containerName);
358
177
  }
359
178
  }
360
- async stop(options) {
361
- const { name } = options;
179
+ async stop(name) {
362
180
  if (name) {
363
181
  await this.projectService.cdProject(name);
364
182
  }
365
183
  await this.projectService.stop();
366
184
  }
367
- async run(script) {
185
+ async run(name, script) {
186
+ if (name) {
187
+ await this.projectService.cdProject(name);
188
+ }
368
189
  const project = await this.projectService.get();
369
190
  if (!project.scripts || !project.scripts[script]) {
370
191
  throw new Error(`Script ${script} not found`);
@@ -387,16 +208,14 @@ class ProjectController extends makes_1.Controller {
387
208
  });
388
209
  await this.dockerService.attachStream(stream);
389
210
  }
390
- async attach(options) {
391
- const { name } = options;
211
+ async attach(name) {
392
212
  if (name) {
393
213
  await this.projectService.cdProject(name);
394
214
  }
395
215
  const containerName = `${name}.workspace`;
396
- await makes_1.Docker.attach(containerName);
216
+ await this.dockerService.attach(containerName);
397
217
  }
398
- async configList(options) {
399
- const { name, global } = options;
218
+ async configList(name, global) {
400
219
  if (name) {
401
220
  await this.projectService.cdProject(name);
402
221
  }
@@ -417,8 +236,7 @@ class ProjectController extends makes_1.Controller {
417
236
  }
418
237
  return table.toString() + "\n";
419
238
  }
420
- async configGet(options, key) {
421
- const { name, global } = options;
239
+ async configGet(name, global, key) {
422
240
  if (name) {
423
241
  await this.projectService.cdProject(name);
424
242
  }
@@ -437,8 +255,7 @@ class ProjectController extends makes_1.Controller {
437
255
  table.push([key, value]);
438
256
  return table.toString() + "\n";
439
257
  }
440
- async configSet(options, configs) {
441
- const { name, global } = options;
258
+ async configSet(name, global, configs) {
442
259
  const env = configs.reduce((env, config) => {
443
260
  const [key, value] = config.split("=");
444
261
  env[key.trim()] = value.trim();
@@ -464,8 +281,7 @@ class ProjectController extends makes_1.Controller {
464
281
  }
465
282
  await project.save();
466
283
  }
467
- async configUnset(options, configs) {
468
- const { name, global } = options;
284
+ async configUnset(name, global, configs) {
469
285
  const env = configs.reduce((env, config) => {
470
286
  const [key] = config.split("=");
471
287
  env[key.trim()] = null;
@@ -483,8 +299,7 @@ class ProjectController extends makes_1.Controller {
483
299
  }
484
300
  await project.save();
485
301
  }
486
- async buildArgsList(options) {
487
- const { name } = options;
302
+ async buildArgsList(name) {
488
303
  if (name) {
489
304
  await this.projectService.cdProject(name);
490
305
  }
@@ -498,8 +313,7 @@ class ProjectController extends makes_1.Controller {
498
313
  }
499
314
  return table.toString() + "\n";
500
315
  }
501
- async buildArgsGet(options, args) {
502
- const { name } = options;
316
+ async buildArgsGet(name, args) {
503
317
  if (name) {
504
318
  await this.projectService.cdProject(name);
505
319
  }
@@ -507,7 +321,7 @@ class ProjectController extends makes_1.Controller {
507
321
  const table = new cli_table3_1.default({
508
322
  head: ["KEY", "VALUE"]
509
323
  });
510
- makes_1.Logger.info("...");
324
+ this.logService.info("...");
511
325
  for (const key of args) {
512
326
  if (project.buildArgs && typeof project.buildArgs[key] !== "undefined") {
513
327
  const value = project.buildArgs[key] || "";
@@ -516,8 +330,7 @@ class ProjectController extends makes_1.Controller {
516
330
  }
517
331
  return table.toString() + "\n";
518
332
  }
519
- async buildArgsSet(options, args) {
520
- const { name } = options;
333
+ async buildArgsSet(name, args) {
521
334
  if (name) {
522
335
  await this.projectService.cdProject(name);
523
336
  }
@@ -535,8 +348,7 @@ class ProjectController extends makes_1.Controller {
535
348
  }
536
349
  await project.save();
537
350
  }
538
- async buildArgsUnset(options, args) {
539
- const { name } = options;
351
+ async buildArgsUnset(name, args) {
540
352
  if (name) {
541
353
  await this.projectService.cdProject(name);
542
354
  }
@@ -556,8 +368,7 @@ class ProjectController extends makes_1.Controller {
556
368
  }
557
369
  await project.save();
558
370
  }
559
- async volumeList(options) {
560
- const { name } = options;
371
+ async volumeList(name) {
561
372
  if (name) {
562
373
  await this.projectService.cdProject(name);
563
374
  }
@@ -571,8 +382,7 @@ class ProjectController extends makes_1.Controller {
571
382
  }
572
383
  return table.toString() + "\n";
573
384
  }
574
- async volumeMount(options, volumes) {
575
- const { name } = options;
385
+ async volumeMount(name, volumes) {
576
386
  if (name) {
577
387
  await this.projectService.cdProject(name);
578
388
  }
@@ -582,8 +392,7 @@ class ProjectController extends makes_1.Controller {
582
392
  await project.save();
583
393
  }
584
394
  }
585
- async volumeUnmount(options, volumes) {
586
- const { name } = options;
395
+ async volumeUnmount(name, volumes) {
587
396
  if (name) {
588
397
  await this.projectService.cdProject(name);
589
398
  }
@@ -593,8 +402,7 @@ class ProjectController extends makes_1.Controller {
593
402
  await project.save();
594
403
  }
595
404
  }
596
- async logs(options) {
597
- const { name, global, detach, follow } = options;
405
+ async logs(name, global, detach, follow) {
598
406
  if (global) {
599
407
  const logFilepath = Path.join(env_1.DATA_DIR, "ws.log");
600
408
  const prepareLog = (str) => {
@@ -627,7 +435,7 @@ class ProjectController extends makes_1.Controller {
627
435
  try {
628
436
  const stats = await makes_1.FS.stat(logFilepath);
629
437
  if (BigInt(stats.size) < position) {
630
- console.log("file truncated");
438
+ console.info("file truncated");
631
439
  position = 0n;
632
440
  }
633
441
  const buffer = await makes_1.FS.readBytes(logFilepath, position);
@@ -645,7 +453,7 @@ class ProjectController extends makes_1.Controller {
645
453
  await this.projectService.cdProject(name);
646
454
  }
647
455
  const project = await this.projectService.get();
648
- const container = await makes_1.Docker.getContainer(`${project.name}.workspace`);
456
+ const container = await this.dockerService.getContainer(`${project.name}.workspace`);
649
457
  if (!detach) {
650
458
  const stream = await container.logs({
651
459
  stdout: true,
@@ -653,7 +461,7 @@ class ProjectController extends makes_1.Controller {
653
461
  follow: true
654
462
  });
655
463
  stream.on("data", (data) => {
656
- process.stdout.write((0, utils_2.demuxOutput)(data));
464
+ process.stdout.write((0, utils_1.demuxOutput)(data));
657
465
  });
658
466
  }
659
467
  else {
@@ -662,17 +470,284 @@ class ProjectController extends makes_1.Controller {
662
470
  stderr: true,
663
471
  follow: false
664
472
  });
665
- process.stdout.write((0, utils_2.demuxOutput)(buffer));
473
+ process.stdout.write((0, utils_1.demuxOutput)(buffer));
666
474
  }
667
475
  }
668
- async exec(options, command) {
669
- const { name } = options;
476
+ async exec(name, command) {
670
477
  if (name) {
671
478
  await this.projectService.cdProject(name);
672
479
  }
673
480
  const project = await this.projectService.get();
674
481
  const containerName = `${project.name}.workspace`;
675
- await makes_1.Docker.exec(containerName, command);
482
+ await this.dockerService.exec(containerName, command);
676
483
  }
677
- }
484
+ };
678
485
  exports.ProjectController = ProjectController;
486
+ __decorate([
487
+ (0, core_1.Completion)("name"),
488
+ __metadata("design:type", Function),
489
+ __metadata("design:paramtypes", []),
490
+ __metadata("design:returntype", Promise)
491
+ ], ProjectController.prototype, "getProjectNames", null);
492
+ __decorate([
493
+ (0, core_1.Completion)("script"),
494
+ __metadata("design:type", Function),
495
+ __metadata("design:paramtypes", []),
496
+ __metadata("design:returntype", Promise)
497
+ ], ProjectController.prototype, "getScripts", null);
498
+ __decorate([
499
+ (0, core_1.Command)("init"),
500
+ __param(0, (0, core_1.Option)("name", {
501
+ type: "string",
502
+ alias: "n",
503
+ description: "Project name"
504
+ })),
505
+ __param(1, (0, core_1.Option)("type", {
506
+ type: "string",
507
+ alias: "t",
508
+ description: "Project type"
509
+ })),
510
+ __param(2, (0, core_1.Option)("preset", {
511
+ type: "string",
512
+ alias: "p",
513
+ description: "Preset"
514
+ })),
515
+ __metadata("design:type", Function),
516
+ __metadata("design:paramtypes", [String, String, String]),
517
+ __metadata("design:returntype", Promise)
518
+ ], ProjectController.prototype, "init", null);
519
+ __decorate([
520
+ (0, core_1.Command)("ps"),
521
+ __param(0, (0, core_1.Option)("all", {
522
+ type: "boolean",
523
+ alias: "a",
524
+ description: "All projects"
525
+ })),
526
+ __metadata("design:type", Function),
527
+ __metadata("design:paramtypes", [Boolean]),
528
+ __metadata("design:returntype", Promise)
529
+ ], ProjectController.prototype, "projectList", null);
530
+ __decorate([
531
+ (0, core_1.Command)("start"),
532
+ __param(0, (0, core_1.Option)("name", {
533
+ type: "string",
534
+ alias: "n",
535
+ description: "Project name"
536
+ })),
537
+ __param(1, (0, core_1.Option)("detach", {
538
+ type: "boolean",
539
+ alias: "d"
540
+ })),
541
+ __param(2, (0, core_1.Option)("build", {
542
+ type: "boolean",
543
+ alias: "b"
544
+ })),
545
+ __param(3, (0, core_1.Option)("restart", {
546
+ type: "boolean",
547
+ alias: "r"
548
+ })),
549
+ __metadata("design:type", Function),
550
+ __metadata("design:paramtypes", [String, Boolean, Boolean, Boolean]),
551
+ __metadata("design:returntype", Promise)
552
+ ], ProjectController.prototype, "start", null);
553
+ __decorate([
554
+ (0, core_1.Command)("stop"),
555
+ __param(0, (0, core_1.Option)("name", {
556
+ type: "string",
557
+ alias: "n",
558
+ description: "Project name"
559
+ })),
560
+ __metadata("design:type", Function),
561
+ __metadata("design:paramtypes", [String]),
562
+ __metadata("design:returntype", Promise)
563
+ ], ProjectController.prototype, "stop", null);
564
+ __decorate([
565
+ (0, core_1.Command)("run <script>"),
566
+ __param(0, (0, core_1.Option)("name", {
567
+ type: "string",
568
+ alias: "n",
569
+ description: "Project name"
570
+ })),
571
+ __metadata("design:type", Function),
572
+ __metadata("design:paramtypes", [String, String]),
573
+ __metadata("design:returntype", Promise)
574
+ ], ProjectController.prototype, "run", null);
575
+ __decorate([
576
+ (0, core_1.Command)("attach"),
577
+ __param(0, (0, core_1.Option)("name", {
578
+ type: "string",
579
+ alias: "n"
580
+ })),
581
+ __metadata("design:type", Function),
582
+ __metadata("design:paramtypes", [String]),
583
+ __metadata("design:returntype", Promise)
584
+ ], ProjectController.prototype, "attach", null);
585
+ __decorate([
586
+ (0, core_1.Command)("config"),
587
+ __param(0, (0, core_1.Option)("name", {
588
+ type: "string",
589
+ alias: "n",
590
+ description: "Project name"
591
+ })),
592
+ __param(1, (0, core_1.Option)("global", {
593
+ type: "boolean",
594
+ alias: "g"
595
+ })),
596
+ __metadata("design:type", Function),
597
+ __metadata("design:paramtypes", [String, Boolean]),
598
+ __metadata("design:returntype", Promise)
599
+ ], ProjectController.prototype, "configList", null);
600
+ __decorate([
601
+ (0, core_1.Command)("config:get <key>"),
602
+ __param(0, (0, core_1.Option)("name", {
603
+ type: "string",
604
+ alias: "n"
605
+ })),
606
+ __param(1, (0, core_1.Option)("global", {
607
+ type: "boolean",
608
+ alias: "b"
609
+ })),
610
+ __metadata("design:type", Function),
611
+ __metadata("design:paramtypes", [String, Boolean, String]),
612
+ __metadata("design:returntype", Promise)
613
+ ], ProjectController.prototype, "configGet", null);
614
+ __decorate([
615
+ (0, core_1.Command)("config:set [...configs]"),
616
+ __param(0, (0, core_1.Option)("name", {
617
+ type: "string",
618
+ alias: "n"
619
+ })),
620
+ __param(1, (0, core_1.Option)("global", {
621
+ type: "boolean",
622
+ alias: "g"
623
+ })),
624
+ __metadata("design:type", Function),
625
+ __metadata("design:paramtypes", [String, Boolean, Array]),
626
+ __metadata("design:returntype", Promise)
627
+ ], ProjectController.prototype, "configSet", null);
628
+ __decorate([
629
+ (0, core_1.Command)("config:unset [...configs]"),
630
+ __param(0, (0, core_1.Option)("name", {
631
+ type: "string",
632
+ alias: "n"
633
+ })),
634
+ __param(1, (0, core_1.Option)("global", {
635
+ type: "boolean",
636
+ alias: "g"
637
+ })),
638
+ __metadata("design:type", Function),
639
+ __metadata("design:paramtypes", [String, Boolean, Array]),
640
+ __metadata("design:returntype", Promise)
641
+ ], ProjectController.prototype, "configUnset", null);
642
+ __decorate([
643
+ (0, core_1.Command)("build-args"),
644
+ __param(0, (0, core_1.Option)("name", {
645
+ type: "string",
646
+ alias: "n"
647
+ })),
648
+ __metadata("design:type", Function),
649
+ __metadata("design:paramtypes", [String]),
650
+ __metadata("design:returntype", Promise)
651
+ ], ProjectController.prototype, "buildArgsList", null);
652
+ __decorate([
653
+ (0, core_1.Command)("build-args:get [...buildArgs]"),
654
+ __param(0, (0, core_1.Option)("name", {
655
+ type: "string",
656
+ alias: "n",
657
+ })),
658
+ __metadata("design:type", Function),
659
+ __metadata("design:paramtypes", [String, Array]),
660
+ __metadata("design:returntype", Promise)
661
+ ], ProjectController.prototype, "buildArgsGet", null);
662
+ __decorate([
663
+ (0, core_1.Command)("build-args:set [...buildArgs]"),
664
+ __param(0, (0, core_1.Option)("name", {
665
+ type: "string",
666
+ alias: "n"
667
+ })),
668
+ __metadata("design:type", Function),
669
+ __metadata("design:paramtypes", [String, Array]),
670
+ __metadata("design:returntype", Promise)
671
+ ], ProjectController.prototype, "buildArgsSet", null);
672
+ __decorate([
673
+ (0, core_1.Command)("build-args:unset [...buildArgs]"),
674
+ __param(0, (0, core_1.Option)("name", {
675
+ type: "string",
676
+ alias: "n"
677
+ })),
678
+ __metadata("design:type", Function),
679
+ __metadata("design:paramtypes", [String, Array]),
680
+ __metadata("design:returntype", Promise)
681
+ ], ProjectController.prototype, "buildArgsUnset", null);
682
+ __decorate([
683
+ (0, core_1.Command)("volumes"),
684
+ __param(0, (0, core_1.Option)("name", {
685
+ type: "string",
686
+ alias: "n"
687
+ })),
688
+ __metadata("design:type", Function),
689
+ __metadata("design:paramtypes", [String]),
690
+ __metadata("design:returntype", Promise)
691
+ ], ProjectController.prototype, "volumeList", null);
692
+ __decorate([
693
+ (0, core_1.Command)("volume:mount [...volumes]"),
694
+ __param(0, (0, core_1.Option)("name", {
695
+ type: "string",
696
+ alias: "n"
697
+ })),
698
+ __metadata("design:type", Function),
699
+ __metadata("design:paramtypes", [String, Array]),
700
+ __metadata("design:returntype", Promise)
701
+ ], ProjectController.prototype, "volumeMount", null);
702
+ __decorate([
703
+ (0, core_1.Command)("volume:unmount [...volumes]"),
704
+ __param(0, (0, core_1.Option)("name", {
705
+ type: "string",
706
+ alias: "n"
707
+ })),
708
+ __metadata("design:type", Function),
709
+ __metadata("design:paramtypes", [String, Array]),
710
+ __metadata("design:returntype", Promise)
711
+ ], ProjectController.prototype, "volumeUnmount", null);
712
+ __decorate([
713
+ (0, core_1.Command)("logs"),
714
+ __param(0, (0, core_1.Option)("name", {
715
+ type: "string",
716
+ alias: "n",
717
+ description: "Project name"
718
+ })),
719
+ __param(1, (0, core_1.Option)("global", {
720
+ type: "boolean",
721
+ alias: "g"
722
+ })),
723
+ __param(2, (0, core_1.Option)("detach", {
724
+ type: "boolean",
725
+ alias: "d"
726
+ })),
727
+ __param(3, (0, core_1.Option)("follow", {
728
+ type: "boolean",
729
+ alias: "f"
730
+ })),
731
+ __metadata("design:type", Function),
732
+ __metadata("design:paramtypes", [String, Boolean, Boolean, Boolean]),
733
+ __metadata("design:returntype", Promise)
734
+ ], ProjectController.prototype, "logs", null);
735
+ __decorate([
736
+ (0, core_1.Command)("exec [...command]"),
737
+ __param(0, (0, core_1.Option)("name", {
738
+ type: "string",
739
+ alias: "n",
740
+ description: "Project name"
741
+ })),
742
+ __metadata("design:type", Function),
743
+ __metadata("design:paramtypes", [String, Array]),
744
+ __metadata("design:returntype", Promise)
745
+ ], ProjectController.prototype, "exec", null);
746
+ exports.ProjectController = ProjectController = __decorate([
747
+ (0, core_1.Controller)(),
748
+ __metadata("design:paramtypes", [services_1.AppConfigService,
749
+ services_1.AppEventsService,
750
+ services_1.ProjectService,
751
+ services_1.DockerService,
752
+ services_1.LogService])
753
+ ], ProjectController);