@wocker/ws 1.0.32 → 1.1.1
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/lib/AppModule.js +1 -2
- package/lib/main.js +2 -2
- package/lib/makes/GithubClient.d.ts +3 -2
- package/lib/makes/GithubClient.js +27 -27
- package/lib/makes/index.d.ts +0 -3
- package/lib/makes/index.js +0 -3
- package/lib/modules/core/controllers/DebugController.d.ts +3 -4
- package/lib/modules/core/controllers/DebugController.js +5 -22
- package/lib/modules/core/controllers/ExperimentalController.d.ts +3 -3
- package/lib/modules/core/controllers/ExperimentalController.js +1 -1
- package/lib/modules/dns/index.js +3 -3
- package/lib/modules/keystore/controllers/KeystoreController.d.ts +3 -3
- package/lib/modules/keystore/controllers/KeystoreController.js +8 -8
- package/lib/modules/keystore/providers/FileKeystoreProvider.js +8 -8
- package/lib/modules/keystore/services/KeystoreService.d.ts +3 -3
- package/lib/modules/keystore/services/KeystoreService.js +4 -4
- package/lib/modules/package-manager/service/PackageManager.d.ts +3 -3
- package/lib/modules/package-manager/service/PackageManager.js +8 -8
- package/lib/modules/package-manager/service/RegistryService.js +5 -4
- package/lib/modules/plugin/controllers/PluginController.d.ts +3 -3
- package/lib/modules/plugin/controllers/PluginController.js +4 -4
- package/lib/modules/plugin/index.js +4 -5
- package/lib/modules/plugin/services/PluginService.d.ts +3 -3
- package/lib/modules/plugin/services/PluginService.js +11 -13
- package/lib/modules/preset/controllers/PresetController.d.ts +3 -3
- package/lib/modules/preset/controllers/PresetController.js +6 -6
- package/lib/modules/preset/controllers/PresetListener.d.ts +5 -4
- package/lib/modules/preset/controllers/PresetListener.js +19 -55
- package/lib/modules/preset/repositories/PresetRepository.d.ts +3 -3
- package/lib/modules/preset/repositories/PresetRepository.js +7 -7
- package/lib/modules/preset/services/PresetService.d.ts +4 -3
- package/lib/modules/preset/services/PresetService.js +33 -33
- package/lib/modules/project/controllers/MetadataController.d.ts +8 -0
- package/lib/modules/project/controllers/MetadataController.js +89 -0
- package/lib/modules/project/controllers/ProjectController.d.ts +6 -6
- package/lib/modules/project/controllers/ProjectController.js +62 -49
- package/lib/modules/project/controllers/SecretsController.js +2 -2
- package/lib/modules/project/index.d.ts +1 -2
- package/lib/modules/project/index.js +4 -6
- package/lib/modules/project/services/ProjectService.d.ts +3 -4
- package/lib/modules/project/services/ProjectService.js +49 -50
- package/lib/modules/proxy/controllers/HttpAuthController.d.ts +3 -4
- package/lib/modules/proxy/controllers/HttpAuthController.js +28 -16
- package/lib/modules/proxy/controllers/ProxyController.d.ts +3 -3
- package/lib/modules/proxy/controllers/ProxyController.js +11 -11
- package/lib/modules/proxy/services/HttpAuthService.d.ts +3 -0
- package/lib/modules/proxy/services/HttpAuthService.js +29 -10
- package/lib/modules/proxy/services/ProxyService.d.ts +3 -3
- package/lib/modules/proxy/services/ProxyService.js +9 -9
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/index.js +0 -1
- package/package.json +6 -14
- package/lib/makes/Http.d.ts +0 -18
- package/lib/makes/Http.js +0 -82
- package/lib/makes/Version.d.ts +0 -22
- package/lib/makes/Version.js +0 -59
- package/lib/makes/VersionRange.d.ts +0 -6
- package/lib/makes/VersionRange.js +0 -18
- package/lib/makes/VersionRule.d.ts +0 -24
- package/lib/makes/VersionRule.js +0 -68
- package/lib/modules/project/repositories/ProjectRepository.d.ts +0 -13
- package/lib/modules/project/repositories/ProjectRepository.js +0 -71
- package/lib/utils/injectVariables.d.ts +0 -5
- package/lib/utils/injectVariables.js +0 -10
package/lib/AppModule.js
CHANGED
package/lib/main.js
CHANGED
|
@@ -8,7 +8,7 @@ const core_1 = require("@wocker/core");
|
|
|
8
8
|
const yoctocolors_cjs_1 = __importDefault(require("yoctocolors-cjs"));
|
|
9
9
|
const AppModule_1 = require("./AppModule");
|
|
10
10
|
(async () => {
|
|
11
|
-
const context = await core_1.Factory.create(AppModule_1.AppModule),
|
|
11
|
+
const context = await core_1.Factory.create(AppModule_1.AppModule), appService = context.get(core_1.AppService), logService = context.get(core_1.LogService);
|
|
12
12
|
try {
|
|
13
13
|
const res = await context.run(process.argv);
|
|
14
14
|
if (res) {
|
|
@@ -27,7 +27,7 @@ const AppModule_1 = require("./AppModule");
|
|
|
27
27
|
if (err instanceof core_1.CommandNotFoundError) {
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
if (
|
|
30
|
+
if (appService.debug) {
|
|
31
31
|
logService.error(err.stack || err.toString());
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Http } from "@wocker/utils";
|
|
2
2
|
type RepositoryInfo = {
|
|
3
3
|
default_branch: string;
|
|
4
4
|
};
|
|
@@ -24,7 +24,8 @@ export declare class GithubClient {
|
|
|
24
24
|
readonly owner: string;
|
|
25
25
|
readonly repository: string;
|
|
26
26
|
constructor(owner: string, repository: string);
|
|
27
|
-
get
|
|
27
|
+
get client(): Http;
|
|
28
|
+
get contentClient(): Http;
|
|
28
29
|
getInfo(): Promise<RepositoryInfo>;
|
|
29
30
|
getBranches(): Promise<GithubBranch[]>;
|
|
30
31
|
getTags(): Promise<GithubTag[]>;
|
|
@@ -1,54 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.GithubClient = void 0;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
4
|
const core_1 = require("@wocker/core");
|
|
5
|
+
const utils_1 = require("@wocker/utils");
|
|
9
6
|
class GithubClient {
|
|
10
7
|
constructor(owner, repository) {
|
|
11
8
|
this.owner = owner;
|
|
12
9
|
this.repository = repository;
|
|
13
10
|
}
|
|
14
|
-
get
|
|
15
|
-
return
|
|
11
|
+
get client() {
|
|
12
|
+
return utils_1.Http.base("https://api.github.com", {
|
|
16
13
|
headers: {
|
|
17
14
|
"User-Agent": "Wocker"
|
|
18
15
|
}
|
|
19
16
|
});
|
|
20
17
|
}
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
get contentClient() {
|
|
19
|
+
return utils_1.Http.base("https://raw.githubusercontent.com", {
|
|
23
20
|
headers: {
|
|
24
|
-
"
|
|
21
|
+
"User-Agent": "Wocker"
|
|
25
22
|
}
|
|
26
23
|
});
|
|
27
|
-
|
|
24
|
+
}
|
|
25
|
+
async getInfo() {
|
|
26
|
+
return this.contentClient.get(`/repos/${this.owner}/${this.repository}`)
|
|
27
|
+
.withHeader("Accept", "application/vnd.github+json")
|
|
28
|
+
.expectStatus(200)
|
|
29
|
+
.json();
|
|
28
30
|
}
|
|
29
31
|
async getBranches() {
|
|
30
|
-
|
|
31
|
-
.get(
|
|
32
|
-
|
|
32
|
+
return this.client
|
|
33
|
+
.get(`/repos/${this.owner}/${this.repository}/branches`)
|
|
34
|
+
.expectStatus(200)
|
|
35
|
+
.json();
|
|
33
36
|
}
|
|
34
37
|
async getTags() {
|
|
35
|
-
|
|
36
|
-
.get(
|
|
37
|
-
|
|
38
|
+
return this.client
|
|
39
|
+
.get(`/repos/${this.owner}/${this.repository}/tags`)
|
|
40
|
+
.expectStatus(200)
|
|
41
|
+
.json();
|
|
38
42
|
}
|
|
39
43
|
async getFile(ref, path) {
|
|
40
|
-
|
|
41
|
-
.get(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
46
|
-
return res.data;
|
|
44
|
+
return this.contentClient
|
|
45
|
+
.get(`/${this.owner}/${this.repository}/${ref}/${path}`)
|
|
46
|
+
.withHeader("Accept", "application/vnd.github+json")
|
|
47
|
+
.expectStatus(200)
|
|
48
|
+
.json();
|
|
47
49
|
}
|
|
48
50
|
async downloadZipByUrl(url, dirPath) {
|
|
49
|
-
const res = await
|
|
50
|
-
responseType: "stream"
|
|
51
|
-
});
|
|
51
|
+
const res = await utils_1.Http.base(url).expectStatus(200).send();
|
|
52
52
|
const fs = new core_1.FileSystem(dirPath);
|
|
53
53
|
if (!fs.exists()) {
|
|
54
54
|
fs.mkdir("", {
|
|
@@ -56,7 +56,7 @@ class GithubClient {
|
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
return new Promise((resolve, reject) => {
|
|
59
|
-
const { Parse } = require("unzipper"), pipe = res.
|
|
59
|
+
const { Parse } = require("unzipper"), pipe = res.pipe(Parse());
|
|
60
60
|
pipe.on("entry", (entry) => {
|
|
61
61
|
const path = entry.path.replace(/^[^\/]+\//, "");
|
|
62
62
|
if (entry.type === "File") {
|
package/lib/makes/index.d.ts
CHANGED
package/lib/makes/index.js
CHANGED
|
@@ -14,7 +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("./Http"), exports);
|
|
18
17
|
__exportStar(require("./Plugin"), exports);
|
|
19
|
-
__exportStar(require("./Version"), exports);
|
|
20
|
-
__exportStar(require("./VersionRule"), exports);
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { LogService,
|
|
1
|
+
import { LogService, AppService } from "@wocker/core";
|
|
2
2
|
export declare class DebugController {
|
|
3
|
-
protected readonly
|
|
3
|
+
protected readonly appService: AppService;
|
|
4
4
|
protected readonly logService: LogService;
|
|
5
|
-
constructor(
|
|
5
|
+
constructor(appService: AppService, logService: LogService);
|
|
6
6
|
debug(): Promise<string>;
|
|
7
7
|
setDebug(status: string): Promise<void>;
|
|
8
|
-
setLog(level: string): Promise<void>;
|
|
9
8
|
testLog(level: string, args: string[]): Promise<void>;
|
|
10
9
|
debugCompletion(): Promise<string[]>;
|
|
11
10
|
getLevels(): string[];
|
|
@@ -15,24 +15,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.DebugController = void 0;
|
|
16
16
|
const core_1 = require("@wocker/core");
|
|
17
17
|
let DebugController = class DebugController {
|
|
18
|
-
constructor(
|
|
19
|
-
this.
|
|
18
|
+
constructor(appService, logService) {
|
|
19
|
+
this.appService = appService;
|
|
20
20
|
this.logService = logService;
|
|
21
21
|
}
|
|
22
22
|
async debug() {
|
|
23
|
-
return this.
|
|
23
|
+
return this.appService.debug ? "on" : "off";
|
|
24
24
|
}
|
|
25
25
|
async setDebug(status) {
|
|
26
|
-
this.
|
|
27
|
-
this.appConfigService.save();
|
|
28
|
-
}
|
|
29
|
-
async setLog(level) {
|
|
30
|
-
const validLevels = this.getLevels();
|
|
31
|
-
if (!validLevels.includes(level)) {
|
|
32
|
-
throw new Error(`Invalid log level: ${level}. Valid options are ${validLevels.join(', ')}`);
|
|
33
|
-
}
|
|
34
|
-
this.appConfigService.config.logLevel = level;
|
|
35
|
-
this.appConfigService.save();
|
|
26
|
+
this.appService.debug = status === "on";
|
|
36
27
|
}
|
|
37
28
|
async testLog(level, args) {
|
|
38
29
|
this.logService._log(level, ...args);
|
|
@@ -59,14 +50,6 @@ __decorate([
|
|
|
59
50
|
__metadata("design:paramtypes", [String]),
|
|
60
51
|
__metadata("design:returntype", Promise)
|
|
61
52
|
], DebugController.prototype, "setDebug", null);
|
|
62
|
-
__decorate([
|
|
63
|
-
(0, core_1.Description)("Set the log level (options: debug, log, info, warn, error)"),
|
|
64
|
-
(0, core_1.Command)("loglevel <level>"),
|
|
65
|
-
__param(0, (0, core_1.Param)("level")),
|
|
66
|
-
__metadata("design:type", Function),
|
|
67
|
-
__metadata("design:paramtypes", [String]),
|
|
68
|
-
__metadata("design:returntype", Promise)
|
|
69
|
-
], DebugController.prototype, "setLog", null);
|
|
70
53
|
__decorate([
|
|
71
54
|
(0, core_1.Command)("log:<level> [...args]"),
|
|
72
55
|
__param(0, (0, core_1.Param)("level")),
|
|
@@ -89,6 +72,6 @@ __decorate([
|
|
|
89
72
|
], DebugController.prototype, "getLevels", null);
|
|
90
73
|
exports.DebugController = DebugController = __decorate([
|
|
91
74
|
(0, core_1.Controller)(),
|
|
92
|
-
__metadata("design:paramtypes", [core_1.
|
|
75
|
+
__metadata("design:paramtypes", [core_1.AppService,
|
|
93
76
|
core_1.LogService])
|
|
94
77
|
], DebugController);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AppService } from "@wocker/core";
|
|
2
2
|
export declare class ExperimentalController {
|
|
3
|
-
protected readonly appService:
|
|
4
|
-
constructor(appService:
|
|
3
|
+
protected readonly appService: AppService;
|
|
4
|
+
constructor(appService: AppService);
|
|
5
5
|
enable(feature?: string): void;
|
|
6
6
|
disable(feature?: string): void;
|
|
7
7
|
getFeatures(): string[];
|
|
@@ -72,5 +72,5 @@ __decorate([
|
|
|
72
72
|
exports.ExperimentalController = ExperimentalController = __decorate([
|
|
73
73
|
(0, core_1.Controller)(),
|
|
74
74
|
(0, core_1.Description)("Manage experimental features"),
|
|
75
|
-
__metadata("design:paramtypes", [core_1.
|
|
75
|
+
__metadata("design:paramtypes", [core_1.AppService])
|
|
76
76
|
], ExperimentalController);
|
package/lib/modules/dns/index.js
CHANGED
|
@@ -20,9 +20,9 @@ let DnsModule = DnsModule_1 = class DnsModule {
|
|
|
20
20
|
static register() {
|
|
21
21
|
return {
|
|
22
22
|
module: DnsModule_1,
|
|
23
|
-
inject: [core_1.
|
|
24
|
-
useFactory: (
|
|
25
|
-
if (!
|
|
23
|
+
inject: [core_1.AppService],
|
|
24
|
+
useFactory: (appService) => {
|
|
25
|
+
if (!appService.isExperimentalEnabled("dns")) {
|
|
26
26
|
return {};
|
|
27
27
|
}
|
|
28
28
|
return {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AppService } from "@wocker/core";
|
|
2
2
|
import { KeystoreService } from "../services/KeystoreService";
|
|
3
3
|
export declare class KeystoreController {
|
|
4
|
-
protected readonly
|
|
4
|
+
protected readonly appService: AppService;
|
|
5
5
|
protected readonly keystoreService: KeystoreService;
|
|
6
|
-
constructor(
|
|
6
|
+
constructor(appService: AppService, keystoreService: KeystoreService);
|
|
7
7
|
init(provider?: string): Promise<void>;
|
|
8
8
|
}
|
|
@@ -14,28 +14,28 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.KeystoreController = void 0;
|
|
16
16
|
const core_1 = require("@wocker/core");
|
|
17
|
-
const
|
|
17
|
+
const prompts_1 = require("@wocker/prompts");
|
|
18
18
|
const KeystoreService_1 = require("../services/KeystoreService");
|
|
19
19
|
let KeystoreController = class KeystoreController {
|
|
20
|
-
constructor(
|
|
21
|
-
this.
|
|
20
|
+
constructor(appService, keystoreService) {
|
|
21
|
+
this.appService = appService;
|
|
22
22
|
this.keystoreService = keystoreService;
|
|
23
23
|
}
|
|
24
24
|
async init(provider) {
|
|
25
25
|
if (!provider) {
|
|
26
|
-
provider = await (0,
|
|
26
|
+
provider = await (0, prompts_1.promptSelect)({
|
|
27
27
|
required: true,
|
|
28
28
|
message: "Keystore provider",
|
|
29
29
|
type: "text",
|
|
30
30
|
options: ["file", "keytar"],
|
|
31
|
-
default: this.
|
|
31
|
+
default: this.appService.config.keystore
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
if (!this.keystoreService.hasProvider(provider)) {
|
|
35
35
|
throw new Error(`Provider "${provider}" not found`);
|
|
36
36
|
}
|
|
37
|
-
this.
|
|
38
|
-
this.
|
|
37
|
+
this.appService.config.keystore = provider;
|
|
38
|
+
this.appService.save();
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
exports.KeystoreController = KeystoreController;
|
|
@@ -51,6 +51,6 @@ __decorate([
|
|
|
51
51
|
exports.KeystoreController = KeystoreController = __decorate([
|
|
52
52
|
(0, core_1.Controller)(),
|
|
53
53
|
(0, core_1.Description)("Keystore commands"),
|
|
54
|
-
__metadata("design:paramtypes", [core_1.
|
|
54
|
+
__metadata("design:paramtypes", [core_1.AppService,
|
|
55
55
|
KeystoreService_1.KeystoreService])
|
|
56
56
|
], KeystoreController);
|
|
@@ -11,9 +11,9 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.FileKeystoreProvider = void 0;
|
|
13
13
|
const core_1 = require("@wocker/core");
|
|
14
|
-
const
|
|
14
|
+
const prompts_1 = require("@wocker/prompts");
|
|
15
15
|
const FileKeystore_1 = require("../types/FileKeystore");
|
|
16
|
-
const
|
|
16
|
+
const utils_1 = require("../utils");
|
|
17
17
|
let FileKeystoreProvider = class FileKeystoreProvider extends core_1.KeystoreProvider {
|
|
18
18
|
constructor(fs) {
|
|
19
19
|
super();
|
|
@@ -50,24 +50,24 @@ let FileKeystoreProvider = class FileKeystoreProvider extends core_1.KeystorePro
|
|
|
50
50
|
}
|
|
51
51
|
async getEncryptionKey() {
|
|
52
52
|
if (!this.encryptionKey) {
|
|
53
|
-
const password = await (0,
|
|
53
|
+
const password = await (0, prompts_1.promptInput)({
|
|
54
54
|
required: true,
|
|
55
55
|
min: 6,
|
|
56
56
|
max: 32,
|
|
57
57
|
message: "Keystore password",
|
|
58
58
|
type: "password",
|
|
59
59
|
validate: async (value) => {
|
|
60
|
-
if (typeof value !== "string" || !this.passwordHash || (0,
|
|
60
|
+
if (typeof value !== "string" || !this.passwordHash || (0, utils_1.verifyPasswordHash)(value, this.passwordHash)) {
|
|
61
61
|
return true;
|
|
62
62
|
}
|
|
63
63
|
return "Invalid password";
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
66
|
if (!this.keystore.passwordHash) {
|
|
67
|
-
this.keystore.passwordHash = (0,
|
|
67
|
+
this.keystore.passwordHash = (0, utils_1.createPasswordHash)(password);
|
|
68
68
|
this.keystore.save();
|
|
69
69
|
}
|
|
70
|
-
this.encryptionKey = (0,
|
|
70
|
+
this.encryptionKey = (0, utils_1.createEncryptionKey)(password, this.keystore.passwordHash);
|
|
71
71
|
}
|
|
72
72
|
return this.encryptionKey;
|
|
73
73
|
}
|
|
@@ -77,11 +77,11 @@ let FileKeystoreProvider = class FileKeystoreProvider extends core_1.KeystorePro
|
|
|
77
77
|
return defaultValue;
|
|
78
78
|
}
|
|
79
79
|
const encryptionKey = await this.getEncryptionKey();
|
|
80
|
-
return (0,
|
|
80
|
+
return (0, utils_1.decrypt)(encryptionKey, value);
|
|
81
81
|
}
|
|
82
82
|
async set(key, value) {
|
|
83
83
|
const encryptionKey = await this.getEncryptionKey();
|
|
84
|
-
this.keystore.set(key, (0,
|
|
84
|
+
this.keystore.set(key, (0, utils_1.encrypt)(encryptionKey, value));
|
|
85
85
|
this.keystore.save();
|
|
86
86
|
}
|
|
87
87
|
async delete(key) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AppService, AppFileSystemService, KeystoreService as CoreKeystoreService, KeystoreProvider } from "@wocker/core";
|
|
2
2
|
export declare class KeystoreService extends CoreKeystoreService {
|
|
3
|
-
protected readonly
|
|
3
|
+
protected readonly appService: AppService;
|
|
4
4
|
protected readonly fs: AppFileSystemService;
|
|
5
5
|
protected providers: Map<string, KeystoreProvider>;
|
|
6
|
-
constructor(
|
|
6
|
+
constructor(appService: AppService, fs: AppFileSystemService);
|
|
7
7
|
hasProvider(name: string): boolean;
|
|
8
8
|
provider(name?: string): KeystoreProvider;
|
|
9
9
|
get(keys: string | string[], byDefault?: string): Promise<string | undefined>;
|
|
@@ -14,9 +14,9 @@ const core_1 = require("@wocker/core");
|
|
|
14
14
|
const KeytarKeystoreProvider_1 = require("../providers/KeytarKeystoreProvider");
|
|
15
15
|
const FileKeystoreProvider_1 = require("../providers/FileKeystoreProvider");
|
|
16
16
|
let KeystoreService = class KeystoreService extends core_1.KeystoreService {
|
|
17
|
-
constructor(
|
|
17
|
+
constructor(appService, fs) {
|
|
18
18
|
super();
|
|
19
|
-
this.
|
|
19
|
+
this.appService = appService;
|
|
20
20
|
this.fs = fs;
|
|
21
21
|
this.providers = new Map();
|
|
22
22
|
}
|
|
@@ -25,7 +25,7 @@ let KeystoreService = class KeystoreService extends core_1.KeystoreService {
|
|
|
25
25
|
}
|
|
26
26
|
provider(name) {
|
|
27
27
|
if (!name) {
|
|
28
|
-
name = this.
|
|
28
|
+
name = this.appService.config.keystore;
|
|
29
29
|
}
|
|
30
30
|
if (!name) {
|
|
31
31
|
name = "file";
|
|
@@ -70,6 +70,6 @@ let KeystoreService = class KeystoreService extends core_1.KeystoreService {
|
|
|
70
70
|
exports.KeystoreService = KeystoreService;
|
|
71
71
|
exports.KeystoreService = KeystoreService = __decorate([
|
|
72
72
|
(0, core_1.Injectable)("KEYSTORE_SERVICE"),
|
|
73
|
-
__metadata("design:paramtypes", [core_1.
|
|
73
|
+
__metadata("design:paramtypes", [core_1.AppService,
|
|
74
74
|
core_1.AppFileSystemService])
|
|
75
75
|
], KeystoreService);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AppService } from "@wocker/core";
|
|
2
2
|
import { PackageManagerProvider } from "../types/PackageManagerProvider";
|
|
3
3
|
export declare class PackageManager {
|
|
4
|
-
protected readonly
|
|
5
|
-
constructor(
|
|
4
|
+
protected readonly appService: AppService;
|
|
5
|
+
constructor(appService: AppService);
|
|
6
6
|
getManager(): Promise<PackageManagerProvider>;
|
|
7
7
|
getPackages(global?: boolean): Promise<import("../types/Package").Package[]>;
|
|
8
8
|
install(name: string, version?: string): Promise<void>;
|
|
@@ -11,17 +11,17 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.PackageManager = void 0;
|
|
13
13
|
const core_1 = require("@wocker/core");
|
|
14
|
-
const
|
|
14
|
+
const prompts_1 = require("@wocker/prompts");
|
|
15
15
|
const NpmProvider_1 = require("../providers/NpmProvider");
|
|
16
16
|
const PnpmProvider_1 = require("../providers/PnpmProvider");
|
|
17
17
|
const YarnProvider_1 = require("../providers/YarnProvider");
|
|
18
18
|
let PackageManager = class PackageManager {
|
|
19
|
-
constructor(
|
|
20
|
-
this.
|
|
19
|
+
constructor(appService) {
|
|
20
|
+
this.appService = appService;
|
|
21
21
|
}
|
|
22
22
|
async getManager() {
|
|
23
|
-
if (!this.
|
|
24
|
-
this.
|
|
23
|
+
if (!this.appService.config.pm) {
|
|
24
|
+
this.appService.config.pm = await (0, prompts_1.promptSelect)({
|
|
25
25
|
label: "Package manager:",
|
|
26
26
|
options: [
|
|
27
27
|
{
|
|
@@ -39,9 +39,9 @@ let PackageManager = class PackageManager {
|
|
|
39
39
|
],
|
|
40
40
|
required: true
|
|
41
41
|
});
|
|
42
|
-
this.
|
|
42
|
+
this.appService.save();
|
|
43
43
|
}
|
|
44
|
-
switch (this.
|
|
44
|
+
switch (this.appService.config.pm) {
|
|
45
45
|
case "npm":
|
|
46
46
|
return new NpmProvider_1.NpmProvider();
|
|
47
47
|
case "pnpm":
|
|
@@ -66,5 +66,5 @@ let PackageManager = class PackageManager {
|
|
|
66
66
|
exports.PackageManager = PackageManager;
|
|
67
67
|
exports.PackageManager = PackageManager = __decorate([
|
|
68
68
|
(0, core_1.Injectable)("PACKAGE_MANAGER_SERVICE"),
|
|
69
|
-
__metadata("design:paramtypes", [core_1.
|
|
69
|
+
__metadata("design:paramtypes", [core_1.AppService])
|
|
70
70
|
], PackageManager);
|
|
@@ -8,18 +8,19 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.RegistryService = void 0;
|
|
10
10
|
const core_1 = require("@wocker/core");
|
|
11
|
-
const
|
|
11
|
+
const utils_1 = require("@wocker/utils");
|
|
12
12
|
let RegistryService = class RegistryService {
|
|
13
13
|
async getPackageInfo(name) {
|
|
14
|
-
const res = await
|
|
15
|
-
.
|
|
14
|
+
const res = await utils_1.Http.base("https://registry.npmjs.org")
|
|
15
|
+
.get(name)
|
|
16
|
+
.send();
|
|
16
17
|
if (res.status === 404) {
|
|
17
18
|
throw new Error("Package not found");
|
|
18
19
|
}
|
|
19
20
|
if (res.status !== 200) {
|
|
20
21
|
throw new Error("Network error");
|
|
21
22
|
}
|
|
22
|
-
return res.
|
|
23
|
+
return res.json();
|
|
23
24
|
}
|
|
24
25
|
};
|
|
25
26
|
exports.RegistryService = RegistryService;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AppService } from "@wocker/core";
|
|
2
2
|
import { PluginService } from "../services/PluginService";
|
|
3
3
|
export declare class PluginController {
|
|
4
|
-
protected readonly
|
|
4
|
+
protected readonly appService: AppService;
|
|
5
5
|
protected readonly pluginService: PluginService;
|
|
6
|
-
constructor(
|
|
6
|
+
constructor(appService: AppService, pluginService: PluginService);
|
|
7
7
|
list(): Promise<string>;
|
|
8
8
|
add(names: string[]): Promise<void>;
|
|
9
9
|
remove(names: string[]): Promise<void>;
|
|
@@ -16,8 +16,8 @@ exports.PluginController = void 0;
|
|
|
16
16
|
const core_1 = require("@wocker/core");
|
|
17
17
|
const PluginService_1 = require("../services/PluginService");
|
|
18
18
|
let PluginController = class PluginController {
|
|
19
|
-
constructor(
|
|
20
|
-
this.
|
|
19
|
+
constructor(appService, pluginService) {
|
|
20
|
+
this.appService = appService;
|
|
21
21
|
this.pluginService = pluginService;
|
|
22
22
|
}
|
|
23
23
|
async list() {
|
|
@@ -38,7 +38,7 @@ let PluginController = class PluginController {
|
|
|
38
38
|
await this.pluginService.update();
|
|
39
39
|
}
|
|
40
40
|
getInstalledPlugins() {
|
|
41
|
-
return this.
|
|
41
|
+
return this.appService.plugins.map(pluginRef => pluginRef.name);
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
exports.PluginController = PluginController;
|
|
@@ -82,6 +82,6 @@ __decorate([
|
|
|
82
82
|
exports.PluginController = PluginController = __decorate([
|
|
83
83
|
(0, core_1.Controller)(),
|
|
84
84
|
(0, core_1.Description)("Plugin commands"),
|
|
85
|
-
__metadata("design:paramtypes", [core_1.
|
|
85
|
+
__metadata("design:paramtypes", [core_1.AppService,
|
|
86
86
|
PluginService_1.PluginService])
|
|
87
87
|
], PluginController);
|
|
@@ -18,14 +18,14 @@ let PluginModule = PluginModule_1 = class PluginModule {
|
|
|
18
18
|
return {
|
|
19
19
|
module: PluginModule_1,
|
|
20
20
|
inject: [
|
|
21
|
-
core_1.
|
|
21
|
+
core_1.AppService,
|
|
22
22
|
core_1.AppFileSystemService,
|
|
23
23
|
core_1.LogService,
|
|
24
24
|
PluginService_1.PluginService
|
|
25
25
|
],
|
|
26
|
-
useFactory: async (
|
|
26
|
+
useFactory: async (appService, fs, logService, pluginService) => {
|
|
27
27
|
const imports = [];
|
|
28
|
-
for (const pluginData of
|
|
28
|
+
for (const pluginData of appService.plugins) {
|
|
29
29
|
try {
|
|
30
30
|
const plugin = await pluginService.import(pluginData.name);
|
|
31
31
|
imports.push({
|
|
@@ -43,8 +43,7 @@ let PluginModule = PluginModule_1 = class PluginModule {
|
|
|
43
43
|
pluginName: pluginData.name,
|
|
44
44
|
pluginEnv: pluginData.env
|
|
45
45
|
});
|
|
46
|
-
|
|
47
|
-
appConfigService.save();
|
|
46
|
+
appService.removePlugin(pluginData.name);
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
return {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Cli,
|
|
1
|
+
import { Cli, AppService, LogService } from "@wocker/core";
|
|
2
2
|
import { PackageManager, RegistryService } from "../../package-manager";
|
|
3
3
|
import { Plugin } from "../../../makes";
|
|
4
4
|
export declare class PluginService {
|
|
5
|
-
protected readonly
|
|
5
|
+
protected readonly appService: AppService;
|
|
6
6
|
protected readonly pm: PackageManager;
|
|
7
7
|
protected readonly registryService: RegistryService;
|
|
8
8
|
protected readonly logService: LogService;
|
|
9
9
|
protected readonly cli: Cli;
|
|
10
10
|
protected rule: string;
|
|
11
|
-
constructor(
|
|
11
|
+
constructor(appService: AppService, pm: PackageManager, registryService: RegistryService, logService: LogService, cli: Cli);
|
|
12
12
|
getPluginsTable(): string;
|
|
13
13
|
checkPlugin(pluginName: string): Promise<boolean>;
|
|
14
14
|
install(pluginName: string, version?: string): Promise<void>;
|