B8: read gbrain JSON with bun instead of jq in install and wireup

gstack-gbrain-install read package.json with jq but never checked for it,
so on a machine without jq a successful install failed with "cannot read
version". gstack-gbrain-source-wireup hard-failed without jq ("brew
install jq" is not actionable on git-bash), so the wireup was skipped on
every run. Both now read the JSON with bun, which they already require.

Co-authored-by: benjamin beres <benjamin.beres@bienpreter.com>
This commit is contained in:
garrytanandbenjamin beres committed 2026-10-03 21:34:15 +00:00
1 parent c612f28339
commit 6c0917aed2
4 files changed
+108 -17

No files matched your search

+31
View File
@@ -565,3 +565,34 @@ describe('gstack-gbrain-source-wireup — defensive paths', () => {
expect(fs.existsSync(path.join(worktreeDir, 'unrelated.txt'))).toBe(false); // stray gone
});
});
// B8 (#2369): the wireup reads `gbrain sources list --json` with bun, so a
// machine without jq (git-bash on Windows, minimal Linux) still wires up.
describe('gstack-gbrain-source-wireup without jq (B8)', () => {
function pathWithoutJq(): string {
const dir = path.join(tmpHome, 'no-jq-bin');
fs.mkdirSync(dir, { recursive: true });
for (const base of ['/usr/bin', '/bin', '/usr/sbin', '/sbin']) {
if (!fs.existsSync(base)) continue;
for (const name of fs.readdirSync(base)) {
if (name === 'jq' || fs.existsSync(path.join(dir, name))) continue;
try { fs.symlinkSync(path.join(base, name), path.join(dir, name)); } catch {}
}
}
return `${fakeBinDir}:${dir}:${BUN_ONLY_DIR}`;
}
test('detects an already-registered source and re-runs cleanly with no jq on PATH', () => {
setupGstackRepo('git@github.com:user/gstack-brain-user.git');
makeFakeGbrain({});
const PATH = pathWithoutJq();
expect(spawnSync('sh', ['-c', 'command -v jq'], { env: { PATH }, timeout: 10_000 }).status).not.toBe(0);
const first = run([], { env: { PATH, GSTACK_BRAIN_NO_SYNC: '1' } });
expect(first.stderr).not.toContain('jq required');
expect(first.status).toBe(0);
const second = run([], { env: { PATH, GSTACK_BRAIN_NO_SYNC: '1' } });
expect(second.status).toBe(0);
expect(readState().sources).toHaveLength(1);
});
});