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:
@@ -25,6 +25,7 @@ const {
|
||||
compareSemverCore,
|
||||
isStableTripletSemver,
|
||||
} = require('../../get-shit-done/bin/lib/semver-compare.cjs');
|
||||
const { PACKAGE_NAME } = require('../../get-shit-done/bin/lib/package-identity.cjs');
|
||||
|
||||
function parseArgs(argv) {
|
||||
const opts = {
|
||||
@@ -37,7 +38,7 @@ function parseArgs(argv) {
|
||||
changelog: null,
|
||||
output: null,
|
||||
repoSlug: 'open-gsd/get-shit-done-redux',
|
||||
installCommand: 'npx @opengsd/get-shit-done-redux@latest',
|
||||
installCommand: `npx ${PACKAGE_NAME}@latest`,
|
||||
json: false,
|
||||
};
|
||||
if (argv.length === 0) return { ok: true, opts };
|
||||
|
||||
@@ -4,6 +4,7 @@ const cp = require('node:child_process');
|
||||
const path = require('node:path');
|
||||
|
||||
const { parseFragment } = require('./parse.cjs');
|
||||
const { PACKAGE_NAME } = require('../../get-shit-done/bin/lib/package-identity.cjs');
|
||||
|
||||
const SECTION_ORDER = ['Fixed', 'Added', 'Changed', 'Deprecated', 'Removed', 'Security'];
|
||||
|
||||
@@ -146,7 +147,7 @@ function serializeGithubReleaseNotes({
|
||||
fromRef,
|
||||
toRef,
|
||||
repoSlug = 'open-gsd/get-shit-done-redux',
|
||||
installCommand = 'npx @opengsd/get-shit-done-redux@latest',
|
||||
installCommand = `npx ${PACKAGE_NAME}@latest`,
|
||||
}) {
|
||||
if (installCommand.includes('`')) {
|
||||
throw new Error('installCommand cannot contain backtick characters');
|
||||
|
||||
@@ -45,6 +45,7 @@ const { execFileSync, spawnSync } = require('child_process');
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const { PACKAGE_NAME } = require('../get-shit-done/bin/lib/package-identity.cjs');
|
||||
// 120 s proved too tight on Windows GitHub-hosted runners: cold-cache
|
||||
// `npm install -g` with a 1499-file tarball took ~120 s exactly, causing
|
||||
// spawnSync to fire SIGTERM and return { status: null, stdout: '', stderr: '' }
|
||||
@@ -121,10 +122,12 @@ function binInvocation(binPath, args = []) {
|
||||
* an npm --prefix install directory.
|
||||
*/
|
||||
function pkgRoot(installPrefix) {
|
||||
// POSIX: <prefix>/lib/node_modules/@opengsd/get-shit-done-redux
|
||||
// Windows: <prefix>/node_modules/@opengsd/get-shit-done-redux
|
||||
const posix = path.join(installPrefix, 'lib', 'node_modules', '@opengsd', 'get-shit-done-redux');
|
||||
const win = path.join(installPrefix, 'node_modules', '@opengsd', 'get-shit-done-redux');
|
||||
// POSIX: <prefix>/lib/node_modules/<scope>/<pkg>
|
||||
// Windows: <prefix>/node_modules/<scope>/<pkg>
|
||||
// PACKAGE_NAME is scoped (@scope/pkg), so split('/') yields the two path segments.
|
||||
const pkgSegments = PACKAGE_NAME.split('/');
|
||||
const posix = path.join(installPrefix, 'lib', 'node_modules', ...pkgSegments);
|
||||
const win = path.join(installPrefix, 'node_modules', ...pkgSegments);
|
||||
return fs.existsSync(posix) ? posix : win;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user