@tsed/cli-core 7.0.0-beta.1 → 7.0.0-beta.3
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 +19 -38
- package/lib/esm/packageManagers/PackageManagersModule.js +11 -18
- package/lib/esm/packageManagers/supports/BaseManager.js +2 -6
- package/lib/esm/services/CliHttpClient.js +3 -2
- package/lib/esm/services/CliHttpLogClient.js +1 -1
- package/lib/esm/services/CliLoadFile.js +5 -18
- package/lib/esm/services/CliService.js +31 -27
- package/lib/esm/services/ProjectPackageJson.js +17 -4
- package/lib/esm/utils/createInjector.js +1 -1
- package/lib/esm/utils/index.js +1 -0
- package/lib/esm/utils/validate.js +23 -0
- package/lib/types/CliCore.d.ts +2 -9
- package/lib/types/packageManagers/PackageManagersModule.d.ts +1 -2
- package/lib/types/services/CliHttpLogClient.d.ts +1 -1
- package/lib/types/services/CliLoadFile.d.ts +2 -4
- package/lib/types/services/CliService.d.ts +5 -4
- package/lib/types/services/ProjectPackageJson.d.ts +9 -0
- package/lib/types/utils/index.d.ts +1 -0
- package/lib/types/utils/resolveConfiguration.d.ts +1 -1
- package/lib/types/utils/validate.d.ts +14 -0
- package/package.json +2 -2
- package/readme.md +1 -1
package/lib/esm/CliCore.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import "@tsed/logger-std";
|
|
2
2
|
import { join, resolve } from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
import { inject, injectable, InjectorService } from "@tsed/di";
|
|
3
|
+
import { constant, inject, injector } from "@tsed/di";
|
|
5
4
|
import { $asyncEmit } from "@tsed/hooks";
|
|
6
5
|
import chalk from "chalk";
|
|
7
6
|
import { Command } from "commander";
|
|
8
7
|
import semver from "semver";
|
|
9
8
|
import updateNotifier from "update-notifier";
|
|
10
9
|
import { CliError } from "./domains/CliError.js";
|
|
11
|
-
import { CliPackageJson } from "./services/CliPackageJson.js";
|
|
12
10
|
import { CliService } from "./services/CliService.js";
|
|
13
|
-
import { ProjectPackageJson } from "./services/ProjectPackageJson.js";
|
|
14
11
|
import { createInjector } from "./utils/createInjector.js";
|
|
15
12
|
import { loadPlugins } from "./utils/loadPlugins.js";
|
|
16
13
|
import { resolveConfiguration } from "./utils/resolveConfiguration.js";
|
|
@@ -18,9 +15,8 @@ function isHelpManual(argv) {
|
|
|
18
15
|
return argv.includes("-h") || argv.includes("--help");
|
|
19
16
|
}
|
|
20
17
|
export class CliCore {
|
|
21
|
-
constructor() {
|
|
22
|
-
|
|
23
|
-
this.cliService = inject(CliService);
|
|
18
|
+
constructor(settings) {
|
|
19
|
+
createInjector(settings);
|
|
24
20
|
}
|
|
25
21
|
static checkPrecondition(settings) {
|
|
26
22
|
const { pkg } = settings;
|
|
@@ -48,41 +44,16 @@ export class CliCore {
|
|
|
48
44
|
}
|
|
49
45
|
return this;
|
|
50
46
|
}
|
|
51
|
-
static async
|
|
52
|
-
settings = resolveConfiguration(settings);
|
|
53
|
-
const injector = this.createInjector(settings);
|
|
54
|
-
settings.plugins && (await loadPlugins());
|
|
55
|
-
await this.loadInjector(injector, module);
|
|
56
|
-
await $asyncEmit("$onReady");
|
|
57
|
-
return inject(CliCore);
|
|
58
|
-
}
|
|
59
|
-
static async bootstrap(settings, module = CliCore) {
|
|
47
|
+
static async bootstrap(settings) {
|
|
60
48
|
if (settings.checkPrecondition) {
|
|
61
49
|
this.checkPrecondition(settings);
|
|
62
50
|
}
|
|
63
51
|
if (settings.updateNotifier) {
|
|
64
52
|
await this.updateNotifier(settings.pkg);
|
|
65
53
|
}
|
|
66
|
-
|
|
67
|
-
return cli.bootstrap();
|
|
68
|
-
}
|
|
69
|
-
static async loadInjector(injector, module = CliCore) {
|
|
70
|
-
await $asyncEmit("$beforeInit");
|
|
71
|
-
injector.addProvider(CliCore, {
|
|
72
|
-
useClass: module
|
|
73
|
-
});
|
|
74
|
-
await injector.load();
|
|
75
|
-
await injector.invoke(module);
|
|
76
|
-
await $asyncEmit("$afterInit");
|
|
77
|
-
injector.settings.set("loaded", true);
|
|
78
|
-
}
|
|
79
|
-
static async updateNotifier(pkg) {
|
|
80
|
-
updateNotifier({ pkg, updateCheckInterval: 0 }).notify();
|
|
81
|
-
return this;
|
|
82
|
-
}
|
|
83
|
-
static createInjector(settings) {
|
|
54
|
+
settings = resolveConfiguration(settings);
|
|
84
55
|
const argv = settings.argv || process.argv;
|
|
85
|
-
return
|
|
56
|
+
return new CliCore({
|
|
86
57
|
...settings,
|
|
87
58
|
name: settings.name || "tsed",
|
|
88
59
|
argv,
|
|
@@ -92,7 +63,11 @@ export class CliCore {
|
|
|
92
63
|
scriptsDir: "scripts",
|
|
93
64
|
...(settings.project || {})
|
|
94
65
|
}
|
|
95
|
-
});
|
|
66
|
+
}).bootstrap();
|
|
67
|
+
}
|
|
68
|
+
static async updateNotifier(pkg) {
|
|
69
|
+
updateNotifier({ pkg, updateCheckInterval: 0 }).notify();
|
|
70
|
+
return this;
|
|
96
71
|
}
|
|
97
72
|
static getProjectRoot(argv) {
|
|
98
73
|
if (!isHelpManual(argv)) {
|
|
@@ -103,7 +78,14 @@ export class CliCore {
|
|
|
103
78
|
}
|
|
104
79
|
async bootstrap() {
|
|
105
80
|
try {
|
|
106
|
-
|
|
81
|
+
const cliService = inject(CliService);
|
|
82
|
+
constant("plugins") && (await loadPlugins());
|
|
83
|
+
await $asyncEmit("$beforeInit");
|
|
84
|
+
await injector().load();
|
|
85
|
+
await $asyncEmit("$afterInit");
|
|
86
|
+
injector().settings.set("loaded", true);
|
|
87
|
+
await $asyncEmit("$onReady");
|
|
88
|
+
await cliService.parseArgs(constant("argv"));
|
|
107
89
|
}
|
|
108
90
|
catch (er) {
|
|
109
91
|
throw new CliError({ origin: er, cli: this });
|
|
@@ -111,4 +93,3 @@ export class CliCore {
|
|
|
111
93
|
return this;
|
|
112
94
|
}
|
|
113
95
|
}
|
|
114
|
-
injectable(CliCore).imports([CliPackageJson, ProjectPackageJson, CliService]);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Inject, injectable } from "@tsed/di";
|
|
1
|
+
import { Inject, inject, injectable, injectMany } from "@tsed/di";
|
|
3
2
|
import { EMPTY, throwError } from "rxjs";
|
|
4
3
|
import { catchError } from "rxjs/operators";
|
|
5
4
|
import { ProjectPackageJson } from "../services/ProjectPackageJson.js";
|
|
@@ -18,17 +17,19 @@ function mapPackagesWithInvalidVersion(deps) {
|
|
|
18
17
|
.filter(([, version]) => !isValidVersion(version))
|
|
19
18
|
.map(toString);
|
|
20
19
|
}
|
|
21
|
-
|
|
22
|
-
constructor(
|
|
23
|
-
this.
|
|
24
|
-
this.packageManagers =
|
|
20
|
+
export class PackageManagersModule {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.projectPackageJson = inject(ProjectPackageJson);
|
|
23
|
+
this.packageManagers = injectMany("package:manager").filter((manager) => {
|
|
24
|
+
return manager.has();
|
|
25
|
+
});
|
|
25
26
|
}
|
|
26
27
|
init(options = {}) {
|
|
27
28
|
const packageManager = this.get(options.packageManager);
|
|
28
29
|
options.packageManager = packageManager.name;
|
|
29
30
|
options = {
|
|
30
31
|
...options,
|
|
31
|
-
cwd: this.projectPackageJson.
|
|
32
|
+
cwd: this.projectPackageJson.cwd,
|
|
32
33
|
env: {
|
|
33
34
|
...process.env,
|
|
34
35
|
GH_TOKEN: this.projectPackageJson.GH_TOKEN
|
|
@@ -45,7 +46,7 @@ let PackageManagersModule = class PackageManagersModule {
|
|
|
45
46
|
const deps = mapPackagesWithInvalidVersion(this.projectPackageJson.dependencies);
|
|
46
47
|
options = {
|
|
47
48
|
...options,
|
|
48
|
-
cwd: this.projectPackageJson.
|
|
49
|
+
cwd: this.projectPackageJson.cwd,
|
|
49
50
|
env: {
|
|
50
51
|
...process.env,
|
|
51
52
|
GH_TOKEN: this.projectPackageJson.GH_TOKEN
|
|
@@ -101,6 +102,7 @@ let PackageManagersModule = class PackageManagersModule {
|
|
|
101
102
|
selectedPackageManager = this.packageManagers.find((manager) => manager.name === "npm");
|
|
102
103
|
}
|
|
103
104
|
this.projectPackageJson.setPreference("packageManager", selectedPackageManager.name);
|
|
105
|
+
console.log("==", name, selectedPackageManager);
|
|
104
106
|
return selectedPackageManager;
|
|
105
107
|
}
|
|
106
108
|
runScript(scriptName, { ignoreError, ...opts } = {}) {
|
|
@@ -116,14 +118,5 @@ let PackageManagersModule = class PackageManagersModule {
|
|
|
116
118
|
});
|
|
117
119
|
return this.get().runScript(scriptName, options).pipe(errorPipe());
|
|
118
120
|
}
|
|
119
|
-
}
|
|
120
|
-
__decorate([
|
|
121
|
-
Inject(),
|
|
122
|
-
__metadata("design:type", ProjectPackageJson)
|
|
123
|
-
], PackageManagersModule.prototype, "projectPackageJson", void 0);
|
|
124
|
-
PackageManagersModule = __decorate([
|
|
125
|
-
__param(0, Inject("package:manager")),
|
|
126
|
-
__metadata("design:paramtypes", [Array])
|
|
127
|
-
], PackageManagersModule);
|
|
128
|
-
export { PackageManagersModule };
|
|
121
|
+
}
|
|
129
122
|
injectable(PackageManagersModule).imports([YarnManager, YarnBerryManager, NpmManager, PNpmManager, BunManager]);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Inject } from "@tsed/di";
|
|
1
|
+
import { inject } from "@tsed/di";
|
|
3
2
|
import { Observable } from "rxjs";
|
|
4
3
|
import { CliExeca } from "../../services/CliExeca.js";
|
|
5
4
|
export class BaseManager {
|
|
6
5
|
constructor() {
|
|
7
6
|
this.verboseOpt = "--verbose";
|
|
7
|
+
this.cliExeca = inject(CliExeca);
|
|
8
8
|
}
|
|
9
9
|
has() {
|
|
10
10
|
try {
|
|
@@ -23,7 +23,3 @@ export class BaseManager {
|
|
|
23
23
|
return this.cliExeca.run(this.cmd, [cmd, options.verbose && this.verboseOpt, ...args].filter(Boolean), options);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
__decorate([
|
|
27
|
-
Inject(CliExeca),
|
|
28
|
-
__metadata("design:type", CliExeca)
|
|
29
|
-
], BaseManager.prototype, "cliExeca", void 0);
|
|
@@ -41,10 +41,11 @@ export class CliHttpClient extends CliHttpLogClient {
|
|
|
41
41
|
return this.mapResponse(result, options);
|
|
42
42
|
}
|
|
43
43
|
getRequestParameters(method, endpoint, options) {
|
|
44
|
+
const url = (this.host || "") + endpoint.replace(this.host || "", "");
|
|
44
45
|
options = {
|
|
45
46
|
method,
|
|
46
|
-
url: (this.host || "") + endpoint.replace(this.host || "", ""),
|
|
47
47
|
...options,
|
|
48
|
+
url,
|
|
48
49
|
params: options.params || options.qs,
|
|
49
50
|
data: options.data,
|
|
50
51
|
headers: {
|
|
@@ -53,7 +54,7 @@ export class CliHttpClient extends CliHttpLogClient {
|
|
|
53
54
|
...(options.headers || {})
|
|
54
55
|
}
|
|
55
56
|
};
|
|
56
|
-
this.configureProxy(
|
|
57
|
+
this.configureProxy(url, options);
|
|
57
58
|
return options;
|
|
58
59
|
}
|
|
59
60
|
configureProxy(endpoint, options) {
|
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
import { extname } from "node:path";
|
|
2
2
|
import { inject, injectable } from "@tsed/di";
|
|
3
|
-
import {
|
|
3
|
+
import { validate } from "../utils/validate.js";
|
|
4
4
|
import { CliFs } from "./CliFs.js";
|
|
5
5
|
import { CliYaml } from "./CliYaml.js";
|
|
6
6
|
export class CliLoadFile {
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
#ajv;
|
|
9
7
|
constructor() {
|
|
10
8
|
this.cliYaml = inject(CliYaml);
|
|
11
9
|
this.cliFs = inject(CliFs);
|
|
12
|
-
const options = {
|
|
13
|
-
verbose: false,
|
|
14
|
-
coerceTypes: true,
|
|
15
|
-
strict: false
|
|
16
|
-
};
|
|
17
|
-
// @ts-ignore
|
|
18
|
-
this.#ajv = new Ajv(options);
|
|
19
10
|
}
|
|
20
11
|
/**
|
|
21
12
|
* Load a configuration file from yaml, json
|
|
@@ -33,18 +24,14 @@ export class CliLoadFile {
|
|
|
33
24
|
throw new Error("Unsupported format file");
|
|
34
25
|
}
|
|
35
26
|
if (schema) {
|
|
36
|
-
const
|
|
37
|
-
const isValid = validate(config);
|
|
27
|
+
const { isValid, errors, value } = validate(config, schema);
|
|
38
28
|
if (!isValid) {
|
|
39
|
-
const [error] =
|
|
40
|
-
throw new Error([
|
|
41
|
-
`${error.instancePath.replace(/\//gi, ".")} `,
|
|
42
|
-
error.message,
|
|
43
|
-
error.params?.allowedValues && `. Allowed values: ${error.params?.allowedValues}`
|
|
44
|
-
]
|
|
29
|
+
const [error] = errors;
|
|
30
|
+
throw new Error([`${error.path.replace(/\//gi, ".")} `, error.message, error.expected && `. Allowed values: ${error.expected}`]
|
|
45
31
|
.filter(Boolean)
|
|
46
32
|
.join(""));
|
|
47
33
|
}
|
|
34
|
+
return value;
|
|
48
35
|
}
|
|
49
36
|
return config;
|
|
50
37
|
}
|
|
@@ -44,29 +44,25 @@ export class CliService {
|
|
|
44
44
|
*/
|
|
45
45
|
runLifecycle(cmdName, data = {}, $ctx) {
|
|
46
46
|
return runInContext($ctx, async () => {
|
|
47
|
-
await $asyncEmit("$loadPackageJson");
|
|
48
|
-
data = await this.beforePrompt(cmdName, data);
|
|
49
|
-
$ctx.set("data", data);
|
|
50
|
-
data = await this.prompt(cmdName, data);
|
|
51
|
-
await this.dispatch(cmdName, data, $ctx);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
async dispatch(cmdName, data, $ctx) {
|
|
55
|
-
try {
|
|
56
47
|
$ctx.set("dispatchCmd", cmdName);
|
|
57
|
-
$
|
|
58
|
-
await this.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
48
|
+
await $asyncEmit("$loadPackageJson");
|
|
49
|
+
data = await this.beforePrompt(cmdName, data, $ctx);
|
|
50
|
+
data = await this.prompt(cmdName, data, $ctx);
|
|
51
|
+
try {
|
|
52
|
+
await this.exec(cmdName, data, $ctx);
|
|
53
|
+
}
|
|
54
|
+
catch (er) {
|
|
55
|
+
await $asyncEmit("$onFinish", [data, er]);
|
|
56
|
+
await destroyInjector();
|
|
57
|
+
throw er;
|
|
58
|
+
}
|
|
59
|
+
await $asyncEmit("$onFinish", [data]);
|
|
62
60
|
await destroyInjector();
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
await $asyncEmit("$onFinish");
|
|
66
|
-
await destroyInjector();
|
|
61
|
+
});
|
|
67
62
|
}
|
|
68
63
|
async exec(cmdName, data, $ctx) {
|
|
69
64
|
const initialTasks = await this.getTasks(cmdName, data);
|
|
65
|
+
$ctx.set("data", data);
|
|
70
66
|
if (initialTasks.length) {
|
|
71
67
|
const tasks = [
|
|
72
68
|
...initialTasks,
|
|
@@ -77,45 +73,53 @@ export class CliService {
|
|
|
77
73
|
},
|
|
78
74
|
...(await this.getPostInstallTasks(cmdName, data))
|
|
79
75
|
];
|
|
80
|
-
|
|
76
|
+
data = this.mapData(cmdName, data, $ctx);
|
|
77
|
+
$ctx.set("data", data);
|
|
78
|
+
return createTasksRunner(tasks, data);
|
|
81
79
|
}
|
|
82
80
|
}
|
|
83
81
|
/**
|
|
84
82
|
* Run prompt for a given command
|
|
85
83
|
* @param cmdName
|
|
86
84
|
* @param data Initial data
|
|
85
|
+
* @param $ctx
|
|
87
86
|
*/
|
|
88
|
-
async beforePrompt(cmdName, data = {}) {
|
|
87
|
+
async beforePrompt(cmdName, data = {}, $ctx) {
|
|
89
88
|
const provider = this.commands.get(cmdName);
|
|
90
89
|
const instance = inject(provider.useClass);
|
|
91
90
|
const verbose = data.verbose;
|
|
91
|
+
$ctx.set("data", data);
|
|
92
92
|
if (instance.$beforePrompt) {
|
|
93
93
|
data = await instance.$beforePrompt(JSON.parse(JSON.stringify(data)));
|
|
94
94
|
data.verbose = verbose;
|
|
95
95
|
}
|
|
96
|
+
$ctx.set("data", data);
|
|
96
97
|
return data;
|
|
97
98
|
}
|
|
98
99
|
/**
|
|
99
100
|
* Run prompt for a given command
|
|
100
101
|
* @param cmdName
|
|
101
|
-
* @param
|
|
102
|
+
* @param data
|
|
103
|
+
* @param $ctx
|
|
102
104
|
*/
|
|
103
|
-
async prompt(cmdName,
|
|
105
|
+
async prompt(cmdName, data = {}, $ctx) {
|
|
104
106
|
const provider = this.commands.get(cmdName);
|
|
105
107
|
const instance = inject(provider.useClass);
|
|
108
|
+
$ctx.set("data", data);
|
|
106
109
|
if (instance.$prompt) {
|
|
107
110
|
const questions = [
|
|
108
|
-
...(await instance.$prompt(
|
|
109
|
-
...(await this.hooks.emit(CommandStoreKeys.PROMPT_HOOKS, cmdName,
|
|
111
|
+
...(await instance.$prompt(data)),
|
|
112
|
+
...(await this.hooks.emit(CommandStoreKeys.PROMPT_HOOKS, cmdName, data))
|
|
110
113
|
];
|
|
111
114
|
if (questions.length) {
|
|
112
|
-
|
|
113
|
-
...
|
|
115
|
+
data = {
|
|
116
|
+
...data,
|
|
114
117
|
...(await Inquirer.prompt(questions))
|
|
115
118
|
};
|
|
116
119
|
}
|
|
117
120
|
}
|
|
118
|
-
|
|
121
|
+
$ctx.set("data", data);
|
|
122
|
+
return data;
|
|
119
123
|
}
|
|
120
124
|
/**
|
|
121
125
|
* Run lifecycle
|
|
@@ -45,12 +45,21 @@ export class ProjectPackageJson {
|
|
|
45
45
|
get path() {
|
|
46
46
|
return join(this.dir, "package.json");
|
|
47
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* @deprecated
|
|
50
|
+
*/
|
|
48
51
|
get dir() {
|
|
49
|
-
return
|
|
52
|
+
return this.cwd;
|
|
50
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* @deprecated
|
|
56
|
+
* @param dir
|
|
57
|
+
*/
|
|
51
58
|
set dir(dir) {
|
|
52
|
-
|
|
53
|
-
|
|
59
|
+
this.setCWD(dir);
|
|
60
|
+
}
|
|
61
|
+
get cwd() {
|
|
62
|
+
return String(constant("project.rootDir", ""));
|
|
54
63
|
}
|
|
55
64
|
get name() {
|
|
56
65
|
return this.raw.name;
|
|
@@ -83,6 +92,10 @@ export class ProjectPackageJson {
|
|
|
83
92
|
get preferences() {
|
|
84
93
|
return this.raw[constant("name")];
|
|
85
94
|
}
|
|
95
|
+
setCWD(dir) {
|
|
96
|
+
configuration().set("project.rootDir", dir);
|
|
97
|
+
this.read();
|
|
98
|
+
}
|
|
86
99
|
fillWithPreferences(ctx) {
|
|
87
100
|
return {
|
|
88
101
|
...ctx,
|
|
@@ -222,7 +235,7 @@ export class ProjectPackageJson {
|
|
|
222
235
|
refresh() {
|
|
223
236
|
this.reinstall = false;
|
|
224
237
|
this.rewrite = false;
|
|
225
|
-
const cwd =
|
|
238
|
+
const cwd = this.cwd;
|
|
226
239
|
const pkgPath = join(String(cwd), "package.json");
|
|
227
240
|
const pkg = this.fs.readJsonSync(pkgPath, { encoding: "utf8" });
|
|
228
241
|
pkg.scripts = {
|
package/lib/esm/utils/index.js
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Ajv } from "ajv";
|
|
2
|
+
const ajv = new Ajv({
|
|
3
|
+
verbose: false,
|
|
4
|
+
coerceTypes: true,
|
|
5
|
+
strict: false,
|
|
6
|
+
allErrors: true
|
|
7
|
+
});
|
|
8
|
+
export function validate(value, schema) {
|
|
9
|
+
const validate = ajv.compile(schema.toJSON());
|
|
10
|
+
const result = validate(value);
|
|
11
|
+
if (!result) {
|
|
12
|
+
const errors = (validate.errors || []).map((e) => ({
|
|
13
|
+
path: e.instancePath || e.schemaPath,
|
|
14
|
+
message: e.message,
|
|
15
|
+
expected: (e.params && e.params.type) || undefined
|
|
16
|
+
}));
|
|
17
|
+
return {
|
|
18
|
+
isValid: false,
|
|
19
|
+
errors: errors
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return { isValid: true, value: value };
|
|
23
|
+
}
|
package/lib/types/CliCore.d.ts
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
import "@tsed/logger-std";
|
|
2
|
-
import { Type } from "@tsed/core";
|
|
3
|
-
import { InjectorService } from "@tsed/di";
|
|
4
|
-
import { CliService } from "./services/CliService.js";
|
|
5
2
|
export declare class CliCore {
|
|
6
|
-
|
|
7
|
-
readonly cliService: CliService;
|
|
3
|
+
protected constructor(settings: Partial<TsED.Configuration>);
|
|
8
4
|
static checkPrecondition(settings: any): void;
|
|
9
5
|
static checkPackage(pkg: any): void;
|
|
10
6
|
static checkNodeVersion(wanted: string, id: string): typeof CliCore;
|
|
11
|
-
static
|
|
12
|
-
static bootstrap(settings: Partial<TsED.Configuration>, module?: Type): Promise<CliCore>;
|
|
13
|
-
static loadInjector(injector: InjectorService, module?: Type): Promise<void>;
|
|
7
|
+
static bootstrap(settings: Partial<TsED.Configuration>): Promise<CliCore>;
|
|
14
8
|
static updateNotifier(pkg: any): Promise<typeof CliCore>;
|
|
15
|
-
protected static createInjector(settings: Partial<TsED.Configuration>): InjectorService;
|
|
16
9
|
protected static getProjectRoot(argv: string[]): string;
|
|
17
10
|
bootstrap(): Promise<this>;
|
|
18
11
|
}
|
|
@@ -5,9 +5,8 @@ export interface InstallOptions {
|
|
|
5
5
|
[key: string]: any;
|
|
6
6
|
}
|
|
7
7
|
export declare class PackageManagersModule {
|
|
8
|
-
protected packageManagers: BaseManager[];
|
|
9
8
|
protected projectPackageJson: ProjectPackageJson;
|
|
10
|
-
|
|
9
|
+
protected packageManagers: BaseManager[];
|
|
11
10
|
init(options?: InstallOptions): Promise<void>;
|
|
12
11
|
install(options?: InstallOptions): ({
|
|
13
12
|
title: string;
|
|
@@ -6,7 +6,7 @@ export declare class CliHttpLogClient {
|
|
|
6
6
|
callee: string;
|
|
7
7
|
protected logger: Logger;
|
|
8
8
|
constructor(options?: Partial<BaseLogClientOptions>);
|
|
9
|
-
protected onSuccess(options: Record<string, unknown>):
|
|
9
|
+
protected onSuccess(options: Record<string, unknown>): void;
|
|
10
10
|
protected onError(error: any, options: any): void;
|
|
11
11
|
protected logToCurl(options: any): string;
|
|
12
12
|
protected getStatusCodeFromError(error: any): any;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { JsonSchema } from "@tsed/schema";
|
|
2
2
|
import { CliFs } from "./CliFs.js";
|
|
3
3
|
import { CliYaml } from "./CliYaml.js";
|
|
4
4
|
export declare class CliLoadFile {
|
|
5
|
-
#private;
|
|
6
5
|
protected cliYaml: CliYaml;
|
|
7
6
|
protected cliFs: CliFs;
|
|
8
|
-
constructor();
|
|
9
7
|
/**
|
|
10
8
|
* Load a configuration file from yaml, json
|
|
11
9
|
*/
|
|
12
|
-
loadFile<Model = any>(path: string, schema?:
|
|
10
|
+
loadFile<Model = any>(path: string, schema?: JsonSchema<Model>): Promise<Model>;
|
|
13
11
|
}
|
|
@@ -26,20 +26,21 @@ export declare class CliService {
|
|
|
26
26
|
* @param $ctx
|
|
27
27
|
*/
|
|
28
28
|
runLifecycle(cmdName: string, data: CommandData | undefined, $ctx: DIContext): Promise<Promise<void>>;
|
|
29
|
-
dispatch(cmdName: string, data: CommandData, $ctx: DIContext): Promise<void>;
|
|
30
29
|
exec(cmdName: string, data: any, $ctx: DIContext): Promise<any>;
|
|
31
30
|
/**
|
|
32
31
|
* Run prompt for a given command
|
|
33
32
|
* @param cmdName
|
|
34
33
|
* @param data Initial data
|
|
34
|
+
* @param $ctx
|
|
35
35
|
*/
|
|
36
|
-
beforePrompt(cmdName: string, data
|
|
36
|
+
beforePrompt(cmdName: string, data: CommandData | undefined, $ctx: DIContext): Promise<CommandData>;
|
|
37
37
|
/**
|
|
38
38
|
* Run prompt for a given command
|
|
39
39
|
* @param cmdName
|
|
40
|
-
* @param
|
|
40
|
+
* @param data
|
|
41
|
+
* @param $ctx
|
|
41
42
|
*/
|
|
42
|
-
prompt(cmdName: string, ctx
|
|
43
|
+
prompt(cmdName: string, data: CommandData | undefined, $ctx: DIContext): Promise<CommandData>;
|
|
43
44
|
/**
|
|
44
45
|
* Run lifecycle
|
|
45
46
|
* @param cmdName
|
|
@@ -9,8 +9,16 @@ export declare class ProjectPackageJson {
|
|
|
9
9
|
private raw;
|
|
10
10
|
constructor();
|
|
11
11
|
get path(): string;
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated
|
|
14
|
+
*/
|
|
12
15
|
get dir(): string;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated
|
|
18
|
+
* @param dir
|
|
19
|
+
*/
|
|
13
20
|
set dir(dir: string);
|
|
21
|
+
get cwd(): string;
|
|
14
22
|
get name(): string;
|
|
15
23
|
set name(name: string);
|
|
16
24
|
get version(): string;
|
|
@@ -28,6 +36,7 @@ export declare class ProjectPackageJson {
|
|
|
28
36
|
[key: string]: string;
|
|
29
37
|
};
|
|
30
38
|
get preferences(): ProjectPreferences;
|
|
39
|
+
setCWD(dir: string): void;
|
|
31
40
|
fillWithPreferences<T extends {}>(ctx: T): T & {
|
|
32
41
|
packageManager: import("../interfaces/ProjectPreferences.js").PackageManager;
|
|
33
42
|
runtime: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function resolveConfiguration(settings:
|
|
1
|
+
export declare function resolveConfiguration(settings: Partial<TsED.Configuration>): Partial<TsED.Configuration>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { JsonSchema } from "@tsed/schema";
|
|
2
|
+
export declare function validate<Value>(value: unknown, schema: JsonSchema<Value>): {
|
|
3
|
+
isValid: boolean;
|
|
4
|
+
errors: {
|
|
5
|
+
path: string;
|
|
6
|
+
message: string | undefined;
|
|
7
|
+
expected: any;
|
|
8
|
+
}[];
|
|
9
|
+
value?: undefined;
|
|
10
|
+
} | {
|
|
11
|
+
isValid: boolean;
|
|
12
|
+
value: Value;
|
|
13
|
+
errors?: undefined;
|
|
14
|
+
};
|
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": "7.0.0-beta.
|
|
4
|
+
"version": "7.0.0-beta.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/esm/index.js",
|
|
7
7
|
"source": "./src/index.ts",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"uuid": "^10.0.0"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@tsed/typescript": "7.0.0-beta.
|
|
68
|
+
"@tsed/typescript": "7.0.0-beta.3",
|
|
69
69
|
"@types/commander": "2.12.2",
|
|
70
70
|
"@types/figures": "3.0.1",
|
|
71
71
|
"@types/fs-extra": "^11.0.4",
|
package/readme.md
CHANGED
|
@@ -216,7 +216,7 @@ website. [[Become a sponsor](https://opencollective.com/tsed#sponsor)]
|
|
|
216
216
|
|
|
217
217
|
The MIT License (MIT)
|
|
218
218
|
|
|
219
|
-
Copyright (c) 2016 -
|
|
219
|
+
Copyright (c) 2016 - Today Romain Lenzotti
|
|
220
220
|
|
|
221
221
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
222
222
|
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|