@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.
- package/README.md +1 -1
- package/lib/App.d.ts +4 -3
- package/lib/App.js +98 -77
- package/lib/controllers/ImageController.d.ts +2 -2
- package/lib/controllers/ImageController.js +27 -27
- package/lib/controllers/PluginController.d.ts +2 -2
- package/lib/controllers/PluginController.js +78 -56
- package/lib/controllers/PresetController.d.ts +3 -1
- package/lib/controllers/PresetController.js +155 -136
- package/lib/controllers/ProjectController.d.ts +5 -5
- package/lib/controllers/ProjectController.js +653 -603
- package/lib/controllers/ProxyController.d.ts +4 -1
- package/lib/controllers/ProxyController.js +269 -245
- package/lib/controllers/index.js +19 -58
- package/lib/decorators/Inject.d.ts +1 -0
- package/lib/decorators/Inject.js +8 -0
- package/lib/decorators/Injectable.d.ts +4 -0
- package/lib/decorators/Injectable.js +17 -0
- package/lib/decorators/index.d.ts +1 -0
- package/lib/decorators/index.js +17 -0
- package/lib/env.js +33 -15
- package/lib/index.d.ts +3 -0
- package/lib/index.js +31 -16
- package/lib/makes/Controller.js +4 -8
- package/lib/makes/DI.d.ts +7 -0
- package/lib/makes/DI.js +27 -0
- package/lib/makes/Docker.js +298 -382
- package/lib/makes/FS.d.ts +3 -9
- package/lib/makes/FS.js +277 -305
- package/lib/makes/LineConvertStream.js +37 -40
- package/lib/makes/Logger.d.ts +9 -1
- package/lib/makes/Logger.js +22 -11
- package/lib/makes/Model.js +8 -12
- package/lib/makes/MySQL.js +6 -27
- package/lib/makes/Plugin.d.ts +1 -1
- package/lib/makes/Plugin.js +55 -37
- package/lib/makes/Preset.d.ts +46 -0
- package/lib/makes/Preset.js +33 -0
- package/lib/makes/Project.d.ts +45 -0
- package/lib/makes/Project.js +127 -0
- package/lib/makes/Repository.js +18 -21
- package/lib/makes/index.d.ts +3 -0
- package/lib/makes/index.js +23 -69
- package/lib/plugins/ElasticSearchPlugin.d.ts +3 -1
- package/lib/plugins/ElasticSearchPlugin.js +66 -66
- package/lib/plugins/LocaltunnelPlugin.d.ts +2 -2
- package/lib/plugins/LocaltunnelPlugin.js +256 -257
- package/lib/plugins/MaildevPlugin.d.ts +2 -2
- package/lib/plugins/MaildevPlugin.js +45 -44
- package/lib/plugins/MongodbPlugin.d.ts +2 -2
- package/lib/plugins/MongodbPlugin.js +303 -248
- package/lib/plugins/NgrokPlugin.d.ts +2 -2
- package/lib/plugins/NgrokPlugin.js +221 -231
- package/lib/plugins/PageKitePlugin.d.ts +2 -2
- package/lib/plugins/PageKitePlugin.js +150 -149
- package/lib/plugins/PostgresPlugin.d.ts +1 -1
- package/lib/plugins/PostgresPlugin.js +115 -89
- package/lib/plugins/ProxmoxPlugin.d.ts +1 -1
- package/lib/plugins/ProxmoxPlugin.js +50 -38
- package/lib/plugins/RedisPlugin.d.ts +3 -1
- package/lib/plugins/RedisPlugin.js +73 -72
- package/lib/plugins/index.js +25 -103
- package/lib/services/AppConfigService.d.ts +3 -3
- package/lib/services/AppConfigService.js +162 -157
- package/lib/services/AppEventsService.js +26 -24
- package/lib/services/DockerService.d.ts +37 -2
- package/lib/services/DockerService.js +185 -205
- package/lib/services/LogService.d.ts +3 -2
- package/lib/services/LogService.js +33 -34
- package/lib/services/PluginService.d.ts +2 -1
- package/lib/services/PluginService.js +11 -14
- package/lib/services/PresetService.d.ts +8 -3
- package/lib/services/PresetService.js +60 -59
- package/lib/services/ProjectService.d.ts +11 -4
- package/lib/services/ProjectService.js +140 -129
- package/lib/services/index.js +21 -80
- package/lib/types/Config.d.ts +4 -3
- package/lib/types/Config.js +1 -4
- package/lib/types/EnvConfig.js +1 -4
- package/lib/types/index.js +16 -25
- package/lib/utils/buildOptions.js +5 -8
- package/lib/utils/demuxOutput.js +16 -20
- package/lib/utils/escapeRegExp.js +4 -7
- package/lib/utils/exec.js +38 -39
- package/lib/utils/fetch.js +46 -30
- package/lib/utils/followProgress.js +66 -77
- package/lib/utils/format-size-units.js +16 -16
- package/lib/utils/get-config.d.ts +1 -1
- package/lib/utils/get-config.js +13 -16
- package/lib/utils/get-cursor-position.js +22 -29
- package/lib/utils/image-build.js +35 -23
- package/lib/utils/index.js +32 -191
- package/lib/utils/injectVariables.js +10 -13
- package/lib/utils/parse-table.js +20 -23
- package/lib/utils/set-config.d.ts +1 -1
- package/lib/utils/set-config.js +12 -15
- package/lib/utils/spawn.js +17 -20
- package/lib/utils/tty.js +2 -6
- package/lib/utils/volumeFormat.js +5 -12
- package/lib/utils/volumeParse.js +10 -13
- package/package.json +13 -39
- package/presets/bun/Dockerfile +11 -0
- package/presets/bun/config.json +3 -0
- package/presets/node/Dockerfile +4 -2
- package/presets/php-apache/Dockerfile +3 -2
- package/.github/workflows/publish.yml +0 -31
- package/plugins/mariadb/admin/conf/config.user.inc.php +0 -9
|
@@ -1,275 +1,274 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
-
|
|
149
|
-
|
|
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
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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
|
-
|
|
233
|
-
|
|
234
|
-
|
|
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
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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 "
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
class MaildevPlugin extends
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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 "
|
|
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;
|