Read codemod target versions from workspace manifests at build time (#2419)
This commit is contained in:
parent
ddf6cc1d73
commit
79dc162efc
4 changed files with 27 additions and 49 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
};
|
||||
|
|
@ -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';
|
||||
|
|
|
|||
20
packages/codemod/src/versions.ts
Normal file
20
packages/codemod/src/versions.ts
Normal 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}`
|
||||
};
|
||||
Loading…
Reference in a new issue