create-aerobuilt 0.2.8 → 0.2.10
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/index.js +12 -2
- package/lib.js +21 -18
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { cpSync, mkdirSync, existsSync, statSync, readdirSync,
|
|
3
|
+
import { cpSync, mkdirSync, existsSync, statSync, readdirSync, readFileSync } from 'fs'
|
|
4
4
|
import { dirname, join, basename } from 'path'
|
|
5
5
|
import { fileURLToPath } from 'url'
|
|
6
6
|
import { spawnSync } from 'child_process'
|
|
@@ -33,6 +33,7 @@ function copyTemplate(src, dest) {
|
|
|
33
33
|
if (name === 'dist' || name === '.output') return true
|
|
34
34
|
if (name.endsWith('.log') || name === '.DS_Store') return true
|
|
35
35
|
if (name === '.vite' || name === '.nitro') return true
|
|
36
|
+
if (name === 'package.json' || name === 'package-template.json') return true
|
|
36
37
|
return false
|
|
37
38
|
}
|
|
38
39
|
mkdirSync(dest, { recursive: true })
|
|
@@ -137,9 +138,18 @@ function main() {
|
|
|
137
138
|
}
|
|
138
139
|
|
|
139
140
|
const templatePath = resolveTemplatePath(template)
|
|
141
|
+
let aerobuiltVersion = null
|
|
142
|
+
if (!inMonorepo) {
|
|
143
|
+
try {
|
|
144
|
+
const cliPkg = JSON.parse(readFileSync(join(startPkgDir, 'package.json'), 'utf8'))
|
|
145
|
+
aerobuiltVersion = cliPkg.version || null
|
|
146
|
+
} catch {
|
|
147
|
+
// ignore; lib will fall back to *
|
|
148
|
+
}
|
|
149
|
+
}
|
|
140
150
|
console.log(`Creating Aero app in ${target} from template "${template}"...`)
|
|
141
151
|
copyTemplate(templatePath, targetDir)
|
|
142
|
-
rewritePackageJson(targetDir, target, inMonorepo)
|
|
152
|
+
rewritePackageJson(templatePath, targetDir, target, inMonorepo, aerobuiltVersion)
|
|
143
153
|
writeReadme(targetDir, target, template)
|
|
144
154
|
console.log('Installing dependencies...')
|
|
145
155
|
if (inMonorepo) {
|
package/lib.js
CHANGED
|
@@ -24,28 +24,31 @@ export function parseArgs(argv) {
|
|
|
24
24
|
return { target, template }
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
const PACKAGE_TEMPLATE = 'package-template.json'
|
|
28
|
+
|
|
27
29
|
/**
|
|
28
|
-
*
|
|
29
|
-
* @param {string}
|
|
30
|
-
* @param {string}
|
|
31
|
-
* @param {
|
|
30
|
+
* Write package.json in targetDir from the template's package-template.json, with name and aerobuilt version filled in.
|
|
31
|
+
* @param {string} templatePath - Path to the template directory (e.g. packages/templates/minimal)
|
|
32
|
+
* @param {string} targetDir - Path to the scaffolded project directory
|
|
33
|
+
* @param {string} projectName - Project name for package.json "name"
|
|
34
|
+
* @param {boolean} inMonorepo - If true, use workspace:* for aerobuilt; otherwise use aerobuiltVersion
|
|
35
|
+
* @param {string} [aerobuiltVersion] - When !inMonorepo, version range for aerobuilt (e.g. ^0.2.9). Omit to use '*'.
|
|
32
36
|
*/
|
|
33
|
-
export function rewritePackageJson(targetDir, projectName, inMonorepo) {
|
|
34
|
-
const
|
|
35
|
-
if (!existsSync(
|
|
36
|
-
|
|
37
|
+
export function rewritePackageJson(templatePath, targetDir, projectName, inMonorepo, aerobuiltVersion) {
|
|
38
|
+
const templatePkgPath = join(templatePath, PACKAGE_TEMPLATE)
|
|
39
|
+
if (!existsSync(templatePkgPath)) {
|
|
40
|
+
console.error(
|
|
41
|
+
`create-aerobuilt: template is missing ${PACKAGE_TEMPLATE}. Each template must provide this file.`,
|
|
42
|
+
)
|
|
43
|
+
process.exit(1)
|
|
44
|
+
}
|
|
45
|
+
const pkg = JSON.parse(readFileSync(templatePkgPath, 'utf8'))
|
|
37
46
|
pkg.name = projectName
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
for (const key of Object.keys(deps)) {
|
|
42
|
-
if (deps[key] === 'workspace:*') deps[key] = '*'
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
rewrite(pkg.dependencies)
|
|
46
|
-
rewrite(pkg.devDependencies)
|
|
47
|
+
const depVersion = inMonorepo ? 'workspace:*' : (aerobuiltVersion ? `^${aerobuiltVersion}` : '*')
|
|
48
|
+
if (pkg.dependencies && pkg.dependencies.aerobuilt !== undefined) {
|
|
49
|
+
pkg.dependencies.aerobuilt = depVersion
|
|
47
50
|
}
|
|
48
|
-
writeFileSync(
|
|
51
|
+
writeFileSync(join(targetDir, 'package.json'), JSON.stringify(pkg, null, 2) + '\n')
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-aerobuilt",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Jamie Wilson",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"create-aerobuilt": "index.js"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@aerobuilt/template-minimal": "0.2.
|
|
22
|
+
"@aerobuilt/template-minimal": "0.2.10"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"create": "node .",
|