@wocker/ws 1.0.2 → 1.0.4

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 (107) hide show
  1. package/README.md +1 -1
  2. package/lib/App.d.ts +4 -3
  3. package/lib/App.js +98 -77
  4. package/lib/controllers/ImageController.d.ts +2 -2
  5. package/lib/controllers/ImageController.js +27 -27
  6. package/lib/controllers/PluginController.d.ts +2 -2
  7. package/lib/controllers/PluginController.js +78 -56
  8. package/lib/controllers/PresetController.d.ts +3 -1
  9. package/lib/controllers/PresetController.js +155 -136
  10. package/lib/controllers/ProjectController.d.ts +5 -5
  11. package/lib/controllers/ProjectController.js +653 -603
  12. package/lib/controllers/ProxyController.d.ts +4 -1
  13. package/lib/controllers/ProxyController.js +269 -245
  14. package/lib/controllers/index.js +19 -58
  15. package/lib/decorators/Inject.d.ts +1 -0
  16. package/lib/decorators/Inject.js +8 -0
  17. package/lib/decorators/Injectable.d.ts +4 -0
  18. package/lib/decorators/Injectable.js +17 -0
  19. package/lib/decorators/index.d.ts +1 -0
  20. package/lib/decorators/index.js +17 -0
  21. package/lib/env.js +33 -15
  22. package/lib/index.d.ts +3 -0
  23. package/lib/index.js +31 -16
  24. package/lib/makes/Controller.js +4 -8
  25. package/lib/makes/DI.d.ts +7 -0
  26. package/lib/makes/DI.js +27 -0
  27. package/lib/makes/Docker.js +298 -382
  28. package/lib/makes/FS.d.ts +3 -9
  29. package/lib/makes/FS.js +277 -305
  30. package/lib/makes/LineConvertStream.js +37 -40
  31. package/lib/makes/Logger.d.ts +9 -1
  32. package/lib/makes/Logger.js +22 -11
  33. package/lib/makes/Model.js +8 -12
  34. package/lib/makes/MySQL.js +6 -27
  35. package/lib/makes/Plugin.d.ts +1 -1
  36. package/lib/makes/Plugin.js +55 -37
  37. package/lib/makes/Preset.d.ts +46 -0
  38. package/lib/makes/Preset.js +33 -0
  39. package/lib/makes/Project.d.ts +45 -0
  40. package/lib/makes/Project.js +127 -0
  41. package/lib/makes/Repository.js +18 -21
  42. package/lib/makes/index.d.ts +3 -0
  43. package/lib/makes/index.js +23 -69
  44. package/lib/plugins/ElasticSearchPlugin.d.ts +3 -1
  45. package/lib/plugins/ElasticSearchPlugin.js +66 -66
  46. package/lib/plugins/LocaltunnelPlugin.d.ts +2 -2
  47. package/lib/plugins/LocaltunnelPlugin.js +256 -257
  48. package/lib/plugins/MaildevPlugin.d.ts +2 -2
  49. package/lib/plugins/MaildevPlugin.js +45 -44
  50. package/lib/plugins/MongodbPlugin.d.ts +2 -2
  51. package/lib/plugins/MongodbPlugin.js +303 -248
  52. package/lib/plugins/NgrokPlugin.d.ts +2 -2
  53. package/lib/plugins/NgrokPlugin.js +221 -231
  54. package/lib/plugins/PageKitePlugin.d.ts +2 -2
  55. package/lib/plugins/PageKitePlugin.js +150 -149
  56. package/lib/plugins/PostgresPlugin.d.ts +1 -1
  57. package/lib/plugins/PostgresPlugin.js +115 -89
  58. package/lib/plugins/ProxmoxPlugin.d.ts +1 -1
  59. package/lib/plugins/ProxmoxPlugin.js +50 -38
  60. package/lib/plugins/RedisPlugin.d.ts +3 -1
  61. package/lib/plugins/RedisPlugin.js +73 -72
  62. package/lib/plugins/index.js +25 -103
  63. package/lib/services/AppConfigService.d.ts +3 -3
  64. package/lib/services/AppConfigService.js +162 -157
  65. package/lib/services/AppEventsService.js +26 -24
  66. package/lib/services/DockerService.d.ts +37 -2
  67. package/lib/services/DockerService.js +185 -205
  68. package/lib/services/LogService.d.ts +3 -2
  69. package/lib/services/LogService.js +33 -34
  70. package/lib/services/PluginService.d.ts +2 -1
  71. package/lib/services/PluginService.js +11 -14
  72. package/lib/services/PresetService.d.ts +8 -3
  73. package/lib/services/PresetService.js +60 -59
  74. package/lib/services/ProjectService.d.ts +11 -4
  75. package/lib/services/ProjectService.js +140 -129
  76. package/lib/services/index.js +21 -80
  77. package/lib/types/Config.d.ts +4 -3
  78. package/lib/types/Config.js +1 -4
  79. package/lib/types/EnvConfig.js +1 -4
  80. package/lib/types/index.js +16 -25
  81. package/lib/utils/buildOptions.js +5 -8
  82. package/lib/utils/demuxOutput.js +16 -20
  83. package/lib/utils/escapeRegExp.js +4 -7
  84. package/lib/utils/exec.js +38 -39
  85. package/lib/utils/fetch.js +46 -30
  86. package/lib/utils/followProgress.js +66 -77
  87. package/lib/utils/format-size-units.js +16 -16
  88. package/lib/utils/get-config.d.ts +1 -1
  89. package/lib/utils/get-config.js +13 -16
  90. package/lib/utils/get-cursor-position.js +22 -29
  91. package/lib/utils/image-build.js +35 -23
  92. package/lib/utils/index.js +32 -191
  93. package/lib/utils/injectVariables.js +10 -13
  94. package/lib/utils/parse-table.js +20 -23
  95. package/lib/utils/set-config.d.ts +1 -1
  96. package/lib/utils/set-config.js +12 -15
  97. package/lib/utils/spawn.js +17 -20
  98. package/lib/utils/tty.js +2 -6
  99. package/lib/utils/volumeFormat.js +5 -12
  100. package/lib/utils/volumeParse.js +10 -13
  101. package/package.json +13 -39
  102. package/presets/bun/Dockerfile +11 -0
  103. package/presets/bun/config.json +3 -0
  104. package/presets/node/Dockerfile +4 -2
  105. package/presets/php-apache/Dockerfile +3 -2
  106. package/.github/workflows/publish.yml +0 -31
  107. package/plugins/mariadb/admin/conf/config.user.inc.php +0 -9
