@tsed/cli 7.0.2 → 7.1.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.
@@ -59,7 +59,9 @@ export class CreateTemplateCommand {
59
59
  };
60
60
  }
61
61
  $exec(ctx) {
62
- this.projectPackageJson.addDevDependencies({ "@tsed/cli": PKG.version });
62
+ if (this.projectPackageJson.devDependencies["@tsed/cli"] === undefined) {
63
+ this.projectPackageJson.addDevDependencies({ "@tsed/cli": PKG.version });
64
+ }
63
65
  return [
64
66
  {
65
67
  title: "Generate " + ctx.from === "new" ? `new template ${ctx.templateId}` : `template ${ctx.templateId} from ${ctx.from}`,
@@ -1,6 +1,6 @@
1
1
  import { join } from "node:path";
2
2
  import { CliFs } from "@tsed/cli-core";
3
- import { constant, context, inject, injectable, injectMany, logger } from "@tsed/di";
3
+ import { constant, context, inject, injectable, injectMany, lazyInject, logger } from "@tsed/di";
4
4
  import { globby } from "globby";
5
5
  import { TEMPLATE_DIR } from "../constants/index.js";
6
6
  import { mapDefaultTemplateOptions } from "./mappers/mapDefaultTemplateOptions.js";
@@ -29,18 +29,17 @@ export class CliTemplatesService {
29
29
  });
30
30
  const promises = files.map(async (file) => {
31
31
  try {
32
- const files = join(this.templatesDir, file);
33
- const { default: token } = await import(files.replace(".ts", ".js"));
34
- if (token) {
35
- return inject(token);
36
- }
32
+ const modulePath = join(this.templatesDir, file);
33
+ return await lazyInject(() => import(modulePath));
37
34
  }
38
35
  catch (er) {
39
36
  logger().warn("Unable to load custom template %s: %s", file, er.message);
40
37
  }
41
38
  });
42
39
  let customs = await Promise.all(promises);
43
- this.#customTemplates = customs.map((template) => {
40
+ this.#customTemplates = customs
41
+ .filter((template) => !!template)
42
+ .map((template) => {
44
43
  return {
45
44
  ...template,
46
45
  label: template.label + " (custom)"
@@ -16,7 +16,7 @@ export default defineTemplate({
16
16
  fileName: "{{symbolName}}.services",
17
17
  outputDir: "{{srcDir}}/services",
18
18
  render(symbolName, context) {
19
- return \`export class \${symbolName} {}\`
19
+ return \`export class \${symbolName} {}\`;
20
20
  }
21
21
  });`;
22
22
  }