mirror of
https://github.com/colbymchenry/codegraph.git
synced 2026-10-04 06:58:17 +08:00
Phase 3 of the node:sqlite migration: ship a vendored Node runtime so CodeGraph runs with no system Node and no native build (node:sqlite is built in). - scripts/build-bundle.sh: build a per-platform archive (official Node + dist + prod deps + launcher). Same recipe per platform; pins Node v24.16.0. - install.sh: curl|sh installer (no Node required) — detects os/arch, pulls the archive from Releases, symlinks onto PATH; re-run to upgrade, --uninstall to remove. The VPS/SSH path. - scripts/npm-shim.js: thin launcher for the npm channel — resolves the per-platform optionalDependency bundle and execs it, so `npm i -g` keeps working and the real work runs on the bundled Node regardless of the user's. - BUNDLING.md: distribution design + release-pipeline TODO (CI matrix, platform packages, code signing, brew, retiring the Node-version gate). Validated end-to-end: darwin-arm64 and linux-x64 bundles both run init + index + status (Backend: node:sqlite, Journal: wal) + FTS query with NO system Node — linux-x64 verified in a clean ubuntu:24.04 amd64 container. Release archives are gitignored; CI will produce and upload them. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
44 lines
1.8 KiB
JavaScript
Executable File
44 lines
1.8 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
'use strict';
|
|
//
|
|
// npm thin-installer launcher for CodeGraph.
|
|
//
|
|
// The heavy artifact (a vendored Node runtime + the app) ships as a per-platform
|
|
// optionalDependency: @colbymchenry/codegraph-<platform>-<arch>. npm installs
|
|
// only the one matching the host, via each package's `os`/`cpu` fields (the
|
|
// esbuild pattern). This shim — run by the user's OWN Node — locates that bundle
|
|
// and execs its launcher, so the real work always runs on the bundled Node 24
|
|
// (with node:sqlite), regardless of the user's Node version. The user's Node is
|
|
// only ever a launcher; even an ancient version can run this file.
|
|
//
|
|
// Wired up at release time as the main package's `bin`:
|
|
// "bin": { "codegraph": "scripts/npm-shim.js" }
|
|
// with the platform packages listed in `optionalDependencies`.
|
|
|
|
var childProcess = require('child_process');
|
|
|
|
var target = process.platform + '-' + process.arch; // e.g. darwin-arm64, linux-x64
|
|
var pkg = '@colbymchenry/codegraph-' + target;
|
|
var launcher = process.platform === 'win32' ? 'bin/codegraph.cmd' : 'bin/codegraph';
|
|
|
|
var binPath;
|
|
try {
|
|
binPath = require.resolve(pkg + '/' + launcher);
|
|
} catch (e) {
|
|
process.stderr.write(
|
|
'codegraph: no prebuilt bundle for ' + target + '.\n' +
|
|
'Expected the optional package ' + pkg + ' to be installed.\n' +
|
|
'Try reinstalling: npm i -g @colbymchenry/codegraph\n' +
|
|
'Or use the standalone installer (no Node required):\n' +
|
|
' curl -fsSL https://raw.githubusercontent.com/colbymchenry/codegraph/main/install.sh | sh\n'
|
|
);
|
|
process.exit(1);
|
|
}
|
|
|
|
var res = childProcess.spawnSync(binPath, process.argv.slice(2), { stdio: 'inherit' });
|
|
if (res.error) {
|
|
process.stderr.write('codegraph: ' + res.error.message + '\n');
|
|
process.exit(1);
|
|
}
|
|
process.exit(res.status === null ? 1 : res.status);
|