react-native-3rddigital-appupdate 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/scripts/bundle.js +27 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-3rddigital-appupdate",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "A React Native library for seamless over-the-air (OTA) updates with version checks, automatic bundle download, and customizable user prompts for iOS and Android.",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
package/scripts/bundle.js CHANGED
@@ -106,11 +106,29 @@ function buildIOS() {
106
106
  */
107
107
  function getAppVersion(platform) {
108
108
  try {
109
+ // Find the actual React Native project root (two levels up from node_modules)
110
+ let projectRoot = path.resolve(__dirname);
111
+ while (
112
+ projectRoot.includes('node_modules') &&
113
+ !fs.existsSync(path.join(projectRoot, 'package.json'))
114
+ ) {
115
+ projectRoot = path.resolve(projectRoot, '..');
116
+ }
117
+
118
+ // Once we exit node_modules, ensure we’re at the React Native app root
119
+ if (projectRoot.includes('node_modules')) {
120
+ projectRoot = path.resolve(projectRoot, '../../');
121
+ }
122
+
109
123
  if (platform === 'android') {
110
- // Read Android versionName from build.gradle
111
- const gradlePath = path.join(__dirname, 'android', 'app', 'build.gradle');
124
+ const gradlePath = path.join(
125
+ projectRoot,
126
+ 'android',
127
+ 'app',
128
+ 'build.gradle'
129
+ );
112
130
  if (!fs.existsSync(gradlePath)) {
113
- console.warn('⚠️ Android build.gradle not found.');
131
+ console.warn(`⚠️ Android build.gradle not found at ${gradlePath}`);
114
132
  return null;
115
133
  }
116
134
  const gradleContent = fs.readFileSync(gradlePath, 'utf8');
@@ -121,8 +139,12 @@ function getAppVersion(platform) {
121
139
  console.warn('⚠️ Could not find versionName in build.gradle.');
122
140
  }
123
141
  } else if (platform === 'ios') {
124
- // Read MARKETING_VERSION directly from project.pbxproj
125
- const iosDir = path.join(__dirname, 'ios');
142
+ const iosDir = path.join(projectRoot, 'ios');
143
+ if (!fs.existsSync(iosDir)) {
144
+ console.warn(`⚠️ iOS folder not found at ${iosDir}`);
145
+ return null;
146
+ }
147
+
126
148
  const projectDir = fs
127
149
  .readdirSync(iosDir)
128
150
  .find((d) => d.endsWith('.xcodeproj'));