@tsed/cli-core 7.0.0-alpha.9 → 7.0.0-beta.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/esm/CliCore.js
CHANGED
|
@@ -22,6 +22,19 @@ export class CliCore {
|
|
|
22
22
|
this.injector = inject(InjectorService);
|
|
23
23
|
this.cliService = inject(CliService);
|
|
24
24
|
}
|
|
25
|
+
static checkPrecondition(settings) {
|
|
26
|
+
const { pkg } = settings;
|
|
27
|
+
this.checkPackage(pkg);
|
|
28
|
+
if (pkg?.engines?.node) {
|
|
29
|
+
this.checkNodeVersion(pkg.engines.node, pkg.name);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
static checkPackage(pkg) {
|
|
33
|
+
if (!pkg) {
|
|
34
|
+
console.log(chalk.red(`settings.pkg is required. Require the package.json of your CLI when you bootstrap the CLI.`));
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
25
38
|
static checkNodeVersion(wanted, id) {
|
|
26
39
|
if (!semver.satisfies(process.version, wanted)) {
|
|
27
40
|
console.log(chalk.red("You are using Node " +
|
|
@@ -44,11 +57,17 @@ export class CliCore {
|
|
|
44
57
|
return inject(CliCore);
|
|
45
58
|
}
|
|
46
59
|
static async bootstrap(settings, module = CliCore) {
|
|
60
|
+
if (settings.checkPrecondition) {
|
|
61
|
+
this.checkPrecondition(settings);
|
|
62
|
+
}
|
|
63
|
+
if (settings.updateNotifier) {
|
|
64
|
+
await this.updateNotifier(settings.pkg);
|
|
65
|
+
}
|
|
47
66
|
const cli = await this.create(settings, module);
|
|
48
67
|
return cli.bootstrap();
|
|
49
68
|
}
|
|
50
69
|
static async loadInjector(injector, module = CliCore) {
|
|
51
|
-
await
|
|
70
|
+
await $asyncEmit("$beforeInit");
|
|
52
71
|
injector.addProvider(CliCore, {
|
|
53
72
|
useClass: module
|
|
54
73
|
});
|
package/lib/types/CliCore.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ import { CliService } from "./services/CliService.js";
|
|
|
5
5
|
export declare class CliCore {
|
|
6
6
|
readonly injector: InjectorService;
|
|
7
7
|
readonly cliService: CliService;
|
|
8
|
+
static checkPrecondition(settings: any): void;
|
|
9
|
+
static checkPackage(pkg: any): void;
|
|
8
10
|
static checkNodeVersion(wanted: string, id: string): typeof CliCore;
|
|
9
11
|
static create<Cli extends CliCore = CliCore>(settings: Partial<TsED.Configuration>, module?: Type): Promise<Cli>;
|
|
10
12
|
static bootstrap(settings: Partial<TsED.Configuration>, module?: Type): Promise<CliCore>;
|
|
@@ -33,7 +33,7 @@ declare global {
|
|
|
33
33
|
*/
|
|
34
34
|
templateDir?: string;
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* A function that return default projet settings set in fresh project.
|
|
37
37
|
* @param pkg
|
|
38
38
|
*/
|
|
39
39
|
defaultProjectPreferences?: (pkg?: any) => Record<string, any>;
|
|
@@ -50,6 +50,14 @@ declare global {
|
|
|
50
50
|
* Enable plugins loading
|
|
51
51
|
*/
|
|
52
52
|
plugins: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Check version and node version before running a command
|
|
55
|
+
*/
|
|
56
|
+
checkPrecondition?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Display available update on terminal before running a command
|
|
59
|
+
*/
|
|
60
|
+
updateNotifier?: boolean;
|
|
53
61
|
}
|
|
54
62
|
}
|
|
55
63
|
}
|
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-
|
|
4
|
+
"version": "7.0.0-beta.1",
|
|
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-
|
|
68
|
+
"@tsed/typescript": "7.0.0-beta.1",
|
|
69
69
|
"@types/commander": "2.12.2",
|
|
70
70
|
"@types/figures": "3.0.1",
|
|
71
71
|
"@types/fs-extra": "^11.0.4",
|
|
@@ -105,6 +105,6 @@
|
|
|
105
105
|
"author": "Romain Lenzotti",
|
|
106
106
|
"license": "MIT",
|
|
107
107
|
"publishConfig": {
|
|
108
|
-
"tag": "
|
|
108
|
+
"tag": "beta"
|
|
109
109
|
}
|
|
110
110
|
}
|