react-native-3rddigital-appupdate 1.0.12 → 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.
- package/package.json +1 -1
- package/scripts/bundle.js +27 -132
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-3rddigital-appupdate",
|
|
3
|
-
"version": "1.0.
|
|
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,140 +543,60 @@ 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);
|
|
582
560
|
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
targets,
|
|
587
|
-
};
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
function parseSchemeFile(filePath) {
|
|
591
|
-
const content = fs.readFileSync(filePath, 'utf8');
|
|
592
|
-
const schemeName = path.basename(filePath, '.xcscheme');
|
|
593
|
-
|
|
594
|
-
const blueprintName =
|
|
595
|
-
content.match(/BlueprintName\s*=\s*"([^"]+)"/)?.[1] ?? schemeName;
|
|
596
|
-
const buildConfiguration =
|
|
597
|
-
content.match(
|
|
598
|
-
/ArchiveAction[^>]*buildConfiguration\s*=\s*"([^"]+)"/
|
|
599
|
-
)?.[1] ??
|
|
600
|
-
content.match(/LaunchAction[^>]*buildConfiguration\s*=\s*"([^"]+)"/)?.[1] ??
|
|
601
|
-
content.match(
|
|
602
|
-
/ProfileAction[^>]*buildConfiguration\s*=\s*"([^"]+)"/
|
|
603
|
-
)?.[1] ??
|
|
604
|
-
'Release';
|
|
605
|
-
|
|
606
|
-
return {
|
|
607
|
-
scheme: schemeName,
|
|
608
|
-
targetName: blueprintName,
|
|
609
|
-
buildConfiguration,
|
|
610
|
-
};
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
function getIosSchemeMetadata() {
|
|
614
|
-
const iosMetadata = getIosTargetMetadata();
|
|
615
|
-
if (!iosMetadata) return null;
|
|
616
|
-
|
|
617
|
-
const schemeFiles = walkFiles(iosMetadata.projectFiles.iosDir, (filePath) =>
|
|
618
|
-
filePath.endsWith('.xcscheme')
|
|
619
|
-
);
|
|
620
|
-
|
|
621
|
-
const targetsByName = new Map(
|
|
622
|
-
iosMetadata.targets.map((target) => [target.name, target])
|
|
623
|
-
);
|
|
624
|
-
|
|
625
|
-
const schemes = schemeFiles
|
|
626
|
-
.map(parseSchemeFile)
|
|
627
|
-
.map((scheme) => {
|
|
628
|
-
const target = targetsByName.get(scheme.targetName);
|
|
629
|
-
if (!target) return null;
|
|
630
|
-
|
|
631
|
-
const config = target.configsByName.get(scheme.buildConfiguration) ??
|
|
632
|
-
target.configsByName.get('Release') ?? {
|
|
633
|
-
appId: target.appId,
|
|
634
|
-
version: target.version,
|
|
635
|
-
productName: target.productName,
|
|
636
|
-
name: target.buildConfiguration,
|
|
637
|
-
};
|
|
638
|
-
|
|
639
|
-
return {
|
|
640
|
-
name: scheme.scheme,
|
|
641
|
-
label: scheme.scheme,
|
|
642
|
-
targetName: target.name,
|
|
643
|
-
buildConfiguration: scheme.buildConfiguration,
|
|
644
|
-
appId: config.appId ?? target.appId ?? null,
|
|
645
|
-
version: config.version ?? target.version ?? null,
|
|
646
|
-
productName: config.productName ?? target.productName,
|
|
647
|
-
};
|
|
648
|
-
})
|
|
649
|
-
.filter(Boolean);
|
|
650
|
-
|
|
651
|
-
if (!schemes.length) {
|
|
652
|
-
return {
|
|
653
|
-
defaultConfig: iosMetadata.defaultConfig,
|
|
654
|
-
schemes: iosMetadata.targets.map((target) => ({
|
|
655
|
-
name: target.name,
|
|
656
|
-
label: target.label,
|
|
657
|
-
targetName: target.name,
|
|
658
|
-
buildConfiguration: target.buildConfiguration,
|
|
659
|
-
appId: target.appId,
|
|
660
|
-
version: target.version,
|
|
661
|
-
productName: target.productName,
|
|
662
|
-
})),
|
|
663
|
-
};
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
const uniqueSchemes = schemes.filter(
|
|
667
|
-
(scheme, index, allSchemes) =>
|
|
668
|
-
allSchemes.findIndex((candidate) => candidate.name === scheme.name) ===
|
|
561
|
+
const uniqueTargets = targets.filter(
|
|
562
|
+
(target, index, allTargets) =>
|
|
563
|
+
allTargets.findIndex((candidate) => candidate.name === target.name) ===
|
|
669
564
|
index
|
|
670
565
|
);
|
|
671
566
|
|
|
672
567
|
return {
|
|
673
|
-
defaultConfig:
|
|
674
|
-
|
|
568
|
+
defaultConfig: uniqueTargets[0] ?? null,
|
|
569
|
+
targets: uniqueTargets,
|
|
675
570
|
};
|
|
676
571
|
}
|
|
677
572
|
|
|
678
|
-
async function
|
|
679
|
-
const metadata =
|
|
573
|
+
async function getIosTargetSelection() {
|
|
574
|
+
const metadata = getIosTargetMetadata();
|
|
680
575
|
if (!metadata) return null;
|
|
681
576
|
|
|
682
|
-
if (metadata.
|
|
577
|
+
if (metadata.targets.length <= 1) {
|
|
683
578
|
return metadata.defaultConfig;
|
|
684
579
|
}
|
|
685
580
|
|
|
686
|
-
let
|
|
687
|
-
let
|
|
581
|
+
let selectedTarget;
|
|
582
|
+
let isTargetConfirmed = false;
|
|
688
583
|
|
|
689
|
-
while (!
|
|
690
|
-
|
|
691
|
-
message: 'Select iOS
|
|
692
|
-
choices: metadata.
|
|
693
|
-
name: `${
|
|
694
|
-
value:
|
|
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,
|
|
695
590
|
})),
|
|
696
591
|
});
|
|
697
592
|
|
|
698
|
-
|
|
699
|
-
message: `Continue with iOS
|
|
593
|
+
isTargetConfirmed = await confirm({
|
|
594
|
+
message: `Continue with iOS target ${selectedTarget.label ?? selectedTarget.name}?`,
|
|
700
595
|
default: true,
|
|
701
596
|
});
|
|
702
597
|
}
|
|
703
598
|
|
|
704
|
-
return
|
|
599
|
+
return selectedTarget;
|
|
705
600
|
}
|
|
706
601
|
|
|
707
602
|
function getPlatformAppVersion(platform, selection) {
|
|
@@ -713,7 +608,7 @@ function getPlatformAppVersion(platform, selection) {
|
|
|
713
608
|
}
|
|
714
609
|
|
|
715
610
|
if (platform === 'ios') {
|
|
716
|
-
const metadata =
|
|
611
|
+
const metadata = getIosTargetMetadata();
|
|
717
612
|
return metadata?.defaultConfig.version ?? null;
|
|
718
613
|
}
|
|
719
614
|
|
|
@@ -761,7 +656,7 @@ async function getPlatformConfig(platform) {
|
|
|
761
656
|
platform === 'android'
|
|
762
657
|
? await getAndroidFlavorSelection()
|
|
763
658
|
: platform === 'ios'
|
|
764
|
-
? await
|
|
659
|
+
? await getIosTargetSelection()
|
|
765
660
|
: null;
|
|
766
661
|
|
|
767
662
|
if (platform === 'android' && selection?.label) {
|
|
@@ -772,7 +667,7 @@ async function getPlatformConfig(platform) {
|
|
|
772
667
|
|
|
773
668
|
if (platform === 'ios' && selection?.label) {
|
|
774
669
|
console.log(
|
|
775
|
-
`🍎 Selected iOS
|
|
670
|
+
`🍎 Selected iOS target: ${selection.label} (${selection.appId ?? 'unknown app id'})`
|
|
776
671
|
);
|
|
777
672
|
}
|
|
778
673
|
|