@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,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Controller, Cli } from "@wocker/core";
|
|
2
|
+
import { DI, Project } from "../makes";
|
|
3
|
+
import { AppConfigService, AppEventsService, ProjectService, DockerService } from "../services";
|
|
2
4
|
type InitOptions = {
|
|
3
5
|
"http-port"?: number;
|
|
4
6
|
"https-port"?: number;
|
|
@@ -15,6 +17,7 @@ declare class ProxyController extends Controller {
|
|
|
15
17
|
constructor(di: DI);
|
|
16
18
|
install(cli: Cli): void;
|
|
17
19
|
getProjectNames(): Promise<string[]>;
|
|
20
|
+
getDomains(name: string | undefined, selected: string[]): Promise<string[]>;
|
|
18
21
|
onProjectStart(project: Project): Promise<void>;
|
|
19
22
|
onProjectStop(project: Project): Promise<void>;
|
|
20
23
|
init(options: InitOptions): Promise<void>;
|
|
@@ -1,249 +1,273 @@
|
|
|
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.ProxyController = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class ProxyController extends
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
7
|
+
const core_1 = require("@wocker/core");
|
|
8
|
+
const utils_1 = require("@wocker/utils");
|
|
9
|
+
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
10
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
+
const makes_1 = require("../makes");
|
|
12
|
+
const utils_2 = require("../utils");
|
|
13
|
+
const services_1 = require("../services");
|
|
14
|
+
class ProxyController extends core_1.Controller {
|
|
15
|
+
constructor(di) {
|
|
16
|
+
super();
|
|
17
|
+
this.containerName = "proxy.workspace";
|
|
18
|
+
this.appConfigService = di.resolveService(services_1.AppConfigService);
|
|
19
|
+
this.appEventsService = di.resolveService(services_1.AppEventsService);
|
|
20
|
+
this.projectService = di.resolveService(services_1.ProjectService);
|
|
21
|
+
this.dockerService = di.resolveService(services_1.DockerService);
|
|
22
|
+
}
|
|
23
|
+
install(cli) {
|
|
24
|
+
super.install(cli);
|
|
25
|
+
this.appEventsService.on("project:beforeStart", (project) => this.onProjectStart(project));
|
|
26
|
+
this.appEventsService.on("project:stop", (project) => this.onProjectStop(project));
|
|
27
|
+
cli.command("proxy:init")
|
|
28
|
+
.option("http-port", {
|
|
29
|
+
type: "number",
|
|
30
|
+
description: "Http port"
|
|
31
|
+
})
|
|
32
|
+
.option("https-port", {
|
|
33
|
+
type: "number",
|
|
34
|
+
description: "Https port"
|
|
35
|
+
})
|
|
36
|
+
.action((options) => this.init(options));
|
|
37
|
+
cli.command("proxy:start")
|
|
38
|
+
.action(() => this.start());
|
|
39
|
+
cli.command("proxy:stop")
|
|
40
|
+
.action(() => this.stop());
|
|
41
|
+
cli.command("proxy:restart")
|
|
42
|
+
.action(() => this.restart());
|
|
43
|
+
cli.command("domains")
|
|
44
|
+
.option("name", {
|
|
45
|
+
type: "string",
|
|
46
|
+
alias: "n",
|
|
47
|
+
description: "Project name"
|
|
48
|
+
})
|
|
49
|
+
.action((options) => this.domainList(options));
|
|
50
|
+
cli.command("domain:set [...domains]")
|
|
51
|
+
.option("name", {
|
|
52
|
+
type: "string",
|
|
53
|
+
alias: "n",
|
|
54
|
+
description: "Project name"
|
|
55
|
+
})
|
|
56
|
+
.completion("name", () => this.getProjectNames())
|
|
57
|
+
.action((options, domains) => this.setDomains(options, domains));
|
|
58
|
+
cli.command("domain:add [...domains]")
|
|
59
|
+
.option("name", {
|
|
60
|
+
type: "string",
|
|
61
|
+
alias: "n",
|
|
62
|
+
description: "Project name"
|
|
63
|
+
})
|
|
64
|
+
.completion("name", () => this.getProjectNames())
|
|
65
|
+
.action((options, domains) => this.addDomain(options, domains));
|
|
66
|
+
cli.command("domain:remove [...domains]")
|
|
67
|
+
.option("name", {
|
|
68
|
+
type: "string",
|
|
69
|
+
alias: "n",
|
|
70
|
+
description: "Project name"
|
|
71
|
+
})
|
|
72
|
+
.completion("name", () => this.getProjectNames())
|
|
73
|
+
.completion("domains", (options, domains) => this.getDomains(options.name, domains))
|
|
74
|
+
.action((options, domains) => this.removeDomain(options, domains));
|
|
75
|
+
cli.command("domain:clear")
|
|
76
|
+
.option("name", {
|
|
77
|
+
type: "string",
|
|
78
|
+
alias: "n",
|
|
79
|
+
description: "Project name"
|
|
80
|
+
})
|
|
81
|
+
.completion("name", () => this.getProjectNames())
|
|
82
|
+
.action((options) => this.clearDomains(options));
|
|
83
|
+
cli.command("proxy:logs")
|
|
84
|
+
.action(() => this.logs());
|
|
85
|
+
}
|
|
86
|
+
async getProjectNames() {
|
|
87
|
+
const projects = await makes_1.Project.search();
|
|
88
|
+
return projects.map((project) => project.name);
|
|
89
|
+
}
|
|
90
|
+
async getDomains(name, selected) {
|
|
91
|
+
if (name) {
|
|
92
|
+
await this.projectService.cdProject(name);
|
|
93
|
+
}
|
|
94
|
+
const project = await this.projectService.get();
|
|
95
|
+
return (project.getEnv("VIRTUAL_HOST") || "").split(",").filter((domain) => {
|
|
96
|
+
return !selected.includes(domain);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
async onProjectStart(project) {
|
|
100
|
+
if (!project.hasEnv("VIRTUAL_HOST")) {
|
|
101
|
+
project.setEnv("VIRTUAL_HOST", `${project.name}.workspace`);
|
|
102
|
+
}
|
|
103
|
+
await this.start();
|
|
104
|
+
}
|
|
105
|
+
async onProjectStop(project) {
|
|
106
|
+
}
|
|
107
|
+
async init(options) {
|
|
108
|
+
let { "http-port": httpPort, "https-port": httpsPort } = options;
|
|
109
|
+
if (typeof httpPort === "undefined" || isNaN(httpPort)) {
|
|
110
|
+
httpPort = await (0, utils_1.promptText)({
|
|
111
|
+
required: true,
|
|
112
|
+
message: "Http port:",
|
|
113
|
+
type: "int",
|
|
114
|
+
default: await this.appConfigService.getEnvVariable("PROXY_HTTP_PORT", "80")
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
await this.appConfigService.setEnvVariable("PROXY_HTTP_PORT", httpPort);
|
|
118
|
+
if (typeof httpsPort === "undefined" || isNaN(httpsPort)) {
|
|
119
|
+
httpsPort = await (0, utils_1.promptText)({
|
|
120
|
+
required: true,
|
|
121
|
+
message: "Https port:",
|
|
122
|
+
type: "int",
|
|
123
|
+
default: await this.appConfigService.getEnvVariable("PROXY_HTTPS_PORT", "443")
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
await this.appConfigService.setEnvVariable("PROXY_HTTPS_PORT", httpsPort);
|
|
127
|
+
}
|
|
128
|
+
async start() {
|
|
129
|
+
console.info("Proxy starting...");
|
|
130
|
+
await this.dockerService.pullImage("nginxproxy/nginx-proxy");
|
|
131
|
+
const httpPort = await this.appConfigService.getEnvVariable("PROXY_HTTP_PORT", "80");
|
|
132
|
+
const httpsPort = await this.appConfigService.getEnvVariable("PROXY_HTTPS_PORT", "443");
|
|
133
|
+
let container = await this.dockerService.getContainer(this.containerName);
|
|
134
|
+
if (!container) {
|
|
135
|
+
const certsDir = this.appConfigService.dataPath("certs");
|
|
136
|
+
if (!makes_1.FS.existsSync(certsDir)) {
|
|
137
|
+
makes_1.FS.mkdirSync(certsDir, {
|
|
138
|
+
recursive: true
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
container = await this.dockerService.createContainer({
|
|
142
|
+
name: this.containerName,
|
|
143
|
+
image: "nginxproxy/nginx-proxy",
|
|
144
|
+
restart: "always",
|
|
145
|
+
env: {
|
|
146
|
+
DEFAULT_HOST: "index.workspace"
|
|
147
|
+
},
|
|
148
|
+
ports: [
|
|
149
|
+
`${httpPort}:80`,
|
|
150
|
+
`${httpsPort}:443`
|
|
151
|
+
],
|
|
152
|
+
volumes: [
|
|
153
|
+
"/var/run/docker.sock:/tmp/docker.sock:ro",
|
|
154
|
+
`${certsDir}:/etc/nginx/certs`
|
|
155
|
+
]
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
console.info("Container already exists");
|
|
160
|
+
}
|
|
161
|
+
const { State: { Status } } = await container.inspect();
|
|
162
|
+
if (["created", "exited"].includes(Status)) {
|
|
163
|
+
console.info("Starting...", Status);
|
|
164
|
+
await container.start();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
async stop() {
|
|
168
|
+
console.info("Proxy stopping...");
|
|
169
|
+
await this.dockerService.removeContainer(this.containerName);
|
|
170
|
+
}
|
|
171
|
+
async restart() {
|
|
172
|
+
await this.stop();
|
|
173
|
+
await this.start();
|
|
174
|
+
}
|
|
175
|
+
async domainList(options) {
|
|
176
|
+
const { name } = options;
|
|
177
|
+
if (name) {
|
|
178
|
+
await this.projectService.cdProject(name);
|
|
179
|
+
}
|
|
180
|
+
const project = await this.projectService.get();
|
|
181
|
+
const table = new cli_table3_1.default({
|
|
182
|
+
head: [chalk_1.default.yellow("Domain")]
|
|
112
183
|
});
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
async removeDomain(options, removeDomains) {
|
|
202
|
-
const {
|
|
203
|
-
name
|
|
204
|
-
} = options;
|
|
205
|
-
if (name) {
|
|
206
|
-
await this.projectService.cdProject(name);
|
|
207
|
-
}
|
|
208
|
-
const project = await this.projectService.get();
|
|
209
|
-
let domains = project.getEnv("VIRTUAL_HOST", "").split(",").filter(domain => {
|
|
210
|
-
return !!domain;
|
|
211
|
-
});
|
|
212
|
-
domains = domains.filter(domain => {
|
|
213
|
-
return !removeDomains.includes(domain);
|
|
214
|
-
});
|
|
215
|
-
project.setEnv("VIRTUAL_HOST", domains.join(","));
|
|
216
|
-
await project.save();
|
|
217
|
-
}
|
|
218
|
-
async clearDomains(options) {
|
|
219
|
-
const {
|
|
220
|
-
name
|
|
221
|
-
} = options;
|
|
222
|
-
if (name) {
|
|
223
|
-
await this.projectService.cdProject(name);
|
|
224
|
-
}
|
|
225
|
-
const project = await this.projectService.get();
|
|
226
|
-
project.unsetEnv("VIRTUAL_HOST");
|
|
227
|
-
await project.save();
|
|
228
|
-
const container = await this.dockerService.getContainer(`${project.name}.workspace`);
|
|
229
|
-
if (container) {
|
|
230
|
-
await this.projectService.stop(project);
|
|
231
|
-
await this.projectService.start(project);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
async logs() {
|
|
235
|
-
const container = await this.dockerService.getContainer(this.containerName);
|
|
236
|
-
if (!container) {
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
const stream = await container.logs({
|
|
240
|
-
follow: true,
|
|
241
|
-
stdout: true,
|
|
242
|
-
stderr: true
|
|
243
|
-
});
|
|
244
|
-
stream.on("data", data => {
|
|
245
|
-
process.stdout.write((0, _utils2.demuxOutput)(data));
|
|
246
|
-
});
|
|
247
|
-
}
|
|
184
|
+
const domains = project.getEnv("VIRTUAL_HOST", "").split(",");
|
|
185
|
+
for (const domain of domains) {
|
|
186
|
+
table.push([domain]);
|
|
187
|
+
}
|
|
188
|
+
return table.toString() + "\n";
|
|
189
|
+
}
|
|
190
|
+
async setDomains(options, domains) {
|
|
191
|
+
const { name } = options;
|
|
192
|
+
if (name) {
|
|
193
|
+
await this.projectService.cdProject(name);
|
|
194
|
+
}
|
|
195
|
+
const project = await this.projectService.get();
|
|
196
|
+
project.setEnv("VIRTUAL_HOST", domains.join(","));
|
|
197
|
+
project.save();
|
|
198
|
+
const container = await this.dockerService.getContainer(`${project.name}.workspace`);
|
|
199
|
+
if (container) {
|
|
200
|
+
await this.projectService.stop();
|
|
201
|
+
await this.projectService.start();
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
async addDomain(options, addDomains) {
|
|
205
|
+
const { name } = options;
|
|
206
|
+
if (name) {
|
|
207
|
+
await this.projectService.cdProject(name);
|
|
208
|
+
}
|
|
209
|
+
const project = await this.projectService.get();
|
|
210
|
+
let domains = project.getEnv("VIRTUAL_HOST", "").split(",").filter((domain) => {
|
|
211
|
+
return !!domain;
|
|
212
|
+
});
|
|
213
|
+
domains = [
|
|
214
|
+
...domains,
|
|
215
|
+
...addDomains.filter((domain) => {
|
|
216
|
+
return !domains.find((existDomain) => {
|
|
217
|
+
return existDomain === domain;
|
|
218
|
+
});
|
|
219
|
+
})
|
|
220
|
+
];
|
|
221
|
+
project.setEnv("VIRTUAL_HOST", domains.join(","));
|
|
222
|
+
await project.save();
|
|
223
|
+
const container = await this.dockerService.getContainer(`${project.name}.workspace`);
|
|
224
|
+
if (container) {
|
|
225
|
+
await this.projectService.stop();
|
|
226
|
+
await this.projectService.start();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
async removeDomain(options, removeDomains) {
|
|
230
|
+
const { name } = options;
|
|
231
|
+
if (name) {
|
|
232
|
+
await this.projectService.cdProject(name);
|
|
233
|
+
}
|
|
234
|
+
const project = await this.projectService.get();
|
|
235
|
+
let domains = project.getEnv("VIRTUAL_HOST", "").split(",").filter((domain) => {
|
|
236
|
+
return !!domain;
|
|
237
|
+
});
|
|
238
|
+
domains = domains.filter((domain) => {
|
|
239
|
+
return !removeDomains.includes(domain);
|
|
240
|
+
});
|
|
241
|
+
project.setEnv("VIRTUAL_HOST", domains.join(","));
|
|
242
|
+
await project.save();
|
|
243
|
+
}
|
|
244
|
+
async clearDomains(options) {
|
|
245
|
+
const { name } = options;
|
|
246
|
+
if (name) {
|
|
247
|
+
await this.projectService.cdProject(name);
|
|
248
|
+
}
|
|
249
|
+
const project = await this.projectService.get();
|
|
250
|
+
project.unsetEnv("VIRTUAL_HOST");
|
|
251
|
+
await project.save();
|
|
252
|
+
const container = await this.dockerService.getContainer(`${project.name}.workspace`);
|
|
253
|
+
if (container) {
|
|
254
|
+
await this.projectService.stop();
|
|
255
|
+
await this.projectService.start();
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
async logs() {
|
|
259
|
+
const container = await this.dockerService.getContainer(this.containerName);
|
|
260
|
+
if (!container) {
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
const stream = await container.logs({
|
|
264
|
+
follow: true,
|
|
265
|
+
stdout: true,
|
|
266
|
+
stderr: true
|
|
267
|
+
});
|
|
268
|
+
stream.on("data", (data) => {
|
|
269
|
+
process.stdout.write((0, utils_2.demuxOutput)(data));
|
|
270
|
+
});
|
|
271
|
+
}
|
|
248
272
|
}
|
|
249
|
-
exports.ProxyController = ProxyController;
|
|
273
|
+
exports.ProxyController = ProxyController;
|
package/lib/controllers/index.js
CHANGED
|
@@ -1,60 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.keys(_ImageController).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _ImageController[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _ImageController[key];
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
7
|
}
|
|
15
|
-
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Object.keys(_PresetController).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _PresetController[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _PresetController[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
var _ProjectController = require("./ProjectController");
|
|
40
|
-
Object.keys(_ProjectController).forEach(function (key) {
|
|
41
|
-
if (key === "default" || key === "__esModule") return;
|
|
42
|
-
if (key in exports && exports[key] === _ProjectController[key]) return;
|
|
43
|
-
Object.defineProperty(exports, key, {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () {
|
|
46
|
-
return _ProjectController[key];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
var _ProxyController = require("./ProxyController");
|
|
51
|
-
Object.keys(_ProxyController).forEach(function (key) {
|
|
52
|
-
if (key === "default" || key === "__esModule") return;
|
|
53
|
-
if (key in exports && exports[key] === _ProxyController[key]) return;
|
|
54
|
-
Object.defineProperty(exports, key, {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
get: function () {
|
|
57
|
-
return _ProxyController[key];
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
});
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ImageController"), exports);
|
|
18
|
+
__exportStar(require("./PluginController"), exports);
|
|
19
|
+
__exportStar(require("./PresetController"), exports);
|
|
20
|
+
__exportStar(require("./ProjectController"), exports);
|
|
21
|
+
__exportStar(require("./ProxyController"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Inject: () => (target: any) => void;
|