Skip to content

Fail on missing native files and clean up the CLI - #24

Merged
friederbluemle merged 5 commits into
fbluemle:masterfrom
friederbluemle:cli-cleanup
Sep 4, 2026
Merged

friederbluemle merged 5 commits into
fbluemle:masterfrom
friederbluemle:cli-cleanup

Conversation

@friederbluemle

Copy link
Copy Markdown
Contributor

Running the sync where no native project exists printed ✓ Version sync completed successfully and exited 0, because a platform whose file was not found was skipped silently unless --verbose was set. This makes that visible and takes a cleanup pass through the CLI and the README along the way, one commit per change.

$ npx rn-version-sync
Warning: ios/<Project>.xcodeproj/project.pbxproj not found, skipping iOS. Pass --skip-ios to silence this warning.
✓ Version sync completed successfully

$ npx rn-version-sync --project-dir /somewhere/else
Warning: android/app/build.gradle not found, skipping Android. Pass --skip-android to silence this warning.
Warning: ios/<Project>.xcodeproj/project.pbxproj not found, skipping iOS. Pass --skip-ios to silence this warning.
Error: No native project files found in /somewhere/else.
Expected android/app/build.gradle or ios/<Project>.xcodeproj/project.pbxproj; use --gradle-path or --pbxproj-path for other locations.
  • A platform whose file cannot be found is skipped with a warning on stderr, and the command fails when nothing was synced, including with --skip-android --skip-ios. Single-platform projects see the warning until they pass the matching --skip-* flag. syncVersions returns the synced path per platform, and the updaters return the path or null instead of logging in verbose mode.
  • The explicit-path check and auto-detection that the readers and updaters each repeated now live in one locate function per platform.
  • --version-code and --reserve-builds only accept integers (12abc used to become 12 and 1.5 became 1), and a manual version code must be positive, enforced in resolveVersions like reserveBuilds already was.
  • --print-version-name, --print-version-code and --print-app-id render through formatTemplate as single-placeholder templates, which removes their own platform switches and the direct platform imports from the CLI. --dry-run combined with a print flag is rejected instead of ignored.
  • The README documents the seven sync options that were missing (--version-name, --reserve-builds, --skip-android, --skip-ios, --project-dir, --gradle-path, --pbxproj-path) plus --dry-run, condenses the read flags into one section, describes the missing-file behavior, and adds a short programmatic-use section.

The new return types of syncVersions, updateAndroidVersion and updateIOSVersion are additive, but the warning and the failure on missing files are behavior changes, so this should go out as a minor release.

updateAndroidVersion and updateIOSVersion returned nothing and only
mentioned a missing file in verbose mode, so callers could not tell
whether anything was written. They now return the path of the file they
synced, or null when no file was found, so syncVersions can report on
it.

Both updaters also repeated the explicit-path check and the
auto-detection that the readers already performed. That logic now lives
in one locate function per platform, shared by the readers (which throw
when nothing is found) and the updaters (which return null).
Running the sync in a directory without any native project printed the
success message and exited 0, because a platform whose file was not
found was skipped silently unless --verbose was set. A wrong
--project-dir or an unexpected layout therefore went unnoticed.

syncVersions now warns on stderr for each platform whose file cannot be
found, pointing at --skip-android / --skip-ios to silence it, and throws
when no file was synced at all, including when both platforms are
skipped. It returns the synced paths per platform so programmatic
callers get the same information.
--version-code and --reserve-builds went through parseInt, which
accepted "12abc" as 12 and "1.5" as 1, and nothing rejected a zero or
negative version code. Both options now use a commander argument parser
that only accepts integers, and resolveVersions rejects a manual version
code below 1, mirroring the existing reserveBuilds check, so the rule
also applies to programmatic use.
--print-version-name, --print-version-code and --print-app-id each had
their own platform switch in the CLI, duplicating what formatTemplate
already does for --print. They are now single-placeholder templates
rendered through the same path, which drops the direct imports of the
platform functions from the CLI. The re-export comment in index.ts
described those as test helpers; they are the lower-level programmatic
API.

--dry-run combined with a print flag was ignored silently in favor of
the print; it is now rejected like other conflicting combinations.
Seven sync options (--version-name, --reserve-builds, --skip-android,
--skip-ios, --project-dir, --gradle-path, --pbxproj-path) were not
documented at all, and --dry-run only in passing, while each read flag
had grown a long section. The README now opens with a table of what is
written where, lists every sync option in one table, condenses the read
flags into a single section, and documents the new warning and failure
behavior for missing native files. A short section covers the
programmatic API, which ships with type definitions but was not
mentioned.
@friederbluemle
friederbluemle merged commit e9d104e into fbluemle:master Sep 4, 2026
3 checks passed
@friederbluemle
friederbluemle deleted the cli-cleanup branch September 4, 2026 06:06
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🎉 Released in v0.7.0

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.

1 participant