@xrystal/core 3.6.5 → 3.6.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.
Files changed (2) hide show
  1. package/bin/main-cli.js +16 -13
  2. package/package.json +1 -1
package/bin/main-cli.js CHANGED
@@ -56,18 +56,14 @@ const setupCLI = async () => {
56
56
  }
57
57
 
58
58
  cli
59
- .command("create <project-name>")
59
+ .command("create <project-name> [target-path]")
60
60
  .description("Clone template from GitHub (Private/Public)")
61
- .action(async (projectName) => {
62
- if (!projectName) {
63
- console.log(chalk.red("❌ Error: Project name is required"))
64
- process.exit(1)
65
- }
61
+ .action(async (projectName, targetDir) => {
62
+ const rawTarget = targetDir || (projectName === "." ? "." : projectName)
63
+ const targetPath = path.resolve(process.cwd(), rawTarget)
66
64
 
67
- const targetPath = path.join(process.cwd(), projectName)
68
-
69
- if (fs.existsSync(targetPath)) {
70
- console.log(chalk.red(`❌ Error: '${projectName}' folder already exists!`))
65
+ if (fs.existsSync(targetPath) && fs.readdirSync(targetPath).length > 0) {
66
+ console.log(chalk.red(`❌ Error: Target directory '${targetPath}' is not empty!`))
71
67
  process.exit(1)
72
68
  }
73
69
 
@@ -82,20 +78,27 @@ const setupCLI = async () => {
82
78
  }
83
79
 
84
80
  spinner.succeed(chalk.green("Template cloned successfully!"))
85
- console.log(chalk.blue(`\n📦 Dependencies loading with ${packageManager}... (${projectName})`))
81
+ console.log(chalk.blue(`\n📦 Dependencies loading with ${packageManager}...`))
86
82
 
87
83
  const installCmd = isBun ? "bun install" : "npm install"
88
84
  execSync(installCmd, { cwd: targetPath, stdio: "inherit" })
89
85
 
90
86
  console.log(chalk.green("\n✅ Project Ready!"))
91
87
  console.log(chalk.white(`\nStart Project:\n`))
92
- console.log(chalk.cyan(` cd ${projectName}`))
88
+
89
+ if (targetPath !== process.cwd()) {
90
+ console.log(chalk.cyan(` cd ${path.relative(process.cwd(), targetPath)}`))
91
+ }
92
+
93
93
  console.log(chalk.cyan(` ${packageManager} run dev`))
94
94
 
95
95
  } catch (err) {
96
96
  spinner.fail(chalk.red("Failed to clone or install!"))
97
97
  console.error(chalk.red(`\nError details: ${err.message}`))
98
- if (fs.existsSync(targetPath)) fs.rmSync(targetPath, { recursive: true, force: true })
98
+
99
+ if (fs.existsSync(targetPath) && targetPath !== process.cwd() && fs.readdirSync(targetPath).length === 0) {
100
+ fs.rmSync(targetPath, { recursive: true, force: true })
101
+ }
99
102
  }
100
103
  })
101
104
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Yusuf Yasir KAYGUSUZ",
3
3
  "name": "@xrystal/core",
4
- "version": "3.6.5",
4
+ "version": "3.6.6",
5
5
  "description": "Project core for xrystal",
6
6
  "publishConfig": {
7
7
  "access": "public",