Fail on missing native files and clean up the CLI - #24
Merged
Merged
Conversation
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.
Contributor
|
🎉 Released in v0.7.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Running the sync where no native project exists printed
✓ Version sync completed successfullyand exited 0, because a platform whose file was not found was skipped silently unless--verbosewas set. This makes that visible and takes a cleanup pass through the CLI and the README along the way, one commit per change.--skip-android --skip-ios. Single-platform projects see the warning until they pass the matching--skip-*flag.syncVersionsreturns the synced path per platform, and the updaters return the path ornullinstead of logging in verbose mode.--version-codeand--reserve-buildsonly accept integers (12abcused to become 12 and1.5became 1), and a manual version code must be positive, enforced inresolveVersionslikereserveBuildsalready was.--print-version-name,--print-version-codeand--print-app-idrender throughformatTemplateas single-placeholder templates, which removes their own platform switches and the direct platform imports from the CLI.--dry-runcombined with a print flag is rejected instead of ignored.--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,updateAndroidVersionandupdateIOSVersionare additive, but the warning and the failure on missing files are behavior changes, so this should go out as a minor release.