Files
msd-core/tests/package-manifest.test.cjs
Jakub Zych a9a7a328e6 refactor: hard-fork GSD -> MSD (Make Software Done)
Mechanical rename produced by scripts/msd-rename.cjs: gsd/Gsd/GSD -> msd/Msd/MSD
across contents and paths, upstream package/repo coordinates -> @golem15/msd-core
and golem15com/msd-core. Deep links into upstream history, sibling upstream
packages, the GSD-2 import feature, CHANGELOG.md and .changeset/ are kept as-is.

Hand edits on top: MSD block-letter banner and logos, LICENSE copyright line,
package/plugin identity, regenerated lockfile, install-tree fixtures, derived
registries and benchmark baseline; migration checksum baseline re-locked
(MSD keeps its own install state, so no install had applied the old sums);
sort-order and regex-escaped expectations in tests adjusted.
2026-10-06 01:47:40 +02:00

77 lines
2.3 KiB
JavaScript

/**
* Regression tests for bugs #1852 and #1862
*
* The package.json "files" field listed "hooks/dist" but not "hooks" directly.
* The three .sh hook files live in hooks/ (not hooks/dist/), so they were
* excluded from the npm tarball. Any fresh install from the registry would
* produce broken shell hooks (SessionStart / PostToolUse errors).
*
* Fix: change "hooks/dist" to "hooks" in package.json so that the entire
* hooks/ directory (both .js dist files and .sh source files) is included.
*/
'use strict';
const { describe, test } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('fs');
const path = require('path');
const PKG_PATH = path.join(__dirname, '..', 'package.json');
const HOOKS_DIR = path.join(__dirname, '..', 'hooks');
const SH_HOOKS = [
'msd-session-state.sh',
'msd-validate-commit.sh',
'msd-phase-boundary.sh',
];
describe('package.json manifest — hooks .sh files (#1852 #1862)', () => {
let pkg;
try {
pkg = JSON.parse(fs.readFileSync(PKG_PATH, 'utf-8'));
} catch {
pkg = {};
}
const filesField = pkg.files || [];
test('package.json "files" does not contain the narrow "hooks/dist" entry', () => {
assert.ok(
!filesField.includes('hooks/dist'),
[
'"hooks/dist" must not appear alone in package.json "files".',
'This entry only bundles compiled .js files and excludes the .sh hooks',
'in hooks/ (msd-session-state.sh, msd-validate-commit.sh, msd-phase-boundary.sh).',
'Replace "hooks/dist" with "hooks" to include all hook files.',
].join(' ')
);
});
test('package.json "files" includes the full "hooks" directory', () => {
assert.ok(
filesField.includes('hooks'),
[
'"hooks" must be listed in package.json "files" so that',
'.sh hook files are included in the npm tarball.',
'Current files field: ' + JSON.stringify(filesField),
].join(' ')
);
});
for (const hook of SH_HOOKS) {
test(`${hook} exists in hooks/ source directory`, () => {
const hookPath = path.join(HOOKS_DIR, hook);
assert.ok(
fs.existsSync(hookPath),
[
`${hook} must exist at hooks/${hook}.`,
'This file must be present in the repository so that',
'it is included when npm packs the "hooks" directory.',
].join(' ')
);
});
}
});