@tsed/cli-core 7.0.0-beta.7 → 7.0.0-beta.9

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.
@@ -29,7 +29,10 @@ let YarnBerryManager = class YarnBerryManager extends BaseManager {
29
29
  nodeLinker: "node-modules"
30
30
  });
31
31
  // then switch to berry
32
- this.cliExeca.runSync(this.cmd, ["set", "version", "berry"]);
32
+ try {
33
+ this.cliExeca.runSync(this.cmd, ["set", "version", "berry"]);
34
+ }
35
+ catch (er) { }
33
36
  }
34
37
  add(deps, options) {
35
38
  return this.run("add", [...deps], options);
@@ -51,7 +51,9 @@ export class CliFs extends RealFileSystemHost {
51
51
  return this.raw.ensureDirSync(path, options);
52
52
  }
53
53
  findUpFile(root, file) {
54
- return [join(root, file), join(root, "..", file), join(root, "..", "..", file), join(root, "..", "..", "..", file)].find((path) => this.fileExistsSync(path));
54
+ return [join(root, file), join(root, "..", file), join(root, "..", "..", file), join(root, "..", "..", "..", file)].find((path) => {
55
+ return this.fileExistsSync(path) || this.raw.existsSync(path);
56
+ });
55
57
  }
56
58
  async importModule(mod, root = process.cwd()) {
57
59
  try {
@@ -19,7 +19,6 @@ export class CliPlugins {
19
19
  this.name = constant("name", "");
20
20
  this.loadPlugins = loadPlugins;
21
21
  this.npmRegistryClient = inject(NpmRegistryClient);
22
- this.cliHooks = inject(CliHooks);
23
22
  this.packageJson = inject(ProjectPackageJson);
24
23
  this.packageManagers = inject(PackageManagersModule);
25
24
  }
@@ -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);
@@ -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>;
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.7",
4
+ "version": "7.0.0-beta.9",
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.7",
68
+ "@tsed/typescript": "7.0.0-beta.9",
69
69
  "@types/commander": "2.12.2",
70
70
  "@types/figures": "3.0.1",
71
71
  "@types/fs-extra": "^11.0.4",