tova 0.4.2 → 0.4.4
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/bin/tova.js +49 -3
- package/package.json +1 -1
- package/src/codegen/server-codegen.js +16 -11
- package/src/version.js +1 -1
package/bin/tova.js
CHANGED
|
@@ -4495,9 +4495,9 @@ async function upgradeCommand() {
|
|
|
4495
4495
|
}
|
|
4496
4496
|
|
|
4497
4497
|
if (!ghTag) {
|
|
4498
|
-
// No newer binary release
|
|
4499
|
-
console.log(` ${color.dim('No binary release for v' + latestVersion + ' yet.
|
|
4500
|
-
await
|
|
4498
|
+
// No newer binary release — install from npm tarball directly
|
|
4499
|
+
console.log(` ${color.dim('No binary release for v' + latestVersion + ' yet. Installing from npm...')}`);
|
|
4500
|
+
await npmTarballUpgrade(latestVersion);
|
|
4501
4501
|
return;
|
|
4502
4502
|
}
|
|
4503
4503
|
|
|
@@ -4587,6 +4587,52 @@ async function npmUpgrade(latestVersion) {
|
|
|
4587
4587
|
}
|
|
4588
4588
|
}
|
|
4589
4589
|
|
|
4590
|
+
async function npmTarballUpgrade(latestVersion) {
|
|
4591
|
+
const installDir = join(process.env.HOME || '', '.tova');
|
|
4592
|
+
const binDir = join(installDir, 'bin');
|
|
4593
|
+
const libDir = join(installDir, 'lib');
|
|
4594
|
+
mkdirSync(libDir, { recursive: true });
|
|
4595
|
+
|
|
4596
|
+
// Download npm tarball
|
|
4597
|
+
const tarballUrl = `https://registry.npmjs.org/tova/-/tova-${latestVersion}.tgz`;
|
|
4598
|
+
const tarballPath = join(installDir, 'tova.tgz');
|
|
4599
|
+
|
|
4600
|
+
const dlResult = await downloadWithProgress(tarballUrl, tarballPath);
|
|
4601
|
+
if (!dlResult) {
|
|
4602
|
+
console.error(color.red(' Failed to download npm package. Try manually: bun add -g tova@latest'));
|
|
4603
|
+
process.exit(1);
|
|
4604
|
+
}
|
|
4605
|
+
|
|
4606
|
+
// Extract tarball into lib dir
|
|
4607
|
+
console.log(' Extracting...');
|
|
4608
|
+
const { spawnSync: spawnTar } = await import('child_process');
|
|
4609
|
+
rmSync(libDir, { recursive: true, force: true });
|
|
4610
|
+
mkdirSync(libDir, { recursive: true });
|
|
4611
|
+
const tarResult = spawnTar('tar', ['-xzf', tarballPath, '-C', libDir, '--strip-components=1'], { stdio: 'pipe' });
|
|
4612
|
+
rmSync(tarballPath, { force: true });
|
|
4613
|
+
if (tarResult.status !== 0) {
|
|
4614
|
+
console.error(color.red(' Failed to extract package. Try manually: bun add -g tova@latest'));
|
|
4615
|
+
process.exit(1);
|
|
4616
|
+
}
|
|
4617
|
+
|
|
4618
|
+
// Create wrapper script at ~/.tova/bin/tova
|
|
4619
|
+
const libBin = join(libDir, 'bin', 'tova.js');
|
|
4620
|
+
const wrapperScript = `#!/bin/sh\nexec bun "${libBin}" "$@"\n`;
|
|
4621
|
+
const binPath = join(binDir, 'tova');
|
|
4622
|
+
writeFileSync(binPath, wrapperScript);
|
|
4623
|
+
chmodSync(binPath, 0o755);
|
|
4624
|
+
|
|
4625
|
+
// Verify
|
|
4626
|
+
console.log(' Verifying...');
|
|
4627
|
+
const verifyProc = spawnTar(binPath, ['--version'], { timeout: 10000 });
|
|
4628
|
+
if (verifyProc.status !== 0) {
|
|
4629
|
+
console.error(color.red(' Verification failed. Try manually: bun add -g tova@latest'));
|
|
4630
|
+
process.exit(1);
|
|
4631
|
+
}
|
|
4632
|
+
|
|
4633
|
+
console.log(`\n ${color.green('✓')} Upgraded: v${VERSION} -> ${color.bold('v' + latestVersion)}\n`);
|
|
4634
|
+
}
|
|
4635
|
+
|
|
4590
4636
|
function detectPackageManager() {
|
|
4591
4637
|
if (typeof Bun !== 'undefined') return 'bun';
|
|
4592
4638
|
const ua = process.env.npm_config_user_agent || '';
|
package/package.json
CHANGED
|
@@ -2380,11 +2380,16 @@ export class ServerCodegen extends BaseCodegen {
|
|
|
2380
2380
|
// 21. Request Handler — with global rate limit check (F2)
|
|
2381
2381
|
// ════════════════════════════════════════════════════════════
|
|
2382
2382
|
if (isFastMode) {
|
|
2383
|
+
// Build combined list of all static routes (declared routes + RPC endpoints)
|
|
2384
|
+
const rpcRoutes = functions.map(fn => ({ method: 'POST', path: `/rpc/${fn.name}` }));
|
|
2385
|
+
const allFastRoutes = [...routes, ...rpcRoutes];
|
|
2386
|
+
const allFastStatic = allFastRoutes.every(r => !r.path.includes(':') && !r.path.includes('*'));
|
|
2387
|
+
|
|
2383
2388
|
// Fast mode: emit direct handler references for static routes
|
|
2384
|
-
if (
|
|
2385
|
-
for (let ri = 0; ri <
|
|
2386
|
-
const method =
|
|
2387
|
-
const path =
|
|
2389
|
+
if (allFastStatic && allFastRoutes.length <= 16) {
|
|
2390
|
+
for (let ri = 0; ri < allFastRoutes.length; ri++) {
|
|
2391
|
+
const method = allFastRoutes[ri].method.toUpperCase();
|
|
2392
|
+
const path = allFastRoutes[ri].path;
|
|
2388
2393
|
lines.push(`const __fh${ri} = __staticRoutes.get(${JSON.stringify(method + ' ' + path)}).handler;`);
|
|
2389
2394
|
}
|
|
2390
2395
|
}
|
|
@@ -2401,18 +2406,18 @@ export class ServerCodegen extends BaseCodegen {
|
|
|
2401
2406
|
lines.push(' if (__method === "OPTIONS") return new Response(null, { status: 204, headers: __corsHeadersConst });');
|
|
2402
2407
|
|
|
2403
2408
|
// Static route dispatch — emit direct if/else chain using named handler refs
|
|
2404
|
-
if (
|
|
2405
|
-
for (let ri = 0; ri <
|
|
2406
|
-
const method =
|
|
2407
|
-
const path =
|
|
2409
|
+
if (allFastStatic && allFastRoutes.length <= 16) {
|
|
2410
|
+
for (let ri = 0; ri < allFastRoutes.length; ri++) {
|
|
2411
|
+
const method = allFastRoutes[ri].method.toUpperCase();
|
|
2412
|
+
const path = allFastRoutes[ri].path;
|
|
2408
2413
|
const handlerVar = `__fh${ri}`;
|
|
2409
2414
|
lines.push(` if (__method === ${JSON.stringify(method)} && __pathname === ${JSON.stringify(path)}) return ${handlerVar}(req, {});`);
|
|
2410
2415
|
}
|
|
2411
2416
|
// HEAD fallback for GET routes
|
|
2412
|
-
for (let ri = 0; ri <
|
|
2413
|
-
if (
|
|
2417
|
+
for (let ri = 0; ri < allFastRoutes.length; ri++) {
|
|
2418
|
+
if (allFastRoutes[ri].method.toUpperCase() === 'GET') {
|
|
2414
2419
|
const handlerVar = `__fh${ri}`;
|
|
2415
|
-
lines.push(` if (__method === "HEAD" && __pathname === ${JSON.stringify(
|
|
2420
|
+
lines.push(` if (__method === "HEAD" && __pathname === ${JSON.stringify(allFastRoutes[ri].path)}) return ${handlerVar}(req, {});`);
|
|
2416
2421
|
}
|
|
2417
2422
|
}
|
|
2418
2423
|
} else {
|
package/src/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Auto-generated by scripts/embed-runtime.js — do not edit
|
|
2
|
-
export const VERSION = "0.4.
|
|
2
|
+
export const VERSION = "0.4.4";
|