@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
@@ -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,16 +53,7 @@ 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) {
109
57
  if (typeof httpPort === "undefined" || isNaN(httpPort)) {
110
58
  httpPort = await (0, utils_1.promptText)({
111
59
  required: true,
@@ -155,9 +103,6 @@ class ProxyController extends core_1.Controller {
155
103
  ]
156
104
  });
157
105
  }
158
- else {
159
- console.info("Container already exists");
160
- }
161
106
  const { State: { Status } } = await container.inspect();
162
107
  if (["created", "exited"].includes(Status)) {
163
108
  console.info("Starting...", Status);
@@ -172,8 +117,7 @@ class ProxyController extends core_1.Controller {
172
117
  await this.stop();
173
118
  await this.start();
174
119
  }
175
- async domainList(options) {
176
- const { name } = options;
120
+ async domainList(name) {
177
121
  if (name) {
178
122
  await this.projectService.cdProject(name);
179
123
  }
@@ -187,22 +131,20 @@ class ProxyController extends core_1.Controller {
187
131
  }
188
132
  return table.toString() + "\n";
189
133
  }
190
- async setDomains(options, domains) {
191
- const { name } = options;
134
+ async setDomains(name, domains) {
192
135
  if (name) {
193
136
  await this.projectService.cdProject(name);
194
137
  }
195
138
  const project = await this.projectService.get();
196
139
  project.setEnv("VIRTUAL_HOST", domains.join(","));
197
- project.save();
140
+ await project.save();
198
141
  const container = await this.dockerService.getContainer(`${project.name}.workspace`);
199
142
  if (container) {
200
143
  await this.projectService.stop();
201
144
  await this.projectService.start();
202
145
  }
203
146
  }
204
- async addDomain(options, addDomains) {
205
- const { name } = options;
147
+ async addDomain(name, addDomains) {
206
148
  if (name) {
207
149
  await this.projectService.cdProject(name);
208
150
  }
@@ -226,8 +168,7 @@ class ProxyController extends core_1.Controller {
226
168
  await this.projectService.start();
227
169
  }
228
170
  }
229
- async removeDomain(options, removeDomains) {
230
- const { name } = options;
171
+ async removeDomain(name, removeDomains) {
231
172
  if (name) {
232
173
  await this.projectService.cdProject(name);
233
174
  }
@@ -241,8 +182,7 @@ class ProxyController extends core_1.Controller {
241
182
  project.setEnv("VIRTUAL_HOST", domains.join(","));
242
183
  await project.save();
243
184
  }
244
- async clearDomains(options) {
245
- const { name } = options;
185
+ async clearDomains(name) {
246
186
  if (name) {
247
187
  await this.projectService.cdProject(name);
248
188
  }
@@ -266,8 +206,114 @@ class ProxyController extends core_1.Controller {
266
206
  stderr: true
267
207
  });
268
208
  stream.on("data", (data) => {
269
- process.stdout.write((0, utils_2.demuxOutput)(data));
209
+ process.stdout.write((0, utils_1.demuxOutput)(data));
270
210
  });
271
211
  }
272
- }
212
+ };
273
213
  exports.ProxyController = ProxyController;
214
+ __decorate([
215
+ (0, core_1.Completion)("name"),
216
+ __metadata("design:type", Function),
217
+ __metadata("design:paramtypes", []),
218
+ __metadata("design:returntype", Promise)
219
+ ], ProxyController.prototype, "getProjectNames", null);
220
+ __decorate([
221
+ (0, core_1.Command)("proxy:init"),
222
+ __param(0, (0, core_1.Option)("http-port", {
223
+ type: "number",
224
+ description: "Http port"
225
+ })),
226
+ __param(1, (0, core_1.Option)("https-port", {
227
+ type: "number",
228
+ description: "Https port"
229
+ })),
230
+ __metadata("design:type", Function),
231
+ __metadata("design:paramtypes", [Number, Number]),
232
+ __metadata("design:returntype", Promise)
233
+ ], ProxyController.prototype, "init", null);
234
+ __decorate([
235
+ (0, core_1.Command)("proxy:start"),
236
+ __metadata("design:type", Function),
237
+ __metadata("design:paramtypes", []),
238
+ __metadata("design:returntype", Promise)
239
+ ], ProxyController.prototype, "start", null);
240
+ __decorate([
241
+ (0, core_1.Command)("proxy:stop"),
242
+ __metadata("design:type", Function),
243
+ __metadata("design:paramtypes", []),
244
+ __metadata("design:returntype", Promise)
245
+ ], ProxyController.prototype, "stop", null);
246
+ __decorate([
247
+ (0, core_1.Command)("proxy:restart"),
248
+ __metadata("design:type", Function),
249
+ __metadata("design:paramtypes", []),
250
+ __metadata("design:returntype", Promise)
251
+ ], ProxyController.prototype, "restart", null);
252
+ __decorate([
253
+ (0, core_1.Command)("domains"),
254
+ __param(0, (0, core_1.Option)("name", {
255
+ type: "string",
256
+ alias: "n",
257
+ description: "Project name"
258
+ })),
259
+ __metadata("design:type", Function),
260
+ __metadata("design:paramtypes", [String]),
261
+ __metadata("design:returntype", Promise)
262
+ ], ProxyController.prototype, "domainList", null);
263
+ __decorate([
264
+ (0, core_1.Command)("domain:set [...domains]"),
265
+ __param(0, (0, core_1.Option)("name", {
266
+ type: "string",
267
+ alias: "n",
268
+ description: "Project name"
269
+ })),
270
+ __metadata("design:type", Function),
271
+ __metadata("design:paramtypes", [String, Array]),
272
+ __metadata("design:returntype", Promise)
273
+ ], ProxyController.prototype, "setDomains", null);
274
+ __decorate([
275
+ (0, core_1.Command)("domain:add [...domains]"),
276
+ __param(0, (0, core_1.Option)("name", {
277
+ type: "string",
278
+ alias: "n",
279
+ description: "Project name"
280
+ })),
281
+ __metadata("design:type", Function),
282
+ __metadata("design:paramtypes", [String, Array]),
283
+ __metadata("design:returntype", Promise)
284
+ ], ProxyController.prototype, "addDomain", null);
285
+ __decorate([
286
+ (0, core_1.Command)("domain:remove [...domains]"),
287
+ __param(0, (0, core_1.Option)("name", {
288
+ type: "string",
289
+ alias: "n",
290
+ description: "Project name"
291
+ })),
292
+ __metadata("design:type", Function),
293
+ __metadata("design:paramtypes", [String, Array]),
294
+ __metadata("design:returntype", Promise)
295
+ ], ProxyController.prototype, "removeDomain", null);
296
+ __decorate([
297
+ (0, core_1.Command)("domain:clear"),
298
+ __param(0, (0, core_1.Option)("name", {
299
+ type: "string",
300
+ alias: "n",
301
+ description: "Project name"
302
+ })),
303
+ __metadata("design:type", Function),
304
+ __metadata("design:paramtypes", [String]),
305
+ __metadata("design:returntype", Promise)
306
+ ], ProxyController.prototype, "clearDomains", null);
307
+ __decorate([
308
+ (0, core_1.Command)("proxy:logs"),
309
+ __metadata("design:type", Function),
310
+ __metadata("design:paramtypes", []),
311
+ __metadata("design:returntype", Promise)
312
+ ], ProxyController.prototype, "logs", null);
313
+ exports.ProxyController = ProxyController = __decorate([
314
+ (0, core_1.Controller)(),
315
+ __metadata("design:paramtypes", [services_1.AppConfigService,
316
+ services_1.AppEventsService,
317
+ services_1.ProjectService,
318
+ services_1.DockerService])
319
+ ], ProxyController);
@@ -1,3 +1,4 @@
1
+ export * from "./CompletionController";
1
2
  export * from "./ImageController";
2
3
  export * from "./PluginController";
3
4
  export * from "./PresetController";
@@ -14,6 +14,7 @@ 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);
17
18
  __exportStar(require("./ImageController"), exports);
18
19
  __exportStar(require("./PluginController"), exports);
19
20
  __exportStar(require("./PresetController"), exports);
package/lib/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { App } from "./App";
2
2
  declare const app: App;
3
3
  export { app };
4
- export * from "./decorators";
5
4
  export * from "./makes";
6
5
  export * from "./services";
package/lib/index.js CHANGED
@@ -16,18 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.app = void 0;
18
18
  const App_1 = require("./App");
19
- const plugins_1 = require("./plugins");
20
19
  const app = new App_1.App();
21
20
  exports.app = app;
22
- app.use(plugins_1.ElasticSearchPlugin);
23
- app.use(plugins_1.LocaltunnelPlugin);
24
- app.use(plugins_1.MaildevPlugin);
25
- app.use(plugins_1.MongodbPlugin);
26
- app.use(plugins_1.NgrokPlugin);
27
- app.use(plugins_1.PageKitePlugin);
28
- app.use(plugins_1.PostgresPlugin);
29
- app.use(plugins_1.ProxmoxPlugin);
30
- app.use(plugins_1.RedisPlugin);
31
- __exportStar(require("./decorators"), exports);
32
21
  __exportStar(require("./makes"), exports);
33
22
  __exportStar(require("./services"), exports);
package/lib/main.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export declare const app: {
2
+ run(args: string[]): Promise<any>;
3
+ };
package/lib/main.js ADDED
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.app = void 0;
4
+ const core_1 = require("@wocker/core");
5
+ const AppModule_1 = require("./AppModule");
6
+ exports.app = {
7
+ async run(args) {
8
+ const factory = await core_1.Factory.create(AppModule_1.AppModule);
9
+ return factory.run(args);
10
+ }
11
+ };
@@ -1,6 +1,6 @@
1
- import { DI } from "./DI";
1
+ import { LogService } from "../services";
2
2
  declare class Logger {
3
- static install(di: DI): void;
3
+ static install(ls: LogService): void;
4
4
  static log(...data: any[]): void;
5
5
  static info(...data: any[]): void;
6
6
  static warn(...data: any[]): void;
@@ -1,23 +1,34 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Logger = void 0;
4
- const LogService_1 = require("../services/LogService");
5
- let _di;
4
+ let logService;
6
5
  class Logger {
7
- static install(di) {
8
- _di = di;
6
+ static install(ls) {
7
+ logService = ls;
9
8
  }
10
9
  static log(...data) {
11
- _di.resolveService(LogService_1.LogService).log(...data);
10
+ if (!logService) {
11
+ throw new Error("Dependency is missing");
12
+ }
13
+ logService.log(...data);
12
14
  }
13
15
  static info(...data) {
14
- _di.resolveService(LogService_1.LogService).info(...data);
16
+ if (!logService) {
17
+ throw new Error("Dependency is missing");
18
+ }
19
+ logService.info(...data);
15
20
  }
16
21
  static warn(...data) {
17
- _di.resolveService(LogService_1.LogService).warn(...data);
22
+ if (!logService) {
23
+ throw new Error("Dependency is missing");
24
+ }
25
+ logService.warn(...data);
18
26
  }
19
27
  static error(...data) {
20
- _di.resolveService(LogService_1.LogService).error(...data);
28
+ if (!logService) {
29
+ throw new Error("Dependency is missing");
30
+ }
31
+ logService.error(...data);
21
32
  }
22
33
  }
23
34
  exports.Logger = Logger;
@@ -1,6 +1,5 @@
1
- import { EnvConfig } from "../types";
2
- import { DI } from "../makes";
3
- import { PresetServiceSearchOptions as SearchOptions } from "../services/PresetService";
1
+ import { EnvConfig } from "@wocker/core";
2
+ import { PresetService, PresetServiceSearchOptions as SearchOptions } from "../services/PresetService";
4
3
  type TextOption = {
5
4
  type: "string" | "number" | "int";
6
5
  message?: string;
@@ -39,7 +38,7 @@ declare class Preset {
39
38
  constructor(data: any);
40
39
  save(): Promise<void>;
41
40
  getImageName(buildArgs?: EnvConfig): string;
42
- static install(di: DI): void;
41
+ static install(ps: PresetService): void;
43
42
  static search(options: SearchOptions): Promise<Preset[]>;
44
43
  static searchOne(options: SearchOptions): Promise<Preset>;
45
44
  }
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Preset = void 0;
4
- const PresetService_1 = require("../services/PresetService");
5
- let _di;
4
+ let presetService;
6
5
  class Preset {
7
6
  constructor(data) {
8
7
  this.id = data.id;
@@ -15,19 +14,31 @@ class Preset {
15
14
  this.volumeOptions = data.volumeOptions;
16
15
  }
17
16
  async save() {
18
- return _di.resolveService(PresetService_1.PresetService).save(this);
17
+ if (!presetService) {
18
+ throw new Error("Dependency is missing");
19
+ }
20
+ return presetService.save(this);
19
21
  }
20
22
  getImageName(buildArgs) {
21
- return _di.resolveService(PresetService_1.PresetService).getImageName(this, buildArgs);
23
+ if (!presetService) {
24
+ throw new Error("Dependency is missing");
25
+ }
26
+ return presetService.getImageName(this, buildArgs);
22
27
  }
23
- static install(di) {
24
- _di = di;
28
+ static install(ps) {
29
+ presetService = ps;
25
30
  }
26
31
  static search(options) {
27
- return _di.resolveService(PresetService_1.PresetService).search(options);
32
+ if (!presetService) {
33
+ throw new Error("Dependency is missing");
34
+ }
35
+ return presetService.search(options);
28
36
  }
29
37
  static searchOne(options) {
30
- return _di.resolveService(PresetService_1.PresetService).searchOne(options);
38
+ if (!presetService) {
39
+ throw new Error("Dependency is missing");
40
+ }
41
+ return presetService.searchOne(options);
31
42
  }
32
43
  }
33
44
  exports.Preset = Preset;
@@ -1,9 +1,3 @@
1
- export * from "./Controller";
2
- export * from "./DI";
3
- export * from "./Docker";
4
1
  export * from "./FS";
5
2
  export * from "./Logger";
6
- export * from "./Plugin";
7
3
  export * from "./Preset";
8
- export * from "./Project";
9
- export * from "./Repository";
@@ -14,12 +14,6 @@ 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("./Controller"), exports);
18
- __exportStar(require("./DI"), exports);
19
- __exportStar(require("./Docker"), exports);
20
17
  __exportStar(require("./FS"), exports);
21
18
  __exportStar(require("./Logger"), exports);
22
- __exportStar(require("./Plugin"), exports);
23
19
  __exportStar(require("./Preset"), exports);
24
- __exportStar(require("./Project"), exports);
25
- __exportStar(require("./Repository"), exports);
@@ -1,18 +1,17 @@
1
1
  import { FSManager } from "@wocker/core";
2
2
  import { Cli } from "@kearisp/cli";
3
- import { Plugin, DI } from "../makes";
4
3
  import { AppConfigService, DockerService } from "../services";
5
4
  type StartOptions = {
6
5
  restart?: boolean;
7
6
  };
8
- declare class ElasticSearchPlugin extends Plugin {
7
+ export declare class ElasticSearchPlugin {
8
+ protected readonly appConfigService: AppConfigService;
9
+ protected readonly dockerService: DockerService;
9
10
  protected containerName: string;
10
- protected appConfigService: AppConfigService;
11
- protected dockerService: DockerService;
12
11
  protected fs: FSManager;
13
- constructor(di: DI);
12
+ constructor(appConfigService: AppConfigService, dockerService: DockerService);
14
13
  install(cli: Cli): void;
15
14
  start(options: StartOptions): Promise<void>;
16
15
  stop(): Promise<void>;
17
16
  }
18
- export { ElasticSearchPlugin };
17
+ export {};
@@ -1,19 +1,25 @@
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
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.ElasticSearchPlugin = void 0;
4
13
  const core_1 = require("@wocker/core");
5
- const makes_1 = require("../makes");
6
14
  const services_1 = require("../services");
7
- class ElasticSearchPlugin extends makes_1.Plugin {
8
- constructor(di) {
9
- super("elastic-search");
15
+ let ElasticSearchPlugin = class ElasticSearchPlugin {
16
+ constructor(appConfigService, dockerService) {
17
+ this.appConfigService = appConfigService;
18
+ this.dockerService = dockerService;
10
19
  this.containerName = "elastic-search.workspace";
11
- this.appConfigService = di.resolveService(services_1.AppConfigService);
12
- this.dockerService = di.resolveService(services_1.DockerService);
13
20
  this.fs = new core_1.FSManager(this.appConfigService.pluginsPath("elastic-search"), this.appConfigService.dataPath("plugins/elastic-search"));
14
21
  }
15
22
  install(cli) {
16
- super.install(cli);
17
23
  cli.command("elastica:start")
18
24
  .option("restart", {
19
25
  type: "boolean",
@@ -68,5 +74,10 @@ class ElasticSearchPlugin extends makes_1.Plugin {
68
74
  async stop() {
69
75
  await this.dockerService.removeContainer(this.containerName);
70
76
  }
71
- }
77
+ };
72
78
  exports.ElasticSearchPlugin = ElasticSearchPlugin;
79
+ exports.ElasticSearchPlugin = ElasticSearchPlugin = __decorate([
80
+ (0, core_1.Controller)(),
81
+ __metadata("design:paramtypes", [services_1.AppConfigService,
82
+ services_1.DockerService])
83
+ ], ElasticSearchPlugin);