Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/Aquaticat/Monochromatic. TypeScript and Rust monorepo: Claude Code and Pi coding-agent plugins, a m
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300/** The workspace scenarios of `dependent-version-bump-policy.unit.test.ts` and `bump-dependents-worktree.unit.test.ts`, as differential cases with their assertions. */// The bin scripts sit outside the package tsconfig's include list; this reference loads the Node types./// <reference types="node" />import { deepStrictEqual, ok,} from 'node:assert/strict';
import { hexText } from './dependent-version-incumbent-reader.mjs';import { bumpSummary, configFile, devDependent, findingCodes, findingPaths, manifestText, pair, raisedBase, runtimeDependent, source, workspace, workspaceResult, worktreeBase, worktreeBaseline,} from './dependent-version-unit-workspace-parts.mjs';
/** @typedef {import('./dependent-version-types.mjs').CaseResult} CaseResult *//** @typedef {import('./dependent-version-types.mjs').DifferentialCase} DifferentialCase *//** @typedef {import('./dependent-version-types.mjs').WorkspaceInput} WorkspaceInput *//** @typedef {DifferentialCase & { check: (output: CaseResult) => void }} UnitScenario */
/** The workspace scenarios: name, input, and the unit test's assertion.
@type {[string, WorkspaceInput, (output: CaseResult) => void][]} */const table = [ [ 'findDependentBumps patches runtime and bundled dependents of a hand bump and leaves others alone', workspace({ files: [ configFile([ '@s/base', '@s/runtime', '@s/bundled', '@s/unbundled', '@s/test-only' ]), raisedBase, runtimeDependent('2.0.0'), devDependent({ name: 'bundled', version: '0.3.9' }), source({ path: 'package/module/bundled/src/index.ts', text: "import { base } from '@s/base/ts';\n" }), devDependent({ name: 'unbundled', version: '1.0.0' }), devDependent({ name: 'test-only', version: '1.0.0' }), source({ path: 'package/module/test-only/src/index.unit.test.ts', text: "import '@s/base';\n" }) ] }), function check(output) { deepStrictEqual( findingPaths(output), [ 'package/module/bundled/package.json', 'package/module/runtime/package.json' ] ); deepStrictEqual( findingCodes(output), [ 'dependent-version-stale', 'dependent-version-stale' ] ); const { policy } = workspaceResult(output); ok((policy.kind === 'findings') && hexText(policy.findings[1] ?.patch ?.replacement ?? '') .includes(' "version": "2.0.1"')); }, ], [ 'findDependentBumps stays silent for git add of a hand bump', workspace({ files: pair, forwardsCommit: false }), function check(output) { deepStrictEqual( findingPaths(output), [] ); } ], [ 'findDependentBumps reports the same hand bump on commit', workspace({ files: pair }), function check(output) { deepStrictEqual( findingPaths(output) .length, 1 ); } ], [ 'findDependentBumps proposes dependent bumps during direct fix', workspace({ files: pair, trigger: 'direct-fix', forwardsCommit: false }), function check(output) { deepStrictEqual( findingPaths(output), ['package/module/runtime/package.json'] ); } ], [ 'findDependentBumps returns nothing when no manifest version changed', workspace({ files: [ configFile([ '@s/base', '@s/runtime' ]), { path: 'package/module/base/package.json', text: manifestText({ name: '@s/base', version: '1.0.0', description: 'x' }), headText: manifestText({ name: '@s/base', version: '1.0.0' }) }, runtimeDependent('2.0.0') ] }), function check(output) { deepStrictEqual( findingPaths(output), [] ); }, ], [ 'findDependentBumps returns nothing for a configuration alone', workspace({ files: [configFile([])] }), function check(output) { deepStrictEqual( findingPaths(output), [] ); } ], [ 'findDependentBumps settles once dependents are bumped', workspace({ files: [ configFile([ '@s/base', '@s/runtime' ]), raisedBase, { path: 'package/module/runtime/package.json', text: manifestText({ name: '@s/runtime', version: '2.0.1', dependencies: { '@s/base': 'workspace:*' } }), headText: manifestText({ name: '@s/runtime', version: '2.0.0', dependencies: { '@s/base': 'workspace:*' } }) } ] }), function check(output) { deepStrictEqual( findingPaths(output), [] ); }, ], [ 'findDependentBumps reports a dependent whose prerelease version cannot be bumped automatically', workspace({ files: [ configFile([ '@s/base', '@s/runtime' ]), raisedBase, runtimeDependent('2.0.0-rc.1') ] }), function check(output) { deepStrictEqual( findingCodes(output), ['dependent-version-unsupported'] ); const { policy } = workspaceResult(output); ok((policy.kind === 'findings') && (policy.findings[0] ?.patch === null)); }, ], [ 'findDependentBumps ignores a bump when the pnpr config is absent', workspace({ files: [ raisedBase, runtimeDependent('2.0.0') ] }), function check(output) { deepStrictEqual( findingPaths(output), [] ); } ], [ 'bumpWorktreeDependents writes bumps for runtime and bundled dependents of a worktree bump', workspace({ files: [ ...worktreeBaseline, worktreeBase('1.1.0') ], trigger: 'direct-fix', forwardsCommit: false }), function check(output) { deepStrictEqual( bumpSummary(output), [ '@s/app@2.0.1', '@s/tool@0.1.1' ] ); const { plan } = workspaceResult(output); ok((plan.kind === 'planned') && (plan.bumpedNames .join(",") === '@s/base') && hexText(plan.bumps[1] ?.replacement ?? '') .includes('"version": "0.1.1"')); }, ], [ 'bumpWorktreeDependents changes nothing when no manifest differs from the base', workspace({ files: [ ...worktreeBaseline, worktreeBase('1.0.0') ], trigger: 'direct-fix', forwardsCommit: false }), function check(output) { deepStrictEqual( bumpSummary(output), [] ); } ],];
/** The workspace scenarios with their assertions.
@returns {UnitScenario[]} cases */export function workspaceScenarios() { return table.map(function toScenario([name, input, check]) { return { name, kind: 'workspace', input, check, }; });}