@xrystal/core 3.6.2 → 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.
@@ -2,7 +2,7 @@ import path from 'path'
2
2
 
3
3
  import { __filename, __dirname } from '../helpers/index.mjs'
4
4
 
5
- export const packageName = 'tmp-project-tool'
5
+ export const packageName = '@xrystal/core'
6
6
 
7
7
  export const tmpFileDefaultMainFolderName = 'x'
8
8
  export const tmpFileDefaultName = 'tmp'
package/bin/main-cli.js CHANGED
@@ -25,12 +25,21 @@ const packageManager = isBun ? "bun" : "npm"
25
25
  const setupCLI = async () => {
26
26
  const cli = new Command()
27
27
 
28
- let ownerTmpFilePath = findFileRecursively(".", tmpFileDefaultName, tmpFileDefaultExt)
29
-
30
28
  try {
29
+ let ownerTmpFilePath = findFileRecursively(".", tmpFileDefaultName, tmpFileDefaultExt)
30
+
31
31
  if (!ownerTmpFilePath) {
32
+ if (!defaultTmpFilePath || !fs.existsSync(defaultTmpFilePath)) {
33
+ throw new Error("Default template configuration file not found in package")
34
+ }
35
+
32
36
  const tmpFilePathBuffer = fs.readFileSync(defaultTmpFilePath)
33
- fs.mkdirSync(path.resolve(tmpFileDefaultMainFolderName), { recursive: true })
37
+ const folderPath = path.resolve(tmpFileDefaultMainFolderName || ".xrystal")
38
+
39
+ if (!fs.existsSync(folderPath)) {
40
+ fs.mkdirSync(folderPath, { recursive: true })
41
+ }
42
+
34
43
  fs.writeFileSync(defaultOwnerTmpFilePath, tmpFilePathBuffer)
35
44
  ownerTmpFilePath = defaultOwnerTmpFilePath
36
45
  }
@@ -38,20 +47,23 @@ const setupCLI = async () => {
38
47
  const ownerTmpFile = fs.readFileSync(ownerTmpFilePath, "utf8")
39
48
  const parsedTmpObject = yaml.parse(ownerTmpFile)
40
49
  const resolvedTmpObject = resolveObjWithHandlebars(parsedTmpObject, parsedTmpObject)
41
- const projectMainFolderPath = path.resolve(resolvedTmpObject.configs.mainFolderPath)
50
+
51
+ const mainPath = resolvedTmpObject?.configs?.mainFolderPath || "./source"
52
+ const projectMainFolderPath = path.resolve(mainPath)
42
53
 
43
54
  if (!fs.existsSync(projectMainFolderPath)) {
44
55
  fs.mkdirSync(projectMainFolderPath, { recursive: true })
45
56
  }
46
57
 
47
58
  cli
48
- .command("create <project-name>")
59
+ .command("create <project-name> [target-path]")
49
60
  .description("Clone template from GitHub (Private/Public)")
50
- .action(async (projectName) => {
51
- const targetPath = path.join(process.cwd(), projectName)
61
+ .action(async (projectName, targetDir) => {
62
+ const rawTarget = targetDir || (projectName === "." ? "." : projectName)
63
+ const targetPath = path.resolve(process.cwd(), rawTarget)
52
64
 
53
- if (fs.existsSync(targetPath)) {
54
- 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!`))
55
67
  process.exit(1)
56
68
  }
57
69
 
@@ -66,27 +78,34 @@ const setupCLI = async () => {
66
78
  }
67
79
 
68
80
  spinner.succeed(chalk.green("Template cloned successfully!"))
69
- console.log(chalk.blue(`\n📦 Dependencies loading with ${packageManager}... (${projectName})`))
81
+ console.log(chalk.blue(`\n📦 Dependencies loading with ${packageManager}...`))
70
82
 
71
83
  const installCmd = isBun ? "bun install" : "npm install"
72
84
  execSync(installCmd, { cwd: targetPath, stdio: "inherit" })
73
85
 
74
86
  console.log(chalk.green("\n✅ Project Ready!"))
75
87
  console.log(chalk.white(`\nStart Project:\n`))
76
- 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
+
77
93
  console.log(chalk.cyan(` ${packageManager} run dev`))
78
94
 
79
95
  } catch (err) {
80
96
  spinner.fail(chalk.red("Failed to clone or install!"))
81
97
  console.error(chalk.red(`\nError details: ${err.message}`))
82
- 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
+ }
83
102
  }
84
103
  })
85
104
 
86
105
  cli.parse(process.argv)
87
106
 
88
107
  } catch (error) {
89
- console.error(`${packageName} Initialization Error:`, error?.message)
108
+ console.error(`${packageName || "CLI"} Initialization Error:`, error?.message)
90
109
  }
91
110
  }
92
111
 
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.2",
4
+ "version": "3.6.6",
5
5
  "description": "Project core for xrystal",
6
6
  "publishConfig": {
7
7
  "access": "public",
@@ -1,25 +0,0 @@
1
- FROM oven/bun:1.1-alpine AS builder
2
-
3
- WORKDIR /app
4
-
5
- COPY package.json bun.lockb* ./
6
- RUN bun install --frozen-lockfile
7
-
8
- COPY . .
9
-
10
- RUN bun run build:prod
11
-
12
- FROM oven/bun:1.1-alpine
13
-
14
- ENV NODE_ENV=production
15
-
16
- WORKDIR /lib/xrystal-core
17
-
18
- COPY --from=builder /app/source ./source
19
- COPY --from=builder /app/bin ./bin
20
- COPY --from=builder /app/x ./x
21
- RUN rm -rf ./x/dist && ls -la ./x
22
- COPY --from=builder /app/package.json ./package.json
23
- COPY --from=builder /app/bun.lockb* ./
24
-
25
- RUN bun install --production
File without changes
File without changes