@tsed/cli-core 7.0.0-beta.1 → 7.0.0-beta.11

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.
Files changed (61) hide show
  1. package/lib/esm/CliCore.js +24 -38
  2. package/lib/esm/decorators/command.js +1 -1
  3. package/lib/esm/decorators/index.js +0 -4
  4. package/lib/esm/fn/command.js +31 -3
  5. package/lib/esm/index.js +1 -2
  6. package/lib/esm/interfaces/CommandProvider.js +1 -2
  7. package/lib/esm/interfaces/ProjectPreferences.js +1 -0
  8. package/lib/esm/interfaces/index.js +1 -2
  9. package/lib/esm/packageManagers/PackageManagersModule.js +11 -19
  10. package/lib/esm/packageManagers/index.js +1 -0
  11. package/lib/esm/packageManagers/supports/BaseManager.js +2 -6
  12. package/lib/esm/packageManagers/supports/YarnBerryManager.js +4 -1
  13. package/lib/esm/services/CliFs.js +3 -1
  14. package/lib/esm/services/CliHttpClient.js +3 -2
  15. package/lib/esm/services/CliHttpLogClient.js +1 -1
  16. package/lib/esm/services/CliLoadFile.js +5 -18
  17. package/lib/esm/services/CliPlugins.js +2 -3
  18. package/lib/esm/services/CliService.js +65 -76
  19. package/lib/esm/services/ProjectPackageJson.js +17 -4
  20. package/lib/esm/utils/createInjector.js +1 -1
  21. package/lib/esm/utils/getCommandMetadata.js +34 -7
  22. package/lib/esm/utils/index.js +1 -0
  23. package/lib/esm/utils/loadPlugins.js +5 -18
  24. package/lib/esm/utils/validate.js +23 -0
  25. package/lib/types/CliCore.d.ts +2 -9
  26. package/lib/types/decorators/command.d.ts +2 -2
  27. package/lib/types/decorators/index.d.ts +0 -4
  28. package/lib/types/fn/command.d.ts +58 -3
  29. package/lib/types/index.d.ts +1 -2
  30. package/lib/types/interfaces/CommandData.d.ts +1 -0
  31. package/lib/types/interfaces/CommandMetadata.d.ts +17 -15
  32. package/lib/types/interfaces/{CommandParameters.d.ts → CommandOptions.d.ts} +20 -3
  33. package/lib/types/interfaces/CommandProvider.d.ts +4 -22
  34. package/lib/types/interfaces/ProjectPreferences.d.ts +2 -1
  35. package/lib/types/interfaces/index.d.ts +3 -3
  36. package/lib/types/packageManagers/PackageManagersModule.d.ts +1 -2
  37. package/lib/types/packageManagers/index.d.ts +1 -0
  38. package/lib/types/services/CliHttpLogClient.d.ts +1 -1
  39. package/lib/types/services/CliLoadFile.d.ts +2 -4
  40. package/lib/types/services/CliPlugins.d.ts +0 -1
  41. package/lib/types/services/CliService.d.ts +6 -10
  42. package/lib/types/services/ProjectPackageJson.d.ts +9 -0
  43. package/lib/types/utils/index.d.ts +1 -0
  44. package/lib/types/utils/mapCommanderArgs.d.ts +1 -1
  45. package/lib/types/utils/resolveConfiguration.d.ts +1 -1
  46. package/lib/types/utils/validate.d.ts +14 -0
  47. package/package.json +4 -7
  48. package/readme.md +2 -2
  49. package/lib/esm/decorators/on.js +0 -8
  50. package/lib/esm/decorators/onAdd.js +0 -5
  51. package/lib/esm/decorators/onExec.js +0 -5
  52. package/lib/esm/decorators/onPostInstall.js +0 -5
  53. package/lib/esm/decorators/onPrompt.js +0 -5
  54. package/lib/esm/domains/CommandStoreKeys.js +0 -8
  55. package/lib/types/decorators/on.d.ts +0 -1
  56. package/lib/types/decorators/onAdd.d.ts +0 -1
  57. package/lib/types/decorators/onExec.d.ts +0 -1
  58. package/lib/types/decorators/onPostInstall.d.ts +0 -1
  59. package/lib/types/decorators/onPrompt.d.ts +0 -1
  60. package/lib/types/domains/CommandStoreKeys.d.ts +0 -7
  61. /package/lib/esm/interfaces/{CommandParameters.js → CommandOptions.js} +0 -0
@@ -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 String(constant("project.rootDir"));
52
+ return this.cwd;
50
53
  }
