create-avalon 0.1.21 → 0.1.23
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/dist/cli.js +111 -123
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1217,7 +1217,7 @@ export default defineHandler(() => {
|
|
|
1217
1217
|
}
|
|
1218
1218
|
|
|
1219
1219
|
// src/templates/deploy.ts
|
|
1220
|
-
function generateNetlifyToml(
|
|
1220
|
+
function generateNetlifyToml(_config) {
|
|
1221
1221
|
return `[build]
|
|
1222
1222
|
base = "."
|
|
1223
1223
|
command = "bun install && bun build.mjs"
|
|
@@ -1226,120 +1226,113 @@ function generateNetlifyToml(config) {
|
|
|
1226
1226
|
[build.environment]
|
|
1227
1227
|
NODE_VERSION = "22"
|
|
1228
1228
|
BUN_VERSION = "latest"
|
|
1229
|
-
NITRO_PRESET = "
|
|
1229
|
+
NITRO_PRESET = "netlify"
|
|
1230
1230
|
|
|
1231
|
-
[
|
|
1232
|
-
|
|
1233
|
-
|
|
1231
|
+
[functions]
|
|
1232
|
+
directory = ".netlify/functions-internal"
|
|
1233
|
+
node_bundler = "none"
|
|
1234
1234
|
|
|
1235
|
-
#
|
|
1236
|
-
#
|
|
1237
|
-
#
|
|
1235
|
+
# SSR catch-all — Netlify checks for a matching static/prerendered file
|
|
1236
|
+
# first (force=false is the default in netlify.toml). Only requests with
|
|
1237
|
+
# no static file hit the server function.
|
|
1238
|
+
[[redirects]]
|
|
1239
|
+
from = "/*"
|
|
1240
|
+
to = "/.netlify/functions/server"
|
|
1241
|
+
status = 200
|
|
1238
1242
|
`;
|
|
1239
1243
|
}
|
|
1240
1244
|
function generateBuildMjs() {
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
` setTimeout(finish, 3_000);`,
|
|
1333
|
-
` }`,
|
|
1334
|
-
`}, 1_000);`,
|
|
1335
|
-
``,
|
|
1336
|
-
`const absoluteTimeout = setTimeout(() => {`,
|
|
1337
|
-
` console.error('[build] Timeout — killing build');`,
|
|
1338
|
-
` finish();`,
|
|
1339
|
-
`}, 240_000);`
|
|
1340
|
-
];
|
|
1341
|
-
return lines.join(`
|
|
1342
|
-
`) + `
|
|
1245
|
+
return `/**
|
|
1246
|
+
* Build wrapper.
|
|
1247
|
+
*
|
|
1248
|
+
* Vite/Nitro leaves open handles after the build completes, preventing
|
|
1249
|
+
* the Node process from exiting. This wrapper detects when the build
|
|
1250
|
+
* output is ready, kills the entire process group, then runs post-build.
|
|
1251
|
+
*/
|
|
1252
|
+
|
|
1253
|
+
import { spawn, execSync } from 'node:child_process';
|
|
1254
|
+
import { existsSync, rmSync } from 'node:fs';
|
|
1255
|
+
import { join } from 'node:path';
|
|
1256
|
+
|
|
1257
|
+
const CWD = process.cwd();
|
|
1258
|
+
const NITRO_JSON = join(CWD, '.netlify', 'functions-internal', 'nitro.json');
|
|
1259
|
+
const SERVER_MJS = join(CWD, '.netlify', 'functions-internal', 'server', 'server.mjs');
|
|
1260
|
+
const OUTPUT_SSR = join(CWD, '.output', 'server', '_ssr', 'ssr.mjs');
|
|
1261
|
+
|
|
1262
|
+
console.log('[build] Starting vite build...');
|
|
1263
|
+
|
|
1264
|
+
for (const dir of ['.netlify', '.output', 'netlify']) {
|
|
1265
|
+
const full = join(CWD, dir);
|
|
1266
|
+
if (existsSync(full)) {
|
|
1267
|
+
rmSync(full, { recursive: true, force: true });
|
|
1268
|
+
console.log(\`[build] Cleaned stale \${dir}/\`);
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
const child = spawn('bunx', ['--bun', 'vite', 'build'], {
|
|
1273
|
+
cwd: CWD,
|
|
1274
|
+
stdio: 'inherit',
|
|
1275
|
+
detached: true,
|
|
1276
|
+
});
|
|
1277
|
+
|
|
1278
|
+
const childPid = child.pid;
|
|
1279
|
+
let done = false;
|
|
1280
|
+
|
|
1281
|
+
function killTree() {
|
|
1282
|
+
try { process.kill(-childPid, 'SIGKILL'); } catch {}
|
|
1283
|
+
try { child.kill('SIGKILL'); } catch {}
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
function finish() {
|
|
1287
|
+
if (done) return;
|
|
1288
|
+
done = true;
|
|
1289
|
+
clearInterval(poll);
|
|
1290
|
+
clearTimeout(absoluteTimeout);
|
|
1291
|
+
killTree();
|
|
1292
|
+
|
|
1293
|
+
setTimeout(() => {
|
|
1294
|
+
console.log('[build] Running post-build...');
|
|
1295
|
+
try {
|
|
1296
|
+
execSync('node post-build.mjs', { cwd: CWD, stdio: 'inherit', timeout: 120_000 });
|
|
1297
|
+
} catch (err) {
|
|
1298
|
+
console.error('[build] post-build warning:', err.message);
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
const V1_SERVER = join(CWD, '.netlify', 'v1', 'functions', 'server', 'server.mjs');
|
|
1302
|
+
if (existsSync(V1_SERVER)) console.log('[build] ✅ Server function found (v1 API)');
|
|
1303
|
+
else if (existsSync(SERVER_MJS)) console.log('[build] ✅ Server function found (legacy)');
|
|
1304
|
+
else if (existsSync(OUTPUT_SSR)) console.log('[build] ✅ SSR bundle found');
|
|
1305
|
+
else console.error('[build] ❌ No server output found');
|
|
1306
|
+
|
|
1307
|
+
console.log('[build] ✅ Complete');
|
|
1308
|
+
process.exit(0);
|
|
1309
|
+
}, 500);
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
child.on('exit', (code) => {
|
|
1313
|
+
console.log(\`[build] vite build exited with code \${code}\`);
|
|
1314
|
+
finish();
|
|
1315
|
+
});
|
|
1316
|
+
|
|
1317
|
+
child.on('error', (err) => {
|
|
1318
|
+
console.error('[build] spawn error:', err);
|
|
1319
|
+
process.exit(1);
|
|
1320
|
+
});
|
|
1321
|
+
|
|
1322
|
+
const poll = setInterval(() => {
|
|
1323
|
+
const netlifyReady = existsSync(NITRO_JSON) && existsSync(SERVER_MJS);
|
|
1324
|
+
const nodeServerReady = existsSync(OUTPUT_SSR);
|
|
1325
|
+
if (netlifyReady || nodeServerReady) {
|
|
1326
|
+
console.log(\`[build] Output detected (\${netlifyReady ? 'netlify' : 'node-server'}), waiting 3s for final writes...\`);
|
|
1327
|
+
clearInterval(poll);
|
|
1328
|
+
setTimeout(finish, 3_000);
|
|
1329
|
+
}
|
|
1330
|
+
}, 1_000);
|
|
1331
|
+
|
|
1332
|
+
const absoluteTimeout = setTimeout(() => {
|
|
1333
|
+
console.error('[build] Timeout — killing build');
|
|
1334
|
+
finish();
|
|
1335
|
+
}, 240_000);
|
|
1343
1336
|
`;
|
|
1344
1337
|
}
|
|
1345
1338
|
|
|
@@ -1436,10 +1429,10 @@ function generatePackageJson(config) {
|
|
|
1436
1429
|
}
|
|
1437
1430
|
switch (config.middleware) {
|
|
1438
1431
|
case "hono":
|
|
1439
|
-
dependencies
|
|
1432
|
+
dependencies.hono = "latest";
|
|
1440
1433
|
break;
|
|
1441
1434
|
case "elysia":
|
|
1442
|
-
dependencies
|
|
1435
|
+
dependencies.elysia = "latest";
|
|
1443
1436
|
break;
|
|
1444
1437
|
}
|
|
1445
1438
|
const devDependencies = {
|
|
@@ -1450,15 +1443,15 @@ function generatePackageJson(config) {
|
|
|
1450
1443
|
};
|
|
1451
1444
|
switch (config.styling) {
|
|
1452
1445
|
case "tailwind":
|
|
1453
|
-
devDependencies
|
|
1446
|
+
devDependencies.tailwindcss = "latest";
|
|
1454
1447
|
devDependencies["@tailwindcss/vite"] = "latest";
|
|
1455
1448
|
break;
|
|
1456
1449
|
case "shadcn":
|
|
1457
|
-
devDependencies
|
|
1450
|
+
devDependencies.tailwindcss = "latest";
|
|
1458
1451
|
devDependencies["@tailwindcss/vite"] = "latest";
|
|
1459
1452
|
dependencies["@shadcn/ui"] = "latest";
|
|
1460
1453
|
dependencies["tailwind-merge"] = "^3.5.0";
|
|
1461
|
-
dependencies
|
|
1454
|
+
dependencies.clsx = "^2.1.1";
|
|
1462
1455
|
break;
|
|
1463
1456
|
}
|
|
1464
1457
|
const pkg = {
|
|
@@ -1467,17 +1460,12 @@ function generatePackageJson(config) {
|
|
|
1467
1460
|
private: true,
|
|
1468
1461
|
scripts: {
|
|
1469
1462
|
dev: "bunx --bun vite dev",
|
|
1470
|
-
build:
|
|
1471
|
-
"post-build": config.deploy === "netlify" ? "node post-build.mjs" : undefined,
|
|
1463
|
+
build: "node build.mjs",
|
|
1472
1464
|
preview: "node .output/server/index.mjs"
|
|
1473
1465
|
},
|
|
1474
1466
|
dependencies,
|
|
1475
1467
|
devDependencies
|
|
1476
1468
|
};
|
|
1477
|
-
for (const key of Object.keys(pkg.scripts)) {
|
|
1478
|
-
if (pkg.scripts[key] === undefined)
|
|
1479
|
-
delete pkg.scripts[key];
|
|
1480
|
-
}
|
|
1481
1469
|
return JSON.stringify(pkg, null, 2);
|
|
1482
1470
|
}
|
|
1483
1471
|
|
|
@@ -1999,10 +1987,10 @@ async function scaffoldProject(config, targetDir) {
|
|
|
1999
1987
|
``
|
|
2000
1988
|
].join(`
|
|
2001
1989
|
`));
|
|
1990
|
+
await writeFile(join(targetDir, "build.mjs"), generateBuildMjs());
|
|
1991
|
+
await writeFile(join(targetDir, "post-build.mjs"), generatePostBuildMjs());
|
|
2002
1992
|
if (config.deploy === "netlify") {
|
|
2003
1993
|
await writeFile(join(targetDir, "netlify.toml"), generateNetlifyToml(config));
|
|
2004
|
-
await writeFile(join(targetDir, "build.mjs"), generateBuildMjs());
|
|
2005
|
-
await writeFile(join(targetDir, "post-build.mjs"), generatePostBuildMjs());
|
|
2006
1994
|
}
|
|
2007
1995
|
}
|
|
2008
1996
|
|