@axeth/create-cli 3.0.1 → 3.0.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @axeth/create-cli
2
2
 
3
+ ## 3.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 481eab1: Fixing import.meta.url which didn't work properly in the compiled dist file
8
+
3
9
  ## 3.0.1
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -91,6 +91,7 @@ var TemplateGenerators = class {
91
91
  };
92
92
 
93
93
  // src/class/AxethCLI.ts
94
+ import fs2 from "fs-extra";
94
95
  import path2 from "path";
95
96
  import { exec as exec2 } from "child_process";
96
97
  var AxethCLI = class {
@@ -101,54 +102,74 @@ var AxethCLI = class {
101
102
  this.axethCore = `@axeth/core`;
102
103
  console.clear();
103
104
  this.template = new TemplateGenerators();
104
- this.init();
105
+ console.log("Initializing Axeth CLI...");
106
+ this.init().catch((err) => {
107
+ console.error("Fatal error:", err);
108
+ process.exit(1);
109
+ });
105
110
  }
106
111
  async version() {
107
- const url = new URL("../../package.json", import.meta.url);
108
- const pkgData = await Bun.file(url).json();
109
- return pkgData.version;
112
+ try {
113
+ const pkgPath = path2.join(__dirname, "../../../package.json");
114
+ const pkgData = JSON.parse(await fs2.readFile(pkgPath, "utf-8"));
115
+ return pkgData.version;
116
+ } catch (err) {
117
+ try {
118
+ const cliPkgPath = path2.join(__dirname, "../../package.json");
119
+ const cliPkgData = JSON.parse(await fs2.readFile(cliPkgPath, "utf-8"));
120
+ return cliPkgData.version;
121
+ } catch {
122
+ return "3.0.0";
123
+ }
124
+ }
110
125
  }
111
126
  async init() {
112
- const version = await this.version();
113
- const addonInfo = await this.addonInfoPrompt(version, () => {
114
- process.exit(0);
115
- });
116
- const config = await this.configPrompt();
117
- const minecraftServerVersion = await this.getMinecraftServerVersion();
118
- const minecraftServerUIVersion = await this.getMinecraftServerUIVersion();
119
- const spinner2 = prompt.spinner({ indicator: "dots" });
120
- await this.generateTemplate(
121
- addonInfo,
122
- config,
123
- minecraftServerVersion,
124
- minecraftServerUIVersion,
125
- spinner2
126
- );
127
- const projectDir = path2.join(
128
- process.cwd(),
129
- addonInfo.addonName.replace(/\s+/g, "-").toLowerCase()
130
- );
131
- spinner2.start("Linting generated add-on...");
132
- await this.runCommand("bun run lint", projectDir).catch((err) => {
133
- spinner2.stop("Linting failed.");
134
- console.error(color.red(err));
135
- process.exit(1);
136
- });
137
- spinner2.stop("Add-on linted successfully.");
138
- const openVSCode = await prompt.confirm({
139
- message: "Open on VSCode?",
140
- initialValue: false
141
- });
142
- if (openVSCode === true) {
143
- spinner2.start("Opening VSCode...");
144
- await this.runCommand(`code "${projectDir}"`);
145
- spinner2.stop("VSCode opened.");
146
- }
147
- prompt.outro(
148
- color.green(`
127
+ try {
128
+ const version = await this.version();
129
+ const addonInfo = await this.addonInfoPrompt(version, () => {
130
+ process.exit(0);
131
+ });
132
+ const config = await this.configPrompt();
133
+ const minecraftServerVersion = await this.getMinecraftServerVersion();
134
+ const minecraftServerUIVersion = await this.getMinecraftServerUIVersion();
135
+ const spinner2 = prompt.spinner({ indicator: "dots" });
136
+ await this.generateTemplate(
137
+ addonInfo,
138
+ config,
139
+ minecraftServerVersion,
140
+ minecraftServerUIVersion,
141
+ spinner2
142
+ );
143
+ const projectDir = path2.join(
144
+ process.cwd(),
145
+ addonInfo.addonName.replace(/\s+/g, "-").toLowerCase()
146
+ );
147
+ spinner2.start("Linting generated add-on...");
148
+ await this.runCommand("bun run lint", projectDir).catch((err) => {
149
+ spinner2.stop("Linting failed.");
150
+ console.error(color.red(err));
151
+ process.exit(1);
152
+ });
153
+ spinner2.stop("Add-on linted successfully.");
154
+ const openVSCode = await prompt.confirm({
155
+ message: "Open on VSCode?",
156
+ initialValue: false
157
+ });
158
+ if (openVSCode === true) {
159
+ spinner2.start("Opening VSCode...");
160
+ await this.runCommand(`code "${projectDir}"`);
161
+ spinner2.stop("VSCode opened.");
162
+ }
163
+ prompt.outro(
164
+ color.green(`
149
165
  Successfully created add-on: ${addonInfo.addonName}
150
166
  `)
151
- );
167
+ );
168
+ process.exit(0);
169
+ } catch (err) {
170
+ console.error("Error in init:", err);
171
+ throw err;
172
+ }
152
173
  }
153
174
  async generateTemplate(addonInfo, config, minecraftServerVersion, minecraftServerUIVersion, spinner2) {
154
175
  await this.template.generate(
@@ -170,27 +191,36 @@ var AxethCLI = class {
170
191
  );
171
192
  }
172
193
  async addonInfoPrompt(version, onCancel) {
173
- return await new Promise((resolve) => {
174
- this.registerIntro(
175
- "\n _ _ \n /_\\ __ _____| |_ \n / _ \\ \\ \\ / -_) _|\n /_/ \\_\\/\\_\\_\\___|\\__|\n ",
176
- "Axeth CLI",
177
- version
178
- );
179
- this.registerPrompt("addonInfo", "addonName", "Add-on Name", "text", {
180
- placeholder: "My-Addon"
181
- });
182
- this.registerPrompt("addonInfo", "description", "Description", "text", {
183
- placeholder: "This addon create for Minecraft Bedrock (Axeth)"
184
- });
185
- this.registerPrompt("addonInfo", "version", "Version", "text", {
186
- placeholder: "1.0.0"
187
- });
188
- this.registerPrompt("addonInfo", "authors", "Authors", "text", {
189
- placeholder: "YourName,Axeth"
190
- });
191
- this.runPrompts("addonInfo", onCancel).then((responses) => {
192
- resolve(responses);
193
- });
194
+ return await new Promise((resolve, reject) => {
195
+ try {
196
+ console.log("Starting addon info prompt...");
197
+ this.registerIntro(
198
+ "\n _ _ \n /_\\ __ _____| |_ \n / _ \\ \\ \\ / -_) _|\n /_/ \\_\\/\\_\\_\\___|\\__|\n ",
199
+ "Axeth CLI",
200
+ version
201
+ );
202
+ this.registerPrompt("addonInfo", "addonName", "Add-on Name", "text", {
203
+ placeholder: "My-Addon"
204
+ });
205
+ this.registerPrompt("addonInfo", "description", "Description", "text", {
206
+ placeholder: "This addon create for Minecraft Bedrock (Axeth)"
207
+ });
208
+ this.registerPrompt("addonInfo", "version", "Version", "text", {
209
+ placeholder: "1.0.0"
210
+ });
211
+ this.registerPrompt("addonInfo", "authors", "Authors", "text", {
212
+ placeholder: "YourName,Axeth"
213
+ });
214
+ this.runPrompts("addonInfo", onCancel).then((responses) => {
215
+ resolve(responses);
216
+ }).catch((err) => {
217
+ console.error("Error in runPrompts:", err);
218
+ reject(err);
219
+ });
220
+ } catch (err) {
221
+ console.error("Error in addonInfoPrompt:", err);
222
+ reject(err);
223
+ }
194
224
  });
195
225
  }
196
226
  async configPrompt() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axeth/create-cli",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "module": "dist/index.js",
5
5
  "type": "module",
6
6
  "bin": {
@@ -17,59 +17,80 @@ class AxethCLI {
17
17
  constructor() {
18
18
  console.clear();
19
19
  this.template = new TemplateGenerators();
20
- this.init();
20
+ console.log("Initializing Axeth CLI...");
21
+ this.init().catch((err) => {
22
+ console.error("Fatal error:", err);
23
+ process.exit(1);
24
+ });
21
25
  }
22
26
 
23
27
  private async version() {
24
- const url = new URL("../../package.json", import.meta.url);
25
- const pkgData = await Bun.file(url).json();
26
- return pkgData.version;
28
+ try {
29
+ const pkgPath = path.join(__dirname, "../../../package.json");
30
+ const pkgData = JSON.parse(await fs.readFile(pkgPath, "utf-8"));
31
+ return pkgData.version;
32
+ } catch (err) {
33
+ // Fallback to reading from cli package.json
34
+ try {
35
+ const cliPkgPath = path.join(__dirname, "../../package.json");
36
+ const cliPkgData = JSON.parse(await fs.readFile(cliPkgPath, "utf-8"));
37
+ return cliPkgData.version;
38
+ } catch {
39
+ return "3.0.0";
40
+ }
41
+ }
27
42
  }
28
43
 
29
44
  private async init() {
30
- const version = await this.version();
31
- const addonInfo = await this.addonInfoPrompt(version, () => {
32
- process.exit(0);
33
- });
34
- const config = await this.configPrompt();
35
- const minecraftServerVersion = await this.getMinecraftServerVersion();
36
- const minecraftServerUIVersion = await this.getMinecraftServerUIVersion();
37
- const spinner = prompt.spinner({ indicator: "dots" });
45
+ try {
46
+ const version = await this.version();
47
+ const addonInfo = await this.addonInfoPrompt(version, () => {
48
+ process.exit(0);
49
+ });
50
+ const config = await this.configPrompt();
51
+ const minecraftServerVersion = await this.getMinecraftServerVersion();
52
+ const minecraftServerUIVersion = await this.getMinecraftServerUIVersion();
53
+ const spinner = prompt.spinner({ indicator: "dots" });
38
54
 
39
- await this.generateTemplate(
40
- addonInfo,
41
- config,
42
- minecraftServerVersion,
43
- minecraftServerUIVersion,
44
- spinner,
45
- );
55
+ await this.generateTemplate(
56
+ addonInfo,
57
+ config,
58
+ minecraftServerVersion,
59
+ minecraftServerUIVersion,
60
+ spinner,
61
+ );
46
62
 
47
- const projectDir = path.join(
48
- process.cwd(),
49
- (addonInfo.addonName as string).replace(/\s+/g, "-").toLowerCase(),
50
- );
63
+ const projectDir = path.join(
64
+ process.cwd(),
65
+ (addonInfo.addonName as string).replace(/\s+/g, "-").toLowerCase(),
66
+ );
51
67
 
52
- //cd and bun run lint
53
- spinner.start("Linting generated add-on...");
54
- await this.runCommand("bun run lint", projectDir).catch((err) => {
55
- spinner.stop("Linting failed.");
56
- console.error(color.red(err));
57
- process.exit(1);
58
- });
59
- spinner.stop("Add-on linted successfully.");
60
- const openVSCode = await prompt.confirm({
61
- message: "Open on VSCode?",
62
- initialValue: false,
63
- });
68
+ //cd and bun run lint
69
+ spinner.start("Linting generated add-on...");
70
+ await this.runCommand("bun run lint", projectDir).catch((err) => {
71
+ spinner.stop("Linting failed.");
72
+ console.error(color.red(err));
73
+ process.exit(1);
74
+ });
75
+ spinner.stop("Add-on linted successfully.");
76
+ const openVSCode = await prompt.confirm({
77
+ message: "Open on VSCode?",
78
+ initialValue: false,
79
+ });
64
80
 
65
- if (openVSCode === true) {
66
- spinner.start("Opening VSCode...");
67
- await this.runCommand(`code "${projectDir}"`);
68
- spinner.stop("VSCode opened.");
81
+ if (openVSCode === true) {
82
+ spinner.start("Opening VSCode...");
83
+ await this.runCommand(`code "${projectDir}"`);
84
+ spinner.stop("VSCode opened.");
85
+ }
86
+ prompt.outro(
87
+ color.green(`\n Successfully created add-on: ${addonInfo.addonName}\n`),
88
+ );
89
+ process.exit(0);
90
+ } catch (err) {
91
+ console.error("Error in init:", err);
92
+ throw err;
69
93
  }
70
- prompt.outro(
71
- color.green(`\n Successfully created add-on: ${addonInfo.addonName}\n`),
72
- );
73
94
  }
74
95
 
75
96
  private async generateTemplate(
@@ -105,27 +126,36 @@ class AxethCLI {
105
126
  }
106
127
 
107
128
  private async addonInfoPrompt(version: string, onCancel?: () => void) {
108
- return await new Promise<{ [x: string]: any }>((resolve) => {
109
- this.registerIntro(
110
- "\n _ _ \n /_\\ __ _____| |_ \n / _ \\ \\ \\ / -_) _|\n /_/ \\_\\/\\_\\_\\___|\\__|\n ",
111
- "Axeth CLI",
112
- version,
113
- );
114
- this.registerPrompt("addonInfo", "addonName", "Add-on Name", "text", {
115
- placeholder: "My-Addon",
116
- });
117
- this.registerPrompt("addonInfo", "description", "Description", "text", {
118
- placeholder: "This addon create for Minecraft Bedrock (Axeth)",
119
- });
120
- this.registerPrompt("addonInfo", "version", "Version", "text", {
121
- placeholder: "1.0.0",
122
- });
123
- this.registerPrompt("addonInfo", "authors", "Authors", "text", {
124
- placeholder: "YourName,Axeth",
125
- });
126
- this.runPrompts("addonInfo", onCancel).then((responses) => {
127
- resolve(responses);
128
- });
129
+ return await new Promise<{ [x: string]: any }>((resolve, reject) => {
130
+ try {
131
+ console.log("Starting addon info prompt...");
132
+ this.registerIntro(
133
+ "\n _ _ \n /_\\ __ _____| |_ \n / _ \\ \\ \\ / -_) _|\n /_/ \\_\\/\\_\\_\\___|\\__|\n ",
134
+ "Axeth CLI",
135
+ version,
136
+ );
137
+ this.registerPrompt("addonInfo", "addonName", "Add-on Name", "text", {
138
+ placeholder: "My-Addon",
139
+ });
140
+ this.registerPrompt("addonInfo", "description", "Description", "text", {
141
+ placeholder: "This addon create for Minecraft Bedrock (Axeth)",
142
+ });
143
+ this.registerPrompt("addonInfo", "version", "Version", "text", {
144
+ placeholder: "1.0.0",
145
+ });
146
+ this.registerPrompt("addonInfo", "authors", "Authors", "text", {
147
+ placeholder: "YourName,Axeth",
148
+ });
149
+ this.runPrompts("addonInfo", onCancel).then((responses) => {
150
+ resolve(responses);
151
+ }).catch((err) => {
152
+ console.error("Error in runPrompts:", err);
153
+ reject(err);
154
+ });
155
+ } catch (err) {
156
+ console.error("Error in addonInfoPrompt:", err);
157
+ reject(err);
158
+ }
129
159
  });
130
160
  }
131
161