@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
@@ -23,39 +23,50 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Plugin = void 0;
27
- const Path = __importStar(require("path"));
28
- const env_1 = require("../env");
29
- const Controller_1 = require("../makes/Controller");
30
- const FS_1 = require("../makes/FS");
31
- class Plugin extends Controller_1.Controller {
32
- constructor(name) {
33
- super();
34
- this.certsDir = Path.join(env_1.DATA_DIR, "certs");
35
- this.dataDir = Path.join(env_1.DATA_DIR, "plugins", name);
36
- this.pluginDir = Path.join(env_1.PLUGINS_DIR, name);
37
- }
38
- install(cli) {
39
- super.install(cli);
40
- if (!FS_1.FS.existsSync(this.certsDir)) {
41
- FS_1.FS.mkdirSync(this.certsDir, {
42
- recursive: true
43
- });
44
- }
45
- if (!FS_1.FS.existsSync(this.dataDir)) {
46
- FS_1.FS.mkdirSync(this.dataDir, {
47
- recursive: true
48
- });
49
- }
50
- }
51
- certsPath(...paths) {
52
- return Path.join(this.certsDir, ...paths);
53
- }
54
- dataPath(...paths) {
55
- return Path.join(this.dataDir, ...paths);
56
- }
57
- pluginPath(...paths) {
58
- return Path.join(this.pluginDir, ...paths);
26
+ exports.Http = void 0;
27
+ const axios_1 = __importStar(require("axios"));
28
+ class Http {
29
+ constructor(method = "GET", url, body) {
30
+ this.method = method;
31
+ this.url = url;
32
+ this.body = body;
33
+ this.headers = new axios_1.AxiosHeaders();
34
+ }
35
+ withHeader(name, value) {
36
+ this.headers.set(name, value);
37
+ return this;
38
+ }
39
+ withBody(body) {
40
+ this.body = body;
41
+ return this;
42
+ }
43
+ async send(path) {
44
+ return axios_1.default.create({
45
+ method: this.method,
46
+ baseURL: this.url,
47
+ headers: this.headers.toJSON(),
48
+ validateStatus() {
49
+ return true;
50
+ }
51
+ }).request({
52
+ url: path,
53
+ data: this.body
54
+ });
55
+ }
56
+ static get(url) {
57
+ return new Http("GET", url);
58
+ }
59
+ static post(url) {
60
+ return new Http("POST", url);
61
+ }
62
+ static put(url) {
63
+ return new Http("PUT", url);
64
+ }
65
+ static patch(url) {
66
+ return new Http("PATCH", url);
67
+ }
68
+ static delete(url) {
69
+ return new Http("DELETE", url);
59
70
  }
60
71
  }
61
- exports.Plugin = Plugin;
72
+ exports.Http = Http;
@@ -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,8 +38,8 @@ 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;
43
- static search(options: SearchOptions): Promise<Preset[]>;
44
- static searchOne(options: SearchOptions): Promise<Preset>;
41
+ static install(ps: PresetService): void;
42
+ static search(options: SearchOptions): Promise<import("@wocker/core").Preset[]>;
43
+ static searchOne(options: SearchOptions): Promise<import("@wocker/core").Preset>;
45
44
  }
46
45
  export { Preset };
@@ -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,4 @@
1
- export * from "./Controller";
2
- export * from "./DI";
3
- export * from "./Docker";
4
1
  export * from "./FS";
2
+ export * from "./Http";
5
3
  export * from "./Logger";
6
- export * from "./Plugin";
7
4
  export * from "./Preset";
8
- export * from "./Project";
9
- export * from "./Repository";
@@ -14,12 +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("./Controller"), exports);
18
- __exportStar(require("./DI"), exports);
19
- __exportStar(require("./Docker"), exports);
20
17
  __exportStar(require("./FS"), exports);
18
+ __exportStar(require("./Http"), exports);
21
19
  __exportStar(require("./Logger"), exports);
22
- __exportStar(require("./Plugin"), exports);
23
20
  __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);
@@ -1,5 +1,5 @@
1
+ import { Project } from "@wocker/core";
1
2
  import { Cli } from "@kearisp/cli";
2
- import { DI, Plugin, Project } from "../makes";
3
3
  import { AppConfigService, AppEventsService, ProjectService, DockerService } from "../services";
