@tsed/cli 7.0.0-beta.12 → 7.0.0-beta.13

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.
@@ -1,4 +1,4 @@
1
- import { CliPlugins, command, createSubTasks, inject, PackageManagersModule, ProjectPackageJson } from "@tsed/cli-core";
1
+ import { CliPlugins, command, inject, PackageManagersModule, ProjectPackageJson } from "@tsed/cli-core";
2
2
  export class AddCmd {
3
3
  constructor() {
4
4
  this.cliPlugins = inject(CliPlugins);
@@ -20,21 +20,18 @@ export class AddCmd {
20
20
  $exec(ctx) {
21
21
  this.packageJson.addDevDependency(ctx.name, "latest");
22
22
  return [
23
- {
24
- title: "Install plugins",
25
- task: createSubTasks(() => this.packageManagers.install(ctx), { ...ctx, concurrent: false })
26
- },
23
+ this.packageManagers.task("Install plugins", ctx),
27
24
  {
28
25
  title: "Load plugins",
29
26
  task: () => this.cliPlugins.loadPlugins()
30
27
  },
31
28
  {
32
29
  title: "Install plugins dependencies",
33
- task: createSubTasks(() => this.cliPlugins.addPluginsDependencies(ctx), { ...ctx, concurrent: false })
30
+ task: () => this.cliPlugins.addPluginsDependencies(ctx)
34
31
  },
35
32
  {
36
33
  title: "Transform files",
37
- task: createSubTasks(() => this.cliPlugins.addPluginsDependencies(ctx), { ...ctx, concurrent: false })
34
+ task: () => this.cliPlugins.addPluginsDependencies(ctx)
38
35
  }
39
36
  ];
40
37
  }
@@ -1,5 +1,6 @@
1
1
  import { basename, join } from "node:path";
2
- import { CliExeca, CliFs, CliLoadFile, cliPackageJson, CliPlugins, command, Configuration, createSubTasks, createTasksRunner, inject, PackageManagersModule, ProjectPackageJson } from "@tsed/cli-core";
2
+ import { CliExeca, CliFs, CliLoadFile, cliPackageJson, CliPlugins, command, Configuration, inject, PackageManagersModule, ProjectPackageJson } from "@tsed/cli-core";
3
+ import { tasks } from "@tsed/cli-tasks";
3
4
  import { isString } from "@tsed/core";
4
5
  import { constant } from "@tsed/di";
5
6
  import { $asyncAlter } from "@tsed/hooks";
@@ -74,7 +75,7 @@ export class InitCmd {
74
75
  srcDir: constant("project.srcDir", "src")
75
76
  };
76
77
  }
77
- async $exec(ctx) {
78
+ preExec(ctx) {
78
79
  this.fs.ensureDirSync(this.packageJson.cwd);
79
80
  ctx.projectName && (this.packageJson.name = ctx.projectName);
80
81
  ctx.packageManager && this.packageJson.setPreference("packageManager", ctx.packageManager);
@@ -83,7 +84,7 @@ export class InitCmd {
83
84
  ctx.convention && this.packageJson.setPreference("convention", ctx.convention);
84
85
  ctx.platform && this.packageJson.setPreference("platform", ctx.platform);
85
86
  ctx.GH_TOKEN && this.packageJson.setGhToken(ctx.GH_TOKEN);
86
- await createTasksRunner([
87
+ return tasks([
87
88
  {
88
89
  title: "Write RC files",
89
90
  skip: () => !ctx.premium,
@@ -101,19 +102,19 @@ export class InitCmd {
101
102
  this.addFeatures(ctx);
102
103
  }
103
104
  },
104
- {
105
- title: "Install plugins",
106
- task: createSubTasks(() => this.packageManagers.install(ctx), { ...ctx, concurrent: false })
107
- },
105
+ this.packageManagers.task("Install plugins", ctx),
108
106
  {
109
107
  title: "Load plugins",
110
108
  task: () => this.cliPlugins.loadPlugins()
111
109
  },
112
110
  {
113
111
  title: "Install plugins dependencies",
114
- task: createSubTasks(() => this.cliPlugins.addPluginsDependencies(ctx), { ...ctx, concurrent: false })
112
+ task: () => this.cliPlugins.addPluginsDependencies(ctx)
115
113
  }
116
114
  ], ctx);
115
+ }
116
+ async $exec(ctx) {
117
+ await this.preExec(ctx);
117
118
  const runtime = this.runtimes.get();
118
119
  ctx = {
119
120
  ...ctx,
@@ -128,13 +129,13 @@ export class InitCmd {
128
129
  },
129
130
  {
130
131
  title: "Alter package json",
131
- task: () => {
132
- return $asyncAlter("$alterPackageJson", this.packageJson, [ctx]);
132
+ task: async () => {
133
+ await $asyncAlter("$alterPackageJson", this.packageJson, [ctx]);
133
134
  }
134
135
  },
135
136
  {
136
137
  title: "Generate additional project files",
137
- task: createSubTasks(async () => {
138
+ task: async () => {
138
139
  const subTasks = [
139
140
  ...(await exec("generate", {
140
141
  //...ctx,
@@ -153,7 +154,7 @@ export class InitCmd {
153
154
  : [])
154
155
  ];
155
156
  return $asyncAlter("$alterInitSubTasks", subTasks, [ctx]);
156
- }, { ...ctx, concurrent: false })
157
+ }
157
158
  },
158
159
  {
159
160
  title: "transform generated files to the project configuration",
@@ -456,13 +456,12 @@ export const FeaturesPrompt = (availableRuntimes, availablePackageManagers) => [
456
456
  name: "passportPackage",
457
457
  message: "Which passport package ?",
458
458
  when: hasFeature(FeatureType.PASSPORTJS),
459
- async source(_, input) {
459
+ async source(_) {
460
460
  const result = await inject(CliHttpClient).get(`https://www.passportjs.org/packages/-/all.json`, {});
461
461
  return Object.values(result)
462
462
  .filter((o) => {
463
- return o.name?.startsWith("passport-");
463
+ return o.name && o.name?.startsWith("passport-");
464
464
  })
465
- .filter((item) => item.name.toLowerCase().includes(input.toLowerCase()))
466
465
  .map((item) => ({
467
466
  name: `${item.name} - ${item.description}`,
468
467
  value: item.name
@@ -15,7 +15,6 @@ export class RunCmd {
15
15
  await this.runScript.run(cmd, [...args, path, ctx.command, ...ctx.rawArgs], {
16
16
  env: process.env
17
17
  });
18
- return [];
19
18
  }
20
19
  }
21
20
  command({
@@ -1,4 +1,4 @@
1
- import { CliPackageJson, command, createSubTasks, inject, NpmRegistryClient, PackageManagersModule, ProjectPackageJson } from "@tsed/cli-core";
1
+ import { CliPackageJson, command, inject, NpmRegistryClient, PackageManagersModule, ProjectPackageJson } from "@tsed/cli-core";
2
2
  import { getValue } from "@tsed/core";
3
3
  import semver from "semver";
4
4
  import { IGNORE_TAGS, IGNORE_VERSIONS, MINIMAL_TSED_VERSION } from "../../constants/index.js";
@@ -59,12 +59,7 @@ export class UpdateCmd {
59
59
  }
60
60
  });
61
61
  }
62
- return [
63
- {
64
- title: "Update packages",
65
- task: createSubTasks(() => this.packageManagers.install(), { ...ctx, concurrent: false })
66
- }
67
- ];
62
+ return [this.packageManagers.task("Update dependencies", ctx)];
68
63
  }
69
64
  async getAvailableVersions() {
70
65
  const { versions } = await this.npmRegistryClient.info("@tsed/platform-http", 10);
@@ -42,7 +42,7 @@ export class ${symbolName} implements CommandProvider {
42
42
  };
43
43
  }
44
44
  /**
45
- * This step run your tasks with Listr module
45
+ * This step runs your tasks via the @clack/prompts-based @tsed/cli-tasks helpers.
46
46
  */
47
47
  async $exec(ctx: ${symbolName}Context): Promise<any> {
48
48
  return [