diff --git a/package.json b/package.json index 492fcf5..de61df3 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "prepublishOnly": "nr build", "release": "bumpp", "start": "tsx src/index.ts", - "test": "vitest", + "test": "pnpm run build && vitest", "typecheck": "tsc", "prepare": "simple-git-hooks" }, @@ -45,6 +45,7 @@ "publint": "catalog:cli", "simple-git-hooks": "catalog:cli", "tsdown": "catalog:cli", + "tsdown-stale-guard": "catalog:testing", "tsnapi": "catalog:testing", "tsx": "catalog:cli", "typescript": "catalog:cli", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4626cd1..2c96393 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -44,6 +44,9 @@ catalogs: specifier: ^9.3.0 version: 9.3.0 testing: + tsdown-stale-guard: + specifier: ^0.1.1 + version: 0.1.1 tsnapi: specifier: ^0.3.2 version: 0.3.2 @@ -89,6 +92,9 @@ importers: tsdown: specifier: catalog:cli version: 0.21.10(publint@0.3.18)(synckit@0.11.12)(typescript@6.0.3) + tsdown-stale-guard: + specifier: catalog:testing + version: 0.1.1(tsdown@0.21.10(publint@0.3.18)(synckit@0.11.12)(typescript@6.0.3)) tsnapi: specifier: catalog:testing version: 0.3.2(vitest@4.1.5(@types/node@25.6.0)(vite@8.0.9(@types/node@25.6.0)(esbuild@0.27.1)(jiti@2.6.1)(tsx@4.21.0)(yaml@2.8.3))) @@ -493,6 +499,9 @@ packages: '@jridgewell/gen-mapping@0.3.13': resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==} + '@jridgewell/remapping@2.3.5': + resolution: {integrity: sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==} + '@jridgewell/resolve-uri@3.1.2': resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} engines: {node: '>=6.0.0'} @@ -1770,6 +1779,9 @@ packages: resolution: {integrity: sha512-9ie8ItPR6tjY5uYJh8K/Zrv/RMZ5VOlOWvtZdEHYSTFKZfIBPQa9tOAEeAWhd+AnIneLJ22w5fjOYtoutpWq5w==} engines: {node: '>=18'} + logs-sdk@0.0.6: + resolution: {integrity: sha512-G4M1C9aLLBOIWpmw/Lqk4zrap/T2IJsoUOuUDjRcVSLy6lHQqxr3wCqIT1FvvpYTUYpEwvu4utsMY42jTNvx8Q==} + longest-streak@3.1.0: resolution: {integrity: sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==} @@ -2029,10 +2041,6 @@ packages: resolution: {integrity: sha512-pMMHxBOZKFU6HgAZ4eyGnwXF/EvPGGqUr0MnZ5+99485wwW41kW91A4LOGxSHhgugZmSChL5AlElNdwlNgcnLQ==} engines: {node: ^10 || ^12 || >=14} - postcss@8.5.9: - resolution: {integrity: sha512-7a70Nsot+EMX9fFU3064K/kdHWZqGVY+BADLyXc8Dfv+mTLLVl6JzJpPaCZ2kQL9gIJvKXSLMHhqdRRjwQeFtw==} - engines: {node: ^10 || ^12 || >=14} - prelude-ls@1.2.1: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} @@ -2239,6 +2247,12 @@ packages: peerDependencies: typescript: '>=4.0.0' + tsdown-stale-guard@0.1.1: + resolution: {integrity: sha512-LeWJSseF0O4qZin0fCPfoO+8+LdbpMIP5LyVfpNy9WgvhWGPwxmn2W/9iWnY6IdXPZ1JfBp0pHTe2Bts8VVFWA==} + hasBin: true + peerDependencies: + tsdown: ^0.21.9 + tsdown@0.21.10: resolution: {integrity: sha512-3wk73yBhZe/wX7REqSdivNQ84TDs1mJ+IlnzrrEREP70xlJ/AEIzqaI04l/TzMKVIdkTdC3CPaADn2Lk/0SkdA==} engines: {node: '>=20.19.0'} @@ -2320,6 +2334,10 @@ packages: unist-util-visit@5.0.0: resolution: {integrity: sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==} + unplugin@3.0.0: + resolution: {integrity: sha512-0Mqk3AT2TZCXWKdcoaufeXNukv2mTrEZExeXlHIOZXdqYoHHr4n51pymnwV8x2BOVxwXbK2HLlI7usrqMpycdg==} + engines: {node: ^20.19.0 || >=22.12.0} + unrun@0.2.37: resolution: {integrity: sha512-AA7vDuYsgeSYVzJMm16UKA+aXFKhy7nFqW9z5l7q44K4ppFWZAMqYS58ePRZbugMLPH0fwwMzD5A8nP0avxwZQ==} engines: {node: '>=20.19.0'} @@ -2432,6 +2450,9 @@ packages: peerDependencies: eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 + webpack-virtual-modules@0.6.2: + resolution: {integrity: sha512-66/V2i5hQanC51vBQKPH4aI8NMAcBW59FVBs+rC7eGHupMyfn34q7rZIE+ETlJ+XTevqfUhVVBgSUNSW2flEUQ==} + which@2.0.2: resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} engines: {node: '>= 8'} @@ -2793,6 +2814,11 @@ snapshots: '@jridgewell/sourcemap-codec': 1.5.5 '@jridgewell/trace-mapping': 0.3.31 + '@jridgewell/remapping@2.3.5': + dependencies: + '@jridgewell/gen-mapping': 0.3.13 + '@jridgewell/trace-mapping': 0.3.31 + '@jridgewell/resolve-uri@3.1.2': {} '@jridgewell/sourcemap-codec@1.5.5': {} @@ -3241,7 +3267,7 @@ snapshots: '@vue/shared': 3.5.13 estree-walker: 2.0.2 magic-string: 0.30.21 - postcss: 8.5.9 + postcss: 8.5.10 source-map-js: 1.2.1 '@vue/compiler-ssr@3.5.13': @@ -3976,6 +4002,12 @@ snapshots: strip-ansi: 7.1.0 wrap-ansi: 9.0.0 + logs-sdk@0.0.6: + dependencies: + magic-string: 0.30.21 + oxc-parser: 0.126.0 + unplugin: 3.0.0 + longest-streak@3.1.0: {} magic-string@0.30.21: @@ -4449,12 +4481,6 @@ snapshots: picocolors: 1.1.1 source-map-js: 1.2.1 - postcss@8.5.9: - dependencies: - nanoid: 3.3.11 - picocolors: 1.1.1 - source-map-js: 1.2.1 - prelude-ls@1.2.1: {} publint@0.3.18: @@ -4663,6 +4689,13 @@ snapshots: picomatch: 4.0.4 typescript: 6.0.3 + tsdown-stale-guard@0.1.1(tsdown@0.21.10(publint@0.3.18)(synckit@0.11.12)(typescript@6.0.3)): + dependencies: + cac: 7.0.0 + logs-sdk: 0.0.6 + tsdown: 0.21.10(publint@0.3.18)(synckit@0.11.12)(typescript@6.0.3) + yaml: 2.8.3 + tsdown@0.21.10(publint@0.3.18)(synckit@0.11.12)(typescript@6.0.3): dependencies: ansis: 4.2.0 @@ -4758,6 +4791,12 @@ snapshots: unist-util-is: 6.0.0 unist-util-visit-parents: 6.0.1 + unplugin@3.0.0: + dependencies: + '@jridgewell/remapping': 2.3.5 + picomatch: 4.0.4 + webpack-virtual-modules: 0.6.2 + unrun@0.2.37(synckit@0.11.12): dependencies: rolldown: 1.0.0-rc.17 @@ -4830,6 +4869,8 @@ snapshots: transitivePeerDependencies: - supports-color + webpack-virtual-modules@0.6.2: {} + which@2.0.2: dependencies: isexe: 2.0.0 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index e8c4e34..b41b458 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -25,6 +25,7 @@ catalogs: inlined: '@antfu/utils': ^9.3.0 testing: + tsdown-stale-guard: ^0.1.1 tsnapi: ^0.3.2 vitest: ^4.1.5 types: diff --git a/__snapshots__/tsnapi/index.snapshot.d.ts b/test/__snapshots__/tsnapi/pkg-placeholder/index.snapshot.d.ts similarity index 100% rename from __snapshots__/tsnapi/index.snapshot.d.ts rename to test/__snapshots__/tsnapi/pkg-placeholder/index.snapshot.d.ts diff --git a/__snapshots__/tsnapi/index.snapshot.js b/test/__snapshots__/tsnapi/pkg-placeholder/index.snapshot.js similarity index 100% rename from __snapshots__/tsnapi/index.snapshot.js rename to test/__snapshots__/tsnapi/pkg-placeholder/index.snapshot.js diff --git a/test/api-snapshot.test.ts b/test/api-snapshot.test.ts new file mode 100644 index 0000000..af7d676 --- /dev/null +++ b/test/api-snapshot.test.ts @@ -0,0 +1,14 @@ +import { fileURLToPath } from 'node:url' +import { guardStaleBuild } from 'tsdown-stale-guard' +import { snapshotApiPerEntry } from 'tsnapi/vitest' +import { beforeAll, describe } from 'vitest' + +const root = fileURLToPath(new URL('..', import.meta.url)) + +describe('api snapshot', () => { + beforeAll(async () => { + await guardStaleBuild({ root }) + }) + + snapshotApiPerEntry(root) +}) diff --git a/test/index.test.ts b/test/index.test.ts deleted file mode 100644 index 401553c..0000000 --- a/test/index.test.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { describe, expect, it } from 'vitest' - -describe('should', () => { - it('exported', () => { - expect(1).toEqual(1) - }) -}) diff --git a/tsdown.config.ts b/tsdown.config.ts index 503178d..8c48a06 100644 --- a/tsdown.config.ts +++ b/tsdown.config.ts @@ -1,6 +1,5 @@ -import process from 'node:process' import { defineConfig } from 'tsdown' -import ApiSnapshot from 'tsnapi/rolldown' +import { StaleGuardRecorder } from 'tsdown-stale-guard' export default defineConfig({ entry: [ @@ -10,9 +9,6 @@ export default defineConfig({ exports: true, publint: true, plugins: [ - ApiSnapshot({ - // TODO: remove this when the library is stable to guard against breaking changes - update: !process.env.CI, - }), + StaleGuardRecorder(), ], })