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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --skip-expo option to skip Expo versioning even if detected #325

Open
sregg opened this issue Jun 27, 2023 · 1 comment
Open

Add --skip-expo option to skip Expo versioning even if detected #325

sregg opened this issue Jun 27, 2023 · 1 comment

Comments

@sregg
Copy link

sregg commented Jun 27, 2023

Hi! 馃憢

Firstly, thanks for your work on this project! 馃檪

Today I used patch-package to patch react-native-version@4.0.0 for the project I'm working on.

We have a vanilla React Native app that uses expo-updates.
We don't need to update app.json but we do need to update the native files (i.e. Info.plist and build.gradle).
I added a new option --skip-expo to manually skip expo versioning even if detected.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-version/README.md b/node_modules/react-native-version/README.md
index 1f3aa85..21ce3ff 100644
--- a/node_modules/react-native-version/README.md
+++ b/node_modules/react-native-version/README.md
@@ -72,6 +72,7 @@ $ react-native-version
     -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".
+    -e, --skip-expo              Skip Expo versioning even if detected.
     -h, --help                   output usage information
 
 <!-- END cli -->
diff --git a/node_modules/react-native-version/cli.js b/node_modules/react-native-version/cli.js
index 15f4c32..678d5b5 100755
--- a/node_modules/react-native-version/cli.js
+++ b/node_modules/react-native-version/cli.js
@@ -53,6 +53,7 @@ program
 		'Only version specified platforms, e.g. "--target android,ios".',
 		list
 	)
+	.option("-e, --skip-expo", "Skip Expo versioning even if detected.")
 	.parse(process.argv);
 
 rnv.version(program);
diff --git a/node_modules/react-native-version/index.js b/node_modules/react-native-version/index.js
index 345f3d4..de5e692 100644
--- a/node_modules/react-native-version/index.js
+++ b/node_modules/react-native-version/index.js
@@ -114,12 +114,12 @@ function getCFBundleShortVersionString(versionName) {
  * @private
  * @return {Boolean} true if the project is an Expo app
  */
-function isExpoProject(projPath) {
+function isExpoProject(projPath, programOpts) {
 	try {
 		let module = resolveFrom(projPath, "expo");
 		let appInfo = require(`${projPath}/app.json`);
 
-		return !!(module && appInfo.expo);
+		return !!(!programOpts.skipExpo && module && appInfo.expo);
 	} catch (err) {
 		return false;
 	}
@@ -183,7 +183,7 @@ function version(program, projectPath) {
 
 	var appJSON;
 	const appJSONPath = path.join(projPath, "app.json");
-	const isExpoApp = isExpoProject(projPath);
+	const isExpoApp = isExpoProject(projPath, programOpts);
 
 	isExpoApp && log({ text: "Expo detected" }, programOpts.quiet);
 

This issue body was partially generated by patch-package.

@geolffreym
Copy link

Great! Definitely we need this feature too!

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

No branches or pull requests

2 participants