@wocker/ws 1.0.14 → 1.0.15
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/lib/AppModule.js +1 -1
- package/lib/controllers/PresetController.d.ts +2 -1
- package/lib/controllers/PresetController.js +31 -4
- package/lib/controllers/ProjectController.js +4 -4
- package/lib/controllers/ProxyController.d.ts +1 -1
- package/lib/controllers/ProxyController.js +4 -4
- package/lib/plugins/index.d.ts +0 -1
- package/lib/plugins/index.js +0 -1
- package/lib/services/PluginService.js +1 -1
- package/lib/services/PresetService.d.ts +7 -3
- package/lib/services/PresetService.js +158 -21
- package/lib/services/ProjectService.d.ts +2 -2
- package/lib/services/ProjectService.js +12 -12
- package/lib/services/ProxyService.js +10 -20
- package/package.json +5 -3
- package/presets/bun/config.json +1 -0
- package/presets/go/config.json +1 -0
- package/presets/php-fpm/config.json +1 -0
- package/presets/shopify/config.json +2 -0
- package/lib/plugins/PageKitePlugin.d.ts +0 -30
- package/lib/plugins/PageKitePlugin.js +0 -145
- package/plugins/pagekite/Dockerfile +0 -3
- package/presets/node/Dockerfile +0 -39
- package/presets/node/config.json +0 -39
- package/presets/php-apache/Dockerfile +0 -227
- package/presets/php-apache/bin/compare-version +0 -3
- package/presets/php-apache/config.json +0 -64
- package/presets/php-apache/etc/apache2/apache2.conf +0 -230
- package/presets/php-apache/etc/apache2/mods-available/mpm_prefork.conf +0 -16
- package/presets/php-apache/etc/apache2/sites-available/000-default.conf +0 -21
package/lib/AppModule.js
CHANGED
|
@@ -47,7 +47,7 @@ let AppModule = AppModule_1 = class AppModule {
|
|
|
47
47
|
if (!Plugin) {
|
|
48
48
|
continue;
|
|
49
49
|
}
|
|
50
|
-
const name = Reflect.getMetadata(core_1.
|
|
50
|
+
const name = Reflect.getMetadata(core_1.PLUGIN_NAME_METADATA, Plugin);
|
|
51
51
|
Reflect.defineMetadata(core_1.MODULE_METADATA.PROVIDERS, [
|
|
52
52
|
...Reflect.getMetadata(core_1.MODULE_METADATA.PROVIDERS, Plugin) || [],
|
|
53
53
|
{
|
|
@@ -11,7 +11,8 @@ export declare class PresetController {
|
|
|
11
11
|
protected onInit(project: Project): Promise<void>;
|
|
12
12
|
protected onRebuild(project: Project): Promise<void>;
|
|
13
13
|
protected onBeforeStart(project: Project): Promise<void>;
|
|
14
|
-
add(
|
|
14
|
+
add(name: string): Promise<void>;
|
|
15
|
+
delete(name: string, confirm?: boolean): Promise<void>;
|
|
15
16
|
eject(name?: string): Promise<void>;
|
|
16
17
|
build(rebuild: boolean, presetName: string): Promise<void>;
|
|
17
18
|
}
|
|
@@ -115,7 +115,7 @@ let PresetController = class PresetController {
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
async onRebuild(project) {
|
|
118
|
-
if (project.type !==
|
|
118
|
+
if (project.type !== core_1.PROJECT_TYPE_PRESET) {
|
|
119
119
|
return;
|
|
120
120
|
}
|
|
121
121
|
const preset = await this.presetService.get(project.preset);
|
|
@@ -130,7 +130,7 @@ let PresetController = class PresetController {
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
async onBeforeStart(project) {
|
|
133
|
-
if (project.type !==
|
|
133
|
+
if (project.type !== core_1.PROJECT_TYPE_PRESET) {
|
|
134
134
|
return;
|
|
135
135
|
}
|
|
136
136
|
const preset = await this.presetService.get(project.preset);
|
|
@@ -143,13 +143,28 @@ let PresetController = class PresetController {
|
|
|
143
143
|
presetName: preset.name
|
|
144
144
|
},
|
|
145
145
|
buildArgs: project.buildArgs,
|
|
146
|
-
context:
|
|
146
|
+
context: preset.path,
|
|
147
147
|
src: preset.dockerfile
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
-
async add(
|
|
152
|
+
async add(name) {
|
|
153
|
+
await this.presetService.addPreset(name);
|
|
154
|
+
}
|
|
155
|
+
async delete(name, confirm) {
|
|
156
|
+
const preset = await this.presetService.get(name);
|
|
157
|
+
if (typeof confirm === "undefined" || confirm === null) {
|
|
158
|
+
confirm = await (0, utils_2.promptConfirm)({
|
|
159
|
+
message: `Delete preset ${name}?`,
|
|
160
|
+
default: false
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
if (!confirm) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
console.info("Deleting...");
|
|
167
|
+
await preset.delete();
|
|
153
168
|
}
|
|
154
169
|
async eject(name) {
|
|
155
170
|
if (name) {
|
|
@@ -221,10 +236,22 @@ let PresetController = class PresetController {
|
|
|
221
236
|
exports.PresetController = PresetController;
|
|
222
237
|
__decorate([
|
|
223
238
|
(0, core_1.Command)("preset:add <preset>"),
|
|
239
|
+
__param(0, (0, core_1.Param)("preset")),
|
|
224
240
|
__metadata("design:type", Function),
|
|
225
241
|
__metadata("design:paramtypes", [String]),
|
|
226
242
|
__metadata("design:returntype", Promise)
|
|
227
243
|
], PresetController.prototype, "add", null);
|
|
244
|
+
__decorate([
|
|
245
|
+
(0, core_1.Command)("preset:delete <preset>"),
|
|
246
|
+
__param(0, (0, core_1.Param)("preset")),
|
|
247
|
+
__param(1, (0, core_1.Option)("yes", {
|
|
248
|
+
alias: "y",
|
|
249
|
+
description: "Confirm deletion"
|
|
250
|
+
})),
|
|
251
|
+
__metadata("design:type", Function),
|
|
252
|
+
__metadata("design:paramtypes", [String, Boolean]),
|
|
253
|
+
__metadata("design:returntype", Promise)
|
|
254
|
+
], PresetController.prototype, "delete", null);
|
|
228
255
|
__decorate([
|
|
229
256
|
(0, core_1.Command)("preset:eject"),
|
|
230
257
|
__param(0, (0, core_1.Option)("name", {
|
|
@@ -161,19 +161,18 @@ let ProjectController = class ProjectController {
|
|
|
161
161
|
await this.projectService.cdProject(name);
|
|
162
162
|
}
|
|
163
163
|
const project = await this.projectService.get();
|
|
164
|
-
await this.projectService.start(project,
|
|
164
|
+
await this.projectService.start(project, restart, rebuild);
|
|
165
165
|
if (detach) {
|
|
166
166
|
console.info(chalk_1.default.yellow("Warning: Detach option is deprecated"));
|
|
167
167
|
}
|
|
168
168
|
if (attach) {
|
|
169
169
|
const project = await this.projectService.get();
|
|
170
|
-
const
|
|
171
|
-
const container = await this.dockerService.getContainer(containerName);
|
|
170
|
+
const container = await this.dockerService.getContainer(project.containerName);
|
|
172
171
|
await container.resize({
|
|
173
172
|
w: process.stdout.columns,
|
|
174
173
|
h: process.stdout.rows
|
|
175
174
|
});
|
|
176
|
-
await this.dockerService.attach(containerName);
|
|
175
|
+
await this.dockerService.attach(project.containerName);
|
|
177
176
|
}
|
|
178
177
|
}
|
|
179
178
|
async stop(name) {
|
|
@@ -820,6 +819,7 @@ __decorate([
|
|
|
820
819
|
type: "boolean",
|
|
821
820
|
alias: "g"
|
|
822
821
|
})),
|
|
822
|
+
__param(2, (0, core_1.Param)("configs")),
|
|
823
823
|
__metadata("design:type", Function),
|
|
824
824
|
__metadata("design:paramtypes", [String, Boolean, Array]),
|
|
825
825
|
__metadata("design:returntype", Promise)
|
|
@@ -10,7 +10,7 @@ export declare class ProxyController {
|
|
|
10
10
|
onProjectStart(project: Project): Promise<void>;
|
|
11
11
|
onProjectStop(project: Project): Promise<void>;
|
|
12
12
|
getProjectNames(): Promise<string[]>;
|
|
13
|
-
init(httpPort
|
|
13
|
+
init(httpPort?: number, httpsPort?: number): Promise<void>;
|
|
14
14
|
start(restart?: boolean): Promise<void>;
|
|
15
15
|
stop(): Promise<void>;
|
|
16
16
|
logs(): Promise<void>;
|
|
@@ -49,20 +49,20 @@ let ProxyController = class ProxyController {
|
|
|
49
49
|
}
|
|
50
50
|
async init(httpPort, httpsPort) {
|
|
51
51
|
const config = await this.appConfigService.getConfig();
|
|
52
|
-
if (typeof httpPort === "undefined" || isNaN(httpPort)) {
|
|
52
|
+
if (httpPort === null || typeof httpPort === "undefined" || isNaN(httpPort)) {
|
|
53
53
|
httpPort = await (0, utils_1.promptText)({
|
|
54
54
|
required: true,
|
|
55
55
|
message: "Http port:",
|
|
56
|
-
type: "
|
|
56
|
+
type: "number",
|
|
57
57
|
default: config.getMeta("PROXY_HTTP_PORT", "80")
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
config.setMeta("PROXY_HTTP_PORT", httpPort.toString());
|
|
61
|
-
if (typeof httpsPort === "undefined" || isNaN(httpsPort)) {
|
|
61
|
+
if (httpsPort === null || typeof httpsPort === "undefined" || isNaN(httpsPort)) {
|
|
62
62
|
httpsPort = await (0, utils_1.promptText)({
|
|
63
63
|
required: true,
|
|
64
64
|
message: "Https port:",
|
|
65
|
-
type: "
|
|
65
|
+
type: "number",
|
|
66
66
|
default: config.getMeta("PROXY_HTTPS_PORT", "443")
|
|
67
67
|
});
|
|
68
68
|
}
|
package/lib/plugins/index.d.ts
CHANGED
package/lib/plugins/index.js
CHANGED
|
@@ -16,5 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./ElasticSearchPlugin"), exports);
|
|
18
18
|
__exportStar(require("./MongodbPlugin"), exports);
|
|
19
|
-
__exportStar(require("./PageKitePlugin"), exports);
|
|
20
19
|
__exportStar(require("./ProxmoxPlugin"), exports);
|
|
@@ -47,7 +47,7 @@ let PluginService = class PluginService {
|
|
|
47
47
|
async checkPlugin(pluginName) {
|
|
48
48
|
try {
|
|
49
49
|
const { default: Plugin } = await Promise.resolve(`${pluginName}`).then(s => __importStar(require(s)));
|
|
50
|
-
const name = Reflect.getMetadata(core_1.
|
|
50
|
+
const name = Reflect.getMetadata(core_1.PLUGIN_NAME_METADATA, Plugin);
|
|
51
51
|
if (!name) {
|
|
52
52
|
console.log("No name");
|
|
53
53
|
}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { EnvConfig, Preset } from "@wocker/core";
|
|
1
|
+
import { EnvConfig, Preset, Config, PresetProperties, AppConfigService } from "@wocker/core";
|
|
2
2
|
type SearchOptions = Partial<{
|
|
3
3
|
name: string;
|
|
4
|
+
source: string;
|
|
4
5
|
}>;
|
|
5
6
|
export declare class PresetService {
|
|
6
|
-
|
|
7
|
+
protected readonly appConfigService: AppConfigService;
|
|
8
|
+
constructor(appConfigService: AppConfigService);
|
|
9
|
+
protected toObject(config: PresetProperties): Preset;
|
|
10
|
+
protected getList(): Promise<Config["presets"]>;
|
|
7
11
|
getImageName(preset: Preset, buildArgs?: EnvConfig): string;
|
|
8
|
-
save(preset: Preset): Promise<void>;
|
|
9
12
|
get(name: string): Promise<Preset>;
|
|
13
|
+
addPreset(name: string): Promise<void>;
|
|
10
14
|
search(options?: SearchOptions): Promise<Preset[]>;
|
|
11
15
|
searchOne(options?: SearchOptions): Promise<Preset | null>;
|
|
12
16
|
}
|
|
@@ -1,10 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
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;
|
|
17
|
+
});
|
|
2
18
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
19
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
20
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
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;
|
|
6
22
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
23
|
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
8
31
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
32
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
33
|
};
|
|
@@ -15,10 +38,64 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
38
|
exports.PresetService = void 0;
|
|
16
39
|
const core_1 = require("@wocker/core");
|
|
17
40
|
const md5_1 = __importDefault(require("md5"));
|
|
41
|
+
const axios_1 = __importDefault(require("axios"));
|
|
42
|
+
const unzipper_1 = require("unzipper");
|
|
43
|
+
const Path = __importStar(require("path"));
|
|
18
44
|
const env_1 = require("../env");
|
|
19
45
|
const makes_1 = require("../makes");
|
|
20
46
|
let PresetService = class PresetService {
|
|
21
|
-
constructor() {
|
|
47
|
+
constructor(appConfigService) {
|
|
48
|
+
this.appConfigService = appConfigService;
|
|
49
|
+
}
|
|
50
|
+
toObject(config) {
|
|
51
|
+
const _this = this;
|
|
52
|
+
return new class extends core_1.Preset {
|
|
53
|
+
constructor(data) {
|
|
54
|
+
super(data);
|
|
55
|
+
}
|
|
56
|
+
async save() {
|
|
57
|
+
const { source, path, ...rest } = this.toJSON();
|
|
58
|
+
const config = await _this.appConfigService.getConfig();
|
|
59
|
+
let presetData = config.presets.find((presetData) => {
|
|
60
|
+
return presetData.name === this.name;
|
|
61
|
+
});
|
|
62
|
+
if (!makes_1.FS.existsSync(_this.appConfigService.dataPath("presets", this.name))) {
|
|
63
|
+
makes_1.FS.mkdirSync(_this.appConfigService.dataPath("presets", this.name), {
|
|
64
|
+
recursive: true
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
await makes_1.FS.writeJSON(_this.appConfigService.dataPath("presets", this.name, "config.json"), rest);
|
|
68
|
+
if (!presetData) {
|
|
69
|
+
config.registerPreset(this.name, source);
|
|
70
|
+
await config.save();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async delete() {
|
|
74
|
+
if (this.source === core_1.PRESET_SOURCE_GITHUB) {
|
|
75
|
+
const config = await _this.appConfigService.getConfig();
|
|
76
|
+
await makes_1.FS.rm(_this.appConfigService.dataPath("presets", this.name), {
|
|
77
|
+
recursive: true
|
|
78
|
+
});
|
|
79
|
+
config.unregisterPreset(this.name);
|
|
80
|
+
await config.save();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}(config);
|
|
84
|
+
}
|
|
85
|
+
async getList() {
|
|
86
|
+
const dirs = await makes_1.FS.readdir(env_1.PRESETS_DIR);
|
|
87
|
+
const { presets } = await this.appConfigService.getConfig();
|
|
88
|
+
return [
|
|
89
|
+
...dirs.map((name) => {
|
|
90
|
+
return {
|
|
91
|
+
name,
|
|
92
|
+
source: core_1.PRESET_SOURCE_INTERNAL,
|
|
93
|
+
path: Path.join(env_1.PRESETS_DIR, name)
|
|
94
|
+
};
|
|
95
|
+
}),
|
|
96
|
+
...presets
|
|
97
|
+
];
|
|
98
|
+
}
|
|
22
99
|
getImageName(preset, buildArgs = {}) {
|
|
23
100
|
const rawValues = [];
|
|
24
101
|
const hashValues = [];
|
|
@@ -34,38 +111,98 @@ let PresetService = class PresetService {
|
|
|
34
111
|
});
|
|
35
112
|
const version = [
|
|
36
113
|
...rawValues,
|
|
37
|
-
(0, md5_1.default)(hashValues.join(",")).
|
|
114
|
+
(0, md5_1.default)(hashValues.join(",")).substring(0, 6)
|
|
38
115
|
].filter((value) => {
|
|
39
116
|
return !!value;
|
|
40
117
|
}).join("-");
|
|
41
118
|
return `ws-preset-${preset.name}:${version}`;
|
|
42
119
|
}
|
|
43
|
-
async save(preset) {
|
|
44
|
-
}
|
|
45
120
|
async get(name) {
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
121
|
+
const list = await this.getList();
|
|
122
|
+
const item = list.find((item) => {
|
|
123
|
+
return item.name === name;
|
|
124
|
+
});
|
|
125
|
+
if (!item) {
|
|
126
|
+
throw new Error(`Preset ${name} not found`);
|
|
127
|
+
}
|
|
128
|
+
if (item.source === core_1.PRESET_SOURCE_GITHUB) {
|
|
129
|
+
item.path = this.appConfigService.dataPath("presets", item.name);
|
|
130
|
+
}
|
|
131
|
+
else if (item.source === core_1.PRESET_SOURCE_INTERNAL) {
|
|
132
|
+
item.path = Path.join(env_1.PRESETS_DIR, item.name);
|
|
133
|
+
}
|
|
134
|
+
const config = await makes_1.FS.readJSON(item.path, "config.json");
|
|
135
|
+
return this.toObject({
|
|
136
|
+
...item,
|
|
56
137
|
...config
|
|
57
138
|
});
|
|
58
139
|
}
|
|
140
|
+
async addPreset(name) {
|
|
141
|
+
let preset = await this.searchOne({
|
|
142
|
+
name
|
|
143
|
+
});
|
|
144
|
+
if (!preset) {
|
|
145
|
+
console.info("Loading...");
|
|
146
|
+
const res = await makes_1.Http.get("https://raw.githubusercontent.com")
|
|
147
|
+
.withHeader("User-Agent", "Wocker")
|
|
148
|
+
.send(`/kearisp/wocker-${name}-preset/master/config.json`);
|
|
149
|
+
preset = this.toObject(res.data);
|
|
150
|
+
preset.source = core_1.PRESET_SOURCE_GITHUB;
|
|
151
|
+
preset.path = this.appConfigService.dataPath("presets", preset.name);
|
|
152
|
+
const zipRes = await axios_1.default.create({
|
|
153
|
+
baseURL: "https://github.com",
|
|
154
|
+
headers: {
|
|
155
|
+
"User-Agent": "Wocker"
|
|
156
|
+
}
|
|
157
|
+
}).get(`/kearisp/wocker-${preset.name}-preset/archive/refs/heads/master.zip`, {
|
|
158
|
+
responseType: "stream"
|
|
159
|
+
});
|
|
160
|
+
makes_1.FS.mkdirSync(preset.path, {
|
|
161
|
+
recursive: true
|
|
162
|
+
});
|
|
163
|
+
zipRes.data.pipe((0, unzipper_1.Parse)()).on("entry", (entry) => {
|
|
164
|
+
const path = entry.path.replace(/^[^\/]+\//, "");
|
|
165
|
+
if (path === "config.json") {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const fullPath = this.appConfigService.dataPath("presets", preset.name, path);
|
|
169
|
+
if (entry.type === "File") {
|
|
170
|
+
entry.pipe(makes_1.FS.createWriteStream(fullPath));
|
|
171
|
+
}
|
|
172
|
+
else if (entry.type === "Directory") {
|
|
173
|
+
makes_1.FS.mkdirSync(fullPath, {
|
|
174
|
+
recursive: true
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
await preset.save();
|
|
179
|
+
}
|
|
180
|
+
console.log(preset.version);
|
|
181
|
+
}
|
|
59
182
|
async search(options = {}) {
|
|
60
|
-
const { name } = options;
|
|
183
|
+
const { name, source } = options;
|
|
61
184
|
const presets = [];
|
|
62
|
-
const
|
|
63
|
-
for (const
|
|
64
|
-
if (name && name !==
|
|
185
|
+
const presetConfigs = await this.getList();
|
|
186
|
+
for (const presetConfig of presetConfigs) {
|
|
187
|
+
if (name && name !== presetConfig.name) {
|
|
65
188
|
continue;
|
|
66
189
|
}
|
|
67
|
-
|
|
68
|
-
|
|
190
|
+
if (source && source !== presetConfig.source) {
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
try {
|
|
194
|
+
const fullConfig = await makes_1.FS.readJSON(presetConfig.path, "config.json");
|
|
195
|
+
if (!fullConfig.name) {
|
|
196
|
+
console.log(presetConfig.name);
|
|
197
|
+
}
|
|
198
|
+
const preset = this.toObject({
|
|
199
|
+
...presetConfig,
|
|
200
|
+
...fullConfig
|
|
201
|
+
});
|
|
202
|
+
presets.push(preset);
|
|
203
|
+
}
|
|
204
|
+
catch (err) {
|
|
205
|
+
}
|
|
69
206
|
}
|
|
70
207
|
return presets;
|
|
71
208
|
}
|
|
@@ -77,5 +214,5 @@ let PresetService = class PresetService {
|
|
|
77
214
|
exports.PresetService = PresetService;
|
|
78
215
|
exports.PresetService = PresetService = __decorate([
|
|
79
216
|
(0, core_1.Injectable)(),
|
|
80
|
-
__metadata("design:paramtypes", [])
|
|
217
|
+
__metadata("design:paramtypes", [core_1.AppConfigService])
|
|
81
218
|
], PresetService);
|
|
@@ -11,10 +11,10 @@ declare class ProjectService {
|
|
|
11
11
|
protected readonly dockerService: DockerService;
|
|
12
12
|
constructor(appConfigService: AppConfigService, appEventsService: AppEventsService, dockerService: DockerService);
|
|
13
13
|
fromObject(data: Partial<ProjectProperties>): Project;
|
|
14
|
+
get(): Promise<Project>;
|
|
14
15
|
getById(id: string): Promise<Project>;
|
|
15
16
|
cdProject(name: string): Promise<void>;
|
|
16
|
-
|
|
17
|
-
start(project: Project, rebuild?: boolean, restart?: boolean): Promise<void>;
|
|
17
|
+
start(project: Project, restart?: boolean, rebuild?: boolean): Promise<void>;
|
|
18
18
|
stop(project: Project): Promise<void>;
|
|
19
19
|
save(project: Project): Promise<void>;
|
|
20
20
|
search(params?: Partial<SearchParams>): Promise<Project[]>;
|
|
@@ -54,6 +54,15 @@ let ProjectService = class ProjectService {
|
|
|
54
54
|
}
|
|
55
55
|
}(data);
|
|
56
56
|
}
|
|
57
|
+
async get() {
|
|
58
|
+
const project = await this.searchOne({
|
|
59
|
+
path: this.appConfigService.getPWD()
|
|
60
|
+
});
|
|
61
|
+
if (!project) {
|
|
62
|
+
throw new Error("Project not found");
|
|
63
|
+
}
|
|
64
|
+
return project;
|
|
65
|
+
}
|
|
57
66
|
async getById(id) {
|
|
58
67
|
const data = await makes_1.FS.readJSON(this.appConfigService.dataPath("projects", id, "config.json"));
|
|
59
68
|
return this.fromObject(data);
|
|
@@ -67,16 +76,7 @@ let ProjectService = class ProjectService {
|
|
|
67
76
|
}
|
|
68
77
|
this.appConfigService.setPWD(project.path);
|
|
69
78
|
}
|
|
70
|
-
async
|
|
71
|
-
const project = await this.searchOne({
|
|
72
|
-
path: this.appConfigService.getPWD()
|
|
73
|
-
});
|
|
74
|
-
if (!project) {
|
|
75
|
-
throw new Error("Project not found");
|
|
76
|
-
}
|
|
77
|
-
return project;
|
|
78
|
-
}
|
|
79
|
-
async start(project, rebuild, restart) {
|
|
79
|
+
async start(project, restart, rebuild) {
|
|
80
80
|
let container = await this.dockerService.getContainer(project.containerName);
|
|
81
81
|
if (container && (restart || rebuild)) {
|
|
82
82
|
container = null;
|
|
@@ -84,8 +84,7 @@ let ProjectService = class ProjectService {
|
|
|
84
84
|
await this.dockerService.removeContainer(project.containerName);
|
|
85
85
|
}
|
|
86
86
|
if (!container) {
|
|
87
|
-
|
|
88
|
-
if (project.type === "dockerfile") {
|
|
87
|
+
if (project.type === core_1.PROJECT_TYPE_DOCKERFILE) {
|
|
89
88
|
project.imageName = `project-${project.name}:develop`;
|
|
90
89
|
if (rebuild) {
|
|
91
90
|
await this.dockerService.imageRm(project.imageName);
|
|
@@ -105,6 +104,7 @@ let ProjectService = class ProjectService {
|
|
|
105
104
|
if (rebuild) {
|
|
106
105
|
await this.appEventsService.emit("project:rebuild", project);
|
|
107
106
|
}
|
|
107
|
+
await this.appEventsService.emit("project:beforeStart", project);
|
|
108
108
|
const config = await this.appConfigService.getConfig();
|
|
109
109
|
container = await this.dockerService.createContainer({
|
|
110
110
|
name: project.containerName,
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.ProxyService = void 0;
|
|
13
13
|
const core_1 = require("@wocker/core");
|
|
14
14
|
const utils_1 = require("@wocker/utils");
|
|
15
|
-
const
|
|
15
|
+
const makes_1 = require("../makes");
|
|
16
16
|
const AppConfigService_1 = require("./AppConfigService");
|
|
17
17
|
const DockerService_1 = require("./DockerService");
|
|
18
18
|
let ProxyService = class ProxyService {
|
|
@@ -23,35 +23,25 @@ let ProxyService = class ProxyService {
|
|
|
23
23
|
this.imageName = "nginxproxy/nginx-proxy";
|
|
24
24
|
}
|
|
25
25
|
async init(project) {
|
|
26
|
-
const
|
|
27
|
-
message: "
|
|
28
|
-
|
|
26
|
+
const appPort = await (0, utils_1.promptText)({
|
|
27
|
+
message: "App port:",
|
|
28
|
+
type: "number",
|
|
29
|
+
default: project.getEnv("VIRTUAL_PORT", "80")
|
|
29
30
|
});
|
|
30
|
-
|
|
31
|
-
const appPort = await (0, utils_1.promptText)({
|
|
32
|
-
message: "App port:",
|
|
33
|
-
type: "number",
|
|
34
|
-
default: project.getEnv("VIRTUAL_PORT", "80")
|
|
35
|
-
});
|
|
36
|
-
project.setEnv("VIRTUAL_PORT", appPort);
|
|
37
|
-
project.setMeta("WITH_PROXY", "true");
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
project.setMeta("WITH_PROXY", "false");
|
|
41
|
-
}
|
|
31
|
+
project.setEnv("VIRTUAL_PORT", appPort);
|
|
42
32
|
await project.save();
|
|
43
33
|
}
|
|
44
34
|
async start(restart) {
|
|
45
|
-
console.info("Proxy starting...");
|
|
46
35
|
if (restart) {
|
|
47
36
|
await this.stop();
|
|
48
37
|
}
|
|
49
38
|
let container = await this.dockerService.getContainer(this.containerName);
|
|
50
39
|
if (!container) {
|
|
40
|
+
console.info("Proxy starting...");
|
|
51
41
|
await this.dockerService.pullImage(this.imageName);
|
|
52
42
|
const certsDir = this.appConfigService.dataPath("certs");
|
|
53
|
-
if (!
|
|
54
|
-
|
|
43
|
+
if (!makes_1.FS.existsSync(certsDir)) {
|
|
44
|
+
makes_1.FS.mkdirSync(certsDir, {
|
|
55
45
|
recursive: true,
|
|
56
46
|
mode: 0o700
|
|
57
47
|
});
|
|
@@ -77,8 +67,8 @@ let ProxyService = class ProxyService {
|
|
|
77
67
|
});
|
|
78
68
|
const { State: { Status } } = await container.inspect();
|
|
79
69
|
if (["created", "exited"].includes(Status)) {
|
|
80
|
-
console.info("Starting...");
|
|
81
70
|
await container.start();
|
|
71
|
+
console.info("Started");
|
|
82
72
|
}
|
|
83
73
|
}
|
|
84
74
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wocker/ws",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"author": "Kris Papercut <krispcut@gmail.com>",
|
|
5
5
|
"description": "Docker workspace for web projects",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"lint": "eslint \"**/*.{js,jsx,ts,tsx}\""
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@wocker/core": "^1.0.
|
|
28
|
+
"@wocker/core": "^1.0.14",
|
|
29
29
|
"@wocker/utils": "^1.0.5",
|
|
30
30
|
"async-mutex": "^0.4.0",
|
|
31
31
|
"axios": "^1.6.7",
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"md5": "^2.3.0",
|
|
39
39
|
"os": "^0.1.2",
|
|
40
40
|
"path": "^0.12.7",
|
|
41
|
-
"readable-stream": "^4.1.0"
|
|
41
|
+
"readable-stream": "^4.1.0",
|
|
42
|
+
"unzipper": "^0.12.3"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
45
|
"@types/dockerode": "3.3.23",
|
|
@@ -48,6 +49,7 @@
|
|
|
48
49
|
"@types/mute-stream": "^0.0.1",
|
|
49
50
|
"@types/node": "^20.11.16",
|
|
50
51
|
"@types/readable-stream": "^2.3.15",
|
|
52
|
+
"@types/unzipper": "^0.10.10",
|
|
51
53
|
"@typescript-eslint/eslint-plugin": "^6.5.0",
|
|
52
54
|
"@typescript-eslint/parser": "^6.5.0",
|
|
53
55
|
"eslint": "^8.48.0",
|
package/presets/bun/config.json
CHANGED
package/presets/go/config.json
CHANGED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Project } from "@wocker/core";
|
|
2
|
-
import { AppConfigService, AppEventsService, ProjectService, DockerService } from "../services";
|
|
3
|
-
type InitOptions = {};
|
|
4
|
-
type StartOptions = {
|
|
5
|
-
name?: string;
|
|
6
|
-
detach?: boolean;
|
|
7
|
-
restart?: boolean;
|
|
8
|
-
rebuild?: boolean;
|
|
9
|
-
};
|
|
10
|
-
type StopOptions = {
|
|
11
|
-
name?: string;
|
|
12
|
-
};
|
|
13
|
-
type BuildOptions = {
|
|
14
|
-
rebuild?: boolean;
|
|
15
|
-
};
|
|
16
|
-
export declare class PageKitePlugin {
|
|
17
|
-
protected readonly appConfigService: AppConfigService;
|
|
18
|
-
protected readonly appEventsService: AppEventsService;
|
|
19
|
-
protected readonly projectService: ProjectService;
|
|
20
|
-
protected readonly dockerService: DockerService;
|
|
21
|
-
constructor(appConfigService: AppConfigService, appEventsService: AppEventsService, projectService: ProjectService, dockerService: DockerService);
|
|
22
|
-
pluginPath(...parts: string[]): string;
|
|
23
|
-
onProjectStart(project: Project): Promise<void>;
|
|
24
|
-
onProjectStop(project: Project): Promise<void>;
|
|
25
|
-
init(options: InitOptions): Promise<void>;
|
|
26
|
-
start(options: StartOptions): Promise<void>;
|
|
27
|
-
stop(options: StopOptions): Promise<void>;
|
|
28
|
-
build(options?: BuildOptions): Promise<void>;
|
|
29
|
-
}
|
|
30
|
-
export {};
|