@expo/config-plugins 4.0.2 → 4.0.7
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 +14 -0
- package/build/Plugin.types.d.ts +4 -0
- package/build/Plugin.types.js.map +1 -1
- package/build/android/Updates.d.ts +10 -10
- package/build/android/Updates.js.map +1 -1
- package/build/android/codeMod.d.ts +20 -0
- package/build/android/codeMod.js +109 -0
- package/build/android/codeMod.js.map +1 -0
- package/build/android/index.d.ts +2 -6
- package/build/android/index.js +1 -86
- package/build/android/index.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.js +8 -0
- package/build/index.js.map +1 -1
- package/build/ios/Bitcode.d.ts +33 -0
- package/build/ios/Bitcode.js +131 -0
- package/build/ios/Bitcode.js.map +1 -0
- package/build/ios/Maps.js +1 -0
- package/build/ios/Maps.js.map +1 -1
- package/build/ios/Paths.d.ts +1 -0
- package/build/ios/Paths.js +25 -0
- package/build/ios/Paths.js.map +1 -1
- package/build/ios/Updates.d.ts +10 -10
- package/build/ios/Updates.js.map +1 -1
- package/build/ios/codeMod.d.ts +81 -0
- package/build/ios/codeMod.js +306 -0
- package/build/ios/codeMod.js.map +1 -0
- package/build/ios/index.d.ts +3 -5
- package/build/ios/index.js +6 -57
- package/build/ios/index.js.map +1 -1
- package/build/plugins/android-plugins.d.ts +7 -0
- package/build/plugins/android-plugins.js +19 -2
- package/build/plugins/android-plugins.js.map +1 -1
- package/build/plugins/ios-plugins.d.ts +6 -6
- package/build/plugins/ios-plugins.js.map +1 -1
- package/build/plugins/withAndroidBaseMods.d.ts +2 -0
- package/build/plugins/withAndroidBaseMods.js +32 -0
- package/build/plugins/withAndroidBaseMods.js.map +1 -1
- package/build/plugins/withStaticPlugin.js +16 -5
- package/build/plugins/withStaticPlugin.js.map +1 -1
- package/build/utils/Updates.d.ts +5 -4
- package/build/utils/Updates.js +1 -1
- package/build/utils/Updates.js.map +1 -1
- package/build/utils/commonCodeMod.d.ts +32 -0
- package/build/utils/commonCodeMod.js +71 -0
- package/build/utils/commonCodeMod.js.map +1 -0
- package/build/utils/matchBrackets.d.ts +7 -0
- package/build/utils/matchBrackets.js +80 -0
- package/build/utils/matchBrackets.js.map +1 -0
- package/package.json +3 -3
- package/build/android/Branch.d.ts +0 -5
- package/build/android/Branch.js +0 -54
- package/build/android/Branch.js.map +0 -1
- package/build/android/Facebook.d.ts +0 -13
- package/build/android/Facebook.js +0 -236
- package/build/android/Facebook.js.map +0 -1
- package/build/android/NavigationBar.d.ts +0 -9
- package/build/android/NavigationBar.js +0 -141
- package/build/android/NavigationBar.js.map +0 -1
- package/build/android/RootViewBackgroundColor.d.ts +0 -6
- package/build/android/RootViewBackgroundColor.js +0 -81
- package/build/android/RootViewBackgroundColor.js.map +0 -1
- package/build/android/UserInterfaceStyle.d.ts +0 -11
- package/build/android/UserInterfaceStyle.js +0 -125
- package/build/android/UserInterfaceStyle.js.map +0 -1
- package/build/ios/Branch.d.ts +0 -5
- package/build/ios/Branch.js +0 -42
- package/build/ios/Branch.js.map +0 -1
- package/build/ios/Facebook.d.ts +0 -176
- package/build/ios/Facebook.js +0 -232
- package/build/ios/Facebook.js.map +0 -1
- package/build/ios/RootViewBackgroundColor.d.ts +0 -6
- package/build/ios/RootViewBackgroundColor.js +0 -70
- package/build/ios/RootViewBackgroundColor.js.map +0 -1
- package/build/ios/UserInterfaceStyle.d.ts +0 -5
- package/build/ios/UserInterfaceStyle.js +0 -59
- package/build/ios/UserInterfaceStyle.js.map +0 -1
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getBitcode = getBitcode;
|
|
7
|
+
exports.setBitcodeWithConfig = setBitcodeWithConfig;
|
|
8
|
+
exports.setBitcode = setBitcode;
|
|
9
|
+
exports.withCustomBitcode = exports.withBitcode = void 0;
|
|
10
|
+
|
|
11
|
+
function _iosPlugins() {
|
|
12
|
+
const data = require("../plugins/ios-plugins");
|
|
13
|
+
|
|
14
|
+
_iosPlugins = function () {
|
|
15
|
+
return data;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
return data;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function _warnings() {
|
|
22
|
+
const data = require("../utils/warnings");
|
|
23
|
+
|
|
24
|
+
_warnings = function () {
|
|
25
|
+
return data;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return data;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function _Xcodeproj() {
|
|
32
|
+
const data = require("./utils/Xcodeproj");
|
|
33
|
+
|
|
34
|
+
_Xcodeproj = function () {
|
|
35
|
+
return data;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return data;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Plugin to set a bitcode preference for the Xcode project
|
|
43
|
+
* based on the project's Expo config `ios.bitcode` value.
|
|
44
|
+
*/
|
|
45
|
+
const withBitcode = config => {
|
|
46
|
+
return (0, _iosPlugins().withXcodeProject)(config, async config => {
|
|
47
|
+
config.modResults = await setBitcodeWithConfig(config, {
|
|
48
|
+
project: config.modResults
|
|
49
|
+
});
|
|
50
|
+
return config;
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Plugin to set a custom bitcode preference for the Xcode project.
|
|
55
|
+
* Does not read from the Expo config `ios.bitcode`.
|
|
56
|
+
*
|
|
57
|
+
* @param bitcode custom bitcode setting.
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
exports.withBitcode = withBitcode;
|
|
62
|
+
|
|
63
|
+
const withCustomBitcode = (config, bitcode) => {
|
|
64
|
+
return (0, _iosPlugins().withXcodeProject)(config, async config => {
|
|
65
|
+
config.modResults = await setBitcode(bitcode, {
|
|
66
|
+
project: config.modResults
|
|
67
|
+
});
|
|
68
|
+
return config;
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Get the bitcode preference from the Expo config.
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
exports.withCustomBitcode = withCustomBitcode;
|
|
77
|
+
|
|
78
|
+
function getBitcode(config) {
|
|
79
|
+
var _config$ios;
|
|
80
|
+
|
|
81
|
+
return (_config$ios = config.ios) === null || _config$ios === void 0 ? void 0 : _config$ios.bitcode;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Enable or disable the `ENABLE_BITCODE` property of the project configurations.
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
function setBitcodeWithConfig(config, {
|
|
89
|
+
project
|
|
90
|
+
}) {
|
|
91
|
+
const bitcode = getBitcode(config);
|
|
92
|
+
return setBitcode(bitcode, {
|
|
93
|
+
project
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Enable or disable the `ENABLE_BITCODE` property.
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
function setBitcode(bitcode, {
|
|
102
|
+
project
|
|
103
|
+
}) {
|
|
104
|
+
const isDefaultBehavior = bitcode == null; // If the value is undefined, then do nothing.
|
|
105
|
+
|
|
106
|
+
if (isDefaultBehavior) {
|
|
107
|
+
return project;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const targetName = typeof bitcode === 'string' ? bitcode : undefined;
|
|
111
|
+
const isBitcodeEnabled = !!bitcode;
|
|
112
|
+
|
|
113
|
+
if (targetName) {
|
|
114
|
+
// Assert if missing
|
|
115
|
+
const configs = Object.entries(project.pbxXCBuildConfigurationSection()).filter(_Xcodeproj().isNotComment);
|
|
116
|
+
const hasConfiguration = configs.find(([, configuration]) => configuration.name === targetName);
|
|
117
|
+
|
|
118
|
+
if (hasConfiguration) {
|
|
119
|
+
// If targetName is defined then disable bitcode everywhere.
|
|
120
|
+
project.addBuildProperty('ENABLE_BITCODE', 'NO');
|
|
121
|
+
} else {
|
|
122
|
+
const names = [// Remove duplicates, wrap in double quotes, and sort alphabetically.
|
|
123
|
+
...new Set(configs.map(([, configuration]) => `"${configuration.name}"`))].sort();
|
|
124
|
+
(0, _warnings().addWarningIOS)('ios.bitcode', `No configuration named "${targetName}". Expected one of: ${names.join(', ')}.`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
project.addBuildProperty('ENABLE_BITCODE', isBitcodeEnabled ? 'YES' : 'NO', targetName);
|
|
129
|
+
return project;
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=Bitcode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ios/Bitcode.ts"],"names":["withBitcode","config","modResults","setBitcodeWithConfig","project","withCustomBitcode","bitcode","setBitcode","getBitcode","ios","isDefaultBehavior","targetName","undefined","isBitcodeEnabled","configs","Object","entries","pbxXCBuildConfigurationSection","filter","isNotComment","hasConfiguration","find","configuration","name","addBuildProperty","names","Set","map","sort","join"],"mappings":";;;;;;;;;;AAIA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAIA;AACA;AACA;AACA;AACO,MAAMA,WAAyB,GAAGC,MAAM,IAAI;AACjD,SAAO,oCAAiBA,MAAjB,EAAyB,MAAMA,MAAN,IAAgB;AAC9CA,IAAAA,MAAM,CAACC,UAAP,GAAoB,MAAMC,oBAAoB,CAACF,MAAD,EAAS;AACrDG,MAAAA,OAAO,EAAEH,MAAM,CAACC;AADqC,KAAT,CAA9C;AAGA,WAAOD,MAAP;AACD,GALM,CAAP;AAMD,CAPM;AASP;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMI,iBAAwC,GAAG,CAACJ,MAAD,EAASK,OAAT,KAAqB;AAC3E,SAAO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AAR,CAAyB,gBAAzB,EAA2C,IAA3C;AACD,KAHD,MAGO;AACL,YAAMC,KAAK,GAAG,CACZ;AACA,SAAG,IAAIC,GAAJ,CAAQZ,OAAO,CAACa,GAAR,CAAY,CAAC,GAAGL,aAAH,CAAD,KAAwB,IAAGA,aAAa,CAACC,IAAK,GAA1D,CAAR,CAFS,EAGZK,IAHY,EAAd;AAIA,qCACE,aADF,EAEG,2BAA0BjB,UAAW,uBAAsBc,KAAK,CAACI,IAAN,CAAW,IAAX,CAAiB,GAF/E;AAID;AACF;;AAEDzB,EAAAA,OAAO,CAACoB,gBAAR,CAAyB,gBAAzB,EAA2CX,gBAAgB,GAAG,KAAH,GAAW,IAAtE,EAA4EF,UAA5E;AAEA,SAAOP,OAAP;AACD","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport { XcodeProject } from 'xcode';\n\nimport { ConfigPlugin } from '../Plugin.types';\nimport { withXcodeProject } from '../plugins/ios-plugins';\nimport { addWarningIOS } from '../utils/warnings';\nimport { isNotComment } from './utils/Xcodeproj';\n\ntype Bitcode = NonNullable<ExpoConfig['ios']>['bitcode'];\n\n/**\n * Plugin to set a bitcode preference for the Xcode project\n * based on the project's Expo config `ios.bitcode` value.\n */\nexport const withBitcode: ConfigPlugin = config => {\n return withXcodeProject(config, async config => {\n config.modResults = await setBitcodeWithConfig(config, {\n project: config.modResults,\n });\n return config;\n });\n};\n\n/**\n * Plugin to set a custom bitcode preference for the Xcode project.\n * Does not read from the Expo config `ios.bitcode`.\n *\n * @param bitcode custom bitcode setting.\n */\nexport const withCustomBitcode: ConfigPlugin<Bitcode> = (config, bitcode) => {\n return withXcodeProject(config, async config => {\n config.modResults = await setBitcode(bitcode, {\n project: config.modResults,\n });\n return config;\n });\n};\n\n/**\n * Get the bitcode preference from the Expo config.\n */\nexport function getBitcode(config: Pick<ExpoConfig, 'ios'>): Bitcode {\n return config.ios?.bitcode;\n}\n\n/**\n * Enable or disable the `ENABLE_BITCODE` property of the project configurations.\n */\nexport function setBitcodeWithConfig(\n config: Pick<ExpoConfig, 'ios'>,\n { project }: { project: XcodeProject }\n): XcodeProject {\n const bitcode = getBitcode(config);\n return setBitcode(bitcode, { project });\n}\n\n/**\n * Enable or disable the `ENABLE_BITCODE` property.\n */\nexport function setBitcode(bitcode: Bitcode, { project }: { project: XcodeProject }): XcodeProject {\n const isDefaultBehavior = bitcode == null;\n // If the value is undefined, then do nothing.\n if (isDefaultBehavior) {\n return project;\n }\n\n const targetName = typeof bitcode === 'string' ? bitcode : undefined;\n const isBitcodeEnabled = !!bitcode;\n if (targetName) {\n // Assert if missing\n const configs = Object.entries(project.pbxXCBuildConfigurationSection()).filter(isNotComment);\n const hasConfiguration = configs.find(([, configuration]) => configuration.name === targetName);\n if (hasConfiguration) {\n // If targetName is defined then disable bitcode everywhere.\n project.addBuildProperty('ENABLE_BITCODE', 'NO');\n } else {\n const names = [\n // Remove duplicates, wrap in double quotes, and sort alphabetically.\n ...new Set(configs.map(([, configuration]) => `\"${configuration.name}\"`)),\n ].sort();\n addWarningIOS(\n 'ios.bitcode',\n `No configuration named \"${targetName}\". Expected one of: ${names.join(', ')}.`\n );\n }\n }\n\n project.addBuildProperty('ENABLE_BITCODE', isBitcodeEnabled ? 'YES' : 'NO', targetName);\n\n return project;\n}\n"],"file":"Bitcode.js"}
|
package/build/ios/Maps.js
CHANGED
|
@@ -75,6 +75,7 @@ function _resolvePackageRootFolder() {
|
|
|
75
75
|
|
|
76
76
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
77
77
|
|
|
78
|
+
// Match against `UMModuleRegistryAdapter` (unimodules), and React Native without unimodules (Expo Modules).
|
|
78
79
|
const MATCH_INIT = /(?:(self\.|_)(\w+)\s?=\s?\[\[UMModuleRegistryAdapter alloc\])|(?:RCTBridge\s?\*\s?(\w+)\s?=\s?\[\[RCTBridge alloc\])/g;
|
|
79
80
|
exports.MATCH_INIT = MATCH_INIT;
|
|
80
81
|
const withGoogleMapsKey = (0, _iosPlugins().createInfoPlistPlugin)(setGoogleMapsApiKey, 'withGoogleMapsKey');
|
package/build/ios/Maps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ios/Maps.ts"],"names":["MATCH_INIT","withGoogleMapsKey","setGoogleMapsApiKey","withMaps","config","apiKey","getGoogleMapsApiKey","withMapsCocoaPods","useGoogleMaps","withGoogleMapsAppDelegate","ios","googleMapsApiKey","GMSApiKey","infoPlist","addGoogleMapsAppDelegateImport","src","newSrc","push","tag","join","anchor","offset","comment","removeGoogleMapsAppDelegateImport","addGoogleMapsAppDelegateInit","removeGoogleMapsAppDelegateInit","addMapsCocoaPods","googleMapsPath","removeMapsCocoaPods","isReactNativeMapsInstalled","projectRoot","filePath","path","modRequest","platformProjectRoot","contents","fs","readFile","results","googleMapsPodPath","relative","error","code","Error","didMerge","didClear","writeFile","modResults","language"],"mappings":";;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAEO,MAAMA,UAAU,GAAG,uHAAnB;;AAEP,MAAMC,iBAAiB,GAAG,yCAAsBC,mBAAtB,EAA2C,mBAA3C,CAA1B;;AAEO,MAAMC,QAAsB,GAAGC,MAAM,IAAI;AAC9CA,EAAAA,MAAM,GAAGH,iBAAiB,CAACG,MAAD,CAA1B;AAEA,QAAMC,MAAM,GAAGC,mBAAmB,CAACF,MAAD,CAAlC,CAH8C,CAI9C;;AACAA,EAAAA,MAAM,GAAGG,iBAAiB,CAACH,MAAD,EAAS;AAAEI,IAAAA,aAAa,EAAE,CAAC,CAACH;AAAnB,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xC,EAAyE;AACvE,YAAI;AACF1B,UAAAA,MAAM,CAAC2C,UAAP,CAAkBZ,QAAlB,GAA6BrB,8BAA8B,CACzDV,MAAM,CAAC2C,UAAP,CAAkBZ,QADuC,CAA9B,CAE3BA,QAFF;AAGA/B,UAAAA,MAAM,CAAC2C,UAAP,CAAkBZ,QAAlB,GAA6BX,4BAA4B,CACvDpB,MAAM,CAAC2C,UAAP,CAAkBZ,QADqC,EAEvD9B,MAFuD,CAA5B,CAG3B8B,QAHF;AAID,SARD,CAQE,OAAOM,KAAP,EAAc;AACd,cAAIA,KAAK,CAACC,IAAN,KAAe,cAAnB,EAAmC;AACjC,kBAAM,IAAIC,KAAJ,CACH,yIADG,CAAN;AAGD;;AACD,gBAAMF,KAAN;AACD;AACF,OAjBD,MAiBO;AACLrC,QAAAA,MAAM,CAAC2C,UAAP,CAAkBZ,QAAlB,GAA6BZ,iCAAiC,CAC5DnB,MAAM,CAAC2C,UAAP,CAAkBZ,QAD0C,CAAjC,CAE3BA,QAFF;AAGA/B,QAAAA,MAAM,CAAC2C,UAAP,CAAkBZ,QAAlB,GAA6BV,+BAA+B,CAC1DrB,MAAM,CAAC2C,UAAP,CAAkBZ,QADwC,CAA/B,CAE3BA,QAFF;AAGD;AACF,KA1BD,MA0BO;AACL,YAAM,IAAIQ,KAAJ,CAAU,qEAAV,CAAN;AACD;;AACD,WAAOvC,MAAP;AACD,GA/BM,CAAP;AAgCD,CAjCD","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nimport { ConfigPlugin, InfoPlist } from '../Plugin.types';\nimport { createInfoPlistPlugin, withAppDelegate } from '../plugins/ios-plugins';\nimport { withDangerousMod } from '../plugins/withDangerousMod';\nimport { mergeContents, MergeResults, removeContents } from '../utils/generateCode';\nimport { resolvePackageRootFolder } from '../utils/resolvePackageRootFolder';\n\nexport const MATCH_INIT = /(?:(self\\.|_)(\\w+)\\s?=\\s?\\[\\[UMModuleRegistryAdapter alloc\\])|(?:RCTBridge\\s?\\*\\s?(\\w+)\\s?=\\s?\\[\\[RCTBridge alloc\\])/g;\n\nconst withGoogleMapsKey = createInfoPlistPlugin(setGoogleMapsApiKey, 'withGoogleMapsKey');\n\nexport const withMaps: ConfigPlugin = config => {\n config = withGoogleMapsKey(config);\n\n const apiKey = getGoogleMapsApiKey(config);\n // Technically adds react-native-maps (Apple maps) and google maps.\n config = withMapsCocoaPods(config, { useGoogleMaps: !!apiKey });\n // Adds/Removes AppDelegate setup for Google Maps API on iOS\n config = withGoogleMapsAppDelegate(config, { apiKey });\n\n return config;\n};\n\nexport function getGoogleMapsApiKey(config: Pick<ExpoConfig, 'ios'>) {\n return config.ios?.config?.googleMapsApiKey ?? null;\n}\n\nexport function setGoogleMapsApiKey(\n config: Pick<ExpoConfig, 'ios'>,\n { GMSApiKey, ...infoPlist }: InfoPlist\n): InfoPlist {\n const apiKey = getGoogleMapsApiKey(config);\n\n if (apiKey === null) {\n return infoPlist;\n }\n\n return {\n ...infoPlist,\n GMSApiKey: apiKey,\n };\n}\n\nexport function addGoogleMapsAppDelegateImport(src: string): MergeResults {\n const newSrc = [];\n newSrc.push(\n '#if __has_include(<GoogleMaps/GoogleMaps.h>)',\n '#import <GoogleMaps/GoogleMaps.h>',\n '#endif'\n );\n\n return mergeContents({\n tag: 'react-native-maps-import',\n src,\n newSrc: newSrc.join('\\n'),\n anchor: /#import \"AppDelegate\\.h\"/,\n offset: 1,\n comment: '//',\n });\n}\n\nexport function removeGoogleMapsAppDelegateImport(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps-import',\n src,\n });\n}\n\nexport function addGoogleMapsAppDelegateInit(src: string, apiKey: string): MergeResults {\n const newSrc = [];\n newSrc.push(\n '#if __has_include(<GoogleMaps/GoogleMaps.h>)',\n ` [GMSServices provideAPIKey:@\"${apiKey}\"];`,\n '#endif'\n );\n\n return mergeContents({\n tag: 'react-native-maps-init',\n src,\n newSrc: newSrc.join('\\n'),\n anchor: MATCH_INIT,\n offset: 0,\n comment: '//',\n });\n}\n\nexport function removeGoogleMapsAppDelegateInit(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps-init',\n src,\n });\n}\n\n/**\n * @param src\n * @param useGoogleMaps\n * @param googleMapsPath '../node_modules/react-native-maps'\n * @returns\n */\nexport function addMapsCocoaPods(src: string, googleMapsPath: string): MergeResults {\n return mergeContents({\n tag: 'react-native-maps',\n src,\n newSrc: ` pod 'react-native-google-maps', path: '${googleMapsPath}'`,\n anchor: /use_native_modules/,\n offset: 0,\n comment: '#',\n });\n}\n\nexport function removeMapsCocoaPods(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps',\n src,\n });\n}\n\nfunction isReactNativeMapsInstalled(projectRoot: string): string | null {\n return resolvePackageRootFolder(projectRoot, 'react-native-maps');\n}\n\nconst withMapsCocoaPods: ConfigPlugin<{ useGoogleMaps: boolean }> = (config, { useGoogleMaps }) => {\n return withDangerousMod(config, [\n 'ios',\n async config => {\n const filePath = path.join(config.modRequest.platformProjectRoot, 'Podfile');\n const contents = await fs.readFile(filePath, 'utf-8');\n let results: MergeResults;\n // Only add the block if react-native-maps is installed in the project (best effort).\n // Generally prebuild runs after a yarn install so this should always work as expected.\n const googleMapsPath = isReactNativeMapsInstalled(config.modRequest.projectRoot);\n if (googleMapsPath && useGoogleMaps) {\n // Make the pod path relative to the ios folder.\n const googleMapsPodPath = path.relative(\n config.modRequest.platformProjectRoot,\n googleMapsPath\n );\n try {\n results = addMapsCocoaPods(contents, googleMapsPodPath);\n } catch (error) {\n if (error.code === 'ERR_NO_MATCH') {\n throw new Error(\n `Cannot add react-native-maps to the project's ios/Podfile because it's malformed. Please report this with a copy of your project Podfile.`\n );\n }\n throw error;\n }\n } else {\n // If the package is no longer installed, then remove the block.\n results = removeMapsCocoaPods(contents);\n }\n if (results.didMerge || results.didClear) {\n await fs.writeFile(filePath, results.contents);\n }\n return config;\n },\n ]);\n};\n\nconst withGoogleMapsAppDelegate: ConfigPlugin<{ apiKey: string | null }> = (config, { apiKey }) => {\n return withAppDelegate(config, config => {\n if (config.modResults.language === 'objc') {\n if (apiKey && isReactNativeMapsInstalled(config.modRequest.projectRoot)) {\n try {\n config.modResults.contents = addGoogleMapsAppDelegateImport(\n config.modResults.contents\n ).contents;\n config.modResults.contents = addGoogleMapsAppDelegateInit(\n config.modResults.contents,\n apiKey\n ).contents;\n } catch (error) {\n if (error.code === 'ERR_NO_MATCH') {\n throw new Error(\n `Cannot add Google Maps to the project's AppDelegate because it's malformed. Please report this with a copy of your project AppDelegate.`\n );\n }\n throw error;\n }\n } else {\n config.modResults.contents = removeGoogleMapsAppDelegateImport(\n config.modResults.contents\n ).contents;\n config.modResults.contents = removeGoogleMapsAppDelegateInit(\n config.modResults.contents\n ).contents;\n }\n } else {\n throw new Error('Cannot setup Google Maps because the AppDelegate is not Objective C');\n }\n return config;\n });\n};\n"],"file":"Maps.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/ios/Maps.ts"],"names":["MATCH_INIT","withGoogleMapsKey","setGoogleMapsApiKey","withMaps","config","apiKey","getGoogleMapsApiKey","withMapsCocoaPods","useGoogleMaps","withGoogleMapsAppDelegate","ios","googleMapsApiKey","GMSApiKey","infoPlist","addGoogleMapsAppDelegateImport","src","newSrc","push","tag","join","anchor","offset","comment","removeGoogleMapsAppDelegateImport","addGoogleMapsAppDelegateInit","removeGoogleMapsAppDelegateInit","addMapsCocoaPods","googleMapsPath","removeMapsCocoaPods","isReactNativeMapsInstalled","projectRoot","filePath","path","modRequest","platformProjectRoot","contents","fs","readFile","results","googleMapsPodPath","relative","error","code","Error","didMerge","didClear","writeFile","modResults","language"],"mappings":";;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAC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AGD;AACF,KA1BD,MA0BO;AACL,YAAM,IAAIQ,KAAJ,CAAU,qEAAV,CAAN;AACD;;AACD,WAAOvC,MAAP;AACD,GA/BM,CAAP;AAgCD,CAjCD","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nimport { ConfigPlugin, InfoPlist } from '../Plugin.types';\nimport { createInfoPlistPlugin, withAppDelegate } from '../plugins/ios-plugins';\nimport { withDangerousMod } from '../plugins/withDangerousMod';\nimport { mergeContents, MergeResults, removeContents } from '../utils/generateCode';\nimport { resolvePackageRootFolder } from '../utils/resolvePackageRootFolder';\n\n// Match against `UMModuleRegistryAdapter` (unimodules), and React Native without unimodules (Expo Modules).\nexport const MATCH_INIT = /(?:(self\\.|_)(\\w+)\\s?=\\s?\\[\\[UMModuleRegistryAdapter alloc\\])|(?:RCTBridge\\s?\\*\\s?(\\w+)\\s?=\\s?\\[\\[RCTBridge alloc\\])/g;\n\nconst withGoogleMapsKey = createInfoPlistPlugin(setGoogleMapsApiKey, 'withGoogleMapsKey');\n\nexport const withMaps: ConfigPlugin = config => {\n config = withGoogleMapsKey(config);\n\n const apiKey = getGoogleMapsApiKey(config);\n // Technically adds react-native-maps (Apple maps) and google maps.\n config = withMapsCocoaPods(config, { useGoogleMaps: !!apiKey });\n // Adds/Removes AppDelegate setup for Google Maps API on iOS\n config = withGoogleMapsAppDelegate(config, { apiKey });\n\n return config;\n};\n\nexport function getGoogleMapsApiKey(config: Pick<ExpoConfig, 'ios'>) {\n return config.ios?.config?.googleMapsApiKey ?? null;\n}\n\nexport function setGoogleMapsApiKey(\n config: Pick<ExpoConfig, 'ios'>,\n { GMSApiKey, ...infoPlist }: InfoPlist\n): InfoPlist {\n const apiKey = getGoogleMapsApiKey(config);\n\n if (apiKey === null) {\n return infoPlist;\n }\n\n return {\n ...infoPlist,\n GMSApiKey: apiKey,\n };\n}\n\nexport function addGoogleMapsAppDelegateImport(src: string): MergeResults {\n const newSrc = [];\n newSrc.push(\n '#if __has_include(<GoogleMaps/GoogleMaps.h>)',\n '#import <GoogleMaps/GoogleMaps.h>',\n '#endif'\n );\n\n return mergeContents({\n tag: 'react-native-maps-import',\n src,\n newSrc: newSrc.join('\\n'),\n anchor: /#import \"AppDelegate\\.h\"/,\n offset: 1,\n comment: '//',\n });\n}\n\nexport function removeGoogleMapsAppDelegateImport(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps-import',\n src,\n });\n}\n\nexport function addGoogleMapsAppDelegateInit(src: string, apiKey: string): MergeResults {\n const newSrc = [];\n newSrc.push(\n '#if __has_include(<GoogleMaps/GoogleMaps.h>)',\n ` [GMSServices provideAPIKey:@\"${apiKey}\"];`,\n '#endif'\n );\n\n return mergeContents({\n tag: 'react-native-maps-init',\n src,\n newSrc: newSrc.join('\\n'),\n anchor: MATCH_INIT,\n offset: 0,\n comment: '//',\n });\n}\n\nexport function removeGoogleMapsAppDelegateInit(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps-init',\n src,\n });\n}\n\n/**\n * @param src\n * @param useGoogleMaps\n * @param googleMapsPath '../node_modules/react-native-maps'\n * @returns\n */\nexport function addMapsCocoaPods(src: string, googleMapsPath: string): MergeResults {\n return mergeContents({\n tag: 'react-native-maps',\n src,\n newSrc: ` pod 'react-native-google-maps', path: '${googleMapsPath}'`,\n anchor: /use_native_modules/,\n offset: 0,\n comment: '#',\n });\n}\n\nexport function removeMapsCocoaPods(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps',\n src,\n });\n}\n\nfunction isReactNativeMapsInstalled(projectRoot: string): string | null {\n return resolvePackageRootFolder(projectRoot, 'react-native-maps');\n}\n\nconst withMapsCocoaPods: ConfigPlugin<{ useGoogleMaps: boolean }> = (config, { useGoogleMaps }) => {\n return withDangerousMod(config, [\n 'ios',\n async config => {\n const filePath = path.join(config.modRequest.platformProjectRoot, 'Podfile');\n const contents = await fs.readFile(filePath, 'utf-8');\n let results: MergeResults;\n // Only add the block if react-native-maps is installed in the project (best effort).\n // Generally prebuild runs after a yarn install so this should always work as expected.\n const googleMapsPath = isReactNativeMapsInstalled(config.modRequest.projectRoot);\n if (googleMapsPath && useGoogleMaps) {\n // Make the pod path relative to the ios folder.\n const googleMapsPodPath = path.relative(\n config.modRequest.platformProjectRoot,\n googleMapsPath\n );\n try {\n results = addMapsCocoaPods(contents, googleMapsPodPath);\n } catch (error) {\n if (error.code === 'ERR_NO_MATCH') {\n throw new Error(\n `Cannot add react-native-maps to the project's ios/Podfile because it's malformed. Please report this with a copy of your project Podfile.`\n );\n }\n throw error;\n }\n } else {\n // If the package is no longer installed, then remove the block.\n results = removeMapsCocoaPods(contents);\n }\n if (results.didMerge || results.didClear) {\n await fs.writeFile(filePath, results.contents);\n }\n return config;\n },\n ]);\n};\n\nconst withGoogleMapsAppDelegate: ConfigPlugin<{ apiKey: string | null }> = (config, { apiKey }) => {\n return withAppDelegate(config, config => {\n if (config.modResults.language === 'objc') {\n if (apiKey && isReactNativeMapsInstalled(config.modRequest.projectRoot)) {\n try {\n config.modResults.contents = addGoogleMapsAppDelegateImport(\n config.modResults.contents\n ).contents;\n config.modResults.contents = addGoogleMapsAppDelegateInit(\n config.modResults.contents,\n apiKey\n ).contents;\n } catch (error) {\n if (error.code === 'ERR_NO_MATCH') {\n throw new Error(\n `Cannot add Google Maps to the project's AppDelegate because it's malformed. Please report this with a copy of your project AppDelegate.`\n );\n }\n throw error;\n }\n } else {\n config.modResults.contents = removeGoogleMapsAppDelegateImport(\n config.modResults.contents\n ).contents;\n config.modResults.contents = removeGoogleMapsAppDelegateInit(\n config.modResults.contents\n ).contents;\n }\n } else {\n throw new Error('Cannot setup Google Maps because the AppDelegate is not Objective C');\n }\n return config;\n });\n};\n"],"file":"Maps.js"}
|
package/build/ios/Paths.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ interface ProjectFile<L extends string = string> {
|
|
|
6
6
|
export declare type AppDelegateProjectFile = ProjectFile<'objc' | 'swift'>;
|
|
7
7
|
export declare function getAppDelegateHeaderFilePath(projectRoot: string): string;
|
|
8
8
|
export declare function getAppDelegateFilePath(projectRoot: string): string;
|
|
9
|
+
export declare function getAppDelegateObjcHeaderFilePath(projectRoot: string): string;
|
|
9
10
|
export declare function getFileInfo(filePath: string): {
|
|
10
11
|
path: string;
|
|
11
12
|
contents: string;
|
package/build/ios/Paths.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getAppDelegateHeaderFilePath = getAppDelegateHeaderFilePath;
|
|
7
7
|
exports.getAppDelegateFilePath = getAppDelegateFilePath;
|
|
8
|
+
exports.getAppDelegateObjcHeaderFilePath = getAppDelegateObjcHeaderFilePath;
|
|
8
9
|
exports.getFileInfo = getFileInfo;
|
|
9
10
|
exports.getAppDelegate = getAppDelegate;
|
|
10
11
|
exports.getSourceRoot = getSourceRoot;
|
|
@@ -125,6 +126,30 @@ function getAppDelegateFilePath(projectRoot) {
|
|
|
125
126
|
return using;
|
|
126
127
|
}
|
|
127
128
|
|
|
129
|
+
function getAppDelegateObjcHeaderFilePath(projectRoot) {
|
|
130
|
+
const [using, ...extra] = (0, _glob().sync)('ios/*/AppDelegate.h', {
|
|
131
|
+
absolute: true,
|
|
132
|
+
cwd: projectRoot,
|
|
133
|
+
ignore: ignoredPaths
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
if (!using) {
|
|
137
|
+
throw new (_errors().UnexpectedError)(`Could not locate a valid AppDelegate.h at root: "${projectRoot}"`);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (extra.length) {
|
|
141
|
+
warnMultipleFiles({
|
|
142
|
+
tag: 'app-delegate-objc-header',
|
|
143
|
+
fileName: 'AppDelegate.h',
|
|
144
|
+
projectRoot,
|
|
145
|
+
using,
|
|
146
|
+
extra
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return using;
|
|
151
|
+
}
|
|
152
|
+
|
|
128
153
|
function getLanguage(filePath) {
|
|
129
154
|
const extension = path().extname(filePath);
|
|
130
155
|
|
package/build/ios/Paths.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ios/Paths.ts"],"names":["ignoredPaths","getAppDelegateHeaderFilePath","projectRoot","using","extra","absolute","cwd","ignore","UnexpectedError","length","warnMultipleFiles","tag","fileName","getAppDelegateFilePath","getLanguage","filePath","extension","path","extname","getFileInfo","normalize","contents","language","getAppDelegate","getSourceRoot","appDelegate","dirname","findSchemePaths","findSchemeNames","schemePaths","map","schemePath","basename","split","getAllXcodeProjectPaths","iosFolder","pbxprojPaths","filter","project","test","sort","value","join","getXcodeProjectPath","getAllPBXProjectPaths","projectPaths","paths","getPBXProjectPath","getAllInfoPlistPaths","a","b","getInfoPlistPath","getAllEntitlementsPaths","getEntitlementsPath","getSupportingPath","resolve","getExpoPlistPath","supportingPath","usingPath","relative","extraPaths","v","JSON","stringify"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;AAEA,MAAMA,YAAY,GAAG,CAAC,4CAAD,CAArB;;AAUO,SAASC,4BAAT,CAAsCC,WAAtC,EAAmE;AACxE,QAAM,CAACC,KAAD,EAAQ,GAAGC,KAAX,IAAoB,kBAAS,qBAAT,EAAgC;AACxDC,IAAAA,QAAQ,EAAE,IAD8C;AAExDC,IAAAA,GAAG,EAAEJ,WAFmD;AAGxDK,IAAAA,MAAM,EAAEP;AAHgD,GAAhC,CAA1B;;AAMA,MAAI,CAACG,KAAL,EAAY;AACV,UAAM,KAAIK,yBAAJ,EACH,yDAAwDN,WAAY,GADjE,CA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AA2BC,KAA3B,CAAH,GAAuCA,KAApE;AACA,QAAMyD,UAAU,GAAG1D,WAAW,GAAGE,KAAK,CAAC0B,GAAN,CAAU+B,CAAC,IAAI5C,IAAI,GAAC0C,QAAL,CAAczD,WAAd,EAA2B2D,CAA3B,CAAf,CAAH,GAAmDzD,KAAjF;AACA,iCACG,SAAQO,GAAI,EADf,EAEG,kBAAiBC,QAAS,uBAAsB8C,SAAU,qBAAoBI,IAAI,CAACC,SAAL,CAC7EH,UAD6E,CAE7E,EAJJ;AAMD","sourcesContent":["import { pathExistsSync, readFileSync } from 'fs-extra';\nimport { sync as globSync } from 'glob';\nimport * as path from 'path';\n\nimport { UnexpectedError } from '../utils/errors';\nimport { addWarningIOS } from '../utils/warnings';\n\nconst ignoredPaths = ['**/@(Carthage|Pods|vendor|node_modules)/**'];\n\ninterface ProjectFile<L extends string = string> {\n path: string;\n language: L;\n contents: string;\n}\n\nexport type AppDelegateProjectFile = ProjectFile<'objc' | 'swift'>;\n\nexport function getAppDelegateHeaderFilePath(projectRoot: string): string {\n const [using, ...extra] = globSync('ios/*/AppDelegate.h', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n\n if (!using) {\n throw new UnexpectedError(\n `Could not locate a valid AppDelegate header at root: \"${projectRoot}\"`\n );\n }\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'app-delegate-header',\n fileName: 'AppDelegate',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAppDelegateFilePath(projectRoot: string): string {\n const [using, ...extra] = globSync('ios/*/AppDelegate.@(m|swift)', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n\n if (!using) {\n throw new UnexpectedError(`Could not locate a valid AppDelegate at root: \"${projectRoot}\"`);\n }\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'app-delegate',\n fileName: 'AppDelegate',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nfunction getLanguage(filePath: string): 'objc' | 'swift' {\n const extension = path.extname(filePath);\n switch (extension) {\n case '.m':\n case '.h':\n return 'objc';\n case '.swift':\n return 'swift';\n default:\n throw new UnexpectedError(`Unexpected iOS file extension: ${extension}`);\n }\n}\n\nexport function getFileInfo(filePath: string) {\n return {\n path: path.normalize(filePath),\n contents: readFileSync(filePath, 'utf8'),\n language: getLanguage(filePath),\n };\n}\n\nexport function getAppDelegate(projectRoot: string): AppDelegateProjectFile {\n const filePath = getAppDelegateFilePath(projectRoot);\n return getFileInfo(filePath);\n}\n\nexport function getSourceRoot(projectRoot: string): string {\n const appDelegate = getAppDelegate(projectRoot);\n return path.dirname(appDelegate.path);\n}\n\nexport function findSchemePaths(projectRoot: string): string[] {\n return globSync('ios/*.xcodeproj/xcshareddata/xcschemes/*.xcscheme', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n}\n\nexport function findSchemeNames(projectRoot: string): string[] {\n const schemePaths = findSchemePaths(projectRoot);\n return schemePaths.map(schemePath => path.basename(schemePath).split('.')[0]);\n}\n\nexport function getAllXcodeProjectPaths(projectRoot: string): string[] {\n const iosFolder = 'ios';\n const pbxprojPaths = globSync('**/*.xcodeproj', { cwd: projectRoot, ignore: ignoredPaths })\n .filter(project => !/test|example|sample/i.test(project) || path.dirname(project) === iosFolder)\n .sort(project => (path.dirname(project) === iosFolder ? -1 : 1))\n // sort alphabetically to ensure this works the same across different devices (Fail in CI (linux) without this)\n .sort();\n\n if (!pbxprojPaths.length) {\n throw new UnexpectedError(\n `Failed to locate the ios/*.xcodeproj files relative to path \"${projectRoot}\".`\n );\n }\n return pbxprojPaths.map(value => path.join(projectRoot, value));\n}\n\n/**\n * Get the pbxproj for the given path\n */\nexport function getXcodeProjectPath(projectRoot: string): string {\n const [using, ...extra] = getAllXcodeProjectPaths(projectRoot);\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'xcodeproj',\n fileName: '*.xcodeproj',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAllPBXProjectPaths(projectRoot: string): string[] {\n const projectPaths = getAllXcodeProjectPaths(projectRoot);\n const paths = projectPaths\n .map(value => path.join(value, 'project.pbxproj'))\n .filter(value => pathExistsSync(value));\n\n if (!paths.length) {\n throw new UnexpectedError(\n `Failed to locate the ios/*.xcodeproj/project.pbxproj files relative to path \"${projectRoot}\".`\n );\n }\n return paths;\n}\n\nexport function getPBXProjectPath(projectRoot: string): string {\n const [using, ...extra] = getAllPBXProjectPaths(projectRoot);\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'project-pbxproj',\n fileName: 'project.pbxproj',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAllInfoPlistPaths(projectRoot: string): string[] {\n const paths = globSync('ios/*/Info.plist', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n }).sort(\n // longer name means more suffixes, we want the shortest possible one to be first.\n (a, b) => a.length - b.length\n );\n\n if (!paths.length) {\n throw new UnexpectedError(\n `Failed to locate Info.plist files relative to path \"${projectRoot}\".`\n );\n }\n return paths;\n}\n\nexport function getInfoPlistPath(projectRoot: string): string {\n const [using, ...extra] = getAllInfoPlistPaths(projectRoot);\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'info-plist',\n fileName: 'Info.plist',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAllEntitlementsPaths(projectRoot: string): string[] {\n const paths = globSync('ios/*/*.entitlements', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n return paths;\n}\n\n/**\n * Get the entitlements file path if it exists.\n *\n * @param projectRoot\n */\nexport function getEntitlementsPath(projectRoot: string): string | null {\n const [using, ...extra] = getAllEntitlementsPaths(projectRoot);\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'entitlements',\n fileName: '*.entitlements',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using ?? null;\n}\n\nexport function getSupportingPath(projectRoot: string): string {\n return path.resolve(projectRoot, 'ios', path.basename(getSourceRoot(projectRoot)), 'Supporting');\n}\n\nexport function getExpoPlistPath(projectRoot: string): string {\n const supportingPath = getSupportingPath(projectRoot);\n return path.join(supportingPath, 'Expo.plist');\n}\n\nfunction warnMultipleFiles({\n tag,\n fileName,\n projectRoot,\n using,\n extra,\n}: {\n tag: string;\n fileName: string;\n projectRoot?: string;\n using: string;\n extra: string[];\n}) {\n const usingPath = projectRoot ? path.relative(projectRoot, using) : using;\n const extraPaths = projectRoot ? extra.map(v => path.relative(projectRoot, v)) : extra;\n addWarningIOS(\n `paths-${tag}`,\n `Found multiple ${fileName} file paths, using \"${usingPath}\". Ignored paths: ${JSON.stringify(\n extraPaths\n )}`\n );\n}\n"],"file":"Paths.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/ios/Paths.ts"],"names":["ignoredPaths","getAppDelegateHeaderFilePath","projectRoot","using","extra","absolute","cwd","ignore","UnexpectedError","length","warnMultipleFiles","tag","fileName","getAppDelegateFilePath","getAppDelegateObjcHeaderFilePath","getLanguage","filePath","extension","path","extname","getFileInfo","normalize","contents","language","getAppDelegate","getSourceRoot","appDelegate","dirname","findSchemePaths","findSchemeNames","schemePaths","map","schemePath","basename","split","getAllXcodeProjectPaths","iosFolder","pbxprojPaths","filter","project","test","sort","value","join","getXcodeProjectPath","getAllPBXProjectPaths","projectPaths","paths","getPBXProjectPath","getAllInfoPlistPaths","a","b","getInfoPlistPath","getAllEntitlementsPaths","getEntitlementsPath","getSupportingPath","resolve","getExpoPlistPath","supportingPath","usingPath","relative","extraPaths","v","JSON","stringify"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;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BAAoBI,IAAI,CAACC,SAAL,CAC7EH,UAD6E,CAE7E,EAJJ;AAMD","sourcesContent":["import { pathExistsSync, readFileSync } from 'fs-extra';\nimport { sync as globSync } from 'glob';\nimport * as path from 'path';\n\nimport { UnexpectedError } from '../utils/errors';\nimport { addWarningIOS } from '../utils/warnings';\n\nconst ignoredPaths = ['**/@(Carthage|Pods|vendor|node_modules)/**'];\n\ninterface ProjectFile<L extends string = string> {\n path: string;\n language: L;\n contents: string;\n}\n\nexport type AppDelegateProjectFile = ProjectFile<'objc' | 'swift'>;\n\nexport function getAppDelegateHeaderFilePath(projectRoot: string): string {\n const [using, ...extra] = globSync('ios/*/AppDelegate.h', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n\n if (!using) {\n throw new UnexpectedError(\n `Could not locate a valid AppDelegate header at root: \"${projectRoot}\"`\n );\n }\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'app-delegate-header',\n fileName: 'AppDelegate',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAppDelegateFilePath(projectRoot: string): string {\n const [using, ...extra] = globSync('ios/*/AppDelegate.@(m|swift)', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n\n if (!using) {\n throw new UnexpectedError(`Could not locate a valid AppDelegate at root: \"${projectRoot}\"`);\n }\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'app-delegate',\n fileName: 'AppDelegate',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAppDelegateObjcHeaderFilePath(projectRoot: string): string {\n const [using, ...extra] = globSync('ios/*/AppDelegate.h', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n\n if (!using) {\n throw new UnexpectedError(`Could not locate a valid AppDelegate.h at root: \"${projectRoot}\"`);\n }\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'app-delegate-objc-header',\n fileName: 'AppDelegate.h',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nfunction getLanguage(filePath: string): 'objc' | 'swift' {\n const extension = path.extname(filePath);\n switch (extension) {\n case '.m':\n case '.h':\n return 'objc';\n case '.swift':\n return 'swift';\n default:\n throw new UnexpectedError(`Unexpected iOS file extension: ${extension}`);\n }\n}\n\nexport function getFileInfo(filePath: string) {\n return {\n path: path.normalize(filePath),\n contents: readFileSync(filePath, 'utf8'),\n language: getLanguage(filePath),\n };\n}\n\nexport function getAppDelegate(projectRoot: string): AppDelegateProjectFile {\n const filePath = getAppDelegateFilePath(projectRoot);\n return getFileInfo(filePath);\n}\n\nexport function getSourceRoot(projectRoot: string): string {\n const appDelegate = getAppDelegate(projectRoot);\n return path.dirname(appDelegate.path);\n}\n\nexport function findSchemePaths(projectRoot: string): string[] {\n return globSync('ios/*.xcodeproj/xcshareddata/xcschemes/*.xcscheme', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n}\n\nexport function findSchemeNames(projectRoot: string): string[] {\n const schemePaths = findSchemePaths(projectRoot);\n return schemePaths.map(schemePath => path.basename(schemePath).split('.')[0]);\n}\n\nexport function getAllXcodeProjectPaths(projectRoot: string): string[] {\n const iosFolder = 'ios';\n const pbxprojPaths = globSync('**/*.xcodeproj', { cwd: projectRoot, ignore: ignoredPaths })\n .filter(project => !/test|example|sample/i.test(project) || path.dirname(project) === iosFolder)\n .sort(project => (path.dirname(project) === iosFolder ? -1 : 1))\n // sort alphabetically to ensure this works the same across different devices (Fail in CI (linux) without this)\n .sort();\n\n if (!pbxprojPaths.length) {\n throw new UnexpectedError(\n `Failed to locate the ios/*.xcodeproj files relative to path \"${projectRoot}\".`\n );\n }\n return pbxprojPaths.map(value => path.join(projectRoot, value));\n}\n\n/**\n * Get the pbxproj for the given path\n */\nexport function getXcodeProjectPath(projectRoot: string): string {\n const [using, ...extra] = getAllXcodeProjectPaths(projectRoot);\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'xcodeproj',\n fileName: '*.xcodeproj',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAllPBXProjectPaths(projectRoot: string): string[] {\n const projectPaths = getAllXcodeProjectPaths(projectRoot);\n const paths = projectPaths\n .map(value => path.join(value, 'project.pbxproj'))\n .filter(value => pathExistsSync(value));\n\n if (!paths.length) {\n throw new UnexpectedError(\n `Failed to locate the ios/*.xcodeproj/project.pbxproj files relative to path \"${projectRoot}\".`\n );\n }\n return paths;\n}\n\nexport function getPBXProjectPath(projectRoot: string): string {\n const [using, ...extra] = getAllPBXProjectPaths(projectRoot);\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'project-pbxproj',\n fileName: 'project.pbxproj',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAllInfoPlistPaths(projectRoot: string): string[] {\n const paths = globSync('ios/*/Info.plist', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n }).sort(\n // longer name means more suffixes, we want the shortest possible one to be first.\n (a, b) => a.length - b.length\n );\n\n if (!paths.length) {\n throw new UnexpectedError(\n `Failed to locate Info.plist files relative to path \"${projectRoot}\".`\n );\n }\n return paths;\n}\n\nexport function getInfoPlistPath(projectRoot: string): string {\n const [using, ...extra] = getAllInfoPlistPaths(projectRoot);\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'info-plist',\n fileName: 'Info.plist',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAllEntitlementsPaths(projectRoot: string): string[] {\n const paths = globSync('ios/*/*.entitlements', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n return paths;\n}\n\n/**\n * Get the entitlements file path if it exists.\n *\n * @param projectRoot\n */\nexport function getEntitlementsPath(projectRoot: string): string | null {\n const [using, ...extra] = getAllEntitlementsPaths(projectRoot);\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'entitlements',\n fileName: '*.entitlements',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using ?? null;\n}\n\nexport function getSupportingPath(projectRoot: string): string {\n return path.resolve(projectRoot, 'ios', path.basename(getSourceRoot(projectRoot)), 'Supporting');\n}\n\nexport function getExpoPlistPath(projectRoot: string): string {\n const supportingPath = getSupportingPath(projectRoot);\n return path.join(supportingPath, 'Expo.plist');\n}\n\nfunction warnMultipleFiles({\n tag,\n fileName,\n projectRoot,\n using,\n extra,\n}: {\n tag: string;\n fileName: string;\n projectRoot?: string;\n using: string;\n extra: string[];\n}) {\n const usingPath = projectRoot ? path.relative(projectRoot, using) : using;\n const extraPaths = projectRoot ? extra.map(v => path.relative(projectRoot, v)) : extra;\n addWarningIOS(\n `paths-${tag}`,\n `Found multiple ${fileName} file paths, using \"${usingPath}\". Ignored paths: ${JSON.stringify(\n extraPaths\n )}`\n );\n}\n"],"file":"Paths.js"}
|
package/build/ios/Updates.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ExpoConfig } from '@expo/config-types';
|
|
2
1
|
import xcode from 'xcode';
|
|
3
2
|
import { ConfigPlugin } from '../Plugin.types';
|
|
3
|
+
import { ExpoConfigUpdates } from '../utils/Updates';
|
|
4
4
|
import { ExpoPlist } from './IosConfig.types';
|
|
5
5
|
export declare enum Config {
|
|
6
6
|
ENABLED = "EXUpdatesEnabled",
|
|
@@ -16,16 +16,16 @@ export declare enum Config {
|
|
|
16
16
|
* runtime version maybe null in projects using classic updates. In that
|
|
17
17
|
* case we use SDK version
|
|
18
18
|
*/
|
|
19
|
-
export declare function getRuntimeVersionNullable(config: Pick<
|
|
20
|
-
export declare function getSDKVersion(config: Pick<
|
|
21
|
-
export declare function getUpdatesEnabled(config: Pick<
|
|
22
|
-
export declare function getUpdatesTimeout(config: Pick<
|
|
23
|
-
export declare function getUpdatesCheckOnLaunch(config: Pick<
|
|
19
|
+
export declare function getRuntimeVersionNullable(config: Pick<ExpoConfigUpdates, 'runtimeVersion'>): string | null;
|
|
20
|
+
export declare function getSDKVersion(config: Pick<ExpoConfigUpdates, 'sdkVersion'>): string | null;
|
|
21
|
+
export declare function getUpdatesEnabled(config: Pick<ExpoConfigUpdates, 'updates'>): boolean;
|
|
22
|
+
export declare function getUpdatesTimeout(config: Pick<ExpoConfigUpdates, 'updates'>): number;
|
|
23
|
+
export declare function getUpdatesCheckOnLaunch(config: Pick<ExpoConfigUpdates, 'updates'>): 'NEVER' | 'ALWAYS';
|
|
24
24
|
export declare const withUpdates: ConfigPlugin<{
|
|
25
25
|
expoUsername: string | null;
|
|
26
26
|
}>;
|
|
27
|
-
export declare function setUpdatesConfig(config:
|
|
28
|
-
export declare function setVersionsConfig(config:
|
|
27
|
+
export declare function setUpdatesConfig(config: ExpoConfigUpdates, expoPlist: ExpoPlist, username: string | null): ExpoPlist;
|
|
28
|
+
export declare function setVersionsConfig(config: ExpoConfigUpdates, expoPlist: ExpoPlist): ExpoPlist;
|
|
29
29
|
interface ShellScriptBuildPhase {
|
|
30
30
|
isa: 'PBXShellScriptBuildPhase';
|
|
31
31
|
name: string;
|
|
@@ -36,6 +36,6 @@ export declare function getBundleReactNativePhase(project: xcode.XcodeProject):
|
|
|
36
36
|
export declare function ensureBundleReactNativePhaseContainsConfigurationScript(projectRoot: string, project: xcode.XcodeProject): xcode.XcodeProject;
|
|
37
37
|
export declare function isShellScriptBuildPhaseConfigured(projectRoot: string, project: xcode.XcodeProject): boolean;
|
|
38
38
|
export declare function isPlistConfigurationSet(expoPlist: ExpoPlist): boolean;
|
|
39
|
-
export declare function isPlistConfigurationSynced(config:
|
|
40
|
-
export declare function isPlistVersionConfigurationSynced(config: Pick<
|
|
39
|
+
export declare function isPlistConfigurationSynced(config: ExpoConfigUpdates, expoPlist: ExpoPlist, username: string | null): boolean;
|
|
40
|
+
export declare function isPlistVersionConfigurationSynced(config: Pick<ExpoConfigUpdates, 'sdkVersion' | 'runtimeVersion'>, expoPlist: ExpoPlist): boolean;
|
|
41
41
|
export {};
|
package/build/ios/Updates.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ios/Updates.ts"],"names":["CREATE_MANIFEST_IOS_PATH","Config","getRuntimeVersionNullable","config","e","getSDKVersion","sdkVersion","getUpdatesEnabled","updates","enabled","getUpdatesTimeout","fallbackToCacheTimeout","getUpdatesCheckOnLaunch","checkAutomatically","withUpdates","expoUsername","modResults","setUpdatesConfig","expoPlist","username","newExpoPlist","ENABLED","CHECK_ON_LAUNCH","LAUNCH_WAIT_MS","updateUrl","UPDATE_URL","setVersionsConfig","runtimeVersion","SDK_VERSION","RUNTIME_VERSION","formatConfigurationScriptPath","projectRoot","buildScriptPath","resolveFrom","silent","Error","relativePath","path","relative","join","process","platform","replace","getBundleReactNativePhase","project","shellScriptBuildPhase","hash","objects","PBXShellScriptBuildPhase","bundleReactNative","Object","values","find","buildPhase","name","ensureBundleReactNativePhaseContainsConfigurationScript","buildPhaseShellScriptPath","isShellScriptBuildPhaseConfigured","shellScript","includes","RegExp","isPlistConfigurationSet","Boolean","EXUpdatesURL","EXUpdatesSDKVersion","EXUpdatesRuntimeVersion","isPlistConfigurationSynced","EXUpdatesEnabled","EXUpdatesLaunchWaitMs","EXUpdatesCheckOnLaunch","isPlistVersionConfigurationSynced","expectedRuntimeVersion","expectedSdkVersion","currentRuntimeVersion","currentSdkVersion"],"mappings":";;;;;;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAIA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;;;AAGA,MAAMA,wBAAwB,GAAG,6CAAjC;IAEYC,M;AAWZ;AACA;AACA;AACA;;;;WAdYA,M;AAAAA,EAAAA,M;AAAAA,EAAAA,M;AAAAA,EAAAA,M;AAAAA,EAAAA,M;AAAAA,EAAAA,M;AAAAA,EAAAA,M;AAAAA,EAAAA,M;AAAAA,EAAAA,M;GAAAA,M,sBAAAA,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qBAAqB,4BAAGvD,SAAS,CAAC+C,uBAAb,yEAAwC,IAAnE;AACA,QAAMS,iBAAiB,4BAAGxD,SAAS,CAAC8C,mBAAb,yEAAoC,IAA3D;;AAEA,MAAIO,sBAAsB,KAAK,IAA/B,EAAqC;AACnC,WAAOE,qBAAqB,KAAKF,sBAA1B,IAAoDG,iBAAiB,KAAK,IAAjF;AACD,GAFD,MAEO,IAAIF,kBAAkB,KAAK,IAA3B,EAAiC;AACtC,WAAOE,iBAAiB,KAAKF,kBAAtB,IAA4CC,qBAAqB,KAAK,IAA7E;AACD,GAFM,MAEA;AACL,WAAO,IAAP;AACD;AACF","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport * as path from 'path';\nimport resolveFrom from 'resolve-from';\nimport xcode from 'xcode';\n\nimport { ConfigPlugin } from '../Plugin.types';\nimport { withExpoPlist } from '../plugins/ios-plugins';\nimport { getRuntimeVersion, getUpdateUrl } from '../utils/Updates';\nimport { ExpoPlist } from './IosConfig.types';\n\nconst CREATE_MANIFEST_IOS_PATH = 'expo-updates/scripts/create-manifest-ios.sh';\n\nexport enum Config {\n ENABLED = 'EXUpdatesEnabled',\n CHECK_ON_LAUNCH = 'EXUpdatesCheckOnLaunch',\n LAUNCH_WAIT_MS = 'EXUpdatesLaunchWaitMs',\n RUNTIME_VERSION = 'EXUpdatesRuntimeVersion',\n SDK_VERSION = 'EXUpdatesSDKVersion',\n UPDATE_URL = 'EXUpdatesURL',\n RELEASE_CHANNEL = 'EXUpdatesReleaseChannel',\n UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY = 'EXUpdatesRequestHeaders',\n}\n\n/**\n * runtime version maybe null in projects using classic updates. In that\n * case we use SDK version\n */\nexport function getRuntimeVersionNullable(\n config: Pick<ExpoConfig, 'runtimeVersion'>\n): string | null {\n try {\n return getRuntimeVersion(config, 'ios');\n } catch (e) {\n return null;\n }\n}\n\nexport function getSDKVersion(config: Pick<ExpoConfig, 'sdkVersion'>): string | null {\n return typeof config.sdkVersion === 'string' ? config.sdkVersion : null;\n}\n\nexport function getUpdatesEnabled(config: Pick<ExpoConfig, 'updates'>): boolean {\n return config.updates?.enabled !== false;\n}\n\nexport function getUpdatesTimeout(config: Pick<ExpoConfig, 'updates'>) {\n return config.updates?.fallbackToCacheTimeout ?? 0;\n}\n\nexport function getUpdatesCheckOnLaunch(config: Pick<ExpoConfig, 'updates'>): 'NEVER' | 'ALWAYS' {\n if (config.updates?.checkAutomatically === 'ON_ERROR_RECOVERY') {\n return 'NEVER';\n } else if (config.updates?.checkAutomatically === 'ON_LOAD') {\n return 'ALWAYS';\n }\n return 'ALWAYS';\n}\n\nexport const withUpdates: ConfigPlugin<{ expoUsername: string | null }> = (\n config,\n { expoUsername }\n) => {\n return withExpoPlist(config, config => {\n config.modResults = setUpdatesConfig(config, config.modResults, expoUsername);\n return config;\n });\n};\n\nexport function setUpdatesConfig(\n config: ExpoConfig,\n expoPlist: ExpoPlist,\n username: string | null\n): ExpoPlist {\n const newExpoPlist = {\n ...expoPlist,\n [Config.ENABLED]: getUpdatesEnabled(config),\n [Config.CHECK_ON_LAUNCH]: getUpdatesCheckOnLaunch(config),\n [Config.LAUNCH_WAIT_MS]: getUpdatesTimeout(config),\n };\n\n const updateUrl = getUpdateUrl(config, username);\n if (updateUrl) {\n newExpoPlist[Config.UPDATE_URL] = updateUrl;\n } else {\n delete newExpoPlist[Config.UPDATE_URL];\n }\n\n return setVersionsConfig(config, newExpoPlist);\n}\n\nexport function setVersionsConfig(config: ExpoConfig, expoPlist: ExpoPlist): ExpoPlist {\n const newExpoPlist = { ...expoPlist };\n\n const runtimeVersion = getRuntimeVersionNullable(config);\n const sdkVersion = getSDKVersion(config);\n if (runtimeVersion) {\n delete newExpoPlist[Config.SDK_VERSION];\n newExpoPlist[Config.RUNTIME_VERSION] = runtimeVersion;\n } else if (sdkVersion) {\n delete newExpoPlist[Config.RUNTIME_VERSION];\n newExpoPlist[Config.SDK_VERSION] = sdkVersion;\n } else {\n delete newExpoPlist[Config.SDK_VERSION];\n delete newExpoPlist[Config.RUNTIME_VERSION];\n }\n\n return newExpoPlist;\n}\n\nfunction formatConfigurationScriptPath(projectRoot: string): string {\n const buildScriptPath = resolveFrom.silent(projectRoot, CREATE_MANIFEST_IOS_PATH);\n\n if (!buildScriptPath) {\n throw new Error(\n \"Could not find the build script for iOS. This could happen in case of outdated 'node_modules'. Run 'npm install' to make sure that it's up-to-date.\"\n );\n }\n\n const relativePath = path.relative(path.join(projectRoot, 'ios'), buildScriptPath);\n return process.platform === 'win32' ? relativePath.replace(/\\\\/g, '/') : relativePath;\n}\n\ninterface ShellScriptBuildPhase {\n isa: 'PBXShellScriptBuildPhase';\n name: string;\n shellScript: string;\n [key: string]: any;\n}\n\nexport function getBundleReactNativePhase(project: xcode.XcodeProject): ShellScriptBuildPhase {\n const shellScriptBuildPhase = project.hash.project.objects.PBXShellScriptBuildPhase as Record<\n string,\n ShellScriptBuildPhase\n >;\n const bundleReactNative = Object.values(shellScriptBuildPhase).find(\n buildPhase => buildPhase.name === '\"Bundle React Native code and images\"'\n );\n\n if (!bundleReactNative) {\n throw new Error(`Couldn't find a build phase \"Bundle React Native code and images\"`);\n }\n\n return bundleReactNative;\n}\n\nexport function ensureBundleReactNativePhaseContainsConfigurationScript(\n projectRoot: string,\n project: xcode.XcodeProject\n): xcode.XcodeProject {\n const bundleReactNative = getBundleReactNativePhase(project);\n const buildPhaseShellScriptPath = formatConfigurationScriptPath(projectRoot);\n\n if (!isShellScriptBuildPhaseConfigured(projectRoot, project)) {\n // check if there's already another path to create-manifest-ios.sh\n // this might be the case for monorepos\n if (bundleReactNative.shellScript.includes(CREATE_MANIFEST_IOS_PATH)) {\n bundleReactNative.shellScript = bundleReactNative.shellScript.replace(\n new RegExp(`(\\\\\\\\n)(\\\\.\\\\.)+/node_modules/${CREATE_MANIFEST_IOS_PATH}`),\n ''\n );\n }\n bundleReactNative.shellScript = `${bundleReactNative.shellScript.replace(\n /\"$/,\n ''\n )}${buildPhaseShellScriptPath}\\\\n\"`;\n }\n return project;\n}\n\nexport function isShellScriptBuildPhaseConfigured(\n projectRoot: string,\n project: xcode.XcodeProject\n): boolean {\n const bundleReactNative = getBundleReactNativePhase(project);\n const buildPhaseShellScriptPath = formatConfigurationScriptPath(projectRoot);\n return bundleReactNative.shellScript.includes(buildPhaseShellScriptPath);\n}\n\nexport function isPlistConfigurationSet(expoPlist: ExpoPlist): boolean {\n return Boolean(\n expoPlist.EXUpdatesURL && (expoPlist.EXUpdatesSDKVersion || expoPlist.EXUpdatesRuntimeVersion)\n );\n}\n\nexport function isPlistConfigurationSynced(\n config: ExpoConfig,\n expoPlist: ExpoPlist,\n username: string | null\n): boolean {\n return (\n getUpdateUrl(config, username) === expoPlist.EXUpdatesURL &&\n getUpdatesEnabled(config) === expoPlist.EXUpdatesEnabled &&\n getUpdatesTimeout(config) === expoPlist.EXUpdatesLaunchWaitMs &&\n getUpdatesCheckOnLaunch(config) === expoPlist.EXUpdatesCheckOnLaunch &&\n isPlistVersionConfigurationSynced(config, expoPlist)\n );\n}\n\nexport function isPlistVersionConfigurationSynced(\n config: Pick<ExpoConfig, 'sdkVersion' | 'runtimeVersion'>,\n expoPlist: ExpoPlist\n): boolean {\n const expectedRuntimeVersion = getRuntimeVersionNullable(config);\n const expectedSdkVersion = getSDKVersion(config);\n\n const currentRuntimeVersion = expoPlist.EXUpdatesRuntimeVersion ?? null;\n const currentSdkVersion = expoPlist.EXUpdatesSDKVersion ?? null;\n\n if (expectedRuntimeVersion !== null) {\n return currentRuntimeVersion === expectedRuntimeVersion && currentSdkVersion === null;\n } else if (expectedSdkVersion !== null) {\n return currentSdkVersion === expectedSdkVersion && currentRuntimeVersion === null;\n } else {\n return true;\n }\n}\n"],"file":"Updates.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/ios/Updates.ts"],"names":["CREATE_MANIFEST_IOS_PATH","Config","getRuntimeVersionNullable","config","e","getSDKVersion","sdkVersion","getUpdatesEnabled","updates","enabled","getUpdatesTimeout","fallbackToCacheTimeout","getUpdatesCheckOnLaunch","checkAutomatically","withUpdates","expoUsername","modResults","setUpdatesConfig","expoPlist","username","newExpoPlist","ENABLED","CHECK_ON_LAUNCH","LAUNCH_WAIT_MS","updateUrl","UPDATE_URL","setVersionsConfig","runtimeVersion","SDK_VERSION","RUNTIME_VERSION","formatConfigurationScriptPath","projectRoot","buildScriptPath","resolveFrom","silent","Error","relativePath","path","relative","join","process","platform","replace","getBundleReactNativePhase","project","shellScriptBuildPhase","hash","objects","PBXShellScriptBuildPhase","bundleReactNative","Object","values","find","buildPhase","name","ensureBundleReactNativePhaseContainsConfigurationScript","buildPhaseShellScriptPath","isShellScriptBuildPhaseConfigured","shellScript","includes","RegExp","isPlistConfigurationSet","Boolean","EXUpdatesURL","EXUpdatesSDKVersion","EXUpdatesRuntimeVersion","isPlistConfigurationSynced","EXUpdatesEnabled","EXUpdatesLaunchWaitMs","EXUpdatesCheckOnLaunch","isPlistVersionConfigurationSynced","expectedRuntimeVersion","expectedSdkVersion","currentRuntimeVersion","currentSdkVersion"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAIA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;;;AAGA,MAAMA,wBAAwB,GAAG,6CAAjC;IAEYC,M;AAWZ;AACA;AACA;AACA;;;;WAdYA,M;AAAAA,EAAAA,M;AAAAA,EAAAA,M;AAAAA,EAAAA,M;AAAAA,EAAAA,M;AAAAA,EAAAA,M;AAAAA,EAAAA,M;AAAAA,EAAAA,M;AAAAA,EAAAA,M;GAAAA,M,sBAAAA,M;;AAeL,SAASC,yBAAT,CACLC,MADK,EAEU;AACf,MAAI;AACF,WAAO,kCAAkBA,MAAlB,EAA0B,KAA1B,CAAP;AACD,GAFD,CAEE,OAAO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EA,MAAIO,sBAAsB,KAAK,IAA/B,EAAqC;AACnC,WAAOE,qBAAqB,KAAKF,sBAA1B,IAAoDG,iBAAiB,KAAK,IAAjF;AACD,GAFD,MAEO,IAAIF,kBAAkB,KAAK,IAA3B,EAAiC;AACtC,WAAOE,iBAAiB,KAAKF,kBAAtB,IAA4CC,qBAAqB,KAAK,IAA7E;AACD,GAFM,MAEA;AACL,WAAO,IAAP;AACD;AACF","sourcesContent":["import * as path from 'path';\nimport resolveFrom from 'resolve-from';\nimport xcode from 'xcode';\n\nimport { ConfigPlugin } from '../Plugin.types';\nimport { withExpoPlist } from '../plugins/ios-plugins';\nimport { ExpoConfigUpdates, getRuntimeVersion, getUpdateUrl } from '../utils/Updates';\nimport { ExpoPlist } from './IosConfig.types';\n\nconst CREATE_MANIFEST_IOS_PATH = 'expo-updates/scripts/create-manifest-ios.sh';\n\nexport enum Config {\n ENABLED = 'EXUpdatesEnabled',\n CHECK_ON_LAUNCH = 'EXUpdatesCheckOnLaunch',\n LAUNCH_WAIT_MS = 'EXUpdatesLaunchWaitMs',\n RUNTIME_VERSION = 'EXUpdatesRuntimeVersion',\n SDK_VERSION = 'EXUpdatesSDKVersion',\n UPDATE_URL = 'EXUpdatesURL',\n RELEASE_CHANNEL = 'EXUpdatesReleaseChannel',\n UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY = 'EXUpdatesRequestHeaders',\n}\n\n/**\n * runtime version maybe null in projects using classic updates. In that\n * case we use SDK version\n */\nexport function getRuntimeVersionNullable(\n config: Pick<ExpoConfigUpdates, 'runtimeVersion'>\n): string | null {\n try {\n return getRuntimeVersion(config, 'ios');\n } catch (e) {\n return null;\n }\n}\n\nexport function getSDKVersion(config: Pick<ExpoConfigUpdates, 'sdkVersion'>): string | null {\n return typeof config.sdkVersion === 'string' ? config.sdkVersion : null;\n}\n\nexport function getUpdatesEnabled(config: Pick<ExpoConfigUpdates, 'updates'>): boolean {\n return config.updates?.enabled !== false;\n}\n\nexport function getUpdatesTimeout(config: Pick<ExpoConfigUpdates, 'updates'>) {\n return config.updates?.fallbackToCacheTimeout ?? 0;\n}\n\nexport function getUpdatesCheckOnLaunch(\n config: Pick<ExpoConfigUpdates, 'updates'>\n): 'NEVER' | 'ALWAYS' {\n if (config.updates?.checkAutomatically === 'ON_ERROR_RECOVERY') {\n return 'NEVER';\n } else if (config.updates?.checkAutomatically === 'ON_LOAD') {\n return 'ALWAYS';\n }\n return 'ALWAYS';\n}\n\nexport const withUpdates: ConfigPlugin<{ expoUsername: string | null }> = (\n config,\n { expoUsername }\n) => {\n return withExpoPlist(config, config => {\n config.modResults = setUpdatesConfig(config, config.modResults, expoUsername);\n return config;\n });\n};\n\nexport function setUpdatesConfig(\n config: ExpoConfigUpdates,\n expoPlist: ExpoPlist,\n username: string | null\n): ExpoPlist {\n const newExpoPlist = {\n ...expoPlist,\n [Config.ENABLED]: getUpdatesEnabled(config),\n [Config.CHECK_ON_LAUNCH]: getUpdatesCheckOnLaunch(config),\n [Config.LAUNCH_WAIT_MS]: getUpdatesTimeout(config),\n };\n\n const updateUrl = getUpdateUrl(config, username);\n if (updateUrl) {\n newExpoPlist[Config.UPDATE_URL] = updateUrl;\n } else {\n delete newExpoPlist[Config.UPDATE_URL];\n }\n\n return setVersionsConfig(config, newExpoPlist);\n}\n\nexport function setVersionsConfig(config: ExpoConfigUpdates, expoPlist: ExpoPlist): ExpoPlist {\n const newExpoPlist = { ...expoPlist };\n\n const runtimeVersion = getRuntimeVersionNullable(config);\n const sdkVersion = getSDKVersion(config);\n if (runtimeVersion) {\n delete newExpoPlist[Config.SDK_VERSION];\n newExpoPlist[Config.RUNTIME_VERSION] = runtimeVersion;\n } else if (sdkVersion) {\n delete newExpoPlist[Config.RUNTIME_VERSION];\n newExpoPlist[Config.SDK_VERSION] = sdkVersion;\n } else {\n delete newExpoPlist[Config.SDK_VERSION];\n delete newExpoPlist[Config.RUNTIME_VERSION];\n }\n\n return newExpoPlist;\n}\n\nfunction formatConfigurationScriptPath(projectRoot: string): string {\n const buildScriptPath = resolveFrom.silent(projectRoot, CREATE_MANIFEST_IOS_PATH);\n\n if (!buildScriptPath) {\n throw new Error(\n \"Could not find the build script for iOS. This could happen in case of outdated 'node_modules'. Run 'npm install' to make sure that it's up-to-date.\"\n );\n }\n\n const relativePath = path.relative(path.join(projectRoot, 'ios'), buildScriptPath);\n return process.platform === 'win32' ? relativePath.replace(/\\\\/g, '/') : relativePath;\n}\n\ninterface ShellScriptBuildPhase {\n isa: 'PBXShellScriptBuildPhase';\n name: string;\n shellScript: string;\n [key: string]: any;\n}\n\nexport function getBundleReactNativePhase(project: xcode.XcodeProject): ShellScriptBuildPhase {\n const shellScriptBuildPhase = project.hash.project.objects.PBXShellScriptBuildPhase as Record<\n string,\n ShellScriptBuildPhase\n >;\n const bundleReactNative = Object.values(shellScriptBuildPhase).find(\n buildPhase => buildPhase.name === '\"Bundle React Native code and images\"'\n );\n\n if (!bundleReactNative) {\n throw new Error(`Couldn't find a build phase \"Bundle React Native code and images\"`);\n }\n\n return bundleReactNative;\n}\n\nexport function ensureBundleReactNativePhaseContainsConfigurationScript(\n projectRoot: string,\n project: xcode.XcodeProject\n): xcode.XcodeProject {\n const bundleReactNative = getBundleReactNativePhase(project);\n const buildPhaseShellScriptPath = formatConfigurationScriptPath(projectRoot);\n\n if (!isShellScriptBuildPhaseConfigured(projectRoot, project)) {\n // check if there's already another path to create-manifest-ios.sh\n // this might be the case for monorepos\n if (bundleReactNative.shellScript.includes(CREATE_MANIFEST_IOS_PATH)) {\n bundleReactNative.shellScript = bundleReactNative.shellScript.replace(\n new RegExp(`(\\\\\\\\n)(\\\\.\\\\.)+/node_modules/${CREATE_MANIFEST_IOS_PATH}`),\n ''\n );\n }\n bundleReactNative.shellScript = `${bundleReactNative.shellScript.replace(\n /\"$/,\n ''\n )}${buildPhaseShellScriptPath}\\\\n\"`;\n }\n return project;\n}\n\nexport function isShellScriptBuildPhaseConfigured(\n projectRoot: string,\n project: xcode.XcodeProject\n): boolean {\n const bundleReactNative = getBundleReactNativePhase(project);\n const buildPhaseShellScriptPath = formatConfigurationScriptPath(projectRoot);\n return bundleReactNative.shellScript.includes(buildPhaseShellScriptPath);\n}\n\nexport function isPlistConfigurationSet(expoPlist: ExpoPlist): boolean {\n return Boolean(\n expoPlist.EXUpdatesURL && (expoPlist.EXUpdatesSDKVersion || expoPlist.EXUpdatesRuntimeVersion)\n );\n}\n\nexport function isPlistConfigurationSynced(\n config: ExpoConfigUpdates,\n expoPlist: ExpoPlist,\n username: string | null\n): boolean {\n return (\n getUpdateUrl(config, username) === expoPlist.EXUpdatesURL &&\n getUpdatesEnabled(config) === expoPlist.EXUpdatesEnabled &&\n getUpdatesTimeout(config) === expoPlist.EXUpdatesLaunchWaitMs &&\n getUpdatesCheckOnLaunch(config) === expoPlist.EXUpdatesCheckOnLaunch &&\n isPlistVersionConfigurationSynced(config, expoPlist)\n );\n}\n\nexport function isPlistVersionConfigurationSynced(\n config: Pick<ExpoConfigUpdates, 'sdkVersion' | 'runtimeVersion'>,\n expoPlist: ExpoPlist\n): boolean {\n const expectedRuntimeVersion = getRuntimeVersionNullable(config);\n const expectedSdkVersion = getSDKVersion(config);\n\n const currentRuntimeVersion = expoPlist.EXUpdatesRuntimeVersion ?? null;\n const currentSdkVersion = expoPlist.EXUpdatesSDKVersion ?? null;\n\n if (expectedRuntimeVersion !== null) {\n return currentRuntimeVersion === expectedRuntimeVersion && currentSdkVersion === null;\n } else if (expectedSdkVersion !== null) {\n return currentSdkVersion === expectedSdkVersion && currentRuntimeVersion === null;\n } else {\n return true;\n }\n}\n"],"file":"Updates.js"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { CodeBlock } from '../utils/commonCodeMod';
|
|
2
|
+
interface InsertContentFunctionOptions {
|
|
3
|
+
position: 'head' | 'tail' | 'tailBeforeLastReturn';
|
|
4
|
+
indent?: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Add Objective-C import
|
|
8
|
+
* @param source source contents
|
|
9
|
+
* @param imports array of imports, e.g. ['<Foundation/Foundation.h>']
|
|
10
|
+
* @returns updated contents
|
|
11
|
+
*/
|
|
12
|
+
export declare function addObjcImports(source: string, imports: string[]): string;
|
|
13
|
+
/**
|
|
14
|
+
* Find code block of Objective-C interface or implementation
|
|
15
|
+
*
|
|
16
|
+
* @param contents source contents
|
|
17
|
+
* @param declaration interface/implementation, e.g. '@interface Foo'
|
|
18
|
+
* @returns found CodeBlock, or null if not found
|
|
19
|
+
*/
|
|
20
|
+
export declare function findObjcInterfaceCodeBlock(contents: string, declaration: string): CodeBlock | null;
|
|
21
|
+
/**
|
|
22
|
+
* Find code block of Objective-C function without declaration, will return only {} block
|
|
23
|
+
*
|
|
24
|
+
* @param contents source contents
|
|
25
|
+
* @param selector function selector, e.g. 'doSomething:withSomeValue:'
|
|
26
|
+
* @returns found CodeBlock, or null if not found.
|
|
27
|
+
*/
|
|
28
|
+
export declare function findObjcFunctionCodeBlock(contents: string, selector: string): CodeBlock | null;
|
|
29
|
+
/**
|
|
30
|
+
* Insert contents to the Objective-C function block
|
|
31
|
+
*
|
|
32
|
+
* @param srcContents source contents
|
|
33
|
+
* @param selector function selector, e.g. 'doSomething:withSomeValue:'
|
|
34
|
+
* @param insertion code to insert
|
|
35
|
+
* @param options insertion options
|
|
36
|
+
* @returns updated contents
|
|
37
|
+
*/
|
|
38
|
+
export declare function insertContentsInsideObjcFunctionBlock(srcContents: string, selector: string, insertion: string, options: InsertContentFunctionOptions): string;
|
|
39
|
+
/**
|
|
40
|
+
* Insert contents to the Objective-C interface/implementation block
|
|
41
|
+
*
|
|
42
|
+
* @param srcContents source contents
|
|
43
|
+
* @param declaration interface/implementation, e.g. '@interface Foo'
|
|
44
|
+
* @param insertion code to insert
|
|
45
|
+
* @param options insertion options
|
|
46
|
+
* @returns updated contents
|
|
47
|
+
*/
|
|
48
|
+
export declare function insertContentsInsideObjcInterfaceBlock(srcContents: string, declaration: string, insertion: string, options: {
|
|
49
|
+
position: 'head' | 'tail';
|
|
50
|
+
}): string;
|
|
51
|
+
/**
|
|
52
|
+
* Find code block of Swift function without declaration, will return only {} block
|
|
53
|
+
*
|
|
54
|
+
* @param contents source contents
|
|
55
|
+
* @param selector function selector, e.g. 'doSomething(_:withSomeValue:)'
|
|
56
|
+
* @returns found CodeBlock, or null if not found.
|
|
57
|
+
*/
|
|
58
|
+
export declare function findSwiftFunctionCodeBlock(contents: string, selector: string): CodeBlock | null;
|
|
59
|
+
/**
|
|
60
|
+
* Insert contents to the swift class block
|
|
61
|
+
*
|
|
62
|
+
* @param srcContents source contents
|
|
63
|
+
* @param declaration class/extension declaration, e.g. 'class AppDelegate'
|
|
64
|
+
* @param insertion code to append
|
|
65
|
+
* @param options insertion options
|
|
66
|
+
* @returns updated contents
|
|
67
|
+
*/
|
|
68
|
+
export declare function insertContentsInsideSwiftClassBlock(srcContents: string, declaration: string, insertion: string, options: {
|
|
69
|
+
position: 'head' | 'tail';
|
|
70
|
+
}): string;
|
|
71
|
+
/**
|
|
72
|
+
* Insert contents to the Swift function block
|
|
73
|
+
*
|
|
74
|
+
* @param srcContents source contents
|
|
75
|
+
* @param selector function selector, e.g. 'doSomething:withSomeValue:'
|
|
76
|
+
* @param insertion code to insert
|
|
77
|
+
* @param options insertion options
|
|
78
|
+
* @returns updated contents
|
|
79
|
+
*/
|
|
80
|
+
export declare function insertContentsInsideSwiftFunctionBlock(srcContents: string, selector: string, insertion: string, options: InsertContentFunctionOptions): string;
|
|
81
|
+
export {};
|