fix(#935): install changeset CLI so /gsd-update changelog preview works (#938)

- bin/install.js now copies scripts/changeset/ and scripts/lib/ into
  <configDir>/scripts/ so $GSD_DIR/scripts/changeset/cli.cjs resolves
  at runtime; aborts install with an explicit failure if the source
  directory is missing from the package.
- gsd-core/workflows/update.md: corrected path from
  gsd-core/scripts/changeset/cli.cjs to scripts/changeset/cli.cjs;
  added an explicit [ ! -f ] guard so a missing CLI surfaces a clear
  message rather than silently swallowing the error; stderr captured
  via 2>&1 sentinel so node errors are visible in the preview output.
- release.yml's changeset-CLI invocations (node scripts/changeset/cli.cjs)
  remain at the repo-root path and are unaffected by this change.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-06-09 12:37:26 -04:00
committed by GitHub
parent 79254478fe
commit dcb0d8a28d
6 changed files with 311 additions and 19 deletions

View File

@@ -195,24 +195,29 @@ CHANGELOG_TMP="/tmp/gsd-changelog-$$.md"
curl -fsSL "https://raw.githubusercontent.com/open-gsd/gsd-core/main/CHANGELOG.md" -o "$CHANGELOG_TMP" 2>/dev/null \
|| wget -qO "$CHANGELOG_TMP" "https://raw.githubusercontent.com/open-gsd/gsd-core/main/CHANGELOG.md" 2>/dev/null
EXTRACT_JSON=$(node "$GSD_DIR/gsd-core/scripts/changeset/cli.cjs" extract \
--from "$INSTALLED_VERSION" \
--to "$LATEST_VERSION" \
--changelog "$CHANGELOG_TMP" \
--json 2>/dev/null)
EXTRACT_EXIT=$?
if [ "$EXTRACT_EXIT" -eq 2 ]; then
# Exit 2 = no releases in range (e.g. versions are equal or changelog is sparse)
CHANGELOG_PREVIEW="No changelog updates between v${INSTALLED_VERSION} and v${LATEST_VERSION}."
elif [ "$EXTRACT_EXIT" -ne 0 ] || [ -z "$EXTRACT_JSON" ]; then
CHANGELOG_PREVIEW="(Could not extract changelog — update will still proceed)"
GSD_CHANGESET_CLI="$GSD_DIR/scripts/changeset/cli.cjs"
if [ ! -f "$GSD_CHANGESET_CLI" ]; then
CHANGELOG_PREVIEW="(Changelog CLI not found at $GSD_CHANGESET_CLI — reinstall GSD to restore preview. Update will still proceed.)"
else
# Re-run without --json to get the human-readable markdown for display
CHANGELOG_PREVIEW=$(node "$GSD_DIR/gsd-core/scripts/changeset/cli.cjs" extract \
EXTRACT_JSON=$(node "$GSD_CHANGESET_CLI" extract \
--from "$INSTALLED_VERSION" \
--to "$LATEST_VERSION" \
--changelog "$CHANGELOG_TMP" 2>/dev/null || echo "(changelog unavailable)")
--changelog "$CHANGELOG_TMP" \
--json 2>&1)
EXTRACT_EXIT=$?
if [ "$EXTRACT_EXIT" -eq 2 ]; then
# Exit 2 = no releases in range (e.g. versions are equal or changelog is sparse)
CHANGELOG_PREVIEW="No changelog updates between v${INSTALLED_VERSION} and v${LATEST_VERSION}."
elif [ "$EXTRACT_EXIT" -ne 0 ] || [ -z "$EXTRACT_JSON" ]; then
CHANGELOG_PREVIEW="(Could not extract changelog — update will still proceed)"
else
# Re-run without --json to get the human-readable markdown for display
CHANGELOG_PREVIEW=$(node "$GSD_CHANGESET_CLI" extract \
--from "$INSTALLED_VERSION" \
--to "$LATEST_VERSION" \
--changelog "$CHANGELOG_TMP" 2>/dev/null || echo "(changelog unavailable)")
fi
fi
# Clean up temp changelog now that both extract runs are done
rm -f "$CHANGELOG_TMP"