@inizioevoke/veeva-astroclm 1.0.0 → 1.0.1
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/create.js +35 -0
- package/package.json +2 -1
package/bin/create.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs'
|
|
3
|
+
import { basename, dirname, join, resolve, sep } from 'node:path'
|
|
4
|
+
import { fileURLToPath } from 'node:url'
|
|
5
|
+
|
|
6
|
+
const templateRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..')
|
|
7
|
+
|
|
8
|
+
const targetArg = process.argv[2]
|
|
9
|
+
const targetDir = targetArg ? resolve(process.cwd(), targetArg) : process.cwd()
|
|
10
|
+
|
|
11
|
+
if (existsSync(targetDir) && readdirSync(targetDir).length > 0) {
|
|
12
|
+
console.error(`Target directory is not empty: ${targetDir}`)
|
|
13
|
+
process.exit(1)
|
|
14
|
+
}
|
|
15
|
+
mkdirSync(targetDir, { recursive: true })
|
|
16
|
+
|
|
17
|
+
const skipTopLevel = new Set(['bin', 'node_modules', '.git', 'package-lock.json'])
|
|
18
|
+
|
|
19
|
+
cpSync(templateRoot, targetDir, {
|
|
20
|
+
recursive: true,
|
|
21
|
+
filter: (src) => {
|
|
22
|
+
const rel = src.slice(templateRoot.length).replace(/^[\\/]/, '')
|
|
23
|
+
if (!rel) return true
|
|
24
|
+
return !skipTopLevel.has(rel.split(sep)[0])
|
|
25
|
+
},
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
const pkgPath = join(targetDir, 'package.json')
|
|
29
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'))
|
|
30
|
+
pkg.name = basename(targetDir)
|
|
31
|
+
delete pkg.bin
|
|
32
|
+
writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n')
|
|
33
|
+
|
|
34
|
+
console.log(`Scaffolded ${pkg.name} in ${targetDir}`)
|
|
35
|
+
console.log(`Next: cd ${targetArg ?? '.'} && npm install`)
|