-
-
Notifications
You must be signed in to change notification settings - Fork 177
Test file val keyword #181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -230,6 +230,19 @@ function updateXCConfigFile(content: string, params: Record<string, unknown>): s | |
| return result; | ||
| } | ||
|
|
||
| /** | ||
| * Fix Swift syntax issues (e.g., Kotlin 'val' keyword should be 'let') | ||
| */ | ||
| function fixSwiftSyntax(content: string): string { | ||
| let result = content; | ||
|
|
||
| // Replace Kotlin 'val' keyword with Swift 'let' | ||
| // Match 'val' followed by whitespace and an identifier (variable name) | ||
| result = result.replace(/\bval\s+(\w+)\s*=/g, 'let $1 ='); | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| /** | ||
| * Replace placeholders in a string (for non-XCConfig files) | ||
| */ | ||
|
|
@@ -301,6 +314,7 @@ async function processFile( | |
| const isTextFile = textExtensions.some((textExt) => ext.endsWith(textExt)); | ||
| const isXCConfig = sourcePath.endsWith('.xcconfig'); | ||
| const isPackageSwift = sourcePath.endsWith('Package.swift'); | ||
| const isSwiftFile = sourcePath.endsWith('.swift'); | ||
|
|
||
| if (isTextFile && customizeNames) { | ||
| // Read the file content | ||
|
|
@@ -322,6 +336,11 @@ async function processFile( | |
| processedContent = replacePlaceholders(content, projectName, bundleIdentifier); | ||
| } | ||
|
|
||
| // Apply Swift syntax fixes if this is a Swift file | ||
| if (isSwiftFile) { | ||
| processedContent = fixSwiftSyntax(processedContent); | ||
| } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Swift syntax fix skipped when
|
||
|
|
||
| await fileSystemExecutor.mkdir(dirname(finalDestPath), { recursive: true }); | ||
| await fileSystemExecutor.writeFile(finalDestPath, processedContent, 'utf-8'); | ||
| } else { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicated
fixSwiftSyntaxfunction across scaffolding filesLow Severity
The
fixSwiftSyntaxfunction is duplicated identically in bothscaffold_ios_project.tsandscaffold_macos_project.ts. Both implementations contain the same regex replacement logic (/\bval\s+(\w+)\s*=/g→let $1 =). This duplication increases maintenance burden and risks inconsistent bug fixes if the logic needs to be updated in the future—a fix applied to one file might be forgotten in the other.Additional Locations (1)
src/mcp/tools/project-scaffolding/scaffold_macos_project.ts#L150-L159