4
4
  type InitOptions = {
5
5
  name?: string;
@@ -15,12 +15,12 @@ type LogsOptions = {
15
15
  name?: string;
16
16
  detach?: boolean;
17
17
  };
18
- declare class LocaltunnelPlugin extends Plugin {
19
- protected appConfigService: AppConfigService;
20
- protected appEventsService: AppEventsService;
21
- protected projectService: ProjectService;
22
- protected dockerService: DockerService;
23
- constructor(di: DI);
18
+ export declare class LocaltunnelPlugin {
19
+ protected readonly appConfigService: AppConfigService;
20
+ protected readonly appEventsService: AppEventsService;
21
+ protected readonly projectService: ProjectService;
22
+ protected readonly dockerService: DockerService;
23
+ constructor(appConfigService: AppConfigService, appEventsService: AppEventsService, projectService: ProjectService, dockerService: DockerService);
24
24
  install(cli: Cli): void;
25
25
  getIp(): Promise<string>;
26
26
  onProjectStart(project: Project): Promise<void>;
@@ -33,4 +33,4 @@ declare class LocaltunnelPlugin extends Plugin {
33
33
  restart(options: StartOptions): Promise<void>;
34
34
  logs(options: LogsOptions): Promise<void>;
35
35
  }
36
- export { LocaltunnelPlugin };
36
+ export {};
@@ -1,23 +1,31 @@
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
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
13
  };
5
14
  Object.defineProperty(exports, "__esModule", { value: true });
6
15
  exports.LocaltunnelPlugin = void 0;
16
+ const core_1 = require("@wocker/core");
7
17
  const utils_1 = require("@wocker/utils");
8
18
  const axios_1 = __importDefault(require("axios"));
9
19
  const makes_1 = require("../makes");
10
20
  const services_1 = require("../services");
11
- class LocaltunnelPlugin extends makes_1.Plugin {
12
- constructor(di) {
13
- super("localtunnel");
14
- this.appConfigService = di.resolveService(services_1.AppConfigService);
15
- this.appEventsService = di.resolveService(services_1.AppEventsService);
16
- this.projectService = di.resolveService(services_1.ProjectService);
17
- this.dockerService = di.resolveService(services_1.DockerService);
21
+ let LocaltunnelPlugin = class LocaltunnelPlugin {
22
+ constructor(appConfigService, appEventsService, projectService, dockerService) {
23
+ this.appConfigService = appConfigService;
24
+ this.appEventsService = appEventsService;
25
+ this.projectService = projectService;
26
+ this.dockerService = dockerService;
18
27
  }
19
28
  install(cli) {
20
- super.install(cli);
21
29
  this.appEventsService.on("project:start", (project) => this.onProjectStart(project));
22
30
  this.appEventsService.on("project:stop", (project) => this.onProjectStop(project));
23
31
  cli.command("localtunnel:init")
@@ -176,7 +184,7 @@ class LocaltunnelPlugin extends makes_1.Plugin {
176
184
  if (!exists) {
177
185
  await this.dockerService.buildImage({
178
186
  tag: "ws-localtunnel",
179
- context: this.pluginPath(),
187
+ context: this.appConfigService.pluginsPath("plugins/localtunnel"),
180
188
  src: "./Dockerfile"
181
189
  });
182
190
  }
@@ -270,5 +278,12 @@ class LocaltunnelPlugin extends makes_1.Plugin {
270
278
  process.stderr.write(data);
271
279
  });
272
280
  }
273
- }
281
+ };
274
282
  exports.LocaltunnelPlugin = LocaltunnelPlugin;
283
+ exports.LocaltunnelPlugin = LocaltunnelPlugin = __decorate([
284
+ (0, core_1.Controller)(),
285
+ __metadata("design:paramtypes", [services_1.AppConfigService,
286
+ services_1.AppEventsService,
287
+ services_1.ProjectService,
288
+ services_1.DockerService])
289
+ ], LocaltunnelPlugin);
@@ -1,12 +1,11 @@
1
1
  import { Cli } from "@kearisp/cli";
2
- import { DI, Plugin } from "../makes";
3
- import { DockerService } from "../services";
4
- declare class MaildevPlugin extends Plugin {
2
+ import { DockerService, AppConfigService } from "../services";
3
+ export declare class MaildevPlugin {
4
+ protected readonly appConfigService: AppConfigService;
5
+ protected readonly dockerService: DockerService;
5
6
  protected containerName: string;
6
- protected dockerService: DockerService;
7
- constructor(di: DI);
7
+ constructor(appConfigService: AppConfigService, dockerService: DockerService);
8
8
  install(cli: Cli): void;
9
9
  start(): Promise<void>;
10
10
  stop(): Promise<void>;
11
11
  }
12
- export { MaildevPlugin };
@@ -1,16 +1,24 @@
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.MaildevPlugin = void 0;
4
- const makes_1 = require("../makes");
13
+ const core_1 = require("@wocker/core");
5
14
  const services_1 = require("../services");
6
- class MaildevPlugin extends makes_1.Plugin {
7
- constructor(di) {
8
- super("maildev");
15
+ let MaildevPlugin = class MaildevPlugin {
16
+ constructor(appConfigService, dockerService) {
17
+ this.appConfigService = appConfigService;
18
+ this.dockerService = dockerService;
9
19
  this.containerName = "maildev.workspace";
10
- this.dockerService = di.resolveService(services_1.DockerService);
11
20
  }
12
21
  install(cli) {
13
- super.install(cli);
14
22
  cli.command("maildev:start")
15
23
  .action(() => this.start());
16
24
  cli.command("maildev:stop")
@@ -24,7 +32,7 @@ class MaildevPlugin extends makes_1.Plugin {
24
32
  tag: "ws-maildev",
25
33
  buildArgs: {},
26
34
  labels: {},
27
- context: this.pluginPath(),
35
+ context: this.appConfigService.pluginsPath("plugins/maildev"),
28
36
  src: "./Dockerfile"
29
37
  });
30
38
  }
@@ -45,5 +53,10 @@ class MaildevPlugin extends makes_1.Plugin {
45
53
  console.log("Maildev stopping...");
46
54
  await this.dockerService.removeContainer(this.containerName);
47
55
  }
48
- }
56
+ };
49
57
  exports.MaildevPlugin = MaildevPlugin;
58
+ exports.MaildevPlugin = MaildevPlugin = __decorate([
59
+ (0, core_1.Controller)(),
60
+ __metadata("design:paramtypes", [services_1.AppConfigService,
61
+ services_1.DockerService])
62
+ ], MaildevPlugin);
@@ -1,11 +1,12 @@
1
1
  import { Cli } from "@kearisp/cli";
2
- import { DI, Plugin } from "../makes";
3
2
  import { DockerService } from "../services";
4
- declare class MongodbPlugin extends Plugin {
3
+ export declare class MongodbPlugin {
4
+ protected readonly dockerService: DockerService;
5
5
  protected container: string;
6
6
  protected adminContainer: string;
7
- protected dockerService: DockerService;
8
- constructor(di: DI);
7
+ protected dataDir: string;
8
+ constructor(dockerService: DockerService);
9
+ protected dataPath(...parts: string[]): string;
9
10
  install(cli: Cli): void;
10
11
  getDatabases(): Promise<string[]>;
11
12
  getDatabasesDumps(): Promise<string[]>;
@@ -19,4 +20,3 @@ declare class MongodbPlugin extends Plugin {
19
20
  deleteBackup(database?: string, filename?: string, yes?: boolean): Promise<void>;
20
21
  restore(database?: string, filename?: string): Promise<void>;
21
22
  }
22
- export { MongodbPlugin };
@@ -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,24 +28,29 @@ 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
+ };
25
34
  Object.defineProperty(exports, "__esModule", { value: true });
26
35
  exports.MongodbPlugin = void 0;
36
+ const core_1 = require("@wocker/core");
27
37
  const utils_1 = require("@wocker/utils");
28
38
  const Path = __importStar(require("path"));
29
39
  const dateFns = __importStar(require("date-fns"));
30
40
  const env_1 = require("../env");
31
41
  const makes_1 = require("../makes");
32
42
  const services_1 = require("../services");
33
- class MongodbPlugin extends makes_1.Plugin {
34
- constructor(di) {
35
- super("mongodb");
43
+ let MongodbPlugin = class MongodbPlugin {
44
+ constructor(dockerService) {
45
+ this.dockerService = dockerService;
36
46
  this.container = "mongodb.workspace";
37
47
  this.adminContainer = "dbadmin-mongodb.workspace";
38
- this.dockerService = di.resolveService(services_1.DockerService);
39
48
  this.dataDir = Path.join(env_1.DATA_DIR, "db/mongodb");
40
49
  }
50
+ dataPath(...parts) {
51
+ return Path.join(this.dataDir, ...parts);
52
+ }
41
53
  install(cli) {
42
- super.install(cli);
43
54
  cli.command("mongodb:start").action(() => {
44
55
  return this.start();
45
56
  });
@@ -97,7 +108,7 @@ class MongodbPlugin extends makes_1.Plugin {
97
108
  });
98
109
  }
99
110
  async getDatabases() {
100
- const stream = await makes_1.Docker.exec(this.container, [
111
+ const stream = await this.dockerService.exec(this.container, [
101
112
  "mongosh",
102
113
  "--username", "root",
103
114
  "--password", "toor",
@@ -122,7 +133,7 @@ class MongodbPlugin extends makes_1.Plugin {
122
133
  }
123
134
  async start() {
124
135
  console.log("Mongidb starting...");
125
- await makes_1.Docker.pullImage("mongo:latest");
136
+ await this.dockerService.pullImage("mongo:latest");
126
137
  const container = await this.dockerService.createContainer({
127
138
  name: this.container,
128
139
  restart: "always",
@@ -143,7 +154,7 @@ class MongodbPlugin extends makes_1.Plugin {
143
154
  }
144
155
  async startAdmin() {
145
156
  console.log("Mongodb Admin starting...");
146
- await makes_1.Docker.pullImage("mongo-express:latest");
157
+ await this.dockerService.pullImage("mongo-express:latest");
147
158
  const container = await this.dockerService.createContainer({
148
159
  name: this.adminContainer,
149
160
  restart: "always",
@@ -205,7 +216,7 @@ class MongodbPlugin extends makes_1.Plugin {
205
216
  recursive: true
206
217
  });
207
218
  }
208
- const stream = await makes_1.Docker.exec(this.container, [
219
+ const stream = await this.dockerService.exec(this.container, [
209
220
  "mongodump",
210
221
  "--authenticationDatabase", "admin",
211
222
  "--host", `${this.container}:27017`,
@@ -293,7 +304,7 @@ class MongodbPlugin extends makes_1.Plugin {
293
304
  }
294
305
  const path = this.dataPath("dump", database, filename);
295
306
  const file = makes_1.FS.createReadStream(path);
296
- const stream = await makes_1.Docker.exec(this.container, [
307
+ const stream = await this.dockerService.exec(this.container, [
297
308
  "mongorestore",
298
309
  "--authenticationDatabase", "admin",
299
310
  "--host", `${this.container}:27017`,
@@ -316,5 +327,9 @@ class MongodbPlugin extends makes_1.Plugin {
316
327
  });
317
328
  console.log(path);
318
329
  }
319
- }
330
+ };
320
331
  exports.MongodbPlugin = MongodbPlugin;
332
+ exports.MongodbPlugin = MongodbPlugin = __decorate([
333
+ (0, core_1.Controller)(),
334
+ __metadata("design:paramtypes", [services_1.DockerService])
335
+ ], MongodbPlugin);
@@ -1,5 +1,5 @@
1
+ import { DockerService, Project } from "@wocker/core";
1
2
  import { Cli } from "@kearisp/cli";
2
- import { DI, Plugin, Project } from "../makes";
3
3
  import { AppEventsService, ProjectService } from "../services";
4
4
  type StartOptions = {
5
5
  name?: string;
@@ -17,10 +17,11 @@ type AttachOptions = {
17
17
  type ForwardingOptions = {
18
18
  name?: string;
19
19
  };
20
- declare class NgrokPlugin extends Plugin {
21
- protected appEventsService: AppEventsService;
22
- protected projectService: ProjectService;
23
- constructor(di: DI);
20
+ export declare class NgrokPlugin {
21
+ protected readonly appEventsService: AppEventsService;
22
+ protected readonly projectService: ProjectService;
23
+ protected readonly dockerService: DockerService;
24
+ constructor(appEventsService: AppEventsService, projectService: ProjectService, dockerService: DockerService);
24
25
  install(cli: Cli): void;
25
26
  init(options: any): Promise<void>;
26
27
  getForwarding(project: Project): Promise<string | undefined>;
@@ -33,4 +34,4 @@ declare class NgrokPlugin extends Plugin {
33
34
  attach(options: AttachOptions): Promise<void>;
34
35
  forwarding(options: ForwardingOptions): Promise<string>;
35
36
  }
36
- export { NgrokPlugin };
37
+ export {};