* chore(npm): rebrand packages to @opengsd scope Rename: - get-shit-done-redux → @opengsd/get-shit-done-redux - @gsd-redux/sdk → @opengsd/gsd-sdk Add publishConfig.access=public for first-time scoped publish. CLI binary names (get-shit-done-redux, gsd-sdk, gsd-tools) unchanged. Sweeps install commands, npx invocations, CI publish/version-check workflows, tests, docs, READMEs (all translations), and the PACKAGE_NAME constant in check-latest-version. Bumps qs 6.15.1 → 6.15.2 to clear a moderate advisory surfaced by the audit-clean test (GHSA-q8mj-m7cp-5q26). Closes #126 * chore: pin 2.0.0 release + remove canary workflow - Bump both packages 1.50.0-canary.0 → 2.0.0 for first @opengsd publish - Remove .github/workflows/canary.yml and canary dist-tag handling in release.yml / release-sdk.yml - Drop canary section from VERSIONING.md Refs #126 * chore: address review findings + harden tarball-smoke timeout - .changeset/opengsd-org-rename.md: match project's custom parse.cjs frontmatter (type: Changed / pr: 127); the scoped @changesets/cli keys were silently rejected. - CONTEXT.md: drop two canary-stream policy lines and a dangling DEFECT.CANARY-VERSION-LEAK.cross-ref now that canary.yml is gone. - tests/release-tarball-smoke.install.test.cjs: pass timeout: 600_000 for npm pack + global install; the 3-minute runNpm default was timing out on slower Docker hosts (cartographer). Refs #126 * fix(sdk): add missing type/runtime devDependencies for build prepublishOnly invokes tsc which couldn't resolve @types/node, @types/ws, or synckit. They had been hoisted from root but were not declared in sdk/'s own package.json — first publish from a clean SDK tree failed. Refs #126 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(ci): use npm pack stdout instead of glob to find tarball `npm pack --silent` for a scoped package (@opengsd/get-shit-done-redux) produces `opengsd-get-shit-done-redux-*.tgz`, not `get-shit-done-redux-*.tgz`. Capture the filename from stdout instead of a hardcoded glob so the step works regardless of package name format. Fixes smoke (ubuntu-latest, 22, false) CI failure. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * ci: treat workflow-file changes as test-skip eligible `.github/workflows/install-smoke.yml` (and other workflow files) were in neither `test.yml` paths nor `test-skip.yml` paths-ignore, so neither workflow ran on a workflow-only commit — leaving the required test-skip check perpetually missing. Refs #126 * chore: reset version to 1.0.0 for first @opengsd publish Nothing has been published yet under the @opengsd scope, so the inaugural release uses 1.0.0 rather than 2.0.0. The "major bump" in the changeset reflects the breaking install-command change for users migrating from the prior unscoped `get-shit-done-redux`, not a numeric continuation from a 1.x line under the new identity. Refs #126 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
192 lines
7.9 KiB
JavaScript
192 lines
7.9 KiB
JavaScript
'use strict';
|
|
|
|
process.env.GSD_TEST_MODE = '1';
|
|
|
|
/**
|
|
* Regression test for #3011: SDK not found.
|
|
*
|
|
* Reporter (Windows / PowerShell 7) ran `npx @opengsd/get-shit-done-redux@latest`,
|
|
* upgrade reported success, but `gsd-sdk` could not be resolved by Claude
|
|
* Code, Git Bash, PowerShell, or WSL. The previous diagnostic was a
|
|
* generic "not on your PATH" with no actionable info; the user couldn't
|
|
* find where the shim was written or how to add it to PATH for each shell.
|
|
*
|
|
* Fix: formatSdkPathDiagnostic() returns a typed IR with the shim
|
|
* location, platform-specific PATH-export commands, and an npx-note
|
|
* when running under an `_npx` cache. The console renderer in install.js
|
|
* just emits each line; tests assert on the IR fields directly.
|
|
*/
|
|
|
|
const { test, describe } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const path = require('node:path');
|
|
|
|
const { formatSdkPathDiagnostic } = require(path.join(__dirname, '..', 'bin', 'install.js'));
|
|
|
|
describe('Bug #3011: formatSdkPathDiagnostic — Windows shim location and PATH commands', () => {
|
|
test('emits shim location line when shimDir is provided', () => {
|
|
const ir = formatSdkPathDiagnostic({
|
|
shimDir: 'C:\\Users\\me\\AppData\\Roaming\\npm',
|
|
platform: 'win32',
|
|
runDir: 'C:\\Users\\me\\AppData\\Roaming\\npm\\node_modules\\get-shit-done-redux\\bin',
|
|
});
|
|
assert.equal(ir.shimLocationLine,
|
|
'Shim written to: C:\\Users\\me\\AppData\\Roaming\\npm');
|
|
});
|
|
|
|
test('Windows action lines include all three shell flavors (PowerShell, cmd.exe, Git Bash)', () => {
|
|
const ir = formatSdkPathDiagnostic({
|
|
shimDir: 'C:\\Users\\me\\AppData\\Roaming\\npm',
|
|
platform: 'win32',
|
|
runDir: 'C:\\some\\path',
|
|
});
|
|
const labels = ir.actionLines.map(l => l.split(':')[0].trim());
|
|
assert.ok(labels.some(l => l === 'PowerShell'), `expected PowerShell line, got: ${JSON.stringify(labels)}`);
|
|
assert.ok(labels.some(l => l === 'cmd.exe'), `expected cmd.exe line, got: ${JSON.stringify(labels)}`);
|
|
assert.ok(labels.some(l => l === 'Git Bash'), `expected Git Bash line, got: ${JSON.stringify(labels)}`);
|
|
});
|
|
|
|
test('Git Bash command translates Windows backslashes to forward slashes', () => {
|
|
const ir = formatSdkPathDiagnostic({
|
|
shimDir: 'C:\\Users\\me\\AppData\\Roaming\\npm',
|
|
platform: 'win32',
|
|
runDir: 'C:\\some\\path',
|
|
});
|
|
const gitBash = ir.actionLines.find(l => l.startsWith('Git Bash'));
|
|
assert.ok(gitBash);
|
|
// Git Bash uses POSIX path syntax; backslashes would not work in bash.
|
|
assert.equal(gitBash.includes('\\'), false,
|
|
`Git Bash line must not contain backslashes: ${gitBash}`);
|
|
assert.ok(gitBash.includes('C:/Users/me/AppData/Roaming/npm'),
|
|
`Git Bash line must contain forward-slash path: ${gitBash}`);
|
|
});
|
|
|
|
test('PowerShell command preserves Windows backslashes in the embedded path', () => {
|
|
const ir = formatSdkPathDiagnostic({
|
|
shimDir: 'C:\\Users\\me\\AppData\\Roaming\\npm',
|
|
platform: 'win32',
|
|
runDir: 'C:\\some\\path',
|
|
});
|
|
const ps = ir.actionLines.find(l => l.startsWith('PowerShell'));
|
|
assert.ok(ps);
|
|
// PowerShell uses native Windows paths.
|
|
assert.ok(ps.includes('C:\\Users\\me\\AppData\\Roaming\\npm'),
|
|
`PowerShell line must contain Windows-style path: ${ps}`);
|
|
});
|
|
|
|
test("paths containing a single quote are escaped for each shell (#3014 CR)", () => {
|
|
// CR finding: a real Windows username like "O'Neil" would generate
|
|
// unparseable commands. PowerShell single-quote escape is '' (doubled);
|
|
// bash within outer single-quotes uses '\'' to embed a literal quote;
|
|
// POSIX export within double-quotes leaves single quotes alone.
|
|
const ir = formatSdkPathDiagnostic({
|
|
shimDir: "C:\\Users\\O'Neil\\AppData\\Roaming\\npm",
|
|
platform: 'win32',
|
|
runDir: 'C:\\some\\path',
|
|
});
|
|
const ps = ir.actionLines.find(l => l.startsWith('PowerShell'));
|
|
const cmd = ir.actionLines.find(l => l.startsWith('cmd.exe'));
|
|
const gitBash = ir.actionLines.find(l => l.startsWith('Git Bash'));
|
|
// PowerShell: literal quote escape is doubled
|
|
assert.ok(ps.includes("C:\\Users\\O''Neil\\AppData\\Roaming\\npm"),
|
|
`PowerShell line must double single quotes: ${ps}`);
|
|
// cmd.exe (which delegates to powershell) uses the same PS-escape
|
|
assert.ok(cmd.includes("C:\\Users\\O''Neil\\AppData\\Roaming\\npm"),
|
|
`cmd.exe line must double single quotes (delegates to PowerShell): ${cmd}`);
|
|
// Git Bash: '\'' escape inside outer single-quoted echo
|
|
assert.ok(gitBash.includes("C:/Users/O'\\''Neil/AppData/Roaming/npm"),
|
|
`Git Bash line must escape single quote with '\\\\'': ${gitBash}`);
|
|
});
|
|
});
|
|
|
|
describe('Bug #3011: formatSdkPathDiagnostic — POSIX action lines', () => {
|
|
test('emits a single export PATH line on Linux', () => {
|
|
const ir = formatSdkPathDiagnostic({
|
|
shimDir: '/home/me/.local/bin',
|
|
platform: 'linux',
|
|
runDir: '/home/me/.local/lib/node_modules/get-shit-done-redux/bin',
|
|
});
|
|
const exports_ = ir.actionLines.filter(l => l.startsWith('export PATH='));
|
|
assert.equal(exports_.length, 1, `expected 1 export line, got: ${JSON.stringify(ir.actionLines)}`);
|
|
assert.equal(exports_[0], 'export PATH="/home/me/.local/bin:$PATH"');
|
|
});
|
|
|
|
test('emits a single export PATH line on macOS (darwin)', () => {
|
|
const ir = formatSdkPathDiagnostic({
|
|
shimDir: '/usr/local/bin',
|
|
platform: 'darwin',
|
|
runDir: '/usr/local/lib/node_modules/get-shit-done-redux/bin',
|
|
});
|
|
assert.ok(ir.actionLines.some(l => l === 'export PATH="/usr/local/bin:$PATH"'));
|
|
});
|
|
});
|
|
|
|
describe('Bug #3011: formatSdkPathDiagnostic — fallback when shimDir is null', () => {
|
|
test('shimLocationLine is empty', () => {
|
|
const ir = formatSdkPathDiagnostic({
|
|
shimDir: null,
|
|
platform: 'win32',
|
|
runDir: 'C:\\some\\path',
|
|
});
|
|
assert.equal(ir.shimLocationLine, '');
|
|
});
|
|
|
|
test('action lines fall back to npm install -g advice', () => {
|
|
const ir = formatSdkPathDiagnostic({
|
|
shimDir: null,
|
|
platform: 'win32',
|
|
runDir: 'C:\\some\\path',
|
|
});
|
|
assert.ok(ir.actionLines.some(l => l.includes('npm install -g @opengsd/get-shit-done-redux')));
|
|
});
|
|
});
|
|
|
|
describe('Bug #3011: formatSdkPathDiagnostic — npx-cache detection', () => {
|
|
test('detects POSIX npx cache path', () => {
|
|
const ir = formatSdkPathDiagnostic({
|
|
shimDir: '/home/me/.local/bin',
|
|
platform: 'linux',
|
|
runDir: '/home/me/.npm/_npx/abc123/node_modules/get-shit-done-redux/bin',
|
|
});
|
|
assert.equal(ir.isNpx, true);
|
|
assert.ok(ir.npxNoteLines.length >= 2,
|
|
`expected npx note lines, got: ${JSON.stringify(ir.npxNoteLines)}`);
|
|
assert.ok(ir.npxNoteLines.some(l => l.includes('npx')));
|
|
assert.ok(ir.npxNoteLines.some(l => l.includes('npm install -g')));
|
|
});
|
|
|
|
test('detects Windows npx cache path', () => {
|
|
const ir = formatSdkPathDiagnostic({
|
|
shimDir: 'C:\\Users\\me\\AppData\\Roaming\\npm',
|
|
platform: 'win32',
|
|
runDir: 'C:\\Users\\me\\AppData\\Local\\npm-cache\\_npx\\abc123\\node_modules\\get-shit-done-redux\\bin',
|
|
});
|
|
assert.equal(ir.isNpx, true);
|
|
});
|
|
|
|
test('non-npx invocation leaves npxNoteLines empty', () => {
|
|
const ir = formatSdkPathDiagnostic({
|
|
shimDir: 'C:\\Users\\me\\AppData\\Roaming\\npm',
|
|
platform: 'win32',
|
|
runDir: 'C:\\Users\\me\\AppData\\Roaming\\npm\\node_modules\\get-shit-done-redux\\bin',
|
|
});
|
|
assert.equal(ir.isNpx, false);
|
|
assert.deepEqual(ir.npxNoteLines, []);
|
|
});
|
|
});
|
|
|
|
describe('Bug #3011: formatSdkPathDiagnostic — actionable shape contract', () => {
|
|
test('returns the documented IR shape for any input', () => {
|
|
const ir = formatSdkPathDiagnostic({
|
|
shimDir: '/x',
|
|
platform: 'linux',
|
|
runDir: '/y',
|
|
});
|
|
assert.equal(typeof ir.shimLocationLine, 'string');
|
|
assert.ok(Array.isArray(ir.actionLines));
|
|
assert.ok(Array.isArray(ir.npxNoteLines));
|
|
assert.equal(typeof ir.isNpx, 'boolean');
|
|
assert.equal(typeof ir.isWin32, 'boolean');
|
|
});
|
|
});
|