@wocker/ws 1.0.21 → 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 -53
- 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 +4 -2
- package/lib/controllers/PresetController.js +50 -44
- package/lib/controllers/ProjectController.d.ts +1 -0
- package/lib/controllers/ProjectController.js +45 -36
- package/lib/controllers/ProxyController.js +37 -31
- 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 +3 -2
- 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 +1 -1
- package/lib/makes/GithubClient.d.ts +14 -0
- package/lib/makes/GithubClient.js +65 -0
- 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/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 +71 -55
- package/lib/services/AppEventsService.d.ts +4 -4
- package/lib/services/AppEventsService.js +14 -10
- package/lib/services/CertService.js +2 -2
- package/lib/services/DockerService.js +6 -3
- package/lib/services/LogService.d.ts +3 -1
- package/lib/services/LogService.js +12 -10
- package/lib/services/PluginService.d.ts +8 -2
- package/lib/services/PluginService.js +71 -16
- package/lib/services/PresetService.d.ts +9 -8
- package/lib/services/PresetService.js +144 -258
- package/lib/services/ProjectService.d.ts +5 -2
- package/lib/services/ProjectService.js +37 -10
- package/lib/services/ProxyService.js +6 -6
- package/lib/utils/index.d.ts +0 -2
- package/lib/utils/index.js +0 -2
- package/package.json +23 -13
- 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/elastic-search/controllers/ElasticSearchController.d.ts +0 -10
- package/lib/plugins/elastic-search/controllers/ElasticSearchController.js +0 -91
- package/lib/plugins/elastic-search/index.d.ts +0 -2
- package/lib/plugins/elastic-search/index.js +0 -22
- package/lib/plugins/proxmox/controllers/ProxmoxController.d.ts +0 -14
- package/lib/plugins/proxmox/controllers/ProxmoxController.js +0 -127
- package/lib/plugins/proxmox/index.d.ts +0 -2
- package/lib/plugins/proxmox/index.js +0 -23
- 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/presets/bun/Dockerfile +0 -11
- package/presets/bun/config.json +0 -4
|
@@ -0,0 +1,21 @@
|
|
|
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("./createEncryptionKey"), exports);
|
|
18
|
+
__exportStar(require("./createPasswordHash"), exports);
|
|
19
|
+
__exportStar(require("./decrypt"), exports);
|
|
20
|
+
__exportStar(require("./encrypt"), exports);
|
|
21
|
+
__exportStar(require("./verifyPasswordHash"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const verifyPasswordHash: (password: string, passwordHash: string) => boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyPasswordHash = void 0;
|
|
4
|
+
const createPasswordHash_1 = require("./createPasswordHash");
|
|
5
|
+
const verifyPasswordHash = (password, passwordHash) => {
|
|
6
|
+
const [, salt = ""] = (passwordHash || "").split(":");
|
|
7
|
+
return passwordHash === (0, createPasswordHash_1.createPasswordHash)(password, salt);
|
|
8
|
+
};
|
|
9
|
+
exports.verifyPasswordHash = verifyPasswordHash;
|
package/lib/main.js
CHANGED
|
@@ -5,13 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.app = void 0;
|
|
7
7
|
const core_1 = require("@wocker/core");
|
|
8
|
-
const
|
|
8
|
+
const yoctocolors_cjs_1 = __importDefault(require("yoctocolors-cjs"));
|
|
9
9
|
const AppModule_1 = require("./AppModule");
|
|
10
10
|
const services_1 = require("./services");
|
|
11
11
|
exports.app = {
|
|
12
12
|
async run(args) {
|
|
13
13
|
const app = await core_1.Factory.create(AppModule_1.AppModule);
|
|
14
|
-
const
|
|
14
|
+
const configService = app.get(services_1.AppConfigService);
|
|
15
15
|
const logger = app.get(services_1.LogService);
|
|
16
16
|
try {
|
|
17
17
|
const res = await app.run(args);
|
|
@@ -21,9 +21,14 @@ exports.app = {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
catch (err) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
if (typeof err.name === "string" && ["ExitPromptError", "CancelPromptError", "AbortPromptError"].includes(err.name)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
console.error(yoctocolors_cjs_1.default.red(err.message));
|
|
28
|
+
if (err instanceof core_1.CommandNotFoundError) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (configService.config.debug) {
|
|
27
32
|
logger.error(err.stack || err.toString());
|
|
28
33
|
}
|
|
29
34
|
}
|
package/lib/makes/FS.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare class FS extends CoreFS {
|
|
|
14
14
|
static appendFile(path: PathOrFileDescriptor, data: any, options?: WriteFileOptions): Promise<void>;
|
|
15
15
|
static appendFileSync(path: PathOrFileDescriptor, data: any, options?: WriteFileOptions): void;
|
|
16
16
|
static readBytes(filePath: PathLike, position?: number | bigint, size?: number | bigint): Promise<Buffer>;
|
|
17
|
-
static readFileSync(filePath: PathLike):
|
|
17
|
+
static readFileSync(filePath: PathLike): NonSharedBuffer;
|
|
18
18
|
static writeFileSync(path: PathLike, data: any, options?: WriteFileOptions): void;
|
|
19
19
|
static createWriteStream(path: PathLike): fs.WriteStream;
|
|
20
20
|
static unlink(filePath: PathLike): Promise<void>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
type RepositoryInfo = {
|
|
3
|
+
default_branch: string;
|
|
4
|
+
};
|
|
5
|
+
export declare class GithubClient {
|
|
6
|
+
owner: string;
|
|
7
|
+
repository: string;
|
|
8
|
+
constructor(owner: string, repository: string);
|
|
9
|
+
get axios(): AxiosInstance;
|
|
10
|
+
getInfo(): Promise<RepositoryInfo>;
|
|
11
|
+
getFile(branch: string, path: string): Promise<any>;
|
|
12
|
+
download(branch: string, dirPath: string): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.GithubClient = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const core_1 = require("@wocker/core");
|
|
9
|
+
class GithubClient {
|
|
10
|
+
constructor(owner, repository) {
|
|
11
|
+
this.owner = owner;
|
|
12
|
+
this.repository = repository;
|
|
13
|
+
}
|
|
14
|
+
get axios() {
|
|
15
|
+
return axios_1.default.create({
|
|
16
|
+
headers: {
|
|
17
|
+
"User-Agent": "Wocker"
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
async getInfo() {
|
|
22
|
+
const response = await this.axios.get(`https://api.github.com/repos/${this.owner}/${this.repository}`, {
|
|
23
|
+
headers: {
|
|
24
|
+
"Accept": "application/vnd.github+json"
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return response.data;
|
|
28
|
+
}
|
|
29
|
+
async getFile(branch, path) {
|
|
30
|
+
const response = await this.axios.get(`https://raw.githubusercontent.com/${this.owner}/${this.repository}/${branch}/${path}`, {
|
|
31
|
+
headers: {
|
|
32
|
+
"Accept": "application/vnd.github+json"
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return response.data;
|
|
36
|
+
}
|
|
37
|
+
async download(branch, dirPath) {
|
|
38
|
+
const res = await this.axios.get(`https://github.com/${this.owner}/${this.repository}/archive/refs/heads/${branch}.zip`, {
|
|
39
|
+
responseType: "stream"
|
|
40
|
+
});
|
|
41
|
+
const fs = new core_1.FileSystem(dirPath);
|
|
42
|
+
if (!fs.exists()) {
|
|
43
|
+
fs.mkdir("", {
|
|
44
|
+
recursive: true
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
const { Parse } = require("unzipper"), pipe = res.data.pipe(Parse());
|
|
49
|
+
pipe.on("entry", (entry) => {
|
|
50
|
+
const path = entry.path.replace(/^[^\/]+\//, "");
|
|
51
|
+
if (entry.type === "File") {
|
|
52
|
+
entry.pipe(fs.createWriteStream(path));
|
|
53
|
+
}
|
|
54
|
+
else if (entry.type === "Directory") {
|
|
55
|
+
fs.mkdir(path, {
|
|
56
|
+
recursive: true
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
pipe.on("end", () => resolve());
|
|
61
|
+
pipe.on("error", reject);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.GithubClient = GithubClient;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Plugin = void 0;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const core_1 = require("@wocker/core");
|
|
6
|
+
class Plugin {
|
|
7
|
+
constructor(type) {
|
|
8
|
+
this.type = type;
|
|
9
|
+
const pluginName = Reflect.getMetadata(core_1.PLUGIN_NAME_METADATA, this.type);
|
|
10
|
+
if (!pluginName || typeof pluginName !== "string") {
|
|
11
|
+
throw new Error("Invalid plugin package");
|
|
12
|
+
}
|
|
13
|
+
this.name = pluginName;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.Plugin = Plugin;
|
package/lib/makes/index.d.ts
CHANGED
package/lib/makes/index.js
CHANGED
package/lib/plugins/index.d.ts
CHANGED
package/lib/plugins/index.js
CHANGED
|
@@ -14,6 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./elastic-search"), exports);
|
|
18
|
-
__exportStar(require("./proxmox"), exports);
|
|
19
17
|
__exportStar(require("./MongodbPlugin"), exports);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AppConfig, Preset, PresetSource } from "@wocker/core";
|
|
2
|
+
import { AppConfigService } from "../services/AppConfigService";
|
|
3
|
+
import { LogService } from "../services/LogService";
|
|
4
|
+
type PresetData = {
|
|
5
|
+
name: string;
|
|
6
|
+
source: PresetSource;
|
|
7
|
+
path?: string;
|
|
8
|
+
};
|
|
9
|
+
type SearchOptions = Partial<{
|
|
10
|
+
name: string;
|
|
11
|
+
source: string;
|
|
12
|
+
path: string;
|
|
13
|
+
}>;
|
|
14
|
+
export declare class PresetRepository {
|
|
15
|
+
protected readonly appConfig: AppConfigService;
|
|
16
|
+
protected readonly logService: LogService;
|
|
17
|
+
constructor(appConfig: AppConfigService, logService: LogService);
|
|
18
|
+
protected load(data: PresetData): Preset;
|
|
19
|
+
protected configs(): AppConfig["presets"];
|
|
20
|
+
search(options?: SearchOptions): Preset[];
|
|
21
|
+
searchOne(options?: SearchOptions): Preset | null;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -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 {};
|
|
@@ -59,6 +59,69 @@ let AppConfigService = class AppConfigService extends core_1.AppConfigService {
|
|
|
59
59
|
get version() {
|
|
60
60
|
return env_1.WOCKER_VERSION;
|
|
61
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
|
+
}
|
|
62
125
|
get fs() {
|
|
63
126
|
if (!this._fs) {
|
|
64
127
|
this._fs = new core_1.FileSystem(env_1.DATA_DIR);
|
|
@@ -83,61 +146,14 @@ let AppConfigService = class AppConfigService extends core_1.AppConfigService {
|
|
|
83
146
|
getProjectTypes() {
|
|
84
147
|
return this.mapTypes;
|
|
85
148
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
catch (err) {
|
|
95
|
-
if (fs.exists("wocker.config.json")) {
|
|
96
|
-
let json = fs.readJSON("wocker.config.json");
|
|
97
|
-
if (typeof json === "string") {
|
|
98
|
-
json = JSON.parse(json);
|
|
99
|
-
}
|
|
100
|
-
data = json;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
else if (fs.exists("wocker.config.json")) {
|
|
105
|
-
data = fs.readJSON("wocker.config.json");
|
|
106
|
-
}
|
|
107
|
-
else if (fs.exists("wocker.json")) {
|
|
108
|
-
let json = fs.readJSON("wocker.json");
|
|
109
|
-
if (typeof json === "string") {
|
|
110
|
-
json = JSON.parse(json);
|
|
111
|
-
}
|
|
112
|
-
data = json;
|
|
113
|
-
}
|
|
114
|
-
else if (fs.exists("data.json")) {
|
|
115
|
-
data = fs.readJSON("data.json");
|
|
116
|
-
}
|
|
117
|
-
else if (!fs.exists()) {
|
|
118
|
-
fs.mkdir("", {
|
|
119
|
-
recursive: true
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
return new class extends core_1.AppConfig {
|
|
123
|
-
constructor(data) {
|
|
124
|
-
super(data);
|
|
125
|
-
}
|
|
126
|
-
async save() {
|
|
127
|
-
if (!fs.exists()) {
|
|
128
|
-
fs.mkdir("");
|
|
129
|
-
}
|
|
130
|
-
const json = JSON.stringify(this.toJson(), null, 4);
|
|
131
|
-
await fs.writeFile("wocker.config.js", `// Wocker config\nexports.config = ${json};`);
|
|
132
|
-
await fs.writeFile("wocker.config.json", json);
|
|
133
|
-
if (fs.exists("data.json")) {
|
|
134
|
-
await fs.rm("data.json");
|
|
135
|
-
}
|
|
136
|
-
if (fs.exists("wocker.json")) {
|
|
137
|
-
await fs.rm("wocker.json");
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}(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();
|
|
141
157
|
}
|
|
142
158
|
};
|
|
143
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
|
};
|
|
@@ -94,7 +94,7 @@ let CertService = class CertService {
|
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
async getCertsMap() {
|
|
97
|
-
const files =
|
|
97
|
+
const files = this.appConfigService.fs.readdir("certs/projects");
|
|
98
98
|
return files.reduce((res, file) => {
|
|
99
99
|
const ext = Path.extname(file);
|
|
100
100
|
const name = Path.basename(file, ext);
|
|
@@ -137,7 +137,7 @@ let CertService = class CertService {
|
|
|
137
137
|
return;
|
|
138
138
|
}
|
|
139
139
|
for (const ext of certs[name]) {
|
|
140
|
-
|
|
140
|
+
this.appConfigService.fs.rm(`certs/projects/${name}${ext}`);
|
|
141
141
|
}
|
|
142
142
|
console.info(`Cert ${name} deleted`);
|
|
143
143
|
}
|
|
@@ -183,9 +183,12 @@ let DockerService = class DockerService extends core_1.DockerService {
|
|
|
183
183
|
t: tag,
|
|
184
184
|
labels,
|
|
185
185
|
buildargs: Object.keys(buildArgs).reduce((res, key) => {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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
|
+
}
|
|
189
192
|
return res;
|
|
190
193
|
}, {}),
|
|
191
194
|
dockerfile: src
|
|
@@ -1,8 +1,10 @@
|
|
|
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;
|