From 6153302144ea26c3a4c95c453928e6dbeaf0cc15 Mon Sep 17 00:00:00 2001 From: James Ross Date: Wed, 3 Jun 2026 07:30:21 -0700 Subject: [PATCH 1/2] Fix: structure non-TS tail assertions --- test/unit/scripts/non-ts-tail-shape.test.ts | 53 ++++++++++----------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/test/unit/scripts/non-ts-tail-shape.test.ts b/test/unit/scripts/non-ts-tail-shape.test.ts index e67e22e3e..35734d090 100644 --- a/test/unit/scripts/non-ts-tail-shape.test.ts +++ b/test/unit/scripts/non-ts-tail-shape.test.ts @@ -1,13 +1,16 @@ import { execFileSync } from 'node:child_process'; -import { existsSync, readFileSync } from 'node:fs'; +import { existsSync } from 'node:fs'; import { fileURLToPath } from 'node:url'; import { describe, expect, it } from 'vitest'; -const repoRoot = fileURLToPath(new URL('../../../', import.meta.url)); +import jsrJson from '../../../jsr.json' with { type: 'json' }; +import packageJson from '../../../package.json' with { type: 'json' }; +import tsconfig from '../../../tsconfig.json' with { type: 'json' }; +import srcConfig from '../../../tsconfig.src.json' with { type: 'json' }; +import testConfig from '../../../tsconfig.test.json' with { type: 'json' }; +import vitestConfig from '../../../vitest.config.ts'; -function readRepoFile(relativePath: string): string { - return readFileSync(`${repoRoot}${relativePath}`, 'utf8'); -} +const repoRoot = fileURLToPath(new URL('../../../', import.meta.url)); function trackedNonTypeScriptTail(): string[] { const output = execFileSync('git', ['ls-files', '-z', '--', '*.js', '*.d.ts'], { @@ -39,31 +42,25 @@ describe('non-TS tail shape', () => { }); it('keeps the sha1sync export honest without a standalone declaration file', () => { - const packageJson = readRepoFile('package.json'); - const jsrJson = readRepoFile('jsr.json'); - - expect(packageJson).toContain('"./sha1sync"'); - expect(packageJson).toContain('"types": "./dist/src/infrastructure/adapters/sha1sync.d.ts"'); - expect(packageJson).toContain('"import": "./dist/src/infrastructure/adapters/sha1sync.js"'); - expect(packageJson).not.toContain('"sha1sync.d.ts"'); - expect(jsrJson).toContain('"./sha1sync": "./src/infrastructure/adapters/sha1sync.ts"'); - expect(jsrJson).not.toContain('"sha1sync.d.ts"'); + expect(packageJson.exports['./sha1sync']).toEqual({ + types: './dist/src/infrastructure/adapters/sha1sync.d.ts', + import: './dist/src/infrastructure/adapters/sha1sync.js', + default: './dist/src/infrastructure/adapters/sha1sync.js', + }); + expect(jsrJson.exports['./sha1sync']).toBe('./src/infrastructure/adapters/sha1sync.ts'); + expect(trackedNonTypeScriptTail()).not.toContain('src/infrastructure/adapters/sha1sync.d.ts'); }); it('removes the stale .js glob assumptions from vitest and tsconfig', () => { - const vitestConfig = readRepoFile('vitest.config.ts'); - const tsconfig = readRepoFile('tsconfig.json'); - const srcConfig = readRepoFile('tsconfig.src.json'); - const testConfig = readRepoFile('tsconfig.test.json'); - - expect(vitestConfig).toContain("from './scripts/coverage-ratchet.ts'"); - expect(vitestConfig).not.toContain('.benchmark.js'); - expect(vitestConfig).not.toContain("src/**/*.js"); - expect(tsconfig).not.toContain('"src/**/*.js"'); - expect(tsconfig).not.toContain('"bin/**/*.js"'); - expect(tsconfig).not.toContain('"scripts/**/*.js"'); - expect(tsconfig).not.toContain('"test/**/*.js"'); - expect(srcConfig).not.toContain('"src/**/*.js"'); - expect(testConfig).not.toContain('"src/**/*.js"'); + expect(vitestConfig.test?.include).toEqual([ + '**/*.{test,spec}.?(c|m)[jt]s?(x)', + '**/benchmark/*.benchmark.ts', + ]); + expect(tsconfig.include).not.toContain('src/**/*.js'); + expect(tsconfig.include).not.toContain('bin/**/*.js'); + expect(tsconfig.include).not.toContain('scripts/**/*.js'); + expect(tsconfig.include).not.toContain('test/**/*.js'); + expect(srcConfig.include).not.toContain('src/**/*.js'); + expect(testConfig.include).not.toContain('src/**/*.js'); }); }); From 1b3ce66f8f15168d730df365567db2b1b54d91b6 Mon Sep 17 00:00:00 2001 From: James Ross Date: Wed, 3 Jun 2026 14:54:14 -0700 Subject: [PATCH 2/2] Fix: keep non-ts tail ratchet witness --- test/unit/scripts/non-ts-tail-shape.test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/unit/scripts/non-ts-tail-shape.test.ts b/test/unit/scripts/non-ts-tail-shape.test.ts index 35734d090..825709626 100644 --- a/test/unit/scripts/non-ts-tail-shape.test.ts +++ b/test/unit/scripts/non-ts-tail-shape.test.ts @@ -8,6 +8,7 @@ import packageJson from '../../../package.json' with { type: 'json' }; import tsconfig from '../../../tsconfig.json' with { type: 'json' }; import srcConfig from '../../../tsconfig.src.json' with { type: 'json' }; import testConfig from '../../../tsconfig.test.json' with { type: 'json' }; +import { shouldAutoUpdateCoverageRatchet } from '../../../scripts/coverage-ratchet.ts'; import vitestConfig from '../../../vitest.config.ts'; const repoRoot = fileURLToPath(new URL('../../../', import.meta.url)); @@ -51,7 +52,10 @@ describe('non-TS tail shape', () => { expect(trackedNonTypeScriptTail()).not.toContain('src/infrastructure/adapters/sha1sync.d.ts'); }); - it('removes the stale .js glob assumptions from vitest and tsconfig', () => { + it('keeps the coverage ratchet hook and removes stale .js glob assumptions from vitest and tsconfig', () => { + expect(vitestConfig.test?.coverage?.thresholds?.autoUpdate).toBe(shouldAutoUpdateCoverageRatchet()); + expect(shouldAutoUpdateCoverageRatchet({ GIT_WARP_UPDATE_COVERAGE_RATCHET: '1' })).toBe(true); + expect(shouldAutoUpdateCoverageRatchet({ GIT_WARP_UPDATE_COVERAGE_RATCHET: '0' })).toBe(false); expect(vitestConfig.test?.include).toEqual([ '**/*.{test,spec}.?(c|m)[jt]s?(x)', '**/benchmark/*.benchmark.ts',