@wocker/ws 1.0.8 → 1.0.10
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 +1 -12
- package/lib/AppModule.js +6 -3
- package/lib/controllers/DebugController.d.ts +8 -0
- package/lib/controllers/DebugController.js +46 -0
- package/lib/controllers/ImageController.js +1 -1
- package/lib/controllers/PluginController.d.ts +2 -0
- package/lib/controllers/PluginController.js +42 -41
- package/lib/controllers/PresetController.d.ts +1 -0
- package/lib/controllers/PresetController.js +67 -6
- package/lib/controllers/ProjectController.d.ts +2 -3
- package/lib/controllers/ProjectController.js +58 -68
- package/lib/controllers/ProxyController.js +15 -6
- package/lib/controllers/index.d.ts +1 -0
- package/lib/controllers/index.js +1 -0
- package/lib/main.d.ts +1 -1
- package/lib/main.js +22 -2
- package/lib/makes/FS.d.ts +3 -5
- package/lib/makes/FS.js +3 -21
- package/lib/makes/Http.d.ts +18 -0
- package/lib/makes/Http.js +72 -0
- package/lib/makes/Preset.d.ts +2 -2
- package/lib/makes/index.d.ts +1 -0
- package/lib/makes/index.js +1 -0
- package/lib/plugins/index.d.ts +0 -2
- package/lib/plugins/index.js +0 -2
- package/lib/services/AppConfigService.d.ts +6 -16
- package/lib/services/AppConfigService.js +29 -113
- package/lib/services/DockerService.d.ts +2 -1
- package/lib/services/DockerService.js +31 -11
- package/lib/services/PluginService.d.ts +9 -2
- package/lib/services/PluginService.js +85 -3
- package/lib/services/PresetService.d.ts +1 -2
- package/lib/services/PresetService.js +19 -7
- package/lib/services/ProjectService.js +18 -13
- 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 -6
- package/lib/utils/index.js +0 -6
- package/lib/utils/spawn.d.ts +1 -1
- package/lib/utils/spawn.js +20 -12
- package/package.json +4 -6
- package/presets/php-apache/Dockerfile +1 -1
- package/presets/php-apache/config.json +2 -1
- package/lib/App.d.ts +0 -11
- package/lib/App.js +0 -81
- package/lib/index.d.ts +0 -5
- package/lib/index.js +0 -22
- package/lib/plugins/NgrokPlugin.d.ts +0 -37
- package/lib/plugins/NgrokPlugin.js +0 -254
- package/lib/plugins/RedisPlugin.d.ts +0 -16
- package/lib/plugins/RedisPlugin.js +0 -91
- package/lib/utils/buildOptions.d.ts +0 -1
- package/lib/utils/buildOptions.js +0 -9
- 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
- package/plugins/ngrok/Dockerfile +0 -2
package/bin/ws.js
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const chalk = require("chalk");
|
|
4
3
|
const {app} = require("../lib/main.js");
|
|
5
4
|
|
|
6
5
|
|
|
7
|
-
app.run(process.argv)
|
|
8
|
-
if(!res) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
process.stdout.write(res);
|
|
13
|
-
}).catch((err) => {
|
|
14
|
-
console.error(chalk.red(err.message));
|
|
15
|
-
|
|
16
|
-
// throw err;
|
|
17
|
-
});
|
|
6
|
+
app.run(process.argv);
|
package/lib/AppModule.js
CHANGED
|
@@ -38,10 +38,10 @@ let AppModule = AppModule_1 = class AppModule {
|
|
|
38
38
|
async load(container) {
|
|
39
39
|
const appConfigService = container.getModule(AppModule_1).get(services_1.AppConfigService);
|
|
40
40
|
const logService = container.getModule(AppModule_1).get(services_1.LogService);
|
|
41
|
-
const
|
|
42
|
-
const
|
|
41
|
+
const pluginService = container.getModule(AppModule_1).get(services_1.PluginService);
|
|
42
|
+
const config = await appConfigService.getConfig();
|
|
43
43
|
const imports = [];
|
|
44
|
-
for (const plugin of plugins) {
|
|
44
|
+
for (const plugin of config.plugins) {
|
|
45
45
|
try {
|
|
46
46
|
const { default: Plugin } = await Promise.resolve(`${plugin}`).then(s => __importStar(require(s)));
|
|
47
47
|
if (!Plugin) {
|
|
@@ -59,6 +59,8 @@ let AppModule = AppModule_1 = class AppModule {
|
|
|
59
59
|
}
|
|
60
60
|
catch (err) {
|
|
61
61
|
logService.error(err.message);
|
|
62
|
+
config.removePlugin(plugin);
|
|
63
|
+
await config.save();
|
|
62
64
|
throw err;
|
|
63
65
|
}
|
|
64
66
|
}
|
|
@@ -72,6 +74,7 @@ exports.AppModule = AppModule = AppModule_1 = __decorate([
|
|
|
72
74
|
(0, core_1.Module)({
|
|
73
75
|
controllers: [
|
|
74
76
|
controllers_1.CompletionController,
|
|
77
|
+
controllers_1.DebugController,
|
|
75
78
|
controllers_1.ImageController,
|
|
76
79
|
controllers_1.PluginController,
|
|
77
80
|
controllers_1.PresetController,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AppConfigService, LogService } from "../services";
|
|
2
|
+
export declare class DebugController {
|
|
3
|
+
protected readonly appConfigService: AppConfigService;
|
|
4
|
+
protected readonly logService: LogService;
|
|
5
|
+
constructor(appConfigService: AppConfigService, logService: LogService);
|
|
6
|
+
debug(status: string): Promise<void>;
|
|
7
|
+
debugCompletion(): Promise<string[]>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DebugController = void 0;
|
|
13
|
+
const core_1 = require("@wocker/core");
|
|
14
|
+
const services_1 = require("../services");
|
|
15
|
+
let DebugController = class DebugController {
|
|
16
|
+
constructor(appConfigService, logService) {
|
|
17
|
+
this.appConfigService = appConfigService;
|
|
18
|
+
this.logService = logService;
|
|
19
|
+
}
|
|
20
|
+
async debug(status) {
|
|
21
|
+
const config = await this.appConfigService.getConfig();
|
|
22
|
+
config.debug = status === "on";
|
|
23
|
+
await config.save();
|
|
24
|
+
}
|
|
25
|
+
async debugCompletion() {
|
|
26
|
+
return ["on", "off"];
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
exports.DebugController = DebugController;
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, core_1.Command)("debug <status>"),
|
|
32
|
+
__metadata("design:type", Function),
|
|
33
|
+
__metadata("design:paramtypes", [String]),
|
|
34
|
+
__metadata("design:returntype", Promise)
|
|
35
|
+
], DebugController.prototype, "debug", null);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, core_1.Completion)("status"),
|
|
38
|
+
__metadata("design:type", Function),
|
|
39
|
+
__metadata("design:paramtypes", []),
|
|
40
|
+
__metadata("design:returntype", Promise)
|
|
41
|
+
], DebugController.prototype, "debugCompletion", null);
|
|
42
|
+
exports.DebugController = DebugController = __decorate([
|
|
43
|
+
(0, core_1.Controller)(),
|
|
44
|
+
__metadata("design:paramtypes", [services_1.AppConfigService,
|
|
45
|
+
services_1.LogService])
|
|
46
|
+
], DebugController);
|
|
@@ -1,33 +1,10 @@
|
|
|
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
|
-
});
|
|
18
2
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
3
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
4
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
5
|
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
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
7
|
};
|
|
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
|
-
};
|
|
31
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
10
|
};
|
|
@@ -37,12 +14,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
15
|
exports.PluginController = void 0;
|
|
39
16
|
const core_1 = require("@wocker/core");
|
|
40
|
-
const axios_1 = __importDefault(require("axios"));
|
|
41
17
|
const chalk_1 = __importDefault(require("chalk"));
|
|
42
18
|
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
43
19
|
const services_1 = require("../services");
|
|
44
20
|
const utils_1 = require("../utils");
|
|
45
|
-
const
|
|
21
|
+
const Http_1 = require("../makes/Http");
|
|
46
22
|
let PluginController = class PluginController {
|
|
47
23
|
constructor(appConfigService, pluginService, logService) {
|
|
48
24
|
this.appConfigService = appConfigService;
|
|
@@ -50,12 +26,12 @@ let PluginController = class PluginController {
|
|
|
50
26
|
this.logService = logService;
|
|
51
27
|
}
|
|
52
28
|
async list() {
|
|
53
|
-
const
|
|
29
|
+
const config = await this.appConfigService.getConfig();
|
|
54
30
|
const table = new cli_table3_1.default({
|
|
55
31
|
head: ["Name"],
|
|
56
32
|
colWidths: [30]
|
|
57
33
|
});
|
|
58
|
-
for (const name of plugins) {
|
|
34
|
+
for (const name of config.plugins) {
|
|
59
35
|
table.push([name]);
|
|
60
36
|
}
|
|
61
37
|
return table.toString() + "\n";
|
|
@@ -63,26 +39,29 @@ let PluginController = class PluginController {
|
|
|
63
39
|
async add(addName) {
|
|
64
40
|
const [, prefix = "@wocker/", name, suffix = "-plugin"] = /^(@wocker\/)?(\w+)(-plugin)?$/.exec(addName) || [];
|
|
65
41
|
const fullName = `${prefix}${name}${suffix}`;
|
|
42
|
+
this.logService.info(`Installing plugin... ${fullName}`);
|
|
43
|
+
const config = await this.appConfigService.getConfig();
|
|
66
44
|
try {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
try {
|
|
76
|
-
const res = await axios_1.default.get(`https://registry.npmjs.org/${encodeURIComponent(fullName)}`, {
|
|
77
|
-
validateStatus: () => true
|
|
78
|
-
});
|
|
45
|
+
if (await this.pluginService.checkPlugin(fullName)) {
|
|
46
|
+
config.addPlugin(fullName);
|
|
47
|
+
await config.save();
|
|
48
|
+
console.info(`Plugin ${fullName} activated`);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const res = await Http_1.Http.get("https://registry.npmjs.org")
|
|
52
|
+
.send(fullName);
|
|
79
53
|
if (res.status !== 200) {
|
|
80
54
|
console.error(chalk_1.default.red(`Plugin ${fullName} not found`));
|
|
81
55
|
return;
|
|
82
56
|
}
|
|
83
57
|
console.info(`Installing ${fullName}`);
|
|
84
58
|
await (0, utils_1.exec)(`npm install -g ${fullName}`);
|
|
85
|
-
await this.
|
|
59
|
+
if (await this.pluginService.checkPlugin(fullName)) {
|
|
60
|
+
config.addPlugin(fullName);
|
|
61
|
+
await config.save();
|
|
62
|
+
console.info(`Plugin ${fullName} activated`);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
86
65
|
}
|
|
87
66
|
catch (err) {
|
|
88
67
|
this.logService.error(err.message);
|
|
@@ -91,9 +70,18 @@ let PluginController = class PluginController {
|
|
|
91
70
|
async remove(removeName) {
|
|
92
71
|
const [, prefix = "@wocker/", name, suffix = "-plugin"] = /^(@wocker\/)?(\w+)(-plugin)?$/.exec(removeName) || [];
|
|
93
72
|
const fullName = `${prefix}${name}${suffix}`;
|
|
94
|
-
await this.appConfigService.
|
|
73
|
+
const config = await this.appConfigService.getConfig();
|
|
74
|
+
config.removePlugin(fullName);
|
|
75
|
+
await config.save();
|
|
95
76
|
console.info(`Plugin ${fullName} deactivated`);
|
|
96
77
|
}
|
|
78
|
+
async update() {
|
|
79
|
+
await this.pluginService.update();
|
|
80
|
+
}
|
|
81
|
+
async getInstalledPlugins() {
|
|
82
|
+
const config = await this.appConfigService.getConfig();
|
|
83
|
+
return config.plugins || [];
|
|
84
|
+
}
|
|
97
85
|
};
|
|
98
86
|
exports.PluginController = PluginController;
|
|
99
87
|
__decorate([
|
|
@@ -114,6 +102,19 @@ __decorate([
|
|
|
114
102
|
__metadata("design:paramtypes", [String]),
|
|
115
103
|
__metadata("design:returntype", Promise)
|
|
116
104
|
], PluginController.prototype, "remove", null);
|
|
105
|
+
__decorate([
|
|
106
|
+
(0, core_1.Command)("plugin:update [name]"),
|
|
107
|
+
__metadata("design:type", Function),
|
|
108
|
+
__metadata("design:paramtypes", []),
|
|
109
|
+
__metadata("design:returntype", Promise)
|
|
110
|
+
], PluginController.prototype, "update", null);
|
|
111
|
+
__decorate([
|
|
112
|
+
(0, core_1.Completion)("name", "plugin:update [name]"),
|
|
113
|
+
(0, core_1.Completion)("name", "plugin:remove <name>"),
|
|
114
|
+
__metadata("design:type", Function),
|
|
115
|
+
__metadata("design:paramtypes", []),
|
|
116
|
+
__metadata("design:returntype", Promise)
|
|
117
|
+
], PluginController.prototype, "getInstalledPlugins", null);
|
|
117
118
|
exports.PluginController = PluginController = __decorate([
|
|
118
119
|
(0, core_1.Controller)(),
|
|
119
120
|
__metadata("design:paramtypes", [services_1.AppConfigService,
|
|
@@ -11,5 +11,6 @@ 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
|
+
eject(name?: string): Promise<void>;
|
|
14
15
|
build(rebuild: boolean, presetName: string): Promise<void>;
|
|
15
16
|
}
|
|
@@ -38,9 +38,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
38
38
|
exports.PresetController = void 0;
|
|
39
39
|
const core_1 = require("@wocker/core");
|
|
40
40
|
const utils_1 = require("@wocker/utils");
|
|
41
|
+
const utils_2 = require("@wocker/utils");
|
|
41
42
|
const Path = __importStar(require("path"));
|
|
42
43
|
const env_1 = require("../env");
|
|
43
|
-
const
|
|
44
|
+
const utils_3 = require("../utils");
|
|
44
45
|
const services_1 = require("../services");
|
|
45
46
|
let PresetController = class PresetController {
|
|
46
47
|
constructor(appConfigService, appEventsService, projectService, presetService, dockerService) {
|
|
@@ -90,18 +91,18 @@ let PresetController = class PresetController {
|
|
|
90
91
|
}
|
|
91
92
|
if (preset.volumeOptions) {
|
|
92
93
|
for (let volume of preset.volumeOptions) {
|
|
93
|
-
volume = (0,
|
|
94
|
+
volume = (0, utils_3.injectVariables)(volume, {
|
|
94
95
|
...project.buildArgs || {},
|
|
95
96
|
...project.env || {}
|
|
96
97
|
});
|
|
97
|
-
const { destination, options } = (0,
|
|
98
|
+
const { destination, options } = (0, utils_3.volumeParse)(volume);
|
|
98
99
|
let projectVolume = project.getVolumeByDestination(destination);
|
|
99
100
|
const source = await (0, utils_1.promptText)({
|
|
100
101
|
message: "Volume",
|
|
101
102
|
suffix: `:${destination}`,
|
|
102
|
-
default: projectVolume ? (0,
|
|
103
|
+
default: projectVolume ? (0, utils_3.volumeParse)(projectVolume).source : "./"
|
|
103
104
|
});
|
|
104
|
-
projectVolume = (0,
|
|
105
|
+
projectVolume = (0, utils_3.volumeFormat)({
|
|
105
106
|
source,
|
|
106
107
|
destination,
|
|
107
108
|
options
|
|
@@ -110,7 +111,7 @@ let PresetController = class PresetController {
|
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
113
|
if (preset.dockerfile) {
|
|
113
|
-
project.imageName =
|
|
114
|
+
project.imageName = this.presetService.getImageName(preset, project.buildArgs);
|
|
114
115
|
}
|
|
115
116
|
}
|
|
116
117
|
async onRebuild(project) {
|
|
@@ -148,6 +149,55 @@ let PresetController = class PresetController {
|
|
|
148
149
|
}
|
|
149
150
|
}
|
|
150
151
|
}
|
|
152
|
+
async eject(name) {
|
|
153
|
+
if (name) {
|
|
154
|
+
await this.projectService.cdProject(name);
|
|
155
|
+
}
|
|
156
|
+
const project = await this.projectService.get();
|
|
157
|
+
const preset = await this.presetService.get(project.preset);
|
|
158
|
+
if (!preset) {
|
|
159
|
+
throw new Error("Preset not found");
|
|
160
|
+
}
|
|
161
|
+
const confirm = await (0, utils_2.promptConfirm)({
|
|
162
|
+
message: "Confirm eject",
|
|
163
|
+
default: false
|
|
164
|
+
});
|
|
165
|
+
if (!confirm) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const copier = new core_1.FSManager(this.appConfigService.presetPath(preset.name), this.appConfigService.getPWD());
|
|
169
|
+
if (preset.dockerfile) {
|
|
170
|
+
if (!copier.destination.exists(preset.dockerfile)) {
|
|
171
|
+
await copier.copy(preset.dockerfile);
|
|
172
|
+
}
|
|
173
|
+
project.type = "dockerfile";
|
|
174
|
+
project.dockerfile = preset.dockerfile;
|
|
175
|
+
}
|
|
176
|
+
const files = await copier.source.readdirFiles("", {
|
|
177
|
+
recursive: true
|
|
178
|
+
});
|
|
179
|
+
for (const path of files) {
|
|
180
|
+
const stat = copier.source.stat(path), dir = Path.dirname(path);
|
|
181
|
+
if (stat.isFile() && path === "config.json") {
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
if (stat.isFile() && path === preset.dockerfile) {
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
if (copier.destination.exists(path)) {
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
if (!copier.destination.exists(dir)) {
|
|
191
|
+
copier.destination.mkdir(dir, {
|
|
192
|
+
recursive: true
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
await copier.copy(path);
|
|
196
|
+
}
|
|
197
|
+
delete project.preset;
|
|
198
|
+
delete project.imageName;
|
|
199
|
+
await project.save();
|
|
200
|
+
}
|
|
151
201
|
async build(rebuild, presetName) {
|
|
152
202
|
const preset = await this.presetService.get(presetName);
|
|
153
203
|
let buildArgs = {};
|
|
@@ -167,6 +217,17 @@ let PresetController = class PresetController {
|
|
|
167
217
|
}
|
|
168
218
|
};
|
|
169
219
|
exports.PresetController = PresetController;
|
|
220
|
+
__decorate([
|
|
221
|
+
(0, core_1.Command)("preset:eject"),
|
|
222
|
+
__param(0, (0, core_1.Option)("name", {
|
|
223
|
+
type: "string",
|
|
224
|
+
alias: "n",
|
|
225
|
+
description: "Project name"
|
|
226
|
+
})),
|
|
227
|
+
__metadata("design:type", Function),
|
|
228
|
+
__metadata("design:paramtypes", [String]),
|
|
229
|
+
__metadata("design:returntype", Promise)
|
|
230
|
+
], PresetController.prototype, "eject", null);
|
|
170
231
|
__decorate([
|
|
171
232
|
(0, core_1.Command)("preset:build <preset>"),
|
|
172
233
|
__param(0, (0, core_1.Option)("rebuild", {
|
|
@@ -7,7 +7,6 @@ export declare class ProjectController {
|
|
|
7
7
|
protected readonly logService: LogService;
|
|
8
8
|
constructor(appConfigService: AppConfigService, appEventsService: AppEventsService, projectService: ProjectService, dockerService: DockerService, logService: LogService);
|
|
9
9
|
protected getProjectNames(): Promise<string[]>;
|
|
10
|
-
protected getScripts(): Promise<string[]>;
|
|
11
10
|
init(name: string, type: string, preset: string): Promise<void>;
|
|
12
11
|
projectList(all: boolean): Promise<string>;
|
|
13
12
|
start(name?: string, detach?: boolean, rebuild?: boolean, restart?: boolean): Promise<void>;
|
|
@@ -15,8 +14,8 @@ export declare class ProjectController {
|
|
|
15
14
|
run(name: string, script: string): Promise<void>;
|
|
16
15
|
attach(name?: string): Promise<void>;
|
|
17
16
|
configList(name?: string, global?: boolean): Promise<string>;
|
|
18
|
-
configGet(name: string, global: boolean,
|
|
19
|
-
configSet(name: string, global: boolean,
|
|
17
|
+
configGet(name: string, global: boolean, keys: string[]): Promise<string>;
|
|
18
|
+
configSet(name: string, global: boolean, variables: string[]): Promise<void>;
|
|
20
19
|
configUnset(name: string, global: boolean, configs: string[]): Promise<void>;
|
|
21
20
|
buildArgsList(name?: string): Promise<string>;
|
|
22
21
|
buildArgsGet(name: string, args: string[]): Promise<string>;
|
|
@@ -48,7 +48,6 @@ const async_mutex_1 = require("async-mutex");
|
|
|
48
48
|
const env_1 = require("../env");
|
|
49
49
|
const makes_1 = require("../makes");
|
|
50
50
|
const services_1 = require("../services");
|
|
51
|
-
const utils_2 = require("../utils");
|
|
52
51
|
let ProjectController = class ProjectController {
|
|
53
52
|
constructor(appConfigService, appEventsService, projectService, dockerService, logService) {
|
|
54
53
|
this.appConfigService = appConfigService;
|
|
@@ -63,22 +62,14 @@ let ProjectController = class ProjectController {
|
|
|
63
62
|
return project.name;
|
|
64
63
|
});
|
|
65
64
|
}
|
|
66
|
-
async getScripts() {
|
|
67
|
-
this.logService.warn(">_<");
|
|
68
|
-
try {
|
|
69
|
-
const project = await this.projectService.get();
|
|
70
|
-
return Object.keys(project.scripts || {});
|
|
71
|
-
}
|
|
72
|
-
catch (ignore) {
|
|
73
|
-
return [];
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
65
|
async init(name, type, preset) {
|
|
77
66
|
let project = await this.projectService.searchOne({
|
|
78
67
|
path: this.appConfigService.getPWD()
|
|
79
68
|
});
|
|
80
69
|
if (!project) {
|
|
81
|
-
project = this.projectService.fromObject({
|
|
70
|
+
project = this.projectService.fromObject({
|
|
71
|
+
path: this.appConfigService.getPWD()
|
|
72
|
+
});
|
|
82
73
|
}
|
|
83
74
|
if (name) {
|
|
84
75
|
project.name = name;
|
|
@@ -87,8 +78,8 @@ let ProjectController = class ProjectController {
|
|
|
87
78
|
project.name = await (0, utils_1.promptText)({
|
|
88
79
|
type: "string",
|
|
89
80
|
required: true,
|
|
90
|
-
message: "Project name",
|
|
91
|
-
default: project.name
|
|
81
|
+
message: "Project name:",
|
|
82
|
+
default: project.name || Path.basename(project.path)
|
|
92
83
|
});
|
|
93
84
|
}
|
|
94
85
|
if (type) {
|
|
@@ -97,7 +88,7 @@ let ProjectController = class ProjectController {
|
|
|
97
88
|
const mapTypes = this.appConfigService.getProjectTypes();
|
|
98
89
|
if (!type || !project.type || !mapTypes[project.type]) {
|
|
99
90
|
project.type = await (0, utils_1.promptSelect)({
|
|
100
|
-
message: "Project type",
|
|
91
|
+
message: "Project type:",
|
|
101
92
|
options: mapTypes,
|
|
102
93
|
default: project.type
|
|
103
94
|
});
|
|
@@ -134,7 +125,7 @@ let ProjectController = class ProjectController {
|
|
|
134
125
|
}
|
|
135
126
|
await this.appEventsService.emit("project:init", project);
|
|
136
127
|
project.path = this.appConfigService.getPWD();
|
|
137
|
-
await
|
|
128
|
+
await project.save();
|
|
138
129
|
}
|
|
139
130
|
async projectList(all) {
|
|
140
131
|
const table = new cli_table3_1.default({
|
|
@@ -153,7 +144,7 @@ let ProjectController = class ProjectController {
|
|
|
153
144
|
const { State: { Status = "stopped" } = {} } = await container.inspect();
|
|
154
145
|
table.push([project.name, project.type, Status]);
|
|
155
146
|
}
|
|
156
|
-
return table.toString()
|
|
147
|
+
return table.toString();
|
|
157
148
|
}
|
|
158
149
|
async start(name, detach, rebuild, restart) {
|
|
159
150
|
if (name) {
|
|
@@ -212,20 +203,20 @@ let ProjectController = class ProjectController {
|
|
|
212
203
|
if (name) {
|
|
213
204
|
await this.projectService.cdProject(name);
|
|
214
205
|
}
|
|
215
|
-
const
|
|
216
|
-
await this.dockerService.attach(containerName);
|
|
206
|
+
const project = await this.projectService.get();
|
|
207
|
+
await this.dockerService.attach(project.containerName);
|
|
217
208
|
}
|
|
218
209
|
async configList(name, global) {
|
|
219
210
|
if (name) {
|
|
220
211
|
await this.projectService.cdProject(name);
|
|
221
212
|
}
|
|
222
|
-
let env
|
|
213
|
+
let env;
|
|
223
214
|
if (!global) {
|
|
224
215
|
const project = await this.projectService.get();
|
|
225
216
|
env = project.env || {};
|
|
226
217
|
}
|
|
227
218
|
else {
|
|
228
|
-
const config = await
|
|
219
|
+
const config = await this.appConfigService.getConfig();
|
|
229
220
|
env = config.env || {};
|
|
230
221
|
}
|
|
231
222
|
const table = new cli_table3_1.default({
|
|
@@ -234,52 +225,50 @@ let ProjectController = class ProjectController {
|
|
|
234
225
|
for (const i in env) {
|
|
235
226
|
table.push([i, env[i]]);
|
|
236
227
|
}
|
|
237
|
-
return table.toString()
|
|
228
|
+
return table.toString();
|
|
238
229
|
}
|
|
239
|
-
async configGet(name, global,
|
|
230
|
+
async configGet(name, global, keys) {
|
|
240
231
|
if (name) {
|
|
241
232
|
await this.projectService.cdProject(name);
|
|
242
233
|
}
|
|
243
|
-
let
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
value = config[key] || "";
|
|
247
|
-
}
|
|
248
|
-
else {
|
|
249
|
-
const project = await this.projectService.get();
|
|
250
|
-
value = project.getEnv(key);
|
|
251
|
-
}
|
|
234
|
+
let config = global
|
|
235
|
+
? await this.appConfigService.getConfig()
|
|
236
|
+
: await this.projectService.get();
|
|
252
237
|
const table = new cli_table3_1.default({
|
|
253
238
|
head: ["KEY", "VALUE"]
|
|
254
239
|
});
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
env[key.trim()] = value.trim();
|
|
262
|
-
return env;
|
|
263
|
-
}, {});
|
|
264
|
-
if (global) {
|
|
265
|
-
const config = await (0, utils_2.getConfig)();
|
|
266
|
-
await (0, utils_2.setConfig)({
|
|
267
|
-
...config,
|
|
268
|
-
env: {
|
|
269
|
-
...config.env || {},
|
|
270
|
-
...env
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
return;
|
|
240
|
+
for (const key of keys) {
|
|
241
|
+
const value = config.getEnv(key, "");
|
|
242
|
+
if (!value) {
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
table.push([key, value]);
|
|
274
246
|
}
|
|
275
|
-
|
|
247
|
+
return table.toString();
|
|
248
|
+
}
|
|
249
|
+
async configSet(name, global, variables) {
|
|
250
|
+
if (!global && name) {
|
|
276
251
|
await this.projectService.cdProject(name);
|
|
277
252
|
}
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
|
|
253
|
+
const config = global
|
|
254
|
+
? await this.appConfigService.getConfig()
|
|
255
|
+
: await this.projectService.get();
|
|
256
|
+
for (const variable of variables) {
|
|
257
|
+
const [key, value] = variable.split("=");
|
|
258
|
+
if (!value) {
|
|
259
|
+
console.info(chalk_1.default.yellow(`No value for "${key}"`));
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
config.setEnv(key.trim(), value.trim());
|
|
263
|
+
}
|
|
264
|
+
await config.save();
|
|
265
|
+
if (!global) {
|
|
266
|
+
const project = await this.projectService.get();
|
|
267
|
+
const container = await this.dockerService.getContainer(project.containerName);
|
|
268
|
+
if (container) {
|
|
269
|
+
await this.projectService.start(true);
|
|
270
|
+
}
|
|
281
271
|
}
|
|
282
|
-
await project.save();
|
|
283
272
|
}
|
|
284
273
|
async configUnset(name, global, configs) {
|
|
285
274
|
const env = configs.reduce((env, config) => {
|
|
@@ -298,6 +287,13 @@ let ProjectController = class ProjectController {
|
|
|
298
287
|
project.unsetEnv(i);
|
|
299
288
|
}
|
|
300
289
|
await project.save();
|
|
290
|
+
if (!global) {
|
|
291
|
+
const project = await this.projectService.get();
|
|
292
|
+
const container = await this.dockerService.getContainer(project.containerName);
|
|
293
|
+
if (container) {
|
|
294
|
+
await this.projectService.start(true);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
301
297
|
}
|
|
302
298
|
async buildArgsList(name) {
|
|
303
299
|
if (name) {
|
|
@@ -311,7 +307,7 @@ let ProjectController = class ProjectController {
|
|
|
311
307
|
for (const i in buildArgs) {
|
|
312
308
|
table.push([i, typeof buildArgs[i] === "string" ? buildArgs[i] : JSON.stringify(buildArgs[i])]);
|
|
313
309
|
}
|
|
314
|
-
return table.toString()
|
|
310
|
+
return table.toString();
|
|
315
311
|
}
|
|
316
312
|
async buildArgsGet(name, args) {
|
|
317
313
|
if (name) {
|
|
@@ -328,7 +324,7 @@ let ProjectController = class ProjectController {
|
|
|
328
324
|
table.push([key, value]);
|
|
329
325
|
}
|
|
330
326
|
}
|
|
331
|
-
return table.toString()
|
|
327
|
+
return table.toString();
|
|
332
328
|
}
|
|
333
329
|
async buildArgsSet(name, args) {
|
|
334
330
|
if (name) {
|
|
@@ -380,7 +376,7 @@ let ProjectController = class ProjectController {
|
|
|
380
376
|
for (const volume of volumes) {
|
|
381
377
|
table.push([volume]);
|
|
382
378
|
}
|
|
383
|
-
return table.toString()
|
|
379
|
+
return table.toString();
|
|
384
380
|
}
|
|
385
381
|
async volumeMount(name, volumes) {
|
|
386
382
|
if (name) {
|
|
@@ -489,12 +485,6 @@ __decorate([
|
|
|
489
485
|
__metadata("design:paramtypes", []),
|
|
490
486
|
__metadata("design:returntype", Promise)
|
|
491
487
|
], ProjectController.prototype, "getProjectNames", null);
|
|
492
|
-
__decorate([
|
|
493
|
-
(0, core_1.Completion)("script"),
|
|
494
|
-
__metadata("design:type", Function),
|
|
495
|
-
__metadata("design:paramtypes", []),
|
|
496
|
-
__metadata("design:returntype", Promise)
|
|
497
|
-
], ProjectController.prototype, "getScripts", null);
|
|
498
488
|
__decorate([
|
|
499
489
|
(0, core_1.Command)("init"),
|
|
500
490
|
__param(0, (0, core_1.Option)("name", {
|
|
@@ -598,17 +588,17 @@ __decorate([
|
|
|
598
588
|
__metadata("design:returntype", Promise)
|
|
599
589
|
], ProjectController.prototype, "configList", null);
|
|
600
590
|
__decorate([
|
|
601
|
-
(0, core_1.Command)("config:get
|
|
591
|
+
(0, core_1.Command)("config:get [...key]"),
|
|
602
592
|
__param(0, (0, core_1.Option)("name", {
|
|
603
593
|
type: "string",
|
|
604
594
|
alias: "n"
|
|
605
595
|
})),
|
|
606
596
|
__param(1, (0, core_1.Option)("global", {
|
|
607
597
|
type: "boolean",
|
|
608
|
-
alias: "
|
|
598
|
+
alias: "g"
|
|
609
599
|
})),
|
|
610
600
|
__metadata("design:type", Function),
|
|
611
|
-
__metadata("design:paramtypes", [String, Boolean,
|
|
601
|
+
__metadata("design:paramtypes", [String, Boolean, Array]),
|
|
612
602
|
__metadata("design:returntype", Promise)
|
|
613
603
|
], ProjectController.prototype, "configGet", null);
|
|
614
604
|
__decorate([
|