@axeth/create-cli 2.0.5 → 2.0.6
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 +1 -1
- package/src/class/AxethCLI.ts +17 -7
package/package.json
CHANGED
package/src/class/AxethCLI.ts
CHANGED
|
@@ -3,7 +3,7 @@ import color from "colors";
|
|
|
3
3
|
import { TemplateGenerators } from "./TemplateGenerators.js";
|
|
4
4
|
import fs from "fs-extra";
|
|
5
5
|
import path from "path";
|
|
6
|
-
import { spawn } from "child_process";
|
|
6
|
+
import { exec, spawn } from "child_process";
|
|
7
7
|
|
|
8
8
|
class AxethCLI {
|
|
9
9
|
private promptGroups: Record<string, Record<string, (opts?: any) => any>> = {};
|
|
@@ -42,13 +42,11 @@ class AxethCLI {
|
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
if (openVSCode) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
45
|
+
spinner.start("Opening VSCode...");
|
|
46
|
+
await this.runCommand(`code ${path.join(process.cwd(), (addonInfo.addonName as string).replace(/\s+/g, "-").toLowerCase())}`);
|
|
47
|
+
spinner.stop("VSCode opened.");
|
|
49
48
|
}
|
|
50
49
|
prompt.outro(color.green(`\n Successfully created add-on: ${addonInfo.addonName}\n`));
|
|
51
|
-
process.exit(0);
|
|
52
50
|
}
|
|
53
51
|
|
|
54
52
|
private async generateTemplate(addonInfo: { [x: string]: any }, config: { [x: string]: any }, minecraftServerVersion: string, minecraftServerUIVersion: string, spinner: any) {
|
|
@@ -152,7 +150,7 @@ class AxethCLI {
|
|
|
152
150
|
private async getAxethCoreVersion() {
|
|
153
151
|
const moduleData: any = await fetch(`https://registry.npmjs.org/${this.axethCore}`)
|
|
154
152
|
.then(res => res.json());
|
|
155
|
-
|
|
153
|
+
|
|
156
154
|
const versions = Object.keys(moduleData.versions);
|
|
157
155
|
return versions.reverse()[0];
|
|
158
156
|
}
|
|
@@ -194,6 +192,18 @@ class AxethCLI {
|
|
|
194
192
|
private registerIntro(logo: string, title: string, version: string) {
|
|
195
193
|
prompt.intro(color.cyan(logo) + `\n ${title} - v${version}\n`);
|
|
196
194
|
}
|
|
195
|
+
|
|
196
|
+
private async runCommand(command: string): Promise<void> {
|
|
197
|
+
return new Promise((resolve, reject) => {
|
|
198
|
+
exec(command, (error, stdout, stderr) => {
|
|
199
|
+
if (error) {
|
|
200
|
+
reject(error);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
resolve();
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
}
|
|
197
207
|
}
|
|
198
208
|
|
|
199
209
|
export { AxethCLI };
|