import { describe, expect, it } from 'vitest' import { readFileSync, readdirSync } from 'node:fs' import { join } from 'node:path' /** * The `./components` export ships RAW SFC source (tsup builds no .vue), so every * consumer site type-checks these files directly — against a dependency tree where * cms-core is TRANSITIVE and pnpm's strict layout never exposes it. A VALUE import * of cms-core in any raw-shipped .vue is therefore TS2307 in every fleet site's * type-check gate, invisible to this package's own checks (cms-core resolves fine * HERE — that is exactly why only a consumer-shaped gate or this test can see it). * * Measured on the 0.13.0 canary (2026-08-10): one value import in PreviewRibbon.vue * would have redded CI on kept (the payer), boogie-babies, bryans and mi-handyman. * `import type` is erased at compile time and stays allowed. */ describe('raw-source .vue exports must not value-import cms-core', () => { const dir = __dirname const vueFiles = readdirSync(dir).filter((f) => f.endsWith('.vue')) it('finds the raw-shipped component set (non-vacuity)', () => { expect(vueFiles.length).toBeGreaterThan(0) expect(vueFiles).toContain('PreviewRibbon.vue') }) for (const file of vueFiles) { it(`${file} has no cms-core value import`, () => { const src = readFileSync(join(dir, file), 'utf8') const valueImports = Array.from(src.matchAll(/^\s*import\s+(?!type\b)[^;'"]*['"]@duffcloudservices\/cms-core['"]/gm)) expect( valueImports.map((m) => m[0].trim()), `${file} value-imports cms-core — this ships as raw source and breaks every consumer site's type-check (see header comment)`, ).toEqual([]) }) } it('kill-test: the guard regex catches the 0.13.0 defect shape', () => { const bad = "import { platformFetch } from '@duffcloudservices/cms-core'" const good = "import type { PlatformFetchOptions } from '@duffcloudservices/cms-core'" const re = /^\s*import\s+(?!type\b)[^;'"]*['"]@duffcloudservices\/cms-core['"]/gm expect(Array.from(bad.matchAll(re)).length).toBe(1) expect(Array.from(good.matchAll(re)).length).toBe(0) }) })