Adds get-shit-done/bin/lib/package-identity.cjs as the single source of truth for PACKAGE_NAME, derived from package.json `name` via require. Refactors all runtime code-line occurrences in bin/install.js, get-shit-done/bin/check-latest-version.cjs, get-shit-done/bin/lib/shell-command-projection.cjs, get-shit-done/bin/lib/verify.cjs, scripts/changeset/cli.cjs, scripts/changeset/github-release-notes.cjs, and scripts/release-tarball-smoke.cjs to import PACKAGE_NAME from the identity module instead of hardcoding the literal. The package name is unchanged (@opengsd/get-shit-done-redux). Behaviour is byte-identical: all --help, hint, and release-notes strings render exactly as before. Golden-literal tests (bug-2992, bug-378) keep their hardcoded expected values and remain GREEN. Adds tests/package-name-single-source.test.cjs lint guard: fails CI if @opengsd/get-shit-done-redux appears as a code-line literal in runtime .cjs/.js outside the identity module, enforcing a one-file rename path. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -21,10 +21,11 @@
|
||||
*/
|
||||
|
||||
const { execNpm } = require('./lib/shell-command-projection.cjs');
|
||||
const { PACKAGE_NAME } = require('./lib/package-identity.cjs');
|
||||
|
||||
// Hardcoded. Do not parameterise — the whole point of this script is that
|
||||
// the package name is not a runtime choice for the caller.
|
||||
const PACKAGE_NAME = '@opengsd/get-shit-done-redux';
|
||||
// Sourced from package.json via package-identity.cjs (#516). Do not
|
||||
// parameterise — the whole point of this script is that the package name is
|
||||
// not a runtime choice for the caller.
|
||||
|
||||
const CHECK_REASON = Object.freeze({
|
||||
OK: 'ok',
|
||||
|
||||
19
get-shit-done/bin/lib/package-identity.cjs
Normal file
19
get-shit-done/bin/lib/package-identity.cjs
Normal file
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Single source of truth for the package name at runtime (#516).
|
||||
*
|
||||
* Why this exists: the package name `@opengsd/get-shit-done-redux` was
|
||||
* hardcoded as a string literal in ~15 runtime .cjs/.js files. When the
|
||||
* package is renamed (e.g. to `@opengsd/gsd-core`), changing this one
|
||||
* require path propagates the new name everywhere in runtime code.
|
||||
*
|
||||
* Path: get-shit-done/bin/lib/package-identity.cjs
|
||||
* Resolves package.json both in-repo (3 levels up) and when shipped
|
||||
* (package root is always 3 dirs above this file).
|
||||
*/
|
||||
const pkg = require('../../../package.json');
|
||||
|
||||
module.exports = {
|
||||
PACKAGE_NAME: pkg.name,
|
||||
};
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const { PACKAGE_NAME } = require('./package-identity.cjs');
|
||||
// Use non-destructured access so test-time mock.method(childProcess, 'spawnSync')
|
||||
// can intercept calls from this seam — destructured imports capture references
|
||||
// at load time and become un-mockable.
|
||||
@@ -350,12 +351,12 @@ function formatSdkPathDiagnostic({ shimDir, platform, runDir }) {
|
||||
} else {
|
||||
actionLines.push('Could not locate a writable PATH directory to install the shim.');
|
||||
actionLines.push('Install globally to materialize the bin symlink:');
|
||||
actionLines.push('npm install -g @opengsd/get-shit-done-redux');
|
||||
actionLines.push(`npm install -g ${PACKAGE_NAME}`);
|
||||
}
|
||||
const npxNoteLines = isNpx
|
||||
? [
|
||||
"Note: you're running via npx. For a persistent shim,",
|
||||
'install globally instead: npm install -g @opengsd/get-shit-done-redux',
|
||||
`install globally instead: npm install -g ${PACKAGE_NAME}`,
|
||||
]
|
||||
: [];
|
||||
return { shimLocationLine, actionLines, shellActions, npxNoteLines, isNpx, isWin32 };
|
||||
|
||||
@@ -14,6 +14,7 @@ const path = require('path');
|
||||
const os = require('os');
|
||||
const { loadConfig, normalizePhaseName, escapeRegex, findPhaseInternal, getMilestoneInfo, stripShippedMilestones, extractCurrentMilestone, output, error, checkAgentsInstalled, CONFIG_DEFAULTS, inspectWorktreeHealth } = require('./core.cjs');
|
||||
const { execGit, platformReadSync: safeReadFile, platformWriteSync } = require('./shell-command-projection.cjs');
|
||||
const { PACKAGE_NAME } = require('./package-identity.cjs');
|
||||
const { planningDir } = require('./planning-workspace.cjs');
|
||||
const { extractFrontmatter, parseMustHavesBlock } = require('./frontmatter.cjs');
|
||||
const { writeStateMd } = require('./state.cjs');
|
||||
@@ -867,11 +868,11 @@ function cmdValidateHealth(cwd, options, raw) {
|
||||
if (agentStatus.installed_agents.length === 0) {
|
||||
addIssue('warning', 'W010',
|
||||
`No GSD agents found in ${agentStatus.agents_dir} — Task(subagent_type="gsd-*") will fall back to general-purpose`,
|
||||
'Run the GSD installer: npx @opengsd/get-shit-done-redux@latest');
|
||||
`Run the GSD installer: npx ${PACKAGE_NAME}@latest`);
|
||||
} else {
|
||||
addIssue('warning', 'W010',
|
||||
`Missing ${agentStatus.missing_agents.length} GSD agents: ${agentStatus.missing_agents.join(', ')} — affected workflows will fall back to general-purpose`,
|
||||
'Run the GSD installer: npx @opengsd/get-shit-done-redux@latest');
|
||||
`Run the GSD installer: npx ${PACKAGE_NAME}@latest`);
|
||||
}
|
||||
}
|
||||
} catch { /* intentionally empty — agent check is non-blocking */ }
|
||||
|
||||
Reference in New Issue
Block a user