@xrystal/core 3.7.7 ā 3.7.9
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/bin/main-cli.js +30 -15
- package/package.json +1 -1
package/bin/main-cli.js
CHANGED
|
@@ -57,17 +57,28 @@ const setupCLI = async () => {
|
|
|
57
57
|
|
|
58
58
|
cli
|
|
59
59
|
.command("create <project-name> [target-path]")
|
|
60
|
-
.description("
|
|
60
|
+
.description("Project initializer with git setup")
|
|
61
61
|
.action(async (projectName, targetDir) => {
|
|
62
|
-
|
|
63
|
-
const
|
|
62
|
+
let targetPath = ""
|
|
63
|
+
const isCurrentDir = projectName === "."
|
|
64
|
+
|
|
65
|
+
if (targetDir) {
|
|
66
|
+
const baseDir = path.resolve(process.cwd(), targetDir)
|
|
67
|
+
targetPath = isCurrentDir ? baseDir : path.join(baseDir, projectName)
|
|
68
|
+
} else {
|
|
69
|
+
targetPath = isCurrentDir ? process.cwd() : path.resolve(process.cwd(), projectName)
|
|
70
|
+
}
|
|
64
71
|
|
|
65
72
|
if (fs.existsSync(targetPath) && fs.readdirSync(targetPath).length > 0) {
|
|
66
73
|
console.log(chalk.red(`ā Error: Target directory '${targetPath}' is not empty!`))
|
|
67
74
|
process.exit(1)
|
|
68
75
|
}
|
|
69
76
|
|
|
70
|
-
|
|
77
|
+
if (!fs.existsSync(targetPath)) {
|
|
78
|
+
fs.mkdirSync(targetPath, { recursive: true })
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const spinner = ora("Cloning and initializing git...").start()
|
|
71
82
|
|
|
72
83
|
try {
|
|
73
84
|
execSync(`git clone --depth 1 ${templateRepoUri} "${targetPath}"`, { stdio: "ignore" })
|
|
@@ -77,24 +88,28 @@ const setupCLI = async () => {
|
|
|
77
88
|
fs.rmSync(gitFolder, { recursive: true, force: true })
|
|
78
89
|
}
|
|
79
90
|
|
|
80
|
-
|
|
81
|
-
|
|
91
|
+
try {
|
|
92
|
+
execSync(`git init`, { cwd: targetPath, stdio: "ignore" })
|
|
93
|
+
} catch (e) {
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
spinner.succeed(chalk.green("Template cloned and git initialized!"))
|
|
97
|
+
console.log(chalk.blue(`\nš¦ Installing dependencies with bun...`))
|
|
82
98
|
|
|
83
|
-
|
|
84
|
-
execSync(installCmd, { cwd: targetPath, stdio: "inherit" })
|
|
99
|
+
execSync("bun install", { cwd: targetPath, stdio: "inherit" })
|
|
85
100
|
|
|
86
|
-
console.log(chalk.green("\nā
|
|
87
|
-
console.log(chalk.white(`\nStart Project:\n`))
|
|
101
|
+
console.log(chalk.green("\nā
Done!"))
|
|
88
102
|
|
|
89
|
-
|
|
90
|
-
|
|
103
|
+
const relativePath = path.relative(process.cwd(), targetPath)
|
|
104
|
+
if (relativePath && relativePath !== ".") {
|
|
105
|
+
console.log(chalk.cyan(`\n cd ${relativePath}`))
|
|
91
106
|
}
|
|
92
107
|
|
|
93
|
-
console.log(chalk.cyan(`
|
|
108
|
+
console.log(chalk.cyan(` bun run dev`))
|
|
94
109
|
|
|
95
110
|
} catch (err) {
|
|
96
|
-
spinner.fail(chalk.red("Failed
|
|
97
|
-
console.error(chalk.red(`\
|
|
111
|
+
spinner.fail(chalk.red("Failed!"))
|
|
112
|
+
console.error(chalk.red(`\nDetails: ${err.message}`))
|
|
98
113
|
|
|
99
114
|
if (fs.existsSync(targetPath) && targetPath !== process.cwd() && fs.readdirSync(targetPath).length === 0) {
|
|
100
115
|
fs.rmSync(targetPath, { recursive: true, force: true })
|