@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,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 {};
@@ -1,17 +1,26 @@
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.NgrokPlugin = void 0;
13
+ const core_1 = require("@wocker/core");
4
14
  const utils_1 = require("@wocker/utils");
5
15
  const makes_1 = require("../makes");
6
16
  const services_1 = require("../services");
7
- class NgrokPlugin extends makes_1.Plugin {
8
- constructor(di) {
9
- super("ngrok");
10
- this.appEventsService = di.resolveService(services_1.AppEventsService);
11
- this.projectService = di.resolveService(services_1.ProjectService);
17
+ let NgrokPlugin = class NgrokPlugin {
18
+ constructor(appEventsService, projectService, dockerService) {
19
+ this.appEventsService = appEventsService;
20
+ this.projectService = projectService;
21
+ this.dockerService = dockerService;
12
22
  }
13
23
  install(cli) {
14
- super.install(cli);
15
24
  this.appEventsService.on("project:start", (project) => this.onProjectStart(project));
16
25
  this.appEventsService.on("project:stop", (project) => this.onProjectStop(project));
17
26
  cli.command("ngrok:init")
@@ -98,12 +107,12 @@ class NgrokPlugin extends makes_1.Plugin {
98
107
  await project.save();
99
108
  }
100
109
  async getForwarding(project) {
101
- const container = await makes_1.Docker.getContainer(`ngrok-${project.name}`);
110
+ const container = await this.dockerService.getContainer(`ngrok-${project.name}`);
102
111
  if (!container) {
103
112
  throw new Error(`Ngrok for "${project.name}" not started`);
104
113
  }
105
114
  const { NetworkSettings: { Networks: { workspace } } } = await container.inspect();
106
- const stream = await makes_1.Docker.exec("proxy.workspace", [
115
+ const stream = await this.dockerService.exec("proxy.workspace", [
107
116
  "curl", `http://${workspace.IPAddress}:4040/api/tunnels/command_line`
108
117
  ], false);
109
118
  const res = await new Promise((resolve, reject) => {
@@ -121,7 +130,7 @@ class NgrokPlugin extends makes_1.Plugin {
121
130
  if (!project || project.getEnv("NGROK_ENABLE", "false") !== "true") {
122
131
  return;
123
132
  }
124
- const container1 = await makes_1.Docker.getContainer(`ngrok-${project.name}`);
133
+ const container1 = await this.dockerService.getContainer(`ngrok-${project.name}`);
125
134
  if (container1) {
126
135
  const { State: { Running } } = await container1.inspect();
127
136
  if (Running) {
@@ -131,13 +140,13 @@ class NgrokPlugin extends makes_1.Plugin {
131
140
  return;
132
141
  }
133
142
  else {
134
- await makes_1.Docker.removeContainer(`ngrok-${project.name}`);
143
+ await this.dockerService.removeContainer(`ngrok-${project.name}`);
135
144
  }
136
145
  }
137
146
  console.log("Ngrok starting...");
138
147
  makes_1.Logger.info(`Ngrok start: ${project.name}`);
139
- await makes_1.Docker.pullImage("ngrok/ngrok:latest");
140
- const container = await makes_1.Docker.createContainer({
148
+ await this.dockerService.pullImage("ngrok/ngrok:latest");
149
+ const container = await this.dockerService.createContainer({
141
150
  name: `ngrok-${project.name}`,
142
151
  image: "ngrok/ngrok:latest",
143
152
  tty: true,
@@ -182,7 +191,7 @@ class NgrokPlugin extends makes_1.Plugin {
182
191
  return;
183
192
  }
184
193
  console.log("Ngrok stopping...");
185
- await makes_1.Docker.removeContainer(`ngrok-${project.name}`);
194
+ await this.dockerService.removeContainer(`ngrok-${project.name}`);
186
195
  }
187
196
  async start(options) {
188
197
  const { name, detach } = options;
@@ -192,7 +201,7 @@ class NgrokPlugin extends makes_1.Plugin {
192
201
  const project = await this.projectService.get();
193
202
  await this.onProjectStart(project);
194
203
  if (!detach) {
195
- await makes_1.Docker.attach(`ngrok-${project.name}`);
204
+ await this.dockerService.attach(`ngrok-${project.name}`);
196
205
  }
197
206
  }
198
207
  async stop(options) {
@@ -214,7 +223,7 @@ class NgrokPlugin extends makes_1.Plugin {
214
223
  await this.projectService.cdProject(name);
215
224
  }
216
225
  const project = await this.projectService.get();
217
- const container = await makes_1.Docker.getContainer(`ngrok-${project.name}`);
226
+ const container = await this.dockerService.getContainer(`ngrok-${project.name}`);
218
227
  if (!container) {
219
228
  throw new Error("Ngrok not started");
220
229
  }
@@ -225,7 +234,7 @@ class NgrokPlugin extends makes_1.Plugin {
225
234
  await this.projectService.cdProject(name);
226
235
  }
227
236
  const project = await this.projectService.get();
228
- await makes_1.Docker.attach(`ngrok-${project.name}`);
237
+ await this.dockerService.attach(`ngrok-${project.name}`);
229
238
  }
230
239
  async forwarding(options) {
231
240
  const { name } = options;
@@ -235,5 +244,11 @@ class NgrokPlugin extends makes_1.Plugin {
235
244
  const project = await this.projectService.get();
236
245
  return this.getForwarding(project);
237
246
  }
238
- }
247
+ };
239
248
  exports.NgrokPlugin = NgrokPlugin;
249
+ exports.NgrokPlugin = NgrokPlugin = __decorate([
250
+ (0, core_1.Controller)(),
251
+ __metadata("design:paramtypes", [services_1.AppEventsService,
252
+ services_1.ProjectService,
253
+ core_1.DockerService])
254
+ ], NgrokPlugin);
@@ -1,6 +1,6 @@
1
+ import { Project } from "@wocker/core";
1
2
  import { Cli } from "@kearisp/cli";
2
- import { DI, Plugin, Project } from "../makes";
3
- import { AppConfigService, AppEventsService, ProjectService } from "../services";
3
+ import { AppConfigService, AppEventsService, ProjectService, DockerService } from "../services";
4
4
  type InitOptions = {};
5
5
  type StartOptions = {
6
6
  name?: string;
@@ -14,11 +14,13 @@ type StopOptions = {
14
14
  type BuildOptions = {
15
15
  rebuild?: boolean;
16
16
  };
17
- declare class PageKitePlugin extends Plugin {
18
- protected appConfigService: AppConfigService;
19
- protected appEventsService: AppEventsService;
20
- protected projectService: ProjectService;
21
- constructor(di: DI);
17
+ export declare class PageKitePlugin {
18
+ protected readonly appConfigService: AppConfigService;
19
+ protected readonly appEventsService: AppEventsService;
20
+ protected readonly projectService: ProjectService;
21
+ protected readonly dockerService: DockerService;
22
+ constructor(appConfigService: AppConfigService, appEventsService: AppEventsService, projectService: ProjectService, dockerService: DockerService);
23
+ pluginPath(...parts: string[]): string;
22
24
  install(cli: Cli): void;
23
25
  onProjectStart(project: Project): Promise<void>;
24
26
  onProjectStop(project: Project): Promise<void>;
@@ -27,4 +29,4 @@ declare class PageKitePlugin extends Plugin {
27
29
  stop(options: StopOptions): Promise<void>;
28
30
  build(options?: BuildOptions): Promise<void>;
29
31
  }
30
- export { PageKitePlugin };
32
+ export {};
@@ -1,19 +1,29 @@
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.PageKitePlugin = void 0;
13
+ const core_1 = require("@wocker/core");
4
14
  const utils_1 = require("@wocker/utils");
5
- const makes_1 = require("../makes");
6
- const utils_2 = require("../utils");
7
15
  const services_1 = require("../services");
8
- class PageKitePlugin extends makes_1.Plugin {
9
- constructor(di) {
10
- super("pagekite");
11
- this.appConfigService = di.resolveService(services_1.AppConfigService);
12
- this.appEventsService = di.resolveService(services_1.AppEventsService);
13
- this.projectService = di.resolveService(services_1.ProjectService);
16
+ let PageKitePlugin = class PageKitePlugin {
17
+ constructor(appConfigService, appEventsService, projectService, dockerService) {
18
+ this.appConfigService = appConfigService;
19
+ this.appEventsService = appEventsService;
20
+ this.projectService = projectService;
21
+ this.dockerService = dockerService;
22
+ }
23
+ pluginPath(...parts) {
24
+ return this.appConfigService.pluginsPath("pagekite", ...parts);
14
25
  }
15
26
  install(cli) {
16
- super.install(cli);
17
27
  this.appEventsService.on("project:start", (project) => this.onProjectStart(project));
18
28
  this.appEventsService.on("project:stop", (project) => this.onProjectStop(project));
19
29
  cli.command("pagekite:init")
@@ -51,7 +61,7 @@ class PageKitePlugin extends makes_1.Plugin {
51
61
  }
52
62
  console.info("Pagekite starting...");
53
63
  await this.build();
54
- let container = await makes_1.Docker.getContainer(`pagekite-${project.name}`);
64
+ let container = await this.dockerService.getContainer(`pagekite-${project.name}`);
55
65
  if (container) {
56
66
  const { State: { Running } } = await container.inspect();
57
67
  if (Running) {
@@ -59,11 +69,11 @@ class PageKitePlugin extends makes_1.Plugin {
59
69
  return;
60
70
  }
61
71
  else {
62
- await makes_1.Docker.removeContainer(`pagekite-${project.name}`);
72
+ await this.dockerService.removeContainer(`pagekite-${project.name}`);
63
73
  }
64
74
  }
65
75
  const subdomain = project.getEnv("PAGEKITE_SUBDOMAIN");
66
- container = await makes_1.Docker.createContainer({
76
+ container = await this.dockerService.createContainer({
67
77
  name: `pagekite-${project.name}`,
68
78
  image: "ws-pagekite",
69
79
  tty: true,
@@ -93,14 +103,14 @@ class PageKitePlugin extends makes_1.Plugin {
93
103
  stream.end();
94
104
  }
95
105
  });
96
- await makes_1.Docker.attachStream(stream);
106
+ await this.dockerService.attachStream(stream);
97
107
  }
98
108
  async onProjectStop(project) {
99
109
  if (!project || project.getEnv("PAGEKITE_ENABLE", "false") !== "true") {
100
110
  return;
101
111
  }
102
112
  console.info("Pagekite stopping...");
103
- await makes_1.Docker.removeContainer(`pagekite-${project.name}`);
113
+ await this.dockerService.removeContainer(`pagekite-${project.name}`);
104
114
  }
105
115
  async init(options) {
106
116
  const project = await this.projectService.get();
@@ -130,7 +140,7 @@ class PageKitePlugin extends makes_1.Plugin {
130
140
  }
131
141
  const project = await this.projectService.get();
132
142
  if (restart) {
133
- await makes_1.Docker.removeContainer(`pagekite-${project.name}`);
143
+ await this.dockerService.removeContainer(`pagekite-${project.name}`);
134
144
  }
135
145
  await this.onProjectStart(project);
136
146
  }
@@ -144,18 +154,24 @@ class PageKitePlugin extends makes_1.Plugin {
144
154
  }
145
155
  async build(options = {}) {
146
156
  const { rebuild } = options;
147
- const exists = await makes_1.Docker.imageExists("ws-pagekite");
157
+ const exists = await this.dockerService.imageExists("ws-pagekite");
148
158
  if (rebuild) {
149
- await makes_1.Docker.removeContainer("ws-pagekite");
159
+ await this.dockerService.removeContainer("ws-pagekite");
150
160
  }
151
161
  if (!exists || rebuild) {
152
- const stream = await makes_1.Docker.imageBuild2({
162
+ await this.dockerService.buildImage({
153
163
  tag: "ws-pagekite",
154
164
  context: this.pluginPath(),
155
165
  src: "./Dockerfile"
156
166
  });
157
- await (0, utils_2.followProgress)(stream);
158
167
  }
159
168
  }
160
- }
169
+ };
161
170
  exports.PageKitePlugin = PageKitePlugin;
171
+ exports.PageKitePlugin = PageKitePlugin = __decorate([
172
+ (0, core_1.Controller)(),
173
+ __metadata("design:paramtypes", [services_1.AppConfigService,
174
+ services_1.AppEventsService,
175
+ services_1.ProjectService,
176
+ services_1.DockerService])
177
+ ], PageKitePlugin);
@@ -1,9 +1,12 @@
1
- import { Cli } from "@kearisp/cli";
2
- import { Plugin } from "../makes";
3
- export declare class ProxmoxPlugin extends Plugin {
1
+ import { FSManager } from "@wocker/core";
2
+ import { AppConfigService, DockerService } from "../services";
3
+ export declare class ProxmoxPlugin {
4
+ protected readonly appConfigService: AppConfigService;
5
+ protected readonly dockerService: DockerService;
4
6
  protected configDir: string;
5
- constructor();
6
- install(cli: Cli): void;
7
+ protected fs: FSManager;
8
+ constructor(appConfigService: AppConfigService, dockerService: DockerService);
9
+ pluginPath(...parts: string[]): string;
7
10
  up(): Promise<void>;
8
11
  down(): Promise<void>;
9
12
  }