create-aerobuilt 0.1.0 → 0.1.2

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 (2) hide show
  1. package/index.js +18 -16
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -8,7 +8,6 @@ import { parseArgs, rewritePackageJson, writeReadme, findWorkspaceRoot } from '.
8
8
 
9
9
  const __dirname = dirname(fileURLToPath(import.meta.url))
10
10
  const startPkgDir = __dirname
11
- const pkgRoot = join(startPkgDir, 'node_modules')
12
11
  const APPS_DIR = 'dist'
13
12
 
14
13
  const TEMPLATES = ['minimal']
@@ -16,15 +15,15 @@ const DEFAULT_TEMPLATE = 'minimal'
16
15
 
17
16
  function resolveTemplatePath(templateName) {
18
17
  const pkgName = `@aerobuilt/template-${templateName}`
19
- const templatePath = join(pkgRoot, pkgName)
20
- if (!existsSync(templatePath)) {
21
- console.error(
22
- `create-aerobuilt: template "${templateName}" not found (expected ${templatePath}).`,
23
- )
24
- console.error('Install dependencies with: pnpm install')
18
+ try {
19
+ const pkgUrl = import.meta.resolve(`${pkgName}/package.json`)
20
+ const templatePath = dirname(fileURLToPath(pkgUrl))
21
+ return templatePath
22
+ } catch (e) {
23
+ console.error(`create-aerobuilt: template "${templateName}" not found.`)
24
+ console.error(`Please install with: npm install -g ${pkgName} (or locally)`)
25
25
  process.exit(1)
26
26
  }
27
- return templatePath
28
27
  }
29
28
 
30
29
  function copyTemplate(src, dest) {
@@ -49,9 +48,8 @@ function copyTemplate(src, dest) {
49
48
 
50
49
  function isInMonorepo() {
51
50
  try {
52
- const templatePath = join(pkgRoot, `@aerobuilt/template-${DEFAULT_TEMPLATE}`)
53
- if (!existsSync(templatePath)) return false
54
- return lstatSync(templatePath).isSymbolicLink()
51
+ const rootPath = join(startPkgDir, '..', '..')
52
+ return existsSync(join(rootPath, 'pnpm-workspace.yaml'))
55
53
  } catch {
56
54
  return false
57
55
  }
@@ -77,11 +75,15 @@ function installInMonorepo(targetDir) {
77
75
  }
78
76
 
79
77
  function installStandalone(targetDir) {
80
- const hasPnpm = existsSync(join(targetDir, 'pnpm-lock.yaml'))
81
- const hasNpm = existsSync(join(targetDir, 'package-lock.json'))
82
- const hasYarn = existsSync(join(targetDir, 'yarn.lock'))
83
- const cmd = hasPnpm ? 'pnpm' : hasYarn ? 'yarn' : 'npm'
84
- const args = hasPnpm || hasYarn ? ['install'] : ['install']
78
+ const userAgent = process.env.npm_config_user_agent || ''
79
+ let cmd = 'pnpm' // prefer pnpm as default for Aero
80
+ if (userAgent.startsWith('yarn')) cmd = 'yarn'
81
+ else if (userAgent.startsWith('npm')) cmd = 'npm'
82
+ else if (userAgent.startsWith('bun')) cmd = 'bun'
83
+
84
+ const args = ['install']
85
+ if (cmd === 'npm') args.push('--legacy-peer-deps')
86
+
85
87
  const r = spawnSync(cmd, args, { stdio: 'inherit', cwd: targetDir, shell: true })
86
88
  if (r.status !== 0) {
87
89
  console.error(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-aerobuilt",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Jamie Wilson",