Skip to content

Commit 874db59

Browse files
authored
Ensure manifest.json version always matches the package.json (#29)
* update * 0.4.2 * update * update
1 parent fd6a14e commit 874db59

File tree

9 files changed

+65
-24
lines changed

9 files changed

+65
-24
lines changed

.husky/pre-commit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
#!/usr/bin/env sh
2+
npm run sync-manifest
3+
git add manifest.json
24
npx lint-staged

.husky/setup-hooks.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
/*global console*/
2-
import { writeFileSync, mkdirSync, chmodSync, constants } from 'fs';
3-
import { execSync } from 'child_process';
4-
import { platform } from 'os';
1+
import { writeFileSync, mkdirSync, chmodSync, constants } from 'node:fs';
2+
import { execSync } from 'node:child_process';
3+
import { platform } from 'node:os';
54

65
mkdirSync('.husky', { recursive: true });
76

@@ -10,6 +9,8 @@ execSync('git config core.hooksPath .husky');
109
writeFileSync(
1110
'.husky/pre-commit',
1211
`#!/usr/bin/env sh
12+
npm run sync-manifest
13+
git add manifest.json
1314
npx lint-staged`
1415
);
1516

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This file provides Claude and developers with essential context, commands, and s
1414
- `npm run format:fix` — Auto-format code
1515
- `npx plop create-tool` — Generate a new tool scaffold
1616
- `npx @modelcontextprotocol/inspector node dist/esm/index.js` — Inspect the MCP server
17-
- `npx @anthropic-ai/dxt pack`Create a DXT package for distribution
17+
- `npm run sync-manifest`Sync version from package.json to manifest.json
1818
- `docker build -t mapbox-mcp-devkit .` — Build Docker image
1919
- `docker run mapbox/mcp-devkit-server ...` — Run server in Docker
2020

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"dxt_version": "0.1",
33
"name": "@mapbox/mcp-devkit-server",
44
"display_name": "Mapbox MCP DevKit Server",
5-
"version": "0.4.0",
5+
"version": "0.4.2",
66
"description": "Mapbox MCP devkit server",
77
"author": {
88
"name": "Mapbox, Inc."

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mapbox/mcp-devkit-server",
3-
"version": "0.4.1",
3+
"version": "0.4.2",
44
"description": "Mapbox MCP devkit server",
55
"main": "./dist/commonjs/index.js",
66
"module": "./dist/esm/index.js",
@@ -16,9 +16,9 @@
1616
"format:fix": "prettier --write \"./src/**/*.{ts,tsx,js,json,md}\" \"./test/**/*.{ts,tsx,js,json,md}\"",
1717
"prepare": "husky && node .husky/setup-hooks.js",
1818
"test": "vitest",
19-
"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",
19+
"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",
2020
"generate-version": "node scripts/build-helpers.cjs generate-version",
21-
"sync-manifest-version": "node scripts/build-helpers.cjs sync-manifest-version",
21+
"sync-manifest": "node scripts/sync-manifest-version.cjs",
2222
"dev": "tsc -p tsconfig.json --watch",
2323
"dev:inspect": "npm run build && npx @modelcontextprotocol/inspector -e MAPBOX_ACCESS_TOKEN=\"$MAPBOX_ACCESS_PRIVATE_TOKEN\" node dist/esm/index.js"
2424
},

scripts/build-helpers.cjs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,6 @@ function generateVersion() {
3333
console.log('Generated version.json:', versionInfo);
3434
}
3535

36-
// Sync version from package.json to manifest.json
37-
function syncManifestVersion() {
38-
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
39-
const manifestJson = JSON.parse(fs.readFileSync('manifest.json', 'utf8'));
40-
41-
manifestJson.version = packageJson.version;
42-
43-
fs.writeFileSync('manifest.json', JSON.stringify(manifestJson, null, 2) + '\n');
44-
console.log(`Synced version ${packageJson.version} from package.json to manifest.json`);
45-
}
4636

4737
// Copy JSON files to dist
4838
function copyJsonFiles() {
@@ -77,9 +67,6 @@ switch (command) {
7767
case 'generate-version':
7868
generateVersion();
7969
break;
80-
case 'sync-manifest-version':
81-
syncManifestVersion();
82-
break;
8370
case 'copy-json':
8471
copyJsonFiles();
8572
break;

scripts/sync-manifest-version.cjs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Sync manifest.json version with package.json
2+
const fs = require('node:fs');
3+
const path = require('node:path');
4+
5+
function syncManifestVersion() {
6+
const packageJsonPath = path.join(process.cwd(), 'package.json');
7+
const manifestJsonPath = path.join(process.cwd(), 'manifest.json');
8+
9+
// Read package.json
10+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
11+
const packageVersion = packageJson.version;
12+
13+
// Read manifest.json
14+
const manifestJson = JSON.parse(fs.readFileSync(manifestJsonPath, 'utf-8'));
15+
const manifestVersion = manifestJson.version;
16+
17+
// Check if versions are already in sync
18+
if (manifestVersion === packageVersion) {
19+
console.log(`✓ Versions already in sync: ${packageVersion}`);
20+
return;
21+
}
22+
23+
// Update manifest.json version
24+
manifestJson.version = packageVersion;
25+
fs.writeFileSync(
26+
manifestJsonPath,
27+
JSON.stringify(manifestJson, null, 2) + '\n',
28+
'utf-8'
29+
);
30+
31+
console.log(
32+
`✓ Updated manifest.json version: ${manifestVersion}${packageVersion}`
33+
);
34+
}
35+
36+
syncManifestVersion();

test/version-consistency.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { describe, it, expect } from 'vitest';
2+
import { readFileSync } from 'node:fs';
3+
import { join } from 'node:path';
4+
5+
describe('Version Consistency', () => {
6+
it('should have matching versions in package.json and manifest.json', () => {
7+
const packageJsonPath = join(process.cwd(), 'package.json');
8+
const manifestJsonPath = join(process.cwd(), 'manifest.json');
9+
10+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
11+
const manifestJson = JSON.parse(readFileSync(manifestJsonPath, 'utf-8'));
12+
13+
expect(manifestJson.version).toBe(packageJson.version);
14+
});
15+
});

0 commit comments

Comments
 (0)