react-native-3rddigital-appupdate 1.0.3 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/scripts/bundle.js +22 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-3rddigital-appupdate",
3
- "version": "1.0.3",
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
@@ -89,27 +89,33 @@ function buildIOS() {
89
89
  return outputPath;
90
90
  }
91
91
 
92
- async function getConfig(platform) {
93
- 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`);
94
94
 
95
95
  const API_TOKEN = await input({
96
- message: `(${platform}) Enter API Token:`,
96
+ message: `Enter API Token:`,
97
97
  validate: (val) => (val.trim() ? true : 'API Token is required'),
98
98
  });
99
99
 
100
100
  const PROJECT_ID = await input({
101
- message: `(${platform}) Enter Project ID:`,
101
+ message: `Enter Project ID:`,
102
102
  validate: (val) => (val.trim() ? true : 'Project ID is required'),
103
103
  });
104
104
 
105
105
  const ENVIRONMENT = await select({
106
- message: `(${platform}) Select Environment:`,
106
+ message: `Select Environment:`,
107
107
  choices: [
108
108
  { name: 'development', value: 'development' },
109
109
  { name: 'production', value: 'production' },
110
110
  ],
111
111
  });
112
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
+
113
119
  const VERSION = await input({
114
120
  message: `(${platform}) Enter App Version (e.g. 1.0.0):`,
115
121
  validate: (val) => (val.trim() ? true : 'Version is required'),
@@ -120,13 +126,7 @@ async function getConfig(platform) {
120
126
  default: false,
121
127
  });
122
128
 
123
- return {
124
- API_TOKEN,
125
- PROJECT_ID,
126
- ENVIRONMENT,
127
- VERSION,
128
- FORCE_UPDATE,
129
- };
129
+ return { VERSION, FORCE_UPDATE };
130
130
  }
131
131
 
132
132
  (async () => {
@@ -137,8 +137,11 @@ async function getConfig(platform) {
137
137
  process.exit(1);
138
138
  }
139
139
 
140
+ const commonConfig = await getCommonConfig();
141
+
140
142
  if (platform === 'android') {
141
- const config = await getConfig('android');
143
+ const androidExtra = await getPlatformSpecificConfig('android');
144
+ const config = { ...commonConfig, ...androidExtra };
142
145
  const androidFile = buildAndroid();
143
146
  await uploadBundle({
144
147
  filePath: androidFile,
@@ -146,24 +149,25 @@ async function getConfig(platform) {
146
149
  config,
147
150
  });
148
151
  } else if (platform === 'ios') {
149
- const config = await getConfig('ios');
152
+ const iosExtra = await getPlatformSpecificConfig('ios');
153
+ const config = { ...commonConfig, ...iosExtra };
150
154
  const iosFile = buildIOS();
151
155
  await uploadBundle({ filePath: iosFile, platform: 'ios', config });
152
156
  } else if (platform === 'all') {
153
- const androidConfig = await getConfig('android');
157
+ const androidExtra = await getPlatformSpecificConfig('android');
154
158
  const androidFile = buildAndroid();
155
159
  await uploadBundle({
156
160
  filePath: androidFile,
157
161
  platform: 'android',
158
- config: androidConfig,
162
+ config: { ...commonConfig, ...androidExtra },
159
163
  });
160
164
 
161
- const iosConfig = await getConfig('ios');
165
+ const iosExtra = await getPlatformSpecificConfig('ios');
162
166
  const iosFile = buildIOS();
163
167
  await uploadBundle({
164
168
  filePath: iosFile,
165
169
  platform: 'ios',
166
- config: iosConfig,
170
+ config: { ...commonConfig, ...iosExtra },
167
171
  });
168
172
  } else {
169
173
  console.log('❌ Invalid option. Use: android | ios | all');