diff --git a/.husky/pre-commit b/.husky/pre-commit index 754fb2e..15ec148 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,2 +1,4 @@ #!/usr/bin/env sh +npm run sync-manifest +git add manifest.json npx lint-staged \ No newline at end of file diff --git a/.husky/setup-hooks.js b/.husky/setup-hooks.js index 9b46ed1..d7096e4 100644 --- a/.husky/setup-hooks.js +++ b/.husky/setup-hooks.js @@ -1,7 +1,6 @@ -/*global console*/ -import { writeFileSync, mkdirSync, chmodSync, constants } from 'fs'; -import { execSync } from 'child_process'; -import { platform } from 'os'; +import { writeFileSync, mkdirSync, chmodSync, constants } from 'node:fs'; +import { execSync } from 'node:child_process'; +import { platform } from 'node:os'; mkdirSync('.husky', { recursive: true }); @@ -10,6 +9,8 @@ execSync('git config core.hooksPath .husky'); writeFileSync( '.husky/pre-commit', `#!/usr/bin/env sh +npm run sync-manifest +git add manifest.json npx lint-staged` ); diff --git a/CLAUDE.md b/CLAUDE.md index 7fba22f..05cd93e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -14,7 +14,7 @@ This file provides Claude and developers with essential context, commands, and s - `npm run format:fix` — Auto-format code - `npx plop create-tool` — Generate a new tool scaffold - `npx @modelcontextprotocol/inspector node dist/esm/index.js` — Inspect the MCP server -- `npx @anthropic-ai/dxt pack` — Create a DXT package for distribution +- `npm run sync-manifest` — Sync version from package.json to manifest.json - `docker build -t mapbox-mcp-devkit .` — Build Docker image - `docker run mapbox/mcp-devkit-server ...` — Run server in Docker diff --git a/manifest.json b/manifest.json index 974a4f0..1484513 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "dxt_version": "0.1", "name": "@mapbox/mcp-devkit-server", "display_name": "Mapbox MCP DevKit Server", - "version": "0.4.0", + "version": "0.4.2", "description": "Mapbox MCP devkit server", "author": { "name": "Mapbox, Inc." diff --git a/package-lock.json b/package-lock.json index 6a5b346..c0901e3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@mapbox/mcp-devkit-server", - "version": "0.4.1", + "version": "0.4.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@mapbox/mcp-devkit-server", - "version": "0.4.1", + "version": "0.4.2", "license": "MIT", "dependencies": { "@modelcontextprotocol/sdk": "^1.17.5", diff --git a/package.json b/package.json index b6b5e0d..152d525 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mapbox/mcp-devkit-server", - "version": "0.4.1", + "version": "0.4.2", "description": "Mapbox MCP devkit server", "main": "./dist/commonjs/index.js", "module": "./dist/esm/index.js", @@ -16,9 +16,9 @@ "format:fix": "prettier --write \"./src/**/*.{ts,tsx,js,json,md}\" \"./test/**/*.{ts,tsx,js,json,md}\"", "prepare": "husky && node .husky/setup-hooks.js", "test": "vitest", - "build": "npm run prepare && npm run sync-manifest-version && tshy && npm run generate-version && node scripts/build-helpers.cjs copy-json && node scripts/add-shebang.cjs", + "build": "npm run prepare && npm run sync-manifest && tshy && npm run generate-version && node scripts/build-helpers.cjs copy-json && node scripts/add-shebang.cjs", "generate-version": "node scripts/build-helpers.cjs generate-version", - "sync-manifest-version": "node scripts/build-helpers.cjs sync-manifest-version", + "sync-manifest": "node scripts/sync-manifest-version.cjs", "dev": "tsc -p tsconfig.json --watch", "dev:inspect": "npm run build && npx @modelcontextprotocol/inspector -e MAPBOX_ACCESS_TOKEN=\"$MAPBOX_ACCESS_PRIVATE_TOKEN\" node dist/esm/index.js" }, diff --git a/scripts/build-helpers.cjs b/scripts/build-helpers.cjs index 4a9ed07..33b012f 100644 --- a/scripts/build-helpers.cjs +++ b/scripts/build-helpers.cjs @@ -33,16 +33,6 @@ function generateVersion() { console.log('Generated version.json:', versionInfo); } -// Sync version from package.json to manifest.json -function syncManifestVersion() { - const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8')); - const manifestJson = JSON.parse(fs.readFileSync('manifest.json', 'utf8')); - - manifestJson.version = packageJson.version; - - fs.writeFileSync('manifest.json', JSON.stringify(manifestJson, null, 2) + '\n'); - console.log(`Synced version ${packageJson.version} from package.json to manifest.json`); -} // Copy JSON files to dist function copyJsonFiles() { @@ -77,9 +67,6 @@ switch (command) { case 'generate-version': generateVersion(); break; - case 'sync-manifest-version': - syncManifestVersion(); - break; case 'copy-json': copyJsonFiles(); break; diff --git a/scripts/sync-manifest-version.cjs b/scripts/sync-manifest-version.cjs new file mode 100644 index 0000000..931cb9a --- /dev/null +++ b/scripts/sync-manifest-version.cjs @@ -0,0 +1,36 @@ +// Sync manifest.json version with package.json +const fs = require('node:fs'); +const path = require('node:path'); + +function syncManifestVersion() { + const packageJsonPath = path.join(process.cwd(), 'package.json'); + const manifestJsonPath = path.join(process.cwd(), 'manifest.json'); + + // Read package.json + const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')); + const packageVersion = packageJson.version; + + // Read manifest.json + const manifestJson = JSON.parse(fs.readFileSync(manifestJsonPath, 'utf-8')); + const manifestVersion = manifestJson.version; + + // Check if versions are already in sync + if (manifestVersion === packageVersion) { + console.log(`✓ Versions already in sync: ${packageVersion}`); + return; + } + + // Update manifest.json version + manifestJson.version = packageVersion; + fs.writeFileSync( + manifestJsonPath, + JSON.stringify(manifestJson, null, 2) + '\n', + 'utf-8' + ); + + console.log( + `✓ Updated manifest.json version: ${manifestVersion} → ${packageVersion}` + ); +} + +syncManifestVersion(); \ No newline at end of file diff --git a/test/version-consistency.test.ts b/test/version-consistency.test.ts new file mode 100644 index 0000000..8b95bd3 --- /dev/null +++ b/test/version-consistency.test.ts @@ -0,0 +1,15 @@ +import { describe, it, expect } from 'vitest'; +import { readFileSync } from 'node:fs'; +import { join } from 'node:path'; + +describe('Version Consistency', () => { + it('should have matching versions in package.json and manifest.json', () => { + const packageJsonPath = join(process.cwd(), 'package.json'); + const manifestJsonPath = join(process.cwd(), 'manifest.json'); + + const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')); + const manifestJson = JSON.parse(readFileSync(manifestJsonPath, 'utf-8')); + + expect(manifestJson.version).toBe(packageJson.version); + }); +});