@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.
Files changed (2) hide show
  1. package/bin/main-cli.js +30 -15
  2. 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("Clone template from GitHub (Private/Public)")
60
+ .description("Project initializer with git setup")
61
61
  .action(async (projectName, targetDir) => {
62
- const rawTarget = targetDir || (projectName === "." ? "." : projectName)
63
- const targetPath = path.resolve(process.cwd(), rawTarget)
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
- const spinner = ora("Cloning template from GitHub...").start()
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
- spinner.succeed(chalk.green("Template cloned successfully!"))
81
- console.log(chalk.blue(`\nšŸ“¦ Dependencies loading with ${packageManager}...`))
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
- const installCmd = isBun ? "bun install" : "npm install"
84
- execSync(installCmd, { cwd: targetPath, stdio: "inherit" })
99
+ execSync("bun install", { cwd: targetPath, stdio: "inherit" })
85
100
 
86
- console.log(chalk.green("\nāœ… Project Ready!"))
87
- console.log(chalk.white(`\nStart Project:\n`))
101
+ console.log(chalk.green("\nāœ… Done!"))
88
102
 
89
- if (targetPath !== process.cwd()) {
90
- console.log(chalk.cyan(` cd ${path.relative(process.cwd(), targetPath)}`))
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(` ${packageManager} run dev`))
108
+ console.log(chalk.cyan(` bun run dev`))
94
109
 
95
110
  } catch (err) {
96
- spinner.fail(chalk.red("Failed to clone or install!"))
97
- console.error(chalk.red(`\nError details: ${err.message}`))
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 })
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Yusuf Yasir KAYGUSUZ",
3
3
  "name": "@xrystal/core",
4
- "version": "3.7.7",
4
+ "version": "3.7.9",
5
5
  "description": "Project core for xrystal",
6
6
  "publishConfig": {
7
7
  "access": "public",