@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
@@ -1,34 +1,24 @@
1
- import { Controller, Cli } from "@wocker/core";
2
- import { DI, Project } from "../makes";
1
+ import { Project } from "@wocker/core";
3
2
  import { AppConfigService, AppEventsService, ProjectService, DockerService } from "../services";
4
- type InitOptions = {
5
- "http-port"?: number;
6
- "https-port"?: number;
7
- };
8
- type DomainsOptions = {
9
- name?: string;
10
- };
11
- declare class ProxyController extends Controller {
3
+ export declare class ProxyController {
4
+ protected readonly appConfigService: AppConfigService;
5
+ protected readonly appEventsService: AppEventsService;
6
+ protected readonly projectService: ProjectService;
7
+ protected readonly dockerService: DockerService;
12
8
  protected containerName: string;
13
- protected appConfigService: AppConfigService;
14
- protected appEventsService: AppEventsService;
15
- protected projectService: ProjectService;
16
- protected dockerService: DockerService;
17
- constructor(di: DI);
18
- install(cli: Cli): void;
19
- getProjectNames(): Promise<string[]>;
20
- getDomains(name: string | undefined, selected: string[]): Promise<string[]>;
9
+ constructor(appConfigService: AppConfigService, appEventsService: AppEventsService, projectService: ProjectService, dockerService: DockerService);
21
10
  onProjectStart(project: Project): Promise<void>;
22
11
  onProjectStop(project: Project): Promise<void>;
23
- init(options: InitOptions): Promise<void>;
12
+ getProjectNames(): Promise<string[]>;
13
+ getDomains(name: string | undefined, selected: string[]): Promise<string[]>;
14
+ init(httpPort: number, httpsPort: number): Promise<void>;
24
15
  start(): Promise<void>;
25
16
  stop(): Promise<void>;
26
17
  restart(): Promise<void>;
27
- domainList(options: DomainsOptions): Promise<string>;
28
- setDomains(options: DomainsOptions, domains: string[]): Promise<void>;
29
- addDomain(options: DomainsOptions, addDomains: string[]): Promise<void>;
30
- removeDomain(options: DomainsOptions, removeDomains: string[]): Promise<void>;
31
- clearDomains(options: DomainsOptions): Promise<void>;
18
+ domainList(name: string): Promise<string>;
19
+ setDomains(name: string, domains: string[]): Promise<void>;
20
+ addDomain(name: string, addDomains: string[]): Promise<void>;
21
+ removeDomain(name: string, removeDomains: string[]): Promise<void>;
22
+ clearDomains(name: string): Promise<void>;
32
23
  logs(): Promise<void>;
33
24
  }
34
- export { ProxyController };
@@ -1,4 +1,16 @@
1
1
  "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
2
14
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
15
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
16
  };
@@ -9,82 +21,27 @@ const utils_1 = require("@wocker/utils");
9
21
  const cli_table3_1 = __importDefault(require("cli-table3"));
10
22
  const chalk_1 = __importDefault(require("chalk"));
11
23
  const makes_1 = require("../makes");
12
- const utils_2 = require("../utils");
13
24
  const services_1 = require("../services");
