@axeth/create-cli 2.1.0 → 2.1.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axeth/create-cli",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "bin": {
@@ -66,9 +66,9 @@ class AxethCLI {
66
66
  "axethApiVersion": config.axethApiVersion,
67
67
  "pack_name": addonInfo.addonName,
68
68
  "pack_description": addonInfo.description,
69
- "author_name": `[${(addonInfo.authors as string).split(",").map((name: string) => `"${name.trim()}"`)}]`,
70
- "version": `[${addonInfo.version.split(".").map((num: string) => `${parseInt(num, 10)}`)}]`,
71
- "seed": `${Math.floor(Math.random() * 1000000)}`,
69
+ "author_name": (addonInfo.authors as string).split(",").map((name: string) => name.trim()),
70
+ "version": addonInfo.version.split(".").map((num: string) => parseInt(num, 10)),
71
+ "seed": Math.floor(Math.random() * 1000000),
72
72
  "axethApiName": this.axethAPI,
73
73
  "axethCoreName": this.axethCore,
74
74
  "axethCoreVersion": config.axethCoreVersion,
@@ -29,10 +29,21 @@ class TemplateGenerators {
29
29
  let populatedContent = fileContent;
30
30
  for (const [key, value] of Object.entries(config)) {
31
31
  const placeholder = `{{${key}}}`;
32
- populatedContent = populatedContent.split(placeholder).join(value);
33
- this.registerFile(filePath, populatedContent);
32
+ let replacementValue: string;
33
+
34
+ // Determine the proper string representation based on type
35
+ if (Array.isArray(value)) {
36
+ replacementValue = JSON.stringify(value);
37
+ } else if (typeof value === "number") {
38
+ replacementValue = value.toString();
39
+ } else {
40
+ replacementValue = String(value);
41
+ }
42
+
43
+ populatedContent = populatedContent.split(placeholder).join(replacementValue);
34
44
  await new Promise((resolve) => setTimeout(resolve, 10)); // Slight delay to ensure responsiveness
35
45
  }
46
+ this.registerFile(filePath, populatedContent);
36
47
  }
37
48
  spinner.stop("Prepared template pack files.");
38
49
  spinner.start("Creating template pack files...");
@@ -53,9 +64,13 @@ class TemplateGenerators {
53
64
  spinner.stop("Dependencies installed.");
54
65
  }
55
66
 
56
- private async runCommand(command: string): Promise<void> {
67
+ private async runCommand(command: string, cwd?: string): Promise<void> {
57
68
  return new Promise((resolve, reject) => {
58
- exec(command, (error, stdout, stderr) => {
69
+ const options: any = {};
70
+ if (cwd) {
71
+ options.cwd = cwd;
72
+ }
73
+ exec(command, options, (error, stdout, stderr) => {
59
74
  if (error) {
60
75
  reject(error);
61
76
  return;
@@ -66,9 +81,9 @@ class TemplateGenerators {
66
81
  }
67
82
 
68
83
  private async installDependencies(projectName: string, dependencies?: string[]): Promise<void> {
69
- //cd to the generated pack directory
70
- const installCommand = `cd ${path.join(process.cwd(), projectName || '')} && bun add ${dependencies ? dependencies.join(' ') : this.dependencies.join(' ')}`;
71
- return await this.runCommand(installCommand);
84
+ const projectPath = path.join(process.cwd(), projectName || '');
85
+ const installCommand = `bun add ${dependencies ? dependencies.join(' ') : this.dependencies.join(' ')}`;
86
+ return await this.runCommand(installCommand, projectPath);
72
87
  }
73
88
  }
74
89