@tsed/cli-core 7.0.0-beta.1 → 7.0.0-beta.10
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/decorators/command.js +1 -1
- package/lib/esm/decorators/index.js +0 -4
- package/lib/esm/fn/command.js +31 -3
- package/lib/esm/interfaces/ProjectPreferences.js +1 -0
- package/lib/esm/interfaces/index.js +1 -1
- package/lib/esm/packageManagers/PackageManagersModule.js +11 -19
- package/lib/esm/packageManagers/index.js +1 -0
- package/lib/esm/packageManagers/supports/BaseManager.js +2 -6
- package/lib/esm/packageManagers/supports/YarnBerryManager.js +4 -1
- package/lib/esm/services/CliFs.js +3 -1
- 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/CliPlugins.js +2 -3
- package/lib/esm/services/CliService.js +59 -71
- package/lib/esm/services/ProjectPackageJson.js +17 -4
- package/lib/esm/utils/createInjector.js +1 -1
- package/lib/esm/utils/getCommandMetadata.js +34 -7
- package/lib/esm/utils/index.js +1 -0
- package/lib/esm/utils/loadPlugins.js +5 -18
- package/lib/esm/utils/validate.js +23 -0
- package/lib/types/CliCore.d.ts +2 -9
- package/lib/types/decorators/command.d.ts +2 -2
- package/lib/types/decorators/index.d.ts +0 -4
- package/lib/types/fn/command.d.ts +58 -3
- package/lib/types/interfaces/CommandMetadata.d.ts +17 -15
- package/lib/types/interfaces/{CommandParameters.d.ts → CommandOptions.d.ts} +20 -3
- package/lib/types/interfaces/CommandProvider.d.ts +0 -10
- package/lib/types/interfaces/ProjectPreferences.d.ts +2 -1
- package/lib/types/interfaces/index.d.ts +3 -3
- package/lib/types/packageManagers/PackageManagersModule.d.ts +1 -2
- package/lib/types/packageManagers/index.d.ts +1 -0
- package/lib/types/services/CliHttpLogClient.d.ts +1 -1
- package/lib/types/services/CliLoadFile.d.ts +2 -4
- package/lib/types/services/CliPlugins.d.ts +0 -1
- package/lib/types/services/CliService.d.ts +4 -10
- package/lib/types/services/ProjectPackageJson.d.ts +9 -0
- package/lib/types/utils/index.d.ts +1 -0
- package/lib/types/utils/mapCommanderArgs.d.ts +1 -1
- 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/decorators/on.js +0 -8
- package/lib/esm/decorators/onAdd.js +0 -5
- package/lib/esm/decorators/onExec.js +0 -5
- package/lib/esm/decorators/onPostInstall.js +0 -5
- package/lib/esm/decorators/onPrompt.js +0 -5
- package/lib/esm/domains/CommandStoreKeys.js +0 -8
- package/lib/types/decorators/on.d.ts +0 -1
- package/lib/types/decorators/onAdd.d.ts +0 -1
- package/lib/types/decorators/onExec.d.ts +0 -1
- package/lib/types/decorators/onPostInstall.d.ts +0 -1
- package/lib/types/decorators/onPrompt.d.ts +0 -1
- package/lib/types/domains/CommandStoreKeys.d.ts +0 -7
- /package/lib/esm/interfaces/{CommandParameters.js → CommandOptions.js} +0 -0
|
@@ -1,17 +1,44 @@
|
|
|
1
|
-
import { Store } from "@tsed/core";
|
|
2
|
-
import { CommandStoreKeys } from "../domains/CommandStoreKeys.js";
|
|
1
|
+
import { isArrowFn, Store } from "@tsed/core";
|
|
3
2
|
export function getCommandMetadata(token) {
|
|
4
|
-
const { name, alias, args = {},
|
|
3
|
+
const { name, alias, args = {}, description, options = {}, enableFeatures, disableReadUpPkg, inputSchema, bindLogger = true, ...opts } = Store.from(token)?.get("command");
|
|
5
4
|
return {
|
|
6
5
|
name,
|
|
6
|
+
inputSchema,
|
|
7
7
|
alias,
|
|
8
|
-
args,
|
|
9
8
|
description,
|
|
10
|
-
options,
|
|
11
|
-
allowUnknownOption: !!allowUnknownOption,
|
|
12
9
|
enableFeatures: enableFeatures || [],
|
|
13
10
|
disableReadUpPkg: !!disableReadUpPkg,
|
|
14
11
|
bindLogger,
|
|
15
|
-
...opts
|
|
12
|
+
...opts,
|
|
13
|
+
getOptions() {
|
|
14
|
+
if (inputSchema) {
|
|
15
|
+
const schema = isArrowFn(inputSchema) ? inputSchema() : inputSchema;
|
|
16
|
+
Object.entries(schema.get("properties") || {})?.forEach(([propertyKey, propertySchema]) => {
|
|
17
|
+
const base = {
|
|
18
|
+
type: propertySchema.getTarget(),
|
|
19
|
+
itemType: propertySchema.isCollection ? propertySchema.get("items").getTarget() : undefined,
|
|
20
|
+
description: propertySchema.get("description") || "",
|
|
21
|
+
defaultValue: propertySchema.get("default"),
|
|
22
|
+
required: schema.isRequired(propertyKey)
|
|
23
|
+
};
|
|
24
|
+
const opt = propertySchema.get("x-opt");
|
|
25
|
+
if (opt) {
|
|
26
|
+
options[opt] = {
|
|
27
|
+
...base,
|
|
28
|
+
customParser: schema.get("custom-parser")
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
args[propertyKey] = base;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
opts.allowUnknownOption = !!schema.get("additionalProperties");
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
args,
|
|
39
|
+
options,
|
|
40
|
+
allowUnknownOption: !!opts.allowUnknownOption
|
|
41
|
+
};
|
|
42
|
+
}
|
|
16
43
|
};
|
|
17
44
|
}
|
package/lib/esm/utils/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { injector, lazyInject, logger } from "@tsed/di";
|
|
2
2
|
import chalk from "chalk";
|
|
3
3
|
import figures from "figures";
|
|
4
4
|
import { CliFs } from "../services/CliFs.js";
|
|
@@ -7,33 +7,20 @@ const all = (promises) => Promise.all(promises);
|
|
|
7
7
|
export async function loadPlugins() {
|
|
8
8
|
const $inj = injector();
|
|
9
9
|
const name = $inj.settings.get("name");
|
|
10
|
-
const rootDir = $inj.settings.get("project.rootDir");
|
|
11
10
|
const projectPackageJson = $inj.invoke(ProjectPackageJson);
|
|
12
11
|
const fs = $inj.invoke(CliFs);
|
|
13
12
|
const promises = Object.keys(projectPackageJson.allDependencies)
|
|
14
13
|
.filter((mod) => mod.startsWith(`@${name}/cli-plugin`) || mod.includes(`${name}-cli-plugin`))
|
|
15
14
|
.map(async (mod) => {
|
|
16
15
|
try {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (provider?.imports.length) {
|
|
21
|
-
await all(provider.imports.map(async (token) => {
|
|
22
|
-
$inj.add(token, GlobalProviders.get(token)?.clone());
|
|
23
|
-
if ($inj.settings.get("loaded")) {
|
|
24
|
-
await $inj.invoke(token);
|
|
25
|
-
}
|
|
26
|
-
}));
|
|
27
|
-
}
|
|
28
|
-
$inj.add(plugin, provider);
|
|
29
|
-
if ($inj.settings.get("loaded")) {
|
|
30
|
-
await $inj.invoke(plugin);
|
|
31
|
-
}
|
|
16
|
+
if ($inj.settings.get("loaded")) {
|
|
17
|
+
logger().info("Try to load ", mod);
|
|
18
|
+
await lazyInject(() => fs.importModule(mod, projectPackageJson.cwd));
|
|
32
19
|
}
|
|
33
20
|
logger().info(chalk.green(figures.tick), mod, "module loaded");
|
|
34
21
|
}
|
|
35
22
|
catch (er) {
|
|
36
|
-
logger().warn(chalk.red(figures.cross), "Fail to load plugin", mod);
|
|
23
|
+
logger().warn(chalk.red(figures.cross), "Fail to load plugin", mod, er.message);
|
|
37
24
|
}
|
|
38
25
|
});
|
|
39
26
|
await all(promises);
|
|
@@ -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
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function Command(options:
|
|
1
|
+
import type { BaseCommandOptions } from "../interfaces/CommandOptions.js";
|
|
2
|
+
export declare function Command<Input = any>(options: BaseCommandOptions<Input>): ClassDecorator;
|
|
@@ -1,3 +1,58 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type
|
|
3
|
-
|
|
1
|
+
import type { Type } from "@tsed/core";
|
|
2
|
+
import { type FactoryTokenProvider } from "@tsed/di";
|
|
3
|
+
import { JsonSchema } from "@tsed/schema";
|
|
4
|
+
import type { CommandOptions } from "../interfaces/CommandOptions.js";
|
|
5
|
+
import type { CommandProvider } from "../interfaces/index.js";
|
|
6
|
+
type SchemaChoice = {
|
|
7
|
+
label: string;
|
|
8
|
+
value: string;
|
|
9
|
+
checked?: ((ctx: any) => boolean) | boolean;
|
|
10
|
+
items?: SchemaChoice[];
|
|
11
|
+
};
|
|
12
|
+
declare module "@tsed/schema" {
|
|
13
|
+
interface JsonSchema {
|
|
14
|
+
prompt(label: string): this;
|
|
15
|
+
opt(value: string): this;
|
|
16
|
+
when(fn: (ctx: any) => boolean): this;
|
|
17
|
+
choices(value: SchemaChoice[]): this;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export declare function command<Input>(options: CommandOptions<Input>): TsED.ProviderBuilder<FactoryTokenProvider<{
|
|
21
|
+
$prompt: any;
|
|
22
|
+
$exec: any;
|
|
23
|
+
token: import("@tsed/di").TokenProvider<CommandProvider>;
|
|
24
|
+
name: string;
|
|
25
|
+
alias?: string;
|
|
26
|
+
description: string;
|
|
27
|
+
args?: {
|
|
28
|
+
[key: string]: import("../interfaces/CommandOptions.js").CommandArg;
|
|
29
|
+
};
|
|
30
|
+
inputSchema?: JsonSchema<Input> | (() => JsonSchema<Input>) | undefined;
|
|
31
|
+
options?: {
|
|
32
|
+
[key: string]: import("../interfaces/CommandOptions.js").CommandOpts;
|
|
33
|
+
};
|
|
34
|
+
allowUnknownOption?: boolean;
|
|
35
|
+
enableFeatures?: string[];
|
|
36
|
+
disableReadUpPkg?: boolean;
|
|
37
|
+
bindLogger?: boolean;
|
|
38
|
+
} | {
|
|
39
|
+
$prompt: any;
|
|
40
|
+
$exec: any;
|
|
41
|
+
prompt?<T extends import("inquirer").Answers = import("inquirer").Answers>(initialOptions: Partial<Input>): import("../interfaces/CommandProvider.js").QuestionOptions<T> | Promise<import("../interfaces/CommandProvider.js").QuestionOptions<T>>;
|
|
42
|
+
handler: (data: Input) => import("../interfaces/Tasks.js").Tasks | Promise<import("../interfaces/Tasks.js").Tasks> | any | Promise<any>;
|
|
43
|
+
name: string;
|
|
44
|
+
alias?: string;
|
|
45
|
+
description: string;
|
|
46
|
+
args?: {
|
|
47
|
+
[key: string]: import("../interfaces/CommandOptions.js").CommandArg;
|
|
48
|
+
};
|
|
49
|
+
inputSchema?: JsonSchema<Input> | (() => JsonSchema<Input>) | undefined;
|
|
50
|
+
options?: {
|
|
51
|
+
[key: string]: import("../interfaces/CommandOptions.js").CommandOpts;
|
|
52
|
+
};
|
|
53
|
+
allowUnknownOption?: boolean;
|
|
54
|
+
enableFeatures?: string[];
|
|
55
|
+
disableReadUpPkg?: boolean;
|
|
56
|
+
bindLogger?: boolean;
|
|
57
|
+
}>> | TsED.ClassProviderBuilder<Type<CommandProvider<Input>>>;
|
|
58
|
+
export {};
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export interface CommandMetadata extends
|
|
3
|
-
/**
|
|
4
|
-
* CommandProvider arguments
|
|
5
|
-
*/
|
|
6
|
-
args: {
|
|
7
|
-
[key: string]: CommandArg;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* CommandProvider options
|
|
11
|
-
*/
|
|
12
|
-
options: {
|
|
13
|
-
[key: string]: CommandOptions;
|
|
14
|
-
};
|
|
15
|
-
allowUnknownOption?: boolean;
|
|
1
|
+
import type { BaseCommandOptions, CommandArg, CommandOpts } from "./CommandOptions.js";
|
|
2
|
+
export interface CommandMetadata extends Omit<BaseCommandOptions<any>, "args" | "options" | "allowUnknownOption"> {
|
|
16
3
|
enableFeatures: string[];
|
|
17
4
|
disableReadUpPkg: boolean;
|
|
18
5
|
bindLogger: boolean;
|
|
6
|
+
getOptions(): {
|
|
7
|
+
/**
|
|
8
|
+
* CommandProvider arguments
|
|
9
|
+
*/
|
|
10
|
+
args: {
|
|
11
|
+
[key: string]: CommandArg;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* CommandProvider options
|
|
15
|
+
*/
|
|
16
|
+
options: {
|
|
17
|
+
[key: string]: CommandOpts;
|
|
18
|
+
};
|
|
19
|
+
allowUnknownOption?: boolean;
|
|
20
|
+
};
|
|
19
21
|
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { Type } from "@tsed/core";
|
|
2
|
+
import type { TokenProvider } from "@tsed/di";
|
|
3
|
+
import type { JsonSchema } from "@tsed/schema";
|
|
4
|
+
import type { Answers } from "inquirer";
|
|
5
|
+
import type { CommandProvider, QuestionOptions } from "./CommandProvider.js";
|
|
6
|
+
import type { Tasks } from "./Tasks.js";
|
|
2
7
|
export interface CommandArg {
|
|
3
8
|
/**
|
|
4
9
|
* Description of the argument
|
|
@@ -21,7 +26,7 @@ export interface CommandArg {
|
|
|
21
26
|
*/
|
|
22
27
|
required?: boolean;
|
|
23
28
|
}
|
|
24
|
-
export interface
|
|
29
|
+
export interface CommandOpts {
|
|
25
30
|
/**
|
|
26
31
|
* Description of the commander.option()
|
|
27
32
|
*/
|
|
@@ -48,7 +53,7 @@ export interface CommandOptions {
|
|
|
48
53
|
*/
|
|
49
54
|
customParser?: (value: any) => any;
|
|
50
55
|
}
|
|
51
|
-
export interface
|
|
56
|
+
export interface BaseCommandOptions<Input> {
|
|
52
57
|
/**
|
|
53
58
|
* name commands
|
|
54
59
|
*/
|
|
@@ -64,14 +69,26 @@ export interface CommandParameters {
|
|
|
64
69
|
args?: {
|
|
65
70
|
[key: string]: CommandArg;
|
|
66
71
|
};
|
|
72
|
+
inputSchema?: JsonSchema<Input> | (() => JsonSchema<Input>);
|
|
67
73
|
/**
|
|
68
74
|
* CommandProvider options
|
|
69
75
|
*/
|
|
70
76
|
options?: {
|
|
71
|
-
[key: string]:
|
|
77
|
+
[key: string]: CommandOpts;
|
|
72
78
|
};
|
|
73
79
|
allowUnknownOption?: boolean;
|
|
74
80
|
enableFeatures?: string[];
|
|
75
81
|
disableReadUpPkg?: boolean;
|
|
82
|
+
bindLogger?: boolean;
|
|
83
|
+
}
|
|
84
|
+
interface FunctionalCommandOptions<Input> extends BaseCommandOptions<Input> {
|
|
85
|
+
prompt?<T extends Answers = Answers>(initialOptions: Partial<Input>): QuestionOptions<T> | Promise<QuestionOptions<T>>;
|
|
86
|
+
handler: (data: Input) => Tasks | Promise<Tasks> | any | Promise<any>;
|
|
87
|
+
[key: string]: any;
|
|
88
|
+
}
|
|
89
|
+
export interface ClassCommandOptions<Input> extends BaseCommandOptions<Input> {
|
|
90
|
+
token: TokenProvider<CommandProvider>;
|
|
76
91
|
[key: string]: any;
|
|
77
92
|
}
|
|
93
|
+
export type CommandOptions<Input> = ClassCommandOptions<Input> | FunctionalCommandOptions<Input>;
|
|
94
|
+
export {};
|
|
@@ -9,11 +9,6 @@ declare module "inquirer" {
|
|
|
9
9
|
}
|
|
10
10
|
export type QuestionOptions<T extends Answers = Answers> = QuestionCollection<T>;
|
|
11
11
|
export interface CommandProvider<Ctx = any> {
|
|
12
|
-
/**
|
|
13
|
-
* Run a function before the main prompt. Useful for pre-loading data from the file system
|
|
14
|
-
* @param initialOptions
|
|
15
|
-
*/
|
|
16
|
-
$beforePrompt?(initialOptions: Partial<Ctx>): Partial<Ctx>;
|
|
17
12
|
/**
|
|
18
13
|
* Hook to create the main prompt for the command
|
|
19
14
|
* See https://github.com/enquirer/enquirer for more detail on question configuration.
|
|
@@ -25,11 +20,6 @@ export interface CommandProvider<Ctx = any> {
|
|
|
25
20
|
* @param ctx
|
|
26
21
|
*/
|
|
27
22
|
$mapContext?(ctx: Partial<Ctx>): Ctx;
|
|
28
|
-
/**
|
|
29
|
-
* Run something before the exec hook
|
|
30
|
-
* @param ctx
|
|
31
|
-
*/
|
|
32
|
-
$beforeExec?(ctx: Ctx): Promise<any>;
|
|
33
23
|
/**
|
|
34
24
|
* Run a command
|
|
35
25
|
* @param ctx
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { TokenProvider } from "@tsed/di";
|
|
2
2
|
import type { CommandProvider } from "./CommandProvider.js";
|
|
3
3
|
import type { PackageJson } from "./PackageJson.js";
|
|
4
4
|
export * from "./CliDefaultOptions.js";
|
|
5
5
|
export * from "./CommandData.js";
|
|
6
6
|
export * from "./CommandMetadata.js";
|
|
7
|
-
export * from "./
|
|
7
|
+
export * from "./CommandOptions.js";
|
|
8
8
|
export * from "./CommandProvider.js";
|
|
9
9
|
export * from "./PackageJson.js";
|
|
10
10
|
export * from "./ProjectPreferences.js";
|
|
@@ -15,7 +15,7 @@ declare global {
|
|
|
15
15
|
/**
|
|
16
16
|
* Load given commands
|
|
17
17
|
*/
|
|
18
|
-
commands:
|
|
18
|
+
commands: TokenProvider<CommandProvider>[];
|
|
19
19
|
/**
|
|
20
20
|
* Init Cli with defined argv
|
|
21
21
|
*/
|
|
@@ -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,14 @@ 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
|
-
* @param data
|
|
35
|
-
|
|
36
|
-
beforePrompt(cmdName: string, data?: CommandData): Promise<CommandData>;
|
|
37
|
-
/**
|
|
38
|
-
* Run prompt for a given command
|
|
39
|
-
* @param cmdName
|
|
40
|
-
* @param ctx Initial data
|
|
33
|
+
* @param data
|
|
34
|
+
* @param $ctx
|
|
41
35
|
*/
|
|
42
|
-
prompt(cmdName: string, ctx
|
|
36
|
+
prompt(cmdName: string, data: CommandData | undefined, $ctx: DIContext): Promise<CommandData>;
|
|
43
37
|
/**
|
|
44
38
|
* Run lifecycle
|
|
45
39
|
* @param cmdName
|
|
@@ -48,7 +42,7 @@ export declare class CliService {
|
|
|
48
42
|
getTasks(cmdName: string, data: any): Promise<Task[]>;
|
|
49
43
|
getPostInstallTasks(cmdName: string, data: any): Promise<any[]>;
|
|
50
44
|
createCommand(metadata: CommandMetadata): any;
|
|
51
|
-
|
|
45
|
+
load(): void;
|
|
52
46
|
private mapData;
|
|
53
47
|
/**
|
|
54
48
|
* Build command and sub-commands
|
|
@@ -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.10",
|
|
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.10",
|
|
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
|
package/lib/esm/decorators/on.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export var CommandStoreKeys;
|
|
2
|
-
(function (CommandStoreKeys) {
|
|
3
|
-
CommandStoreKeys["COMMAND"] = "command";
|
|
4
|
-
CommandStoreKeys["ADD"] = "$onAdd";
|
|
5
|
-
CommandStoreKeys["EXEC_HOOKS"] = "$onExec";
|
|
6
|
-
CommandStoreKeys["POST_INSTALL_HOOKS"] = "$onPostInstall";
|
|
7
|
-
CommandStoreKeys["PROMPT_HOOKS"] = "$onPrompt";
|
|
8
|
-
})(CommandStoreKeys || (CommandStoreKeys = {}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function On(hookName: string, name: string): MethodDecorator;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function OnAdd(cliPlugin: string): MethodDecorator;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function OnExec(cmdName: string): MethodDecorator;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function OnPostInstall(cmdName: string): MethodDecorator;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function OnPrompt(cmdName: string): MethodDecorator;
|
|
File without changes
|