Read codemod target versions from workspace manifests at build time (#2419)

This commit is contained in:
Felix Weinberger 2026-07-02 16:01:32 +01:00 • committed by GitHub
commit 79dc162efc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 27 additions and 49 deletions

View file

@ -6,10 +6,10 @@ import { tmpdir } from 'node:os';
import path from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import { V2_PACKAGE_VERSIONS } from '../generated/versions';
import { getMigration } from '../migrations/index';
import { run } from '../runner';
import type { Diagnostic, Migration } from '../types';
import { V2_PACKAGE_VERSIONS } from '../versions';
// ---------------------------------------------------------------------------
// Types

View file

@ -1,9 +0,0 @@
// AUTO-GENERATED — do not edit. Run `pnpm run generate:versions` to regenerate.
export const V2_PACKAGE_VERSIONS: Record<string, string> = {
'@modelcontextprotocol/client': '^2.0.0-beta.1',
'@modelcontextprotocol/server': '^2.0.0-beta.1',
'@modelcontextprotocol/node': '^2.0.0-beta.1',
'@modelcontextprotocol/express': '^2.0.0-beta.1',
'@modelcontextprotocol/server-legacy': '^2.0.0-beta.1',
'@modelcontextprotocol/core': '^2.0.0-beta.1'
};

View file

@ -3,8 +3,8 @@ import path from 'node:path';
import fg from 'fast-glob';
import { V2_PACKAGE_VERSIONS } from '../generated/versions';
import type { PackageJsonChange } from '../types';
import { V2_PACKAGE_VERSIONS } from '../versions';
import { findPackageJson } from './projectAnalyzer';
const V1_PACKAGE = '@modelcontextprotocol/sdk';

View file

@ -0,0 +1,20 @@
import clientPkg from '../../client/package.json';
import corePkg from '../../core/package.json';
import expressPkg from '../../middleware/express/package.json';
import nodePkg from '../../middleware/node/package.json';
import serverPkg from '../../server/package.json';
import serverLegacyPkg from '../../server-legacy/package.json';
/**
* Caret ranges for the v2 packages the codemod writes into migrated package.json
* files. Versions come straight from the workspace manifests — the bundler inlines
* them at build time — so a release bump can never leave this map stale.
*/
export const V2_PACKAGE_VERSIONS: Record<string, string> = {
'@modelcontextprotocol/client': `^${clientPkg.version}`,
'@modelcontextprotocol/server': `^${serverPkg.version}`,
'@modelcontextprotocol/node': `^${nodePkg.version}`,
'@modelcontextprotocol/express': `^${expressPkg.version}`,
'@modelcontextprotocol/server-legacy': `^${serverLegacyPkg.version}`,
'@modelcontextprotocol/core': `^${corePkg.version}`
};