@wocker/ws 1.0.1 → 1.0.3
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 +11 -137
- package/bin/ws.js +7 -3
- package/lib/App.d.ts +10 -7
- package/lib/App.js +99 -44
- package/lib/controllers/ImageController.d.ts +4 -2
- package/lib/controllers/ImageController.js +27 -25
- package/lib/controllers/PluginController.d.ts +14 -0
- package/lib/controllers/PluginController.js +84 -0
- package/lib/controllers/PresetController.d.ts +21 -0
- package/lib/controllers/PresetController.js +169 -0
- package/lib/controllers/ProjectController.d.ts +11 -3
- package/lib/controllers/ProjectController.js +653 -536
- package/lib/{plugins/ProxyPlugin.d.ts → controllers/ProxyController.d.ts} +12 -11
- package/lib/controllers/ProxyController.js +273 -0
- package/lib/controllers/index.d.ts +3 -0
- package/lib/controllers/index.js +19 -25
- package/lib/env.js +33 -22
- package/lib/index.d.ts +2 -0
- package/lib/index.js +29 -28
- 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 +299 -397
- package/lib/makes/FS.d.ts +1 -1
- package/lib/makes/FS.js +328 -301
- package/lib/makes/LineConvertStream.js +37 -40
- package/lib/makes/Logger.d.ts +5 -3
- package/lib/makes/Logger.js +18 -34
- 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/{models → makes}/Project.d.ts +23 -16
- 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 +18 -0
- package/lib/plugins/ElasticSearchPlugin.js +72 -0
- package/lib/plugins/LocaltunnelPlugin.d.ts +4 -4
- package/lib/plugins/LocaltunnelPlugin.js +256 -255
- package/lib/plugins/MaildevPlugin.d.ts +4 -2
- package/lib/plugins/MaildevPlugin.js +45 -41
- package/lib/plugins/MongodbPlugin.d.ts +6 -4
- package/lib/plugins/MongodbPlugin.js +303 -254
- package/lib/plugins/NgrokPlugin.d.ts +3 -4
- package/lib/plugins/NgrokPlugin.js +221 -230
- package/lib/plugins/PageKitePlugin.d.ts +3 -4
- package/lib/plugins/PageKitePlugin.js +150 -147
- package/lib/plugins/PostgresPlugin.d.ts +1 -1
- package/lib/plugins/PostgresPlugin.js +115 -88
- package/lib/plugins/ProxmoxPlugin.d.ts +1 -1
- package/lib/plugins/ProxmoxPlugin.js +50 -38
- package/lib/plugins/RedisPlugin.d.ts +10 -2
- package/lib/plugins/RedisPlugin.js +77 -39
- package/lib/plugins/index.d.ts +2 -6
- package/lib/plugins/index.js +25 -158
- package/lib/services/AppConfigService.d.ts +13 -3
- package/lib/services/AppConfigService.js +161 -71
- package/lib/services/AppEventsService.d.ts +5 -8
- package/lib/services/AppEventsService.js +26 -25
- package/lib/services/DockerService.d.ts +51 -0
- package/lib/services/DockerService.js +200 -0
- package/lib/services/LogService.d.ts +12 -0
- package/lib/services/LogService.js +38 -0
- package/lib/services/PluginService.d.ts +11 -0
- package/lib/services/PluginService.js +15 -0
- package/lib/services/PresetService.d.ts +14 -0
- package/lib/services/PresetService.js +64 -0
- package/lib/services/ProjectService.d.ts +12 -4
- package/lib/services/ProjectService.js +141 -78
- package/lib/services/index.d.ts +4 -0
- package/lib/services/index.js +21 -36
- 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 -22
- package/lib/utils/escapeRegExp.js +4 -7
- package/lib/utils/exec.d.ts +1 -1
- package/lib/utils/exec.js +38 -40
- package/lib/utils/fetch.js +45 -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.d.ts +0 -4
- package/lib/utils/index.js +32 -235
- 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 +21 -47
- package/presets/bun/Dockerfile +11 -0
- package/presets/bun/config.json +3 -0
- package/presets/node/Dockerfile +4 -2
- package/presets/node/config.json +9 -7
- package/presets/php-apache/Dockerfile +40 -38
- package/presets/php-apache/config.json +10 -15
- package/presets/php-fpm/Dockerfile +21 -0
- package/presets/php-fpm/config.json +25 -0
- package/lib/models/Preset.d.ts +0 -19
- package/lib/models/Preset.js +0 -60
- package/lib/models/Project.js +0 -151
- package/lib/models/index.d.ts +0 -2
- package/lib/models/index.js +0 -27
- package/lib/plugins/MariadbPlugin.d.ts +0 -25
- package/lib/plugins/MariadbPlugin.js +0 -297
- package/lib/plugins/PresetPlugin.d.ts +0 -19
- package/lib/plugins/PresetPlugin.js +0 -164
- package/lib/plugins/ProjectPlugin.d.ts +0 -12
- package/lib/plugins/ProjectPlugin.js +0 -54
- package/lib/plugins/ProxyPlugin.js +0 -257
- package/lib/plugins/ServeoPlugin.d.ts +0 -36
- package/lib/plugins/ServeoPlugin.js +0 -260
- package/lib/plugins/TestPlugin.d.ts +0 -10
- package/lib/plugins/TestPlugin.js +0 -75
- package/lib/utils/promptConfirm.d.ts +0 -6
- package/lib/utils/promptConfirm.js +0 -21
- package/lib/utils/promptGroup.d.ts +0 -16
- package/lib/utils/promptGroup.js +0 -39
- package/lib/utils/promptSelect.d.ts +0 -12
- package/lib/utils/promptSelect.js +0 -47
- package/lib/utils/promptText.d.ts +0 -13
- package/lib/utils/promptText.js +0 -53
- package/plugins/mariadb/admin/conf/config.user.inc.php +0 -9
- package/plugins/serveo/Dockerfile +0 -17
|
@@ -1,273 +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
|
-
class LocaltunnelPlugin extends
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
install(cli) {
|
|
19
|
-
super.install(cli);
|
|
20
|
-
this.appEventsService.on("project:start", project => this.onProjectStart(project));
|
|
21
|
-
this.appEventsService.on("project:stop", project => this.onProjectStop(project));
|
|
22
|
-
cli.command("localtunnel:init").option("name", {
|
|
23
|
-
alias: "n",
|
|
24
|
-
type: "string",
|
|
25
|
-
description: "Project name"
|
|
26
|
-
}).action(options => this.init(options));
|
|
27
|
-
cli.command("localtunnel:start").option("name", {
|
|
28
|
-
alias: "n",
|
|
29
|
-
type: "string",
|
|
30
|
-
description: "Project name"
|
|
31
|
-
}).option("detach", {
|
|
32
|
-
type: "boolean",
|
|
33
|
-
alias: "d",
|
|
34
|
-
description: "Detach"
|
|
35
|
-
}).action(options => this.start(options));
|
|
36
|
-
cli.command("localtunnel:restart").option("name", {
|
|
37
|
-
alias: "n",
|
|
38
|
-
type: "string",
|
|
39
|
-
description: "Project name"
|
|
40
|
-
}).option("detach", {
|
|
41
|
-
type: "boolean",
|
|
42
|
-
alias: "d",
|
|
43
|
-
description: "Detach"
|
|
44
|
-
}).action(options => this.restart(options));
|
|
45
|
-
cli.command("localtunnel:stop").option("name", {
|
|
46
|
-
alias: "n",
|
|
47
|
-
type: "string",
|
|
48
|
-
description: "Project name"
|
|
49
|
-
}).action(options => this.stop(options));
|
|
50
|
-
cli.command("localtunnel:build").action(() => this.build());
|
|
51
|
-
cli.command("localtunnel:rebuild").action(() => this.rebuild());
|
|
52
|
-
cli.command("localtunnel:logs").option("name", {
|
|
53
|
-
alias: "n",
|
|
54
|
-
type: "string",
|
|
55
|
-
description: "Project name"
|
|
56
|
-
}).option("detach", {
|
|
57
|
-
type: "boolean",
|
|
58
|
-
alias: "d",
|
|
59
|
-
description: "Detach"
|
|
60
|
-
}).action(options => this.logs(options));
|
|
61
|
-
}
|
|
62
|
-
async getIp() {
|
|
63
|
-
const res = await _axios.default.get("https://ipv4.icanhazip.com");
|
|
64
|
-
return res.data.replace("\n", "");
|
|
65
|
-
}
|
|
66
|
-
async onProjectStart(project) {
|
|
67
|
-
if (!project || project.getEnv("LOCALTUNNEL_ENABLE", "false") !== "true") {
|
|
68
|
-
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);
|
|
69
18
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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", "");
|
|
83
81
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const stream = await container.attach({
|
|
99
|
-
logs: true,
|
|
100
|
-
stream: true,
|
|
101
|
-
hijack: true,
|
|
102
|
-
stdin: true,
|
|
103
|
-
stdout: true,
|
|
104
|
-
stderr: true
|
|
105
|
-
});
|
|
106
|
-
stream.setEncoding("utf8");
|
|
107
|
-
await container.start();
|
|
108
|
-
const link = await new Promise((resolve, reject) => {
|
|
109
|
-
let res = "";
|
|
110
|
-
stream.on("data", data => {
|
|
111
|
-
const regLink = /(https?):\/\/(\w[\w.-]+[a-z]|\d+\.\d+\.\d+\.\d+)(?::(\d+))?/;
|
|
112
|
-
if (regLink.test(data.toString())) {
|
|
113
|
-
const [link] = regLink.exec(data.toString());
|
|
114
|
-
if (link.includes(".loca.lt")) {
|
|
115
|
-
res = link;
|
|
116
|
-
stream.end();
|
|
117
|
-
}
|
|
82
|
+
async onProjectStart(project) {
|
|
83
|
+
if (!project || project.getEnv("LOCALTUNNEL_ENABLE", "false") !== "true") {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
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
|
+
}
|
|
118
96
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
});
|
|
135
|
-
const [path] = /\/continue\/[\w.]+/.exec(res.data) || [];
|
|
136
|
-
if (path) {
|
|
137
|
-
const sendData = new URLSearchParams({
|
|
138
|
-
endpoint: ip
|
|
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
|
+
]
|
|
139
112
|
});
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
113
|
+
const stream = await container.attach({
|
|
114
|
+
logs: true,
|
|
115
|
+
stream: true,
|
|
116
|
+
hijack: true,
|
|
117
|
+
stdin: true,
|
|
118
|
+
stdout: true,
|
|
119
|
+
stderr: true
|
|
145
120
|
});
|
|
146
|
-
|
|
147
|
-
|
|
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);
|
|
137
|
+
});
|
|
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
|
+
}
|
|
148
165
|
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
async onProjectStop(project) {
|
|
153
|
-
if (!project || project.getEnv("LOCALTUNNEL_ENABLE", "false") !== "true") {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
console.info("Localtunnel stopping...");
|
|
157
|
-
await _makes.Docker.removeContainer(`localtunnel-${project.name}`);
|
|
158
|
-
}
|
|
159
|
-
async build() {
|
|
160
|
-
const exists = await _makes.Docker.imageExists("ws-localtunnel");
|
|
161
|
-
if (!exists) {
|
|
162
|
-
await _makes.Docker.imageBuild({
|
|
163
|
-
tag: "ws-localtunnel",
|
|
164
|
-
context: this.pluginPath(),
|
|
165
|
-
src: "./Dockerfile"
|
|
166
|
-
});
|
|
167
166
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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}`);
|
|
174
173
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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
|
+
}
|
|
183
183
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
prefix: "https://",
|
|
193
|
-
suffix: ".loca.lt",
|
|
194
|
-
default: project.getEnv("LOCALTUNNEL_SUBDOMAIN")
|
|
195
|
-
});
|
|
196
|
-
if (!subdomain) {
|
|
197
|
-
throw new Error("Subdomain can't be empty");
|
|
198
|
-
}
|
|
199
|
-
const autoConfirmIP = await (0, _utils.promptConfirm)({
|
|
200
|
-
message: "Do you want to skip the IP confirmation form automatically?",
|
|
201
|
-
default: project.getEnv("LOCALTUNNEL_AUTO_CONFIRM", "true") === "true"
|
|
202
|
-
});
|
|
203
|
-
project.setEnv("LOCALTUNNEL_ENABLE", "true");
|
|
204
|
-
project.setEnv("LOCALTUNNEL_SUBDOMAIN", subdomain);
|
|
205
|
-
project.setEnv("LOCALTUNNEL_AUTO_CONFIRM", autoConfirmIP ? "true" : "false");
|
|
206
|
-
} else {
|
|
207
|
-
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();
|
|
208
192
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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();
|
|
218
225
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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
|
+
}
|
|
222
239
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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);
|
|
228
247
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
} = options;
|
|
234
|
-
if (name) {
|
|
235
|
-
await this.projectService.cdProject(name);
|
|
248
|
+
async restart(options) {
|
|
249
|
+
const { name } = options;
|
|
250
|
+
await this.stop({ name });
|
|
251
|
+
await this.start(options);
|
|
236
252
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
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
|
+
});
|
|
256
272
|
}
|
|
257
|
-
const project = await this.projectService.get();
|
|
258
|
-
const container = await _makes.Docker.getContainer(`localtunnel-${project.name}`);
|
|
259
|
-
const stream = await container.logs({
|
|
260
|
-
follow: true,
|
|
261
|
-
stderr: true,
|
|
262
|
-
stdout: true,
|
|
263
|
-
tail: 5
|
|
264
|
-
});
|
|
265
|
-
stream.on("data", data => {
|
|
266
|
-
process.stdout.write(data);
|
|
267
|
-
});
|
|
268
|
-
stream.on("error", data => {
|
|
269
|
-
process.stderr.write(data);
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
273
|
}
|
|
273
|
-
exports.LocaltunnelPlugin = LocaltunnelPlugin;
|
|
274
|
+
exports.LocaltunnelPlugin = LocaltunnelPlugin;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Cli } from "@kearisp/cli";
|
|
2
|
-
import { Plugin } from "
|
|
2
|
+
import { DI, Plugin } from "../makes";
|
|
3
|
+
import { DockerService } from "../services";
|
|
3
4
|
declare class MaildevPlugin extends Plugin {
|
|
4
5
|
protected containerName: string;
|
|
5
|
-
|
|
6
|
+
protected dockerService: DockerService;
|
|
7
|
+
constructor(di: DI);
|
|
6
8
|
install(cli: Cli): void;
|
|
7
9
|
start(): Promise<void>;
|
|
8
10
|
stop(): Promise<void>;
|
|
@@ -1,45 +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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
cli
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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);
|
|
29
47
|
}
|
|
30
|
-
await _makes.Docker.containerRun({
|
|
31
|
-
name: this.containerName,
|
|
32
|
-
restart: "always",
|
|
33
|
-
env: {
|
|
34
|
-
VIRTUAL_HOST: "maildev.workspace"
|
|
35
|
-
},
|
|
36
|
-
ports: ["25:25"],
|
|
37
|
-
image: imageName
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
async stop() {
|
|
41
|
-
console.log("Maildev stopping...");
|
|
42
|
-
await _makes.Docker.removeContainer(this.containerName);
|
|
43
|
-
}
|
|
44
48
|
}
|
|
45
|
-
exports.MaildevPlugin = MaildevPlugin;
|
|
49
|
+
exports.MaildevPlugin = MaildevPlugin;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Cli } from "@kearisp/cli";
|
|
2
|
-
import { Plugin } from "
|
|
2
|
+
import { DI, Plugin } from "../makes";
|
|
3
|
+
import { DockerService } from "../services";
|
|
3
4
|
declare class MongodbPlugin extends Plugin {
|
|
4
|
-
container: string;
|
|
5
|
-
adminContainer: string;
|
|
6
|
-
|
|
5
|
+
protected container: string;
|
|
6
|
+
protected adminContainer: string;
|
|
7
|
+
protected dockerService: DockerService;
|
|
8
|
+
constructor(di: DI);
|
|
7
9
|
install(cli: Cli): void;
|
|
8
10
|
getDatabases(): Promise<string[]>;
|
|
9
11
|
getDatabasesDumps(): Promise<string[]>;
|