@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
|
@@ -21,64 +21,128 @@ 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
|
};
|
|
44
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
+
};
|
|
34
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
48
|
exports.PluginService = void 0;
|
|
36
49
|
const core_1 = require("@wocker/core");
|
|
50
|
+
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
51
|
+
const yoctocolors_cjs_1 = __importDefault(require("yoctocolors-cjs"));
|
|
37
52
|
const AppConfigService_1 = require("./AppConfigService");
|
|
38
53
|
const LogService_1 = require("./LogService");
|
|
54
|
+
const NpmService_1 = require("./NpmService");
|
|
39
55
|
const makes_1 = require("../makes");
|
|
40
56
|
const utils_1 = require("../utils");
|
|
41
57
|
let PluginService = class PluginService {
|
|
42
|
-
constructor(appConfigService, logService, cli) {
|
|
58
|
+
constructor(appConfigService, npmService, logService, cli) {
|
|
43
59
|
this.appConfigService = appConfigService;
|
|
60
|
+
this.npmService = npmService;
|
|
44
61
|
this.logService = logService;
|
|
45
62
|
this.cli = cli;
|
|
46
63
|
}
|
|
64
|
+
getPluginsTable() {
|
|
65
|
+
const config = this.appConfigService.config;
|
|
66
|
+
const table = new cli_table3_1.default({
|
|
67
|
+
head: ["Name", "Env"],
|
|
68
|
+
colWidths: [30]
|
|
69
|
+
});
|
|
70
|
+
if (config.plugins.length === 0) {
|
|
71
|
+
return yoctocolors_cjs_1.default.gray("No plugins installed");
|
|
72
|
+
}
|
|
73
|
+
for (const plugin of config.plugins) {
|
|
74
|
+
table.push([plugin.name, plugin.env]);
|
|
75
|
+
}
|
|
76
|
+
return table.toString();
|
|
77
|
+
}
|
|
47
78
|
async checkPlugin(pluginName) {
|
|
48
79
|
try {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
80
|
+
await this.import(pluginName);
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
this.logService.error(err.message, {
|
|
85
|
+
pluginName
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
async install(pluginName, beta) {
|
|
91
|
+
const [, prefix = "@wocker/", name, suffix = "-plugin"] = /^(@wocker\/)?(\w+)(-plugin)?$/.exec(pluginName) || [];
|
|
92
|
+
const fullName = `${prefix}${name}${suffix}`;
|
|
93
|
+
const config = this.appConfigService.config;
|
|
94
|
+
try {
|
|
95
|
+
if (await this.checkPlugin(fullName)) {
|
|
96
|
+
config.addPlugin(fullName);
|
|
97
|
+
await config.save();
|
|
98
|
+
console.info(`Plugin ${fullName} activated`);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const packageInfo = await this.npmService.getPackageInfo(fullName);
|
|
102
|
+
const env = packageInfo["dist-tags"].beta && beta ? "beta" : "latest";
|
|
103
|
+
await this.npmService.install(fullName, env);
|
|
104
|
+
if (await this.checkPlugin(fullName)) {
|
|
105
|
+
config.addPlugin(fullName, env);
|
|
106
|
+
await config.save();
|
|
107
|
+
console.info(`Plugin ${fullName}@${env} activated`);
|
|
108
|
+
return;
|
|
53
109
|
}
|
|
54
|
-
return !!name;
|
|
55
110
|
}
|
|
56
111
|
catch (err) {
|
|
57
112
|
this.logService.error(err.message);
|
|
58
113
|
}
|
|
59
|
-
return false;
|
|
60
114
|
}
|
|
61
|
-
async
|
|
115
|
+
async uninstall(pluginName) {
|
|
116
|
+
const [, prefix = "@wocker/", name, suffix = "-plugin"] = /^(@wocker\/)?(\w+)(-plugin)?$/.exec(pluginName) || [];
|
|
117
|
+
const fullName = `${prefix}${name}${suffix}`;
|
|
118
|
+
const config = this.appConfigService.config;
|
|
119
|
+
config.removePlugin(fullName);
|
|
120
|
+
await config.save();
|
|
121
|
+
console.info(`Plugin ${fullName} deactivated`);
|
|
122
|
+
}
|
|
123
|
+
async import(name) {
|
|
124
|
+
const { default: type } = await Promise.resolve(`${name}`).then(s => __importStar(require(s)));
|
|
125
|
+
return new makes_1.Plugin(type);
|
|
62
126
|
}
|
|
63
127
|
async update() {
|
|
64
|
-
const config = this.appConfigService.
|
|
128
|
+
const config = this.appConfigService.config;
|
|
65
129
|
if (!config.plugins) {
|
|
66
130
|
return;
|
|
67
131
|
}
|
|
68
|
-
for (const
|
|
69
|
-
console.info(`Checking ${name}...`);
|
|
132
|
+
for (const plugin of config.plugins) {
|
|
133
|
+
console.info(`Checking ${plugin.name}...`);
|
|
70
134
|
try {
|
|
71
|
-
const current = await this.getCurrentVersion(name);
|
|
135
|
+
const current = await this.getCurrentVersion(plugin.name);
|
|
72
136
|
const res = await makes_1.Http.get("https://registry.npmjs.org")
|
|
73
|
-
.send(name);
|
|
137
|
+
.send(plugin.name);
|
|
74
138
|
if (res.status !== 200) {
|
|
75
139
|
continue;
|
|
76
140
|
}
|
|
77
141
|
const { "dist-tags": { latest } } = res.data;
|
|
78
|
-
this.logService.info(name, current, latest);
|
|
142
|
+
this.logService.info(plugin.name, current, latest);
|
|
79
143
|
if (!current || current < latest) {
|
|
80
|
-
console.log(`Updating ${name}...`);
|
|
81
|
-
await (0, utils_1.spawn)("npm", ["i", "-g", name]);
|
|
144
|
+
console.log(`Updating ${plugin.name}...`);
|
|
145
|
+
await (0, utils_1.spawn)("npm", ["i", "-g", plugin.name]);
|
|
82
146
|
}
|
|
83
147
|
}
|
|
84
148
|
catch (err) {
|
|
@@ -102,6 +166,7 @@ exports.PluginService = PluginService;
|
|
|
102
166
|
exports.PluginService = PluginService = __decorate([
|
|
103
167
|
(0, core_1.Injectable)(),
|
|
104
168
|
__metadata("design:paramtypes", [AppConfigService_1.AppConfigService,
|
|
169
|
+
NpmService_1.NpmService,
|
|
105
170
|
LogService_1.LogService,
|
|
106
171
|
core_1.Cli])
|
|
107
172
|
], PluginService);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { EnvConfig, Project, Preset,
|
|
1
|
+
import { EnvConfig, Project, Preset, PresetVariableConfig } from "@wocker/core";
|
|
2
2
|
import { AppConfigService } from "./AppConfigService";
|
|
3
3
|
import { LogService } from "./LogService";
|
|
4
|
+
import { PresetRepository } from "../repositories/PresetRepository";
|
|
4
5
|
type SearchOptions = Partial<{
|
|
5
6
|
name: string;
|
|
6
7
|
source: string;
|
|
@@ -8,17 +9,17 @@ type SearchOptions = Partial<{
|
|
|
8
9
|
}>;
|
|
9
10
|
export declare class PresetService {
|
|
10
11
|
protected readonly appConfigService: AppConfigService;
|
|
12
|
+
protected readonly presetRepository: PresetRepository;
|
|
11
13
|
protected readonly logService: LogService;
|
|
12
|
-
constructor(appConfigService: AppConfigService, logService: LogService);
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
constructor(appConfigService: AppConfigService, presetRepository: PresetRepository, logService: LogService);
|
|
15
|
+
prompt(configMap: {
|
|
16
|
+
[name: string]: PresetVariableConfig;
|
|
17
|
+
}, values?: EnvConfig): Promise<EnvConfig>;
|
|
15
18
|
getImageNameForProject(project: Project, preset: Preset): string;
|
|
16
19
|
getImageName(preset: Preset, buildArgs: EnvConfig): string;
|
|
17
20
|
init(): Promise<void>;
|
|
18
21
|
deinit(): Promise<void>;
|
|
19
|
-
get(name
|
|
20
|
-
addPreset(name: string): Promise<void>;
|
|
21
|
-
search(options?: SearchOptions): Promise<Preset[]>;
|
|
22
|
-
searchOne(options?: SearchOptions): Promise<Preset | null>;
|
|
22
|
+
get(name?: string): Preset;
|
|
23
|
+
addPreset(name: string, repository?: string, version?: string): Promise<void>;
|
|
23
24
|
}
|
|
24
25
|
export { SearchOptions as PresetServiceSearchOptions };
|