Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/codemod-versions-from-manifests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@modelcontextprotocol/codemod': patch
---

Read the v2 package versions the codemod writes into migrated `package.json` files directly from the workspace manifests at build time, replacing the committed generated `versions.ts` (which went stale after every release and made source builds write outdated versions).
2 changes: 0 additions & 2 deletions packages/codemod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
],
"scripts": {
"typecheck": "tsgo -p tsconfig.json --noEmit",
"generate:versions": "tsx scripts/generateVersions.ts",
"prebuild": "pnpm run generate:versions",
"build": "tsdown",
"build:watch": "tsdown --watch",
"prepack": "pnpm run build",
Expand Down
36 changes: 0 additions & 36 deletions packages/codemod/scripts/generateVersions.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/codemod/src/bin/batchTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 0 additions & 9 deletions packages/codemod/src/generated/versions.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/codemod/src/utils/packageJsonUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
20 changes: 20 additions & 0 deletions packages/codemod/src/versions.ts
Original file line number Diff line number Diff line change
@@ -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