@wocker/ws 1.0.6 → 1.0.8
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 -1
- package/lib/App.d.ts +1 -6
- package/lib/App.js +1 -27
- package/lib/AppModule.d.ts +6 -0
- package/lib/AppModule.js +97 -0
- package/lib/controllers/CompletionController.d.ts +6 -0
- package/lib/controllers/CompletionController.js +32 -0
- package/lib/controllers/ImageController.d.ts +5 -8
- package/lib/controllers/ImageController.js +27 -12
- package/lib/controllers/PluginController.d.ts +9 -13
- package/lib/controllers/PluginController.js +56 -18
- package/lib/controllers/PresetController.d.ts +9 -15
- package/lib/controllers/PresetController.js +41 -22
- package/lib/controllers/ProjectController.d.ts +27 -69
- package/lib/controllers/ProjectController.js +336 -261
- package/lib/controllers/ProxyController.d.ts +15 -25
- package/lib/controllers/ProxyController.js +142 -96
- package/lib/controllers/index.d.ts +1 -0
- package/lib/controllers/index.js +1 -0
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -11
- package/lib/main.d.ts +3 -0
- package/lib/main.js +11 -0
- package/lib/makes/Logger.d.ts +2 -2
- package/lib/makes/Logger.js +19 -8
- package/lib/makes/Preset.d.ts +3 -4
- package/lib/makes/Preset.js +19 -8
- package/lib/makes/index.d.ts +0 -6
- package/lib/makes/index.js +0 -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 +3 -3
- package/lib/services/AppConfigService.js +16 -2
- 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 +4 -9
- package/lib/services/PluginService.js +18 -8
- package/lib/services/PresetService.d.ts +5 -5
- package/lib/services/PresetService.js +11 -2
- package/lib/services/ProjectService.d.ts +9 -6
- package/lib/services/ProjectService.js +62 -31
- package/lib/utils/get-config.d.ts +2 -2
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/index.js +0 -1
- package/lib/utils/set-config.d.ts +2 -2
- package/package.json +6 -6
- package/presets/node/config.json +1 -1
- package/presets/php-apache/Dockerfile +24 -0
- package/presets/php-apache/config.json +4 -1
- package/presets/php-fpm/Dockerfile +164 -12
- package/presets/php-fpm/bin/compare-version +3 -0
- package/presets/php-fpm/config.json +34 -5
- package/presets/php-fpm/etc/nginx/sites-available/default.conf +36 -0
- 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/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/Plugin.js +0 -61
- 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/demuxOutput.d.ts +0 -2
- package/lib/utils/demuxOutput.js +0 -19
package/bin/ws.js
CHANGED
package/lib/App.d.ts
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import { Controller } from "@wocker/core";
|
|
2
1
|
import { Cli } from "@kearisp/cli";
|
|
3
|
-
import { DI } from "./makes";
|
|
4
2
|
import { AppConfigService } from "./services";
|
|
5
3
|
export declare class App {
|
|
6
|
-
protected di: DI;
|
|
7
4
|
protected cli: Cli;
|
|
8
5
|
protected appConfigService: AppConfigService;
|
|
9
6
|
constructor();
|
|
10
7
|
install(): void;
|
|
11
|
-
use(Constructor:
|
|
12
|
-
new (...params: any[]): Controller;
|
|
13
|
-
}): void;
|
|
8
|
+
use(Constructor: any): void;
|
|
14
9
|
setDebug(status: string): Promise<string>;
|
|
15
10
|
run(): Promise<string>;
|
|
16
11
|
}
|
package/lib/App.js
CHANGED
|
@@ -24,36 +24,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.App = void 0;
|
|
27
|
-
const cli_1 = require("@kearisp/cli");
|
|
28
27
|
const Path = __importStar(require("path"));
|
|
29
28
|
const env_1 = require("./env");
|
|
30
29
|
const utils_1 = require("./utils");
|
|
31
30
|
const makes_1 = require("./makes");
|
|
32
|
-
const services_1 = require("./services");
|
|
33
|
-
const controllers_1 = require("./controllers");
|
|
34
31
|
class App {
|
|
35
|
-
constructor() {
|
|
36
|
-
this.di = new makes_1.DI();
|
|
37
|
-
this.appConfigService = new services_1.AppConfigService();
|
|
38
|
-
this.di.registerService(services_1.AppConfigService, this.appConfigService);
|
|
39
|
-
this.di.registerService(services_1.AppEventsService, new services_1.AppEventsService());
|
|
40
|
-
this.di.registerService(services_1.DockerService, new services_1.DockerService(this.di));
|
|
41
|
-
this.di.registerService(services_1.PresetService, new services_1.PresetService(this.di));
|
|
42
|
-
this.di.registerService(services_1.PluginService, new services_1.PluginService(this.di));
|
|
43
|
-
this.di.registerService(services_1.ProjectService, new services_1.ProjectService(this.di));
|
|
44
|
-
this.di.registerService(services_1.LogService, new services_1.LogService(this.di));
|
|
45
|
-
this.di.registerService(cli_1.Cli, this.cli);
|
|
46
|
-
this.cli = new cli_1.Cli(makes_1.Logger);
|
|
47
|
-
makes_1.Preset.install(this.di);
|
|
48
|
-
makes_1.Project.install(this.di);
|
|
49
|
-
makes_1.Logger.install(this.di);
|
|
50
|
-
this.install();
|
|
51
|
-
this.use(controllers_1.ImageController);
|
|
52
|
-
this.use(controllers_1.PluginController);
|
|
53
|
-
this.use(controllers_1.PresetController);
|
|
54
|
-
this.use(controllers_1.ProjectController);
|
|
55
|
-
this.use(controllers_1.ProxyController);
|
|
56
|
-
}
|
|
32
|
+
constructor() { }
|
|
57
33
|
install() {
|
|
58
34
|
this.cli.command("completion script")
|
|
59
35
|
.help(false)
|
|
@@ -68,8 +44,6 @@ class App {
|
|
|
68
44
|
.action(async (options, status) => this.setDebug(status));
|
|
69
45
|
}
|
|
70
46
|
use(Constructor) {
|
|
71
|
-
const controller = new Constructor(this.di);
|
|
72
|
-
controller.install(this.cli);
|
|
73
47
|
}
|
|
74
48
|
async setDebug(status) {
|
|
75
49
|
makes_1.Logger.info(`Set debug ${status}`);
|
package/lib/AppModule.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
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 config = await appConfigService.getAppConfig();
|
|
42
|
+
const { plugins } = config;
|
|
43
|
+
const imports = [];
|
|
44
|
+
for (const plugin of 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
|
+
throw err;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
imports
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
exports.AppModule = AppModule;
|
|
71
|
+
exports.AppModule = AppModule = AppModule_1 = __decorate([
|
|
72
|
+
(0, core_1.Module)({
|
|
73
|
+
controllers: [
|
|
74
|
+
controllers_1.CompletionController,
|
|
75
|
+
controllers_1.ImageController,
|
|
76
|
+
controllers_1.PluginController,
|
|
77
|
+
controllers_1.PresetController,
|
|
78
|
+
controllers_1.ProjectController,
|
|
79
|
+
controllers_1.ProxyController
|
|
80
|
+
],
|
|
81
|
+
providers: [
|
|
82
|
+
services_1.AppConfigService,
|
|
83
|
+
services_1.AppEventsService,
|
|
84
|
+
services_1.DockerService,
|
|
85
|
+
services_1.LogService,
|
|
86
|
+
services_1.PluginService,
|
|
87
|
+
services_1.PresetService,
|
|
88
|
+
services_1.ProjectService
|
|
89
|
+
],
|
|
90
|
+
exports: [
|
|
91
|
+
services_1.AppConfigService,
|
|
92
|
+
services_1.AppEventsService,
|
|
93
|
+
services_1.DockerService,
|
|
94
|
+
services_1.LogService
|
|
95
|
+
]
|
|
96
|
+
})
|
|
97
|
+
], 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);
|
|
@@ -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,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
install(cli: Cli): void;
|
|
11
|
-
add(options: AddOptions, addName: string): Promise<void>;
|
|
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>;
|
|
13
10
|
}
|
|
14
|
-
export { PluginController };
|
|
@@ -15,6 +15,12 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
18
24
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
25
|
if (mod && mod.__esModule) return mod;
|
|
20
26
|
var result = {};
|
|
@@ -22,41 +28,49 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
28
|
__setModuleDefault(result, mod);
|
|
23
29
|
return result;
|
|
24
30
|
};
|
|
31
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
|
+
};
|
|
25
34
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
36
|
};
|
|
28
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
38
|
exports.PluginController = void 0;
|
|
39
|
+
const core_1 = require("@wocker/core");
|
|
30
40
|
const axios_1 = __importDefault(require("axios"));
|
|
31
41
|
const chalk_1 = __importDefault(require("chalk"));
|
|
32
|
-
const
|
|
42
|
+
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
33
43
|
const services_1 = require("../services");
|
|
34
44
|
const utils_1 = require("../utils");
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
this.appConfigService =
|
|
39
|
-
this.pluginService =
|
|
45
|
+
const console = __importStar(require("console"));
|
|
46
|
+
let PluginController = class PluginController {
|
|
47
|
+
constructor(appConfigService, pluginService, logService) {
|
|
48
|
+
this.appConfigService = appConfigService;
|
|
49
|
+
this.pluginService = pluginService;
|
|
50
|
+
this.logService = logService;
|
|
40
51
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
52
|
+
async list() {
|
|
53
|
+
const { plugins } = await this.appConfigService.getAppConfig();
|
|
54
|
+
const table = new cli_table3_1.default({
|
|
55
|
+
head: ["Name"],
|
|
56
|
+
colWidths: [30]
|
|
57
|
+
});
|
|
58
|
+
for (const name of plugins) {
|
|
59
|
+
table.push([name]);
|
|
60
|
+
}
|
|
61
|
+
return table.toString() + "\n";
|
|
47
62
|
}
|
|
48
|
-
async add(
|
|
63
|
+
async add(addName) {
|
|
49
64
|
const [, prefix = "@wocker/", name, suffix = "-plugin"] = /^(@wocker\/)?(\w+)(-plugin)?$/.exec(addName) || [];
|
|
50
65
|
const fullName = `${prefix}${name}${suffix}`;
|
|
51
66
|
try {
|
|
52
67
|
const { default: Plugin } = await Promise.resolve(`${fullName}`).then(s => __importStar(require(s)));
|
|
53
|
-
this.pluginService.use(Plugin);
|
|
54
68
|
await this.appConfigService.activatePlugin(fullName);
|
|
55
69
|
console.info(`Plugin ${fullName} activated`);
|
|
56
70
|
return;
|
|
57
71
|
}
|
|
58
72
|
catch (err) {
|
|
59
|
-
|
|
73
|
+
this.logService.error(err.message);
|
|
60
74
|
}
|
|
61
75
|
try {
|
|
62
76
|
const res = await axios_1.default.get(`https://registry.npmjs.org/${encodeURIComponent(fullName)}`, {
|
|
@@ -71,14 +85,38 @@ class PluginController extends makes_1.Controller {
|
|
|
71
85
|
await this.appConfigService.activatePlugin(fullName);
|
|
72
86
|
}
|
|
73
87
|
catch (err) {
|
|
74
|
-
|
|
88
|
+
this.logService.error(err.message);
|
|
75
89
|
}
|
|
76
90
|
}
|
|
77
|
-
async remove(
|
|
91
|
+
async remove(removeName) {
|
|
78
92
|
const [, prefix = "@wocker/", name, suffix = "-plugin"] = /^(@wocker\/)?(\w+)(-plugin)?$/.exec(removeName) || [];
|
|
79
93
|
const fullName = `${prefix}${name}${suffix}`;
|
|
80
94
|
await this.appConfigService.deactivatePlugin(fullName);
|
|
81
95
|
console.info(`Plugin ${fullName} deactivated`);
|
|
82
96
|
}
|
|
83
|
-
}
|
|
97
|
+
};
|
|
84
98
|
exports.PluginController = PluginController;
|
|
99
|
+
__decorate([
|
|
100
|
+
(0, core_1.Command)("plugins"),
|
|
101
|
+
__metadata("design:type", Function),
|
|
102
|
+
__metadata("design:paramtypes", []),
|
|
103
|
+
__metadata("design:returntype", Promise)
|
|
104
|
+
], PluginController.prototype, "list", null);
|
|
105
|
+
__decorate([
|
|
106
|
+
(0, core_1.Command)("plugin:add <name>"),
|
|
107
|
+
__metadata("design:type", Function),
|
|
108
|
+
__metadata("design:paramtypes", [String]),
|
|
109
|
+
__metadata("design:returntype", Promise)
|
|
110
|
+
], PluginController.prototype, "add", null);
|
|
111
|
+
__decorate([
|
|
112
|
+
(0, core_1.Command)("plugin:remove <name>"),
|
|
113
|
+
__metadata("design:type", Function),
|
|
114
|
+
__metadata("design:paramtypes", [String]),
|
|
115
|
+
__metadata("design:returntype", Promise)
|
|
116
|
+
], PluginController.prototype, "remove", null);
|
|
117
|
+
exports.PluginController = PluginController = __decorate([
|
|
118
|
+
(0, core_1.Controller)(),
|
|
119
|
+
__metadata("design:paramtypes", [services_1.AppConfigService,
|
|
120
|
+
services_1.PluginService,
|
|
121
|
+
services_1.LogService])
|
|
122
|
+
], PluginController);
|
|
@@ -1,21 +1,15 @@
|
|
|
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
|
-
build(
|
|
14
|
+
build(rebuild: boolean, presetName: string): Promise<void>;
|
|
20
15
|
}
|
|
21
|
-
export { PresetController };
|
|
@@ -15,6 +15,12 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
18
24
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
25
|
if (mod && mod.__esModule) return mod;
|
|
20
26
|
var result = {};
|
|
@@ -22,37 +28,31 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
28
|
__setModuleDefault(result, mod);
|
|
23
29
|
return result;
|
|
24
30
|
};
|
|
31
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
|
+
};
|
|
34
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
35
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
36
|
+
};
|
|
25
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
38
|
exports.PresetController = void 0;
|
|
39
|
+
const core_1 = require("@wocker/core");
|
|
27
40
|
const utils_1 = require("@wocker/utils");
|
|
28
41
|
const Path = __importStar(require("path"));
|
|
29
42
|
const env_1 = require("../env");
|
|
30
43
|
const utils_2 = require("../utils");
|
|
31
|
-
const makes_1 = require("../makes");
|
|
32
44
|
const services_1 = require("../services");
|
|
33
|
-
|
|
34
|
-
constructor(
|
|
35
|
-
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
38
|
-
this.
|
|
39
|
-
this.
|
|
40
|
-
this.dockerService = di.resolveService(services_1.DockerService);
|
|
41
|
-
}
|
|
42
|
-
install(cli) {
|
|
43
|
-
super.install(cli);
|
|
45
|
+
let PresetController = class PresetController {
|
|
46
|
+
constructor(appConfigService, appEventsService, projectService, presetService, dockerService) {
|
|
47
|
+
this.appConfigService = appConfigService;
|
|
48
|
+
this.appEventsService = appEventsService;
|
|
49
|
+
this.projectService = projectService;
|
|
50
|
+
this.presetService = presetService;
|
|
51
|
+
this.dockerService = dockerService;
|
|
44
52
|
this.appConfigService.registerProjectType("preset", "Preset");
|
|
45
53
|
this.appEventsService.on("project:init", (project) => this.onInit(project));
|
|
46
54
|
this.appEventsService.on("project:beforeStart", (project) => this.onBeforeStart(project));
|
|
47
55
|
this.appEventsService.on("project:rebuild", (project) => this.onRebuild(project));
|
|
48
|
-
cli.command("preset:build <preset>")
|
|
49
|
-
.completion("preset", () => this.presets())
|
|
50
|
-
.option("rebuild", {
|
|
51
|
-
type: "boolean",
|
|
52
|
-
alias: "r",
|
|
53
|
-
description: "Rebuild image"
|
|
54
|
-
})
|
|
55
|
-
.action((options, preset) => this.build(options, preset));
|
|
56
56
|
}
|
|
57
57
|
async presets() {
|
|
58
58
|
const presets = await this.presetService.search();
|
|
@@ -148,7 +148,7 @@ class PresetController extends makes_1.Controller {
|
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
-
async build(
|
|
151
|
+
async build(rebuild, presetName) {
|
|
152
152
|
const preset = await this.presetService.get(presetName);
|
|
153
153
|
let buildArgs = {};
|
|
154
154
|
if (preset.buildArgsOptions) {
|
|
@@ -165,5 +165,24 @@ class PresetController extends makes_1.Controller {
|
|
|
165
165
|
src: preset.dockerfile
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
|
-
}
|
|
168
|
+
};
|
|
169
169
|
exports.PresetController = PresetController;
|
|
170
|
+
__decorate([
|
|
171
|
+
(0, core_1.Command)("preset:build <preset>"),
|
|
172
|
+
__param(0, (0, core_1.Option)("rebuild", {
|
|
173
|
+
type: "boolean",
|
|
174
|
+
alias: "r",
|
|
175
|
+
description: "Rebuild image"
|
|
176
|
+
})),
|
|
177
|
+
__metadata("design:type", Function),
|
|
178
|
+
__metadata("design:paramtypes", [Boolean, String]),
|
|
179
|
+
__metadata("design:returntype", Promise)
|
|
180
|
+
], PresetController.prototype, "build", null);
|
|
181
|
+
exports.PresetController = PresetController = __decorate([
|
|
182
|
+
(0, core_1.Controller)(),
|
|
183
|
+
__metadata("design:paramtypes", [services_1.AppConfigService,
|
|
184
|
+
services_1.AppEventsService,
|
|
185
|
+
services_1.ProjectService,
|
|
186
|
+
services_1.PresetService,
|
|
187
|
+
services_1.DockerService])
|
|
188
|
+
], PresetController);
|