@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,248 +1,239 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.NgrokPlugin = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
install(cli) {
|
|
16
|
-
super.install(cli);
|
|
17
|
-
this.appEventsService.on("project:start", project => this.onProjectStart(project));
|
|
18
|
-
this.appEventsService.on("project:stop", project => this.onProjectStop(project));
|
|
19
|
-
cli.command("ngrok:init").option("name", {
|
|
20
|
-
alias: "n",
|
|
21
|
-
type: "string",
|
|
22
|
-
description: "Project name"
|
|
23
|
-
}).action(options => this.init(options));
|
|
24
|
-
cli.command("ngrok:start").option("name", {
|
|
25
|
-
type: "string",
|
|
26
|
-
alias: "n",
|
|
27
|
-
description: "Project name"
|
|
28
|
-
}).option("detach", {
|
|
29
|
-
type: "boolean",
|
|
30
|
-
alias: "d",
|
|
31
|
-
description: "Detach"
|
|
32
|
-
}).action(options => this.start(options));
|
|
33
|
-
cli.command("ngrok:stop").option("name", {
|
|
34
|
-
type: "string",
|
|
35
|
-
alias: "n",
|
|
36
|
-
description: "Project name"
|
|
37
|
-
}).action(options => this.stop(options));
|
|
38
|
-
cli.command("ngrok:restart").option("name", {
|
|
39
|
-
type: "string",
|
|
40
|
-
alias: "n",
|
|
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("ngrok:logs").option("name", {
|
|
48
|
-
type: "string",
|
|
49
|
-
alias: "n",
|
|
50
|
-
description: "Project name"
|
|
51
|
-
}).action(options => this.logs(options));
|
|
52
|
-
cli.command("ngrok:attach").option("name", {
|
|
53
|
-
type: "string",
|
|
54
|
-
alias: "n",
|
|
55
|
-
description: "Project name"
|
|
56
|
-
}).action(options => this.attach(options));
|
|
57
|
-
cli.command("ngrok:forwarding").option("name", {
|
|
58
|
-
type: "string",
|
|
59
|
-
alias: "n",
|
|
60
|
-
description: "Project name"
|
|
61
|
-
}).action(options => this.forwarding(options));
|
|
62
|
-
}
|
|
63
|
-
async init(options) {
|
|
64
|
-
const {
|
|
65
|
-
name
|
|
66
|
-
} = options;
|
|
67
|
-
if (name) {
|
|
68
|
-
await this.projectService.cdProject(name);
|
|
4
|
+
const utils_1 = require("@wocker/utils");
|
|
5
|
+
const makes_1 = require("../makes");
|
|
6
|
+
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);
|
|
69
12
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
13
|
+
install(cli) {
|
|
14
|
+
super.install(cli);
|
|
15
|
+
this.appEventsService.on("project:start", (project) => this.onProjectStart(project));
|
|
16
|
+
this.appEventsService.on("project:stop", (project) => this.onProjectStop(project));
|
|
17
|
+
cli.command("ngrok:init")
|
|
18
|
+
.option("name", {
|
|
19
|
+
alias: "n",
|
|
20
|
+
type: "string",
|
|
21
|
+
description: "Project name"
|
|
22
|
+
})
|
|
23
|
+
.action((options) => this.init(options));
|
|
24
|
+
cli.command("ngrok:start")
|
|
25
|
+
.option("name", {
|
|
26
|
+
type: "string",
|
|
27
|
+
alias: "n",
|
|
28
|
+
description: "Project name"
|
|
29
|
+
})
|
|
30
|
+
.option("detach", {
|
|
31
|
+
type: "boolean",
|
|
32
|
+
alias: "d",
|
|
33
|
+
description: "Detach"
|
|
34
|
+
})
|
|
35
|
+
.action((options) => this.start(options));
|
|
36
|
+
cli.command("ngrok:stop")
|
|
37
|
+
.option("name", {
|
|
38
|
+
type: "string",
|
|
39
|
+
alias: "n",
|
|
40
|
+
description: "Project name"
|
|
41
|
+
})
|
|
42
|
+
.action((options) => this.stop(options));
|
|
43
|
+
cli.command("ngrok:restart")
|
|
44
|
+
.option("name", {
|
|
45
|
+
type: "string",
|
|
46
|
+
alias: "n",
|
|
47
|
+
description: "Project name"
|
|
48
|
+
})
|
|
49
|
+
.option("detach", {
|
|
50
|
+
type: "boolean",
|
|
51
|
+
alias: "d",
|
|
52
|
+
description: "Detach"
|
|
53
|
+
})
|
|
54
|
+
.action((options) => this.restart(options));
|
|
55
|
+
cli.command("ngrok:logs")
|
|
56
|
+
.option("name", {
|
|
57
|
+
type: "string",
|
|
58
|
+
alias: "n",
|
|
59
|
+
description: "Project name"
|
|
60
|
+
})
|
|
61
|
+
.action((options) => this.logs(options));
|
|
62
|
+
cli.command("ngrok:attach")
|
|
63
|
+
.option("name", {
|
|
64
|
+
type: "string",
|
|
65
|
+
alias: "n",
|
|
66
|
+
description: "Project name"
|
|
67
|
+
})
|
|
68
|
+
.action((options) => this.attach(options));
|
|
69
|
+
cli.command("ngrok:forwarding")
|
|
70
|
+
.option("name", {
|
|
71
|
+
type: "string",
|
|
72
|
+
alias: "n",
|
|
73
|
+
description: "Project name"
|
|
74
|
+
})
|
|
75
|
+
.action((options) => this.forwarding(options));
|
|
84
76
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
77
|
+
async init(options) {
|
|
78
|
+
const { name } = options;
|
|
79
|
+
if (name) {
|
|
80
|
+
await this.projectService.cdProject(name);
|
|
81
|
+
}
|
|
82
|
+
const project = await this.projectService.get();
|
|
83
|
+
const enable = await (0, utils_1.promptConfirm)({
|
|
84
|
+
message: "Enable ngrok?",
|
|
85
|
+
default: true
|
|
86
|
+
});
|
|
87
|
+
if (enable) {
|
|
88
|
+
const token = await (0, utils_1.promptText)({
|
|
89
|
+
message: "Token",
|
|
90
|
+
default: project.getEnv("NGROK_AUTHTOKEN")
|
|
91
|
+
});
|
|
92
|
+
project.setEnv("NGROK_AUTHTOKEN", token);
|
|
93
|
+
project.setEnv("NGROK_ENABLE", "true");
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
project.setEnv("NGROK_ENABLE", "false");
|
|
96
97
|
}
|
|
97
|
-
|
|
98
|
-
} = await container.inspect();
|
|
99
|
-
const stream = await _makes.Docker.exec("proxy.workspace", ["curl", `http://${workspace.IPAddress}:4040/api/tunnels/command_line`], false);
|
|
100
|
-
const res = await new Promise((resolve, reject) => {
|
|
101
|
-
let res = "";
|
|
102
|
-
stream.on("data", data => {
|
|
103
|
-
res += (0, _utils.demuxOutput)(data).toString();
|
|
104
|
-
});
|
|
105
|
-
stream.on("end", () => resolve(res));
|
|
106
|
-
stream.on("error", reject);
|
|
107
|
-
});
|
|
108
|
-
const tunnel = JSON.parse(res);
|
|
109
|
-
return tunnel.public_url;
|
|
110
|
-
}
|
|
111
|
-
async onProjectStart(project) {
|
|
112
|
-
if (!project || project.getEnv("NGROK_ENABLE", "false") !== "true") {
|
|
113
|
-
return;
|
|
98
|
+
await project.save();
|
|
114
99
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
Running
|
|
100
|
+
async getForwarding(project) {
|
|
101
|
+
const container = await makes_1.Docker.getContainer(`ngrok-${project.name}`);
|
|
102
|
+
if (!container) {
|
|
103
|
+
throw new Error(`Ngrok for "${project.name}" not started`);
|
|
120
104
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
105
|
+
const { NetworkSettings: { Networks: { workspace } } } = await container.inspect();
|
|
106
|
+
const stream = await makes_1.Docker.exec("proxy.workspace", [
|
|
107
|
+
"curl", `http://${workspace.IPAddress}:4040/api/tunnels/command_line`
|
|
108
|
+
], false);
|
|
109
|
+
const res = await new Promise((resolve, reject) => {
|
|
110
|
+
let res = "";
|
|
111
|
+
stream.on("data", (data) => {
|
|
112
|
+
res += (0, utils_1.demuxOutput)(data).toString();
|
|
113
|
+
});
|
|
114
|
+
stream.on("end", () => resolve(res));
|
|
115
|
+
stream.on("error", reject);
|
|
116
|
+
});
|
|
117
|
+
const tunnel = JSON.parse(res);
|
|
118
|
+
return tunnel.public_url;
|
|
130
119
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const container = await _makes.Docker.createContainer({
|
|
135
|
-
name: `ngrok-${project.name}`,
|
|
136
|
-
image: "ngrok/ngrok:latest",
|
|
137
|
-
tty: true,
|
|
138
|
-
restart: "always",
|
|
139
|
-
env: {
|
|
140
|
-
NGROK_AUTHTOKEN: project.getEnv("NGROK_AUTHTOKEN")
|
|
141
|
-
},
|
|
142
|
-
cmd: ["http", `${project.name}.workspace:80`]
|
|
143
|
-
});
|
|
144
|
-
const stream = await container.attach({
|
|
145
|
-
logs: true,
|
|
146
|
-
stream: true,
|
|
147
|
-
hijack: true,
|
|
148
|
-
stdin: true,
|
|
149
|
-
stdout: true,
|
|
150
|
-
stderr: true
|
|
151
|
-
});
|
|
152
|
-
stream.setEncoding("utf8");
|
|
153
|
-
await container.start();
|
|
154
|
-
await container.resize({
|
|
155
|
-
w: 90,
|
|
156
|
-
h: 40
|
|
157
|
-
});
|
|
158
|
-
await new Promise((resolve, reject) => {
|
|
159
|
-
stream.on("data", data => {
|
|
160
|
-
const regLink = /(https?):\/\/(\w[\w.-]+[a-z]|\d+\.\d+\.\d+\.\d+)(?::(\d+))?/;
|
|
161
|
-
if (regLink.test(data.toString())) {
|
|
162
|
-
const [link] = regLink.exec(data.toString());
|
|
163
|
-
if (link.includes(".ngrok")) {
|
|
164
|
-
_makes.Logger.info(`${project.name} forwarding: ${link}`);
|
|
165
|
-
console.log(`Forwarding: ${link}`);
|
|
166
|
-
stream.end();
|
|
167
|
-
}
|
|
120
|
+
async onProjectStart(project) {
|
|
121
|
+
if (!project || project.getEnv("NGROK_ENABLE", "false") !== "true") {
|
|
122
|
+
return;
|
|
168
123
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
124
|
+
const container1 = await makes_1.Docker.getContainer(`ngrok-${project.name}`);
|
|
125
|
+
if (container1) {
|
|
126
|
+
const { State: { Running } } = await container1.inspect();
|
|
127
|
+
if (Running) {
|
|
128
|
+
console.log("Ngrok is already running");
|
|
129
|
+
const forwarding = await this.getForwarding(project);
|
|
130
|
+
console.log(`Forwarding: ${forwarding}`);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
await makes_1.Docker.removeContainer(`ngrok-${project.name}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
console.log("Ngrok starting...");
|
|
138
|
+
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({
|
|
141
|
+
name: `ngrok-${project.name}`,
|
|
142
|
+
image: "ngrok/ngrok:latest",
|
|
143
|
+
tty: true,
|
|
144
|
+
restart: "always",
|
|
145
|
+
env: {
|
|
146
|
+
NGROK_AUTHTOKEN: project.getEnv("NGROK_AUTHTOKEN")
|
|
147
|
+
},
|
|
148
|
+
cmd: ["http", `${project.name}.workspace:80`]
|
|
149
|
+
});
|
|
150
|
+
const stream = await container.attach({
|
|
151
|
+
logs: true,
|
|
152
|
+
stream: true,
|
|
153
|
+
hijack: true,
|
|
154
|
+
stdin: true,
|
|
155
|
+
stdout: true,
|
|
156
|
+
stderr: true
|
|
157
|
+
});
|
|
158
|
+
stream.setEncoding("utf8");
|
|
159
|
+
await container.start();
|
|
160
|
+
await container.resize({
|
|
161
|
+
w: 90,
|
|
162
|
+
h: 40
|
|
163
|
+
});
|
|
164
|
+
await new Promise((resolve, reject) => {
|
|
165
|
+
stream.on("data", (data) => {
|
|
166
|
+
const regLink = /(https?):\/\/(\w[\w.-]+[a-z]|\d+\.\d+\.\d+\.\d+)(?::(\d+))?/;
|
|
167
|
+
if (regLink.test(data.toString())) {
|
|
168
|
+
const [link] = regLink.exec(data.toString());
|
|
169
|
+
if (link.includes(".ngrok")) {
|
|
170
|
+
makes_1.Logger.info(`${project.name} forwarding: ${link}`);
|
|
171
|
+
console.log(`Forwarding: ${link}`);
|
|
172
|
+
stream.end();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
stream.on("end", resolve);
|
|
177
|
+
stream.on("error", reject);
|
|
178
|
+
});
|
|
177
179
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
detach
|
|
185
|
-
} = options;
|
|
186
|
-
if (name) {
|
|
187
|
-
await this.projectService.cdProject(name);
|
|
180
|
+
async onProjectStop(project) {
|
|
181
|
+
if (!project || project.getEnv("NGROK_ENABLE", "false") !== "true") {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
console.log("Ngrok stopping...");
|
|
185
|
+
await makes_1.Docker.removeContainer(`ngrok-${project.name}`);
|
|
188
186
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
187
|
+
async start(options) {
|
|
188
|
+
const { name, detach } = options;
|
|
189
|
+
if (name) {
|
|
190
|
+
await this.projectService.cdProject(name);
|
|
191
|
+
}
|
|
192
|
+
const project = await this.projectService.get();
|
|
193
|
+
await this.onProjectStart(project);
|
|
194
|
+
if (!detach) {
|
|
195
|
+
await makes_1.Docker.attach(`ngrok-${project.name}`);
|
|
196
|
+
}
|
|
193
197
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
198
|
+
async stop(options) {
|
|
199
|
+
const { name } = options;
|
|
200
|
+
if (name) {
|
|
201
|
+
await this.projectService.cdProject(name);
|
|
202
|
+
}
|
|
203
|
+
const project = await this.projectService.get();
|
|
204
|
+
await this.onProjectStop(project);
|
|
201
205
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const {
|
|
207
|
-
name
|
|
208
|
-
} = options;
|
|
209
|
-
await this.stop({
|
|
210
|
-
name
|
|
211
|
-
});
|
|
212
|
-
await this.start(options);
|
|
213
|
-
}
|
|
214
|
-
async logs(options) {
|
|
215
|
-
const {
|
|
216
|
-
name
|
|
217
|
-
} = options;
|
|
218
|
-
if (name) {
|
|
219
|
-
await this.projectService.cdProject(name);
|
|
206
|
+
async restart(options) {
|
|
207
|
+
const { name } = options;
|
|
208
|
+
await this.stop({ name });
|
|
209
|
+
await this.start(options);
|
|
220
210
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
211
|
+
async logs(options) {
|
|
212
|
+
const { name } = options;
|
|
213
|
+
if (name) {
|
|
214
|
+
await this.projectService.cdProject(name);
|
|
215
|
+
}
|
|
216
|
+
const project = await this.projectService.get();
|
|
217
|
+
const container = await makes_1.Docker.getContainer(`ngrok-${project.name}`);
|
|
218
|
+
if (!container) {
|
|
219
|
+
throw new Error("Ngrok not started");
|
|
220
|
+
}
|
|
225
221
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
222
|
+
async attach(options) {
|
|
223
|
+
const { name } = options;
|
|
224
|
+
if (name) {
|
|
225
|
+
await this.projectService.cdProject(name);
|
|
226
|
+
}
|
|
227
|
+
const project = await this.projectService.get();
|
|
228
|
+
await makes_1.Docker.attach(`ngrok-${project.name}`);
|
|
233
229
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
if (name) {
|
|
242
|
-
await this.projectService.cdProject(name);
|
|
230
|
+
async forwarding(options) {
|
|
231
|
+
const { name } = options;
|
|
232
|
+
if (name) {
|
|
233
|
+
await this.projectService.cdProject(name);
|
|
234
|
+
}
|
|
235
|
+
const project = await this.projectService.get();
|
|
236
|
+
return this.getForwarding(project);
|
|
243
237
|
}
|
|
244
|
-
const project = await this.projectService.get();
|
|
245
|
-
return this.getForwarding(project);
|
|
246
|
-
}
|
|
247
238
|
}
|
|
248
|
-
exports.NgrokPlugin = NgrokPlugin;
|
|
239
|
+
exports.NgrokPlugin = NgrokPlugin;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Cli } from "@kearisp/cli";
|
|
2
|
-
import { Plugin } from "
|
|
3
|
-
import {
|
|
4
|
-
import { AppConfigService, AppEventsService, ProjectService } from "src/services";
|
|
2
|
+
import { DI, Plugin, Project } from "../makes";
|
|
3
|
+
import { AppConfigService, AppEventsService, ProjectService } from "../services";
|
|
5
4
|
type InitOptions = {};
|
|
6
5
|
type StartOptions = {
|
|
7
6
|
name?: string;
|
|
@@ -19,7 +18,7 @@ declare class PageKitePlugin extends Plugin {
|
|
|
19
18
|
protected appConfigService: AppConfigService;
|
|
20
19
|
protected appEventsService: AppEventsService;
|
|
21
20
|
protected projectService: ProjectService;
|
|
22
|
-
constructor(
|
|
21
|
+
constructor(di: DI);
|
|
23
22
|
install(cli: Cli): void;
|
|
24
23
|
onProjectStart(project: Project): Promise<void>;
|
|
25
24
|
onProjectStop(project: Project): Promise<void>;
|