@wocker/ws 1.0.7 → 1.0.9
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/bin/ws.js +2 -13
- package/lib/AppModule.d.ts +6 -0
- package/lib/AppModule.js +100 -0
- package/lib/controllers/CompletionController.d.ts +6 -0
- package/lib/controllers/CompletionController.js +32 -0
- package/lib/controllers/DebugController.d.ts +7 -0
- package/lib/controllers/DebugController.js +44 -0
- package/lib/controllers/ImageController.d.ts +5 -8
- package/lib/controllers/ImageController.js +27 -12
- package/lib/controllers/PluginController.d.ts +11 -13
- package/lib/controllers/PluginController.js +93 -54
- package/lib/controllers/PresetController.d.ts +10 -15
- package/lib/controllers/PresetController.js +111 -27
- package/lib/controllers/ProjectController.d.ts +27 -70
- package/lib/controllers/ProjectController.js +357 -306
- package/lib/controllers/ProxyController.d.ts +15 -25
- package/lib/controllers/ProxyController.js +157 -102
- package/lib/controllers/index.d.ts +2 -0
- package/lib/controllers/index.js +2 -0
- package/lib/main.d.ts +3 -0
- package/lib/main.js +30 -0
- package/lib/makes/FS.d.ts +15 -5
- package/lib/makes/FS.js +42 -9
- package/lib/makes/Http.d.ts +18 -0
- package/lib/makes/{Plugin.js → Http.js} +45 -34
- package/lib/makes/Logger.d.ts +2 -2
- package/lib/makes/Logger.js +19 -8
- package/lib/makes/Preset.d.ts +5 -6
- package/lib/makes/Preset.js +19 -8
- package/lib/makes/index.d.ts +1 -6
- package/lib/makes/index.js +1 -6
- package/lib/plugins/ElasticSearchPlugin.d.ts +5 -6
- package/lib/plugins/ElasticSearchPlugin.js +19 -8
- package/lib/plugins/LocaltunnelPlugin.d.ts +8 -8
- package/lib/plugins/LocaltunnelPlugin.js +25 -10
- package/lib/plugins/MaildevPlugin.d.ts +5 -6
- package/lib/plugins/MaildevPlugin.js +21 -8
- package/lib/plugins/MongodbPlugin.d.ts +5 -5
- package/lib/plugins/MongodbPlugin.js +26 -11
- package/lib/plugins/NgrokPlugin.d.ts +7 -6
- package/lib/plugins/NgrokPlugin.js +32 -17
- package/lib/plugins/PageKitePlugin.d.ts +10 -8
- package/lib/plugins/PageKitePlugin.js +36 -20
- package/lib/plugins/ProxmoxPlugin.d.ts +8 -5
- package/lib/plugins/ProxmoxPlugin.js +25 -9
- package/lib/plugins/RedisPlugin.d.ts +4 -6
- package/lib/plugins/RedisPlugin.js +19 -8
- package/lib/plugins/index.d.ts +0 -2
- package/lib/plugins/index.js +0 -2
- package/lib/services/AppConfigService.d.ts +7 -17
- package/lib/services/AppConfigService.js +44 -114
- package/lib/services/AppEventsService.d.ts +1 -2
- package/lib/services/AppEventsService.js +11 -2
- package/lib/services/DockerService.d.ts +9 -39
- package/lib/services/DockerService.js +122 -4
- package/lib/services/LogService.d.ts +3 -5
- package/lib/services/LogService.js +19 -4
- package/lib/services/PluginService.d.ts +11 -9
- package/lib/services/PluginService.js +100 -8
- package/lib/services/PresetService.d.ts +4 -5
- package/lib/services/PresetService.js +26 -5
- package/lib/services/ProjectService.d.ts +9 -6
- package/lib/services/ProjectService.js +72 -37
- package/lib/utils/exec.d.ts +4 -1
- package/lib/utils/exec.js +16 -31
- package/lib/utils/followProgress.js +49 -45
- package/lib/utils/index.d.ts +0 -7
- package/lib/utils/index.js +0 -7
- package/lib/utils/spawn.d.ts +1 -1
- package/lib/utils/spawn.js +20 -12
- package/package.json +5 -7
- package/presets/node/config.json +1 -1
- package/presets/php-apache/Dockerfile +1 -1
- package/presets/php-apache/config.json +2 -1
- package/presets/php-fpm/Dockerfile +1 -1
- package/lib/App.d.ts +0 -16
- package/lib/App.js +0 -107
- package/lib/decorators/Inject.d.ts +0 -1
- package/lib/decorators/Inject.js +0 -8
- package/lib/decorators/Injectable.d.ts +0 -4
- package/lib/decorators/Injectable.js +0 -17
- package/lib/decorators/index.d.ts +0 -1
- package/lib/decorators/index.js +0 -17
- package/lib/index.d.ts +0 -6
- package/lib/index.js +0 -33
- package/lib/makes/Controller.d.ts +0 -5
- package/lib/makes/Controller.js +0 -8
- package/lib/makes/DI.d.ts +0 -7
- package/lib/makes/DI.js +0 -27
- package/lib/makes/Docker.d.ts +0 -58
- package/lib/makes/Docker.js +0 -320
- package/lib/makes/Plugin.d.ts +0 -13
- package/lib/makes/Project.d.ts +0 -45
- package/lib/makes/Project.js +0 -127
- package/lib/makes/Repository.d.ts +0 -11
- package/lib/makes/Repository.js +0 -22
- package/lib/plugins/PostgresPlugin.d.ts +0 -16
- package/lib/plugins/PostgresPlugin.js +0 -121
- package/lib/types/Config.d.ts +0 -12
- package/lib/types/Config.js +0 -2
- package/lib/types/EnvConfig.d.ts +0 -3
- package/lib/types/EnvConfig.js +0 -2
- package/lib/types/index.d.ts +0 -2
- package/lib/types/index.js +0 -18
- package/lib/utils/buildOptions.d.ts +0 -1
- package/lib/utils/buildOptions.js +0 -9
- package/lib/utils/demuxOutput.d.ts +0 -2
- package/lib/utils/demuxOutput.js +0 -19
- package/lib/utils/fetch.d.ts +0 -5
- package/lib/utils/fetch.js +0 -52
- package/lib/utils/get-config.d.ts +0 -2
- package/lib/utils/get-config.js +0 -17
- package/lib/utils/image-build.d.ts +0 -13
- package/lib/utils/image-build.js +0 -46
- package/lib/utils/set-config.d.ts +0 -2
- package/lib/utils/set-config.js +0 -15
- package/lib/utils/tty.d.ts +0 -2
- package/lib/utils/tty.js +0 -6
|
@@ -15,6 +15,12 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
18
24
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
25
|
if (mod && mod.__esModule) return mod;
|
|
20
26
|
var result = {};
|
|
@@ -22,37 +28,33 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
28
|
__setModuleDefault(result, mod);
|
|
23
29
|
return result;
|
|
24
30
|
};
|
|
31
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
|
+
};
|
|
34
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
35
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
36
|
+
};
|
|
25
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
38
|
exports.PresetController = void 0;
|
|
39
|
+
const core_1 = require("@wocker/core");
|
|
27
40
|
const utils_1 = require("@wocker/utils");
|
|
41
|
+
const utils_2 = require("@wocker/utils");
|
|
28
42
|
const Path = __importStar(require("path"));
|
|
29
43
|
const env_1 = require("../env");
|
|
30
|
-
const
|
|
44
|
+
const utils_3 = require("../utils");
|
|
31
45
|
const makes_1 = require("../makes");
|
|
32
46
|
const services_1 = require("../services");
|
|
33
|
-
|
|
34
|
-
constructor(
|
|
35
|
-
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
38
|
-
this.
|
|
39
|
-
this.
|
|
40
|
-
this.dockerService = di.resolveService(services_1.DockerService);
|
|
41
|
-
}
|
|
42
|
-
install(cli) {
|
|
43
|
-
super.install(cli);
|
|
47
|
+
let PresetController = class PresetController {
|
|
48
|
+
constructor(appConfigService, appEventsService, projectService, presetService, dockerService) {
|
|
49
|
+
this.appConfigService = appConfigService;
|
|
50
|
+
this.appEventsService = appEventsService;
|
|
51
|
+
this.projectService = projectService;
|
|
52
|
+
this.presetService = presetService;
|
|
53
|
+
this.dockerService = dockerService;
|
|
44
54
|
this.appConfigService.registerProjectType("preset", "Preset");
|
|
45
55
|
this.appEventsService.on("project:init", (project) => this.onInit(project));
|
|
46
56
|
this.appEventsService.on("project:beforeStart", (project) => this.onBeforeStart(project));
|
|
47
57
|
this.appEventsService.on("project:rebuild", (project) => this.onRebuild(project));
|
|
48
|
-
cli.command("preset:build <preset>")
|
|
49
|
-
.completion("preset", () => this.presets())
|
|
50
|
-
.option("rebuild", {
|
|
51
|
-
type: "boolean",
|
|
52
|
-
alias: "r",
|
|
53
|
-
description: "Rebuild image"
|
|
54
|
-
})
|
|
55
|
-
.action((options, preset) => this.build(options, preset));
|
|
56
58
|
}
|
|
57
59
|
async presets() {
|
|
58
60
|
const presets = await this.presetService.search();
|
|
@@ -90,18 +92,18 @@ class PresetController extends makes_1.Controller {
|
|
|
90
92
|
}
|
|
91
93
|
if (preset.volumeOptions) {
|
|
92
94
|
for (let volume of preset.volumeOptions) {
|
|
93
|
-
volume = (0,
|
|
95
|
+
volume = (0, utils_3.injectVariables)(volume, {
|
|
94
96
|
...project.buildArgs || {},
|
|
95
97
|
...project.env || {}
|
|
96
98
|
});
|
|
97
|
-
const { destination, options } = (0,
|
|
99
|
+
const { destination, options } = (0, utils_3.volumeParse)(volume);
|
|
98
100
|
let projectVolume = project.getVolumeByDestination(destination);
|
|
99
101
|
const source = await (0, utils_1.promptText)({
|
|
100
102
|
message: "Volume",
|
|
101
103
|
suffix: `:${destination}`,
|
|
102
|
-
default: projectVolume ? (0,
|
|
104
|
+
default: projectVolume ? (0, utils_3.volumeParse)(projectVolume).source : "./"
|
|
103
105
|
});
|
|
104
|
-
projectVolume = (0,
|
|
106
|
+
projectVolume = (0, utils_3.volumeFormat)({
|
|
105
107
|
source,
|
|
106
108
|
destination,
|
|
107
109
|
options
|
|
@@ -110,7 +112,7 @@ class PresetController extends makes_1.Controller {
|
|
|
110
112
|
}
|
|
111
113
|
}
|
|
112
114
|
if (preset.dockerfile) {
|
|
113
|
-
project.imageName =
|
|
115
|
+
project.imageName = this.presetService.getImageName(preset, project.buildArgs);
|
|
114
116
|
}
|
|
115
117
|
}
|
|
116
118
|
async onRebuild(project) {
|
|
@@ -148,7 +150,59 @@ class PresetController extends makes_1.Controller {
|
|
|
148
150
|
}
|
|
149
151
|
}
|
|
150
152
|
}
|
|
151
|
-
async
|
|
153
|
+
async eject(name) {
|
|
154
|
+
if (name) {
|
|
155
|
+
await this.projectService.cdProject(name);
|
|
156
|
+
}
|
|
157
|
+
const project = await this.projectService.get();
|
|
158
|
+
const preset = await this.presetService.get(project.preset);
|
|
159
|
+
if (!preset) {
|
|
160
|
+
throw new Error("Preset not found");
|
|
161
|
+
}
|
|
162
|
+
const confirm = await (0, utils_2.promptConfirm)({
|
|
163
|
+
message: "Confirm eject",
|
|
164
|
+
default: false
|
|
165
|
+
});
|
|
166
|
+
if (!confirm) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const source = new makes_1.FS(this.appConfigService.presetPath(preset.name));
|
|
170
|
+
const destination = new makes_1.FS(this.appConfigService.getPWD());
|
|
171
|
+
const fs = new core_1.FSManager(this.appConfigService.presetPath(preset.name), this.appConfigService.getPWD());
|
|
172
|
+
if (preset.dockerfile) {
|
|
173
|
+
if (!destination.exists(preset.dockerfile)) {
|
|
174
|
+
await fs.copy(preset.dockerfile);
|
|
175
|
+
}
|
|
176
|
+
project.type = "dockerfile";
|
|
177
|
+
project.dockerfile = preset.dockerfile;
|
|
178
|
+
}
|
|
179
|
+
const files = await source.readdirFiles("", {
|
|
180
|
+
recursive: true
|
|
181
|
+
});
|
|
182
|
+
for (const path of files) {
|
|
183
|
+
const stat = source.stat(path);
|
|
184
|
+
if (stat.isFile() && path === "config.json") {
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
if (stat.isFile() && path === preset.dockerfile) {
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
if (destination.exists(path)) {
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
const dir = Path.dirname(path);
|
|
194
|
+
if (!destination.exists(dir)) {
|
|
195
|
+
destination.mkdir(dir, {
|
|
196
|
+
recursive: true
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
await fs.copy(path);
|
|
200
|
+
}
|
|
201
|
+
delete project.preset;
|
|
202
|
+
delete project.imageName;
|
|
203
|
+
await project.save();
|
|
204
|
+
}
|
|
205
|
+
async build(rebuild, presetName) {
|
|
152
206
|
const preset = await this.presetService.get(presetName);
|
|
153
207
|
let buildArgs = {};
|
|
154
208
|
if (preset.buildArgsOptions) {
|
|
@@ -165,5 +219,35 @@ class PresetController extends makes_1.Controller {
|
|
|
165
219
|
src: preset.dockerfile
|
|
166
220
|
});
|
|
167
221
|
}
|
|
168
|
-
}
|
|
222
|
+
};
|
|
169
223
|
exports.PresetController = PresetController;
|
|
224
|
+
__decorate([
|
|
225
|
+
(0, core_1.Command)("preset:eject"),
|
|
226
|
+
__param(0, (0, core_1.Option)("name", {
|
|
227
|
+
type: "string",
|
|
228
|
+
alias: "n",
|
|
229
|
+
description: "Project name"
|
|
230
|
+
})),
|
|
231
|
+
__metadata("design:type", Function),
|
|
232
|
+
__metadata("design:paramtypes", [String]),
|
|
233
|
+
__metadata("design:returntype", Promise)
|
|
234
|
+
], PresetController.prototype, "eject", null);
|
|
235
|
+
__decorate([
|
|
236
|
+
(0, core_1.Command)("preset:build <preset>"),
|
|
237
|
+
__param(0, (0, core_1.Option)("rebuild", {
|
|
238
|
+
type: "boolean",
|
|
239
|
+
alias: "r",
|
|
240
|
+
description: "Rebuild image"
|
|
241
|
+
})),
|
|
242
|
+
__metadata("design:type", Function),
|
|
243
|
+
__metadata("design:paramtypes", [Boolean, String]),
|
|
244
|
+
__metadata("design:returntype", Promise)
|
|
245
|
+
], PresetController.prototype, "build", null);
|
|
246
|
+
exports.PresetController = PresetController = __decorate([
|
|
247
|
+
(0, core_1.Controller)(),
|
|
248
|
+
__metadata("design:paramtypes", [services_1.AppConfigService,
|
|
249
|
+
services_1.AppEventsService,
|
|
250
|
+
services_1.ProjectService,
|
|
251
|
+
services_1.PresetService,
|
|
252
|
+
services_1.DockerService])
|
|
253
|
+
], PresetController);
|
|
@@ -1,72 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
type ListOptions = {
|
|
10
|
-
all?: boolean;
|
|
11
|
-
};
|
|
12
|
-
type StartOptions = {
|
|
13
|
-
name?: string;
|
|
14
|
-
rebuild?: boolean;
|
|
15
|
-
detach?: boolean;
|
|
16
|
-
};
|
|
17
|
-
type StopOptions = {
|
|
18
|
-
name?: string;
|
|
19
|
-
};
|
|
20
|
-
type AttachOptions = {
|
|
21
|
-
name?: string;
|
|
22
|
-
};
|
|
23
|
-
type ConfigOptions = {
|
|
24
|
-
name?: string;
|
|
25
|
-
global?: boolean;
|
|
26
|
-
};
|
|
27
|
-
type BuildArgsOptions = {
|
|
28
|
-
name?: string;
|
|
29
|
-
};
|
|
30
|
-
type VolumeOptions = {
|
|
31
|
-
name?: string;
|
|
32
|
-
};
|
|
33
|
-
type LogsOptions = {
|
|
34
|
-
name?: string;
|
|
35
|
-
global?: boolean;
|
|
36
|
-
detach?: boolean;
|
|
37
|
-
follow?: boolean;
|
|
38
|
-
};
|
|
39
|
-
type ExecOptions = {
|
|
40
|
-
name?: string;
|
|
41
|
-
};
|
|
42
|
-
declare class ProjectController extends Controller {
|
|
43
|
-
protected di: DI;
|
|
44
|
-
protected appConfigService: AppConfigService;
|
|
45
|
-
protected appEventsService: AppEventsService;
|
|
46
|
-
protected projectService: ProjectService;
|
|
47
|
-
protected dockerService: DockerService;
|
|
48
|
-
constructor(di: DI);
|
|
49
|
-
install(cli: Cli): void;
|
|
1
|
+
import { AppConfigService, AppEventsService, ProjectService, DockerService, LogService } from "../services";
|
|
2
|
+
export declare class ProjectController {
|
|
3
|
+
protected readonly appConfigService: AppConfigService;
|
|
4
|
+
protected readonly appEventsService: AppEventsService;
|
|
5
|
+
protected readonly projectService: ProjectService;
|
|
6
|
+
protected readonly dockerService: DockerService;
|
|
7
|
+
protected readonly logService: LogService;
|
|
8
|
+
constructor(appConfigService: AppConfigService, appEventsService: AppEventsService, projectService: ProjectService, dockerService: DockerService, logService: LogService);
|
|
50
9
|
protected getProjectNames(): Promise<string[]>;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
exec(options: ExecOptions, command: string[]): Promise<void>;
|
|
10
|
+
init(name: string, type: string, preset: string): Promise<void>;
|
|
11
|
+
projectList(all: boolean): Promise<string>;
|
|
12
|
+
start(name?: string, detach?: boolean, rebuild?: boolean, restart?: boolean): Promise<void>;
|
|
13
|
+
stop(name: string): Promise<void>;
|
|
14
|
+
run(name: string, script: string): Promise<void>;
|
|
15
|
+
attach(name?: string): Promise<void>;
|
|
16
|
+
configList(name?: string, global?: boolean): Promise<string>;
|
|
17
|
+
configGet(name: string, global: boolean, keys: string[]): Promise<string>;
|
|
18
|
+
configSet(name: string, global: boolean, variables: string[]): Promise<void>;
|
|
19
|
+
configUnset(name: string, global: boolean, configs: string[]): Promise<void>;
|
|
20
|
+
buildArgsList(name?: string): Promise<string>;
|
|
21
|
+
buildArgsGet(name: string, args: string[]): Promise<string>;
|
|
22
|
+
buildArgsSet(name: string, args: string[]): Promise<void>;
|
|
23
|
+
buildArgsUnset(name: string, args: string[]): Promise<void>;
|
|
24
|
+
volumeList(name?: string): Promise<string>;
|
|
25
|
+
volumeMount(name: string, volumes: string[]): Promise<void>;
|
|
26
|
+
volumeUnmount(name: string, volumes: string[]): Promise<void>;
|
|
27
|
+
logs(name: string, global: boolean, detach: boolean, follow: boolean): Promise<void>;
|
|
28
|
+
exec(name?: string, command?: string[]): Promise<void>;
|
|
71
29
|
}
|
|
72
|
-
export { ProjectController };
|