react-native-3rddigital-appupdate 1.0.13 → 1.0.14

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 -139
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-3rddigital-appupdate",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
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
@@ -169,25 +169,6 @@ function findFirstXcodeProj(dir) {
169
169
  return null;
170
170
  }
171
171
 
172
- function walkFiles(dir, matcher, result = []) {
173
- if (!fs.existsSync(dir)) return result;
174
-
175
- const entries = fs.readdirSync(dir, { withFileTypes: true });
176
- for (const entry of entries) {
177
- const fullPath = path.join(dir, entry.name);
178
- if (entry.isDirectory()) {
179
- walkFiles(fullPath, matcher, result);
180
- continue;
181
- }
182
-
183
- if (matcher(fullPath)) {
184
- result.push(fullPath);
185
- }
186
- }
187
-
188
- return result;
189
- }
190
-
191
172
  function extractBracedBlock(content, startIndex) {
192
173
  const openIndex = content.indexOf('{', startIndex);
193
174
  if (openIndex === -1) return null;
@@ -553,12 +534,6 @@ function getIosTargetMetadata() {
553
534
  .map((configId) => configMap.get(configId))
554
535
  .filter(Boolean) ?? [];
555
536
 
556
- const configsByName = new Map(
557
- buildConfigs
558
- .filter((config) => config.name)
559
- .map((config) => [config.name, config])
560
- );
561
-
562
537
  const preferredConfig =
563
538
  buildConfigs.find(
564
539
  (config) => config.name === configList?.defaultName
@@ -568,14 +543,17 @@ function getIosTargetMetadata() {
568
543
 
569
544
  if (!preferredConfig) return null;
570
545
 
546
+ const buildConfigurationLabel = preferredConfig.name
547
+ ? ` [${preferredConfig.name}]`
548
+ : '';
549
+
571
550
  return {
572
551
  name: targetName,
573
- label: targetName,
552
+ label: `${targetName}${buildConfigurationLabel}`,
574
553
  appId: preferredConfig.appId ?? null,
575
554
  version: preferredConfig.version ?? null,
576
555
  productName: preferredConfig.productName ?? targetName,
577
556
  buildConfiguration: preferredConfig.name ?? null,
578
- configsByName,
579
557
  };
580
558
  })
581
559
  .filter(Boolean);
@@ -587,133 +565,38 @@ function getIosTargetMetadata() {
587
565
  );
588
566
 
589
567
  return {
590
- projectFiles,
591
568
  defaultConfig: uniqueTargets[0] ?? null,
592
569
  targets: uniqueTargets,
593
570
  };
594
571
  }
595
572
 
596
- function parseSchemeFile(filePath) {
597
- const content = fs.readFileSync(filePath, 'utf8');
598
- const schemeName = path.basename(filePath, '.xcscheme');
599
-
600
- const blueprintName =
601
- content.match(/BlueprintName\s*=\s*"([^"]+)"/)?.[1] ?? schemeName;
602
- const buildConfiguration =
603
- content.match(
604
- /ArchiveAction[^>]*buildConfiguration\s*=\s*"([^"]+)"/
605
- )?.[1] ??
606
- content.match(/LaunchAction[^>]*buildConfiguration\s*=\s*"([^"]+)"/)?.[1] ??
607
- content.match(
608
- /ProfileAction[^>]*buildConfiguration\s*=\s*"([^"]+)"/
609
- )?.[1] ??
610
- 'Release';
611
-
612
- return {
613
- scheme: schemeName,
614
- targetName: blueprintName,
615
- buildConfiguration,
616
- };
617
- }
618
-
619
- function getIosSchemeMetadata() {
620
- const iosMetadata = getIosTargetMetadata();
621
- if (!iosMetadata) return null;
622
-
623
- const schemeFiles = walkFiles(iosMetadata.projectFiles.iosDir, (filePath) =>
624
- filePath.endsWith('.xcscheme')
625
- );
626
-
627
- const targetsByName = new Map(
628
- iosMetadata.targets.map((target) => [target.name, target])
629
- );
630
-
631
- const schemes = schemeFiles
632
- .map(parseSchemeFile)
633
- .map((scheme) => {
634
- const target = targetsByName.get(scheme.targetName);
635
- if (!target) return null;
636
-
637
- const config = target.configsByName.get(scheme.buildConfiguration) ??
638
- target.configsByName.get('Release') ?? {
639
- appId: target.appId,
640
- version: target.version,
641
- productName: target.productName,
642
- name: target.buildConfiguration,
643
- };
644
-
645
- return {
646
- name: scheme.scheme,
647
- label: scheme.scheme,
648
- targetName: target.name,
649
- buildConfiguration: scheme.buildConfiguration,
650
- appId: config.appId ?? target.appId ?? null,
651
- version: config.version ?? target.version ?? null,
652
- productName: config.productName ?? target.productName,
653
- };
654
- })
655
- .filter(Boolean);
656
-
657
- const schemesByTargetName = new Map(
658
- schemes.map((scheme) => [scheme.targetName, scheme])
659
- );
660
-
661
- const mergedSchemes = iosMetadata.targets.map((target) => {
662
- const matchedScheme = schemesByTargetName.get(target.name);
663
- if (matchedScheme) {
664
- return matchedScheme;
665
- }
666
-
667
- return {
668
- name: target.name,
669
- label: `${target.label}${target.buildConfiguration ? ` [${target.buildConfiguration}]` : ''}`,
670
- targetName: target.name,
671
- buildConfiguration: target.buildConfiguration,
672
- appId: target.appId,
673
- version: target.version,
674
- productName: target.productName,
675
- };
676
- });
677
-
678
- const uniqueSchemes = mergedSchemes.filter(
679
- (scheme, index, allSchemes) =>
680
- allSchemes.findIndex((candidate) => candidate.name === scheme.name) ===
681
- index
682
- );
683
-
684
- return {
685
- defaultConfig: uniqueSchemes[0] ?? iosMetadata.defaultConfig,
686
- schemes: uniqueSchemes,
687
- };
688
- }
689
-
690
- async function getIosSchemeSelection() {
691
- const metadata = getIosSchemeMetadata();
573
+ async function getIosTargetSelection() {
574
+ const metadata = getIosTargetMetadata();
692
575
  if (!metadata) return null;
693
576
 
694
- if (metadata.schemes.length <= 1) {
577
+ if (metadata.targets.length <= 1) {
695
578
  return metadata.defaultConfig;
696
579
  }
697
580
 
698
- let selectedScheme;
699
- let isSchemeConfirmed = false;
581
+ let selectedTarget;
582
+ let isTargetConfirmed = false;
700
583
 
701
- while (!isSchemeConfirmed) {
702
- selectedScheme = await select({
703
- message: 'Select iOS scheme:',
704
- choices: metadata.schemes.map((scheme) => ({
705
- name: `${scheme.label} (${scheme.appId ?? 'unknown app id'} / ${scheme.version ?? 'unknown version'})`,
706
- value: scheme,
584
+ while (!isTargetConfirmed) {
585
+ selectedTarget = await select({
586
+ message: 'Select iOS target:',
587
+ choices: metadata.targets.map((target) => ({
588
+ name: `${target.label} (${target.appId ?? 'unknown app id'} / ${target.version ?? 'unknown version'})`,
589
+ value: target,
707
590
  })),
708
591
  });
709
592
 
710
- isSchemeConfirmed = await confirm({
711
- message: `Continue with iOS scheme ${selectedScheme.label ?? selectedScheme.name}?`,
593
+ isTargetConfirmed = await confirm({
594
+ message: `Continue with iOS target ${selectedTarget.label ?? selectedTarget.name}?`,
712
595
  default: true,
713
596
  });
714
597
  }
715
598
 
716
- return selectedScheme;
599
+ return selectedTarget;
717
600
  }
718
601
 
719
602
  function getPlatformAppVersion(platform, selection) {
@@ -725,7 +608,7 @@ function getPlatformAppVersion(platform, selection) {
725
608
  }
726
609
 
727
610
  if (platform === 'ios') {
728
- const metadata = getIosSchemeMetadata();
611
+ const metadata = getIosTargetMetadata();
729
612
  return metadata?.defaultConfig.version ?? null;
730
613
  }
731
614
 
@@ -773,7 +656,7 @@ async function getPlatformConfig(platform) {
773
656
  platform === 'android'
774
657
  ? await getAndroidFlavorSelection()
775
658
  : platform === 'ios'
776
- ? await getIosSchemeSelection()
659
+ ? await getIosTargetSelection()
777
660
  : null;
778
661
 
779
662
  if (platform === 'android' && selection?.label) {
@@ -784,7 +667,7 @@ async function getPlatformConfig(platform) {
784
667
 
785
668
  if (platform === 'ios' && selection?.label) {
786
669
  console.log(
787
- `🍎 Selected iOS scheme: ${selection.label} (${selection.appId ?? 'unknown app id'})`
670
+ `🍎 Selected iOS target: ${selection.label} (${selection.appId ?? 'unknown app id'})`
788
671
  );
789
672
  }
790
673