react-native-3rddigital-appupdate 1.0.2 → 1.0.4

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.
package/README.md CHANGED
@@ -140,7 +140,6 @@ You will be prompted for:
140
140
  - Project ID
141
141
  - Environment (development / production)
142
142
  - Version
143
- - Build Number
144
143
  - Force Update (true/false)
145
144
 
146
145
  What it does
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-3rddigital-appupdate",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
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
@@ -34,7 +34,6 @@ async function uploadBundle({ filePath, platform, config }) {
34
34
  form.append('environment', config.ENVIRONMENT);
35
35
  form.append('platform', platform);
36
36
  form.append('version', config.VERSION);
37
- form.append('buildNumber', String(config.BUILD_NUMBER));
38
37
  form.append('forceUpdate', String(config.FORCE_UPDATE));
39
38
 
40
39
  try {
@@ -90,51 +89,44 @@ function buildIOS() {
90
89
  return outputPath;
91
90
  }
92
91
 
93
- async function getConfig(platform) {
94
- console.log(`\n⚙️ Enter configuration for ${platform.toUpperCase()}\n`);
92
+ async function getCommonConfig() {
93
+ console.log(`\n⚙️ Enter common configuration (applies to both platforms)\n`);
95
94
 
96
95
  const API_TOKEN = await input({
97
- message: `(${platform}) Enter API Token:`,
96
+ message: `Enter API Token:`,
98
97
  validate: (val) => (val.trim() ? true : 'API Token is required'),
99
98
  });
100
99
 
101
100
  const PROJECT_ID = await input({
102
- message: `(${platform}) Enter Project ID:`,
101
+ message: `Enter Project ID:`,
103
102
  validate: (val) => (val.trim() ? true : 'Project ID is required'),
104
103
  });
105
104
 
106
105
  const ENVIRONMENT = await select({
107
- message: `(${platform}) Select Environment:`,
106
+ message: `Select Environment:`,
108
107
  choices: [
109
108
  { name: 'development', value: 'development' },
110
109
  { name: 'production', value: 'production' },
111
110
  ],
112
111
  });
113
112
 
113
+ return { API_TOKEN, PROJECT_ID, ENVIRONMENT };
114
+ }
115
+
116
+ async function getPlatformSpecificConfig(platform) {
117
+ console.log(`\n🔧 Enter ${platform.toUpperCase()} specific configuration\n`);
118
+
114
119
  const VERSION = await input({
115
120
  message: `(${platform}) Enter App Version (e.g. 1.0.0):`,
116
121
  validate: (val) => (val.trim() ? true : 'Version is required'),
117
122
  });
118
123
 
119
- const BUILD_NUMBER = await input({
120
- message: `(${platform}) Enter Build Number:`,
121
- validate: (val) =>
122
- !isNaN(val) && val.trim() !== '' ? true : 'Must be a number',
123
- });
124
-
125
124
  const FORCE_UPDATE = await confirm({
126
125
  message: `(${platform}) Force Update?`,
127
126
  default: false,
128
127
  });
129
128
 
130
- return {
131
- API_TOKEN,
132
- PROJECT_ID,
133
- ENVIRONMENT,
134
- VERSION,
135
- BUILD_NUMBER,
136
- FORCE_UPDATE,
137
- };
129
+ return { VERSION, FORCE_UPDATE };
138
130
  }
139
131
 
140
132
  (async () => {
@@ -145,8 +137,11 @@ async function getConfig(platform) {
145
137
  process.exit(1);
146
138
  }
147
139
 
140
+ const commonConfig = await getCommonConfig();
141
+
148
142
  if (platform === 'android') {
149
- const config = await getConfig('android');
143
+ const androidExtra = await getPlatformSpecificConfig('android');
144
+ const config = { ...commonConfig, ...androidExtra };
150
145
  const androidFile = buildAndroid();
151
146
  await uploadBundle({
152
147
  filePath: androidFile,
@@ -154,24 +149,25 @@ async function getConfig(platform) {
154
149
  config,
155
150
  });
156
151
  } else if (platform === 'ios') {
157
- const config = await getConfig('ios');
152
+ const iosExtra = await getPlatformSpecificConfig('ios');
153
+ const config = { ...commonConfig, ...iosExtra };
158
154
  const iosFile = buildIOS();
159
155
  await uploadBundle({ filePath: iosFile, platform: 'ios', config });
160
156
  } else if (platform === 'all') {
161
- const androidConfig = await getConfig('android');
157
+ const androidExtra = await getPlatformSpecificConfig('android');
162
158
  const androidFile = buildAndroid();
163
159
  await uploadBundle({
164
160
  filePath: androidFile,
165
161
  platform: 'android',
166
- config: androidConfig,
162
+ config: { ...commonConfig, ...androidExtra },
167
163
  });
168
164
 
169
- const iosConfig = await getConfig('ios');
165
+ const iosExtra = await getPlatformSpecificConfig('ios');
170
166
  const iosFile = buildIOS();
171
167
  await uploadBundle({
172
168
  filePath: iosFile,
173
169
  platform: 'ios',
174
- config: iosConfig,
170
+ config: { ...commonConfig, ...iosExtra },
175
171
  });
176
172
  } else {
177
173
  console.log('❌ Invalid option. Use: android | ios | all');