create-aerobuilt 0.3.1 → 0.3.3

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 +41 -11
  2. package/lib.js +19 -6
  3. package/package.json +7 -7
package/index.js CHANGED
@@ -1,10 +1,22 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { cpSync, mkdirSync, existsSync, statSync, readdirSync, readFileSync } from 'fs'
3
+ import {
4
+ cpSync,
5
+ mkdirSync,
6
+ existsSync,
7
+ statSync,
8
+ readdirSync,
9
+ readFileSync,
10
+ } from 'fs'
4
11
  import { dirname, join, basename } from 'path'
5
12
  import { fileURLToPath } from 'url'
6
13
  import { spawnSync } from 'child_process'
7
- import { parseArgs, rewritePackageJson, writeReadme, findWorkspaceRoot } from './lib.js'
14
+ import {
15
+ parseArgs,
16
+ rewritePackageJson,
17
+ writeReadme,
18
+ findWorkspaceRoot,
19
+ } from './lib.js'
8
20
 
9
21
  const __dirname = dirname(fileURLToPath(import.meta.url))
10
22
  const startPkgDir = __dirname
@@ -62,7 +74,9 @@ function isInMonorepo() {
62
74
  function installInMonorepo(targetDir) {
63
75
  const root = findWorkspaceRoot(targetDir)
64
76
  if (!root) {
65
- console.error('create-aerobuilt: could not find workspace root (pnpm-workspace.yaml).')
77
+ console.error(
78
+ 'create-aerobuilt: could not find workspace root (pnpm-workspace.yaml).'
79
+ )
66
80
  process.exit(1)
67
81
  }
68
82
  const r = spawnSync('pnpm', ['install', '--no-frozen-lockfile'], {
@@ -72,7 +86,7 @@ function installInMonorepo(targetDir) {
72
86
  })
73
87
  if (r.status !== 0) {
74
88
  console.error(
75
- 'create-aerobuilt: pnpm install failed. Run "pnpm install" from the repo root.',
89
+ 'create-aerobuilt: pnpm install failed. Run "pnpm install" from the repo root.'
76
90
  )
77
91
  process.exit(1)
78
92
  }
@@ -88,10 +102,14 @@ function installStandalone(targetDir) {
88
102
  const args = ['install']
89
103
  if (cmd === 'npm') args.push('--legacy-peer-deps')
90
104
 
91
- const r = spawnSync(cmd, args, { stdio: 'inherit', cwd: targetDir, shell: true })
105
+ const r = spawnSync(cmd, args, {
106
+ stdio: 'inherit',
107
+ cwd: targetDir,
108
+ shell: true,
109
+ })
92
110
  if (r.status !== 0) {
93
111
  console.error(
94
- `create-aerobuilt: ${cmd} install failed. Run "${cmd} install" in the project directory.`,
112
+ `create-aerobuilt: ${cmd} install failed. Run "${cmd} install" in the project directory.`
95
113
  )
96
114
  process.exit(1)
97
115
  }
@@ -109,7 +127,7 @@ function main() {
109
127
 
110
128
  if (!TEMPLATES.includes(template)) {
111
129
  console.error(
112
- `create-aerobuilt: unknown template "${template}". Use one of: ${TEMPLATES.join(', ')}`,
130
+ `create-aerobuilt: unknown template "${template}". Use one of: ${TEMPLATES.join(', ')}`
113
131
  )
114
132
  process.exit(1)
115
133
  }
@@ -127,12 +145,16 @@ function main() {
127
145
  if (existsSync(targetDir)) {
128
146
  const stat = statSync(targetDir)
129
147
  if (!stat.isDirectory()) {
130
- console.error(`create-aerobuilt: "${target}" exists and is not a directory.`)
148
+ console.error(
149
+ `create-aerobuilt: "${target}" exists and is not a directory.`
150
+ )
131
151
  process.exit(1)
132
152
  }
133
153
  const files = readdirSync(targetDir)
134
154
  if (files.length > 0) {
135
- console.error(`create-aerobuilt: directory "${target}" already exists and is not empty.`)
155
+ console.error(
156
+ `create-aerobuilt: directory "${target}" already exists and is not empty.`
157
+ )
136
158
  process.exit(1)
137
159
  }
138
160
  }
@@ -141,7 +163,9 @@ function main() {
141
163
  let aerobuiltVersion = null
142
164
  if (!inMonorepo) {
143
165
  try {
144
- const cliPkg = JSON.parse(readFileSync(join(startPkgDir, 'package.json'), 'utf8'))
166
+ const cliPkg = JSON.parse(
167
+ readFileSync(join(startPkgDir, 'package.json'), 'utf8')
168
+ )
145
169
  aerobuiltVersion = cliPkg.version || null
146
170
  } catch {
147
171
  // ignore; lib will fall back to *
@@ -149,7 +173,13 @@ function main() {
149
173
  }
150
174
  console.log(`Creating Aero app in ${target} from template "${template}"...`)
151
175
  copyTemplate(templatePath, targetDir)
152
- rewritePackageJson(templatePath, targetDir, target, inMonorepo, aerobuiltVersion)
176
+ rewritePackageJson(
177
+ templatePath,
178
+ targetDir,
179
+ target,
180
+ inMonorepo,
181
+ aerobuiltVersion
182
+ )
153
183
  writeReadme(targetDir, target, template)
154
184
  console.log('Installing dependencies...')
155
185
  if (inMonorepo) {
package/lib.js CHANGED
@@ -34,21 +34,34 @@ const PACKAGE_TEMPLATE = 'package-template.json'
34
34
  * @param {boolean} inMonorepo - If true, use workspace:* for aerobuilt; otherwise use aerobuiltVersion
35
35
  * @param {string} [aerobuiltVersion] - When !inMonorepo, version range for aerobuilt (e.g. ^0.2.9). Omit to use '*'.
36
36
  */
37
- export function rewritePackageJson(templatePath, targetDir, projectName, inMonorepo, aerobuiltVersion) {
37
+ export function rewritePackageJson(
38
+ templatePath,
39
+ targetDir,
40
+ projectName,
41
+ inMonorepo,
42
+ aerobuiltVersion
43
+ ) {
38
44
  const templatePkgPath = join(templatePath, PACKAGE_TEMPLATE)
39
45
  if (!existsSync(templatePkgPath)) {
40
46
  console.error(
41
- `create-aerobuilt: template is missing ${PACKAGE_TEMPLATE}. Each template must provide this file.`,
47
+ `create-aerobuilt: template is missing ${PACKAGE_TEMPLATE}. Each template must provide this file.`
42
48
  )
43
49
  process.exit(1)
44
50
  }
45
51
  const pkg = JSON.parse(readFileSync(templatePkgPath, 'utf8'))
46
52
  pkg.name = projectName
47
- const depVersion = inMonorepo ? 'workspace:*' : (aerobuiltVersion ? `^${aerobuiltVersion}` : '*')
53
+ const depVersion = inMonorepo
54
+ ? 'workspace:*'
55
+ : aerobuiltVersion
56
+ ? `^${aerobuiltVersion}`
57
+ : '*'
48
58
  if (pkg.dependencies && pkg.dependencies.aerobuilt !== undefined) {
49
59
  pkg.dependencies.aerobuilt = depVersion
50
60
  }
51
- writeFileSync(join(targetDir, 'package.json'), JSON.stringify(pkg, null, 2) + '\n')
61
+ writeFileSync(
62
+ join(targetDir, 'package.json'),
63
+ JSON.stringify(pkg, null, 2) + '\n'
64
+ )
52
65
  }
53
66
 
54
67
  /**
@@ -103,7 +116,7 @@ export function writeReadme(targetDir, projectName, template) {
103
116
  '├── public/ # Static assets (copied as-is)',
104
117
  '├── vite.config.ts # Aero Vite plugin',
105
118
  '└── tsconfig.json # Path aliases',
106
- '```',
119
+ '```'
107
120
  )
108
121
 
109
122
  lines.push(
@@ -112,7 +125,7 @@ export function writeReadme(targetDir, projectName, template) {
112
125
  '',
113
126
  '- [Aero on GitHub](https://github.com/aerobuilt/aero)',
114
127
  '- [aerobuilt on npm](https://www.npmjs.com/package/aerobuilt)',
115
- '',
128
+ ''
116
129
  )
117
130
 
118
131
  writeFileSync(join(targetDir, 'README.md'), lines.join('\n'))
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-aerobuilt",
3
- "version": "0.3.1",
4
- "type": "module",
3
+ "version": "0.3.3",
4
+ "homepage": "https://github.com/aerobuilt/aero",
5
5
  "license": "MIT",
6
6
  "author": "Jamie Wilson",
7
7
  "repository": {
@@ -9,17 +9,17 @@
9
9
  "url": "https://github.com/aerobuilt/aero.git",
10
10
  "directory": "packages/create-aerobuilt"
11
11
  },
12
- "homepage": "https://github.com/aerobuilt/aero",
12
+ "bin": {
13
+ "create-aerobuilt": "index.js"
14
+ },
13
15
  "files": [
14
16
  "index.js",
15
17
  "lib.js",
16
18
  "README.md"
17
19
  ],
18
- "bin": {
19
- "create-aerobuilt": "index.js"
20
- },
20
+ "type": "module",
21
21
  "dependencies": {
22
- "@aerobuilt/template-minimal": "0.3.1"
22
+ "@aerobuilt/template-minimal": "0.3.3"
23
23
  },
24
24
  "scripts": {
25
25
  "create": "node .",