@tsed/cli-core 3.14.1 → 3.17.0

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.
@@ -697,24 +697,15 @@ function getLogger() {
697
697
  }
698
698
 
699
699
  function createConfiguration(injector) {
700
- const provider = GlobalProviders.get(CliConfiguration).clone();
701
- provider.instance = injector.invoke(provider.useClass);
702
- injector.addProvider(CliConfiguration, provider);
703
- return provider.instance;
704
- }
705
-
706
- function createProjectPackageJson(injector) {
707
- const provider = GlobalProviders.get(ProjectPackageJson).clone();
708
- injector.addProvider(ProjectPackageJson, provider);
709
- provider.instance = injector.invoke(provider);
710
- return provider.instance;
700
+ injector.addProvider(CliConfiguration);
701
+ return injector.invoke(CliConfiguration);
711
702
  }
712
703
 
713
704
  function createInjector(settings = {}) {
714
705
  const injector = new InjectorService();
715
706
  injector.settings = createConfiguration(injector);
716
707
  logger = injector.logger = new Logger(settings.name || "CLI");
717
- createProjectPackageJson(injector);
708
+ injector.addProvider(ProjectPackageJson);
718
709
  injector.settings.set(settings);
719
710
  /* istanbul ignore next */
720
711
 
@@ -1010,6 +1001,7 @@ let CliService = class CliService {
1010
1001
 
1011
1002
 
1012
1003
  async runLifecycle(cmdName, data = {}) {
1004
+ data = await this.beforePrompt(cmdName, data);
1013
1005
  data = await this.prompt(cmdName, data);
1014
1006
 
1015
1007
  try {
@@ -1045,6 +1037,25 @@ let CliService = class CliService {
1045
1037
  */
1046
1038
 
1047
1039
 
1040
+ async beforePrompt(cmdName, ctx = {}) {
1041
+ const provider = this.commands.get(cmdName);
1042
+ const instance = this.injector.get(provider.useClass);
1043
+ const verbose = ctx.verbose;
1044
+
1045
+ if (instance.$beforePrompt) {
1046
+ ctx = await instance.$beforePrompt(JSON.parse(JSON.stringify(ctx)));
1047
+ ctx.verbose = verbose;
1048
+ }
1049
+
1050
+ return ctx;
1051
+ }
1052
+ /**
1053
+ * Run prompt for a given command
1054
+ * @param cmdName
1055
+ * @param ctx Initial data
1056
+ */
1057
+
1058
+
1048
1059
  async prompt(cmdName, ctx = {}) {
1049
1060
  const provider = this.commands.get(cmdName);
1050
1061
  const instance = this.injector.get(provider.useClass);
@@ -1559,7 +1570,7 @@ async function loadPlugins(injector) {
1559
1570
  } = injector.settings;
1560
1571
  const projectPackageJson = injector.invoke(ProjectPackageJson);
1561
1572
  const fs = injector.invoke(CliFs);
1562
- const promises = Object.keys(projectPackageJson.allDependencies).filter(mod => mod.startsWith(`@${name}/cli-plugin`) || mod.startsWith(`${name}-cli-plugin`)).map(async mod => {
1573
+ const promises = Object.keys(projectPackageJson.allDependencies).filter(mod => mod.startsWith(`@${name}/cli-plugin`) || mod.includes(`${name}-cli-plugin`)).map(async mod => {
1563
1574
  const {
1564
1575
  default: plugin
1565
1576
  } = await fs.importModule(mod, rootDir);
@@ -1769,7 +1780,7 @@ let CliPlugins = class CliPlugins {
1769
1780
  }
1770
1781
 
1771
1782
  isPlugin(name) {
1772
- return name.startsWith(`@${this.name}/cli-plugin`) || name.startsWith(`${this.name}-cli-plugin`);
1783
+ return name.startsWith(`@${this.name}/cli-plugin`) || name.includes(`${this.name}-cli-plugin`);
1773
1784
  }
1774
1785
 
1775
1786
  };