@wocker/ws 1.0.1 → 1.0.3
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 +11 -137
- package/bin/ws.js +7 -3
- package/lib/App.d.ts +10 -7
- package/lib/App.js +99 -44
- package/lib/controllers/ImageController.d.ts +4 -2
- package/lib/controllers/ImageController.js +27 -25
- package/lib/controllers/PluginController.d.ts +14 -0
- package/lib/controllers/PluginController.js +84 -0
- package/lib/controllers/PresetController.d.ts +21 -0
- package/lib/controllers/PresetController.js +169 -0
- package/lib/controllers/ProjectController.d.ts +11 -3
- package/lib/controllers/ProjectController.js +653 -536
- package/lib/{plugins/ProxyPlugin.d.ts → controllers/ProxyController.d.ts} +12 -11
- package/lib/controllers/ProxyController.js +273 -0
- package/lib/controllers/index.d.ts +3 -0
- package/lib/controllers/index.js +19 -25
- package/lib/env.js +33 -22
- package/lib/index.d.ts +2 -0
- package/lib/index.js +29 -28
- 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 +299 -397
- package/lib/makes/FS.d.ts +1 -1
- package/lib/makes/FS.js +328 -301
- package/lib/makes/LineConvertStream.js +37 -40
- package/lib/makes/Logger.d.ts +5 -3
- package/lib/makes/Logger.js +18 -34
- 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/{models → makes}/Project.d.ts +23 -16
- 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 +18 -0
- package/lib/plugins/ElasticSearchPlugin.js +72 -0
- package/lib/plugins/LocaltunnelPlugin.d.ts +4 -4
- package/lib/plugins/LocaltunnelPlugin.js +256 -255
- package/lib/plugins/MaildevPlugin.d.ts +4 -2
- package/lib/plugins/MaildevPlugin.js +45 -41
- package/lib/plugins/MongodbPlugin.d.ts +6 -4
- package/lib/plugins/MongodbPlugin.js +303 -254
- package/lib/plugins/NgrokPlugin.d.ts +3 -4
- package/lib/plugins/NgrokPlugin.js +221 -230
- package/lib/plugins/PageKitePlugin.d.ts +3 -4
- package/lib/plugins/PageKitePlugin.js +150 -147
- package/lib/plugins/PostgresPlugin.d.ts +1 -1
- package/lib/plugins/PostgresPlugin.js +115 -88
- package/lib/plugins/ProxmoxPlugin.d.ts +1 -1
- package/lib/plugins/ProxmoxPlugin.js +50 -38
- package/lib/plugins/RedisPlugin.d.ts +10 -2
- package/lib/plugins/RedisPlugin.js +77 -39
- package/lib/plugins/index.d.ts +2 -6
- package/lib/plugins/index.js +25 -158
- package/lib/services/AppConfigService.d.ts +13 -3
- package/lib/services/AppConfigService.js +161 -71
- package/lib/services/AppEventsService.d.ts +5 -8
- package/lib/services/AppEventsService.js +26 -25
- package/lib/services/DockerService.d.ts +51 -0
- package/lib/services/DockerService.js +200 -0
- package/lib/services/LogService.d.ts +12 -0
- package/lib/services/LogService.js +38 -0
- package/lib/services/PluginService.d.ts +11 -0
- package/lib/services/PluginService.js +15 -0
- package/lib/services/PresetService.d.ts +14 -0
- package/lib/services/PresetService.js +64 -0
- package/lib/services/ProjectService.d.ts +12 -4
- package/lib/services/ProjectService.js +141 -78
- package/lib/services/index.d.ts +4 -0
- package/lib/services/index.js +21 -36
- 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 -22
- package/lib/utils/escapeRegExp.js +4 -7
- package/lib/utils/exec.d.ts +1 -1
- package/lib/utils/exec.js +38 -40
- package/lib/utils/fetch.js +45 -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.d.ts +0 -4
- package/lib/utils/index.js +32 -235
- 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 +21 -47
- package/presets/bun/Dockerfile +11 -0
- package/presets/bun/config.json +3 -0
- package/presets/node/Dockerfile +4 -2
- package/presets/node/config.json +9 -7
- package/presets/php-apache/Dockerfile +40 -38
- package/presets/php-apache/config.json +10 -15
- package/presets/php-fpm/Dockerfile +21 -0
- package/presets/php-fpm/config.json +25 -0
- package/lib/models/Preset.d.ts +0 -19
- package/lib/models/Preset.js +0 -60
- package/lib/models/Project.js +0 -151
- package/lib/models/index.d.ts +0 -2
- package/lib/models/index.js +0 -27
- package/lib/plugins/MariadbPlugin.d.ts +0 -25
- package/lib/plugins/MariadbPlugin.js +0 -297
- package/lib/plugins/PresetPlugin.d.ts +0 -19
- package/lib/plugins/PresetPlugin.js +0 -164
- package/lib/plugins/ProjectPlugin.d.ts +0 -12
- package/lib/plugins/ProjectPlugin.js +0 -54
- package/lib/plugins/ProxyPlugin.js +0 -257
- package/lib/plugins/ServeoPlugin.d.ts +0 -36
- package/lib/plugins/ServeoPlugin.js +0 -260
- package/lib/plugins/TestPlugin.d.ts +0 -10
- package/lib/plugins/TestPlugin.js +0 -75
- package/lib/utils/promptConfirm.d.ts +0 -6
- package/lib/utils/promptConfirm.js +0 -21
- package/lib/utils/promptGroup.d.ts +0 -16
- package/lib/utils/promptGroup.js +0 -39
- package/lib/utils/promptSelect.d.ts +0 -12
- package/lib/utils/promptSelect.js +0 -47
- package/lib/utils/promptText.d.ts +0 -13
- package/lib/utils/promptText.js +0 -53
- package/plugins/mariadb/admin/conf/config.user.inc.php +0 -9
- package/plugins/serveo/Dockerfile +0 -17
|
@@ -1,10 +1,18 @@
|
|
|
1
|
+
import { FSManager } from "@wocker/core";
|
|
1
2
|
import { Cli } from "@kearisp/cli";
|
|
2
|
-
import { Plugin } from "
|
|
3
|
+
import { DI, Plugin } from "../makes";
|
|
4
|
+
import { AppConfigService, DockerService } from "../services";
|
|
3
5
|
declare class RedisPlugin extends Plugin {
|
|
4
6
|
protected container: string;
|
|
5
|
-
|
|
7
|
+
protected commander: string;
|
|
8
|
+
protected appConfigService: AppConfigService;
|
|
9
|
+
protected dockerService: DockerService;
|
|
10
|
+
protected fs: FSManager;
|
|
11
|
+
constructor(di: DI);
|
|
6
12
|
install(cli: Cli): void;
|
|
7
13
|
up(): Promise<void>;
|
|
14
|
+
protected startCommander(): Promise<void>;
|
|
8
15
|
down(): Promise<void>;
|
|
16
|
+
protected stopCommander(): Promise<void>;
|
|
9
17
|
}
|
|
10
18
|
export { RedisPlugin };
|
|
@@ -1,42 +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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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"));
|
|
15
|
+
}
|
|
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
|
+
});
|
|
64
|
+
}
|
|
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();
|
|
74
|
+
}
|
|
75
|
+
async stopCommander() {
|
|
76
|
+
console.info("RedisCommander stopping...");
|
|
77
|
+
await this.dockerService.removeContainer(this.commander);
|
|
78
|
+
}
|
|
41
79
|
}
|
|
42
|
-
exports.RedisPlugin = RedisPlugin;
|
|
80
|
+
exports.RedisPlugin = RedisPlugin;
|
package/lib/plugins/index.d.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
+
export * from "./ElasticSearchPlugin";
|
|
1
2
|
export * from "./LocaltunnelPlugin";
|
|
2
3
|
export * from "./MaildevPlugin";
|
|
3
|
-
export * from "./MariadbPlugin";
|
|
4
4
|
export * from "./MongodbPlugin";
|
|
5
5
|
export * from "./NgrokPlugin";
|
|
6
6
|
export * from "./PageKitePlugin";
|
|
7
7
|
export * from "./PostgresPlugin";
|
|
8
|
-
export * from "./
|
|
9
|
-
export * from "./ProjectPlugin";
|
|
8
|
+
export * from "./PostgresPlugin";
|
|
10
9
|
export * from "./ProxmoxPlugin";
|
|
11
|
-
export * from "./ProxyPlugin";
|
|
12
10
|
export * from "./RedisPlugin";
|
|
13
|
-
export * from "./ServeoPlugin";
|
|
14
|
-
export * from "./TestPlugin";
|
package/lib/plugins/index.js
CHANGED
|
@@ -1,159 +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 _MariadbPlugin = require("./MariadbPlugin");
|
|
29
|
-
Object.keys(_MariadbPlugin).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _MariadbPlugin[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _MariadbPlugin[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 _PresetPlugin = require("./PresetPlugin");
|
|
84
|
-
Object.keys(_PresetPlugin).forEach(function (key) {
|
|
85
|
-
if (key === "default" || key === "__esModule") return;
|
|
86
|
-
if (key in exports && exports[key] === _PresetPlugin[key]) return;
|
|
87
|
-
Object.defineProperty(exports, key, {
|
|
88
|
-
enumerable: true,
|
|
89
|
-
get: function () {
|
|
90
|
-
return _PresetPlugin[key];
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
var _ProjectPlugin = require("./ProjectPlugin");
|
|
95
|
-
Object.keys(_ProjectPlugin).forEach(function (key) {
|
|
96
|
-
if (key === "default" || key === "__esModule") return;
|
|
97
|
-
if (key in exports && exports[key] === _ProjectPlugin[key]) return;
|
|
98
|
-
Object.defineProperty(exports, key, {
|
|
99
|
-
enumerable: true,
|
|
100
|
-
get: function () {
|
|
101
|
-
return _ProjectPlugin[key];
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
var _ProxmoxPlugin = require("./ProxmoxPlugin");
|
|
106
|
-
Object.keys(_ProxmoxPlugin).forEach(function (key) {
|
|
107
|
-
if (key === "default" || key === "__esModule") return;
|
|
108
|
-
if (key in exports && exports[key] === _ProxmoxPlugin[key]) return;
|
|
109
|
-
Object.defineProperty(exports, key, {
|
|
110
|
-
enumerable: true,
|
|
111
|
-
get: function () {
|
|
112
|
-
return _ProxmoxPlugin[key];
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
var _ProxyPlugin = require("./ProxyPlugin");
|
|
117
|
-
Object.keys(_ProxyPlugin).forEach(function (key) {
|
|
118
|
-
if (key === "default" || key === "__esModule") return;
|
|
119
|
-
if (key in exports && exports[key] === _ProxyPlugin[key]) return;
|
|
120
|
-
Object.defineProperty(exports, key, {
|
|
121
|
-
enumerable: true,
|
|
122
|
-
get: function () {
|
|
123
|
-
return _ProxyPlugin[key];
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
var _RedisPlugin = require("./RedisPlugin");
|
|
128
|
-
Object.keys(_RedisPlugin).forEach(function (key) {
|
|
129
|
-
if (key === "default" || key === "__esModule") return;
|
|
130
|
-
if (key in exports && exports[key] === _RedisPlugin[key]) return;
|
|
131
|
-
Object.defineProperty(exports, key, {
|
|
132
|
-
enumerable: true,
|
|
133
|
-
get: function () {
|
|
134
|
-
return _RedisPlugin[key];
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
var _ServeoPlugin = require("./ServeoPlugin");
|
|
139
|
-
Object.keys(_ServeoPlugin).forEach(function (key) {
|
|
140
|
-
if (key === "default" || key === "__esModule") return;
|
|
141
|
-
if (key in exports && exports[key] === _ServeoPlugin[key]) return;
|
|
142
|
-
Object.defineProperty(exports, key, {
|
|
143
|
-
enumerable: true,
|
|
144
|
-
get: function () {
|
|
145
|
-
return _ServeoPlugin[key];
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
var _TestPlugin = require("./TestPlugin");
|
|
150
|
-
Object.keys(_TestPlugin).forEach(function (key) {
|
|
151
|
-
if (key === "default" || key === "__esModule") return;
|
|
152
|
-
if (key in exports && exports[key] === _TestPlugin[key]) return;
|
|
153
|
-
Object.defineProperty(exports, key, {
|
|
154
|
-
enumerable: true,
|
|
155
|
-
get: function () {
|
|
156
|
-
return _TestPlugin[key];
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
});
|
|
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,3 +1,4 @@
|
|
|
1
|
+
import { Config, EnvConfig } from "../types";
|
|
1
2
|
type TypeMap = {
|
|
2
3
|
[type: string]: string;
|
|
3
4
|
};
|
|
@@ -5,14 +6,23 @@ declare class AppConfigService {
|
|
|
5
6
|
protected pwd: string;
|
|
6
7
|
protected mapTypes: TypeMap;
|
|
7
8
|
constructor();
|
|
9
|
+
dataPath(...args: string[]): string;
|
|
10
|
+
pluginsPath(...args: string[]): string;
|
|
8
11
|
getPWD(): string;
|
|
9
12
|
setPWD(pwd: string): void;
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
getAppConfig(): Promise<Config>;
|
|
14
|
+
private saveAppConfig;
|
|
15
|
+
getMeta(name: string, defaultValue?: string): Promise<string>;
|
|
16
|
+
setMeta(name: string, value?: string | number): Promise<void>;
|
|
17
|
+
getAllEnvVariables(): Promise<EnvConfig>;
|
|
18
|
+
getEnvVariable(name: string, defaultValue?: string): Promise<string>;
|
|
12
19
|
setEnv(env: any): Promise<void>;
|
|
13
20
|
setEnvVariable(name: string, value: string | number): Promise<void>;
|
|
14
21
|
unsetEnv(...keys: string[]): Promise<void>;
|
|
15
|
-
registerProjectType(name: string, title?: string): void;
|
|
16
22
|
getProjectTypes(): TypeMap;
|
|
23
|
+
registerProjectType(name: string, title?: string): void;
|
|
24
|
+
setProjectConfig(id: string, path: string): Promise<void>;
|
|
25
|
+
activatePlugin(name: string): Promise<void>;
|
|
26
|
+
deactivatePlugin(name: string): Promise<void>;
|
|
17
27
|
}
|
|
18
28
|
export { AppConfigService };
|
|
@@ -1,77 +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
|
-
|
|
27
|
+
const Path = __importStar(require("path"));
|
|
28
|
+
const env_1 = require("../env");
|
|
29
|
+
const makes_1 = require("../makes");
|
|
9
30
|
class AppConfigService {
|
|
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
|
-
|
|
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");
|
|
65
142
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
+
}
|
|
76
166
|
}
|
|
77
|
-
exports.AppConfigService = AppConfigService;
|
|
167
|
+
exports.AppConfigService = AppConfigService;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
type EventHandle = (...args: any[]) => Promise<void> | void;
|
|
4
|
-
declare class AppEventsService {
|
|
5
|
-
protected emitter: EventEmitter;
|
|
1
|
+
import { AppEventsService as CoreAppEventsService, AppEventHandle } from "@wocker/core";
|
|
2
|
+
declare class AppEventsService extends CoreAppEventsService {
|
|
6
3
|
protected handles: ({
|
|
7
|
-
[event: string]:
|
|
4
|
+
[event: string]: AppEventHandle[];
|
|
8
5
|
});
|
|
9
|
-
on(event: string, handle:
|
|
10
|
-
off(event: string, handle:
|
|
6
|
+
on(event: string, handle: AppEventHandle): () => void;
|
|
7
|
+
off(event: string, handle: AppEventHandle): void;
|
|
11
8
|
emit(event: string, ...args: any[]): Promise<void>;
|
|
12
9
|
}
|
|
13
10
|
export { AppEventsService };
|