Skip to content

Refactor: Make the tuikit project generator cross-platform and testable#73

Open
phranck wants to merge 1 commit into
mainfrom
issue/30-project-generator
Open

Refactor: Make the tuikit project generator cross-platform and testable#73
phranck wants to merge 1 commit into
mainfrom
issue/30-project-generator

Conversation

@phranck

@phranck phranck commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Closes #30.

Summary

  • Name handling: three-way split into display name, Swift identifier, and filesystem path. Non-identifier characters become underscores (my-appmy_app), and invalid names (.., embedded /, control characters, empty) are rejected before any file is written.
  • Non-interactive mode: --yes / -y and TUIKIT_NON_INTERACTIVE=1 suppress every prompt (Xcode-open, PATH-update, Swift-install-consent), enabling CI runs. The banner is skipped in this mode.
  • macOS-only Xcode paths: defaults write com.apple.dt.Xcode …, open Package.swift, and the "Open in Xcode?" prompt now run only when detect_os reports macos.
  • Swift 6.0 pin: swiftly installs 6.0.3 (matching the SDK gates) instead of latest; the swift.org tarball path refuses non-Ubuntu distributions instead of pretending to be Ubuntu.
  • Symmetric uninstall: resolve_install_path finds the script's own bin directory first and falls back to the same defaults install.sh uses. tuikit uninstall and the generated tuikit-uninstall both work.
  • Integration tests: scripts/tests/project-template/test-tuikit-generator.sh covers sanitization, path validation, OS/arch detection, basic project generation, invalid-name rejection, and hyphen sanitization end to end.
  • README rewritten to reflect actual behavior (removed the stale .swiftpm claim; documented non-interactive mode, name handling, the pinned Swift version, and macOS/Linux behavior).

Test plan

  • scripts/tests/project-template/test-tuikit-generator.sh — 12 assertions pass on macOS (helpers, path detection, generation with sanitization)
  • ./scripts/test-linux.sh green on macOS (Swift 6.0.3) and Linux (Docker 6.0.3-noble), warning-fatal
  • Generated projects use the sanitized Swift identifier in Package.swift and target names

- Sanitize project names into three separate values (display name,
  Swift identifier, filesystem path); reject '..', embedded slashes,
  and control characters before writing any file
- Non-identifier characters become underscores in the Swift identifier
  (my-app -> my_app) so Package.swift and target names always compile
- Add --yes/-y and TUIKIT_NON_INTERACTIVE=1 for CI-friendly runs;
  suppress the banner and the "Open in Xcode?" prompt in that mode
- Guard Xcode defaults, the "open Package.swift" call, and the Xcode
  prompt behind a macOS check so nothing macOS-only runs on Linux
- Pin swiftly to Swift 6.0.3 (matching the SDK gates) instead of
  installing latest; refuse the swift.org tarball path on non-Ubuntu
  distributions instead of pretending to be Ubuntu
- Symmetric install/uninstall: resolve_install_path finds the script's
  own directory first and falls back to the installer defaults
- Add an integration test script (scripts/tests/project-template/) that
  covers sanitization, path validation, OS/arch detection, basic
  generation, and hyphen sanitization end to end
- Rewrite the README to describe non-interactive mode, name handling,
  the pinned Swift version, and remove the stale .swiftpm claim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P1-25] Make the project generator cross-platform and self-testing

1 participant