Skip to content

Commit 6bbde1e

Browse files
committed
Update template logic
1 parent 97e023e commit 6bbde1e

3 files changed

Lines changed: 16 additions & 11 deletions

File tree

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ When developing or testing changes to the templates:
123123
2. Set the appropriate environment variable to use your local template:
124124
```bash
125125
# For iOS template development
126-
export XCODEBUILD_MCP_IOS_TEMPLATE_PATH=/path/to/XcodeBuildMCP-iOS-Template
126+
export XCODEBUILDMCP_IOS_TEMPLATE_PATH=/path/to/XcodeBuildMCP-iOS-Template
127127

128128
# For macOS template development
129-
export XCODEBUILD_MCP_MACOS_TEMPLATE_PATH=/path/to/XcodeBuildMCP-macOS-Template
129+
export XCODEBUILDMCP_MACOS_TEMPLATE_PATH=/path/to/XcodeBuildMCP-macOS-Template
130130
```
131131

132132
3. When using MCP clients, add these environment variables to your MCP configuration:
@@ -137,8 +137,8 @@ When developing or testing changes to the templates:
137137
"command": "node",
138138
"args": ["/path_to/XcodeBuildMCP/build/index.js"],
139139
"env": {
140-
"XCODEBUILD_MCP_IOS_TEMPLATE_PATH": "/path/to/XcodeBuildMCP-iOS-Template",
141-
"XCODEBUILD_MCP_MACOS_TEMPLATE_PATH": "/path/to/XcodeBuildMCP-macOS-Template"
140+
"XCODEBUILDMCP_IOS_TEMPLATE_PATH": "/path/to/XcodeBuildMCP-iOS-Template",
141+
"XCODEBUILDMCP_MACOS_TEMPLATE_PATH": "/path/to/XcodeBuildMCP-macOS-Template"
142142
}
143143
}
144144
}

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
{
22
"name": "xcodebuildmcp",
33
"version": "1.10.1",
4-
"templateVersion": "v1.0.3",
4+
"iOSTemplateVersion": "v1.0.6",
5+
"macOSTemplateVersion": "v1.0.4",
56
"main": "build/index.js",
67
"type": "module",
78
"bin": {
89
"xcodebuildmcp": "build/index.js",
910
"xcodebuildmcp-diagnostic": "build/diagnostic-cli.js"
1011
},
1112
"scripts": {
12-
"build": "node -e \"const fs = require('fs'); const pkg = require('./package.json'); fs.writeFileSync('src/version.ts', \\`export const version = '\\${pkg.version}';\\nexport const templateVersion = '\\${pkg.templateVersion}';\\n\\`)\" && tsup",
13+
"build": "node -e \"const fs = require('fs'); const pkg = require('./package.json'); fs.writeFileSync('src/version.ts', \\`export const version = '\\${pkg.version}';\\nexport const iOSTemplateVersion = '\\${pkg.iOSTemplateVersion}';\\nexport const macOSTemplateVersion = '\\${pkg.macOSTemplateVersion}';\\n\\`)\" && tsup",
1314
"build:watch": "npm run build && tsup --watch",
1415
"bundle:axe": "scripts/bundle-axe.sh",
1516
"lint": "eslint 'src/**/*.{js,ts}'",

src/utils/template-manager.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { tmpdir } from 'os';
55
import { randomUUID } from 'crypto';
66
import { spawn } from 'child_process';
77
import { log } from './logger.js';
8-
import { templateVersion } from '../version.js';
8+
import { iOSTemplateVersion, macOSTemplateVersion } from '../version.js';
99

1010
/**
1111
* Template manager for downloading and managing project templates
@@ -22,9 +22,7 @@ export class TemplateManager {
2222
static async getTemplatePath(platform: 'iOS' | 'macOS'): Promise<string> {
2323
// Check for local override
2424
const envVar =
25-
platform === 'iOS'
26-
? 'XCODEBUILD_MCP_IOS_TEMPLATE_PATH'
27-
: 'XCODEBUILD_MCP_MACOS_TEMPLATE_PATH';
25+
platform === 'iOS' ? 'XCODEBUILDMCP_IOS_TEMPLATE_PATH' : 'XCODEBUILDMCP_MACOS_TEMPLATE_PATH';
2826

2927
const localPath = process.env[envVar];
3028
if (localPath && existsSync(localPath)) {
@@ -46,7 +44,13 @@ export class TemplateManager {
4644
*/
4745
private static async downloadTemplate(platform: 'iOS' | 'macOS'): Promise<string> {
4846
const repo = platform === 'iOS' ? this.IOS_TEMPLATE_REPO : this.MACOS_TEMPLATE_REPO;
49-
const version = process.env.XCODEBUILD_MCP_TEMPLATE_VERSION || templateVersion;
47+
const defaultVersion = platform === 'iOS' ? iOSTemplateVersion : macOSTemplateVersion;
48+
const envVarName =
49+
platform === 'iOS'
50+
? 'XCODEBUILD_MCP_IOS_TEMPLATE_VERSION'
51+
: 'XCODEBUILD_MCP_MACOS_TEMPLATE_VERSION';
52+
const version =
53+
process.env[envVarName] || process.env.XCODEBUILD_MCP_TEMPLATE_VERSION || defaultVersion;
5054

5155
// Create temp directory for download
5256
const tempDir = join(tmpdir(), `xcodebuild-mcp-template-${randomUUID()}`);

0 commit comments

Comments
 (0)