Skip to content

Read project settings from package.json - #29

Merged
friederbluemle merged 1 commit into
fbluemle:masterfrom
friederbluemle:package-json-config
Sep 5, 2026
Merged

friederbluemle merged 1 commit into
fbluemle:masterfrom
friederbluemle:package-json-config

Conversation

@friederbluemle

@friederbluemle friederbluemle commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Options such as --reserve-builds change the version code every command compares against or writes, so they had to be repeated on each call. Forgetting one silently checks against the wrong code or, with --write, writes a lower code than the native files already hold. Settings that are permanent for a project can now live in package.json:

{
  "rn-version-sync": {
    "reserveBuilds": 100
  }
}
  • Six settings, one per option. reserveBuilds, gradlePath, pbxprojPath, configuration, skipAndroid and skipIos map to the flags of the same name. Per-invocation flags (--write, --version-name, --version-code, the --print* family and --format) stay command line only.
  • A command line option takes precedence over the configured value, including an explicit skip flag over a configured one. Relative paths are resolved against the project directory, like the flags.
  • Mistakes fail loudly. An unknown setting lists the valid names (so reserveBuild is caught), a value of the wrong type names the expected type, and a key that is not an object is rejected. A missing package.json means no configuration, so --version-name plus --version-code keep working without one.
  • The library applies the configuration too. checkVersions, syncVersions, resolveVersions, readNativeValues and formatTemplate fill in options that are not passed explicitly, so syncVersions(dir) from a script and the CLI agree. loadConfig and the ProjectConfig type are exported, and SyncOptions now extends ProjectConfig.
  • The table honors the configured configuration. The iOS row reads ios (Staging) whether the configuration comes from the flag or from package.json.
  • --help and README document the key, the settings table and the precedence rule; the --reserve-builds row points to it.

package.json is the usual place for small tool configuration in the npm ecosystem, and the tool already reads it, so no new file, lookup or dependency is needed. Deferred for now: an rc file as an alternative location, and a guard that refuses to write a lower version code than the native files hold.

Options such as --reserve-builds change the version code every command
compares against or writes, so they had to be repeated on each call.
Forgetting one silently checks against the wrong code or, with --write,
writes a lower code than the native files already hold.

Settings that are permanent for a project can now be stored under an
"rn-version-sync" key in package.json: reserveBuilds, gradlePath,
pbxprojPath, configuration, skipAndroid and skipIos. A command line
option takes precedence over the configured value, relative paths are
resolved against the project directory, and unknown settings or values
of the wrong type are rejected.

package.json is the usual place for small tool configuration in the npm
ecosystem, and the tool already reads it, so no new file, lookup or
dependency is needed. The library functions apply the configuration as
well, so programmatic use and the CLI agree.
@friederbluemle
friederbluemle merged commit d09be24 into fbluemle:master Sep 5, 2026
3 checks passed
@friederbluemle
friederbluemle deleted the package-json-config branch September 5, 2026 01:00
@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