Skip to content

Add --print and --format options - #22

Merged
friederbluemle merged 1 commit into
fbluemle:masterfrom
friederbluemle:print-format
Sep 3, 2026
Merged

friederbluemle merged 1 commit into
fbluemle:masterfrom
friederbluemle:print-format

Conversation

@friederbluemle

Copy link
Copy Markdown
Contributor

Adds --print <platform> with an optional --format <template>. Without a template it lists the three native values in the style of --dry-run; with one, it fills the template, so a composed identifier such as a Sentry release string is a single call:

$ npx rn-version-sync --print ios
appId: com.example.app
versionName: 1.2.3
versionCode: 10203

$ npx rn-version-sync --print ios --format '{appId}@{versionName}+{versionCode}'
com.example.app@1.2.3+10203
  • Placeholders are {appId}, {versionName} and {versionCode}, matching the library field names. An unknown placeholder fails with the available list; other braces pass through, so there are no escaping rules.
  • Reads are lazy: only referenced placeholders are resolved, so a template without {appId} keeps working in projects with flavor-specific application ids where --print-app-id fails.
  • Values are inserted as written in the native file, like the single-value --print-* flags. The character check stays specific to --print-env, where it protects eval.
  • --configuration applies to {appId} for iOS as with the other flags. --format without --print is an error.
  • The README documents the new flag and switches the Sentry example to the one-liner, with --print-env shown after it for scripts that need several values.

Internally the platform switch for reading the app id and versions moved into two helpers shared with readNativeValues; formatTemplate is exported alongside formatEnv.

Print the app id, version name and version code of one platform as
read from the native file. Without --format the three values are
listed as key: value lines in the style of --dry-run; with --format
they fill a template, so a composed identifier such as a Sentry
release string comes out of a single call:

    --print ios --format '{appId}@{versionName}+{versionCode}'

Only the referenced placeholders are read, so a template without
{appId} keeps working in projects where the app id cannot be resolved.
Values are inserted as written in the native file, like the single-value
--print-* flags print them; unknown placeholders are an error.

The platform switch for reading the app id and the versions moves into
two small helpers shared with readNativeValues.
@friederbluemle
friederbluemle merged commit cc5b98a into fbluemle:master Sep 3, 2026
3 checks passed
@friederbluemle
friederbluemle deleted the print-format branch September 3, 2026 20:24
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