mirror of
https://github.com/glittercowboy/get-shit-done
synced 2026-04-25 17:25:23 +02:00
PR #2386 v1 installed the published @gsd-build/sdk from npm, which ships an older version that lacks query handlers needed by current workflows. Every GSD release would drift further from what the installer put on PATH. This commit rewires installSdkIfNeeded() to build from the in-repo sdk/ source tree instead: 1. cd sdk && npm install (build-time deps incl. tsc) 2. npm run build (tsc → sdk/dist/) 3. npm install -g . (global install; gsd-sdk on PATH) Each step is a hard gate — failures warn loudly and point users at the manual equivalent command. No more silent drift between installed SDK and the rest of the GSD system. Root package.json `files` now ships sdk/src, sdk/prompts, sdk/package.json, sdk/package-lock.json, and sdk/tsconfig.json so npm-registry installs also carry the source tree needed to build gsd-sdk locally. Also fixes a blocking tsc error in sdk/src/event-stream.ts:313 — the cast to `Array<{ type: string; [key: string]: unknown }>` needed a double-cast via `unknown` because BetaContentBlock's variants don't carry an index signature. Runtime-neutral type-widening; sdk vitest suite unchanged (1256 passing; the lone failure is a pre-existing integration test that requires external API access). Updates the #1657/#2385 regression test to assert the new build-from-source path (path.resolve(__dirname, '..', 'sdk') + `npm run build` + `npm install -g .`) plus a new assertion that root package.json files array ships sdk source. Refs #2385 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
115 lines
4.9 KiB
JavaScript
115 lines
4.9 KiB
JavaScript
/**
|
|
* Regression tests for:
|
|
* #1656 — 3 bash hooks referenced in settings.json but never installed
|
|
* #1657 — SDK install prompt fires and fails during interactive install
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
process.env.GSD_TEST_MODE = '1';
|
|
|
|
const { test, describe, before } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const { execFileSync } = require('child_process');
|
|
|
|
const HOOKS_DIST = path.join(__dirname, '..', 'hooks', 'dist');
|
|
const BUILD_SCRIPT = path.join(__dirname, '..', 'scripts', 'build-hooks.js');
|
|
const INSTALL_SRC = path.join(__dirname, '..', 'bin', 'install.js');
|
|
|
|
// ─── #1656 ───────────────────────────────────────────────────────────────────
|
|
|
|
describe('#1656: community .sh hooks must be present in hooks/dist', () => {
|
|
// Run the build script once before checking outputs.
|
|
// hooks/dist/ is gitignored so it must be generated; this mirrors what
|
|
// `npm run build:hooks` (prepublishOnly) does before publish.
|
|
before(() => {
|
|
execFileSync(process.execPath, [BUILD_SCRIPT], {
|
|
encoding: 'utf-8',
|
|
stdio: 'pipe',
|
|
});
|
|
});
|
|
|
|
test('gsd-session-state.sh exists in hooks/dist', () => {
|
|
const p = path.join(HOOKS_DIST, 'gsd-session-state.sh');
|
|
assert.ok(fs.existsSync(p), 'gsd-session-state.sh must be in hooks/dist/ so the installer can copy it');
|
|
});
|
|
|
|
test('gsd-validate-commit.sh exists in hooks/dist', () => {
|
|
const p = path.join(HOOKS_DIST, 'gsd-validate-commit.sh');
|
|
assert.ok(fs.existsSync(p), 'gsd-validate-commit.sh must be in hooks/dist/ so the installer can copy it');
|
|
});
|
|
|
|
test('gsd-phase-boundary.sh exists in hooks/dist', () => {
|
|
const p = path.join(HOOKS_DIST, 'gsd-phase-boundary.sh');
|
|
assert.ok(fs.existsSync(p), 'gsd-phase-boundary.sh must be in hooks/dist/ so the installer can copy it');
|
|
});
|
|
});
|
|
|
|
// ─── #1657 ───────────────────────────────────────────────────────────────────
|
|
//
|
|
// Historical context: #1657 originally guarded against a broken `promptSdk()`
|
|
// flow that shipped when `@gsd-build/sdk` did not yet exist on npm. The
|
|
// package was published at v0.1.0 and is now a hard runtime requirement for
|
|
// every /gsd-* command (they all shell out to `gsd-sdk query …`).
|
|
//
|
|
// #2385 restored the `--sdk` flag and made SDK install the default path in
|
|
// bin/install.js. These guards are inverted: we now assert that SDK install
|
|
// IS wired up, and that the old broken `promptSdk()` prompt is still gone.
|
|
|
|
describe('#1657 / #2385: SDK install must be wired into installer source', () => {
|
|
let src;
|
|
test('install.js does not contain the legacy promptSdk() prompt (#1657)', () => {
|
|
src = fs.readFileSync(INSTALL_SRC, 'utf-8');
|
|
assert.ok(
|
|
!src.includes('promptSdk('),
|
|
'promptSdk() must not be reintroduced — the old interactive prompt flow was broken'
|
|
);
|
|
});
|
|
|
|
test('install.js wires up --sdk / --no-sdk flag handling (#2385)', () => {
|
|
src = src || fs.readFileSync(INSTALL_SRC, 'utf-8');
|
|
assert.ok(
|
|
src.includes("args.includes('--sdk')"),
|
|
'--sdk flag must be parsed so users can force SDK (re)install'
|
|
);
|
|
assert.ok(
|
|
src.includes("args.includes('--no-sdk')"),
|
|
'--no-sdk flag must be parsed so users can opt out of SDK install'
|
|
);
|
|
});
|
|
|
|
test('install.js builds gsd-sdk from in-repo sdk/ source (#2385)', () => {
|
|
src = src || fs.readFileSync(INSTALL_SRC, 'utf-8');
|
|
// The installer must locate the in-repo sdk/ directory, run the build,
|
|
// and install it globally. We intentionally do NOT install
|
|
// @gsd-build/sdk from npm because that published version lags the source
|
|
// tree and shipping it breaks query handlers added since the last
|
|
// publish.
|
|
assert.ok(
|
|
src.includes("path.resolve(__dirname, '..', 'sdk')") ||
|
|
src.includes('path.resolve(__dirname, "..", "sdk")'),
|
|
'installer must locate the in-repo sdk/ directory'
|
|
);
|
|
assert.ok(
|
|
src.includes("'npm install -g .'") ||
|
|
src.includes("['install', '-g', '.']"),
|
|
'installer must run `npm install -g .` from sdk/ to install the built package globally'
|
|
);
|
|
assert.ok(
|
|
src.includes("['run', 'build']"),
|
|
'installer must compile TypeScript via `npm run build` before installing globally'
|
|
);
|
|
});
|
|
|
|
test('package.json ships sdk source in published tarball (#2385)', () => {
|
|
const rootPkg = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf-8'));
|
|
const files = rootPkg.files || [];
|
|
assert.ok(
|
|
files.some((f) => f === 'sdk' || f.startsWith('sdk/')),
|
|
'root package.json `files` must include sdk source so npm-registry installs can build gsd-sdk from source'
|
|
);
|
|
});
|
|
});
|