@tsed/cli 7.0.0-alpha.9 → 7.0.0-beta.2

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.
@@ -15,8 +15,28 @@ register(pathToFileURL(join(import.meta.dirname, `../loaders/alias.hook.${EXT}`)
15
15
  },
16
16
  transferList: []
17
17
  });
18
- const { Cli } = await import("../Cli.js");
19
- Cli.bootstrap({}).catch((error) => {
18
+ const { commands, CliCore, PKG, TEMPLATE_DIR, ArchitectureConvention, ProjectConvention } = await import("../index.js");
19
+ CliCore.bootstrap({
20
+ name: "tsed",
21
+ pkg: PKG,
22
+ templateDir: TEMPLATE_DIR,
23
+ plugins: true,
24
+ updateNotifier: true,
25
+ checkPrecondition: true,
26
+ commands,
27
+ defaultProjectPreferences() {
28
+ return {
29
+ convention: ProjectConvention.DEFAULT,
30
+ architecture: ArchitectureConvention.DEFAULT
31
+ };
32
+ },
33
+ project: {
34
+ reinstallAfterRun: true
35
+ },
36
+ logger: {
37
+ level: "info"
38
+ }
39
+ }).catch((error) => {
20
40
  console.error(error);
21
41
  process.exit(-1);
22
42
  });
@@ -115,7 +115,7 @@ export class InitCmd {
115
115
  ctx.runtime && this.packageJson.setPreference("runtime", ctx.runtime);
116
116
  ctx.architecture && this.packageJson.setPreference("architecture", ctx.architecture);
117
117
  ctx.convention && this.packageJson.setPreference("convention", ctx.convention);
118
- ctx.platform && this.packageJson.setPreference("platform", ctx.convention);
118
+ ctx.platform && this.packageJson.setPreference("platform", ctx.platform);
119
119
  ctx.GH_TOKEN && this.packageJson.setGhToken(ctx.GH_TOKEN);
120
120
  await createTasksRunner([
121
121
  {
@@ -230,7 +230,7 @@ export class InitCmd {
230
230
  if (ctx.eslint || ctx.testing) {
231
231
  const runtime = this.runtimes.get();
232
232
  const scripts = {
233
- test: [ctx.eslint && runtime.run("test:lint"), ctx.testing && runtime.run("test:coverage")].filter(Boolean).join("&&")
233
+ test: [ctx.eslint && runtime.run("test:lint"), ctx.testing && runtime.run("test:coverage")].filter(Boolean).join(" && ")
234
234
  };
235
235
  this.packageJson.addScripts(scripts);
236
236
  }
package/lib/esm/index.js CHANGED
@@ -1,7 +1,8 @@
1
+ import "@tsed/logger-std";
1
2
  import "./templates/index.js";
2
- export * from "./Cli.js";
3
3
  export * from "./commands/add/AddCmd.js";
4
4
  export * from "./commands/generate/GenerateCmd.js";
5
+ export { default as commands } from "./commands/index.js";
5
6
  export * from "./commands/init/config/FeaturesPrompt.js";
6
7
  export * from "./commands/init/config/FeaturesPrompt.js";
7
8
  export * from "./commands/init/InitCmd.js";
@@ -17,3 +18,4 @@ export * from "./services/CliProjectService.js";
17
18
  export * from "./services/CliTemplatesService.js";
18
19
  export * from "./services/ProjectClient.js";
19
20
  export * from "./utils/defineTemplate.js";
21
+ export { CliCore } from "@tsed/cli-core";
@@ -15,7 +15,9 @@ import { CliTemplatesService } from "./CliTemplatesService.js";
15
15
  export class CliProjectService {
16
16
  constructor() {
17
17
  this.templates = inject(CliTemplatesService);
18
- this.rootDir = constant("project.rootDir", process.cwd());
18
+ }
19
+ get rootDir() {
20
+ return constant("project.rootDir", "");
19
21
  }
20
22
  get srcDir() {
21
23
  return join(...[this.rootDir, constant("project.srcDir")].filter(Boolean));
@@ -32,7 +34,7 @@ export class CliProjectService {
32
34
  this.project = new ProjectClient({
33
35
  rootDir: this.rootDir
34
36
  });
35
- const files = fs.globSync(["!**/node_modules/**", join(constant("project.rootDir", process.cwd()), "**/*.ts")]);
37
+ const files = fs.globSync(["!**/node_modules/**", join(this.rootDir, "**/*.ts")]);
36
38
  files.forEach((file) => {
37
39
  this.project.createSourceFile(file, fs.readFileSync(file, "utf8"), {
38
40
  overwrite: true
@@ -6,12 +6,13 @@ import { TEMPLATE_DIR } from "../constants/index.js";
6
6
  import { mapDefaultTemplateOptions } from "./mappers/mapDefaultTemplateOptions.js";
7
7
  export class CliTemplatesService {
8
8
  constructor() {
9
- this.rootDir = constant("project.rootDir", process.cwd());
10
9
  this.fs = inject(CliFs);
11
- this.#templates = new Map();
10
+ this.renderedFiles = [];
12
11
  }
13
12
  #customTemplates;
14
- #templates;
13
+ get rootDir() {
14
+ return constant("project.rootDir", "");
15
+ }
15
16
  get srcDir() {
16
17
  return join(...[this.rootDir, constant("project.srcDir")].filter(Boolean));
17
18
  }
@@ -89,7 +90,7 @@ export class CliTemplatesService {
89
90
  template.fileName?.replace("{{symbolName}}", opts.symbolName)?.replace("{{srcDir}}", this.srcDir) ||
90
91
  opts.symbolName;
91
92
  const outputPath = `${filePath}${template.ext ? "." + template.ext : ""}`;
92
- return {
93
+ return this.pushRenderResult({
93
94
  templateId,
94
95
  content: render,
95
96
  outputPath,
@@ -97,20 +98,24 @@ export class CliTemplatesService {
97
98
  symbolName: opts.symbolName,
98
99
  symbolPath: opts.symbolPath,
99
100
  symbolPathBasename: opts.symbolPathBasename
100
- };
101
+ });
101
102
  }
102
103
  else {
103
104
  const from = data.from || TEMPLATE_DIR;
104
105
  const fromPath = join(from, templateId.replace("{{srcDir}}", "src"));
105
106
  if (await this.fs.fileExists(fromPath)) {
106
107
  const content = await inject(CliFs).readFile(fromPath);
107
- return {
108
+ return this.pushRenderResult({
108
109
  templateId,
109
110
  content,
110
111
  outputPath: templateId.replace("{{srcDir}}", constant("project.srcDir", ""))
111
- };
112
+ });
112
113
  }
113
114
  }
114
115
  }
116
+ pushRenderResult(renderedFile) {
117
+ this.renderedFiles.push(renderedFile);
118
+ return renderedFile;
119
+ }
115
120
  }
116
121
  injectable(CliTemplatesService);