@wocker/ws 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/App.d.ts +4 -3
- package/lib/App.js +98 -77
- package/lib/controllers/ImageController.d.ts +2 -2
- package/lib/controllers/ImageController.js +27 -27
- package/lib/controllers/PluginController.d.ts +2 -2
- package/lib/controllers/PluginController.js +78 -56
- package/lib/controllers/PresetController.d.ts +3 -1
- package/lib/controllers/PresetController.js +155 -136
- package/lib/controllers/ProjectController.d.ts +5 -5
- package/lib/controllers/ProjectController.js +653 -603
- package/lib/controllers/ProxyController.d.ts +4 -1
- package/lib/controllers/ProxyController.js +269 -245
- package/lib/controllers/index.js +19 -58
- package/lib/decorators/Inject.d.ts +1 -0
- package/lib/decorators/Inject.js +8 -0
- package/lib/decorators/Injectable.d.ts +4 -0
- package/lib/decorators/Injectable.js +17 -0
- package/lib/decorators/index.d.ts +1 -0
- package/lib/decorators/index.js +17 -0
- package/lib/env.js +33 -15
- package/lib/index.d.ts +3 -0
- package/lib/index.js +31 -16
- package/lib/makes/Controller.js +4 -8
- package/lib/makes/DI.d.ts +7 -0
- package/lib/makes/DI.js +27 -0
- package/lib/makes/Docker.js +298 -382
- package/lib/makes/FS.d.ts +3 -9
- package/lib/makes/FS.js +277 -305
- package/lib/makes/LineConvertStream.js +37 -40
- package/lib/makes/Logger.d.ts +9 -1
- package/lib/makes/Logger.js +22 -11
- package/lib/makes/Model.js +8 -12
- package/lib/makes/MySQL.js +6 -27
- package/lib/makes/Plugin.d.ts +1 -1
- package/lib/makes/Plugin.js +55 -37
- package/lib/makes/Preset.d.ts +46 -0
- package/lib/makes/Preset.js +33 -0
- package/lib/makes/Project.d.ts +45 -0
- package/lib/makes/Project.js +127 -0
- package/lib/makes/Repository.js +18 -21
- package/lib/makes/index.d.ts +3 -0
- package/lib/makes/index.js +23 -69
- package/lib/plugins/ElasticSearchPlugin.d.ts +3 -1
- package/lib/plugins/ElasticSearchPlugin.js +66 -66
- package/lib/plugins/LocaltunnelPlugin.d.ts +2 -2
- package/lib/plugins/LocaltunnelPlugin.js +256 -257
- package/lib/plugins/MaildevPlugin.d.ts +2 -2
- package/lib/plugins/MaildevPlugin.js +45 -44
- package/lib/plugins/MongodbPlugin.d.ts +2 -2
- package/lib/plugins/MongodbPlugin.js +303 -248
- package/lib/plugins/NgrokPlugin.d.ts +2 -2
- package/lib/plugins/NgrokPlugin.js +221 -231
- package/lib/plugins/PageKitePlugin.d.ts +2 -2
- package/lib/plugins/PageKitePlugin.js +150 -149
- package/lib/plugins/PostgresPlugin.d.ts +1 -1
- package/lib/plugins/PostgresPlugin.js +115 -89
- package/lib/plugins/ProxmoxPlugin.d.ts +1 -1
- package/lib/plugins/ProxmoxPlugin.js +50 -38
- package/lib/plugins/RedisPlugin.d.ts +3 -1
- package/lib/plugins/RedisPlugin.js +73 -72
- package/lib/plugins/index.js +25 -103
- package/lib/services/AppConfigService.d.ts +3 -3
- package/lib/services/AppConfigService.js +162 -157
- package/lib/services/AppEventsService.js +26 -24
- package/lib/services/DockerService.d.ts +37 -2
- package/lib/services/DockerService.js +185 -205
- package/lib/services/LogService.d.ts +3 -2
- package/lib/services/LogService.js +33 -34
- package/lib/services/PluginService.d.ts +2 -1
- package/lib/services/PluginService.js +11 -14
- package/lib/services/PresetService.d.ts +8 -3
- package/lib/services/PresetService.js +60 -59
- package/lib/services/ProjectService.d.ts +11 -4
- package/lib/services/ProjectService.js +140 -129
- package/lib/services/index.js +21 -80
- package/lib/types/Config.d.ts +4 -3
- package/lib/types/Config.js +1 -4
- package/lib/types/EnvConfig.js +1 -4
- package/lib/types/index.js +16 -25
- package/lib/utils/buildOptions.js +5 -8
- package/lib/utils/demuxOutput.js +16 -20
- package/lib/utils/escapeRegExp.js +4 -7
- package/lib/utils/exec.js +38 -39
- package/lib/utils/fetch.js +46 -30
- package/lib/utils/followProgress.js +66 -77
- package/lib/utils/format-size-units.js +16 -16
- package/lib/utils/get-config.d.ts +1 -1
- package/lib/utils/get-config.js +13 -16
- package/lib/utils/get-cursor-position.js +22 -29
- package/lib/utils/image-build.js +35 -23
- package/lib/utils/index.js +32 -191
- package/lib/utils/injectVariables.js +10 -13
- package/lib/utils/parse-table.js +20 -23
- package/lib/utils/set-config.d.ts +1 -1
- package/lib/utils/set-config.js +12 -15
- package/lib/utils/spawn.js +17 -20
- package/lib/utils/tty.js +2 -6
- package/lib/utils/volumeFormat.js +5 -12
- package/lib/utils/volumeParse.js +10 -13
- package/package.json +13 -39
- package/presets/bun/Dockerfile +11 -0
- package/presets/bun/config.json +3 -0
- package/presets/node/Dockerfile +4 -2
- package/presets/php-apache/Dockerfile +3 -2
- package/.github/workflows/publish.yml +0 -31
- package/plugins/mariadb/admin/conf/config.user.inc.php +0 -9
|
@@ -1,79 +1,80 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.RedisPlugin = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
super.install(cli);
|
|
19
|
-
cli.command("redis:start").action(() => this.up());
|
|
20
|
-
cli.command("redis:stop").action(() => this.down());
|
|
21
|
-
}
|
|
22
|
-
async up() {
|
|
23
|
-
console.log("Redis up...");
|
|
24
|
-
await this.dockerService.pullImage("redis");
|
|
25
|
-
let container = await this.dockerService.getContainer(this.container);
|
|
26
|
-
if (!container) {
|
|
27
|
-
await this.fs.mkdir("", {
|
|
28
|
-
recursive: true
|
|
29
|
-
});
|
|
30
|
-
container = await this.dockerService.createContainer({
|
|
31
|
-
name: this.container,
|
|
32
|
-
image: "redis",
|
|
33
|
-
restart: "always",
|
|
34
|
-
env: {
|
|
35
|
-
VIRTUAL_HOST: this.container
|
|
36
|
-
},
|
|
37
|
-
volumes: [`${this.fs.path()}:/data`],
|
|
38
|
-
ports: ["6379:6379"]
|
|
39
|
-
});
|
|
4
|
+
const core_1 = require("@wocker/core");
|
|
5
|
+
const makes_1 = require("../makes");
|
|
6
|
+
const services_1 = require("../services");
|
|
7
|
+
class RedisPlugin extends makes_1.Plugin {
|
|
8
|
+
constructor(di) {
|
|
9
|
+
super("redis");
|
|
10
|
+
this.container = "redis.workspace";
|
|
11
|
+
this.commander = "redis-commander.workspace";
|
|
12
|
+
this.appConfigService = di.resolveService(services_1.AppConfigService);
|
|
13
|
+
this.dockerService = di.resolveService(services_1.DockerService);
|
|
14
|
+
this.fs = new core_1.FSManager(this.appConfigService.pluginsPath("redis"), this.appConfigService.dataPath("plugins/redis"));
|
|
40
15
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
16
|
+
install(cli) {
|
|
17
|
+
super.install(cli);
|
|
18
|
+
cli.command("redis:start")
|
|
19
|
+
.action(() => this.up());
|
|
20
|
+
cli.command("redis:stop")
|
|
21
|
+
.action(() => this.down());
|
|
22
|
+
}
|
|
23
|
+
async up() {
|
|
24
|
+
console.log("Redis up...");
|
|
25
|
+
await this.dockerService.pullImage("redis");
|
|
26
|
+
let container = await this.dockerService.getContainer(this.container);
|
|
27
|
+
if (!container) {
|
|
28
|
+
await this.fs.mkdir("", {
|
|
29
|
+
recursive: true
|
|
30
|
+
});
|
|
31
|
+
container = await this.dockerService.createContainer({
|
|
32
|
+
name: this.container,
|
|
33
|
+
image: "redis",
|
|
34
|
+
restart: "always",
|
|
35
|
+
env: {
|
|
36
|
+
VIRTUAL_HOST: this.container
|
|
37
|
+
},
|
|
38
|
+
volumes: [
|
|
39
|
+
`${this.fs.path()}:/data`
|
|
40
|
+
],
|
|
41
|
+
ports: [
|
|
42
|
+
"6379:6379"
|
|
43
|
+
]
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
await container.start();
|
|
47
|
+
await this.startCommander();
|
|
48
|
+
}
|
|
49
|
+
async startCommander() {
|
|
50
|
+
console.info("RedisCommander starting...");
|
|
51
|
+
let container = await this.dockerService.getContainer(this.commander);
|
|
52
|
+
if (!container) {
|
|
53
|
+
await this.dockerService.pullImage("rediscommander/redis-commander:latest");
|
|
54
|
+
container = await this.dockerService.createContainer({
|
|
55
|
+
name: this.commander,
|
|
56
|
+
image: "rediscommander/redis-commander:latest",
|
|
57
|
+
restart: "always",
|
|
58
|
+
env: {
|
|
59
|
+
VIRTUAL_HOST: this.commander,
|
|
60
|
+
VIRTUAL_PORT: "8081",
|
|
61
|
+
REDIS_HOSTS: this.container
|
|
62
|
+
}
|
|
63
|
+
});
|
|
57
64
|
}
|
|
58
|
-
|
|
65
|
+
const { State: { Status } } = await container.inspect();
|
|
66
|
+
if (Status === "created" || Status === "exited") {
|
|
67
|
+
await container.start();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async down() {
|
|
71
|
+
console.log("Redis down...");
|
|
72
|
+
await this.dockerService.removeContainer(this.container);
|
|
73
|
+
await this.stopCommander();
|
|
59
74
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
} = await container.inspect();
|
|
65
|
-
if (Status === "created" || Status === "exited") {
|
|
66
|
-
await container.start();
|
|
75
|
+
async stopCommander() {
|
|
76
|
+
console.info("RedisCommander stopping...");
|
|
77
|
+
await this.dockerService.removeContainer(this.commander);
|
|
67
78
|
}
|
|
68
|
-
}
|
|
69
|
-
async down() {
|
|
70
|
-
console.log("Redis down...");
|
|
71
|
-
await this.dockerService.removeContainer(this.container);
|
|
72
|
-
await this.stopCommander();
|
|
73
|
-
}
|
|
74
|
-
async stopCommander() {
|
|
75
|
-
console.info("RedisCommander stopping...");
|
|
76
|
-
await this.dockerService.removeContainer(this.commander);
|
|
77
|
-
}
|
|
78
79
|
}
|
|
79
|
-
exports.RedisPlugin = RedisPlugin;
|
|
80
|
+
exports.RedisPlugin = RedisPlugin;
|
package/lib/plugins/index.js
CHANGED
|
@@ -1,104 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
});
|
|
28
|
-
var _MaildevPlugin = require("./MaildevPlugin");
|
|
29
|
-
Object.keys(_MaildevPlugin).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _MaildevPlugin[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _MaildevPlugin[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
var _MongodbPlugin = require("./MongodbPlugin");
|
|
40
|
-
Object.keys(_MongodbPlugin).forEach(function (key) {
|
|
41
|
-
if (key === "default" || key === "__esModule") return;
|
|
42
|
-
if (key in exports && exports[key] === _MongodbPlugin[key]) return;
|
|
43
|
-
Object.defineProperty(exports, key, {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () {
|
|
46
|
-
return _MongodbPlugin[key];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
var _NgrokPlugin = require("./NgrokPlugin");
|
|
51
|
-
Object.keys(_NgrokPlugin).forEach(function (key) {
|
|
52
|
-
if (key === "default" || key === "__esModule") return;
|
|
53
|
-
if (key in exports && exports[key] === _NgrokPlugin[key]) return;
|
|
54
|
-
Object.defineProperty(exports, key, {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
get: function () {
|
|
57
|
-
return _NgrokPlugin[key];
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
var _PageKitePlugin = require("./PageKitePlugin");
|
|
62
|
-
Object.keys(_PageKitePlugin).forEach(function (key) {
|
|
63
|
-
if (key === "default" || key === "__esModule") return;
|
|
64
|
-
if (key in exports && exports[key] === _PageKitePlugin[key]) return;
|
|
65
|
-
Object.defineProperty(exports, key, {
|
|
66
|
-
enumerable: true,
|
|
67
|
-
get: function () {
|
|
68
|
-
return _PageKitePlugin[key];
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
var _PostgresPlugin = require("./PostgresPlugin");
|
|
73
|
-
Object.keys(_PostgresPlugin).forEach(function (key) {
|
|
74
|
-
if (key === "default" || key === "__esModule") return;
|
|
75
|
-
if (key in exports && exports[key] === _PostgresPlugin[key]) return;
|
|
76
|
-
Object.defineProperty(exports, key, {
|
|
77
|
-
enumerable: true,
|
|
78
|
-
get: function () {
|
|
79
|
-
return _PostgresPlugin[key];
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
var _ProxmoxPlugin = require("./ProxmoxPlugin");
|
|
84
|
-
Object.keys(_ProxmoxPlugin).forEach(function (key) {
|
|
85
|
-
if (key === "default" || key === "__esModule") return;
|
|
86
|
-
if (key in exports && exports[key] === _ProxmoxPlugin[key]) return;
|
|
87
|
-
Object.defineProperty(exports, key, {
|
|
88
|
-
enumerable: true,
|
|
89
|
-
get: function () {
|
|
90
|
-
return _ProxmoxPlugin[key];
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
var _RedisPlugin = require("./RedisPlugin");
|
|
95
|
-
Object.keys(_RedisPlugin).forEach(function (key) {
|
|
96
|
-
if (key === "default" || key === "__esModule") return;
|
|
97
|
-
if (key in exports && exports[key] === _RedisPlugin[key]) return;
|
|
98
|
-
Object.defineProperty(exports, key, {
|
|
99
|
-
enumerable: true,
|
|
100
|
-
get: function () {
|
|
101
|
-
return _RedisPlugin[key];
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
});
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ElasticSearchPlugin"), exports);
|
|
18
|
+
__exportStar(require("./LocaltunnelPlugin"), exports);
|
|
19
|
+
__exportStar(require("./MaildevPlugin"), exports);
|
|
20
|
+
__exportStar(require("./MongodbPlugin"), exports);
|
|
21
|
+
__exportStar(require("./NgrokPlugin"), exports);
|
|
22
|
+
__exportStar(require("./PageKitePlugin"), exports);
|
|
23
|
+
__exportStar(require("./PostgresPlugin"), exports);
|
|
24
|
+
__exportStar(require("./PostgresPlugin"), exports);
|
|
25
|
+
__exportStar(require("./ProxmoxPlugin"), exports);
|
|
26
|
+
__exportStar(require("./RedisPlugin"), exports);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Config, EnvConfig } from "../types";
|
|
2
2
|
type TypeMap = {
|
|
3
3
|
[type: string]: string;
|
|
4
4
|
};
|
|
5
|
-
declare class AppConfigService
|
|
5
|
+
declare class AppConfigService {
|
|
6
6
|
protected pwd: string;
|
|
7
7
|
protected mapTypes: TypeMap;
|
|
8
8
|
constructor();
|
|
@@ -10,7 +10,7 @@ declare class AppConfigService extends CoreAppConfigService {
|
|
|
10
10
|
pluginsPath(...args: string[]): string;
|
|
11
11
|
getPWD(): string;
|
|
12
12
|
setPWD(pwd: string): void;
|
|
13
|
-
getAppConfig(): Promise<
|
|
13
|
+
getAppConfig(): Promise<Config>;
|
|
14
14
|
private saveAppConfig;
|
|
15
15
|
getMeta(name: string, defaultValue?: string): Promise<string>;
|
|
16
16
|
setMeta(name: string, value?: string | number): Promise<void>;
|
|
@@ -1,162 +1,167 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
5
17
|
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
26
|
exports.AppConfigService = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
27
|
+
const Path = __importStar(require("path"));
|
|
28
|
+
const env_1 = require("../env");
|
|
29
|
+
const makes_1 = require("../makes");
|
|
30
|
+
class AppConfigService {
|
|
31
|
+
constructor() {
|
|
32
|
+
this.mapTypes = {
|
|
33
|
+
image: "Image",
|
|
34
|
+
dockerfile: "Dockerfile"
|
|
35
|
+
};
|
|
36
|
+
this.pwd = (process.cwd() || process.env.PWD);
|
|
37
|
+
}
|
|
38
|
+
dataPath(...args) {
|
|
39
|
+
return Path.join(env_1.DATA_DIR, ...args);
|
|
40
|
+
}
|
|
41
|
+
pluginsPath(...args) {
|
|
42
|
+
return Path.join(env_1.PLUGINS_DIR, ...args);
|
|
43
|
+
}
|
|
44
|
+
getPWD() {
|
|
45
|
+
return this.pwd;
|
|
46
|
+
}
|
|
47
|
+
setPWD(pwd) {
|
|
48
|
+
this.pwd = pwd;
|
|
49
|
+
}
|
|
50
|
+
async getAppConfig() {
|
|
51
|
+
return makes_1.FS.readJSON(env_1.MAP_PATH);
|
|
52
|
+
}
|
|
53
|
+
async saveAppConfig(config) {
|
|
54
|
+
await makes_1.FS.writeJSON(env_1.MAP_PATH, config);
|
|
55
|
+
}
|
|
56
|
+
async getMeta(name, defaultValue) {
|
|
57
|
+
const config = await this.getAppConfig();
|
|
58
|
+
const value = (config.meta || {})[name];
|
|
59
|
+
if (!value) {
|
|
60
|
+
return defaultValue;
|
|
61
|
+
}
|
|
62
|
+
return value;
|
|
63
|
+
}
|
|
64
|
+
async setMeta(name, value) {
|
|
65
|
+
const config = await this.getAppConfig();
|
|
66
|
+
if (!config.meta) {
|
|
67
|
+
config.meta = {};
|
|
68
|
+
}
|
|
69
|
+
config.meta[name] = value ? value.toString() : undefined;
|
|
70
|
+
await this.saveAppConfig(config);
|
|
71
|
+
}
|
|
72
|
+
async getAllEnvVariables() {
|
|
73
|
+
const { env = {} } = await makes_1.FS.readJSON(env_1.MAP_PATH);
|
|
74
|
+
return env;
|
|
75
|
+
}
|
|
76
|
+
async getEnvVariable(name, defaultValue) {
|
|
77
|
+
const { [name]: value = defaultValue } = await this.getAllEnvVariables();
|
|
78
|
+
if (value === null) {
|
|
79
|
+
return defaultValue;
|
|
80
|
+
}
|
|
81
|
+
return value;
|
|
82
|
+
}
|
|
83
|
+
async setEnv(env) {
|
|
84
|
+
const config = await makes_1.FS.readJSON(env_1.MAP_PATH);
|
|
85
|
+
await makes_1.FS.writeJSON(env_1.MAP_PATH, {
|
|
86
|
+
...config,
|
|
87
|
+
env: {
|
|
88
|
+
...config.env || {},
|
|
89
|
+
...env
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
async setEnvVariable(name, value) {
|
|
94
|
+
const config = await makes_1.FS.readJSON(env_1.MAP_PATH);
|
|
95
|
+
await makes_1.FS.writeJSON(env_1.MAP_PATH, {
|
|
96
|
+
...config,
|
|
97
|
+
env: {
|
|
98
|
+
...config.env || {},
|
|
99
|
+
[name]: value
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
async unsetEnv(...keys) {
|
|
104
|
+
const config = await makes_1.FS.readJSON(env_1.MAP_PATH);
|
|
105
|
+
await makes_1.FS.writeJSON(env_1.MAP_PATH, {
|
|
106
|
+
...config,
|
|
107
|
+
env: Object.keys(config.env || {}).reduce((res, key) => {
|
|
108
|
+
if (!keys.includes(key)) {
|
|
109
|
+
res[key] = config.env[key];
|
|
110
|
+
}
|
|
111
|
+
return res;
|
|
112
|
+
}, {})
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
getProjectTypes() {
|
|
116
|
+
return this.mapTypes;
|
|
117
|
+
}
|
|
118
|
+
registerProjectType(name, title) {
|
|
119
|
+
this.mapTypes[name] = title || name;
|
|
120
|
+
}
|
|
121
|
+
async setProjectConfig(id, path) {
|
|
122
|
+
const { projects, ...rest } = await this.getAppConfig();
|
|
123
|
+
await makes_1.FS.writeJSON(env_1.MAP_PATH, {
|
|
124
|
+
...rest,
|
|
125
|
+
projects: [
|
|
126
|
+
...(projects || []).filter((project) => {
|
|
127
|
+
return project.id !== id;
|
|
128
|
+
}).filter((project) => {
|
|
129
|
+
return project.src !== path;
|
|
130
|
+
}),
|
|
131
|
+
{
|
|
132
|
+
id: id,
|
|
133
|
+
src: path
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
async activatePlugin(name) {
|
|
139
|
+
const { default: Plugin } = await Promise.resolve(`${name}`).then(s => __importStar(require(s)));
|
|
140
|
+
if (!Plugin) {
|
|
141
|
+
throw new Error("No plugin");
|
|
98
142
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
src: path
|
|
123
|
-
}]
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
async activatePlugin(name) {
|
|
127
|
-
const {
|
|
128
|
-
default: Plugin
|
|
129
|
-
} = await (specifier => new Promise(r => r(`${specifier}`)).then(s => _interopRequireWildcard(require(s))))(name);
|
|
130
|
-
|
|
131
|
-
// this.use
|
|
132
|
-
if (!Plugin) {
|
|
133
|
-
throw new Error("No plugin");
|
|
134
|
-
}
|
|
135
|
-
const {
|
|
136
|
-
plugins = [],
|
|
137
|
-
...rest
|
|
138
|
-
} = await this.getAppConfig();
|
|
139
|
-
await _makes.FS.writeJSON(_env.MAP_PATH, {
|
|
140
|
-
plugins: [...plugins.filter(plugin => {
|
|
141
|
-
return plugin !== name;
|
|
142
|
-
}), name],
|
|
143
|
-
...rest
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
async deactivatePlugin(name) {
|
|
147
|
-
const {
|
|
148
|
-
plugins = [],
|
|
149
|
-
...rest
|
|
150
|
-
} = await this.getAppConfig();
|
|
151
|
-
if (!plugins.includes(name)) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
await _makes.FS.writeJSON(_env.MAP_PATH, {
|
|
155
|
-
plugins: plugins.filter(plugin => {
|
|
156
|
-
return plugin !== name;
|
|
157
|
-
}),
|
|
158
|
-
...rest
|
|
159
|
-
});
|
|
160
|
-
}
|
|
143
|
+
const { plugins = [], ...rest } = await this.getAppConfig();
|
|
144
|
+
await makes_1.FS.writeJSON(env_1.MAP_PATH, {
|
|
145
|
+
plugins: [
|
|
146
|
+
...plugins.filter((plugin) => {
|
|
147
|
+
return plugin !== name;
|
|
148
|
+
}),
|
|
149
|
+
name
|
|
150
|
+
],
|
|
151
|
+
...rest
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
async deactivatePlugin(name) {
|
|
155
|
+
const { plugins = [], ...rest } = await this.getAppConfig();
|
|
156
|
+
if (!plugins.includes(name)) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
await makes_1.FS.writeJSON(env_1.MAP_PATH, {
|
|
160
|
+
plugins: plugins.filter((plugin) => {
|
|
161
|
+
return plugin !== name;
|
|
162
|
+
}),
|
|
163
|
+
...rest
|
|
164
|
+
});
|
|
165
|
+
}
|
|
161
166
|
}
|
|
162
|
-
exports.AppConfigService = AppConfigService;
|
|
167
|
+
exports.AppConfigService = AppConfigService;
|