Skip to content

Commit a437436

Browse files
committed
Update scaffold tool to install in workspace directly
1 parent 210e429 commit a437436

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/tools/scaffold.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -399,15 +399,23 @@ async function scaffoldProject(params: ScaffoldProjectParams): Promise<string> {
399399
);
400400
}
401401

402-
// Create output directory
403-
const projectPath = join(outputPath, customizeNames ? projectName : 'MyProject');
402+
// Use outputPath directly as the destination
403+
const projectPath = outputPath;
404404

405-
if (existsSync(projectPath)) {
406-
throw new ValidationError(`Project directory already exists at ${projectPath}`);
405+
// Check if the output directory already has Xcode project files
406+
const xcworkspaceExists = existsSync(
407+
join(projectPath, `${customizeNames ? projectName : 'MyProject'}.xcworkspace`),
408+
);
409+
const xcodeprojExists = existsSync(
410+
join(projectPath, `${customizeNames ? projectName : 'MyProject'}.xcodeproj`),
411+
);
412+
413+
if (xcworkspaceExists || xcodeprojExists) {
414+
throw new ValidationError(`Xcode project files already exist in ${projectPath}`);
407415
}
408416

409417
try {
410-
// Process the template
418+
// Process the template directly into the output path
411419
await processDirectory(templatePath, projectPath, params);
412420

413421
return projectPath;
@@ -433,9 +441,9 @@ export function registerScaffoldTools(server: McpServer): void {
433441
success: true,
434442
projectPath,
435443
platform: 'iOS',
436-
message: `Successfully scaffolded iOS project "${params.projectName}" at ${projectPath}`,
444+
message: `Successfully scaffolded iOS project "${params.projectName}" in ${projectPath}`,
437445
nextSteps: [
438-
`Open the project: open ${projectPath}/${params.customizeNames ? params.projectName : 'MyProject'}.xcworkspace`,
446+
`Important: Before working on the project make sure to read the README.md file in the workspace root directory.`,
439447
`Build for simulator: build_ios_sim_name_ws --workspace-path "${projectPath}/${params.customizeNames ? params.projectName : 'MyProject'}.xcworkspace" --scheme "${params.customizeNames ? params.projectName : 'MyProject'}" --simulator-name "iPhone 16"`,
440448
`Build and run on simulator: build_run_ios_sim_name_ws --workspace-path "${projectPath}/${params.customizeNames ? params.projectName : 'MyProject'}.xcworkspace" --scheme "${params.customizeNames ? params.projectName : 'MyProject'}" --simulator-name "iPhone 16"`,
441449
],
@@ -489,9 +497,9 @@ export function registerScaffoldTools(server: McpServer): void {
489497
success: true,
490498
projectPath,
491499
platform: 'macOS',
492-
message: `Successfully scaffolded macOS project "${params.projectName}" at ${projectPath}`,
500+
message: `Successfully scaffolded macOS project "${params.projectName}" in ${projectPath}`,
493501
nextSteps: [
494-
`Open the project: open ${projectPath}/${params.customizeNames ? params.projectName : 'MyProject'}.xcworkspace`,
502+
`Important: Before working on the project make sure to read the README.md file in the workspace root directory.`,
495503
`Build for macOS: build_mac_ws --workspace-path "${projectPath}/${params.customizeNames ? params.projectName : 'MyProject'}.xcworkspace" --scheme "${params.customizeNames ? params.projectName : 'MyProject'}"`,
496504
`Run and run on macOS: build_run_mac_ws --workspace-path "${projectPath}/${params.customizeNames ? params.projectName : 'MyProject'}.xcworkspace" --scheme "${params.customizeNames ? params.projectName : 'MyProject'}"`,
497505
],

0 commit comments

Comments
 (0)