|
| 1 | +/** |
| 2 | + * Resolved-version assertions for the pinned Solid 2 prerelease toolchain. |
| 3 | + * |
| 4 | + * The whole matrix sits on prereleases, and a `bun install` that silently drifts onto a newer |
| 5 | + * beta — or, worse, onto `@solidjs/web`'s `latest` tag, which is the incompatible |
| 6 | + * `2.0.0-experimental.0` line — is the single most likely cause of an inexplicable failure in |
| 7 | + * this repo. It should report itself as a version drift, not as 200 broken assertions. |
| 8 | + * |
| 9 | + * Runs before every other gate in CI. |
| 10 | + */ |
| 11 | +import { existsSync } from 'node:fs'; |
| 12 | +import { dirname, resolve } from 'node:path'; |
| 13 | +import { fileURLToPath } from 'node:url'; |
| 14 | + |
| 15 | +const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), '../../..'); |
| 16 | + |
| 17 | +const failures: string[] = []; |
| 18 | + |
| 19 | +const read = async (pkg: string): Promise<string | undefined> => { |
| 20 | + const manifest = resolve(repoRoot, 'node_modules', pkg, 'package.json'); |
| 21 | + if (!existsSync(manifest)) return undefined; |
| 22 | + const json = await Bun.file(manifest).json(); |
| 23 | + return json.version as string; |
| 24 | +}; |
| 25 | + |
| 26 | +// Exact pins. `solid-js` and `@solidjs/web` must move together, and only deliberately. |
| 27 | +const exact: Record<string, string> = { |
| 28 | + 'solid-js': '2.0.0-beta.32', |
| 29 | + '@solidjs/web': '2.0.0-beta.32', |
| 30 | + 'vite-plugin-solid': '3.0.0-next.23', |
| 31 | + '@solidjs/testing-library': '1.0.0-beta.2', |
| 32 | +}; |
| 33 | + |
| 34 | +for (const [pkg, want] of Object.entries(exact)) { |
| 35 | + const got = await read(pkg); |
| 36 | + if (got === undefined) { |
| 37 | + failures.push(`${pkg} is not installed`); |
| 38 | + } else if (got !== want) { |
| 39 | + failures.push(`${pkg} resolved to ${got}, expected exactly ${want}`); |
| 40 | + } |
| 41 | +} |
| 42 | + |
| 43 | +// Line assertions. These catch the two drifts that produce confusing *compile* errors rather |
| 44 | +// than a resolution failure, and they stay correct if the exact pins above are bumped. |
| 45 | +const pluginVersion = await read('vite-plugin-solid'); |
| 46 | +if (pluginVersion && !pluginVersion.startsWith('3.')) { |
| 47 | + failures.push(`vite-plugin-solid must be on the 3.x line, got ${pluginVersion}`); |
| 48 | +} |
| 49 | + |
| 50 | +const webVersion = await read('@solidjs/web'); |
| 51 | +if (webVersion?.includes('-experimental.')) { |
| 52 | + failures.push( |
| 53 | + `@solidjs/web resolved to the experimental line (${webVersion}). That is npm's \`latest\` ` + |
| 54 | + `tag and vite-plugin-solid@3 explicitly excludes it (<2.0.0-experimental.0). Install from ` + |
| 55 | + `the \`next\` tag.` |
| 56 | + ); |
| 57 | +} |
| 58 | + |
| 59 | +// The DOM runtime is compiled against the core package; a split between them is silent and fatal. |
| 60 | +const solidVersion = await read('solid-js'); |
| 61 | +if (solidVersion && webVersion && solidVersion !== webVersion) { |
| 62 | + failures.push( |
| 63 | + `solid-js (${solidVersion}) and @solidjs/web (${webVersion}) must be the same version` |
| 64 | + ); |
| 65 | +} |
| 66 | + |
| 67 | +if (failures.length > 0) { |
| 68 | + console.error('check:versions FAILED — the Solid 2 toolchain drifted:'); |
| 69 | + for (const f of failures) console.error(` - ${f}`); |
| 70 | + process.exit(1); |
| 71 | +} |
| 72 | + |
| 73 | +console.log( |
| 74 | + `check:versions ok — solid-js ${solidVersion}, @solidjs/web ${webVersion}, ` + |
| 75 | + `vite-plugin-solid ${pluginVersion}` |
| 76 | +); |
0 commit comments