create-avalon 0.1.19 → 0.1.21
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 +138 -106
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1226,112 +1226,120 @@ function generateNetlifyToml(config) {
|
|
|
1226
1226
|
[build.environment]
|
|
1227
1227
|
NODE_VERSION = "22"
|
|
1228
1228
|
BUN_VERSION = "latest"
|
|
1229
|
-
NITRO_PRESET = "
|
|
1229
|
+
NITRO_PRESET = "netlify_edge"
|
|
1230
1230
|
|
|
1231
|
-
[
|
|
1232
|
-
|
|
1231
|
+
[dev]
|
|
1232
|
+
command = "bunx --bun vite"
|
|
1233
|
+
autoLaunch = false
|
|
1233
1234
|
|
|
1234
|
-
#
|
|
1235
|
-
#
|
|
1236
|
-
#
|
|
1237
|
-
[[redirects]]
|
|
1238
|
-
from = "/*"
|
|
1239
|
-
to = "/.netlify/functions/server"
|
|
1240
|
-
status = 200
|
|
1235
|
+
# Edge functions are configured via .netlify/edge-functions/manifest.json
|
|
1236
|
+
# generated by Nitro at build time. The manifest routes "/*" to the
|
|
1237
|
+
# "server" edge function with static-file exclusion rules.
|
|
1241
1238
|
`;
|
|
1242
1239
|
}
|
|
1243
1240
|
function generateBuildMjs() {
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
*
|
|
1247
|
-
|
|
1248
|
-
*
|
|
1249
|
-
*
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
import {
|
|
1254
|
-
import {
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
const
|
|
1258
|
-
const
|
|
1259
|
-
const
|
|
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
|
-
console.log('[build] ✅
|
|
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
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1241
|
+
const lines = [
|
|
1242
|
+
`/**`,
|
|
1243
|
+
` * Netlify build wrapper.`,
|
|
1244
|
+
` *`,
|
|
1245
|
+
` * Vite/Nitro leaves open handles after the build completes, preventing`,
|
|
1246
|
+
` * the Node process from exiting. This wrapper detects when the build`,
|
|
1247
|
+
` * output is ready, kills the entire process group, then runs post-build.`,
|
|
1248
|
+
` */`,
|
|
1249
|
+
``,
|
|
1250
|
+
`import { spawn, execSync } from 'node:child_process';`,
|
|
1251
|
+
`import { existsSync, rmSync } from 'node:fs';`,
|
|
1252
|
+
`import { join } from 'node:path';`,
|
|
1253
|
+
``,
|
|
1254
|
+
`const CWD = process.cwd();`,
|
|
1255
|
+
`const EDGE_SERVER = join(CWD, '.netlify', 'edge-functions', 'server', 'server.js');`,
|
|
1256
|
+
`const EDGE_MANIFEST = join(CWD, '.netlify', 'edge-functions', 'manifest.json');`,
|
|
1257
|
+
`const NETLIFY_MAIN = join(CWD, '.netlify', 'functions-internal', 'main.mjs');`,
|
|
1258
|
+
`const NETLIFY_SERVER = join(CWD, '.netlify', 'functions-internal', 'server', 'server.mjs');`,
|
|
1259
|
+
`const OUTPUT_SSR = join(CWD, '.output', 'server', '_ssr', 'ssr.mjs');`,
|
|
1260
|
+
``,
|
|
1261
|
+
`console.log('[build] Starting vite build...');`,
|
|
1262
|
+
``,
|
|
1263
|
+
`for (const dir of ['.netlify', '.output', 'netlify']) {`,
|
|
1264
|
+
` const full = join(CWD, dir);`,
|
|
1265
|
+
` if (existsSync(full)) {`,
|
|
1266
|
+
" rmSync(full, { recursive: true, force: true });",
|
|
1267
|
+
" console.log(`[build] Cleaned stale ${dir}/`);",
|
|
1268
|
+
` }`,
|
|
1269
|
+
`}`,
|
|
1270
|
+
``,
|
|
1271
|
+
`const child = spawn('bunx', ['--bun', 'vite', 'build'], {`,
|
|
1272
|
+
` cwd: CWD,`,
|
|
1273
|
+
` stdio: 'inherit',`,
|
|
1274
|
+
` detached: true,`,
|
|
1275
|
+
`});`,
|
|
1276
|
+
``,
|
|
1277
|
+
`const childPid = child.pid;`,
|
|
1278
|
+
`let done = false;`,
|
|
1279
|
+
``,
|
|
1280
|
+
`function killTree() {`,
|
|
1281
|
+
` try { process.kill(-childPid, 'SIGKILL'); } catch {}`,
|
|
1282
|
+
` try { child.kill('SIGKILL'); } catch {}`,
|
|
1283
|
+
`}`,
|
|
1284
|
+
``,
|
|
1285
|
+
`function finish() {`,
|
|
1286
|
+
` if (done) return;`,
|
|
1287
|
+
` done = true;`,
|
|
1288
|
+
` clearInterval(poll);`,
|
|
1289
|
+
` clearTimeout(absoluteTimeout);`,
|
|
1290
|
+
` killTree();`,
|
|
1291
|
+
``,
|
|
1292
|
+
` setTimeout(() => {`,
|
|
1293
|
+
` console.log('[build] Running post-build...');`,
|
|
1294
|
+
` try {`,
|
|
1295
|
+
` execSync('node post-build.mjs', { cwd: CWD, stdio: 'inherit', timeout: 120_000 });`,
|
|
1296
|
+
` } catch (err) {`,
|
|
1297
|
+
` console.error('[build] post-build warning:', err.message);`,
|
|
1298
|
+
` }`,
|
|
1299
|
+
``,
|
|
1300
|
+
` if (existsSync(EDGE_SERVER) && existsSync(EDGE_MANIFEST))`,
|
|
1301
|
+
` console.log('[build] ✅ Edge function found');`,
|
|
1302
|
+
` else if (existsSync(NETLIFY_SERVER))`,
|
|
1303
|
+
` console.log('[build] ✅ Server function found (netlify v2)');`,
|
|
1304
|
+
` else if (existsSync(OUTPUT_SSR))`,
|
|
1305
|
+
` console.log('[build] ✅ SSR bundle found');`,
|
|
1306
|
+
` else`,
|
|
1307
|
+
` console.error('[build] ❌ No server output found');`,
|
|
1308
|
+
``,
|
|
1309
|
+
` console.log('[build] ✅ Complete');`,
|
|
1310
|
+
` process.exit(0);`,
|
|
1311
|
+
` }, 500);`,
|
|
1312
|
+
`}`,
|
|
1313
|
+
``,
|
|
1314
|
+
"child.on('exit', (code) => {",
|
|
1315
|
+
" console.log(`[build] vite build exited with code ${code}`);",
|
|
1316
|
+
` finish();`,
|
|
1317
|
+
`});`,
|
|
1318
|
+
``,
|
|
1319
|
+
"child.on('error', (err) => {",
|
|
1320
|
+
` console.error('[build] spawn error:', err);`,
|
|
1321
|
+
` process.exit(1);`,
|
|
1322
|
+
`});`,
|
|
1323
|
+
``,
|
|
1324
|
+
`const poll = setInterval(() => {`,
|
|
1325
|
+
` const edgeReady = existsSync(EDGE_SERVER) && existsSync(EDGE_MANIFEST);`,
|
|
1326
|
+
` const netlifyReady = existsSync(NETLIFY_MAIN) && existsSync(NETLIFY_SERVER);`,
|
|
1327
|
+
` const nodeServerReady = existsSync(OUTPUT_SSR);`,
|
|
1328
|
+
` if (edgeReady || netlifyReady || nodeServerReady) {`,
|
|
1329
|
+
" const kind = edgeReady ? 'netlify-edge' : netlifyReady ? 'netlify' : 'node-server';",
|
|
1330
|
+
" console.log(`[build] Output detected (${kind}), waiting 3s for final writes...`);",
|
|
1331
|
+
` clearInterval(poll);`,
|
|
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
|
+
`) + `
|
|
1335
1343
|
`;
|
|
1336
1344
|
}
|
|
1337
1345
|
|
|
@@ -1859,6 +1867,8 @@ function generateViteConfig(config) {
|
|
|
1859
1867
|
` nitro: {`,
|
|
1860
1868
|
` preset: process.env.NITRO_PRESET || 'node_server',`,
|
|
1861
1869
|
` streaming: true,`,
|
|
1870
|
+
` clientEntry: 'app/entry-client',`,
|
|
1871
|
+
` globalCSS: ['app/shared/styles/main.css'],`,
|
|
1862
1872
|
` prerender: {`,
|
|
1863
1873
|
` routes: ['/'],`,
|
|
1864
1874
|
` crawlLinks: true,`,
|
|
@@ -1868,17 +1878,39 @@ function generateViteConfig(config) {
|
|
|
1868
1878
|
` });`,
|
|
1869
1879
|
"",
|
|
1870
1880
|
` return {`,
|
|
1881
|
+
` environments: {`,
|
|
1882
|
+
` client: {`,
|
|
1883
|
+
` build: {`,
|
|
1884
|
+
` rollupOptions: {`,
|
|
1885
|
+
` input: './app/entry-client.ts',`,
|
|
1886
|
+
` },`,
|
|
1887
|
+
` },`,
|
|
1888
|
+
` },`,
|
|
1889
|
+
` ssr: {`,
|
|
1890
|
+
` build: {`,
|
|
1891
|
+
` rollupOptions: {`,
|
|
1892
|
+
` input: './server/renderer.ts',`,
|
|
1893
|
+
` },`,
|
|
1894
|
+
` },`,
|
|
1895
|
+
` },`,
|
|
1896
|
+
` },`,
|
|
1897
|
+
``,
|
|
1871
1898
|
` plugins: [`,
|
|
1872
1899
|
pluginEntries.join(`
|
|
1873
1900
|
`),
|
|
1874
1901
|
` ],`,
|
|
1875
1902
|
``,
|
|
1876
1903
|
` resolve: {`,
|
|
1877
|
-
` alias:
|
|
1878
|
-
` '@shared': resolve(
|
|
1879
|
-
` '@modules': resolve(
|
|
1880
|
-
` '
|
|
1881
|
-
`
|
|
1904
|
+
` alias: [`,
|
|
1905
|
+
` { find: '@shared', replacement: resolve('app/shared') },`,
|
|
1906
|
+
` { find: '@modules', replacement: resolve('app/modules') },`,
|
|
1907
|
+
` { find: '@/', replacement: \`\${resolve('app')}/\` },`,
|
|
1908
|
+
` ],`,
|
|
1909
|
+
` },`,
|
|
1910
|
+
``,
|
|
1911
|
+
` build: {`,
|
|
1912
|
+
` outDir: 'dist',`,
|
|
1913
|
+
` emptyOutDir: true,`,
|
|
1882
1914
|
` },`,
|
|
1883
1915
|
``,
|
|
1884
1916
|
` server: {`,
|