@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
package/bin/ws.js
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const {app} = require("../lib/index.js");
|
|
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
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
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
|
+
};
|
|
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
|
+
var AppModule_1;
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.AppModule = void 0;
|
|
34
|
+
const core_1 = require("@wocker/core");
|
|
35
|
+
const controllers_1 = require("./controllers");
|
|
36
|
+
const services_1 = require("./services");
|
|
37
|
+
let AppModule = AppModule_1 = class AppModule {
|
|
38
|
+
async load(container) {
|
|
39
|
+
const appConfigService = container.getModule(AppModule_1).get(services_1.AppConfigService);
|
|
40
|
+
const logService = container.getModule(AppModule_1).get(services_1.LogService);
|
|
41
|
+
const pluginService = container.getModule(AppModule_1).get(services_1.PluginService);
|
|
42
|
+
const config = await appConfigService.getConfig();
|
|
43
|
+
const imports = [];
|
|
44
|
+
for (const plugin of config.plugins) {
|
|
45
|
+
try {
|
|
46
|
+
const { default: Plugin } = await Promise.resolve(`${plugin}`).then(s => __importStar(require(s)));
|
|
47
|
+
if (!Plugin) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const name = Reflect.getMetadata(core_1.MODULE_METADATA.NAME, Plugin);
|
|
51
|
+
Reflect.defineMetadata(core_1.MODULE_METADATA.PROVIDERS, [
|
|
52
|
+
...Reflect.getMetadata(core_1.MODULE_METADATA.PROVIDERS, Plugin) || [],
|
|
53
|
+
{
|
|
54
|
+
provide: core_1.PLUGIN_DIR_KEY,
|
|
55
|
+
useValue: name ? appConfigService.dataPath("plugins", name) : undefined
|
|
56
|
+
}
|
|
57
|
+
], Plugin);
|
|
58
|
+
imports.push(Plugin);
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
logService.error(err.message);
|
|
62
|
+
config.removePlugin(plugin);
|
|
63
|
+
await config.save();
|
|
64
|
+
throw err;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
imports
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
exports.AppModule = AppModule;
|
|
73
|
+
exports.AppModule = AppModule = AppModule_1 = __decorate([
|
|
74
|
+
(0, core_1.Module)({
|
|
75
|
+
controllers: [
|
|
76
|
+
controllers_1.CompletionController,
|
|
77
|
+
controllers_1.DebugController,
|
|
78
|
+
controllers_1.ImageController,
|
|
79
|
+
controllers_1.PluginController,
|
|
80
|
+
controllers_1.PresetController,
|
|
81
|
+
controllers_1.ProjectController,
|
|
82
|
+
controllers_1.ProxyController
|
|
83
|
+
],
|
|
84
|
+
providers: [
|
|
85
|
+
services_1.AppConfigService,
|
|
86
|
+
services_1.AppEventsService,
|
|
87
|
+
services_1.DockerService,
|
|
88
|
+
services_1.LogService,
|
|
89
|
+
services_1.PluginService,
|
|
90
|
+
services_1.PresetService,
|
|
91
|
+
services_1.ProjectService
|
|
92
|
+
],
|
|
93
|
+
exports: [
|
|
94
|
+
services_1.AppConfigService,
|
|
95
|
+
services_1.AppEventsService,
|
|
96
|
+
services_1.DockerService,
|
|
97
|
+
services_1.LogService
|
|
98
|
+
]
|
|
99
|
+
})
|
|
100
|
+
], AppModule);
|
|
@@ -0,0 +1,32 @@
|
|
|
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.CompletionController = void 0;
|
|
13
|
+
const core_1 = require("@wocker/core");
|
|
14
|
+
let CompletionController = class CompletionController {
|
|
15
|
+
constructor(cli) {
|
|
16
|
+
this.cli = cli;
|
|
17
|
+
}
|
|
18
|
+
completion() {
|
|
19
|
+
return this.cli.completionScript() + "\n";
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
exports.CompletionController = CompletionController;
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, core_1.Command)("completion script"),
|
|
25
|
+
__metadata("design:type", Function),
|
|
26
|
+
__metadata("design:paramtypes", []),
|
|
27
|
+
__metadata("design:returntype", void 0)
|
|
28
|
+
], CompletionController.prototype, "completion", null);
|
|
29
|
+
exports.CompletionController = CompletionController = __decorate([
|
|
30
|
+
(0, core_1.Controller)(),
|
|
31
|
+
__metadata("design:paramtypes", [core_1.Cli])
|
|
32
|
+
], CompletionController);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AppConfigService } from "../services";
|
|
2
|
+
export declare class DebugController {
|
|
3
|
+
protected readonly appConfigService: AppConfigService;
|
|
4
|
+
constructor(appConfigService: AppConfigService);
|
|
5
|
+
debug(status: string): Promise<void>;
|
|
6
|
+
debugCompletion(): Promise<string[]>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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) {
|
|
17
|
+
this.appConfigService = appConfigService;
|
|
18
|
+
}
|
|
19
|
+
async debug(status) {
|
|
20
|
+
const config = await this.appConfigService.getConfig();
|
|
21
|
+
config.debug = status === "on";
|
|
22
|
+
await config.save();
|
|
23
|
+
}
|
|
24
|
+
async debugCompletion() {
|
|
25
|
+
return ["on", "off"];
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
exports.DebugController = DebugController;
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, core_1.Command)("debug <status>"),
|
|
31
|
+
__metadata("design:type", Function),
|
|
32
|
+
__metadata("design:paramtypes", [String]),
|
|
33
|
+
__metadata("design:returntype", Promise)
|
|
34
|
+
], DebugController.prototype, "debug", null);
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, core_1.Completion)("status"),
|
|
37
|
+
__metadata("design:type", Function),
|
|
38
|
+
__metadata("design:paramtypes", []),
|
|
39
|
+
__metadata("design:returntype", Promise)
|
|
40
|
+
], DebugController.prototype, "debugCompletion", null);
|
|
41
|
+
exports.DebugController = DebugController = __decorate([
|
|
42
|
+
(0, core_1.Controller)(),
|
|
43
|
+
__metadata("design:paramtypes", [services_1.AppConfigService])
|
|
44
|
+
], DebugController);
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
constructor(di: DI);
|
|
7
|
-
install(cli: Cli): void;
|
|
1
|
+
import { AppConfigService, DockerService } from "../services";
|
|
2
|
+
export declare class ImageController {
|
|
3
|
+
protected readonly appConfigService: AppConfigService;
|
|
4
|
+
protected readonly dockerService: DockerService;
|
|
5
|
+
constructor(appConfigService: AppConfigService, dockerService: DockerService);
|
|
8
6
|
list(): Promise<string>;
|
|
9
7
|
}
|
|
10
|
-
export { ImageController };
|
|
@@ -1,24 +1,28 @@
|
|
|
1
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
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
5
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
15
|
exports.ImageController = void 0;
|
|
16
|
+
const core_1 = require("@wocker/core");
|
|
7
17
|
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
8
|
-
const makes_1 = require("../makes");
|
|
9
18
|
const services_1 = require("../services");
|
|
10
|
-
|
|
11
|
-
constructor(
|
|
12
|
-
|
|
13
|
-
this.
|
|
14
|
-
}
|
|
15
|
-
install(cli) {
|
|
16
|
-
super.install(cli);
|
|
17
|
-
cli.command("images")
|
|
18
|
-
.action(() => this.list());
|
|
19
|
+
let ImageController = class ImageController {
|
|
20
|
+
constructor(appConfigService, dockerService) {
|
|
21
|
+
this.appConfigService = appConfigService;
|
|
22
|
+
this.dockerService = dockerService;
|
|
19
23
|
}
|
|
20
24
|
async list() {
|
|
21
|
-
const images = await
|
|
25
|
+
const images = await this.dockerService.imageLs({});
|
|
22
26
|
const table = new cli_table3_1.default({
|
|
23
27
|
head: ["Name"]
|
|
24
28
|
});
|
|
@@ -27,5 +31,16 @@ class ImageController extends makes_1.Controller {
|
|
|
27
31
|
}
|
|
28
32
|
return table.toString() + "\n";
|
|
29
33
|
}
|
|
30
|
-
}
|
|
34
|
+
};
|
|
31
35
|
exports.ImageController = ImageController;
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, core_1.Command)("images"),
|
|
38
|
+
__metadata("design:type", Function),
|
|
39
|
+
__metadata("design:paramtypes", []),
|
|
40
|
+
__metadata("design:returntype", Promise)
|
|
41
|
+
], ImageController.prototype, "list", null);
|
|
42
|
+
exports.ImageController = ImageController = __decorate([
|
|
43
|
+
(0, core_1.Controller)(),
|
|
44
|
+
__metadata("design:paramtypes", [services_1.AppConfigService,
|
|
45
|
+
services_1.DockerService])
|
|
46
|
+
], ImageController);
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
remove(options: RemoveOptions, removeName: string): Promise<void>;
|
|
1
|
+
import { AppConfigService, PluginService, LogService } from "../services";
|
|
2
|
+
export declare class PluginController {
|
|
3
|
+
protected readonly appConfigService: AppConfigService;
|
|
4
|
+
protected readonly pluginService: PluginService;
|
|
5
|
+
protected readonly logService: LogService;
|
|
6
|
+
constructor(appConfigService: AppConfigService, pluginService: PluginService, logService: LogService);
|
|
7
|
+
list(): Promise<string>;
|
|
8
|
+
add(addName: string): Promise<void>;
|
|
9
|
+
remove(removeName: string): Promise<void>;
|
|
10
|
+
update(): Promise<void>;
|
|
11
|
+
getInstalledPlugins(): Promise<string[]>;
|
|
13
12
|
}
|
|
14
|
-
export { PluginController };
|
|
@@ -1,84 +1,123 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
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;
|
|
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);
|
|
24
10
|
};
|
|
25
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
13
|
};
|
|
28
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
15
|
exports.PluginController = void 0;
|
|
30
|
-
const
|
|
16
|
+
const core_1 = require("@wocker/core");
|
|
31
17
|
const chalk_1 = __importDefault(require("chalk"));
|
|
32
|
-
const
|
|
18
|
+
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
33
19
|
const services_1 = require("../services");
|
|
34
20
|
const utils_1 = require("../utils");
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
this.appConfigService =
|
|
39
|
-
this.pluginService =
|
|
21
|
+
const Http_1 = require("../makes/Http");
|
|
22
|
+
let PluginController = class PluginController {
|
|
23
|
+
constructor(appConfigService, pluginService, logService) {
|
|
24
|
+
this.appConfigService = appConfigService;
|
|
25
|
+
this.pluginService = pluginService;
|
|
26
|
+
this.logService = logService;
|
|
40
27
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
28
|
+
async list() {
|
|
29
|
+
const config = await this.appConfigService.getConfig();
|
|
30
|
+
const table = new cli_table3_1.default({
|
|
31
|
+
head: ["Name"],
|
|
32
|
+
colWidths: [30]
|
|
33
|
+
});
|
|
34
|
+
for (const name of config.plugins) {
|
|
35
|
+
table.push([name]);
|
|
36
|
+
}
|
|
37
|
+
return table.toString() + "\n";
|
|
47
38
|
}
|
|
48
|
-
async add(
|
|
39
|
+
async add(addName) {
|
|
49
40
|
const [, prefix = "@wocker/", name, suffix = "-plugin"] = /^(@wocker\/)?(\w+)(-plugin)?$/.exec(addName) || [];
|
|
50
41
|
const fullName = `${prefix}${name}${suffix}`;
|
|
42
|
+
this.logService.info(`Installing plugin... ${fullName}`);
|
|
43
|
+
const config = await this.appConfigService.getConfig();
|
|
51
44
|
try {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
try {
|
|
62
|
-
const res = await axios_1.default.get(`https://registry.npmjs.org/${encodeURIComponent(fullName)}`, {
|
|
63
|
-
validateStatus: () => true
|
|
64
|
-
});
|
|
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);
|
|
65
53
|
if (res.status !== 200) {
|
|
66
54
|
console.error(chalk_1.default.red(`Plugin ${fullName} not found`));
|
|
67
55
|
return;
|
|
68
56
|
}
|
|
69
57
|
console.info(`Installing ${fullName}`);
|
|
70
58
|
await (0, utils_1.exec)(`npm install -g ${fullName}`);
|
|
71
|
-
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
|
+
}
|
|
72
65
|
}
|
|
73
66
|
catch (err) {
|
|
74
|
-
|
|
67
|
+
this.logService.error(err.message);
|
|
75
68
|
}
|
|
76
69
|
}
|
|
77
|
-
async remove(
|
|
70
|
+
async remove(removeName) {
|
|
78
71
|
const [, prefix = "@wocker/", name, suffix = "-plugin"] = /^(@wocker\/)?(\w+)(-plugin)?$/.exec(removeName) || [];
|
|
79
72
|
const fullName = `${prefix}${name}${suffix}`;
|
|
80
|
-
await this.appConfigService.
|
|
73
|
+
const config = await this.appConfigService.getConfig();
|
|
74
|
+
config.removePlugin(fullName);
|
|
75
|
+
await config.save();
|
|
81
76
|
console.info(`Plugin ${fullName} deactivated`);
|
|
82
77
|
}
|
|
83
|
-
|
|
78
|
+
async update() {
|
|
79
|
+
await this.pluginService.update();
|
|
80
|
+
}
|
|
81
|
+
async getInstalledPlugins() {
|
|
82
|
+
const config = await this.appConfigService.getConfig();
|
|
83
|
+
return config.plugins || [];
|
|
84
|
+
}
|
|
85
|
+
};
|
|
84
86
|
exports.PluginController = PluginController;
|
|
87
|
+
__decorate([
|
|
88
|
+
(0, core_1.Command)("plugins"),
|
|
89
|
+
__metadata("design:type", Function),
|
|
90
|
+
__metadata("design:paramtypes", []),
|
|
91
|
+
__metadata("design:returntype", Promise)
|
|
92
|
+
], PluginController.prototype, "list", null);
|
|
93
|
+
__decorate([
|
|
94
|
+
(0, core_1.Command)("plugin:add <name>"),
|
|
95
|
+
__metadata("design:type", Function),
|
|
96
|
+
__metadata("design:paramtypes", [String]),
|
|
97
|
+
__metadata("design:returntype", Promise)
|
|
98
|
+
], PluginController.prototype, "add", null);
|
|
99
|
+
__decorate([
|
|
100
|
+
(0, core_1.Command)("plugin:remove <name>"),
|
|
101
|
+
__metadata("design:type", Function),
|
|
102
|
+
__metadata("design:paramtypes", [String]),
|
|
103
|
+
__metadata("design:returntype", Promise)
|
|
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);
|
|
118
|
+
exports.PluginController = PluginController = __decorate([
|
|
119
|
+
(0, core_1.Controller)(),
|
|
120
|
+
__metadata("design:paramtypes", [services_1.AppConfigService,
|
|
121
|
+
services_1.PluginService,
|
|
122
|
+
services_1.LogService])
|
|
123
|
+
], PluginController);
|
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DI, Controller, Project } from "../makes";
|
|
1
|
+
import { Project } from "@wocker/core";
|
|
3
2
|
import { AppConfigService, AppEventsService, ProjectService, PresetService, DockerService } from "../services";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
protected
|
|
9
|
-
protected
|
|
10
|
-
|
|
11
|
-
protected presetService: PresetService;
|
|
12
|
-
protected dockerService: DockerService;
|
|
13
|
-
constructor(di: DI);
|
|
14
|
-
install(cli: Cli): void;
|
|
3
|
+
export declare class PresetController {
|
|
4
|
+
protected readonly appConfigService: AppConfigService;
|
|
5
|
+
protected readonly appEventsService: AppEventsService;
|
|
6
|
+
protected readonly projectService: ProjectService;
|
|
7
|
+
protected readonly presetService: PresetService;
|
|
8
|
+
protected readonly dockerService: DockerService;
|
|
9
|
+
constructor(appConfigService: AppConfigService, appEventsService: AppEventsService, projectService: ProjectService, presetService: PresetService, dockerService: DockerService);
|
|
15
10
|
presets(): Promise<string[]>;
|
|
16
11
|
protected onInit(project: Project): Promise<void>;
|
|
17
12
|
protected onRebuild(project: Project): Promise<void>;
|
|
18
13
|
protected onBeforeStart(project: Project): Promise<void>;
|
|
19
|
-
|
|
14
|
+
eject(name?: string): Promise<void>;
|
|
15
|
+
build(rebuild: boolean, presetName: string): Promise<void>;
|
|
20
16
|
}
|
|
21
|
-
export { PresetController };
|