@wocker/ws 1.0.2 → 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 +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/env.js +33 -15
- package/lib/index.d.ts +2 -0
- package/lib/index.js +30 -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.js +328 -304
- 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,150 +1,169 @@
|
|
|
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
|
});
|
|
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 });
|
|
6
26
|
exports.PresetController = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this.dockerService = di.resolveService(_core.DockerService);
|
|
22
|
-
}
|
|
23
|
-
install(cli) {
|
|
24
|
-
super.install(cli);
|
|
25
|
-
this.appConfigService.registerProjectType("preset", "Preset");
|
|
26
|
-
this.appEventsService.on("project:init", project => this.onInit(project));
|
|
27
|
-
this.appEventsService.on("project:beforeStart", project => this.onBeforeStart(project));
|
|
28
|
-
this.appEventsService.on("project:rebuild", project => this.onRebuild(project));
|
|
29
|
-
cli.command("preset:build <preset>").completion("preset", () => this.presets()).option("rebuild", {
|
|
30
|
-
type: "boolean",
|
|
31
|
-
alias: "r",
|
|
32
|
-
description: "Rebuild image"
|
|
33
|
-
}).action((options, preset) => this.build(options, preset));
|
|
34
|
-
}
|
|
35
|
-
async presets() {
|
|
36
|
-
const presets = await this.presetService.search();
|
|
37
|
-
return presets.map(preset => {
|
|
38
|
-
return preset.name;
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
async onInit(project) {
|
|
42
|
-
if (project.type !== "preset") {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const presets = await this.presetService.search();
|
|
46
|
-
if (presets.length === 0) {
|
|
47
|
-
throw new Error("No presets");
|
|
48
|
-
}
|
|
49
|
-
project.preset = await (0, _utils.promptSelect)({
|
|
50
|
-
message: "Choose preset:",
|
|
51
|
-
options: presets.map(preset => {
|
|
52
|
-
return {
|
|
53
|
-
label: preset.name,
|
|
54
|
-
value: preset.name
|
|
55
|
-
};
|
|
56
|
-
}),
|
|
57
|
-
default: project.preset
|
|
58
|
-
});
|
|
59
|
-
const preset = await this.presetService.get(project.preset);
|
|
60
|
-
if (!preset) {
|
|
61
|
-
throw new Error("Preset not found");
|
|
27
|
+
const utils_1 = require("@wocker/utils");
|
|
28
|
+
const Path = __importStar(require("path"));
|
|
29
|
+
const env_1 = require("../env");
|
|
30
|
+
const utils_2 = require("../utils");
|
|
31
|
+
const makes_1 = require("../makes");
|
|
32
|
+
const services_1 = require("../services");
|
|
33
|
+
class PresetController extends makes_1.Controller {
|
|
34
|
+
constructor(di) {
|
|
35
|
+
super();
|
|
36
|
+
this.appConfigService = di.resolveService(services_1.AppConfigService);
|
|
37
|
+
this.appEventsService = di.resolveService(services_1.AppEventsService);
|
|
38
|
+
this.projectService = di.resolveService(services_1.ProjectService);
|
|
39
|
+
this.presetService = di.resolveService(services_1.PresetService);
|
|
40
|
+
this.dockerService = di.resolveService(services_1.DockerService);
|
|
62
41
|
}
|
|
63
|
-
|
|
64
|
-
|
|
42
|
+
install(cli) {
|
|
43
|
+
super.install(cli);
|
|
44
|
+
this.appConfigService.registerProjectType("preset", "Preset");
|
|
45
|
+
this.appEventsService.on("project:init", (project) => this.onInit(project));
|
|
46
|
+
this.appEventsService.on("project:beforeStart", (project) => this.onBeforeStart(project));
|
|
47
|
+
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));
|
|
65
56
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
for (let volume of preset.volumeOptions) {
|
|
71
|
-
volume = (0, _utils2.injectVariables)(volume, {
|
|
72
|
-
...(project.buildArgs || {}),
|
|
73
|
-
...(project.env || {})
|
|
74
|
-
});
|
|
75
|
-
const {
|
|
76
|
-
destination,
|
|
77
|
-
options
|
|
78
|
-
} = (0, _utils2.volumeParse)(volume);
|
|
79
|
-
let projectVolume = project.getVolumeByDestination(destination);
|
|
80
|
-
const source = await (0, _utils.promptText)({
|
|
81
|
-
message: "Volume",
|
|
82
|
-
suffix: `:${destination}`,
|
|
83
|
-
default: projectVolume ? (0, _utils2.volumeParse)(projectVolume).source : "./"
|
|
57
|
+
async presets() {
|
|
58
|
+
const presets = await this.presetService.search();
|
|
59
|
+
return presets.map((preset) => {
|
|
60
|
+
return preset.name;
|
|
84
61
|
});
|
|
85
|
-
projectVolume = (0, _utils2.volumeFormat)({
|
|
86
|
-
source,
|
|
87
|
-
destination,
|
|
88
|
-
options
|
|
89
|
-
});
|
|
90
|
-
project.volumeMount(projectVolume);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
if (preset.dockerfile) {
|
|
94
|
-
project.imageName = preset.getImageName(project.buildArgs);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
async onRebuild(project) {
|
|
98
|
-
if (project.type !== "preset") {
|
|
99
|
-
return;
|
|
100
62
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
63
|
+
async onInit(project) {
|
|
64
|
+
if (project.type !== "preset") {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const presets = await this.presetService.search();
|
|
68
|
+
if (presets.length === 0) {
|
|
69
|
+
throw new Error("No presets");
|
|
70
|
+
}
|
|
71
|
+
project.preset = await (0, utils_1.promptSelect)({
|
|
72
|
+
message: "Choose preset:",
|
|
73
|
+
options: presets.map((preset) => {
|
|
74
|
+
return {
|
|
75
|
+
label: preset.name,
|
|
76
|
+
value: preset.name
|
|
77
|
+
};
|
|
78
|
+
}),
|
|
79
|
+
default: project.preset
|
|
80
|
+
});
|
|
81
|
+
const preset = await this.presetService.get(project.preset);
|
|
82
|
+
if (!preset) {
|
|
83
|
+
throw new Error("Preset not found");
|
|
84
|
+
}
|
|
85
|
+
if (preset.buildArgsOptions) {
|
|
86
|
+
project.buildArgs = await (0, utils_1.promptConfig)(preset.buildArgsOptions, project.buildArgs);
|
|
87
|
+
}
|
|
88
|
+
if (preset.envOptions) {
|
|
89
|
+
project.env = await (0, utils_1.promptConfig)(preset.envOptions, project.env);
|
|
90
|
+
}
|
|
91
|
+
if (preset.volumeOptions) {
|
|
92
|
+
for (let volume of preset.volumeOptions) {
|
|
93
|
+
volume = (0, utils_2.injectVariables)(volume, {
|
|
94
|
+
...project.buildArgs || {},
|
|
95
|
+
...project.env || {}
|
|
96
|
+
});
|
|
97
|
+
const { destination, options } = (0, utils_2.volumeParse)(volume);
|
|
98
|
+
let projectVolume = project.getVolumeByDestination(destination);
|
|
99
|
+
const source = await (0, utils_1.promptText)({
|
|
100
|
+
message: "Volume",
|
|
101
|
+
suffix: `:${destination}`,
|
|
102
|
+
default: projectVolume ? (0, utils_2.volumeParse)(projectVolume).source : "./"
|
|
103
|
+
});
|
|
104
|
+
projectVolume = (0, utils_2.volumeFormat)({
|
|
105
|
+
source,
|
|
106
|
+
destination,
|
|
107
|
+
options
|
|
108
|
+
});
|
|
109
|
+
project.volumeMount(projectVolume);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (preset.dockerfile) {
|
|
113
|
+
project.imageName = preset.getImageName(project.buildArgs);
|
|
114
|
+
}
|
|
104
115
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
116
|
+
async onRebuild(project) {
|
|
117
|
+
if (project.type !== "preset") {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const preset = await this.presetService.get(project.preset);
|
|
121
|
+
if (!preset) {
|
|
122
|
+
throw new Error(`Preset ${project.preset} not found`);
|
|
123
|
+
}
|
|
124
|
+
const imageName = preset.getImageName(project.buildArgs || {});
|
|
125
|
+
const exists = await this.dockerService.imageExists(imageName);
|
|
126
|
+
if (exists) {
|
|
127
|
+
console.info(`Removing image: ${imageName}`);
|
|
128
|
+
await this.dockerService.imageRm(imageName);
|
|
129
|
+
}
|
|
110
130
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
131
|
+
async onBeforeStart(project) {
|
|
132
|
+
if (project.type !== "preset") {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const preset = await this.presetService.get(project.preset);
|
|
136
|
+
if (preset.dockerfile) {
|
|
137
|
+
project.imageName = preset.getImageName(project.buildArgs);
|
|
138
|
+
if (!await this.dockerService.imageExists(project.imageName)) {
|
|
139
|
+
await this.dockerService.buildImage({
|
|
140
|
+
tag: project.imageName,
|
|
141
|
+
labels: {
|
|
142
|
+
presetName: preset.name
|
|
143
|
+
},
|
|
144
|
+
buildArgs: project.buildArgs,
|
|
145
|
+
context: Path.join(env_1.PRESETS_DIR, preset.name),
|
|
146
|
+
src: preset.dockerfile
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
115
150
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
151
|
+
async build(options, presetName) {
|
|
152
|
+
const preset = await this.presetService.get(presetName);
|
|
153
|
+
let buildArgs = {};
|
|
154
|
+
if (preset.buildArgsOptions) {
|
|
155
|
+
buildArgs = await (0, utils_1.promptGroup)(preset.buildArgsOptions);
|
|
156
|
+
}
|
|
157
|
+
const imageName = preset.getImageName(buildArgs);
|
|
120
158
|
await this.dockerService.buildImage({
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
159
|
+
tag: imageName,
|
|
160
|
+
labels: {
|
|
161
|
+
presetName: preset.name
|
|
162
|
+
},
|
|
163
|
+
buildArgs: buildArgs,
|
|
164
|
+
context: Path.join(env_1.PRESETS_DIR, preset.name),
|
|
165
|
+
src: preset.dockerfile
|
|
128
166
|
});
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
async build(options, presetName) {
|
|
133
|
-
const preset = await this.presetService.get(presetName);
|
|
134
|
-
let buildArgs = {};
|
|
135
|
-
if (preset.buildArgsOptions) {
|
|
136
|
-
buildArgs = await (0, _utils.promptGroup)(preset.buildArgsOptions);
|
|
137
167
|
}
|
|
138
|
-
const imageName = preset.getImageName(buildArgs);
|
|
139
|
-
await this.dockerService.buildImage({
|
|
140
|
-
tag: imageName,
|
|
141
|
-
labels: {
|
|
142
|
-
presetName: preset.name
|
|
143
|
-
},
|
|
144
|
-
buildArgs: buildArgs,
|
|
145
|
-
context: Path.join(_env.PRESETS_DIR, preset.name),
|
|
146
|
-
src: preset.dockerfile
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
168
|
}
|
|
150
|
-
exports.PresetController = PresetController;
|
|
169
|
+
exports.PresetController = PresetController;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DI, AppConfigService as CoreAppConfigService, AppEventsService as CoreAppEventsService, ProjectService as CoreProjectService, DockerService } from "@wocker/core";
|
|
2
1
|
import { Cli } from "@kearisp/cli";
|
|
3
|
-
import { Controller } from "
|
|
2
|
+
import { DI, Controller } from "../makes";
|
|
3
|
+
import { AppConfigService, AppEventsService, ProjectService, DockerService } from "../services";
|
|
4
4
|
type InitOptions = {
|
|
5
5
|
name?: string;
|
|
6
6
|
type?: string;
|
|
@@ -41,9 +41,9 @@ type ExecOptions = {
|
|
|
41
41
|
};
|
|
42
42
|
declare class ProjectController extends Controller {
|
|
43
43
|
protected di: DI;
|
|
44
|
-
protected appConfigService:
|
|
45
|
-
protected appEventsService:
|
|
46
|
-
protected projectService:
|
|
44
|
+
protected appConfigService: AppConfigService;
|
|
45
|
+
protected appEventsService: AppEventsService;
|
|
46
|
+
protected projectService: ProjectService;
|
|
47
47
|
protected dockerService: DockerService;
|
|
48
48
|
constructor(di: DI);
|
|
49
49
|
install(cli: Cli): void;
|