@axeth/create-cli 2.0.4 → 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
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>> = {};
|
|
@@ -36,10 +36,17 @@ class AxethCLI {
|
|
|
36
36
|
const spinner = prompt.spinner({ indicator: "dots" });
|
|
37
37
|
|
|
38
38
|
await this.generateTemplate(addonInfo, config, minecraftServerVersion, minecraftServerUIVersion, spinner);
|
|
39
|
-
await prompt.confirm({
|
|
39
|
+
const openVSCode = await prompt.confirm({
|
|
40
40
|
message: "Open on VSCode?",
|
|
41
41
|
initialValue: false
|
|
42
|
-
})
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
if (openVSCode) {
|
|
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.");
|
|
48
|
+
}
|
|
49
|
+
prompt.outro(color.green(`\n Successfully created add-on: ${addonInfo.addonName}\n`));
|
|
43
50
|
}
|
|
44
51
|
|
|
45
52
|
private async generateTemplate(addonInfo: { [x: string]: any }, config: { [x: string]: any }, minecraftServerVersion: string, minecraftServerUIVersion: string, spinner: any) {
|
|
@@ -143,7 +150,7 @@ class AxethCLI {
|
|
|
143
150
|
private async getAxethCoreVersion() {
|
|
144
151
|
const moduleData: any = await fetch(`https://registry.npmjs.org/${this.axethCore}`)
|
|
145
152
|
.then(res => res.json());
|
|
146
|
-
|
|
153
|
+
|
|
147
154
|
const versions = Object.keys(moduleData.versions);
|
|
148
155
|
return versions.reverse()[0];
|
|
149
156
|
}
|
|
@@ -185,6 +192,18 @@ class AxethCLI {
|
|
|
185
192
|
private registerIntro(logo: string, title: string, version: string) {
|
|
186
193
|
prompt.intro(color.cyan(logo) + `\n ${title} - v${version}\n`);
|
|
187
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
|
+
}
|
|
188
207
|
}
|
|
189
208
|
|
|
190
209
|
export { AxethCLI };
|
|
@@ -38,7 +38,7 @@ class TemplateGenerators {
|
|
|
38
38
|
spinner.start("Creating template pack files...");
|
|
39
39
|
|
|
40
40
|
for (const filePath of this.fileList.keys()) {
|
|
41
|
-
const fullPath = path.join(process.cwd(), config['
|
|
41
|
+
const fullPath = path.join(process.cwd(), config['project_name'], filePath);
|
|
42
42
|
const shortPath = filePath
|
|
43
43
|
.split('/')
|
|
44
44
|
.slice(-5)
|
|
@@ -49,7 +49,7 @@ class TemplateGenerators {
|
|
|
49
49
|
}
|
|
50
50
|
spinner.stop("Template pack files generated.");
|
|
51
51
|
spinner.start("Installing dependencies...");
|
|
52
|
-
await this.installDependencies(config['
|
|
52
|
+
await this.installDependencies(config['project_name'], this.dependencies);
|
|
53
53
|
spinner.stop("Dependencies installed.");
|
|
54
54
|
}
|
|
55
55
|
|