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.
- package/index.js +18 -16
- 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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
console.error(
|
|
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
|
|
53
|
-
|
|
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
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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(
|