54
+ /**
55
+ * @deprecated
56
+ * @param dir
57
+ */
51
58
  set dir(dir) {
52
- configuration().set("project.rootDir", dir);
53
- this.read();
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 = constant("project.rootDir");
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 = {
@@ -14,7 +14,7 @@ export function createInjector(settings = {}) {
14
14
  inj.settings.set({
15
15
  ...settings,
16
16
  project: {
17
- root: process.cwd(),
17
+ // root: process.cwd(),
18
18
  srcDir: "src",
19
19
  ...(settings.project || {})
20
20
  }
@@ -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 = {}, allowUnknownOption, description, options = {}, enableFeatures, disableReadUpPkg, bindLogger = true, ...opts } = Store.from(token)?.get(CommandStoreKeys.COMMAND);
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
  }
@@ -8,3 +8,4 @@ export * from "./mapCommanderArgs.js";
8
8
  export * from "./mapCommanderOptions.js";
9
9
  export * from "./parseOption.js";
10
10
  export * from "./resolveConfiguration.js";
11
+ export * from "./validate.js";
@@ -1,4 +1,4 @@
1
- import { GlobalProviders, injector, logger } from "@tsed/di";
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
- const { default: plugin } = await fs.importModule(mod, rootDir);
18
- if (!$inj.has(plugin)) {
19
- const provider = GlobalProviders.get(plugin)?.clone();
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
+ }
@@ -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
- readonly injector: InjectorService;
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 create<Cli extends CliCore = CliCore>(settings: Partial<TsED.Configuration>, module?: Type): Promise<Cli>;
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 { CommandParameters } from "../interfaces/CommandParameters.js";
2
- export declare function Command(options: CommandParameters): ClassDecorator;
1
+ import type { BaseCommandOptions } from "../interfaces/CommandOptions.js";
2
+ export declare function Command<Input = any>(options: BaseCommandOptions<Input>): ClassDecorator;
@@ -1,5 +1 @@
1
1
  export * from "./command.js";
2
- export * from "./onAdd.js";
3
- export * from "./onExec.js";
4
- export * from "./onPostInstall.js";
5
- export * from "./onPrompt.js";
@@ -1,3 +1,58 @@
1
- import { injectable, type TokenProvider } from "@tsed/di";
2
- import type { CommandParameters } from "../interfaces/CommandParameters.js";
3
- export declare function command(token: TokenProvider, options: CommandParameters): ReturnType<typeof injectable>;
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
+ handler: (data: Input) => import("../interfaces/Tasks.js").Tasks | Promise<import("../interfaces/Tasks.js").Tasks> | any | Promise<any>;
42
+ prompt?(initialOptions: Partial<Input>): import("@tsed/cli-prompts").PromptQuestion[] | Promise<import("@tsed/cli-prompts").PromptQuestion[]>;
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,5 +1,4 @@
1
1
  import "./utils/patchCommander.js";
2
- import Inquirer from "inquirer";
3
2
  export * from "./CliCore.js";
4
3
  export * from "./decorators/index.js";
5
4
  export * from "./fn/command.js";
@@ -7,8 +6,8 @@ export * from "./interfaces/index.js";
7
6
  export * from "./packageManagers/index.js";
8
7
  export * from "./services/index.js";
9
8
  export * from "./utils/index.js";
9
+ export * from "@tsed/cli-prompts";
10
10
  export * from "@tsed/core";
11
11
  export * from "@tsed/di";
12
12
  export * from "@tsed/logger";
13
13
  export * from "@tsed/normalize-path";
14
- export { Inquirer };
@@ -9,4 +9,5 @@ export interface CommandData extends TsED.InitialCommandData {
9
9
  verbose?: boolean;
10
10
  bindLogger?: boolean;
11
11
  rawArgs?: string[];
12
+ [key: string]: any;
12
13
  }
@@ -1,19 +1,21 @@
1
- import type { CommandArg, CommandOptions, CommandParameters } from "./CommandParameters.js";
2
- export interface CommandMetadata extends CommandParameters {
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
+ import type { PromptQuestion } from "@tsed/cli-prompts";
1
2
  import { Type } from "@tsed/core";
3
+ import type { TokenProvider } from "@tsed/di";
4
+ import type { JsonSchema } from "@tsed/schema";
5
+ import type { CommandProvider } 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 CommandOptions {
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 CommandParameters {
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]: CommandOptions;
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
+ handler: (data: Input) => Tasks | Promise<Tasks> | any | Promise<any>;
86
+ prompt?(initialOptions: Partial<Input>): PromptQuestion[] | Promise<PromptQuestion[]>;
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 {};
@@ -1,35 +1,17 @@
1
- import "inquirer-autocomplete-prompt";
2
- import type { Answers, QuestionCollection } from "inquirer";
3
- import AutocompletePrompt from "inquirer-autocomplete-prompt";
1
+ import type { PromptQuestion } from "@tsed/cli-prompts";
4
2
  import type { Tasks } from "./Tasks.js";
5
- declare module "inquirer" {
6
- interface QuestionMap<T extends Answers = Answers> {
7
- autocomplete: AutocompletePrompt.AutocompleteQuestionOptions<T>;
8
- }
9
- }
10
- export type QuestionOptions<T extends Answers = Answers> = QuestionCollection<T>;
11
3
  export interface CommandProvider<Ctx = any> {
12
4
  /**
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
- /**
18
- * Hook to create the main prompt for the command
19
- * See https://github.com/enquirer/enquirer for more detail on question configuration.
5
+ * Hook to create the main prompt for the command. Refer to {@link PromptQuestion}
6
+ * for supported question attributes.
20
7
  * @param initialOptions
21
8
  */
22
- $prompt?<T extends Answers = Answers>(initialOptions: Partial<Ctx>): QuestionOptions<T> | Promise<QuestionOptions<T>>;
9
+ $prompt?(initialOptions: Partial<Ctx>): PromptQuestion[] | Promise<PromptQuestion[]>;
23
10
  /**
24
11
  * Hook to map options
25
12
  * @param ctx
26
13
  */
27
14
  $mapContext?(ctx: Partial<Ctx>): Ctx;
28
- /**
29
- * Run something before the exec hook
30
- * @param ctx
31
- */
32
- $beforeExec?(ctx: Ctx): Promise<any>;
33
15
  /**
34
16
  * Run a command
35
17
  * @param ctx
@@ -2,7 +2,8 @@ export declare enum PackageManager {
2
2
  YARN = "yarn",
3
3
  YARN_BERRY = "yarn_berry",
4
4
  NPM = "npm",
5
- PNPM = "pnpm"
5
+ PNPM = "pnpm",
6
+ BUN = "bun"
6
7
  }
7
8
  declare global {
8
9
  namespace TsED {
@@ -1,10 +1,10 @@
1
- import { Type } from "@tsed/core";
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 "./CommandParameters.js";
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: Type<CommandProvider>[];
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
- constructor(packageManagers: BaseManager[]);
9
+ protected packageManagers: BaseManager[];
11
10
  init(options?: InstallOptions): Promise<void>;
12
11
  install(options?: InstallOptions): ({
13
12
  title: string;
@@ -2,4 +2,5 @@ export * from "./PackageManagersModule.js";
2
2
  export * from "./supports/BaseManager.js";
3
3
  export * from "./supports/NpmManager.js";
4
4
  export * from "./supports/PNpmManager.js";
5
+ export * from "./supports/YarnBerryManager.js";
5
6
  export * from "./supports/YarnManager.js";
@@ -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>): Logger;
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 { type Schema } from "ajv";
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?: Schema): Promise<Model>;
10
+ loadFile<Model = any>(path: string, schema?: JsonSchema<Model>): Promise<Model>;
13
11
  }
@@ -4,7 +4,6 @@ export declare class CliPlugins {
4
4
  name: string;
5
5
  readonly loadPlugins: typeof loadPlugins;
6
6
  private npmRegistryClient;
7
- private cliHooks;
8
7
  private packageJson;
9
8
  private packageManagers;
10
9
  searchPlugins(keyword?: string, options?: any): Promise<any>;
@@ -1,3 +1,4 @@
1
+ import { PromptRunner } from "@tsed/cli-prompts";
1
2
  import { DIContext } from "@tsed/di";
2
3
  import { Command } from "commander";
3
4
  import type { CommandData } from "../interfaces/CommandData.js";
@@ -13,6 +14,7 @@ export declare class CliService {
13
14
  protected hooks: CliHooks;
14
15
  protected projectPkg: ProjectPackageJson;
15
16
  protected packageManagers: PackageManagersModule;
17
+ protected promptRunner: PromptRunner;
16
18
  private commands;
17
19
  /**
18
20
  * Parse process.argv and runLifecycle action
@@ -26,20 +28,14 @@ export declare class CliService {
26
28
  * @param $ctx
27
29
  */
28
30
  runLifecycle(cmdName: string, data: CommandData | undefined, $ctx: DIContext): Promise<Promise<void>>;
29
- dispatch(cmdName: string, data: CommandData, $ctx: DIContext): Promise<void>;
30
31
  exec(cmdName: string, data: any, $ctx: DIContext): Promise<any>;
31
32
  /**
32
33
  * Run prompt for a given command
33
34
  * @param cmdName
34
- * @param data Initial 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
35
+ * @param data
36
+ * @param $ctx
41
37
  */
42
- prompt(cmdName: string, ctx?: CommandData): Promise<CommandData>;
38
+ prompt(cmdName: string, data: CommandData | undefined, $ctx: DIContext): Promise<CommandData>;
43
39
  /**
44
40
  * Run lifecycle
45
41
  * @param cmdName
@@ -48,7 +44,7 @@ export declare class CliService {
48
44
  getTasks(cmdName: string, data: any): Promise<Task[]>;
49
45
  getPostInstallTasks(cmdName: string, data: any): Promise<any[]>;
50
46
  createCommand(metadata: CommandMetadata): any;
51
- private load;
47
+ load(): void;
52
48
  private mapData;
53
49
  /**
54
50
  * 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;
@@ -8,3 +8,4 @@ export * from "./mapCommanderArgs.js";
8
8
  export * from "./mapCommanderOptions.js";
9
9
  export * from "./parseOption.js";
10
10
  export * from "./resolveConfiguration.js";
11
+ export * from "./validate.js";
@@ -1,4 +1,4 @@
1
- import type { CommandArg } from "../interfaces/CommandParameters.js";
1
+ import type { CommandArg } from "../interfaces/CommandOptions.js";
2
2
  export declare function mapCommanderArgs(args: {
3
3
  [arg: string]: CommandArg;
4
4
  }, commandArgs: any[]): any;
@@ -1 +1 @@
1
- export declare function resolveConfiguration(settings: any): any;
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
+ };