@xrystal/core 3.7.7 → 3.7.8

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 +28 -12
  2. package/package.json +1 -1
package/bin/main-cli.js CHANGED
@@ -57,17 +57,27 @@ 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
+ targetPath = path.resolve(process.cwd(), targetDir)
67
+ } else {
68
+ targetPath = isCurrentDir ? process.cwd() : path.resolve(process.cwd(), projectName)
69
+ }
64
70
 
65
71
  if (fs.existsSync(targetPath) && fs.readdirSync(targetPath).length > 0) {
66
72
  console.log(chalk.red(`āŒ Error: Target directory '${targetPath}' is not empty!`))
67
73
  process.exit(1)
68
74
  }
69
75
 
70
- const spinner = ora("Cloning template from GitHub...").start()
76
+ if (!fs.existsSync(targetPath)) {
77
+ fs.mkdirSync(targetPath, { recursive: true })
78
+ }
79
+
80
+ const spinner = ora("Cloning and initializing git...").start()
71
81
 
72
82
  try {
73
83
  execSync(`git clone --depth 1 ${templateRepoUri} "${targetPath}"`, { stdio: "ignore" })
@@ -77,24 +87,30 @@ const setupCLI = async () => {
77
87
  fs.rmSync(gitFolder, { recursive: true, force: true })
78
88
  }
79
89
 
80
- spinner.succeed(chalk.green("Template cloned successfully!"))
81
- console.log(chalk.blue(`\nšŸ“¦ Dependencies loading with ${packageManager}...`))
90
+ try {
91
+ execSync(`git init`, { cwd: targetPath, stdio: "ignore" })
92
+ } catch (e) {
93
+ // Failed silently
94
+ }
95
+
96
+ spinner.succeed(chalk.green("Template cloned and git initialized!"))
97
+ console.log(chalk.blue(`\nšŸ“¦ Installing dependencies with ${packageManager}...`))
82
98
 
83
99
  const installCmd = isBun ? "bun install" : "npm install"
84
100
  execSync(installCmd, { cwd: targetPath, stdio: "inherit" })
85
101
 
86
- console.log(chalk.green("\nāœ… Project Ready!"))
87
- console.log(chalk.white(`\nStart Project:\n`))
102
+ console.log(chalk.green("\nāœ… Done!"))
88
103
 
89
- if (targetPath !== process.cwd()) {
90
- console.log(chalk.cyan(` cd ${path.relative(process.cwd(), targetPath)}`))
104
+ const relativePath = path.relative(process.cwd(), targetPath)
105
+ if (relativePath && relativePath !== ".") {
106
+ console.log(chalk.cyan(`\n cd ${relativePath}`))
91
107
  }
92
108
 
93
109
  console.log(chalk.cyan(` ${packageManager} run dev`))
94
110
 
95
111
  } catch (err) {
96
- spinner.fail(chalk.red("Failed to clone or install!"))
97
- console.error(chalk.red(`\nError details: ${err.message}`))
112
+ spinner.fail(chalk.red("Failed!"))
113
+ console.error(chalk.red(`\nDetails: ${err.message}`))
98
114
 
99
115
  if (fs.existsSync(targetPath) && targetPath !== process.cwd() && fs.readdirSync(targetPath).length === 0) {
100
116
  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.8",
5
5
  "description": "Project core for xrystal",
6
6
  "publishConfig": {
7
7
  "access": "public",