Skip to content

Make the bare command a check and require --write - #28

Merged
friederbluemle merged 2 commits into
fbluemle:masterfrom
friederbluemle:check-mode
Sep 5, 2026
Merged

friederbluemle merged 2 commits into
fbluemle:masterfrom
friederbluemle:check-mode

Conversation

@friederbluemle

@friederbluemle friederbluemle commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

The bare command no longer writes. It compares the native files with the package.json version and prints one table; --write applies the update, in the spirit of Prettier and Biome.

$ rn-version-sync
PLATFORM  APP ID           VERSION        STATUS
js        example-app      1.2.3
android   com.example.app  1.2.3 (10203)  ok
ios       com.example.app  1.2.2 (10202)  outdated
Run with --write to update the native files.
$ echo $?
1

$ rn-version-sync --write
PLATFORM  APP ID           VERSION        STATUS
js        example-app      1.2.3
android   com.example.app  1.2.3 (10203)  unchanged
ios       com.example.app  1.2.3 (10203)  updated
  • Every row shows what its file says. The js row is package.json (name and version), the native rows show app id, version name and code as written. When --version-name or --version-code replace the package.json values, the js row's status names the target, e.g. overridden 2.0.0 (20000); --reserve-builds alone is derived and not marked.
  • The check exits 1 when a platform is outdated, so it doubles as a CI step. It also protects existing npm version hooks that are not updated to --write: at hook time the native files lag behind package.json, so the old hook fails loudly with the hint instead of silently committing a bump that never reached the native files.
  • --write prints the same table read back after writing, marking each platform updated or unchanged.
  • A platform whose file is not found gets a row (not found, pass --skip-ios to ignore) instead of a warning on stderr; skipped platforms are omitted. With --configuration Staging the iOS row is labeled ios (Staging).
  • --dry-run and --verbose are removed. The check shows what --dry-run did and more, and the table after --write replaces the verbose log. The --print* flags stay as they are for scripting.
  • Library: checkVersions is new and syncVersions returns the same per-platform status (values read back after writing, plus an updated flag) instead of bare paths, along with packageName, packageVersion, overridden and missing. The updaters lose their verbose parameter and console output. SyncOptions extends ReadOptions.
  • README documents the check-first flow, the CI use, and the --write hook.

One consequence to be aware of: both modes read the app id for the table, so a project where it cannot be resolved (Android flavors with their own applicationId, or a variable bundle identifier) now fails in --write too, where the old sync worked. That matches the earlier decision to treat such projects as out of scope for now.

This changes what the bare command does, so it should go out as 0.8.0 with a prominent release note.

@friederbluemle
friederbluemle force-pushed the check-mode branch 2 times, most recently from 1e6f01c to 41d6f04 Compare September 4, 2026 18:41
The CLI is about to gain a read-only default mode that compares the
native files with the package.json version, which needs a library call
that reads the current values of every platform next to the resolved
target. checkVersions does that and syncVersions now returns the same
per-platform status, read back after writing and with an updated flag,
instead of bare file paths.

The status also carries the package.json name and version as written,
whether the target was overridden with versionName or versionCode, and
the platforms whose native file was not found, which replaces the
console warning so the caller decides how to present it. Both functions
share one lookup of the native files. The updaters lose their verbose
parameter and console output; reporting is the caller's job now that
the status is returned. SyncOptions extends ReadOptions, so
--configuration selects the iOS build configuration for the comparison
as it does for reads.
Running rn-version-sync without arguments wrote to the native files,
which is unusual for a tool of this kind and left no way to see the
current state. The bare command now prints a table with one row per
platform, each showing what its file says: js with the name and version
from package.json, android and ios with app id, version name and code
as written, plus a status of ok or outdated. It exits 1 when a platform
is outdated, which makes it a CI check and, for existing `npm version`
hooks that are not updated, turns a silent non-update into a loud
failure pointing at --write.

--write applies the update and prints the same table read back after
writing, with updated or unchanged per platform. A platform whose file
is not found gets a row saying so instead of a warning on stderr. When
--version-name or --version-code replace the package.json values, the
js row's status names the target, and the ios row names the
configuration when --configuration is given.

--dry-run and --verbose are gone: the check covers what --dry-run
showed, and the table after --write replaces the verbose log.
@friederbluemle
friederbluemle merged commit 26929d6 into fbluemle:master Sep 5, 2026
3 checks passed
@friederbluemle
friederbluemle deleted the check-mode branch September 5, 2026 00:40
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

🎉 Released in v0.8.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