@@ -1,275 +1,274 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.LocaltunnelPlugin = void 0;
7
- var _core = require("@wocker/core");
8
- var _utils = require("@wocker/utils");
9
- var _axios = _interopRequireDefault(require("axios"));
10
- var _makes = require("../makes");
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
- class LocaltunnelPlugin extends _makes.Plugin {
13
- constructor(di) {
14
- super("localtunnel");
15
- this.appConfigService = di.resolveService(_core.AppConfigService);
16
- this.appEventsService = di.resolveService(_core.AppEventsService);
17
- this.projectService = di.resolveService(_core.ProjectService);
18
- this.dockerService = di.resolveService(_core.DockerService);
19
- }
20
- install(cli) {
21
- super.install(cli);
22
- this.appEventsService.on("project:start", project => this.onProjectStart(project));
23
- this.appEventsService.on("project:stop", project => this.onProjectStop(project));
24
- cli.command("localtunnel:init").option("name", {
25
- alias: "n",
26
- type: "string",
27
- description: "Project name"
28
- }).action(options => this.init(options));
29
- cli.command("localtunnel:start").option("name", {
30
- alias: "n",
31
- type: "string",
32
- description: "Project name"
33
- }).option("detach", {
34
- type: "boolean",
35
- alias: "d",
36
- description: "Detach"
37
- }).action(options => this.start(options));
38
- cli.command("localtunnel:restart").option("name", {
39
- alias: "n",
40
- type: "string",
41
- description: "Project name"
42
- }).option("detach", {
43
- type: "boolean",
44
- alias: "d",
45
- description: "Detach"
46
- }).action(options => this.restart(options));
47
- cli.command("localtunnel:stop").option("name", {
48
- alias: "n",
49
- type: "string",
50
- description: "Project name"
51
- }).action(options => this.stop(options));
52
- cli.command("localtunnel:build").action(() => this.build());
53
- cli.command("localtunnel:rebuild").action(() => this.rebuild());
54
- cli.command("localtunnel:logs").option("name", {
55
- alias: "n",
56
- type: "string",
57
- description: "Project name"
58
- }).option("detach", {
59
- type: "boolean",
60
- alias: "d",
61
- description: "Detach"
62
- }).action(options => this.logs(options));
63
- }
64
- async getIp() {
65
- const res = await _axios.default.get("https://ipv4.icanhazip.com");
66
- return res.data.replace("\n", "");
67
- }
68
- async onProjectStart(project) {
69
- if (!project || project.getEnv("LOCALTUNNEL_ENABLE", "false") !== "true") {
70
- return;
7
+ const utils_1 = require("@wocker/utils");
8
+ const axios_1 = __importDefault(require("axios"));
9
+ const makes_1 = require("../makes");
10
+ 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);
71
18
  }
72
- let container = await this.dockerService.getContainer(`localtunnel-${project.name}`);
73
- if (container) {
74
- const {
75
- State: {
76
- Running
77
- }
78
- } = await container.inspect();
79
- if (Running) {
80
- console.info("Localtunnel is already running");
81
- return;
82
- } else {
83
- await this.dockerService.removeContainer(`localtunnel-${project.name}`);
84
- }
19
+ install(cli) {
20
+ super.install(cli);
21
+ this.appEventsService.on("project:start", (project) => this.onProjectStart(project));
22
+ this.appEventsService.on("project:stop", (project) => this.onProjectStop(project));
23
+ cli.command("localtunnel:init")
24
+ .option("name", {
25
+ alias: "n",
26
+ type: "string",
27
+ description: "Project name"
28
+ })
29
+ .action((options) => this.init(options));
30
+ cli.command("localtunnel:start")
31
+ .option("name", {
32
+ alias: "n",
33
+ type: "string",
34
+ description: "Project name"
35
+ })
36
+ .option("detach", {
37
+ type: "boolean",
38
+ alias: "d",
39
+ description: "Detach"
40
+ })
41
+ .action((options) => this.start(options));
42
+ cli.command("localtunnel:restart")
43
+ .option("name", {
44
+ alias: "n",
45
+ type: "string",
46
+ description: "Project name"
47
+ })
48
+ .option("detach", {
49
+ type: "boolean",
50
+ alias: "d",
51
+ description: "Detach"
52
+ })
53
+ .action((options) => this.restart(options));
54
+ cli.command("localtunnel:stop")
55
+ .option("name", {
56
+ alias: "n",
57
+ type: "string",
58
+ description: "Project name"
59
+ })
60
+ .action((options) => this.stop(options));
61
+ cli.command("localtunnel:build")
62
+ .action(() => this.build());
63
+ cli.command("localtunnel:rebuild")
64
+ .action(() => this.rebuild());
65
+ cli.command("localtunnel:logs")
66
+ .option("name", {
67
+ alias: "n",
68
+ type: "string",
69
+ description: "Project name"
70
+ })
71
+ .option("detach", {
72
+ type: "boolean",
73
+ alias: "d",
74
+ description: "Detach"
75
+ })
76
+ .action((options) => this.logs(options));
77
+ }
78
+ async getIp() {
79
+ const res = await axios_1.default.get("https://ipv4.icanhazip.com");
80
+ return res.data.replace("\n", "");
85
81
  }
86
- console.info("Localtunnel starting...");
87
- _core.Logger.info(`Localtunnel start: ${project.name}`);
88
- await this.build();
89
- const subdomain = project.getEnv("LOCALTUNNEL_SUBDOMAIN", project.name);
90
- container = await this.dockerService.createContainer({
91
- name: `localtunnel-${project.name}`,
92
- image: "ws-localtunnel",
93
- // tty: true,
94
- restart: "always",
95
- networkMode: "host",
96
- cmd: ["lt", `--port=80`,
97
- // `--local-host=${project.name}.workspace`,
98
- `--subdomain=${subdomain}`, "--print-requests"]
99
- });
100
- const stream = await container.attach({
101
- logs: true,
102
- stream: true,
103
- hijack: true,
104
- stdin: true,
105
- stdout: true,
106
- stderr: true
107
- });
108
- stream.setEncoding("utf8");
109
- await container.start();
110
- const link = await new Promise((resolve, reject) => {
111
- let res = "";
112
- stream.on("data", data => {
113
- const regLink = /(https?):\/\/(\w[\w.-]+[a-z]|\d+\.\d+\.\d+\.\d+)(?::(\d+))?/;
114
- if (regLink.test(data.toString())) {
115
- const [link] = regLink.exec(data.toString());
116
- if (link.includes(".loca.lt")) {
117
- res = link;
118
- stream.end();
119
- }
82
+ async onProjectStart(project) {
83
+ if (!project || project.getEnv("LOCALTUNNEL_ENABLE", "false") !== "true") {
84
+ return;
120
85
  }
121
- });
122
- stream.on("end", () => resolve(res));
123
- stream.on("error", reject);
124
- });
125
- _core.Logger.info(`${project.name} localtunnel forwarding: ${link}`);
126
- const ip = await this.getIp();
127
- console.info(`IP: ${ip}`);
128
- console.info(`Forwarding: ${link}`);
129
- if (project.getEnv("LOCALTUNNEL_AUTO_CONFIRM", "false") === "true") {
130
- console.info("Skipping IP confirmation...");
131
- const res = await _axios.default.get(link, {
132
- headers: {
133
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36"
134
- },
135
- validateStatus: () => true
136
- });
137
- const [path] = /\/continue\/[\w.]+/.exec(res.data) || [];
138
- if (path) {
139
- const sendData = new URLSearchParams({
140
- endpoint: ip
86
+ let container = await this.dockerService.getContainer(`localtunnel-${project.name}`);
87
+ if (container) {
88
+ const { State: { Running } } = await container.inspect();
89
+ if (Running) {
90
+ console.info("Localtunnel is already running");
91
+ return;
92
+ }
93
+ else {
94
+ await this.dockerService.removeContainer(`localtunnel-${project.name}`);
95
+ }
96
+ }
97
+ console.info("Localtunnel starting...");
98
+ makes_1.Logger.info(`Localtunnel start: ${project.name}`);
99
+ await this.build();
100
+ const subdomain = project.getEnv("LOCALTUNNEL_SUBDOMAIN", project.name);
101
+ container = await this.dockerService.createContainer({
102
+ name: `localtunnel-${project.name}`,
103
+ image: "ws-localtunnel",
104
+ restart: "always",
105
+ networkMode: "host",
106
+ cmd: [
107
+ "lt",
108
+ `--port=80`,
109
+ `--subdomain=${subdomain}`,
110
+ "--print-requests"
111
+ ]
112
+ });
113
+ const stream = await container.attach({
114
+ logs: true,
115
+ stream: true,
116
+ hijack: true,
117
+ stdin: true,
118
+ stdout: true,
119
+ stderr: true
141
120
  });
142
- const res = await _axios.default.post(`${link}${path}`, sendData.toString(), {
143
- headers: {
144
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",
145
- "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
146
- }
121
+ stream.setEncoding("utf8");
122
+ await container.start();
123
+ const link = await new Promise((resolve, reject) => {
124
+ let res = "";
125
+ stream.on("data", (data) => {
126
+ const regLink = /(https?):\/\/(\w[\w.-]+[a-z]|\d+\.\d+\.\d+\.\d+)(?::(\d+))?/;
127
+ if (regLink.test(data.toString())) {
128
+ const [link] = regLink.exec(data.toString());
129
+ if (link.includes(".loca.lt")) {
130
+ res = link;
131
+ stream.end();
132
+ }
133
+ }
134
+ });
135
+ stream.on("end", () => resolve(res));
136
+ stream.on("error", reject);
147
137
  });
148
- if (res.status === 200) {
149
- console.info("IP confirmed");
138
+ makes_1.Logger.info(`${project.name} localtunnel forwarding: ${link}`);
139
+ const ip = await this.getIp();
140
+ console.info(`IP: ${ip}`);
141
+ console.info(`Forwarding: ${link}`);
142
+ if (project.getEnv("LOCALTUNNEL_AUTO_CONFIRM", "false") === "true") {
143
+ console.info("Skipping IP confirmation...");
144
+ const res = await axios_1.default.get(link, {
145
+ headers: {
146
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36"
147
+ },
148
+ validateStatus: () => true
149
+ });
150
+ const [path] = /\/continue\/[\w.]+/.exec(res.data) || [];
151
+ if (path) {
152
+ const sendData = new URLSearchParams({
153
+ endpoint: ip
154
+ });
155
+ const res = await axios_1.default.post(`${link}${path}`, sendData.toString(), {
156
+ headers: {
157
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",
158
+ "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
159
+ }
160
+ });
161
+ if (res.status === 200) {
162
+ console.info("IP confirmed");
163
+ }
164
+ }
150
165
  }
151
- }
152
- }
153
- }
154
- async onProjectStop(project) {
155
- if (!project || project.getEnv("LOCALTUNNEL_ENABLE", "false") !== "true") {
156
- return;
157
166
  }
158
- console.info("Localtunnel stopping...");
159
- await this.dockerService.removeContainer(`localtunnel-${project.name}`);
160
- }
161
- async build() {
162
- const exists = await this.dockerService.imageExists("ws-localtunnel");
163
- if (!exists) {
164
- await this.dockerService.buildImage({
165
- tag: "ws-localtunnel",
166
- context: this.pluginPath(),
167
- src: "./Dockerfile"
168
- });
169
- }
170
- }
171
- async rebuild() {
172
- try {
173
- await this.dockerService.imageRm("ws-localtunnel");
174
- } catch (err) {
175
- console.info(err.message);
167
+ async onProjectStop(project) {
168
+ if (!project || project.getEnv("LOCALTUNNEL_ENABLE", "false") !== "true") {
169
+ return;
170
+ }
171
+ console.info("Localtunnel stopping...");
172
+ await this.dockerService.removeContainer(`localtunnel-${project.name}`);
176
173
  }
177
- await this.build();
178
- }
179
- async init(options) {
180
- const {
181
- name
182
- } = options;
183
- if (name) {
184
- await this.projectService.cdProject(name);
174
+ async build() {
175
+ const exists = await this.dockerService.imageExists("ws-localtunnel");
176
+ if (!exists) {
177
+ await this.dockerService.buildImage({
178
+ tag: "ws-localtunnel",
179
+ context: this.pluginPath(),
180
+ src: "./Dockerfile"
181
+ });
182
+ }
185
183
  }
186
- const project = await this.projectService.get();
187
- const enabled = await (0, _utils.promptConfirm)({
188
- message: "Enable localtunnel?",
189
- default: project.getEnv("LOCALTUNNEL_ENABLE", "false") === "true"
190
- });
191
- if (enabled) {
192
- const subdomain = await (0, _utils.promptText)({
193
- message: "Subdomain",
194
- prefix: "https://",
195
- suffix: ".loca.lt",
196
- default: project.getEnv("LOCALTUNNEL_SUBDOMAIN")
197
- });
198
- if (!subdomain) {
199
- throw new Error("Subdomain can't be empty");
200
- }
201
- const autoConfirmIP = await (0, _utils.promptConfirm)({
202
- message: "Do you want to skip the IP confirmation form automatically?",
203
- default: project.getEnv("LOCALTUNNEL_AUTO_CONFIRM", "true") === "true"
204
- });
205
- project.setEnv("LOCALTUNNEL_ENABLE", "true");
206
- project.setEnv("LOCALTUNNEL_SUBDOMAIN", subdomain);
207
- project.setEnv("LOCALTUNNEL_AUTO_CONFIRM", autoConfirmIP ? "true" : "false");
208
- } else {
209
- project.setEnv("LOCALTUNNEL_ENABLE", "false");
184
+ async rebuild() {
185
+ try {
186
+ await this.dockerService.imageRm("ws-localtunnel");
187
+ }
188
+ catch (err) {
189
+ console.info(err.message);
190
+ }
191
+ await this.build();
210
192
  }
211
- await project.save();
212
- }
213
- async start(options) {
214
- const {
215
- name,
216
- detach
217
- } = options;
218
- if (name) {
219
- await this.projectService.cdProject(name);
193
+ async init(options) {
194
+ const { name } = options;
195
+ if (name) {
196
+ await this.projectService.cdProject(name);
197
+ }
198
+ const project = await this.projectService.get();
199
+ const enabled = await (0, utils_1.promptConfirm)({
200
+ message: "Enable localtunnel?",
201
+ default: project.getEnv("LOCALTUNNEL_ENABLE", "false") === "true"
202
+ });
203
+ if (enabled) {
204
+ const subdomain = await (0, utils_1.promptText)({
205
+ message: "Subdomain",
206
+ prefix: "https://",
207
+ suffix: ".loca.lt",
208
+ default: project.getEnv("LOCALTUNNEL_SUBDOMAIN")
209
+ });
210
+ if (!subdomain) {
211
+ throw new Error("Subdomain can't be empty");
212
+ }
213
+ const autoConfirmIP = await (0, utils_1.promptConfirm)({
214
+ message: "Do you want to skip the IP confirmation form automatically?",
215
+ default: project.getEnv("LOCALTUNNEL_AUTO_CONFIRM", "true") === "true"
216
+ });
217
+ project.setEnv("LOCALTUNNEL_ENABLE", "true");
218
+ project.setEnv("LOCALTUNNEL_SUBDOMAIN", subdomain);
219
+ project.setEnv("LOCALTUNNEL_AUTO_CONFIRM", autoConfirmIP ? "true" : "false");
220
+ }
221
+ else {
222
+ project.setEnv("LOCALTUNNEL_ENABLE", "false");
223
+ }
224
+ await project.save();
220
225
  }
221
- const project = await this.projectService.get();
222
- if (project.getEnv("LOCALTUNNEL_ENABLE", "false") !== "true") {
223
- throw new Error(`Localtunnel is not initialized. Run "ws localtunnel:init${name ? ` -n=${name}` : ""}" first.`);
226
+ async start(options) {
227
+ const { name, detach } = options;
228
+ if (name) {
229
+ await this.projectService.cdProject(name);
230
+ }
231
+ const project = await this.projectService.get();
232
+ if (project.getEnv("LOCALTUNNEL_ENABLE", "false") !== "true") {
233
+ throw new Error(`Localtunnel is not initialized. Run "ws localtunnel:init${name ? ` -n=${name}` : ""}" first.`);
234
+ }
235
+ await this.onProjectStart(project);
236
+ if (!detach) {
237
+ await this.logs({ name });
238
+ }
224
239
  }
225
- await this.onProjectStart(project);
226
- if (!detach) {
227
- await this.logs({
228
- name
229
- });
240
+ async stop(options) {
241
+ const { name } = options;
242
+ if (name) {
243
+ await this.projectService.cdProject(name);
244
+ }
245
+ const project = await this.projectService.get();
246
+ await this.onProjectStop(project);
230
247
  }
231
- }
232
- async stop(options) {
233
- const {
234
- name
235
- } = options;
236
- if (name) {
237
- await this.projectService.cdProject(name);
248
+ async restart(options) {
249
+ const { name } = options;
250
+ await this.stop({ name });
251
+ await this.start(options);
238
252
  }
239
- const project = await this.projectService.get();
240
- await this.onProjectStop(project);
241
- }
242
- async restart(options) {
243
- const {
244
- name
245
- } = options;
246
- await this.stop({
247
- name
248
- });
249
- await this.start(options);
250
- }
251
- async logs(options) {
252
- const {
253
- name
254
- // detach
255
- } = options;
256
- if (name) {
257
- await this.projectService.cdProject(name);
253
+ async logs(options) {
254
+ const { name, } = options;
255
+ if (name) {
256
+ await this.projectService.cdProject(name);
257
+ }
258
+ const project = await this.projectService.get();
259
+ const container = await this.dockerService.getContainer(`localtunnel-${project.name}`);
260
+ const stream = await container.logs({
261
+ follow: true,
262
+ stderr: true,
263
+ stdout: true,
264
+ tail: 5
265
+ });
266
+ stream.on("data", (data) => {
267
+ process.stdout.write(data);
268
+ });
269
+ stream.on("error", (data) => {
270
+ process.stderr.write(data);
271
+ });
258
272
  }
259
- const project = await this.projectService.get();
260
- const container = await this.dockerService.getContainer(`localtunnel-${project.name}`);
261
- const stream = await container.logs({
262
- follow: true,
263
- stderr: true,
264
- stdout: true,
265
- tail: 5
266
- });
267
- stream.on("data", data => {
268
- process.stdout.write(data);
269
- });
270
- stream.on("error", data => {
271
- process.stderr.write(data);
272
- });
273
- }
274
273
  }
275
- exports.LocaltunnelPlugin = LocaltunnelPlugin;
274
+ exports.LocaltunnelPlugin = LocaltunnelPlugin;
@@ -1,6 +1,6 @@
1
- import { DI, DockerService } from "@wocker/core";
2
1
  import { Cli } from "@kearisp/cli";
3
- import { Plugin } from "src/makes";
2
+ import { DI, Plugin } from "../makes";
3
+ import { DockerService } from "../services";
4
4
  declare class MaildevPlugin extends Plugin {
5
5
  protected containerName: string;
6
6
  protected dockerService: DockerService;
@@ -1,48 +1,49 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.MaildevPlugin = void 0;
7
- var _core = require("@wocker/core");
8
- var _makes = require("../makes");
9
- class MaildevPlugin extends _makes.Plugin {
10
- containerName = "maildev.workspace";
11
- constructor(di) {
12
- super("maildev");
13
- this.dockerService = di.resolveService(_core.DockerService);
14
- }
15
- install(cli) {
16
- super.install(cli);
17
- cli.command("maildev:start").action(() => this.start());
18
- cli.command("maildev:stop").action(() => this.stop());
19
- }
20
- async start() {
21
- console.log("Maildev starting...");
22
- const imageName = "ws-maildev";
23
- if (!(await this.dockerService.imageExists(imageName))) {
24
- await this.dockerService.buildImage({
25
- tag: "ws-maildev",
26
- buildArgs: {},
27
- labels: {},
28
- context: this.pluginPath(),
29
- src: "./Dockerfile"
30
- });
4
+ const makes_1 = require("../makes");
5
+ const services_1 = require("../services");
6
+ class MaildevPlugin extends makes_1.Plugin {
7
+ constructor(di) {
8
+ super("maildev");
9
+ this.containerName = "maildev.workspace";
10
+ this.dockerService = di.resolveService(services_1.DockerService);
11
+ }
12
+ install(cli) {
13
+ super.install(cli);
14
+ cli.command("maildev:start")
15
+ .action(() => this.start());
16
+ cli.command("maildev:stop")
17
+ .action(() => this.stop());
18
+ }
19
+ async start() {
20
+ console.log("Maildev starting...");
21
+ const imageName = "ws-maildev";
22
+ if (!await this.dockerService.imageExists(imageName)) {
23
+ await this.dockerService.buildImage({
24
+ tag: "ws-maildev",
25
+ buildArgs: {},
26
+ labels: {},
27
+ context: this.pluginPath(),
28
+ src: "./Dockerfile"
29
+ });
30
+ }
31
+ let container = await this.dockerService.createContainer({
32
+ name: this.containerName,
33
+ restart: "always",
34
+ env: {
35
+ VIRTUAL_HOST: "maildev.workspace"
36
+ },
37
+ ports: [
38
+ "25:25"
39
+ ],
40
+ image: imageName
41
+ });
42
+ await container.start();
43
+ }
44
+ async stop() {
45
+ console.log("Maildev stopping...");
46
+ await this.dockerService.removeContainer(this.containerName);
31
47
  }
32
- let container = await this.dockerService.createContainer({
33
- name: this.containerName,
34
- restart: "always",
35
- env: {
36
- VIRTUAL_HOST: "maildev.workspace"
37
- },
38
- ports: ["25:25"],
39
- image: imageName
40
- });
41
- await container.start();
42
- }
43
- async stop() {
44
- console.log("Maildev stopping...");
45
- await this.dockerService.removeContainer(this.containerName);
46
- }
47
48
  }
48
- exports.MaildevPlugin = MaildevPlugin;
49
+ exports.MaildevPlugin = MaildevPlugin;
@@ -1,6 +1,6 @@
1
- import { DI, DockerService } from "@wocker/core";
2
1
  import { Cli } from "@kearisp/cli";
3
- import { Plugin } from "src/makes";
2
+ import { DI, Plugin } from "../makes";
3
+ import { DockerService } from "../services";
4
4
  declare class MongodbPlugin extends Plugin {
5
5
  protected container: string;
6
6
  protected adminContainer: string;