14
- class ProxyController extends core_1.Controller {
15
- constructor(di) {
16
- super();
25
+ let ProxyController = class ProxyController {
26
+ constructor(appConfigService, appEventsService, projectService, dockerService) {
27
+ this.appConfigService = appConfigService;
28
+ this.appEventsService = appEventsService;
29
+ this.projectService = projectService;
30
+ this.dockerService = dockerService;
17
31
  this.containerName = "proxy.workspace";
18
- this.appConfigService = di.resolveService(services_1.AppConfigService);
19
- this.appEventsService = di.resolveService(services_1.AppEventsService);
20
- this.projectService = di.resolveService(services_1.ProjectService);
21
- this.dockerService = di.resolveService(services_1.DockerService);
22
- }
23
- install(cli) {
24
- super.install(cli);
25
32
  this.appEventsService.on("project:beforeStart", (project) => this.onProjectStart(project));
26
33
  this.appEventsService.on("project:stop", (project) => this.onProjectStop(project));
27
- cli.command("proxy:init")
28
- .option("http-port", {
29
- type: "number",
30
- description: "Http port"
31
- })
32
- .option("https-port", {
33
- type: "number",
34
- description: "Https port"
35
- })
36
- .action((options) => this.init(options));
37
- cli.command("proxy:start")
38
- .action(() => this.start());
39
- cli.command("proxy:stop")
40
- .action(() => this.stop());
41
- cli.command("proxy:restart")
42
- .action(() => this.restart());
43
- cli.command("domains")
44
- .option("name", {
45
- type: "string",
46
- alias: "n",
47
- description: "Project name"
48
- })
49
- .action((options) => this.domainList(options));
50
- cli.command("domain:set [...domains]")
51
- .option("name", {
52
- type: "string",
53
- alias: "n",
54
- description: "Project name"
55
- })
56
- .completion("name", () => this.getProjectNames())
57
- .action((options, domains) => this.setDomains(options, domains));
58
- cli.command("domain:add [...domains]")
59
- .option("name", {
60
- type: "string",
61
- alias: "n",
62
- description: "Project name"
63
- })
64
- .completion("name", () => this.getProjectNames())
65
- .action((options, domains) => this.addDomain(options, domains));
66
- cli.command("domain:remove [...domains]")
67
- .option("name", {
68
- type: "string",
69
- alias: "n",
70
- description: "Project name"
71
- })
72
- .completion("name", () => this.getProjectNames())
73
- .completion("domains", (options, domains) => this.getDomains(options.name, domains))
74
- .action((options, domains) => this.removeDomain(options, domains));
75
- cli.command("domain:clear")
76
- .option("name", {
77
- type: "string",
78
- alias: "n",
79
- description: "Project name"
80
- })
81
- .completion("name", () => this.getProjectNames())
82
- .action((options) => this.clearDomains(options));
83
- cli.command("proxy:logs")
84
- .action(() => this.logs());
34
+ }
35
+ async onProjectStart(project) {
36
+ if (!project.hasEnv("VIRTUAL_HOST")) {
37
+ project.setEnv("VIRTUAL_HOST", project.containerName);
38
+ }
39
+ await this.start();
40
+ }
41
+ async onProjectStop(project) {
85
42
  }
86
43
  async getProjectNames() {
87
- const projects = await makes_1.Project.search();
44
+ const projects = await this.projectService.search();
88
45
  return projects.map((project) => project.name);
89
46
  }
90
47
  async getDomains(name, selected) {
@@ -96,40 +53,34 @@ class ProxyController extends core_1.Controller {
96
53
  return !selected.includes(domain);
97
54
  });
98
55
  }
99
- async onProjectStart(project) {
100
- if (!project.hasEnv("VIRTUAL_HOST")) {
101
- project.setEnv("VIRTUAL_HOST", `${project.name}.workspace`);
102
- }
103
- await this.start();
104
- }
105
- async onProjectStop(project) {
106
- }
107
- async init(options) {
108
- let { "http-port": httpPort, "https-port": httpsPort } = options;
56
+ async init(httpPort, httpsPort) {
57
+ const config = await this.appConfigService.getConfig();
109
58
  if (typeof httpPort === "undefined" || isNaN(httpPort)) {
110
59
  httpPort = await (0, utils_1.promptText)({
111
60
  required: true,
112
61
  message: "Http port:",
113
62
  type: "int",
114
- default: await this.appConfigService.getEnvVariable("PROXY_HTTP_PORT", "80")
63
+ default: config.getMeta("PROXY_HTTP_PORT", "80")
115
64
  });
116
65
  }
117
- await this.appConfigService.setEnvVariable("PROXY_HTTP_PORT", httpPort);
66
+ config.setMeta("PROXY_HTTP_PORT", httpPort.toString());
118
67
  if (typeof httpsPort === "undefined" || isNaN(httpsPort)) {
119
68
  httpsPort = await (0, utils_1.promptText)({
120
69
  required: true,
121
70
  message: "Https port:",
122
71
  type: "int",
123
- default: await this.appConfigService.getEnvVariable("PROXY_HTTPS_PORT", "443")
72
+ default: config.getMeta("PROXY_HTTPS_PORT", "443")
124
73
  });
125
74
  }
126
- await this.appConfigService.setEnvVariable("PROXY_HTTPS_PORT", httpsPort);
75
+ config.setMeta("PROXY_HTTPS_PORT", httpsPort.toString());
76
+ await config.save();
127
77
  }
128
78
  async start() {
129
79
  console.info("Proxy starting...");
80
+ const config = await this.appConfigService.getConfig();
130
81
  await this.dockerService.pullImage("nginxproxy/nginx-proxy");
131
- const httpPort = await this.appConfigService.getEnvVariable("PROXY_HTTP_PORT", "80");
132
- const httpsPort = await this.appConfigService.getEnvVariable("PROXY_HTTPS_PORT", "443");
82
+ const httpPort = config.getMeta("PROXY_HTTP_PORT", "80");
83
+ const httpsPort = config.getMeta("PROXY_HTTPS_PORT", "443");
133
84
  let container = await this.dockerService.getContainer(this.containerName);
134
85
  if (!container) {
135
86
  const certsDir = this.appConfigService.dataPath("certs");
@@ -155,9 +106,6 @@ class ProxyController extends core_1.Controller {
155
106
  ]
156
107
  });
157
108
  }
158
- else {
159
- console.info("Container already exists");
160
- }
161
109
  const { State: { Status } } = await container.inspect();
162
110
  if (["created", "exited"].includes(Status)) {
163
111
  console.info("Starting...", Status);
@@ -172,8 +120,7 @@ class ProxyController extends core_1.Controller {
172
120
  await this.stop();
173
121
  await this.start();
174
122
  }
175
- async domainList(options) {
176
- const { name } = options;
123
+ async domainList(name) {
177
124
  if (name) {
178
125
  await this.projectService.cdProject(name);
179
126
  }
@@ -187,22 +134,20 @@ class ProxyController extends core_1.Controller {
187
134
  }
188
135
  return table.toString() + "\n";
189
136
  }
190
- async setDomains(options, domains) {
191
- const { name } = options;
137
+ async setDomains(name, domains) {
192
138
  if (name) {
193
139
  await this.projectService.cdProject(name);
194
140
  }
195
141
  const project = await this.projectService.get();
196
142
  project.setEnv("VIRTUAL_HOST", domains.join(","));
197
- project.save();
143
+ await project.save();
198
144
  const container = await this.dockerService.getContainer(`${project.name}.workspace`);
199
145
  if (container) {
200
146
  await this.projectService.stop();
201
147
  await this.projectService.start();
202
148
  }
203
149
  }
204
- async addDomain(options, addDomains) {
205
- const { name } = options;
150
+ async addDomain(name, addDomains) {
206
151
  if (name) {
207
152
  await this.projectService.cdProject(name);
208
153
  }
@@ -226,8 +171,7 @@ class ProxyController extends core_1.Controller {
226
171
  await this.projectService.start();
227
172
  }
228
173
  }
229
- async removeDomain(options, removeDomains) {
230
- const { name } = options;
174
+ async removeDomain(name, removeDomains) {
231
175
  if (name) {
232
176
  await this.projectService.cdProject(name);
233
177
  }
@@ -241,8 +185,7 @@ class ProxyController extends core_1.Controller {
241
185
  project.setEnv("VIRTUAL_HOST", domains.join(","));
242
186
  await project.save();
243
187
  }
244
- async clearDomains(options) {
245
- const { name } = options;
188
+ async clearDomains(name) {
246
189
  if (name) {
247
190
  await this.projectService.cdProject(name);
248
191
  }
@@ -266,8 +209,120 @@ class ProxyController extends core_1.Controller {
266
209
  stderr: true
267
210
  });
268
211
  stream.on("data", (data) => {
269
- process.stdout.write((0, utils_2.demuxOutput)(data));
212
+ process.stdout.write((0, utils_1.demuxOutput)(data));
270
213
  });
271
214
  }
272
- }
215
+ };
273
216
  exports.ProxyController = ProxyController;
217
+ __decorate([
218
+ (0, core_1.Completion)("name"),
219
+ __metadata("design:type", Function),
220
+ __metadata("design:paramtypes", []),
221
+ __metadata("design:returntype", Promise)
222
+ ], ProxyController.prototype, "getProjectNames", null);
223
+ __decorate([
224
+ (0, core_1.Command)("domains"),
225
+ __metadata("design:type", Function),
226
+ __metadata("design:paramtypes", [String, Array]),
227
+ __metadata("design:returntype", Promise)
228
+ ], ProxyController.prototype, "getDomains", null);
229
+ __decorate([
230
+ (0, core_1.Command)("proxy:init"),
231
+ __param(0, (0, core_1.Option)("http-port", {
232
+ type: "number",
233
+ description: "Http port"
234
+ })),
235
+ __param(1, (0, core_1.Option)("https-port", {
236
+ type: "number",
237
+ description: "Https port"
238
+ })),
239
+ __metadata("design:type", Function),
240
+ __metadata("design:paramtypes", [Number, Number]),
241
+ __metadata("design:returntype", Promise)
242
+ ], ProxyController.prototype, "init", null);
243
+ __decorate([
244
+ (0, core_1.Command)("proxy:start"),
245
+ __metadata("design:type", Function),
246
+ __metadata("design:paramtypes", []),
247
+ __metadata("design:returntype", Promise)
248
+ ], ProxyController.prototype, "start", null);
249
+ __decorate([
250
+ (0, core_1.Command)("proxy:stop"),
251
+ __metadata("design:type", Function),
252
+ __metadata("design:paramtypes", []),
253
+ __metadata("design:returntype", Promise)
254
+ ], ProxyController.prototype, "stop", null);
255
+ __decorate([
256
+ (0, core_1.Command)("proxy:restart"),
257
+ __metadata("design:type", Function),
258
+ __metadata("design:paramtypes", []),
259
+ __metadata("design:returntype", Promise)
260
+ ], ProxyController.prototype, "restart", null);
261
+ __decorate([
262
+ (0, core_1.Command)("domains"),
263
+ __param(0, (0, core_1.Option)("name", {
264
+ type: "string",
265
+ alias: "n",
266
+ description: "Project name"
267
+ })),
268
+ __metadata("design:type", Function),
269
+ __metadata("design:paramtypes", [String]),
270
+ __metadata("design:returntype", Promise)
271
+ ], ProxyController.prototype, "domainList", null);
272
+ __decorate([
273
+ (0, core_1.Command)("domain:set [...domains]"),
274
+ __param(0, (0, core_1.Option)("name", {
275
+ type: "string",
276
+ alias: "n",
277
+ description: "Project name"
278
+ })),
279
+ __metadata("design:type", Function),
280
+ __metadata("design:paramtypes", [String, Array]),
281
+ __metadata("design:returntype", Promise)
282
+ ], ProxyController.prototype, "setDomains", null);
283
+ __decorate([
284
+ (0, core_1.Command)("domain:add [...domains]"),
285
+ __param(0, (0, core_1.Option)("name", {
286
+ type: "string",
287
+ alias: "n",
288
+ description: "Project name"
289
+ })),
290
+ __metadata("design:type", Function),
291
+ __metadata("design:paramtypes", [String, Array]),
292
+ __metadata("design:returntype", Promise)
293
+ ], ProxyController.prototype, "addDomain", null);
294
+ __decorate([
295
+ (0, core_1.Command)("domain:remove [...domains]"),
296
+ __param(0, (0, core_1.Option)("name", {
297
+ type: "string",
298
+ alias: "n",
299
+ description: "Project name"
300
+ })),
301
+ __metadata("design:type", Function),
302
+ __metadata("design:paramtypes", [String, Array]),
303
+ __metadata("design:returntype", Promise)
304
+ ], ProxyController.prototype, "removeDomain", null);
305
+ __decorate([
306
+ (0, core_1.Command)("domain:clear"),
307
+ __param(0, (0, core_1.Option)("name", {
308
+ type: "string",
309
+ alias: "n",
310
+ description: "Project name"
311
+ })),
312
+ __metadata("design:type", Function),
313
+ __metadata("design:paramtypes", [String]),
314
+ __metadata("design:returntype", Promise)
315
+ ], ProxyController.prototype, "clearDomains", null);
316
+ __decorate([
317
+ (0, core_1.Command)("proxy:logs"),
318
+ __metadata("design:type", Function),
319
+ __metadata("design:paramtypes", []),
320
+ __metadata("design:returntype", Promise)
321
+ ], ProxyController.prototype, "logs", null);
322
+ exports.ProxyController = ProxyController = __decorate([
323
+ (0, core_1.Controller)(),
324
+ __metadata("design:paramtypes", [services_1.AppConfigService,
325
+ services_1.AppEventsService,
326
+ services_1.ProjectService,
327
+ services_1.DockerService])
328
+ ], ProxyController);
@@ -1,3 +1,5 @@
1
+ export * from "./CompletionController";
2
+ export * from "./DebugController";
1
3
  export * from "./ImageController";
2
4
  export * from "./PluginController";
3
5
  export * from "./PresetController";
@@ -14,6 +14,8 @@ 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("./CompletionController"), exports);
18
+ __exportStar(require("./DebugController"), exports);
17
19
  __exportStar(require("./ImageController"), exports);
18
20
  __exportStar(require("./PluginController"), exports);
19
21
  __exportStar(require("./PresetController"), exports);
package/lib/main.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export declare const app: {
2
+ run(args: string[]): Promise<void>;
3
+ };
package/lib/main.js ADDED
@@ -0,0 +1,30 @@
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.app = void 0;
7
+ const core_1 = require("@wocker/core");
8
+ const chalk_1 = __importDefault(require("chalk"));
9
+ const AppModule_1 = require("./AppModule");
10
+ const services_1 = require("./services");
11
+ exports.app = {
12
+ async run(args) {
13
+ const app = await core_1.Factory.create(AppModule_1.AppModule);
14
+ const config = app.get(services_1.AppConfigService);
15
+ const logger = app.get(services_1.LogService);
16
+ try {
17
+ const res = await app.run(args);
18
+ if (res) {
19
+ process.stdout.write(res);
20
+ }
21
+ }
22
+ catch (err) {
23
+ console.error(chalk_1.default.red(err.message));
24
+ const { debug } = await config.getConfig();
25
+ if (debug) {
26
+ logger.error(err.stack || err.message);
27
+ }
28
+ }
29
+ }
30
+ };
package/lib/makes/FS.d.ts CHANGED
@@ -2,17 +2,27 @@
2
2
  /// <reference types="node" />
3
3
  import { FS as CoreFS } from "@wocker/core";
4
4
  import * as fs from "fs";
5
- import { Stats, BigIntStats, PathLike, PathOrFileDescriptor, WriteFileOptions, MakeDirectoryOptions } from "fs";
5
+ import { Stats, BigIntStats, PathLike, PathOrFileDescriptor, WriteFileOptions, ObjectEncodingOptions, MakeDirectoryOptions } from "fs";
6
6
  import { PassThrough } from "readable-stream";
7
+ type ReaddirOptions = ObjectEncodingOptions & {
8
+ recursive?: boolean;
9
+ };
7
10
  type ReaddirFilesOptions = {
8
11
  recursive?: boolean;
9
12
  };
10
- declare class FS extends CoreFS {
13
+ export declare class FS extends CoreFS {
14
+ protected source: string;
15
+ constructor(source: string);
16
+ path(...parts: string[]): string;
17
+ exists(...parts: string[]): boolean;
18
+ stat(...parts: string[]): fs.Stats;
19
+ mkdir(path: string, options?: MakeDirectoryOptions): void;
20
+ readdir(...parts: string[]): Promise<string[]>;
21
+ readdirFiles(path?: string, options?: ReaddirOptions): Promise<string[]>;
11
22
  static access(path: PathLike): Promise<any>;
12
- static exists(path: PathLike): Promise<boolean>;
13
23
  static existsSync(path: PathLike): boolean;
14
24
  static mkdir(dirPath: string, options?: MakeDirectoryOptions): Promise<void>;
15
- static mkdirSync(path: any, options?: MakeDirectoryOptions): string;
25
+ static mkdirSync(path: string, options?: MakeDirectoryOptions): string;
16
26
  static readdir(path: PathLike): Promise<string[]>;
17
27
  static readdirFiles(path: string, options?: ReaddirFilesOptions): Promise<string[]>;
18
28
  static appendFile(path: PathOrFileDescriptor, data: any, options?: WriteFileOptions): Promise<unknown>;
@@ -28,4 +38,4 @@ declare class FS extends CoreFS {
28
38
  static createReadLinesStream(path: PathLike, count?: number): PassThrough;
29
39
  static copyFile(src: PathLike, dest: PathLike): Promise<void>;
30
40
  }
31
- export { FS };
41
+ export {};
package/lib/makes/FS.js CHANGED
@@ -29,6 +29,45 @@ const fs = __importStar(require("fs"));
29
29
  const Path = __importStar(require("path"));
30
30
  const readable_stream_1 = require("readable-stream");
31
31
  class FS extends core_1.FS {
32
+ constructor(source) {
33
+ super();
34
+ this.source = source;
35
+ }
36
+ path(...parts) {
37
+ return Path.join(this.source, ...parts);
38
+ }
39
+ exists(...parts) {
40
+ const fullPath = this.path(...parts);
41
+ return FS.existsSync(fullPath);
42
+ }
43
+ stat(...parts) {
44
+ const fullPath = this.path(...parts);
45
+ return fs.statSync(fullPath);
46
+ }
47
+ mkdir(path, options) {
48
+ const fullPath = this.path(path);
49
+ fs.mkdirSync(fullPath, options);
50
+ }
51
+ async readdir(...parts) {
52
+ const fullPath = this.path(...parts);
53
+ return FS.readdir(fullPath);
54
+ }
55
+ async readdirFiles(path, options) {
56
+ const fullPath = this.path(path);
57
+ return new Promise((resolve, reject) => {
58
+ fs.readdir(fullPath, options, (err, files) => {
59
+ if (err) {
60
+ reject(err);
61
+ return;
62
+ }
63
+ files = files.filter((path) => {
64
+ const stat = this.stat(path);
65
+ return stat.isFile();
66
+ });
67
+ resolve(files);
68
+ });
69
+ });
70
+ }
32
71
  static async access(path) {
33
72
  return new Promise((resolve, reject) => {
34
73
  fs.access(path, (err) => {
@@ -41,13 +80,6 @@ class FS extends core_1.FS {
41
80
  });
42
81
  });
43
82
  }
44
- static async exists(path) {
45
- return new Promise((resolve) => {
46
- fs.exists(path, (exists) => {
47
- resolve(exists);
48
- });
49
- });
50
- }
51
83
  static existsSync(path) {
52
84
  return fs.existsSync(path);
53
85
  }
@@ -106,7 +138,8 @@ class FS extends core_1.FS {
106
138
  withFileTypes: true
107
139
  }, (err, files) => {
108
140
  if (err) {
109
- return reject(err);
141
+ reject(err);
142
+ return;
110
143
  }
111
144
  const names = files.filter((dirent) => {
112
145
  return dirent.isFile();
@@ -160,7 +193,7 @@ class FS extends core_1.FS {
160
193
  reject(err);
161
194
  return;
162
195
  }
163
- fs.read(file, buffer, 0, buffer.length, position, (err, bytesRead, buffer) => {
196
+ fs.read(file, buffer, 0, buffer.length, position, (err, _, buffer) => {
164
197
  if (err) {
165
198
  reject(err);
166
199
  return;
@@ -0,0 +1,18 @@
1
+ import { AxiosHeaders, AxiosResponse } from "axios";
2
+ type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
3
+ export declare class Http {
4
+ readonly method: HttpMethod;
5
+ readonly url: string;
6
+ body?: any;
7
+ protected headers: AxiosHeaders;
8
+ private constructor();
9
+ withHeader(name: string, value: string): Http;
10
+ withBody(body: any): Http;
11
+ send(path: string): Promise<AxiosResponse>;
12
+ static get(url: string): Http;
13
+ static post(url: string): Http;
14
+ static put(url: string): Http;
15
+ static patch(url: string): Http;
16
+ static delete(url: string): Http;
17
+ }
18
+ export {};