Files
msd-core/tests/changeset-github-release-notes.test.cjs
Tom Boucher 79002a00cb chore(#518): rename npm package + bin to @opengsd/gsd-core (#519)
* chore: rename npm package + bin to @opengsd/gsd-core (functional)

- package.json: name @opengsd/get-shit-done-redux → @opengsd/gsd-core,
  bin key get-shit-done-redux → gsd-core, repository/homepage/bugs URLs
- package-lock.json: regenerated (npm install --package-lock-only)
- tests/**, scripts/**, bin/**, .github/**, agents/**, commands/**,
  get-shit-done/bin/**, get-shit-done/workflows/**:
  applied the 4-rule replacement (scoped npm ref, GitHub repo path,
  bin/clone invocations) per #505 single-source refactor

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* docs: sweep live references to @opengsd/gsd-core

Update all live documentation (README.md + translations, docs/**,
CONTRIBUTING.md, VERSIONING.md, SECURITY.md, CONTEXT.md,
docs/CANARY.md) to reflect the renamed package and repository.

Rules applied:
- @opengsd/get-shit-done-redux → @opengsd/gsd-core (scoped npm name)
- open-gsd/get-shit-done-redux → open-gsd/gsd-core (GitHub repo)
- GSD-redux/get-shit-done-redux → open-gsd/gsd-core (stale badge org)
- bare bin/clone refs → gsd-core

CHANGELOG.md, docs/adr/**, docs/RELEASE-*.md, docs/research/**,
and .changeset/** are preserved byte-identical.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix: add negative lookbehind to slash-command regex in bug-2954 test

The extractSlashReferences regex matched /gsd-core inside npm package
URLs (@opengsd/gsd-core), producing a false /gsd:core command reference.
Adding a negative lookbehind (?<![a-z]) excludes matches preceded by a
letter, so only standalone /gsd-<cmd> and /gsd:<cmd> tokens are found.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* chore(#518): add changeset for package rename

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* test(#518): update package-identity expectations to the renamed coordinates

The rebase regenerated the seam to @opengsd/gsd-core (bin gsd-core, repo
open-gsd/gsd-core). The #498 seam tests assert deriveIdentity against the REAL
package.json, so their expected literals must follow the rename. The drift-lint
unit test is left as-is — its SEAM is a self-consistent fixture and its
stale-literal detection cases would shift if altered; the live-repo scan in it
already passes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-30 17:25:02 -04:00

163 lines
5.5 KiB
JavaScript

'use strict';
process.env.GSD_TEST_MODE = '1';
const { test, describe } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const os = require('node:os');
const path = require('node:path');
const cp = require('node:child_process');
const ROOT = path.join(__dirname, '..');
const SCRIPT = path.join(ROOT, 'scripts', 'changeset', 'cli.cjs');
const {
loadFragmentsFromRange,
buildGithubReleaseNotesIr,
serializeGithubReleaseNotes,
renderGithubReleaseNotes,
} = require(path.join(ROOT, 'scripts', 'changeset', 'github-release-notes.cjs'));
function run(command, args, cwd) {
const result = cp.spawnSync(command, args, { cwd, encoding: 'utf8' });
assert.equal(result.status, 0, `${command} ${args.join(' ')}\nstdout=${result.stdout}\nstderr=${result.stderr}`);
return result.stdout;
}
function writeFragment(repo, name, type, pr, body) {
const dir = path.join(repo, '.changeset');
fs.mkdirSync(dir, { recursive: true });
fs.writeFileSync(path.join(dir, `${name}.md`), `---\ntype: ${type}\npr: ${pr}\n---\n${body}\n`);
}
function createTaggedRepo() {
const repo = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-release-notes-'));
run('git', ['init', '-q'], repo);
run('git', ['config', 'user.email', 'test@example.com'], repo);
run('git', ['config', 'user.name', 'Test User'], repo);
fs.writeFileSync(path.join(repo, 'README.md'), 'fixture\n');
run('git', ['add', 'README.md'], repo);
run('git', ['commit', '-q', '-m', 'initial'], repo);
run('git', ['tag', 'v1.0.0'], repo);
writeFragment(repo, 'fix-install-sdk', 'Fixed', 101, '**`gsd-sdk` now installs reliably** — persistent PATH is checked.');
writeFragment(repo, 'remove-intel-noise', 'Removed', 102, '**`gsd-intel-updater` no longer emits layout detection noise** — ordinary projects stay quiet.');
run('git', ['add', '.changeset'], repo);
run('git', ['commit', '-q', '-m', 'add changesets'], repo);
run('git', ['tag', 'v1.0.1'], repo);
return repo;
}
describe('changeset github release notes: tag-range renderer (#3382)', () => {
test('loads changed changeset slugs from a git tag range', () => {
const repo = createTaggedRepo();
const result = loadFragmentsFromRange({ repo, fromRef: 'v1.0.0', toRef: 'v1.0.1' });
assert.deepEqual(result.failures, []);
assert.deepEqual(
result.fragments.map((fragment) => ({ slug: fragment.slug, type: fragment.type, pr: fragment.pr })),
[
{ slug: 'fix-install-sdk', type: 'Fixed', pr: 101 },
{ slug: 'remove-intel-noise', type: 'Removed', pr: 102 },
],
);
});
test('builds grouped GitHub release-note IR from parsed fragments', () => {
const repo = createTaggedRepo();
const { fragments } = loadFragmentsFromRange({ repo, fromRef: 'v1.0.0', toRef: 'v1.0.1' });
const ir = buildGithubReleaseNotesIr({ fragments });
assert.deepEqual(
ir.sections.map((section) => ({
type: section.type,
groups: section.groups.map((group) => ({ title: group.title, prs: group.bullets.map((b) => b.pr) })),
})),
[
{ type: 'Fixed', groups: [{ title: 'Install & runtime conversion', prs: [101] }] },
{ type: 'Removed', groups: [{ title: 'Intel updater', prs: [102] }] },
],
);
});
test('CLI writes a notes file suitable for gh release edit --notes-file', () => {
const repo = createTaggedRepo();
const output = path.join(repo, 'release-notes.md');
const result = cp.spawnSync(
process.execPath,
[
SCRIPT,
'github-release-notes',
'--repo', repo,
'--from', 'v1.0.0',
'--to', 'v1.0.1',
'--repo-slug', 'example/project',
'--output', output,
'--json',
],
{ encoding: 'utf8' },
);
assert.equal(result.status, 0, `stdout=${result.stdout}\nstderr=${result.stderr}`);
const report = JSON.parse(result.stdout);
assert.deepEqual(
{ consumed: report.consumed, output: report.output, hasBodyInJson: report.body !== null },
{ consumed: 2, output, hasBodyInJson: false },
);
const generated = renderGithubReleaseNotes({
repo,
fromRef: 'v1.0.0',
toRef: 'v1.0.1',
repoSlug: 'example/project',
installCommand: 'npx @opengsd/gsd-core@latest',
});
assert.equal(fs.readFileSync(output, 'utf8'), generated.body);
});
test('rejects unsafe git refs before rendering a range', () => {
const repo = createTaggedRepo();
assert.throws(
() => loadFragmentsFromRange({ repo, fromRef: '--help', toRef: 'v1.0.1' }),
/Invalid git ref/,
);
});
test('validates PR metadata and repo slug before serializing release notes', () => {
assert.throws(
() => serializeGithubReleaseNotes({
ir: {
sections: [
{
type: 'Fixed',
groups: [{ title: 'Other fixes', bullets: [{ slug: 'missing-pr', body: 'missing pr' }] }],
},
],
},
fromRef: 'v1.0.0',
toRef: 'v1.0.1',
}),
/missing valid pr field/,
);
assert.throws(
() => serializeGithubReleaseNotes({
ir: { sections: [] },
fromRef: 'v1.0.0',
toRef: 'v1.0.1',
repoSlug: 'owner/repo/extra',
}),
/Invalid repoSlug format/,
);
assert.throws(
() => serializeGithubReleaseNotes({
ir: { sections: [] },
fromRef: 'v1.0.0',
toRef: 'v1.0.1',
installCommand: 'echo `bad`',
}),
/installCommand cannot contain backtick/,
);
});
});