Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion src/mcp/tools/device/__tests__/list_devices.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ describe('list_devices plugin (device-shared)', () => {
},
],
nextStepParams: {
build_device: { scheme: 'SCHEME', deviceId: 'DEVICE_UDID' },
build_device: { scheme: 'SCHEME' },
build_run_device: { scheme: 'SCHEME', deviceId: 'DEVICE_UDID' },
test_device: { scheme: 'SCHEME', deviceId: 'DEVICE_UDID' },
get_device_app_path: { scheme: 'SCHEME' },
Expand Down
2 changes: 1 addition & 1 deletion src/mcp/tools/device/list_devices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ export async function list_devicesLogic(
'Before running build/run/test/UI automation tools, set the desired device identifier in session defaults.\n';

nextStepParams = {
build_device: { scheme: 'SCHEME', deviceId: 'DEVICE_UDID' },
build_device: { scheme: 'SCHEME' },
build_run_device: { scheme: 'SCHEME', deviceId: 'DEVICE_UDID' },
test_device: { scheme: 'SCHEME', deviceId: 'DEVICE_UDID' },
get_device_app_path: { scheme: 'SCHEME' },
Expand Down
36 changes: 36 additions & 0 deletions src/utils/__tests__/build-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,5 +387,41 @@ describe('build-utils Sentry Classification', () => {
expect(capturedCommand).toContain(expectedDerivedDataPath);
expect(capturedOptions).toEqual({ cwd: path.dirname(expectedProjectPath) });
});

it('should expand tilde in derivedDataPath to home directory', async () => {
let capturedCommand: string[] | undefined;
const mockExecutor = createMockExecutor({
success: true,
output: 'BUILD SUCCEEDED',
exitCode: 0,
onExecute: (command) => {
capturedCommand = command;
},
});

const { homedir } = await import('os');
const expectedDerivedDataPath = path.join(homedir(), '.derivedData/test');

await executeXcodeBuildCommand(
{
scheme: 'TestScheme',
configuration: 'Debug',
projectPath: '/path/to/project.xcodeproj',
derivedDataPath: '~/.derivedData/test',
},
{
platform: XcodePlatform.iOSSimulator,
simulatorName: 'iPhone 17 Pro',
useLatestOS: true,
logPrefix: 'iOS Simulator Build',
},
false,
'build',
mockExecutor,
);

expect(capturedCommand).toBeDefined();
expect(capturedCommand).toContain(expectedDerivedDataPath);
});
});
});
20 changes: 20 additions & 0 deletions src/utils/__tests__/project-config.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { describe, expect, it } from 'vitest';
import path from 'node:path';
import { homedir } from 'node:os';
import { parse as parseYaml } from 'yaml';
import { createMockFileSystemExecutor } from '../../test-utils/mock-executors.ts';
import {
Expand Down Expand Up @@ -187,6 +188,25 @@ describe('project-config', () => {
);
});

it('should expand tilde in derivedDataPath and other path fields', async () => {
const yaml = [
'schemaVersion: 1',
'sessionDefaults:',
' workspacePath: "./App.xcworkspace"',
' derivedDataPath: "~/.derivedData/myproject"',
'',
].join('\n');

const { fs } = createFsFixture({ exists: true, readFile: yaml });
const result = await loadProjectConfig({ fs, cwd });

if (!result.found) throw new Error('expected config to be found');

const defaults = result.config.sessionDefaults ?? {};
expect(defaults.derivedDataPath).toBe(path.join(homedir(), '.derivedData', 'myproject'));
expect(defaults.workspacePath).toBe(path.join(cwd, 'App.xcworkspace'));
});

it('should return an error result when schemaVersion is unsupported', async () => {
const yaml = ['schemaVersion: 2', 'sessionDefaults:', ' scheme: "App"', ''].join('\n');
const { fs } = createFsFixture({ exists: true, readFile: yaml });
Expand Down
7 changes: 7 additions & 0 deletions src/utils/build-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,15 @@ import {
} from './xcodemake.ts';
import { sessionStore } from './session-store.ts';
import path from 'path';
import { homedir } from 'os';

function resolvePathFromCwd(pathValue: string): string {
if (pathValue === '~') {
return homedir();
}
if (pathValue.startsWith('~/')) {
return path.join(homedir(), pathValue.slice(2));
}
Comment thread
cursor[bot] marked this conversation as resolved.
Outdated
Comment thread
cursor[bot] marked this conversation as resolved.
Outdated
if (path.isAbsolute(pathValue)) {
return pathValue;
}
Expand Down
9 changes: 9 additions & 0 deletions src/utils/project-config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from 'node:path';
import { homedir } from 'node:os';
import { fileURLToPath } from 'node:url';
import { parse as parseYaml, stringify as stringifyYaml } from 'yaml';
import type { FileSystemExecutor } from './FileSystemExecutor.ts';
Expand Down Expand Up @@ -125,6 +126,14 @@ function normalizePathValue(value: string, cwd: string): string {
return fileUrlPath;
}

if (value === '~') {
return homedir();
}

if (value.startsWith('~/')) {
return path.join(homedir(), value.slice(2));
}

if (path.isAbsolute(value)) {
return value;
}
Expand Down