@tsed/cli-core 6.0.0-beta.1 → 6.0.0-beta.2
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/esm/CliCore.js +7 -11
- package/lib/esm/services/CliDockerComposeYaml.js +7 -14
- package/lib/esm/services/CliHooks.js +5 -8
- package/lib/esm/services/CliHttpClient.js +6 -6
- package/lib/esm/services/CliHttpLogClient.js +2 -5
- package/lib/esm/services/CliLoadFile.js +3 -9
- package/lib/esm/services/CliPackageJson.js +4 -1
- package/lib/esm/services/CliPlugins.js +10 -29
- package/lib/esm/services/CliProxyAgent.js +11 -18
- package/lib/esm/services/CliRunScript.js +3 -7
- package/lib/esm/services/CliService.js +26 -44
- package/lib/esm/services/CliYaml.js +5 -6
- package/lib/esm/services/NpmRegistryClient.js +5 -6
- package/lib/esm/services/ProjectPackageJson.js +23 -23
- package/lib/esm/services/Renderer.js +5 -14
- package/lib/esm/utils/createInjector.js +11 -11
- package/lib/esm/utils/getCommandMetadata.js +1 -1
- package/lib/esm/utils/loadPlugins.js +16 -15
- package/lib/types/services/CliHooks.d.ts +0 -2
- package/lib/types/services/CliPackageJson.d.ts +2 -1
- package/lib/types/services/CliPlugins.d.ts +2 -2
- package/lib/types/services/CliProxyAgent.d.ts +4 -3
- package/lib/types/services/CliRunScript.d.ts +0 -2
- package/lib/types/services/CliService.d.ts +4 -5
- package/lib/types/services/ProjectPackageJson.d.ts +2 -4
- package/lib/types/services/Renderer.d.ts +3 -4
- package/lib/types/utils/getCommandMetadata.d.ts +2 -2
- package/lib/types/utils/loadPlugins.d.ts +1 -2
- package/package.json +4 -4
package/lib/esm/CliCore.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var CliCore_1;
|
|
2
|
-
import { __decorate
|
|
2
|
+
import { __decorate } from "tslib";
|
|
3
3
|
import { Type } from "@tsed/core";
|
|
4
|
-
import {
|
|
4
|
+
import { inject, InjectorService, Module } from "@tsed/di";
|
|
5
5
|
import chalk from "chalk";
|
|
6
6
|
import { Command } from "commander";
|
|
7
7
|
import { join, resolve } from "path";
|
|
@@ -19,6 +19,10 @@ function isHelpManual(argv) {
|
|
|
19
19
|
return argv.includes("-h") || argv.includes("--help");
|
|
20
20
|
}
|
|
21
21
|
let CliCore = CliCore_1 = class CliCore {
|
|
22
|
+
constructor() {
|
|
23
|
+
this.injector = inject(InjectorService);
|
|
24
|
+
this.cliService = inject(CliService);
|
|
25
|
+
}
|
|
22
26
|
static checkNodeVersion(wanted, id) {
|
|
23
27
|
if (!semver.satisfies(process.version, wanted)) {
|
|
24
28
|
console.log(chalk.red("You are using Node " +
|
|
@@ -35,7 +39,7 @@ let CliCore = CliCore_1 = class CliCore {
|
|
|
35
39
|
static async create(settings, module = CliCore_1) {
|
|
36
40
|
settings = resolveConfiguration(settings);
|
|
37
41
|
const injector = this.createInjector(settings);
|
|
38
|
-
settings.plugins && (await loadPlugins(
|
|
42
|
+
settings.plugins && (await loadPlugins());
|
|
39
43
|
await this.loadInjector(injector, module);
|
|
40
44
|
await injector.emit("$onReady");
|
|
41
45
|
return injector.get(CliCore_1);
|
|
@@ -89,14 +93,6 @@ let CliCore = CliCore_1 = class CliCore {
|
|
|
89
93
|
return this;
|
|
90
94
|
}
|
|
91
95
|
};
|
|
92
|
-
__decorate([
|
|
93
|
-
Inject(),
|
|
94
|
-
__metadata("design:type", InjectorService)
|
|
95
|
-
], CliCore.prototype, "injector", void 0);
|
|
96
|
-
__decorate([
|
|
97
|
-
Inject(),
|
|
98
|
-
__metadata("design:type", CliService)
|
|
99
|
-
], CliCore.prototype, "cliService", void 0);
|
|
100
96
|
CliCore = CliCore_1 = __decorate([
|
|
101
97
|
Module({
|
|
102
98
|
imports: [CliPackageJson, ProjectPackageJson, CliService, CliConfiguration]
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import { __decorate
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
2
|
import { setValue } from "@tsed/core";
|
|
3
|
-
import {
|
|
3
|
+
import { inject, Injectable } from "@tsed/di";
|
|
4
4
|
import { snakeCase } from "change-case";
|
|
5
5
|
import { join } from "path";
|
|
6
6
|
import { CliFs } from "./CliFs.js";
|
|
7
7
|
import { CliYaml } from "./CliYaml.js";
|
|
8
8
|
import { ProjectPackageJson } from "./ProjectPackageJson.js";
|
|
9
9
|
let CliDockerComposeYaml = class CliDockerComposeYaml {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.cliYaml = inject(CliYaml);
|
|
12
|
+
this.fs = inject(CliFs);
|
|
13
|
+
this.projectPackageJson = inject(ProjectPackageJson);
|
|
14
|
+
}
|
|
10
15
|
read() {
|
|
11
16
|
const path = "docker-compose.yml";
|
|
12
17
|
const file = !this.fs.exists(path) ? this.fs.findUpFile(this.projectPackageJson.dir, path) : path;
|
|
@@ -80,18 +85,6 @@ let CliDockerComposeYaml = class CliDockerComposeYaml {
|
|
|
80
85
|
}
|
|
81
86
|
}
|
|
82
87
|
};
|
|
83
|
-
__decorate([
|
|
84
|
-
Inject(),
|
|
85
|
-
__metadata("design:type", CliYaml)
|
|
86
|
-
], CliDockerComposeYaml.prototype, "cliYaml", void 0);
|
|
87
|
-
__decorate([
|
|
88
|
-
Inject(),
|
|
89
|
-
__metadata("design:type", CliFs)
|
|
90
|
-
], CliDockerComposeYaml.prototype, "fs", void 0);
|
|
91
|
-
__decorate([
|
|
92
|
-
Inject(),
|
|
93
|
-
__metadata("design:type", ProjectPackageJson)
|
|
94
|
-
], CliDockerComposeYaml.prototype, "projectPackageJson", void 0);
|
|
95
88
|
CliDockerComposeYaml = __decorate([
|
|
96
89
|
Injectable()
|
|
97
90
|
], CliDockerComposeYaml);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { __decorate
|
|
2
|
-
import {
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { Injectable, injector } from "@tsed/di";
|
|
3
3
|
let CliHooks = class CliHooks {
|
|
4
4
|
async emit(hookName, cmd, ...args) {
|
|
5
|
-
const
|
|
5
|
+
const inj = injector();
|
|
6
|
+
const providers = inj.getProviders();
|
|
6
7
|
let results = [];
|
|
7
8
|
for (const provider of providers) {
|
|
8
9
|
if (provider.useClass) {
|
|
9
|
-
const instance =
|
|
10
|
+
const instance = inj.get(provider.token);
|
|
10
11
|
if (provider.store.has(hookName)) {
|
|
11
12
|
const props = provider.store.get(hookName)[cmd];
|
|
12
13
|
if (props) {
|
|
@@ -20,10 +21,6 @@ let CliHooks = class CliHooks {
|
|
|
20
21
|
return results.filter((o) => o !== undefined);
|
|
21
22
|
}
|
|
22
23
|
};
|
|
23
|
-
__decorate([
|
|
24
|
-
Inject(),
|
|
25
|
-
__metadata("design:type", InjectorService)
|
|
26
|
-
], CliHooks.prototype, "injector", void 0);
|
|
27
24
|
CliHooks = __decorate([
|
|
28
25
|
Injectable()
|
|
29
26
|
], CliHooks);
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
var CliHttpClient_1;
|
|
2
|
-
import { __decorate
|
|
2
|
+
import { __decorate } from "tslib";
|
|
3
3
|
import { cleanObject } from "@tsed/core";
|
|
4
|
-
import {
|
|
4
|
+
import { inject, Injectable } from "@tsed/di";
|
|
5
5
|
import axios, {} from "axios";
|
|
6
6
|
import { stringify } from "querystring";
|
|
7
7
|
import { URL } from "url";
|
|
8
8
|
import { CliHttpLogClient } from "./CliHttpLogClient.js";
|
|
9
9
|
import { CliProxyAgent } from "./CliProxyAgent.js";
|
|
10
10
|
let CliHttpClient = CliHttpClient_1 = class CliHttpClient extends CliHttpLogClient {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.cliProxyAgent = inject(CliProxyAgent);
|
|
14
|
+
}
|
|
11
15
|
static getParamsSerializer(params) {
|
|
12
16
|
return stringify(cleanObject(params));
|
|
13
17
|
}
|
|
@@ -93,10 +97,6 @@ let CliHttpClient = CliHttpClient_1 = class CliHttpClient extends CliHttpLogClie
|
|
|
93
97
|
return withHeaders ? { data, headers: result?.headers } : data;
|
|
94
98
|
}
|
|
95
99
|
};
|
|
96
|
-
__decorate([
|
|
97
|
-
Inject(),
|
|
98
|
-
__metadata("design:type", CliProxyAgent)
|
|
99
|
-
], CliHttpClient.prototype, "cliProxyAgent", void 0);
|
|
100
100
|
CliHttpClient = CliHttpClient_1 = __decorate([
|
|
101
101
|
Injectable()
|
|
102
102
|
], CliHttpClient);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { __decorate, __metadata, __param } from "tslib";
|
|
2
2
|
import { getValue } from "@tsed/core";
|
|
3
|
-
import {
|
|
3
|
+
import { inject, Opts } from "@tsed/di";
|
|
4
4
|
import { Logger } from "@tsed/logger";
|
|
5
5
|
import querystring from "querystring";
|
|
6
6
|
import { logToCurl } from "../utils/logToCurl.js";
|
|
7
7
|
let CliHttpLogClient = class CliHttpLogClient {
|
|
8
8
|
// @ts-ignore
|
|
9
9
|
constructor(options = {}) {
|
|
10
|
+
this.logger = inject(Logger);
|
|
10
11
|
this.callee = options.callee || "http";
|
|
11
12
|
}
|
|
12
13
|
onSuccess(options) {
|
|
@@ -68,10 +69,6 @@ let CliHttpLogClient = class CliHttpLogClient {
|
|
|
68
69
|
};
|
|
69
70
|
}
|
|
70
71
|
};
|
|
71
|
-
__decorate([
|
|
72
|
-
Inject(),
|
|
73
|
-
__metadata("design:type", Logger)
|
|
74
|
-
], CliHttpLogClient.prototype, "logger", void 0);
|
|
75
72
|
CliHttpLogClient = __decorate([
|
|
76
73
|
__param(0, Opts),
|
|
77
74
|
__metadata("design:paramtypes", [Object])
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import {
|
|
2
|
+
import { inject, Injectable } from "@tsed/di";
|
|
3
3
|
import { default as Ajv } from "ajv";
|
|
4
4
|
import { extname } from "path";
|
|
5
5
|
import { CliFs } from "./CliFs.js";
|
|
@@ -8,6 +8,8 @@ let CliLoadFile = class CliLoadFile {
|
|
|
8
8
|
// @ts-ignore
|
|
9
9
|
#ajv;
|
|
10
10
|
constructor() {
|
|
11
|
+
this.cliYaml = inject(CliYaml);
|
|
12
|
+
this.cliFs = inject(CliFs);
|
|
11
13
|
const options = {
|
|
12
14
|
verbose: false,
|
|
13
15
|
coerceTypes: true,
|
|
@@ -48,14 +50,6 @@ let CliLoadFile = class CliLoadFile {
|
|
|
48
50
|
return config;
|
|
49
51
|
}
|
|
50
52
|
};
|
|
51
|
-
__decorate([
|
|
52
|
-
Inject(),
|
|
53
|
-
__metadata("design:type", CliYaml)
|
|
54
|
-
], CliLoadFile.prototype, "cliYaml", void 0);
|
|
55
|
-
__decorate([
|
|
56
|
-
Inject(),
|
|
57
|
-
__metadata("design:type", CliFs)
|
|
58
|
-
], CliLoadFile.prototype, "cliFs", void 0);
|
|
59
53
|
CliLoadFile = __decorate([
|
|
60
54
|
Injectable(),
|
|
61
55
|
__metadata("design:paramtypes", [])
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { Configuration, Inject, registerProvider } from "@tsed/di";
|
|
1
|
+
import { Configuration, Inject, inject, registerProvider } from "@tsed/di";
|
|
2
2
|
import {} from "../interfaces/PackageJson.js";
|
|
3
3
|
export function CliPackageJson() {
|
|
4
4
|
return Inject(CliPackageJson);
|
|
5
5
|
}
|
|
6
|
+
export function cliPackageJson() {
|
|
7
|
+
return inject(CliPackageJson);
|
|
8
|
+
}
|
|
6
9
|
registerProvider({
|
|
7
10
|
provide: CliPackageJson,
|
|
8
11
|
deps: [Configuration],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { __decorate
|
|
2
|
-
import {
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { constant, inject, Injectable } from "@tsed/di";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import { CommandStoreKeys } from "../domains/CommandStoreKeys.js";
|
|
5
5
|
import { PackageManagersModule } from "../packageManagers/PackageManagersModule.js";
|
|
@@ -16,13 +16,18 @@ function mapPlugins({ package: { name, description = "", ...otherProps } }) {
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
let CliPlugins = class CliPlugins {
|
|
19
|
+
constructor() {
|
|
20
|
+
this.name = constant("name", "");
|
|
21
|
+
this.loadPlugins = loadPlugins;
|
|
22
|
+
this.npmRegistryClient = inject(NpmRegistryClient);
|
|
23
|
+
this.cliHooks = inject(CliHooks);
|
|
24
|
+
this.packageJson = inject(ProjectPackageJson);
|
|
25
|
+
this.packageManagers = inject(PackageManagersModule);
|
|
26
|
+
}
|
|
19
27
|
async searchPlugins(keyword = "", options = {}) {
|
|
20
28
|
const result = await this.npmRegistryClient.search(this.getKeyword(keyword), options);
|
|
21
29
|
return result.filter(({ package: { name } }) => this.isPlugin(name)).map(mapPlugins);
|
|
22
30
|
}
|
|
23
|
-
loadPlugins() {
|
|
24
|
-
return loadPlugins(this.injector);
|
|
25
|
-
}
|
|
26
31
|
addPluginsDependencies(ctx) {
|
|
27
32
|
const plugins = Object.keys(this.packageJson.devDependencies).filter((name) => this.isPlugin(name));
|
|
28
33
|
const tasks = plugins.map((plugin) => {
|
|
@@ -53,30 +58,6 @@ let CliPlugins = class CliPlugins {
|
|
|
53
58
|
return name.startsWith(`@${this.name}/cli-plugin`) || name.includes(`${this.name}-cli-plugin`);
|
|
54
59
|
}
|
|
55
60
|
};
|
|
56
|
-
__decorate([
|
|
57
|
-
Constant("name"),
|
|
58
|
-
__metadata("design:type", String)
|
|
59
|
-
], CliPlugins.prototype, "name", void 0);
|
|
60
|
-
__decorate([
|
|
61
|
-
Inject(NpmRegistryClient),
|
|
62
|
-
__metadata("design:type", NpmRegistryClient)
|
|
63
|
-
], CliPlugins.prototype, "npmRegistryClient", void 0);
|
|
64
|
-
__decorate([
|
|
65
|
-
Inject(InjectorService),
|
|
66
|
-
__metadata("design:type", InjectorService)
|
|
67
|
-
], CliPlugins.prototype, "injector", void 0);
|
|
68
|
-
__decorate([
|
|
69
|
-
Inject(CliHooks),
|
|
70
|
-
__metadata("design:type", CliHooks)
|
|
71
|
-
], CliPlugins.prototype, "cliHooks", void 0);
|
|
72
|
-
__decorate([
|
|
73
|
-
Inject(ProjectPackageJson),
|
|
74
|
-
__metadata("design:type", ProjectPackageJson)
|
|
75
|
-
], CliPlugins.prototype, "packageJson", void 0);
|
|
76
|
-
__decorate([
|
|
77
|
-
Inject(PackageManagersModule),
|
|
78
|
-
__metadata("design:type", PackageManagersModule)
|
|
79
|
-
], CliPlugins.prototype, "packageManagers", void 0);
|
|
80
61
|
CliPlugins = __decorate([
|
|
81
62
|
Injectable()
|
|
82
63
|
], CliPlugins);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { __decorate
|
|
2
|
-
import { Configuration, Inject, Injectable,
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { Configuration, Inject, inject, Injectable, refValue } from "@tsed/di";
|
|
3
3
|
import { camelCase } from "change-case";
|
|
4
4
|
import tunnel from "tunnel";
|
|
5
5
|
import { URL } from "url";
|
|
@@ -7,13 +7,18 @@ import { coerce } from "../utils/coerce.js";
|
|
|
7
7
|
import { CliExeca } from "./CliExeca.js";
|
|
8
8
|
import { ProjectPackageJson } from "./ProjectPackageJson.js";
|
|
9
9
|
let CliProxyAgent = class CliProxyAgent {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.proxySettings = refValue("proxy", {});
|
|
12
|
+
this.projectPackageJson = Inject(ProjectPackageJson);
|
|
13
|
+
this.cliExeca = inject(CliExeca);
|
|
14
|
+
}
|
|
10
15
|
hasProxy() {
|
|
11
|
-
return !!this.proxySettings.url;
|
|
16
|
+
return !!this.proxySettings.value.url;
|
|
12
17
|
}
|
|
13
18
|
get(type) {
|
|
14
19
|
if (this.hasProxy()) {
|
|
15
|
-
const { strictSsl = true } = this.proxySettings;
|
|
16
|
-
const url = new URL(this.proxySettings.url);
|
|
20
|
+
const { strictSsl = true } = this.proxySettings.value;
|
|
21
|
+
const url = new URL(this.proxySettings.value.url);
|
|
17
22
|
const protocol = url.protocol.replace(":", "");
|
|
18
23
|
const options = {
|
|
19
24
|
proxy: {
|
|
@@ -60,25 +65,13 @@ let CliProxyAgent = class CliProxyAgent {
|
|
|
60
65
|
const [proxy, httpProxy, httpsProxy, strictSsl] = result.map(coerce);
|
|
61
66
|
const url = httpsProxy || httpProxy || proxy;
|
|
62
67
|
if (url) {
|
|
63
|
-
this.proxySettings = {
|
|
68
|
+
this.proxySettings.value = {
|
|
64
69
|
url,
|
|
65
70
|
strictSsl: coerce(strictSsl) !== false
|
|
66
71
|
};
|
|
67
72
|
}
|
|
68
73
|
}
|
|
69
74
|
};
|
|
70
|
-
__decorate([
|
|
71
|
-
Value("proxy", {}),
|
|
72
|
-
__metadata("design:type", Object)
|
|
73
|
-
], CliProxyAgent.prototype, "proxySettings", void 0);
|
|
74
|
-
__decorate([
|
|
75
|
-
Inject(),
|
|
76
|
-
__metadata("design:type", ProjectPackageJson)
|
|
77
|
-
], CliProxyAgent.prototype, "projectPackageJson", void 0);
|
|
78
|
-
__decorate([
|
|
79
|
-
Inject(),
|
|
80
|
-
__metadata("design:type", CliExeca)
|
|
81
|
-
], CliProxyAgent.prototype, "cliExeca", void 0);
|
|
82
75
|
CliProxyAgent = __decorate([
|
|
83
76
|
Injectable(),
|
|
84
77
|
Configuration({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { __decorate
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
2
|
// @ts-ignore
|
|
3
3
|
import runScript from "@npmcli/run-script";
|
|
4
|
-
import {
|
|
4
|
+
import { inject, Injectable } from "@tsed/di";
|
|
5
5
|
import { ProjectPackageJson } from "./ProjectPackageJson.js";
|
|
6
6
|
let CliRunScript = class CliRunScript {
|
|
7
7
|
run(cmd, args, options = {}) {
|
|
@@ -9,17 +9,13 @@ let CliRunScript = class CliRunScript {
|
|
|
9
9
|
event: "run",
|
|
10
10
|
...options,
|
|
11
11
|
cmd: `${cmd} ${args.join(" ")}`,
|
|
12
|
-
path: options.cwd ||
|
|
12
|
+
path: options.cwd || inject(ProjectPackageJson).dir,
|
|
13
13
|
env: options.env || {},
|
|
14
14
|
stdio: options.stdio || "inherit",
|
|
15
15
|
banner: false
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
|
-
__decorate([
|
|
20
|
-
Inject(),
|
|
21
|
-
__metadata("design:type", ProjectPackageJson)
|
|
22
|
-
], CliRunScript.prototype, "projectPackageJson", void 0);
|
|
23
19
|
CliRunScript = __decorate([
|
|
24
20
|
Injectable()
|
|
25
21
|
], CliRunScript);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { __decorate
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
2
|
import { classOf } from "@tsed/core";
|
|
3
|
-
import {
|
|
3
|
+
import { $emit, configuration, constant, destroyInjector, DIContext, getContext, inject, Injectable, injector, logger, Provider, runInContext } from "@tsed/di";
|
|
4
4
|
import { Argument, Command } from "commander";
|
|
5
5
|
import Inquirer from "inquirer";
|
|
6
6
|
// @ts-ignore
|
|
@@ -18,8 +18,12 @@ import { ProjectPackageJson } from "./ProjectPackageJson.js";
|
|
|
18
18
|
Inquirer.registerPrompt("autocomplete", inquirer_autocomplete_prompt);
|
|
19
19
|
let CliService = class CliService {
|
|
20
20
|
constructor() {
|
|
21
|
+
this.reinstallAfterRun = constant("project.reinstallAfterRun", false);
|
|
21
22
|
this.program = new Command();
|
|
22
|
-
this.
|
|
23
|
+
this.pkg = constant("pkg", { version: "1.0.0" });
|
|
24
|
+
this.hooks = inject(CliHooks);
|
|
25
|
+
this.projectPkg = inject(ProjectPackageJson);
|
|
26
|
+
this.packageManagers = inject(PackageManagersModule);
|
|
23
27
|
this.commands = new Map();
|
|
24
28
|
}
|
|
25
29
|
/**
|
|
@@ -40,7 +44,7 @@ let CliService = class CliService {
|
|
|
40
44
|
*/
|
|
41
45
|
runLifecycle(cmdName, data = {}, $ctx) {
|
|
42
46
|
return runInContext($ctx, async () => {
|
|
43
|
-
await
|
|
47
|
+
await $emit("$loadPackageJson");
|
|
44
48
|
data = await this.beforePrompt(cmdName, data);
|
|
45
49
|
$ctx.set("data", data);
|
|
46
50
|
data = await this.prompt(cmdName, data);
|
|
@@ -54,12 +58,12 @@ let CliService = class CliService {
|
|
|
54
58
|
await this.exec(cmdName, data, $ctx);
|
|
55
59
|
}
|
|
56
60
|
catch (er) {
|
|
57
|
-
await
|
|
58
|
-
await
|
|
61
|
+
await $emit("$onFinish", er);
|
|
62
|
+
await destroyInjector();
|
|
59
63
|
throw er;
|
|
60
64
|
}
|
|
61
|
-
await
|
|
62
|
-
await
|
|
65
|
+
await $emit("$onFinish");
|
|
66
|
+
await destroyInjector();
|
|
63
67
|
}
|
|
64
68
|
async exec(cmdName, data, $ctx) {
|
|
65
69
|
const initialTasks = await this.getTasks(cmdName, data);
|
|
@@ -83,7 +87,7 @@ let CliService = class CliService {
|
|
|
83
87
|
*/
|
|
84
88
|
async beforePrompt(cmdName, ctx = {}) {
|
|
85
89
|
const provider = this.commands.get(cmdName);
|
|
86
|
-
const instance =
|
|
90
|
+
const instance = inject(provider.useClass);
|
|
87
91
|
const verbose = ctx.verbose;
|
|
88
92
|
if (instance.$beforePrompt) {
|
|
89
93
|
ctx = await instance.$beforePrompt(JSON.parse(JSON.stringify(ctx)));
|
|
@@ -98,7 +102,7 @@ let CliService = class CliService {
|
|
|
98
102
|
*/
|
|
99
103
|
async prompt(cmdName, ctx = {}) {
|
|
100
104
|
const provider = this.commands.get(cmdName);
|
|
101
|
-
const instance =
|
|
105
|
+
const instance = inject(provider.useClass);
|
|
102
106
|
if (instance.$prompt) {
|
|
103
107
|
const questions = [
|
|
104
108
|
...(await instance.$prompt(ctx)),
|
|
@@ -121,7 +125,7 @@ let CliService = class CliService {
|
|
|
121
125
|
async getTasks(cmdName, data) {
|
|
122
126
|
const $ctx = getContext();
|
|
123
127
|
const provider = this.commands.get(cmdName);
|
|
124
|
-
const instance =
|
|
128
|
+
const instance = inject(provider.token);
|
|
125
129
|
data = this.mapData(cmdName, data, $ctx);
|
|
126
130
|
if (instance.$beforeExec) {
|
|
127
131
|
await instance.$beforeExec(data);
|
|
@@ -130,7 +134,7 @@ let CliService = class CliService {
|
|
|
130
134
|
}
|
|
131
135
|
async getPostInstallTasks(cmdName, data) {
|
|
132
136
|
const provider = this.commands.get(cmdName);
|
|
133
|
-
const instance =
|
|
137
|
+
const instance = inject(provider.useClass);
|
|
134
138
|
data = this.mapData(cmdName, data, getContext());
|
|
135
139
|
return [
|
|
136
140
|
...(instance.$postInstall ? await instance.$postInstall(data) : []),
|
|
@@ -157,15 +161,15 @@ let CliService = class CliService {
|
|
|
157
161
|
};
|
|
158
162
|
const $ctx = new DIContext({
|
|
159
163
|
id: v4(),
|
|
160
|
-
injector:
|
|
161
|
-
logger:
|
|
162
|
-
level:
|
|
164
|
+
injector: injector(),
|
|
165
|
+
logger: logger(),
|
|
166
|
+
level: logger().level,
|
|
163
167
|
maxStackSize: 0,
|
|
164
168
|
platform: "CLI"
|
|
165
169
|
});
|
|
166
170
|
$ctx.set("data", data);
|
|
167
171
|
$ctx.set("command", metadata);
|
|
168
|
-
|
|
172
|
+
configuration().set("command.metadata", metadata);
|
|
169
173
|
return this.runLifecycle(name, data, $ctx);
|
|
170
174
|
};
|
|
171
175
|
if (alias) {
|
|
@@ -180,21 +184,23 @@ let CliService = class CliService {
|
|
|
180
184
|
return cmd;
|
|
181
185
|
}
|
|
182
186
|
load() {
|
|
183
|
-
|
|
187
|
+
injector()
|
|
188
|
+
.getProviders("command")
|
|
189
|
+
.forEach((provider) => this.build(provider));
|
|
184
190
|
}
|
|
185
191
|
mapData(cmdName, data, $ctx) {
|
|
186
192
|
const provider = this.commands.get(cmdName);
|
|
187
|
-
const instance =
|
|
193
|
+
const instance = inject(provider.useClass);
|
|
188
194
|
const verbose = data.verbose;
|
|
189
195
|
if (instance.$mapContext) {
|
|
190
196
|
data = instance.$mapContext(JSON.parse(JSON.stringify(data)));
|
|
191
197
|
data.verbose = verbose;
|
|
192
198
|
}
|
|
193
199
|
if (data.verbose) {
|
|
194
|
-
|
|
200
|
+
logger().level = "debug";
|
|
195
201
|
}
|
|
196
202
|
else {
|
|
197
|
-
|
|
203
|
+
logger().level = "info";
|
|
198
204
|
}
|
|
199
205
|
data.bindLogger = $ctx.get("command").bindLogger;
|
|
200
206
|
$ctx.set("data", data);
|
|
@@ -249,30 +255,6 @@ let CliService = class CliService {
|
|
|
249
255
|
}, cmd);
|
|
250
256
|
}
|
|
251
257
|
};
|
|
252
|
-
__decorate([
|
|
253
|
-
Constant("project.reinstallAfterRun", false),
|
|
254
|
-
__metadata("design:type", Object)
|
|
255
|
-
], CliService.prototype, "reinstallAfterRun", void 0);
|
|
256
|
-
__decorate([
|
|
257
|
-
Constant("pkg", { version: "1.0.0" }),
|
|
258
|
-
__metadata("design:type", Object)
|
|
259
|
-
], CliService.prototype, "pkg", void 0);
|
|
260
|
-
__decorate([
|
|
261
|
-
Inject(),
|
|
262
|
-
__metadata("design:type", InjectorService)
|
|
263
|
-
], CliService.prototype, "injector", void 0);
|
|
264
|
-
__decorate([
|
|
265
|
-
Inject(),
|
|
266
|
-
__metadata("design:type", CliHooks)
|
|
267
|
-
], CliService.prototype, "hooks", void 0);
|
|
268
|
-
__decorate([
|
|
269
|
-
Inject(),
|
|
270
|
-
__metadata("design:type", ProjectPackageJson)
|
|
271
|
-
], CliService.prototype, "projectPkg", void 0);
|
|
272
|
-
__decorate([
|
|
273
|
-
Inject(PackageManagersModule),
|
|
274
|
-
__metadata("design:type", PackageManagersModule)
|
|
275
|
-
], CliService.prototype, "packageManagers", void 0);
|
|
276
258
|
CliService = __decorate([
|
|
277
259
|
Injectable()
|
|
278
260
|
], CliService);
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { __decorate
|
|
2
|
-
import {
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { inject, Injectable } from "@tsed/di";
|
|
3
3
|
import JsYaml from "js-yaml";
|
|
4
4
|
import { CliFs } from "./CliFs.js";
|
|
5
5
|
let CliYaml = class CliYaml {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.fs = inject(CliFs);
|
|
8
|
+
}
|
|
6
9
|
async read(path) {
|
|
7
10
|
const content = await this.fs.readFile(path, { encoding: "utf8" });
|
|
8
11
|
return JsYaml.load(content);
|
|
@@ -12,10 +15,6 @@ let CliYaml = class CliYaml {
|
|
|
12
15
|
return this.fs.writeFile(path, content, { encoding: "utf8" });
|
|
13
16
|
}
|
|
14
17
|
};
|
|
15
|
-
__decorate([
|
|
16
|
-
Inject(),
|
|
17
|
-
__metadata("design:type", CliFs)
|
|
18
|
-
], CliYaml.prototype, "fs", void 0);
|
|
19
18
|
CliYaml = __decorate([
|
|
20
19
|
Injectable()
|
|
21
20
|
], CliYaml);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var NpmRegistryClient_1;
|
|
2
|
-
import { __decorate
|
|
3
|
-
import {
|
|
2
|
+
import { __decorate } from "tslib";
|
|
3
|
+
import { inject, Injectable } from "@tsed/di";
|
|
4
4
|
import registry_url from "registry-url";
|
|
5
5
|
import url from "url";
|
|
6
6
|
import { CliHttpClient } from "./CliHttpClient.js";
|
|
@@ -15,6 +15,9 @@ export function addSuffix(pattern, suffix) {
|
|
|
15
15
|
}
|
|
16
16
|
export const SCOPE_SEPARATOR = "%2f";
|
|
17
17
|
let NpmRegistryClient = NpmRegistryClient_1 = class NpmRegistryClient {
|
|
18
|
+
constructor() {
|
|
19
|
+
this.httpClient = inject(CliHttpClient);
|
|
20
|
+
}
|
|
18
21
|
static escapeName(name) {
|
|
19
22
|
// scoped packages contain slashes and the npm registry expects them to be escaped
|
|
20
23
|
return name.replace("/", SCOPE_SEPARATOR);
|
|
@@ -106,10 +109,6 @@ let NpmRegistryClient = NpmRegistryClient_1 = class NpmRegistryClient {
|
|
|
106
109
|
};
|
|
107
110
|
}
|
|
108
111
|
};
|
|
109
|
-
__decorate([
|
|
110
|
-
Inject(CliHttpClient),
|
|
111
|
-
__metadata("design:type", CliHttpClient)
|
|
112
|
-
], NpmRegistryClient.prototype, "httpClient", void 0);
|
|
113
112
|
NpmRegistryClient = NpmRegistryClient_1 = __decorate([
|
|
114
113
|
Injectable()
|
|
115
114
|
], NpmRegistryClient);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { __decorate, __metadata
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
2
|
import { getValue, setValue } from "@tsed/core";
|
|
3
|
-
import {
|
|
3
|
+
import { configuration, constant, inject, Injectable } from "@tsed/di";
|
|
4
4
|
import { dirname, join } from "path";
|
|
5
5
|
import { readPackageUpSync } from "read-pkg-up";
|
|
6
6
|
import { isValidVersion } from "../utils/isValidVersion.js";
|
|
@@ -29,11 +29,10 @@ function mapPackages(deps) {
|
|
|
29
29
|
}, { valid: {}, invalid: {} });
|
|
30
30
|
}
|
|
31
31
|
let ProjectPackageJson = class ProjectPackageJson {
|
|
32
|
-
constructor(
|
|
33
|
-
this.configuration = configuration;
|
|
34
|
-
this.fs = fs;
|
|
32
|
+
constructor() {
|
|
35
33
|
this.rewrite = false;
|
|
36
34
|
this.reinstall = false;
|
|
35
|
+
this.fs = inject(CliFs);
|
|
37
36
|
this.setRaw({
|
|
38
37
|
name: "",
|
|
39
38
|
version: "1.0.0",
|
|
@@ -48,10 +47,10 @@ let ProjectPackageJson = class ProjectPackageJson {
|
|
|
48
47
|
return join(this.dir, "package.json");
|
|
49
48
|
}
|
|
50
49
|
get dir() {
|
|
51
|
-
return String(
|
|
50
|
+
return String(constant("project.rootDir"));
|
|
52
51
|
}
|
|
53
52
|
set dir(dir) {
|
|
54
|
-
|
|
53
|
+
configuration().project.rootDir = dir;
|
|
55
54
|
this.read();
|
|
56
55
|
}
|
|
57
56
|
get name() {
|
|
@@ -83,7 +82,7 @@ let ProjectPackageJson = class ProjectPackageJson {
|
|
|
83
82
|
};
|
|
84
83
|
}
|
|
85
84
|
get preferences() {
|
|
86
|
-
return this.raw[
|
|
85
|
+
return this.raw[constant("name")];
|
|
87
86
|
}
|
|
88
87
|
$loadPackageJson() {
|
|
89
88
|
return this.read();
|
|
@@ -97,11 +96,12 @@ let ProjectPackageJson = class ProjectPackageJson {
|
|
|
97
96
|
return this;
|
|
98
97
|
}
|
|
99
98
|
setRaw(pkg) {
|
|
100
|
-
const
|
|
101
|
-
const
|
|
99
|
+
const config = configuration();
|
|
100
|
+
const projectPreferences = config.defaultProjectPreferences;
|
|
101
|
+
const preferences = getValue(pkg, config.name);
|
|
102
102
|
this.raw = {
|
|
103
103
|
...pkg,
|
|
104
|
-
[
|
|
104
|
+
[config.name]: {
|
|
105
105
|
...(projectPreferences && projectPreferences(pkg)),
|
|
106
106
|
...preferences
|
|
107
107
|
}
|
|
@@ -150,7 +150,7 @@ let ProjectPackageJson = class ProjectPackageJson {
|
|
|
150
150
|
return this;
|
|
151
151
|
}
|
|
152
152
|
setPreference(key, value) {
|
|
153
|
-
setValue(this.raw, `${
|
|
153
|
+
setValue(this.raw, `${constant("name")}.${key}`, value);
|
|
154
154
|
this.rewrite = true;
|
|
155
155
|
return;
|
|
156
156
|
}
|
|
@@ -212,7 +212,7 @@ let ProjectPackageJson = class ProjectPackageJson {
|
|
|
212
212
|
refresh() {
|
|
213
213
|
this.reinstall = false;
|
|
214
214
|
this.rewrite = false;
|
|
215
|
-
const cwd =
|
|
215
|
+
const cwd = constant("project.rootDir");
|
|
216
216
|
const pkgPath = join(String(cwd), "package.json");
|
|
217
217
|
const pkg = this.fs.readJsonSync(pkgPath, { encoding: "utf8" });
|
|
218
218
|
pkg.scripts = {
|
|
@@ -227,17 +227,18 @@ let ProjectPackageJson = class ProjectPackageJson {
|
|
|
227
227
|
...this.raw.devDependencies,
|
|
228
228
|
...pkg.devDependencies
|
|
229
229
|
};
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
...
|
|
230
|
+
const name = constant("name");
|
|
231
|
+
pkg[name] = {
|
|
232
|
+
...this.raw[name],
|
|
233
|
+
...pkg[name]
|
|
233
234
|
};
|
|
234
235
|
this.raw = pkg;
|
|
235
236
|
return this;
|
|
236
237
|
}
|
|
237
238
|
getPackageJson() {
|
|
238
|
-
const cwd =
|
|
239
|
-
const disableReadUpPkg =
|
|
240
|
-
const name =
|
|
239
|
+
const cwd = constant("project.rootDir");
|
|
240
|
+
const disableReadUpPkg = constant("command.metadata.disableReadUpPkg");
|
|
241
|
+
const name = constant("name");
|
|
241
242
|
const pkgPath = join(String(cwd), "package.json");
|
|
242
243
|
const fileExists = this.fs.exists(pkgPath);
|
|
243
244
|
if (!disableReadUpPkg && !fileExists) {
|
|
@@ -246,14 +247,14 @@ let ProjectPackageJson = class ProjectPackageJson {
|
|
|
246
247
|
});
|
|
247
248
|
if (result && result.path) {
|
|
248
249
|
const pkgPath = dirname(result.path);
|
|
249
|
-
|
|
250
|
+
configuration().set("project.root", pkgPath);
|
|
250
251
|
const pkg = this.fs.readJsonSync(result.path, { encoding: "utf8" });
|
|
251
252
|
return { ...this.getEmptyPackageJson(name), ...pkg };
|
|
252
253
|
}
|
|
253
254
|
}
|
|
254
255
|
if (disableReadUpPkg && fileExists) {
|
|
255
256
|
const pkg = this.fs.readJsonSync(pkgPath, { encoding: "utf8" });
|
|
256
|
-
|
|
257
|
+
configuration().set("project.root", pkgPath);
|
|
257
258
|
return { ...this.getEmptyPackageJson(name), ...pkg };
|
|
258
259
|
}
|
|
259
260
|
return this.getEmptyPackageJson(name);
|
|
@@ -271,7 +272,6 @@ let ProjectPackageJson = class ProjectPackageJson {
|
|
|
271
272
|
};
|
|
272
273
|
ProjectPackageJson = __decorate([
|
|
273
274
|
Injectable({}),
|
|
274
|
-
|
|
275
|
-
__metadata("design:paramtypes", [Object, CliFs])
|
|
275
|
+
__metadata("design:paramtypes", [])
|
|
276
276
|
], ProjectPackageJson);
|
|
277
277
|
export { ProjectPackageJson };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { __decorate
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
2
|
import "../utils/hbs/index.js";
|
|
3
3
|
import { isString } from "@tsed/core";
|
|
4
|
-
import { Configuration,
|
|
4
|
+
import { Configuration, constant, inject, Injectable } from "@tsed/di";
|
|
5
5
|
import { normalizePath } from "@tsed/normalize-path";
|
|
6
6
|
import Consolidate from "consolidate";
|
|
7
7
|
import fs from "fs-extra";
|
|
@@ -14,7 +14,10 @@ import { insertImport } from "../utils/renderer/insertImport.js";
|
|
|
14
14
|
import { CliFs } from "./CliFs.js";
|
|
15
15
|
export class Renderer {
|
|
16
16
|
constructor() {
|
|
17
|
+
this.templateDir = constant("templateDir", "");
|
|
18
|
+
this.fs = inject(CliFs);
|
|
17
19
|
this.cache = new Set();
|
|
20
|
+
this.configuration = inject(Configuration);
|
|
18
21
|
}
|
|
19
22
|
async loadPartials(cwd) {
|
|
20
23
|
if (this.cache.has(cwd)) {
|
|
@@ -131,18 +134,6 @@ export class Renderer {
|
|
|
131
134
|
return { output, templateDir, rootDir };
|
|
132
135
|
}
|
|
133
136
|
}
|
|
134
|
-
__decorate([
|
|
135
|
-
Constant("templateDir"),
|
|
136
|
-
__metadata("design:type", String)
|
|
137
|
-
], Renderer.prototype, "templateDir", void 0);
|
|
138
|
-
__decorate([
|
|
139
|
-
Inject(),
|
|
140
|
-
__metadata("design:type", CliFs)
|
|
141
|
-
], Renderer.prototype, "fs", void 0);
|
|
142
|
-
__decorate([
|
|
143
|
-
Configuration(),
|
|
144
|
-
__metadata("design:type", Object)
|
|
145
|
-
], Renderer.prototype, "configuration", void 0);
|
|
146
137
|
let RootRendererService = class RootRendererService extends Renderer {
|
|
147
138
|
get rootDir() {
|
|
148
139
|
return this.configuration.project?.rootDir;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InjectorService } from "@tsed/di";
|
|
1
|
+
import { injector, InjectorService } from "@tsed/di";
|
|
2
2
|
import { Logger } from "@tsed/logger";
|
|
3
3
|
import { CliConfiguration } from "../services/CliConfiguration.js";
|
|
4
4
|
import { ProjectPackageJson } from "../services/ProjectPackageJson.js";
|
|
@@ -11,19 +11,19 @@ function createConfiguration(injector) {
|
|
|
11
11
|
return injector.invoke(CliConfiguration);
|
|
12
12
|
}
|
|
13
13
|
export function createInjector(settings = {}) {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
logger =
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
const inj = injector();
|
|
15
|
+
inj.settings = createConfiguration(inj);
|
|
16
|
+
logger = inj.logger = new Logger(settings.name || "CLI");
|
|
17
|
+
inj.addProvider(ProjectPackageJson);
|
|
18
|
+
inj.settings.set(settings);
|
|
19
19
|
/* istanbul ignore next */
|
|
20
|
-
if (
|
|
21
|
-
|
|
20
|
+
if (inj.settings.env === "test") {
|
|
21
|
+
inj.logger.stop();
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
24
|
/* istanbul ignore next */
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
inj.logger.level = inj.settings.logger?.level || "warn";
|
|
26
|
+
inj.logger.appenders
|
|
27
27
|
.set("stdout", {
|
|
28
28
|
type: "stdout",
|
|
29
29
|
layout: {
|
|
@@ -41,5 +41,5 @@ export function createInjector(settings = {}) {
|
|
|
41
41
|
levels: ["trace", "fatal", "error", "warn"]
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
|
-
return
|
|
44
|
+
return inj;
|
|
45
45
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Store
|
|
1
|
+
import { Store } from "@tsed/core";
|
|
2
2
|
import { CommandStoreKeys } from "../domains/CommandStoreKeys.js";
|
|
3
3
|
export function getCommandMetadata(token) {
|
|
4
4
|
const { name, alias, args = {}, allowUnknownOption, description, options = {}, enableFeatures, disableReadUpPkg, bindLogger = true, ...opts } = Store.from(token)?.get(CommandStoreKeys.COMMAND);
|
|
@@ -1,38 +1,39 @@
|
|
|
1
|
-
import { GlobalProviders,
|
|
1
|
+
import { GlobalProviders, injector, logger } from "@tsed/di";
|
|
2
2
|
import chalk from "chalk";
|
|
3
3
|
import figures from "figures";
|
|
4
4
|
import { CliFs } from "../services/CliFs.js";
|
|
5
5
|
import { ProjectPackageJson } from "../services/ProjectPackageJson.js";
|
|
6
6
|
const all = (promises) => Promise.all(promises);
|
|
7
|
-
export async function loadPlugins(
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
7
|
+
export async function loadPlugins() {
|
|
8
|
+
const $inj = injector();
|
|
9
|
+
const name = $inj.settings.get("name");
|
|
10
|
+
const rootDir = $inj.settings.get("project.rootDir");
|
|
11
|
+
const projectPackageJson = $inj.invoke(ProjectPackageJson);
|
|
12
|
+
const fs = $inj.invoke(CliFs);
|
|
12
13
|
const promises = Object.keys(projectPackageJson.allDependencies)
|
|
13
14
|
.filter((mod) => mod.startsWith(`@${name}/cli-plugin`) || mod.includes(`${name}-cli-plugin`))
|
|
14
15
|
.map(async (mod) => {
|
|
15
16
|
try {
|
|
16
17
|
const { default: plugin } = await fs.importModule(mod, rootDir);
|
|
17
|
-
if (
|
|
18
|
+
if (!$inj.has(plugin)) {
|
|
18
19
|
const provider = GlobalProviders.get(plugin)?.clone();
|
|
19
20
|
if (provider?.imports.length) {
|
|
20
21
|
await all(provider.imports.map(async (token) => {
|
|
21
|
-
|
|
22
|
-
if (
|
|
23
|
-
await
|
|
22
|
+
$inj.add(token, GlobalProviders.get(token)?.clone());
|
|
23
|
+
if ($inj.settings.get("loaded")) {
|
|
24
|
+
await $inj.invoke(token);
|
|
24
25
|
}
|
|
25
26
|
}));
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
-
if (
|
|
29
|
-
await
|
|
28
|
+
$inj.add(plugin, provider);
|
|
29
|
+
if ($inj.settings.get("loaded")) {
|
|
30
|
+
await $inj.invoke(plugin);
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
+
logger().info(chalk.green(figures.tick), mod, "module loaded");
|
|
33
34
|
}
|
|
34
35
|
catch (er) {
|
|
35
|
-
|
|
36
|
+
logger().warn(chalk.red(figures.cross), "Fail to load plugin", mod);
|
|
36
37
|
}
|
|
37
38
|
});
|
|
38
39
|
await all(promises);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Task } from "../interfaces/index.js";
|
|
2
|
+
import { loadPlugins } from "../utils/loadPlugins.js";
|
|
2
3
|
export declare class CliPlugins {
|
|
3
4
|
name: string;
|
|
5
|
+
readonly loadPlugins: typeof loadPlugins;
|
|
4
6
|
private npmRegistryClient;
|
|
5
|
-
private injector;
|
|
6
7
|
private cliHooks;
|
|
7
8
|
private packageJson;
|
|
8
9
|
private packageManagers;
|
|
9
10
|
searchPlugins(keyword?: string, options?: any): Promise<any>;
|
|
10
|
-
loadPlugins(): Promise<void>;
|
|
11
11
|
addPluginsDependencies(ctx: any): Task[];
|
|
12
12
|
protected getKeyword(keyword: string): string;
|
|
13
13
|
protected cleanKeyword(keyword: string): string;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { CliExeca } from "./CliExeca.js";
|
|
2
|
-
import { ProjectPackageJson } from "./ProjectPackageJson.js";
|
|
3
2
|
export interface CliProxySettings {
|
|
4
3
|
url: string;
|
|
5
4
|
strictSsl: boolean;
|
|
6
5
|
}
|
|
7
6
|
export declare class CliProxyAgent {
|
|
8
|
-
proxySettings:
|
|
9
|
-
|
|
7
|
+
readonly proxySettings: {
|
|
8
|
+
value: CliProxySettings;
|
|
9
|
+
};
|
|
10
|
+
protected projectPackageJson: any;
|
|
10
11
|
protected cliExeca: CliExeca;
|
|
11
12
|
hasProxy(): boolean;
|
|
12
13
|
get(type: "http" | "https"): any;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { DIContext
|
|
1
|
+
import { DIContext } from "@tsed/di";
|
|
2
2
|
import { Command } from "commander";
|
|
3
3
|
import type { CommandMetadata } from "../interfaces/CommandMetadata.js";
|
|
4
4
|
import { PackageManagersModule } from "../packageManagers/index.js";
|
|
5
5
|
import { CliHooks } from "./CliHooks.js";
|
|
6
6
|
import { ProjectPackageJson } from "./ProjectPackageJson.js";
|
|
7
7
|
export declare class CliService {
|
|
8
|
+
readonly reinstallAfterRun: boolean;
|
|
8
9
|
readonly program: Command;
|
|
9
|
-
|
|
10
|
-
protected pkg: any;
|
|
11
|
-
protected injector: InjectorService;
|
|
10
|
+
protected pkg: Record<string, any>;
|
|
12
11
|
protected hooks: CliHooks;
|
|
13
12
|
protected projectPkg: ProjectPackageJson;
|
|
14
13
|
protected packageManagers: PackageManagersModule;
|
|
@@ -24,7 +23,7 @@ export declare class CliService {
|
|
|
24
23
|
* @param data
|
|
25
24
|
* @param $ctx
|
|
26
25
|
*/
|
|
27
|
-
runLifecycle(cmdName: string, data: any, $ctx: DIContext): Promise<
|
|
26
|
+
runLifecycle(cmdName: string, data: any, $ctx: DIContext): Promise<Promise<void>>;
|
|
28
27
|
dispatch(cmdName: string, data: any, $ctx: DIContext): Promise<void>;
|
|
29
28
|
exec(cmdName: string, data: any, $ctx: DIContext): Promise<any>;
|
|
30
29
|
/**
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { Configuration } from "@tsed/di";
|
|
2
1
|
import type { PackageJson } from "../interfaces/PackageJson.js";
|
|
3
2
|
import type { ProjectPreferences } from "../interfaces/ProjectPreferences.js";
|
|
4
3
|
import { CliFs } from "./CliFs.js";
|
|
5
4
|
export declare class ProjectPackageJson {
|
|
6
|
-
private configuration;
|
|
7
|
-
protected fs: CliFs;
|
|
8
5
|
rewrite: boolean;
|
|
9
6
|
reinstall: boolean;
|
|
10
7
|
GH_TOKEN: string;
|
|
8
|
+
protected fs: CliFs;
|
|
11
9
|
private raw;
|
|
12
|
-
constructor(
|
|
10
|
+
constructor();
|
|
13
11
|
get path(): string;
|
|
14
12
|
get dir(): string;
|
|
15
13
|
set dir(dir: string);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import "../utils/hbs/index.js";
|
|
2
|
-
import { Configuration } from "@tsed/di";
|
|
3
2
|
import { Observable } from "rxjs";
|
|
4
3
|
import { CliFs } from "./CliFs.js";
|
|
5
4
|
export interface RenderOptions {
|
|
@@ -13,9 +12,9 @@ export interface RenderOptions {
|
|
|
13
12
|
}
|
|
14
13
|
export declare abstract class Renderer {
|
|
15
14
|
templateDir: string;
|
|
16
|
-
fs: CliFs;
|
|
17
|
-
cache: Set<string>;
|
|
18
|
-
protected configuration:
|
|
15
|
+
readonly fs: CliFs;
|
|
16
|
+
readonly cache: Set<string>;
|
|
17
|
+
protected configuration: any;
|
|
19
18
|
abstract get rootDir(): string;
|
|
20
19
|
loadPartials(cwd: string): Promise<void>;
|
|
21
20
|
render(path: string, data: any, options?: Partial<RenderOptions>): Promise<void>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { TokenProvider } from "@tsed/di";
|
|
2
2
|
import type { CommandMetadata } from "../interfaces/CommandMetadata.js";
|
|
3
|
-
export declare function getCommandMetadata(token:
|
|
3
|
+
export declare function getCommandMetadata(token: TokenProvider): CommandMetadata;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function loadPlugins(injector: InjectorService): Promise<void>;
|
|
1
|
+
export declare function loadPlugins(): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/cli-core",
|
|
3
3
|
"description": "Build your CLI with TypeScript and Decorators",
|
|
4
|
-
"version": "6.0.0-beta.
|
|
4
|
+
"version": "6.0.0-beta.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/esm/index.js",
|
|
7
7
|
"source": "./src/index.ts",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"uuid": "^10.0.0"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@tsed/typescript": "6.0.0-beta.
|
|
69
|
+
"@tsed/typescript": "6.0.0-beta.2",
|
|
70
70
|
"@types/commander": "2.12.2",
|
|
71
71
|
"@types/consolidate": "0.14.4",
|
|
72
72
|
"@types/figures": "3.0.1",
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
"vitest": "2.1.1"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
|
-
"@tsed/core": ">=
|
|
87
|
-
"@tsed/di": ">=
|
|
86
|
+
"@tsed/core": ">=8.0.0-beta.2",
|
|
87
|
+
"@tsed/di": ">=8.0.0-beta.2"
|
|
88
88
|
},
|
|
89
89
|
"repository": "https://github.com/tsedio/tsed-cli",
|
|
90
90
|
"bugs": {
|