create-aerobuilt 0.2.8 → 0.2.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 (3) hide show
  1. package/index.js +2 -1
  2. package/lib.js +20 -18
  3. package/package.json +2 -2
package/index.js CHANGED
@@ -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 })
@@ -139,7 +140,7 @@ function main() {
139
140
  const templatePath = resolveTemplatePath(template)
140
141
  console.log(`Creating Aero app in ${target} from template "${template}"...`)
141
142
  copyTemplate(templatePath, targetDir)
142
- rewritePackageJson(targetDir, target, inMonorepo)
143
+ rewritePackageJson(templatePath, targetDir, target, inMonorepo)
143
144
  writeReadme(targetDir, target, template)
144
145
  console.log('Installing dependencies...')
145
146
  if (inMonorepo) {
package/lib.js CHANGED
@@ -24,28 +24,30 @@ export function parseArgs(argv) {
24
24
  return { target, template }
25
25
  }
26
26
 
27
+ const PACKAGE_TEMPLATE = 'package-template.json'
28
+
27
29
  /**
28
- * Rewrite package.json in targetDir: set name to projectName; if !inMonorepo, replace workspace:* with *.
29
- * @param {string} targetDir
30
- * @param {string} projectName
31
- * @param {boolean} inMonorepo
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 *
32
35
  */
33
- export function rewritePackageJson(targetDir, projectName, inMonorepo) {
34
- const pkgPath = join(targetDir, 'package.json')
35
- if (!existsSync(pkgPath)) return
36
- const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'))
36
+ export function rewritePackageJson(templatePath, targetDir, projectName, inMonorepo) {
37
+ const templatePkgPath = join(templatePath, PACKAGE_TEMPLATE)
38
+ if (!existsSync(templatePkgPath)) {
39
+ console.error(
40
+ `create-aerobuilt: template is missing ${PACKAGE_TEMPLATE}. Each template must provide this file.`,
41
+ )
42
+ process.exit(1)
43
+ }
44
+ const pkg = JSON.parse(readFileSync(templatePkgPath, 'utf8'))
37
45
  pkg.name = projectName
38
- if (!inMonorepo) {
39
- const rewrite = deps => {
40
- if (!deps) return
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)
46
+ const aerobuiltVersion = inMonorepo ? 'workspace:*' : '*'
47
+ if (pkg.dependencies && pkg.dependencies.aerobuilt !== undefined) {
48
+ pkg.dependencies.aerobuilt = aerobuiltVersion
47
49
  }
48
- writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n')
50
+ writeFileSync(join(targetDir, 'package.json'), JSON.stringify(pkg, null, 2) + '\n')
49
51
  }
50
52
 
51
53
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-aerobuilt",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
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.8"
22
+ "@aerobuilt/template-minimal": "0.2.9"
23
23
  },
24
24
  "scripts": {
25
25
  "create": "node .",