@wocker/ws 1.0.20 → 1.0.22
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 +8 -0
- package/lib/AppModule.js +17 -39
- package/lib/controllers/DebugController.d.ts +2 -1
- package/lib/controllers/DebugController.js +13 -5
- package/lib/controllers/KeystoreController.d.ts +11 -0
- package/lib/controllers/KeystoreController.js +106 -0
- package/lib/controllers/PluginController.d.ts +3 -5
- package/lib/controllers/PluginController.js +11 -57
- package/lib/controllers/PresetController.d.ts +5 -3
- package/lib/controllers/PresetController.js +73 -55
- package/lib/controllers/ProjectController.d.ts +5 -3
- package/lib/controllers/ProjectController.js +71 -46
- package/lib/controllers/ProxyController.d.ts +1 -1
- package/lib/controllers/ProxyController.js +56 -14
- package/lib/controllers/index.d.ts +1 -1
- package/lib/controllers/index.js +1 -1
- package/lib/env.d.ts +2 -1
- package/lib/env.js +20 -9
- package/lib/keystore/KeystoreService.d.ts +12 -0
- package/lib/keystore/KeystoreService.js +70 -0
- package/lib/keystore/index.d.ts +1 -0
- package/lib/keystore/index.js +17 -0
- package/lib/keystore/providers/FileKeystoreProvider.d.ts +16 -0
- package/lib/keystore/providers/FileKeystoreProvider.js +97 -0
- package/lib/keystore/providers/KeytarKeystoreProvider.d.ts +9 -0
- package/lib/keystore/providers/KeytarKeystoreProvider.js +74 -0
- package/lib/keystore/types/Encryption.d.ts +9 -0
- package/lib/keystore/types/Encryption.js +81 -0
- package/lib/keystore/types/Encryptor.d.ts +10 -0
- package/lib/keystore/types/Encryptor.js +59 -0
- package/lib/keystore/types/FileKeystore.d.ts +17 -0
- package/lib/keystore/types/FileKeystore.js +33 -0
- package/lib/keystore/types/Keytar.d.ts +8 -0
- package/lib/keystore/types/Keytar.js +2 -0
- package/lib/keystore/utils/createEncryptionKey.d.ts +1 -0
- package/lib/keystore/utils/createEncryptionKey.js +46 -0
- package/lib/keystore/utils/createPasswordHash.d.ts +1 -0
- package/lib/keystore/utils/createPasswordHash.js +20 -0
- package/lib/keystore/utils/decrypt.d.ts +1 -0
- package/lib/keystore/utils/decrypt.js +15 -0
- package/lib/keystore/utils/encrypt.d.ts +1 -0
- package/lib/keystore/utils/encrypt.js +19 -0
- package/lib/keystore/utils/index.d.ts +5 -0
- package/lib/keystore/utils/index.js +21 -0
- package/lib/keystore/utils/verifyPasswordHash.d.ts +1 -0
- package/lib/keystore/utils/verifyPasswordHash.js +9 -0
- package/lib/main.js +10 -5
- package/lib/makes/FS.d.ts +2 -2
- package/lib/makes/FS.js +19 -9
- package/lib/makes/GithubClient.d.ts +14 -0
- package/lib/makes/GithubClient.js +65 -0
- package/lib/makes/Http.js +17 -7
- package/lib/makes/Plugin.d.ts +6 -0
- package/lib/makes/Plugin.js +16 -0
- package/lib/makes/index.d.ts +1 -0
- package/lib/makes/index.js +1 -0
- package/lib/plugins/MongodbPlugin.js +17 -7
- package/lib/plugins/index.d.ts +0 -2
- package/lib/plugins/index.js +0 -2
- package/lib/repositories/PresetRepository.d.ts +23 -0
- package/lib/repositories/PresetRepository.js +115 -0
- package/lib/repositories/index.d.ts +1 -0
- package/lib/repositories/index.js +17 -0
- package/lib/services/AppConfigService.d.ts +16 -1
- package/lib/services/AppConfigService.js +88 -62
- package/lib/services/AppEventsService.d.ts +4 -4
- package/lib/services/AppEventsService.js +14 -10
- package/lib/services/CertService.js +18 -8
- package/lib/services/DockerService.d.ts +2 -2
- package/lib/services/DockerService.js +14 -8
- package/lib/services/LogService.d.ts +4 -1
- package/lib/services/LogService.js +14 -8
- package/lib/services/PluginService.d.ts +8 -2
- package/lib/services/PluginService.js +88 -23
- package/lib/services/PresetService.d.ts +9 -8
- package/lib/services/PresetService.js +144 -248
- package/lib/services/ProjectService.d.ts +5 -2
- package/lib/services/ProjectService.js +37 -10
- package/lib/services/ProxyService.d.ts +3 -2
- package/lib/services/ProxyService.js +43 -25
- package/lib/utils/index.d.ts +0 -2
- package/lib/utils/index.js +0 -2
- package/package.json +30 -15
- package/plugins/proxy/Dockerfile +17 -1
- package/plugins/proxy/Procfile +2 -0
- package/lib/controllers/ImageController.d.ts +0 -7
- package/lib/controllers/ImageController.js +0 -46
- package/lib/makes/Model.d.ts +0 -5
- package/lib/makes/Model.js +0 -12
- package/lib/plugins/ElasticSearchPlugin.d.ts +0 -15
- package/lib/plugins/ElasticSearchPlugin.js +0 -72
- package/lib/plugins/ProxmoxPlugin.d.ts +0 -12
- package/lib/plugins/ProxmoxPlugin.js +0 -83
- package/lib/utils/volumeFormat.d.ts +0 -6
- package/lib/utils/volumeFormat.js +0 -8
- package/lib/utils/volumeParse.d.ts +0 -2
- package/lib/utils/volumeParse.js +0 -13
- package/plugins/proxy/config.json +0 -3
- package/presets/bun/Dockerfile +0 -11
- package/presets/bun/config.json +0 -4
|
@@ -0,0 +1,115 @@
|
|
|
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.PresetRepository = void 0;
|
|
13
|
+
const core_1 = require("@wocker/core");
|
|
14
|
+
const AppConfigService_1 = require("../services/AppConfigService");
|
|
15
|
+
const LogService_1 = require("../services/LogService");
|
|
16
|
+
const env_1 = require("../env");
|
|
17
|
+
let PresetRepository = class PresetRepository {
|
|
18
|
+
constructor(appConfig, logService) {
|
|
19
|
+
this.appConfig = appConfig;
|
|
20
|
+
this.logService = logService;
|
|
21
|
+
}
|
|
22
|
+
load(data) {
|
|
23
|
+
const _this = this, fs = new core_1.FileSystem(data.path);
|
|
24
|
+
const config = {
|
|
25
|
+
...fs.readJSON("config.json"),
|
|
26
|
+
name: data.name,
|
|
27
|
+
source: data.source,
|
|
28
|
+
path: data.path
|
|
29
|
+
};
|
|
30
|
+
return new class extends core_1.Preset {
|
|
31
|
+
constructor(data) {
|
|
32
|
+
super(data);
|
|
33
|
+
}
|
|
34
|
+
save() {
|
|
35
|
+
switch (this.source) {
|
|
36
|
+
case core_1.PRESET_SOURCE_EXTERNAL:
|
|
37
|
+
fs.writeJSON("config.json", this.toObject());
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
_this.appConfig.registerPreset(this.name, this.source, data.path);
|
|
41
|
+
}
|
|
42
|
+
delete() {
|
|
43
|
+
switch (this.source) {
|
|
44
|
+
case core_1.PRESET_SOURCE_GITHUB:
|
|
45
|
+
if (fs.exists()) {
|
|
46
|
+
fs.rm("", {
|
|
47
|
+
recursive: true
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
_this.appConfig.unregisterPreset(this.name);
|
|
53
|
+
}
|
|
54
|
+
}(config);
|
|
55
|
+
}
|
|
56
|
+
configs() {
|
|
57
|
+
const fs = new core_1.FileSystem(env_1.PRESETS_DIR), dirs = fs.exists("") ? fs.readdir("") : [];
|
|
58
|
+
const { presets = [] } = this.appConfig.config;
|
|
59
|
+
return [
|
|
60
|
+
...dirs.map((name) => {
|
|
61
|
+
return {
|
|
62
|
+
name,
|
|
63
|
+
source: core_1.PRESET_SOURCE_INTERNAL,
|
|
64
|
+
path: fs.path(name)
|
|
65
|
+
};
|
|
66
|
+
}),
|
|
67
|
+
...presets.map((item) => {
|
|
68
|
+
if (item.source === core_1.PRESET_SOURCE_GITHUB) {
|
|
69
|
+
return {
|
|
70
|
+
...item,
|
|
71
|
+
path: this.appConfig.fs.path("presets", item.name)
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return item;
|
|
75
|
+
})
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
search(options = {}) {
|
|
79
|
+
const { name, source, path } = options;
|
|
80
|
+
const presets = [], configs = this.configs();
|
|
81
|
+
for (const config of configs) {
|
|
82
|
+
if (name && name !== config.name) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (source && source !== config.source) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (path && path !== config.path) {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
const preset = this.load(config);
|
|
93
|
+
presets.push(preset);
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
this.logService.error(err.message, {
|
|
97
|
+
name: config.name,
|
|
98
|
+
source: config.source,
|
|
99
|
+
path: config.path
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return presets;
|
|
104
|
+
}
|
|
105
|
+
searchOne(options = {}) {
|
|
106
|
+
const [preset] = this.search(options);
|
|
107
|
+
return preset || null;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
exports.PresetRepository = PresetRepository;
|
|
111
|
+
exports.PresetRepository = PresetRepository = __decorate([
|
|
112
|
+
(0, core_1.Injectable)(),
|
|
113
|
+
__metadata("design:paramtypes", [AppConfigService_1.AppConfigService,
|
|
114
|
+
LogService_1.LogService])
|
|
115
|
+
], PresetRepository);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./PresetRepository";
|
|
@@ -0,0 +1,17 @@
|
|
|
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 __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("./PresetRepository"), exports);
|
|
@@ -5,9 +5,17 @@ type TypeMap = {
|
|
|
5
5
|
export declare class AppConfigService extends CoreAppConfigService {
|
|
6
6
|
protected _pwd: string;
|
|
7
7
|
protected _fs?: FileSystem;
|
|
8
|
+
protected _config?: AppConfig;
|
|
8
9
|
protected readonly mapTypes: TypeMap;
|
|
9
10
|
constructor();
|
|
10
11
|
get version(): string;
|
|
12
|
+
get config(): AppConfig;
|
|
13
|
+
get projects(): {
|
|
14
|
+
id: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
path?: string;
|
|
17
|
+
src?: string;
|
|
18
|
+
}[];
|
|
11
19
|
get fs(): FileSystem;
|
|
12
20
|
pwd(...parts: string[]): string;
|
|
13
21
|
setPWD(pwd: string): void;
|
|
@@ -15,6 +23,13 @@ export declare class AppConfigService extends CoreAppConfigService {
|
|
|
15
23
|
pluginsPath(...parts: string[]): string;
|
|
16
24
|
presetPath(...parts: string[]): string;
|
|
17
25
|
getProjectTypes(): TypeMap;
|
|
18
|
-
|
|
26
|
+
addProject(id: string, name: string, path: string): void;
|
|
27
|
+
removeProject(id: string): {
|
|
28
|
+
id: string;
|
|
29
|
+
name?: string;
|
|
30
|
+
path?: string;
|
|
31
|
+
src?: string;
|
|
32
|
+
};
|
|
33
|
+
save(): void;
|
|
19
34
|
}
|
|
20
35
|
export {};
|
|
@@ -21,13 +21,23 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
21
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
22
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
23
|
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
31
41
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
42
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
43
|
};
|
|
@@ -49,6 +59,69 @@ let AppConfigService = class AppConfigService extends core_1.AppConfigService {
|
|
|
49
59
|
get version() {
|
|
50
60
|
return env_1.WOCKER_VERSION;
|
|
51
61
|
}
|
|
62
|
+
get config() {
|
|
63
|
+
if (!this._config) {
|
|
64
|
+
const fs = this.fs;
|
|
65
|
+
let data = {};
|
|
66
|
+
if (fs.exists("wocker.config.js")) {
|
|
67
|
+
try {
|
|
68
|
+
const { config } = require(fs.path("wocker.config.js"));
|
|
69
|
+
data = config;
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
if (fs.exists("wocker.config.json")) {
|
|
73
|
+
let json = fs.readJSON("wocker.config.json");
|
|
74
|
+
if (typeof json === "string") {
|
|
75
|
+
json = JSON.parse(json);
|
|
76
|
+
}
|
|
77
|
+
data = json;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else if (fs.exists("wocker.config.json")) {
|
|
82
|
+
data = fs.readJSON("wocker.config.json");
|
|
83
|
+
}
|
|
84
|
+
else if (fs.exists("wocker.json")) {
|
|
85
|
+
let json = fs.readJSON("wocker.json");
|
|
86
|
+
if (typeof json === "string") {
|
|
87
|
+
json = JSON.parse(json);
|
|
88
|
+
}
|
|
89
|
+
data = json;
|
|
90
|
+
}
|
|
91
|
+
else if (fs.exists("data.json")) {
|
|
92
|
+
data = fs.readJSON("data.json");
|
|
93
|
+
}
|
|
94
|
+
else if (!fs.exists()) {
|
|
95
|
+
fs.mkdir("", {
|
|
96
|
+
recursive: true
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
this._config = new class extends core_1.AppConfig {
|
|
100
|
+
constructor(data) {
|
|
101
|
+
super(data);
|
|
102
|
+
}
|
|
103
|
+
async save() {
|
|
104
|
+
if (!fs.exists()) {
|
|
105
|
+
fs.mkdir("", {
|
|
106
|
+
recursive: true
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
fs.writeFile("wocker.config.js", this.toJsString());
|
|
110
|
+
fs.writeFile("wocker.config.json", this.toString());
|
|
111
|
+
if (fs.exists("data.json")) {
|
|
112
|
+
fs.rm("data.json");
|
|
113
|
+
}
|
|
114
|
+
if (fs.exists("wocker.json")) {
|
|
115
|
+
fs.rm("wocker.json");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}(data);
|
|
119
|
+
}
|
|
120
|
+
return this._config;
|
|
121
|
+
}
|
|
122
|
+
get projects() {
|
|
123
|
+
return this.config.projects;
|
|
124
|
+
}
|
|
52
125
|
get fs() {
|
|
53
126
|
if (!this._fs) {
|
|
54
127
|
this._fs = new core_1.FileSystem(env_1.DATA_DIR);
|
|
@@ -73,61 +146,14 @@ let AppConfigService = class AppConfigService extends core_1.AppConfigService {
|
|
|
73
146
|
getProjectTypes() {
|
|
74
147
|
return this.mapTypes;
|
|
75
148
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
catch (err) {
|
|
85
|
-
if (fs.exists("wocker.config.json")) {
|
|
86
|
-
let json = fs.readJSON("wocker.config.json");
|
|
87
|
-
if (typeof json === "string") {
|
|
88
|
-
json = JSON.parse(json);
|
|
89
|
-
}
|
|
90
|
-
data = json;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
else if (fs.exists("wocker.config.json")) {
|
|
95
|
-
data = fs.readJSON("wocker.config.json");
|
|
96
|
-
}
|
|
97
|
-
else if (fs.exists("wocker.json")) {
|
|
98
|
-
let json = fs.readJSON("wocker.json");
|
|
99
|
-
if (typeof json === "string") {
|
|
100
|
-
json = JSON.parse(json);
|
|
101
|
-
}
|
|
102
|
-
data = json;
|
|
103
|
-
}
|
|
104
|
-
else if (fs.exists("data.json")) {
|
|
105
|
-
data = fs.readJSON("data.json");
|
|
106
|
-
}
|
|
107
|
-
else if (!fs.exists()) {
|
|
108
|
-
fs.mkdir("", {
|
|
109
|
-
recursive: true
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
return new class extends core_1.AppConfig {
|
|
113
|
-
constructor(data) {
|
|
114
|
-
super(data);
|
|
115
|
-
}
|
|
116
|
-
async save() {
|
|
117
|
-
if (!fs.exists()) {
|
|
118
|
-
fs.mkdir("");
|
|
119
|
-
}
|
|
120
|
-
const json = JSON.stringify(this.toJson(), null, 4);
|
|
121
|
-
await fs.writeFile("wocker.config.js", `// Wocker config\nexports.config = ${json};`);
|
|
122
|
-
await fs.writeFile("wocker.config.json", json);
|
|
123
|
-
if (fs.exists("data.json")) {
|
|
124
|
-
await fs.rm("data.json");
|
|
125
|
-
}
|
|
126
|
-
if (fs.exists("wocker.json")) {
|
|
127
|
-
await fs.rm("wocker.json");
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}(data);
|
|
149
|
+
addProject(id, name, path) {
|
|
150
|
+
this.config.addProject(id, name, path);
|
|
151
|
+
}
|
|
152
|
+
removeProject(id) {
|
|
153
|
+
return this.config.getProject(id);
|
|
154
|
+
}
|
|
155
|
+
save() {
|
|
156
|
+
this.config.save();
|
|
131
157
|
}
|
|
132
158
|
};
|
|
133
159
|
exports.AppConfigService = AppConfigService;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AppEventsService as CoreAppEventsService, AppEventHandle } from "@wocker/core";
|
|
2
2
|
export declare class AppEventsService extends CoreAppEventsService {
|
|
3
|
-
protected handles:
|
|
4
|
-
[event: string]: AppEventHandle
|
|
5
|
-
}
|
|
6
|
-
on(event: string, handle: AppEventHandle): () => void;
|
|
3
|
+
protected handles: {
|
|
4
|
+
[event: string]: Set<AppEventHandle>;
|
|
5
|
+
};
|
|
6
|
+
on(event: string, handle: AppEventHandle): (() => void);
|
|
7
7
|
off(event: string, handle: AppEventHandle): void;
|
|
8
8
|
emit(event: string, ...args: any[]): Promise<void>;
|
|
9
9
|
}
|
|
@@ -14,22 +14,26 @@ let AppEventsService = class AppEventsService extends core_1.AppEventsService {
|
|
|
14
14
|
this.handles = {};
|
|
15
15
|
}
|
|
16
16
|
on(event, handle) {
|
|
17
|
-
this.handles[event]
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
];
|
|
17
|
+
if (!this.handles[event]) {
|
|
18
|
+
this.handles[event] = new Set();
|
|
19
|
+
}
|
|
20
|
+
this.handles[event].add(handle);
|
|
21
21
|
return () => {
|
|
22
|
-
this.
|
|
23
|
-
return filterHandle !== handle;
|
|
24
|
-
});
|
|
22
|
+
this.off(event, handle);
|
|
25
23
|
};
|
|
26
24
|
}
|
|
27
25
|
off(event, handle) {
|
|
26
|
+
if (!this.handles[event]) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
this.handles[event].delete(handle);
|
|
28
30
|
}
|
|
29
31
|
async emit(event, ...args) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
if (!this.handles[event]) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
for (const handle of this.handles[event].values()) {
|
|
36
|
+
await handle(...args);
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
};
|
|
@@ -21,13 +21,23 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
21
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
22
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
23
|
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
31
41
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
42
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
43
|
};
|
|
@@ -84,7 +94,7 @@ let CertService = class CertService {
|
|
|
84
94
|
});
|
|
85
95
|
}
|
|
86
96
|
async getCertsMap() {
|
|
87
|
-
const files =
|
|
97
|
+
const files = this.appConfigService.fs.readdir("certs/projects");
|
|
88
98
|
return files.reduce((res, file) => {
|
|
89
99
|
const ext = Path.extname(file);
|
|
90
100
|
const name = Path.basename(file, ext);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DockerServiceParams as Params } from "@wocker/core";
|
|
1
|
+
import { DockerService as CoreDockerService, DockerServiceParams as Params } from "@wocker/core";
|
|
2
2
|
import Docker, { Container, Volume, VolumeCreateResponse } from "dockerode";
|
|
3
3
|
import { LogService } from "./LogService";
|
|
4
|
-
export declare class DockerService {
|
|
4
|
+
export declare class DockerService extends CoreDockerService {
|
|
5
5
|
protected readonly logService: LogService;
|
|
6
6
|
protected docker: Docker;
|
|
7
7
|
constructor(logService: LogService);
|
|
@@ -18,8 +18,9 @@ const dockerode_1 = __importDefault(require("dockerode"));
|
|
|
18
18
|
const utils_1 = require("../utils");
|
|
19
19
|
const makes_1 = require("../makes");
|
|
20
20
|
const LogService_1 = require("./LogService");
|
|
21
|
-
let DockerService = class DockerService {
|
|
21
|
+
let DockerService = class DockerService extends core_1.DockerService {
|
|
22
22
|
constructor(logService) {
|
|
23
|
+
super();
|
|
23
24
|
this.logService = logService;
|
|
24
25
|
this.docker = new dockerode_1.default({
|
|
25
26
|
socketPath: "/var/run/docker.sock"
|
|
@@ -49,15 +50,15 @@ let DockerService = class DockerService {
|
|
|
49
50
|
await volume.remove();
|
|
50
51
|
}
|
|
51
52
|
async createContainer(params) {
|
|
52
|
-
const { name, user, entrypoint, tty, image, projectId, restart, ulimits, extraHosts, networkMode = "bridge", links = [], env = {}, volumes = [], ports = [], cmd = [] } = params;
|
|
53
|
-
const network = this.docker.getNetwork(
|
|
53
|
+
const { name, user, entrypoint, tty, image, projectId, restart, memory, memorySwap, ulimits, extraHosts, networkMode = "bridge", links = [], env = {}, volumes = [], ports = [], cmd = [], network: networkName = "workspace", aliases } = params;
|
|
54
|
+
const network = this.docker.getNetwork(networkName);
|
|
54
55
|
try {
|
|
55
56
|
await network.inspect();
|
|
56
57
|
}
|
|
57
58
|
catch (err) {
|
|
58
59
|
if (err.statusCode === 404) {
|
|
59
60
|
await this.docker.createNetwork({
|
|
60
|
-
Name:
|
|
61
|
+
Name: networkName
|
|
61
62
|
});
|
|
62
63
|
}
|
|
63
64
|
}
|
|
@@ -91,6 +92,8 @@ let DockerService = class DockerService {
|
|
|
91
92
|
return res;
|
|
92
93
|
}, {}),
|
|
93
94
|
HostConfig: {
|
|
95
|
+
Memory: memory,
|
|
96
|
+
MemorySwap: memorySwap,
|
|
94
97
|
NetworkMode: networkMode,
|
|
95
98
|
ExtraHosts: extraHosts,
|
|
96
99
|
Ulimits: ulimits ? Object.keys(ulimits).reduce((res, name) => {
|
|
@@ -126,7 +129,7 @@ let DockerService = class DockerService {
|
|
|
126
129
|
EndpointsConfig: networkMode === "host" ? {} : {
|
|
127
130
|
workspace: {
|
|
128
131
|
Links: links,
|
|
129
|
-
Aliases: env.VIRTUAL_HOST ? env.VIRTUAL_HOST.split(",") : undefined
|
|
132
|
+
Aliases: aliases || (env.VIRTUAL_HOST ? env.VIRTUAL_HOST.split(",") : undefined)
|
|
130
133
|
}
|
|
131
134
|
}
|
|
132
135
|
}
|
|
@@ -180,9 +183,12 @@ let DockerService = class DockerService {
|
|
|
180
183
|
t: tag,
|
|
181
184
|
labels,
|
|
182
185
|
buildargs: Object.keys(buildArgs).reduce((res, key) => {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
+
const value = buildArgs[key];
|
|
187
|
+
if (typeof value !== "undefined") {
|
|
188
|
+
res[key] = typeof buildArgs[key] !== "string"
|
|
189
|
+
? buildArgs[key].toString()
|
|
190
|
+
: buildArgs[key];
|
|
191
|
+
}
|
|
186
192
|
return res;
|
|
187
193
|
}, {}),
|
|
188
194
|
dockerfile: src
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { LogService as CoreLogService } from "@wocker/core";
|
|
1
|
+
import { FileSystem, LogService as CoreLogService } from "@wocker/core";
|
|
2
2
|
import { AppConfigService } from "./AppConfigService";
|
|
3
3
|
export declare class LogService extends CoreLogService {
|
|
4
4
|
protected readonly appConfigService: AppConfigService;
|
|
5
5
|
constructor(appConfigService: AppConfigService);
|
|
6
|
+
protected get fs(): FileSystem;
|
|
7
|
+
protected get logName(): string;
|
|
6
8
|
debug(...data: any[]): void;
|
|
7
9
|
log(...data: any[]): void;
|
|
8
10
|
info(...data: any[]): void;
|
|
9
11
|
warn(...data: any[]): void;
|
|
10
12
|
error(...data: any[]): void;
|
|
13
|
+
clear(): void;
|
|
11
14
|
protected _log(type: string, ...data: any[]): void;
|
|
12
15
|
}
|
|
@@ -23,6 +23,12 @@ let LogService = class LogService extends core_1.LogService {
|
|
|
23
23
|
this.appConfigService = appConfigService;
|
|
24
24
|
makes_1.Logger.install(this);
|
|
25
25
|
}
|
|
26
|
+
get fs() {
|
|
27
|
+
return this.appConfigService.fs;
|
|
28
|
+
}
|
|
29
|
+
get logName() {
|
|
30
|
+
return "ws.log";
|
|
31
|
+
}
|
|
26
32
|
debug(...data) {
|
|
27
33
|
this._log("debug", ...data);
|
|
28
34
|
}
|
|
@@ -38,20 +44,20 @@ let LogService = class LogService extends core_1.LogService {
|
|
|
38
44
|
error(...data) {
|
|
39
45
|
this._log("error", ...data);
|
|
40
46
|
}
|
|
47
|
+
clear() {
|
|
48
|
+
this.fs.writeFile(this.logName, "");
|
|
49
|
+
}
|
|
41
50
|
_log(type, ...data) {
|
|
42
|
-
|
|
43
|
-
if (type === "debug" && !config.debug) {
|
|
51
|
+
if (type === "debug" && !this.appConfigService.config.debug) {
|
|
44
52
|
return;
|
|
45
53
|
}
|
|
46
|
-
const time = (0, format_1.default)(new Date(), "yyyy-MM-dd
|
|
47
|
-
const logPath = this.appConfigService.dataPath("ws.log");
|
|
48
|
-
const logData = data.map((item) => {
|
|
54
|
+
const time = (0, format_1.default)(new Date(), "yyyy-MM-dd HH:mm:ss"), logData = data.map((item) => {
|
|
49
55
|
return typeof item !== "string" ? JSON.stringify(item) : item;
|
|
50
56
|
}).join(" ");
|
|
51
|
-
if (!
|
|
52
|
-
|
|
57
|
+
if (!this.fs.exists(this.logName)) {
|
|
58
|
+
this.fs.writeFile(this.logName, "");
|
|
53
59
|
}
|
|
54
|
-
|
|
60
|
+
this.fs.appendFile(this.logName, `[${time}] ${type}: ${logData}\n`);
|
|
55
61
|
}
|
|
56
62
|
};
|
|
57
63
|
exports.LogService = LogService;
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { Cli } from "@wocker/core";
|
|
2
2
|
import { AppConfigService } from "./AppConfigService";
|
|
3
3
|
import { LogService } from "./LogService";
|
|
4
|
+
import { NpmService } from "./NpmService";
|
|
5
|
+
import { Plugin } from "../makes";
|
|
4
6
|
export declare class PluginService {
|
|
5
7
|
protected readonly appConfigService: AppConfigService;
|
|
8
|
+
protected readonly npmService: NpmService;
|
|
6
9
|
protected readonly logService: LogService;
|
|
7
10
|
protected readonly cli: Cli;
|
|
8
|
-
constructor(appConfigService: AppConfigService, logService: LogService, cli: Cli);
|
|
11
|
+
constructor(appConfigService: AppConfigService, npmService: NpmService, logService: LogService, cli: Cli);
|
|
12
|
+
getPluginsTable(): string;
|
|
9
13
|
checkPlugin(pluginName: string): Promise<boolean>;
|
|
10
|
-
|
|
14
|
+
install(pluginName: string, beta?: boolean): Promise<void>;
|
|
15
|
+
uninstall(pluginName: string): Promise<void>;
|
|
16
|
+
import(name: string): Promise<Plugin>;
|
|
11
17
|
update(): Promise<void>;
|
|
12
18
|
protected getCurrentVersion(name: string): Promise<string | null>;
|
|
13
19
|
}
|