@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,7 +1,6 @@
|
|
|
1
|
-
import { Cli } from "@
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { AppConfigService, AppEventsService, ProjectService } from "src/services";
|
|
1
|
+
import { Controller, Cli } from "@wocker/core";
|
|
2
|
+
import { DI, Project } from "../makes";
|
|
3
|
+
import { AppConfigService, AppEventsService, ProjectService, DockerService } from "../services";
|
|
5
4
|
type InitOptions = {
|
|
6
5
|
"http-port"?: number;
|
|
7
6
|
"https-port"?: number;
|
|
@@ -9,25 +8,27 @@ type InitOptions = {
|
|
|
9
8
|
type DomainsOptions = {
|
|
10
9
|
name?: string;
|
|
11
10
|
};
|
|
12
|
-
declare class
|
|
11
|
+
declare class ProxyController extends Controller {
|
|
12
|
+
protected containerName: string;
|
|
13
13
|
protected appConfigService: AppConfigService;
|
|
14
14
|
protected appEventsService: AppEventsService;
|
|
15
15
|
protected projectService: ProjectService;
|
|
16
|
-
protected
|
|
17
|
-
constructor(
|
|
16
|
+
protected dockerService: DockerService;
|
|
17
|
+
constructor(di: DI);
|
|
18
18
|
install(cli: Cli): void;
|
|
19
19
|
getProjectNames(): Promise<string[]>;
|
|
20
|
+
getDomains(name: string | undefined, selected: string[]): Promise<string[]>;
|
|
20
21
|
onProjectStart(project: Project): Promise<void>;
|
|
21
|
-
|
|
22
|
+
onProjectStop(project: Project): Promise<void>;
|
|
22
23
|
init(options: InitOptions): Promise<void>;
|
|
23
24
|
start(): Promise<void>;
|
|
24
25
|
stop(): Promise<void>;
|
|
25
26
|
restart(): Promise<void>;
|
|
26
|
-
logs(): Promise<void>;
|
|
27
27
|
domainList(options: DomainsOptions): Promise<string>;
|
|
28
|
+
setDomains(options: DomainsOptions, domains: string[]): Promise<void>;
|
|
28
29
|
addDomain(options: DomainsOptions, addDomains: string[]): Promise<void>;
|
|
29
30
|
removeDomain(options: DomainsOptions, removeDomains: string[]): Promise<void>;
|
|
30
|
-
setDomains(options: DomainsOptions, domains: string[]): Promise<void>;
|
|
31
31
|
clearDomains(options: DomainsOptions): Promise<void>;
|
|
32
|
+
logs(): Promise<void>;
|
|
32
33
|
}
|
|
33
|
-
export {
|
|
34
|
+
export { ProxyController };
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
exports.ProxyController = void 0;
|
|
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")]
|
|
183
|
+
});
|
|
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
|
+
}
|
|
272
|
+
}
|
|
273
|
+
exports.ProxyController = ProxyController;
|
package/lib/controllers/index.js
CHANGED
|
@@ -1,27 +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
|
-
|
|
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);
|
package/lib/env.js
CHANGED
|
@@ -1,24 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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]; } };
|
|
7
|
+
}
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
5
17
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
exports.ROOT_DIR =
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
exports.
|
|
19
|
-
|
|
20
|
-
exports.
|
|
21
|
-
|
|
22
|
-
exports.DATA_DIR =
|
|
23
|
-
|
|
24
|
-
exports.MAP_PATH = MAP_PATH;
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.MAP_PATH = exports.DATA_DIR = exports.PLUGINS_DIR = exports.SERVICES_DIR = exports.PRESETS_DIR = exports.ROOT_DIR = exports.NODE_ENV = void 0;
|
|
27
|
+
const OS = __importStar(require("os"));
|
|
28
|
+
const Path = __importStar(require("path"));
|
|
29
|
+
exports.NODE_ENV = process.env.NODE_ENV;
|
|
30
|
+
exports.ROOT_DIR = Path.join(__dirname, "..");
|
|
31
|
+
exports.PRESETS_DIR = Path.join(exports.ROOT_DIR, "presets");
|
|
32
|
+
exports.SERVICES_DIR = Path.join(exports.ROOT_DIR, "services");
|
|
33
|
+
exports.PLUGINS_DIR = Path.join(exports.ROOT_DIR, "plugins");
|
|
34
|
+
exports.DATA_DIR = process.env.WS_DIR || Path.join(OS.homedir(), ".workspace");
|
|
35
|
+
exports.MAP_PATH = Path.join(exports.DATA_DIR, "data.json");
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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]; } };
|
|
7
|
+
}
|
|
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 });
|
|
6
17
|
exports.app = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _App = require("./App");
|
|
11
|
-
const appConfigService = new _services.AppConfigService();
|
|
12
|
-
const appEventsService = new _services.AppEventsService();
|
|
13
|
-
const projectService = new _services.ProjectService(appConfigService, appEventsService);
|
|
14
|
-
const app = new _App.App(appConfigService);
|
|
18
|
+
const App_1 = require("./App");
|
|
19
|
+
const plugins_1 = require("./plugins");
|
|
20
|
+
const app = new App_1.App();
|
|
15
21
|
exports.app = app;
|
|
16
|
-
app.
|
|
17
|
-
app.
|
|
18
|
-
app.
|
|
19
|
-
app.
|
|
20
|
-
app.
|
|
21
|
-
app.
|
|
22
|
-
app.
|
|
23
|
-
app.
|
|
24
|
-
app.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
app.usePlugin(new _plugins.ProxyPlugin(appConfigService, appEventsService, projectService));
|
|
28
|
-
app.usePlugin(new _plugins.ProjectPlugin());
|
|
29
|
-
app.usePlugin(new _plugins.RedisPlugin());
|
|
30
|
-
app.usePlugin(new _plugins.ServeoPlugin(appConfigService, appEventsService, projectService));
|
|
31
|
-
app.usePlugin(new _plugins.TestPlugin());
|
|
22
|
+
app.use(plugins_1.ElasticSearchPlugin);
|
|
23
|
+
app.use(plugins_1.LocaltunnelPlugin);
|
|
24
|
+
app.use(plugins_1.MaildevPlugin);
|
|
25
|
+
app.use(plugins_1.MongodbPlugin);
|
|
26
|
+
app.use(plugins_1.NgrokPlugin);
|
|
27
|
+
app.use(plugins_1.PageKitePlugin);
|
|
28
|
+
app.use(plugins_1.PostgresPlugin);
|
|
29
|
+
app.use(plugins_1.ProxmoxPlugin);
|
|
30
|
+
app.use(plugins_1.RedisPlugin);
|
|
31
|
+
__exportStar(require("./makes"), exports);
|
|
32
|
+
__exportStar(require("./services"), exports);
|
package/lib/makes/Controller.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.Controller = void 0;
|
|
7
4
|
class Controller {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
5
|
+
install() {
|
|
6
|
+
}
|
|
11
7
|
}
|
|
12
|
-
exports.Controller = Controller;
|
|
8
|
+
exports.Controller = Controller;
|
package/lib/makes/DI.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DI = void 0;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
class DI {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.services = new Map();
|
|
8
|
+
}
|
|
9
|
+
resolveService(key) {
|
|
10
|
+
let res = this.services.get(key);
|
|
11
|
+
if (!res) {
|
|
12
|
+
const types = Reflect.getMetadata("design:paramtypes", key);
|
|
13
|
+
if (types && types.length > 0) {
|
|
14
|
+
types.forEach((type) => {
|
|
15
|
+
this.resolveService(type);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
res = new key(this);
|
|
19
|
+
this.services.set(key, res);
|
|
20
|
+
}
|
|
21
|
+
return res;
|
|
22
|
+
}
|
|
23
|
+
registerService(key, service) {
|
|
24
|
+
this.services.set(key, service);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.DI = DI;
|