Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I pass command line arguments to lifecycle scripts? #884

Open
swalahamani opened this issue Feb 22, 2022 · 1 comment
Open

How can I pass command line arguments to lifecycle scripts? #884

swalahamani opened this issue Feb 22, 2022 · 1 comment
Labels

Comments

@swalahamani
Copy link

The option to register other scripts or commands to execute on different life-cycle points during the execution of standard-version is really nice. But what if CLI arguments has to be passed to those commands/scripts? I'm aware that we can add the CLI arguments added along while registering it for the specific life-cycle, but is it possible to pass it dynamically at run-time than changing the life-cycle configuration all the time manually?

My Actual Use-Case:
I need to use react-native-version along with standard-version. For this, I can simply add it as below and it is working fine as well:

// package.json
{
   .
   .
   "standard-version": {
      "scripts": {
         "posttag": "react-native-version -a"
      }
   },
   .
   .
}

But, I have to pass the below described CLI options to react-native-version depending on the scenario I'm in. How can I achieve it without changing the standard-version life-cycle configuration all the time.

react-native-version CLI Options:

-a, --amend                  Amend the previous commit. This is done automatically when react-native-version is run from the "version" or "postversion" npm script. Use "--never-amend" if you never want to amend. Also, if the previous commit is a valid npm-version commit, react-native-version will update the Git tag pointing to this commit.
--skip-tag                   For use with "--amend", if you don't want to update Git tags. Use this option if you have git-tag-version set to false in your npm config or you use "--no-git-tag-version" during npm-version.
-A, --never-amend            Never amend the previous commit.
-b, --increment-build        Only increment build number.
-B, --never-increment-build  Never increment build number.
-d, --android [path]         Path to your "android/app/build.gradle" file. (default: "android/app/build.gradle")
-i, --ios [path]             Path to your "ios/" folder. (default: "ios")
-L, --legacy                 Version iOS using agvtool (macOS only). Requires Xcode Command Line Tools.
-q, --quiet                  Be quiet, only report errors.
-r, --reset-build            Reset build number back to "1" (iOS only). Unlike Android's "versionCode", iOS doesn't require you to bump the "CFBundleVersion", as long as "CFBundleShortVersionString" changes. To make it consistent across platforms, react-native-version bumps both by default. You can use this option if you prefer to keep the build number value at "1" after every version change. If you then need to push another build under the same version, you can use "-bt ios" to increment.
-s, --set-build <number>     Set a build number. WARNING: Watch out when setting high values. This option follows Android's app versioning specifics - the value has to be an integer and cannot be greater than 2100000000. You cannot decrement this value after publishing to Google Play! More info at: https://developer.android.com/studio/publish/versioning.html#appversioning
--generate-build             Generate build number from the package version number. (e.g. build number for version 1.22.3 will be 1022003)
-t, --target <platforms>     Only version specified platforms, e.g. "--target android,ios".
@rebinnaf
Copy link

is there any updates for this issue?

in my case, I also like to get an argument in release command and put it in the commit message. is it possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants