@expo/config-plugins 4.0.10 → 4.0.11

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ios/BundleIdentifier.ts"],"names":["withBundleIdentifier","config","bundleIdentifier","bundleId","ios","setBundleIdentifierForPbxproj","modRequest","projectRoot","getBundleIdentifier","setBundleIdentifier","infoPlist","CFBundleIdentifier","getBundleIdentifierFromPbxproj","targetName","buildConfiguration","pbxprojPath","project","xcode","parseSync","xcBuildConfiguration","getProductBundleIdentifierFromBuildConfiguration","bundleIdentifierRaw","buildSettings","PRODUCT_BUNDLE_IDENTIFIER","slice","bundleIdentifierParts","split","length","PRODUCT_NAME","replace","join","updateBundleIdentifierForPbxproj","updateProductName","nativeTarget","buildConfigurationList","forEach","item","productName","pop","includes","fs","writeFileSync","writeSync","pbxprojPaths","defaultBundleId","resetAllPlistBundleIdentifiers","infoPlistPaths","plistPath","resetPlistBundleIdentifier","rawPlist","readFileSync","plistObject","plist","parse","format","pretty","indent","xml","build"],"mappings":";;;;;;;;;;;;;;AACA;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;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAEO,MAAMA,oBAAiE,GAAG,CAC/EC,MAD+E,EAE/E;AAAEC,EAAAA;AAAF,CAF+E,KAG5E;AACH,SAAO,0CAAiBD,MAAjB,EAAyB,CAC9B,KAD8B,EAE9B,MAAMA,MAAN,IAAgB;AAAA;;AACd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,QAAQ,GAAGT,mBAAGU,YAAH,CAAgBH,SAAhB,EAA2B,MAA3B,CAAjB;;AACA,QAAMI,WAAW,GAAGC,iBAAMC,KAAN,CAAYJ,QAAZ,CAApB;;AAEA,MAAIE,WAAW,CAACxC,kBAAhB,EAAoC;AAClC,QAAIwC,WAAW,CAACxC,kBAAZ,KAAmCiC,eAAvC,EAAwD,OADtB,CAGlC;;AACA,UAAMU,MAAM,GAAG;AAAEC,MAAAA,MAAM,EAAE,IAAV;AAAgBC,MAAAA,MAAM,EAAG;AAAzB,KAAf;;AAEA,UAAMC,GAAG,GAAGL,iBAAMM,KAAN,CACV,EACE,GAAGP,WADL;AAEExC,MAAAA,kBAAkB,EAAEiC;AAFtB,KADU,EAKVU,MALU,CAAZ;;AAQA,QAAIG,GAAG,KAAKR,QAAZ,EAAsB;AACpBT,yBAAGC,aAAH,CAAiBM,SAAjB,EAA4BU,GAA5B;AACD;AACF;AACF","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport plist, { PlistObject } from '@expo/plist';\nimport assert from 'assert';\nimport fs from 'fs-extra';\nimport xcode, { XCBuildConfiguration } from 'xcode';\n\nimport { ConfigPlugin } from '../Plugin.types';\nimport { withDangerousMod } from '../plugins/withDangerousMod';\nimport { InfoPlist } from './IosConfig.types';\nimport { getAllInfoPlistPaths, getAllPBXProjectPaths, getPBXProjectPath } from './Paths';\nimport { findFirstNativeTarget, getXCBuildConfigurationFromPbxproj } from './Target';\nimport { ConfigurationSectionEntry, getBuildConfigurationsForListId } from './utils/Xcodeproj';\n\nexport const withBundleIdentifier: ConfigPlugin<{ bundleIdentifier?: string }> = (\n config,\n { bundleIdentifier }\n) => {\n return withDangerousMod(config, [\n 'ios',\n async config => {\n const bundleId = bundleIdentifier ?? config.ios?.bundleIdentifier;\n assert(\n bundleId,\n '`bundleIdentifier` must be defined in the app config (`expo.ios.bundleIdentifier`) or passed to the plugin `withBundleIdentifier`.'\n );\n await setBundleIdentifierForPbxproj(config.modRequest.projectRoot, bundleId!);\n return config;\n },\n ]);\n};\n\nfunction getBundleIdentifier(config: Pick<ExpoConfig, 'ios'>): string | null {\n return config.ios?.bundleIdentifier ?? null;\n}\n\n/**\n * In Turtle v1 we set the bundleIdentifier directly on Info.plist rather\n * than in pbxproj\n */\nfunction setBundleIdentifier(config: ExpoConfig, infoPlist: InfoPlist): InfoPlist {\n const bundleIdentifier = getBundleIdentifier(config);\n\n if (!bundleIdentifier) {\n return infoPlist;\n }\n\n return {\n ...infoPlist,\n CFBundleIdentifier: bundleIdentifier,\n };\n}\n\n/**\n * Gets the bundle identifier defined in the Xcode project found in the project directory.\n *\n * A bundle identifier is stored as a value in XCBuildConfiguration entry.\n * Those entries exist for every pair (build target, build configuration).\n * Unless target name is passed, the first target defined in the pbxproj is used\n * (to keep compatibility with the inaccurate legacy implementation of this function).\n * The build configuration is usually 'Release' or 'Debug'. However, it could be any arbitrary string.\n * Defaults to 'Release'.\n *\n * @param {string} projectRoot Path to project root containing the ios directory\n * @param {string} targetName Target name\n * @param {string} buildConfiguration Build configuration. Defaults to 'Release'.\n * @returns {string | null} bundle identifier of the Xcode project or null if the project is not configured\n */\nfunction getBundleIdentifierFromPbxproj(\n projectRoot: string,\n {\n targetName,\n buildConfiguration = 'Release',\n }: { targetName?: string; buildConfiguration?: string } = {}\n): string | null {\n let pbxprojPath: string;\n try {\n pbxprojPath = getPBXProjectPath(projectRoot);\n } catch {\n return null;\n }\n const project = xcode.project(pbxprojPath);\n project.parseSync();\n\n const xcBuildConfiguration = getXCBuildConfigurationFromPbxproj(project, {\n targetName,\n buildConfiguration,\n });\n if (!xcBuildConfiguration) {\n return null;\n }\n return getProductBundleIdentifierFromBuildConfiguration(xcBuildConfiguration);\n}\n\nfunction getProductBundleIdentifierFromBuildConfiguration(\n xcBuildConfiguration: XCBuildConfiguration\n): string | null {\n const bundleIdentifierRaw = xcBuildConfiguration.buildSettings.PRODUCT_BUNDLE_IDENTIFIER;\n if (bundleIdentifierRaw) {\n const bundleIdentifier =\n bundleIdentifierRaw[0] === '\"' ? bundleIdentifierRaw.slice(1, -1) : bundleIdentifierRaw;\n // it's possible to use interpolation for the bundle identifier\n // the most common case is when the last part of the id is set to `$(PRODUCT_NAME:rfc1034identifier)`\n // in this case, PRODUCT_NAME should be replaced with its value\n // the `rfc1034identifier` modifier replaces all non-alphanumeric characters with dashes\n const bundleIdentifierParts = bundleIdentifier.split('.');\n if (\n bundleIdentifierParts[bundleIdentifierParts.length - 1] ===\n '$(PRODUCT_NAME:rfc1034identifier)' &&\n xcBuildConfiguration.buildSettings.PRODUCT_NAME\n ) {\n bundleIdentifierParts[\n bundleIdentifierParts.length - 1\n ] = xcBuildConfiguration.buildSettings.PRODUCT_NAME.replace(/[^a-zA-Z0-9]/g, '-');\n }\n return bundleIdentifierParts.join('.');\n } else {\n return null;\n }\n}\n\n/**\n * Updates the bundle identifier for a given pbxproj\n *\n * @param {string} pbxprojPath Path to pbxproj file\n * @param {string} bundleIdentifier Bundle identifier to set in the pbxproj\n * @param {boolean} [updateProductName=true] Whether to update PRODUCT_NAME\n */\nfunction updateBundleIdentifierForPbxproj(\n pbxprojPath: string,\n bundleIdentifier: string,\n updateProductName: boolean = true\n): void {\n const project = xcode.project(pbxprojPath);\n project.parseSync();\n\n const [, nativeTarget] = findFirstNativeTarget(project);\n\n getBuildConfigurationsForListId(project, nativeTarget.buildConfigurationList).forEach(\n ([, item]: ConfigurationSectionEntry) => {\n if (item.buildSettings.PRODUCT_BUNDLE_IDENTIFIER === bundleIdentifier) {\n return;\n }\n\n item.buildSettings.PRODUCT_BUNDLE_IDENTIFIER = `\"${bundleIdentifier}\"`;\n\n if (updateProductName) {\n const productName = bundleIdentifier.split('.').pop();\n if (!productName?.includes('$')) {\n item.buildSettings.PRODUCT_NAME = productName;\n }\n }\n }\n );\n fs.writeFileSync(pbxprojPath, project.writeSync());\n}\n\n/**\n * Updates the bundle identifier for pbx projects inside the ios directory of the given project root\n *\n * @param {string} projectRoot Path to project root containing the ios directory\n * @param {string} bundleIdentifier Desired bundle identifier\n * @param {boolean} [updateProductName=true] Whether to update PRODUCT_NAME\n */\nfunction setBundleIdentifierForPbxproj(\n projectRoot: string,\n bundleIdentifier: string,\n updateProductName: boolean = true\n): void {\n // Get all pbx projects in the ${projectRoot}/ios directory\n let pbxprojPaths: string[] = [];\n try {\n pbxprojPaths = getAllPBXProjectPaths(projectRoot);\n } catch {}\n\n for (const pbxprojPath of pbxprojPaths) {\n updateBundleIdentifierForPbxproj(pbxprojPath, bundleIdentifier, updateProductName);\n }\n}\n\n/**\n * Reset bundle identifier field in Info.plist to use PRODUCT_BUNDLE_IDENTIFIER, as recommended by Apple.\n */\n\nconst defaultBundleId = '$(PRODUCT_BUNDLE_IDENTIFIER)';\n\nfunction resetAllPlistBundleIdentifiers(projectRoot: string): void {\n const infoPlistPaths = getAllInfoPlistPaths(projectRoot);\n\n for (const plistPath of infoPlistPaths) {\n resetPlistBundleIdentifier(plistPath);\n }\n}\n\nfunction resetPlistBundleIdentifier(plistPath: string): void {\n const rawPlist = fs.readFileSync(plistPath, 'utf8');\n const plistObject = plist.parse(rawPlist) as PlistObject;\n\n if (plistObject.CFBundleIdentifier) {\n if (plistObject.CFBundleIdentifier === defaultBundleId) return;\n\n // attempt to match default Info.plist format\n const format = { pretty: true, indent: `\\t` };\n\n const xml = plist.build(\n {\n ...plistObject,\n CFBundleIdentifier: defaultBundleId,\n },\n format\n );\n\n if (xml !== rawPlist) {\n fs.writeFileSync(plistPath, xml);\n }\n }\n}\n\nexport {\n getBundleIdentifier,\n setBundleIdentifier,\n getBundleIdentifierFromPbxproj,\n updateBundleIdentifierForPbxproj,\n setBundleIdentifierForPbxproj,\n resetAllPlistBundleIdentifiers,\n resetPlistBundleIdentifier,\n};\n"],"file":"BundleIdentifier.js"}
1
+ {"version":3,"sources":["../../src/ios/BundleIdentifier.ts"],"names":["withBundleIdentifier","config","bundleIdentifier","bundleId","ios","setBundleIdentifierForPbxproj","modRequest","projectRoot","getBundleIdentifier","setBundleIdentifier","infoPlist","CFBundleIdentifier","getBundleIdentifierFromPbxproj","targetName","buildConfiguration","pbxprojPath","project","xcode","parseSync","xcBuildConfiguration","getProductBundleIdentifierFromBuildConfiguration","bundleIdentifierRaw","buildSettings","PRODUCT_BUNDLE_IDENTIFIER","bundleIdentifierParts","split","length","PRODUCT_NAME","replace","join","updateBundleIdentifierForPbxproj","updateProductName","nativeTarget","buildConfigurationList","forEach","item","productName","pop","includes","fs","writeFileSync","writeSync","pbxprojPaths","defaultBundleId","resetAllPlistBundleIdentifiers","infoPlistPaths","plistPath","resetPlistBundleIdentifier","rawPlist","readFileSync","plistObject","plist","parse","format","pretty","indent","xml","build"],"mappings":";;;;;;;;;;;;;;AACA;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;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;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,oBAAiE,GAAG,CAC/EC,MAD+E,EAE/E;AAAEC,EAAAA;AAAF,CAF+E,KAG5E;AACH,SAAO,0CAAiBD,MAAjB,EAAyB,CAC9B,KAD8B,EAE9B,MAAMA,MAAN,IAAgB;AAAA;;AACd,UAAME,QAAQ,GAAGD,gBAAH,aAAGA,gBAAH,cAAGA,gBAAH,kBAAuBD,MAAM,CAACG,GAA9B,gDAAuB,YAAYF,gBAAjD;AACA,2BACEC,QADF,EAEE,oIAFF;AAIA,UAAME,6BAA6B,CAACJ,MAAM,CAACK,UAAP,CAAkBC,WAAnB,EAA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A,MAAM,EAAG;AAAzB,KAAf;;AAEA,UAAMC,GAAG,GAAGL,iBAAMM,KAAN,CACV,EACE,GAAGP,WADL;AAEEvC,MAAAA,kBAAkB,EAAEgC;AAFtB,KADU,EAKVU,MALU,CAAZ;;AAQA,QAAIG,GAAG,KAAKR,QAAZ,EAAsB;AACpBT,yBAAGC,aAAH,CAAiBM,SAAjB,EAA4BU,GAA5B;AACD;AACF;AACF","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport plist, { PlistObject } from '@expo/plist';\nimport assert from 'assert';\nimport fs from 'fs-extra';\nimport xcode, { XCBuildConfiguration } from 'xcode';\n\nimport { ConfigPlugin } from '../Plugin.types';\nimport { withDangerousMod } from '../plugins/withDangerousMod';\nimport { InfoPlist } from './IosConfig.types';\nimport { getAllInfoPlistPaths, getAllPBXProjectPaths, getPBXProjectPath } from './Paths';\nimport { findFirstNativeTarget, getXCBuildConfigurationFromPbxproj } from './Target';\nimport { ConfigurationSectionEntry, getBuildConfigurationsForListId } from './utils/Xcodeproj';\nimport { trimQuotes } from './utils/string';\n\nexport const withBundleIdentifier: ConfigPlugin<{ bundleIdentifier?: string }> = (\n config,\n { bundleIdentifier }\n) => {\n return withDangerousMod(config, [\n 'ios',\n async config => {\n const bundleId = bundleIdentifier ?? config.ios?.bundleIdentifier;\n assert(\n bundleId,\n '`bundleIdentifier` must be defined in the app config (`expo.ios.bundleIdentifier`) or passed to the plugin `withBundleIdentifier`.'\n );\n await setBundleIdentifierForPbxproj(config.modRequest.projectRoot, bundleId!);\n return config;\n },\n ]);\n};\n\nfunction getBundleIdentifier(config: Pick<ExpoConfig, 'ios'>): string | null {\n return config.ios?.bundleIdentifier ?? null;\n}\n\n/**\n * In Turtle v1 we set the bundleIdentifier directly on Info.plist rather\n * than in pbxproj\n */\nfunction setBundleIdentifier(config: ExpoConfig, infoPlist: InfoPlist): InfoPlist {\n const bundleIdentifier = getBundleIdentifier(config);\n\n if (!bundleIdentifier) {\n return infoPlist;\n }\n\n return {\n ...infoPlist,\n CFBundleIdentifier: bundleIdentifier,\n };\n}\n\n/**\n * Gets the bundle identifier defined in the Xcode project found in the project directory.\n *\n * A bundle identifier is stored as a value in XCBuildConfiguration entry.\n * Those entries exist for every pair (build target, build configuration).\n * Unless target name is passed, the first target defined in the pbxproj is used\n * (to keep compatibility with the inaccurate legacy implementation of this function).\n * The build configuration is usually 'Release' or 'Debug'. However, it could be any arbitrary string.\n * Defaults to 'Release'.\n *\n * @param {string} projectRoot Path to project root containing the ios directory\n * @param {string} targetName Target name\n * @param {string} buildConfiguration Build configuration. Defaults to 'Release'.\n * @returns {string | null} bundle identifier of the Xcode project or null if the project is not configured\n */\nfunction getBundleIdentifierFromPbxproj(\n projectRoot: string,\n {\n targetName,\n buildConfiguration = 'Release',\n }: { targetName?: string; buildConfiguration?: string } = {}\n): string | null {\n let pbxprojPath: string;\n try {\n pbxprojPath = getPBXProjectPath(projectRoot);\n } catch {\n return null;\n }\n const project = xcode.project(pbxprojPath);\n project.parseSync();\n\n const xcBuildConfiguration = getXCBuildConfigurationFromPbxproj(project, {\n targetName,\n buildConfiguration,\n });\n if (!xcBuildConfiguration) {\n return null;\n }\n return getProductBundleIdentifierFromBuildConfiguration(xcBuildConfiguration);\n}\n\nfunction getProductBundleIdentifierFromBuildConfiguration(\n xcBuildConfiguration: XCBuildConfiguration\n): string | null {\n const bundleIdentifierRaw = xcBuildConfiguration.buildSettings.PRODUCT_BUNDLE_IDENTIFIER;\n if (bundleIdentifierRaw) {\n const bundleIdentifier = trimQuotes(bundleIdentifierRaw);\n // it's possible to use interpolation for the bundle identifier\n // the most common case is when the last part of the id is set to `$(PRODUCT_NAME:rfc1034identifier)`\n // in this case, PRODUCT_NAME should be replaced with its value\n // the `rfc1034identifier` modifier replaces all non-alphanumeric characters with dashes\n const bundleIdentifierParts = bundleIdentifier.split('.');\n if (\n bundleIdentifierParts[bundleIdentifierParts.length - 1] ===\n '$(PRODUCT_NAME:rfc1034identifier)' &&\n xcBuildConfiguration.buildSettings.PRODUCT_NAME\n ) {\n bundleIdentifierParts[\n bundleIdentifierParts.length - 1\n ] = xcBuildConfiguration.buildSettings.PRODUCT_NAME.replace(/[^a-zA-Z0-9]/g, '-');\n }\n return bundleIdentifierParts.join('.');\n } else {\n return null;\n }\n}\n\n/**\n * Updates the bundle identifier for a given pbxproj\n *\n * @param {string} pbxprojPath Path to pbxproj file\n * @param {string} bundleIdentifier Bundle identifier to set in the pbxproj\n * @param {boolean} [updateProductName=true] Whether to update PRODUCT_NAME\n */\nfunction updateBundleIdentifierForPbxproj(\n pbxprojPath: string,\n bundleIdentifier: string,\n updateProductName: boolean = true\n): void {\n const project = xcode.project(pbxprojPath);\n project.parseSync();\n\n const [, nativeTarget] = findFirstNativeTarget(project);\n\n getBuildConfigurationsForListId(project, nativeTarget.buildConfigurationList).forEach(\n ([, item]: ConfigurationSectionEntry) => {\n if (item.buildSettings.PRODUCT_BUNDLE_IDENTIFIER === bundleIdentifier) {\n return;\n }\n\n item.buildSettings.PRODUCT_BUNDLE_IDENTIFIER = `\"${bundleIdentifier}\"`;\n\n if (updateProductName) {\n const productName = bundleIdentifier.split('.').pop();\n if (!productName?.includes('$')) {\n item.buildSettings.PRODUCT_NAME = productName;\n }\n }\n }\n );\n fs.writeFileSync(pbxprojPath, project.writeSync());\n}\n\n/**\n * Updates the bundle identifier for pbx projects inside the ios directory of the given project root\n *\n * @param {string} projectRoot Path to project root containing the ios directory\n * @param {string} bundleIdentifier Desired bundle identifier\n * @param {boolean} [updateProductName=true] Whether to update PRODUCT_NAME\n */\nfunction setBundleIdentifierForPbxproj(\n projectRoot: string,\n bundleIdentifier: string,\n updateProductName: boolean = true\n): void {\n // Get all pbx projects in the ${projectRoot}/ios directory\n let pbxprojPaths: string[] = [];\n try {\n pbxprojPaths = getAllPBXProjectPaths(projectRoot);\n } catch {}\n\n for (const pbxprojPath of pbxprojPaths) {\n updateBundleIdentifierForPbxproj(pbxprojPath, bundleIdentifier, updateProductName);\n }\n}\n\n/**\n * Reset bundle identifier field in Info.plist to use PRODUCT_BUNDLE_IDENTIFIER, as recommended by Apple.\n */\n\nconst defaultBundleId = '$(PRODUCT_BUNDLE_IDENTIFIER)';\n\nfunction resetAllPlistBundleIdentifiers(projectRoot: string): void {\n const infoPlistPaths = getAllInfoPlistPaths(projectRoot);\n\n for (const plistPath of infoPlistPaths) {\n resetPlistBundleIdentifier(plistPath);\n }\n}\n\nfunction resetPlistBundleIdentifier(plistPath: string): void {\n const rawPlist = fs.readFileSync(plistPath, 'utf8');\n const plistObject = plist.parse(rawPlist) as PlistObject;\n\n if (plistObject.CFBundleIdentifier) {\n if (plistObject.CFBundleIdentifier === defaultBundleId) return;\n\n // attempt to match default Info.plist format\n const format = { pretty: true, indent: `\\t` };\n\n const xml = plist.build(\n {\n ...plistObject,\n CFBundleIdentifier: defaultBundleId,\n },\n format\n );\n\n if (xml !== rawPlist) {\n fs.writeFileSync(plistPath, xml);\n }\n }\n}\n\nexport {\n getBundleIdentifier,\n setBundleIdentifier,\n getBundleIdentifierFromPbxproj,\n updateBundleIdentifierForPbxproj,\n setBundleIdentifierForPbxproj,\n resetAllPlistBundleIdentifiers,\n resetPlistBundleIdentifier,\n};\n"],"file":"BundleIdentifier.js"}
package/build/ios/Maps.js CHANGED
@@ -14,30 +14,30 @@ exports.removeMapsCocoaPods = removeMapsCocoaPods;
14
14
  exports.setGoogleMapsApiKey = setGoogleMapsApiKey;
15
15
  exports.withMaps = void 0;
16
16
 
17
- function _debug() {
18
- const data = _interopRequireDefault(require("debug"));
17
+ function _fsExtra() {
18
+ const data = _interopRequireDefault(require("fs-extra"));
19
19
 
20
- _debug = function () {
20
+ _fsExtra = function () {
21
21
  return data;
22
22
  };
23
23
 
24
24
  return data;
25
25
  }
26
26
 
27
- function _fsExtra() {
28
- const data = _interopRequireDefault(require("fs-extra"));
27
+ function _path() {
28
+ const data = _interopRequireDefault(require("path"));
29
29
 
30
- _fsExtra = function () {
30
+ _path = function () {
31
31
  return data;
32
32
  };
33
33
 
34
34
  return data;
35
35
  }
36
36
 
37
- function _path() {
38
- const data = _interopRequireDefault(require("path"));
37
+ function _resolveFrom() {
38
+ const data = _interopRequireDefault(require("resolve-from"));
39
39
 
40
- _path = function () {
40
+ _resolveFrom = function () {
41
41
  return data;
42
42
  };
43
43
 
@@ -74,19 +74,10 @@ function _generateCode() {
74
74
  return data;
75
75
  }
76
76
 
77
- function _resolvePackageRootFolder() {
78
- const data = require("../utils/resolvePackageRootFolder");
79
-
80
- _resolvePackageRootFolder = function () {
81
- return data;
82
- };
83
-
84
- return data;
85
- }
86
-
87
77
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
88
78
 
89
- const debug = (0, _debug().default)('expo:config-plugins:ios:maps'); // Match against `UMModuleRegistryAdapter` (unimodules), and React Native without unimodules (Expo Modules).
79
+ const debug = require('debug')('expo:config-plugins:ios:maps'); // Match against `UMModuleRegistryAdapter` (unimodules), and React Native without unimodules (Expo Modules).
80
+
90
81
 
91
82
  const MATCH_INIT = /(?:(self\.|_)(\w+)\s?=\s?\[\[UMModuleRegistryAdapter alloc\])|(?:RCTBridge\s?\*\s?(\w+)\s?=\s?\[\[RCTBridge alloc\])/g;
92
83
  exports.MATCH_INIT = MATCH_INIT;
@@ -196,7 +187,9 @@ function removeMapsCocoaPods(src) {
196
187
  }
197
188
 
198
189
  function isReactNativeMapsInstalled(projectRoot) {
199
- return (0, _resolvePackageRootFolder().resolvePackageRootFolder)(projectRoot, 'react-native-maps');
190
+ const resolved = _resolveFrom().default.silent(projectRoot, 'react-native-maps/package.json');
191
+
192
+ return resolved ? _path().default.dirname(resolved) : null;
200
193
  }
201
194
 
202
195
  function isReactNativeMapsAutolinked(config) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ios/Maps.ts"],"names":["debug","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","isReactNativeMapsAutolinked","filePath","path","modRequest","platformProjectRoot","contents","fs","readFile","results","isLinked","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;;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;;;;AAEA,MAAMA,KAAK,GAAG,sBAAM,8BAAN,CAAd,C,CAEA;;AACO,MAAMC,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;;AAEAL,EAAAA,KAAK,CAAC,sBAAD,EAAyBM,MAAzB,CAAL;AACAD,EAAAA,MAAM,GAAGG,iBAAiB,CAACH,MAAD,EAAS;AAAEI,IAAAA,aAAa,EAAE,CAAC,CAACH;AAAnB,GAAT,CAA1B,CAP8C,CAS9C;;AACAD,EAAAA,MAAM,GAAGK,yBAAyB,CAACL,MAAD,EAAS;AAA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EAAwBA,MAAM,IAAI;AACvC,QAAIA,MAAM,CAAC6C,UAAP,CAAkBC,QAAlB,KAA+B,MAAnC,EAA2C;AACzC,UACE7C,MAAM,IACN0B,2BAA2B,CAAC3B,MAAD,CAD3B,IAEAyB,0BAA0B,CAACzB,MAAM,CAAC8B,UAAP,CAAkBJ,WAAnB,CAH5B,EAIE;AACA,YAAI;AACF1B,UAAAA,MAAM,CAAC6C,UAAP,CAAkBb,QAAlB,GAA6BtB,8BAA8B,CACzDV,MAAM,CAAC6C,UAAP,CAAkBb,QADuC,CAA9B,CAE3BA,QAFF;AAGAhC,UAAAA,MAAM,CAAC6C,UAAP,CAAkBb,QAAlB,GAA6BZ,4BAA4B,CACvDpB,MAAM,CAAC6C,UAAP,CAAkBb,QADqC,EAEvD/B,MAFuD,CAA5B,CAG3B+B,QAHF;AAID,SARD,CAQE,OAAOO,KAAP,EAAc;AACd,cAAIA,KAAK,CAACC,IAAN,KAAe,cAAnB,EAAmC;AACjC,kBAAM,IAAIC,KAAJ,CACH,yIADG,CAAN;AAGD;;AACD,gBAAMF,KAAN;AACD;AACF,OArBD,MAqBO;AACLvC,QAAAA,MAAM,CAAC6C,UAAP,CAAkBb,QAAlB,GAA6Bb,iCAAiC,CAC5DnB,MAAM,CAAC6C,UAAP,CAAkBb,QAD0C,CAAjC,CAE3BA,QAFF;AAGAhC,QAAAA,MAAM,CAAC6C,UAAP,CAAkBb,QAAlB,GAA6BX,+BAA+B,CAC1DrB,MAAM,CAAC6C,UAAP,CAAkBb,QADwC,CAA/B,CAE3BA,QAFF;AAGD;AACF,KA9BD,MA8BO;AACL,YAAM,IAAIS,KAAJ,CAAU,qEAAV,CAAN;AACD;;AACD,WAAOzC,MAAP;AACD,GAnCM,CAAP;AAoCD,CArCD","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport Debug from 'debug';\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\nconst debug = Debug('expo:config-plugins:ios:maps');\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\n debug('Google Maps API Key:', apiKey);\n config = withMapsCocoaPods(config, { useGoogleMaps: !!apiKey });\n\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\nfunction isReactNativeMapsAutolinked(config: Pick<ExpoConfig, '_internal'>): boolean {\n // TODO: Detect autolinking\n return true;\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 const isLinked = isReactNativeMapsAutolinked(config);\n debug('Is Expo Autolinked:', isLinked);\n debug('react-native-maps path:', googleMapsPath);\n if (isLinked && 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: any) {\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 (\n apiKey &&\n isReactNativeMapsAutolinked(config) &&\n isReactNativeMapsInstalled(config.modRequest.projectRoot)\n ) {\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":["debug","require","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","resolved","resolveFrom","silent","path","dirname","isReactNativeMapsAutolinked","filePath","modRequest","platformProjectRoot","contents","fs","readFile","results","isLinked","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;;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;;;;AAEA,MAAMA,KAAK,GAAGC,OAAO,CAAC,OAAD,CAAP,CAAiB,8BAAjB,CAAd,C,CAEA;;;AACO,MAAMC,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;;AAEAN,EAAAA,KAAK,CAAC,sBAAD,EAAyBO,MAAzB,CAAL;AACAD,EAAAA,MAAM,GAAGG,iBAAiB,CAACH,MAAD,EAAS;AAAEI,IAAAA,aAAa,EAAE,CAAC,CAACH;AAAnB,GAAT,CAA1B,CAP8C,CAS9C;;AACAD,EAAAA,MAAM,GAA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ExpoConfig } from '@expo/config-types';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\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';\n\nconst debug = require('debug')('expo:config-plugins:ios:maps') as typeof console.log;\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\n debug('Google Maps API Key:', apiKey);\n config = withMapsCocoaPods(config, { useGoogleMaps: !!apiKey });\n\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 const resolved = resolveFrom.silent(projectRoot, 'react-native-maps/package.json');\n return resolved ? path.dirname(resolved) : null;\n}\n\nfunction isReactNativeMapsAutolinked(config: Pick<ExpoConfig, '_internal'>): boolean {\n // TODO: Detect autolinking\n return true;\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 const isLinked = isReactNativeMapsAutolinked(config);\n debug('Is Expo Autolinked:', isLinked);\n debug('react-native-maps path:', googleMapsPath);\n if (isLinked && 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: any) {\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 (\n apiKey &&\n isReactNativeMapsAutolinked(config) &&\n isReactNativeMapsInstalled(config.modRequest.projectRoot)\n ) {\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"}
@@ -46,17 +46,26 @@ function setProvisioningProfileForPbxproj(projectRoot, {
46
46
  const project = (0, _Xcodeproj().getPbxproj)(projectRoot);
47
47
  const nativeTargetEntry = targetName ? (0, _Target().findNativeTargetByName)(project, targetName) : (0, _Target().findFirstNativeTarget)(project);
48
48
  const [nativeTargetId, nativeTarget] = nativeTargetEntry;
49
+ const quotedAppleTeamId = ensureQuotes(appleTeamId);
49
50
  (0, _Xcodeproj().getBuildConfigurationsForListId)(project, nativeTarget.buildConfigurationList).filter(([, item]) => item.name === buildConfiguration).forEach(([, item]) => {
50
51
  item.buildSettings.PROVISIONING_PROFILE_SPECIFIER = `"${profileName}"`;
51
- item.buildSettings.DEVELOPMENT_TEAM = appleTeamId;
52
+ item.buildSettings.DEVELOPMENT_TEAM = quotedAppleTeamId;
52
53
  item.buildSettings.CODE_SIGN_IDENTITY = '"iPhone Distribution"';
53
54
  item.buildSettings.CODE_SIGN_STYLE = 'Manual';
54
55
  });
55
56
  Object.entries((0, _Xcodeproj().getProjectSection)(project)).filter(_Xcodeproj().isNotComment).forEach(([, item]) => {
56
- item.attributes.TargetAttributes[nativeTargetId].DevelopmentTeam = appleTeamId;
57
+ item.attributes.TargetAttributes[nativeTargetId].DevelopmentTeam = quotedAppleTeamId;
57
58
  item.attributes.TargetAttributes[nativeTargetId].ProvisioningStyle = 'Manual';
58
59
  });
59
60
 
60
61
  _fsExtra().default.writeFileSync(project.filepath, project.writeSync());
61
62
  }
63
+
64
+ const ensureQuotes = value => {
65
+ if (!value.match(/^['"]/)) {
66
+ return `"${value}"`;
67
+ }
68
+
69
+ return value;
70
+ };
62
71
  //# sourceMappingURL=ProvisioningProfile.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ios/ProvisioningProfile.ts"],"names":["setProvisioningProfileForPbxproj","projectRoot","targetName","profileName","appleTeamId","buildConfiguration","project","nativeTargetEntry","nativeTargetId","nativeTarget","buildConfigurationList","filter","item","name","forEach","buildSettings","PROVISIONING_PROFILE_SPECIFIER","DEVELOPMENT_TEAM","CODE_SIGN_IDENTITY","CODE_SIGN_STYLE","Object","entries","isNotComment","attributes","TargetAttributes","DevelopmentTeam","ProvisioningStyle","fs","writeFileSync","filepath","writeSync"],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAgBO,SAASA,gCAAT,CACLC,WADK,EAEL;AACEC,EAAAA,UADF;AAEEC,EAAAA,WAFF;AAGEC,EAAAA,WAHF;AAIEC,EAAAA,kBAAkB,GAAG;AAJvB,CAFK,EAQC;AACN,QAAMC,OAAO,GAAG,6BAAWL,WAAX,CAAhB;AAEA,QAAMM,iBAAiB,GAAGL,UAAU,GAChC,sCAAuBI,OAAvB,EAAgCJ,UAAhC,CADgC,GAEhC,qCAAsBI,OAAtB,CAFJ;AAGA,QAAM,CAACE,cAAD,EAAiBC,YAAjB,IAAiCF,iBAAvC;AAEA,oDAAgCD,OAAhC,EAAyCG,YAAY,CAACC,sBAAtD,EACGC,MADH,CACU,CAAC,GAAGC,IAAH,CAAD,KAAyCA,IAAI,CAACC,IAAL,KAAcR,kBADjE,EAEGS,OAFH,CAEW,CAAC,GAAGF,IAAH,CAAD,KAAyC;AAChDA,IAAAA,IAAI,CAACG,aAAL,CAAmBC,8BAAnB,GAAqD,IAAGb,WAAY,GAApE;AACAS,IAAAA,IAAI,CAACG,aAAL,CAAmBE,gBAAnB,GAAsCb,WAAtC;AACAQ,IAAAA,IAAI,CAACG,aAAL,CAAmBG,kBAAnB,GAAwC,uBAAxC;AACAN,IAAAA,IAAI,CAACG,aAAL,CAAmBI,eAAnB,GAAqC,QAArC;AACD,GAPH;AASAC,EAAAA,MAAM,CAACC,OAAP,CAAe,oCAAkBf,OAAlB,CAAf,EACGK,MADH,CACUW,yBADV,EAEGR,OAFH,CAEW,CAAC,GAAGF,IAAH,CAAD,KAAmC;AAC1CA,IAAAA,IAAI,CAACW,UAAL,CAAgBC,gBAAhB,CAAiChB,cAAjC,EAAiDiB,eAAjD,GAAmErB,WAAnE;AACAQ,IAAAA,IAAI,CAACW,UAAL,CAAgBC,gBAAhB,CAAiChB,cAAjC,EAAiDkB,iBAAjD,GAAqE,QAArE;AACD,GALH;;AAOAC,qBAAGC,aAAH,CAAiBtB,OAAO,CAACuB,QAAzB,EAAmCvB,OAAO,CAACwB,SAAR,EAAnC;AACD","sourcesContent":["import fs from 'fs-extra';\n\nimport { findFirstNativeTarget, findNativeTargetByName } from './Target';\nimport {\n ConfigurationSectionEntry,\n getBuildConfigurationsForListId,\n getPbxproj,\n getProjectSection,\n isNotComment,\n ProjectSectionEntry,\n} from './utils/Xcodeproj';\n\ntype ProvisioningProfileSettings = {\n targetName?: string;\n appleTeamId: string;\n profileName: string;\n buildConfiguration?: string;\n};\n\nexport function setProvisioningProfileForPbxproj(\n projectRoot: string,\n {\n targetName,\n profileName,\n appleTeamId,\n buildConfiguration = 'Release',\n }: ProvisioningProfileSettings\n): void {\n const project = getPbxproj(projectRoot);\n\n const nativeTargetEntry = targetName\n ? findNativeTargetByName(project, targetName)\n : findFirstNativeTarget(project);\n const [nativeTargetId, nativeTarget] = nativeTargetEntry;\n\n getBuildConfigurationsForListId(project, nativeTarget.buildConfigurationList)\n .filter(([, item]: ConfigurationSectionEntry) => item.name === buildConfiguration)\n .forEach(([, item]: ConfigurationSectionEntry) => {\n item.buildSettings.PROVISIONING_PROFILE_SPECIFIER = `\"${profileName}\"`;\n item.buildSettings.DEVELOPMENT_TEAM = appleTeamId;\n item.buildSettings.CODE_SIGN_IDENTITY = '\"iPhone Distribution\"';\n item.buildSettings.CODE_SIGN_STYLE = 'Manual';\n });\n\n Object.entries(getProjectSection(project))\n .filter(isNotComment)\n .forEach(([, item]: ProjectSectionEntry) => {\n item.attributes.TargetAttributes[nativeTargetId].DevelopmentTeam = appleTeamId;\n item.attributes.TargetAttributes[nativeTargetId].ProvisioningStyle = 'Manual';\n });\n\n fs.writeFileSync(project.filepath, project.writeSync());\n}\n"],"file":"ProvisioningProfile.js"}
1
+ {"version":3,"sources":["../../src/ios/ProvisioningProfile.ts"],"names":["setProvisioningProfileForPbxproj","projectRoot","targetName","profileName","appleTeamId","buildConfiguration","project","nativeTargetEntry","nativeTargetId","nativeTarget","quotedAppleTeamId","ensureQuotes","buildConfigurationList","filter","item","name","forEach","buildSettings","PROVISIONING_PROFILE_SPECIFIER","DEVELOPMENT_TEAM","CODE_SIGN_IDENTITY","CODE_SIGN_STYLE","Object","entries","isNotComment","attributes","TargetAttributes","DevelopmentTeam","ProvisioningStyle","fs","writeFileSync","filepath","writeSync","value","match"],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAgBO,SAASA,gCAAT,CACLC,WADK,EAEL;AACEC,EAAAA,UADF;AAEEC,EAAAA,WAFF;AAGEC,EAAAA,WAHF;AAIEC,EAAAA,kBAAkB,GAAG;AAJvB,CAFK,EAQC;AACN,QAAMC,OAAO,GAAG,6BAAWL,WAAX,CAAhB;AAEA,QAAMM,iBAAiB,GAAGL,UAAU,GAChC,sCAAuBI,OAAvB,EAAgCJ,UAAhC,CADgC,GAEhC,qCAAsBI,OAAtB,CAFJ;AAGA,QAAM,CAACE,cAAD,EAAiBC,YAAjB,IAAiCF,iBAAvC;AAEA,QAAMG,iBAAiB,GAAGC,YAAY,CAACP,WAAD,CAAtC;AAEA,oDAAgCE,OAAhC,EAAyCG,YAAY,CAACG,sBAAtD,EACGC,MADH,CACU,CAAC,GAAGC,IAAH,CAAD,KAAyCA,IAAI,CAACC,IAAL,KAAcV,kBADjE,EAEGW,OAFH,CAEW,CAAC,GAAGF,IAAH,CAAD,KAAyC;AAChDA,IAAAA,IAAI,CAACG,aAAL,CAAmBC,8BAAnB,GAAqD,IAAGf,WAAY,GAApE;AACAW,IAAAA,IAAI,CAACG,aAAL,CAAmBE,gBAAnB,GAAsCT,iBAAtC;AACAI,IAAAA,IAAI,CAACG,aAAL,CAAmBG,kBAAnB,GAAwC,uBAAxC;AACAN,IAAAA,IAAI,CAACG,aAAL,CAAmBI,eAAnB,GAAqC,QAArC;AACD,GAPH;AASAC,EAAAA,MAAM,CAACC,OAAP,CAAe,oCAAkBjB,OAAlB,CAAf,EACGO,MADH,CACUW,yBADV,EAEGR,OAFH,CAEW,CAAC,GAAGF,IAAH,CAAD,KAAmC;AAC1CA,IAAAA,IAAI,CAACW,UAAL,CAAgBC,gBAAhB,CAAiClB,cAAjC,EAAiDmB,eAAjD,GAAmEjB,iBAAnE;AACAI,IAAAA,IAAI,CAACW,UAAL,CAAgBC,gBAAhB,CAAiClB,cAAjC,EAAiDoB,iBAAjD,GAAqE,QAArE;AACD,GALH;;AAOAC,qBAAGC,aAAH,CAAiBxB,OAAO,CAACyB,QAAzB,EAAmCzB,OAAO,CAAC0B,SAAR,EAAnC;AACD;;AAED,MAAMrB,YAAY,GAAIsB,KAAD,IAAmB;AACtC,MAAI,CAACA,KAAK,CAACC,KAAN,CAAY,OAAZ,CAAL,EAA2B;AACzB,WAAQ,IAAGD,KAAM,GAAjB;AACD;;AACD,SAAOA,KAAP;AACD,CALD","sourcesContent":["import fs from 'fs-extra';\n\nimport { findFirstNativeTarget, findNativeTargetByName } from './Target';\nimport {\n ConfigurationSectionEntry,\n getBuildConfigurationsForListId,\n getPbxproj,\n getProjectSection,\n isNotComment,\n ProjectSectionEntry,\n} from './utils/Xcodeproj';\n\ntype ProvisioningProfileSettings = {\n targetName?: string;\n appleTeamId: string;\n profileName: string;\n buildConfiguration?: string;\n};\n\nexport function setProvisioningProfileForPbxproj(\n projectRoot: string,\n {\n targetName,\n profileName,\n appleTeamId,\n buildConfiguration = 'Release',\n }: ProvisioningProfileSettings\n): void {\n const project = getPbxproj(projectRoot);\n\n const nativeTargetEntry = targetName\n ? findNativeTargetByName(project, targetName)\n : findFirstNativeTarget(project);\n const [nativeTargetId, nativeTarget] = nativeTargetEntry;\n\n const quotedAppleTeamId = ensureQuotes(appleTeamId);\n\n getBuildConfigurationsForListId(project, nativeTarget.buildConfigurationList)\n .filter(([, item]: ConfigurationSectionEntry) => item.name === buildConfiguration)\n .forEach(([, item]: ConfigurationSectionEntry) => {\n item.buildSettings.PROVISIONING_PROFILE_SPECIFIER = `\"${profileName}\"`;\n item.buildSettings.DEVELOPMENT_TEAM = quotedAppleTeamId;\n item.buildSettings.CODE_SIGN_IDENTITY = '\"iPhone Distribution\"';\n item.buildSettings.CODE_SIGN_STYLE = 'Manual';\n });\n\n Object.entries(getProjectSection(project))\n .filter(isNotComment)\n .forEach(([, item]: ProjectSectionEntry) => {\n item.attributes.TargetAttributes[nativeTargetId].DevelopmentTeam = quotedAppleTeamId;\n item.attributes.TargetAttributes[nativeTargetId].ProvisioningStyle = 'Manual';\n });\n\n fs.writeFileSync(project.filepath, project.writeSync());\n}\n\nconst ensureQuotes = (value: string) => {\n if (!value.match(/^['\"]/)) {\n return `\"${value}\"`;\n }\n return value;\n};\n"],"file":"ProvisioningProfile.js"}
@@ -32,6 +32,16 @@ function _Xcodeproj() {
32
32
  return data;
33
33
  }
34
34
 
35
+ function _string() {
36
+ const data = require("./utils/string");
37
+
38
+ _string = function () {
39
+ return data;
40
+ };
41
+
42
+ return data;
43
+ }
44
+
35
45
  let TargetType;
36
46
  exports.TargetType = TargetType;
37
47
 
@@ -59,7 +69,20 @@ async function findApplicationTargetWithDependenciesAsync(projectRoot, scheme) {
59
69
  const applicationTargetName = await (0, _BuildScheme().getApplicationTargetNameForSchemeAsync)(projectRoot, scheme);
60
70
  const project = (0, _Xcodeproj().getPbxproj)(projectRoot);
61
71
  const [, applicationTarget] = findNativeTargetByName(project, applicationTargetName);
62
- const dependencies = applicationTarget.dependencies.map(({
72
+ const dependencies = getTargetDependencies(project, applicationTarget);
73
+ return {
74
+ name: (0, _string().trimQuotes)(applicationTarget.name),
75
+ type: TargetType.APPLICATION,
76
+ dependencies
77
+ };
78
+ }
79
+
80
+ function getTargetDependencies(project, parentTarget) {
81
+ if (!parentTarget.dependencies || parentTarget.dependencies.length === 0) {
82
+ return undefined;
83
+ }
84
+
85
+ return parentTarget.dependencies.map(({
63
86
  value
64
87
  }) => {
65
88
  const {
@@ -68,19 +91,15 @@ async function findApplicationTargetWithDependenciesAsync(projectRoot, scheme) {
68
91
  const [, target] = findNativeTargetById(project, targetId);
69
92
  const type = isTargetOfType(target, TargetType.EXTENSION) ? TargetType.EXTENSION : TargetType.OTHER;
70
93
  return {
71
- name: target.name,
72
- type
94
+ name: (0, _string().trimQuotes)(target.name),
95
+ type,
96
+ dependencies: getTargetDependencies(project, target)
73
97
  };
74
98
  });
75
- return {
76
- name: applicationTarget.name,
77
- type: TargetType.APPLICATION,
78
- dependencies
79
- };
80
99
  }
81
100
 
82
101
  function isTargetOfType(target, targetType) {
83
- return target.productType === targetType || target.productType === `"${targetType}"`;
102
+ return (0, _string().trimQuotes)(target.productType) === targetType;
84
103
  }
85
104
 
86
105
  function getNativeTargets(project) {
@@ -112,7 +131,7 @@ function findFirstNativeTarget(project) {
112
131
 
113
132
  function findNativeTargetByName(project, targetName) {
114
133
  const nativeTargets = getNativeTargets(project);
115
- const nativeTargetEntry = nativeTargets.find(([, i]) => i.name === targetName || i.name === `"${targetName}"`);
134
+ const nativeTargetEntry = nativeTargets.find(([, i]) => (0, _string().trimQuotes)(i.name) === targetName);
116
135
 
117
136
  if (!nativeTargetEntry) {
118
137
  throw new Error(`Could not find target '${targetName}' in project.pbxproj`);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ios/Target.ts"],"names":["TargetType","getXCBuildConfigurationFromPbxproj","project","targetName","buildConfiguration","nativeTarget","findNativeTargetByName","findFirstNativeTarget","xcBuildConfiguration","configurationListId","buildConfigurationList","findApplicationTargetWithDependenciesAsync","projectRoot","scheme","applicationTargetName","applicationTarget","dependencies","map","value","target","targetId","getPBXGroupByKeyAndType","findNativeTargetById","type","isTargetOfType","EXTENSION","OTHER","name","APPLICATION","targetType","productType","getNativeTargets","section","pbxNativeTargetSection","Object","entries","filter","isNotComment","findSignableTargets","targets","applicationTargets","WATCH","STICKER_PACK_EXTENSION","length","Error","nativeTargets","nativeTargetEntry","find","i","key"],"mappings":";;;;;;;;;;;;;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;IAOYA,U;;;WAAAA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;GAAAA,U,0BAAAA,U;;AAcL,SAASC,kCAAT,CACLC,OADK,EAEL;AACEC,EAAAA,UADF;AAEEC,EAAAA,kBAAkB,GAAG;AAFvB,IAG0D,EALrD,EAMwB;AAC7B,QAAM,GAAGC,YAAH,IAAmBF,UAAU,GAC/BG,sBAAsB,CAACJ,OAAD,EAAUC,UAAV,CADS,GAE/BI,qBAAqB,CAACL,OAAD,CAFzB;AAGA,QAAM,GAAGM,oBAAH,IAA2B,wDAAsCN,OAAtC,EAA+C;AAC9EO,IAAAA,mBAAmB,EAAEJ,YAAY,CAACK,sBAD4C;AAE9EN,IAAAA;AAF8E,GAA/C,CAAjC;AAIA,SAAOI,oBAAP,aAAOA,oBAAP,cAAOA,oBAAP,GAA+B,IAA/B;AACD;;AAEM,eAAeG,0CAAf,CACLC,WADK,EAELC,MAFK,EAGY;AACjB,QAAMC,qBAAqB,GAAG,MAAM,2DAAuCF,WAAvC,EAAoDC,MAApD,CAApC;AACA,QAAMX,OAAO,GAAG,6BAAWU,WAAX,CAAhB;AACA,QAAM,GAAGG,iBAAH,IAAwBT,sBAAsB,CAACJ,OAAD,EAAUY,qBAAV,CAApD;AAEA,QAAME,YAAsB,GAAGD,iBAAiB,CAACC,YAAl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,CAAC7B,OAAD,CAAtC;AACA,QAAM4C,iBAAiB,GAAGD,aAAa,CAACE,IAAd,CAAmB,CAAC,CAACE,GAAD,CAAD,KAAWA,GAAG,KAAK7B,QAAtC,CAA1B;;AACA,MAAI,CAAC0B,iBAAL,EAAwB;AACtB,UAAM,IAAIF,KAAJ,CAAW,kCAAiCxB,QAAS,sBAArD,CAAN;AACD;;AACD,SAAO0B,iBAAP;AACD","sourcesContent":["import { PBXNativeTarget, PBXTargetDependency, XCBuildConfiguration, XcodeProject } from 'xcode';\n\nimport { getApplicationTargetNameForSchemeAsync } from './BuildScheme';\nimport {\n getBuildConfigurationForListIdAndName,\n getPbxproj,\n isNotComment,\n NativeTargetSectionEntry,\n} from './utils/Xcodeproj';\n\nexport enum TargetType {\n APPLICATION = 'com.apple.product-type.application',\n EXTENSION = 'com.apple.product-type.app-extension',\n WATCH = 'com.apple.product-type.application.watchapp',\n STICKER_PACK_EXTENSION = 'com.apple.product-type.app-extension.messages-sticker-pack',\n OTHER = 'other',\n}\n\nexport interface Target {\n name: string;\n type: TargetType;\n dependencies?: Target[];\n}\n\nexport function getXCBuildConfigurationFromPbxproj(\n project: XcodeProject,\n {\n targetName,\n buildConfiguration = 'Release',\n }: { targetName?: string; buildConfiguration?: string } = {}\n): XCBuildConfiguration | null {\n const [, nativeTarget] = targetName\n ? findNativeTargetByName(project, targetName)\n : findFirstNativeTarget(project);\n const [, xcBuildConfiguration] = getBuildConfigurationForListIdAndName(project, {\n configurationListId: nativeTarget.buildConfigurationList,\n buildConfiguration,\n });\n return xcBuildConfiguration ?? null;\n}\n\nexport async function findApplicationTargetWithDependenciesAsync(\n projectRoot: string,\n scheme: string\n): Promise<Target> {\n const applicationTargetName = await getApplicationTargetNameForSchemeAsync(projectRoot, scheme);\n const project = getPbxproj(projectRoot);\n const [, applicationTarget] = findNativeTargetByName(project, applicationTargetName);\n\n const dependencies: Target[] = applicationTarget.dependencies.map(({ value }) => {\n const { target: targetId } = project.getPBXGroupByKeyAndType(\n value,\n 'PBXTargetDependency'\n ) as PBXTargetDependency;\n\n const [, target] = findNativeTargetById(project, targetId);\n\n const type = isTargetOfType(target, TargetType.EXTENSION)\n ? TargetType.EXTENSION\n : TargetType.OTHER;\n return {\n name: target.name,\n type,\n };\n });\n\n return {\n name: applicationTarget.name,\n type: TargetType.APPLICATION,\n dependencies,\n };\n}\n\nexport function isTargetOfType(target: PBXNativeTarget, targetType: TargetType): boolean {\n return target.productType === targetType || target.productType === `\"${targetType}\"`;\n}\n\nexport function getNativeTargets(project: XcodeProject): NativeTargetSectionEntry[] {\n const section = project.pbxNativeTargetSection();\n return Object.entries(section).filter(isNotComment);\n}\n\nexport function findSignableTargets(project: XcodeProject): NativeTargetSectionEntry[] {\n const targets = getNativeTargets(project);\n const applicationTargets = targets.filter(\n ([, target]) =>\n isTargetOfType(target, TargetType.APPLICATION) ||\n isTargetOfType(target, TargetType.EXTENSION) ||\n isTargetOfType(target, TargetType.WATCH) ||\n isTargetOfType(target, TargetType.STICKER_PACK_EXTENSION)\n );\n if (applicationTargets.length === 0) {\n throw new Error(`Could not find any signable targets in project.pbxproj`);\n }\n return applicationTargets;\n}\n\nexport function findFirstNativeTarget(project: XcodeProject): NativeTargetSectionEntry {\n const targets = getNativeTargets(project);\n const applicationTargets = targets.filter(([, target]) =>\n isTargetOfType(target, TargetType.APPLICATION)\n );\n if (applicationTargets.length === 0) {\n throw new Error(`Could not find any application target in project.pbxproj`);\n }\n return applicationTargets[0];\n}\n\nexport function findNativeTargetByName(\n project: XcodeProject,\n targetName: string\n): NativeTargetSectionEntry {\n const nativeTargets = getNativeTargets(project);\n const nativeTargetEntry = nativeTargets.find(\n ([, i]) => i.name === targetName || i.name === `\"${targetName}\"`\n );\n if (!nativeTargetEntry) {\n throw new Error(`Could not find target '${targetName}' in project.pbxproj`);\n }\n return nativeTargetEntry;\n}\n\nfunction findNativeTargetById(project: XcodeProject, targetId: string): NativeTargetSectionEntry {\n const nativeTargets = getNativeTargets(project);\n const nativeTargetEntry = nativeTargets.find(([key]) => key === targetId);\n if (!nativeTargetEntry) {\n throw new Error(`Could not find target with id '${targetId}' in project.pbxproj`);\n }\n return nativeTargetEntry;\n}\n"],"file":"Target.js"}
1
+ {"version":3,"sources":["../../src/ios/Target.ts"],"names":["TargetType","getXCBuildConfigurationFromPbxproj","project","targetName","buildConfiguration","nativeTarget","findNativeTargetByName","findFirstNativeTarget","xcBuildConfiguration","configurationListId","buildConfigurationList","findApplicationTargetWithDependenciesAsync","projectRoot","scheme","applicationTargetName","applicationTarget","dependencies","getTargetDependencies","name","type","APPLICATION","parentTarget","length","undefined","map","value","target","targetId","getPBXGroupByKeyAndType","findNativeTargetById","isTargetOfType","EXTENSION","OTHER","targetType","productType","getNativeTargets","section","pbxNativeTargetSection","Object","entries","filter","isNotComment","findSignableTargets","targets","applicationTargets","WATCH","STICKER_PACK_EXTENSION","Error","nativeTargets","nativeTargetEntry","find","i","key"],"mappings":";;;;;;;;;;;;;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAMA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;IAEYA,U;;;WAAAA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;GAAAA,U,0BAAAA,U;;AAcL,SAASC,kCAAT,CACLC,OADK,EAEL;AACEC,EAAAA,UADF;AAEEC,EAAAA,kBAAkB,GAAG;AAFvB,IAG0D,EALrD,EAMwB;AAC7B,QAAM,GAAGC,YAAH,IAAmBF,UAAU,GAC/BG,sBAAsB,CAACJ,OAAD,EAAUC,UAAV,CADS,GAE/BI,qBAAqB,CAACL,OAAD,CAFzB;AAGA,QAAM,GAAGM,oBAAH,IAA2B,wDAAsCN,OAAtC,EAA+C;AAC9EO,IAAAA,mBAAmB,EAAEJ,YAAY,CAACK,sBAD4C;AAE9EN,IAAAA;AA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AIwB,kBAAkB,CAACtB,MAAnB,KAA8B,CAAlC,EAAqC;AACnC,UAAM,IAAIyB,KAAJ,CAAW,0DAAX,CAAN;AACD;;AACD,SAAOH,kBAAkB,CAAC,CAAD,CAAzB;AACD;;AAEM,SAAStC,sBAAT,CACLJ,OADK,EAELC,UAFK,EAGqB;AAC1B,QAAM6C,aAAa,GAAGb,gBAAgB,CAACjC,OAAD,CAAtC;AACA,QAAM+C,iBAAiB,GAAGD,aAAa,CAACE,IAAd,CAAmB,CAAC,GAAGC,CAAH,CAAD,KAAW,0BAAWA,CAAC,CAACjC,IAAb,MAAuBf,UAArD,CAA1B;;AACA,MAAI,CAAC8C,iBAAL,EAAwB;AACtB,UAAM,IAAIF,KAAJ,CAAW,0BAAyB5C,UAAW,sBAA/C,CAAN;AACD;;AACD,SAAO8C,iBAAP;AACD;;AAED,SAASpB,oBAAT,CAA8B3B,OAA9B,EAAqDyB,QAArD,EAAiG;AAC/F,QAAMqB,aAAa,GAAGb,gBAAgB,CAACjC,OAAD,CAAtC;AACA,QAAM+C,iBAAiB,GAAGD,aAAa,CAACE,IAAd,CAAmB,CAAC,CAACE,GAAD,CAAD,KAAWA,GAAG,KAAKzB,QAAtC,CAA1B;;AACA,MAAI,CAACsB,iBAAL,EAAwB;AACtB,UAAM,IAAIF,KAAJ,CAAW,kCAAiCpB,QAAS,sBAArD,CAAN;AACD;;AACD,SAAOsB,iBAAP;AACD","sourcesContent":["import { PBXNativeTarget, PBXTargetDependency, XCBuildConfiguration, XcodeProject } from 'xcode';\n\nimport { getApplicationTargetNameForSchemeAsync } from './BuildScheme';\nimport {\n getBuildConfigurationForListIdAndName,\n getPbxproj,\n isNotComment,\n NativeTargetSectionEntry,\n} from './utils/Xcodeproj';\nimport { trimQuotes } from './utils/string';\n\nexport enum TargetType {\n APPLICATION = 'com.apple.product-type.application',\n EXTENSION = 'com.apple.product-type.app-extension',\n WATCH = 'com.apple.product-type.application.watchapp',\n STICKER_PACK_EXTENSION = 'com.apple.product-type.app-extension.messages-sticker-pack',\n OTHER = 'other',\n}\n\nexport interface Target {\n name: string;\n type: TargetType;\n dependencies?: Target[];\n}\n\nexport function getXCBuildConfigurationFromPbxproj(\n project: XcodeProject,\n {\n targetName,\n buildConfiguration = 'Release',\n }: { targetName?: string; buildConfiguration?: string } = {}\n): XCBuildConfiguration | null {\n const [, nativeTarget] = targetName\n ? findNativeTargetByName(project, targetName)\n : findFirstNativeTarget(project);\n const [, xcBuildConfiguration] = getBuildConfigurationForListIdAndName(project, {\n configurationListId: nativeTarget.buildConfigurationList,\n buildConfiguration,\n });\n return xcBuildConfiguration ?? null;\n}\n\nexport async function findApplicationTargetWithDependenciesAsync(\n projectRoot: string,\n scheme: string\n): Promise<Target> {\n const applicationTargetName = await getApplicationTargetNameForSchemeAsync(projectRoot, scheme);\n const project = getPbxproj(projectRoot);\n const [, applicationTarget] = findNativeTargetByName(project, applicationTargetName);\n const dependencies = getTargetDependencies(project, applicationTarget);\n return {\n name: trimQuotes(applicationTarget.name),\n type: TargetType.APPLICATION,\n dependencies,\n };\n}\n\nfunction getTargetDependencies(\n project: XcodeProject,\n parentTarget: PBXNativeTarget\n): Target[] | undefined {\n if (!parentTarget.dependencies || parentTarget.dependencies.length === 0) {\n return undefined;\n }\n return parentTarget.dependencies.map(({ value }) => {\n const { target: targetId } = project.getPBXGroupByKeyAndType(\n value,\n 'PBXTargetDependency'\n ) as PBXTargetDependency;\n\n const [, target] = findNativeTargetById(project, targetId);\n\n const type = isTargetOfType(target, TargetType.EXTENSION)\n ? TargetType.EXTENSION\n : TargetType.OTHER;\n return {\n name: trimQuotes(target.name),\n type,\n dependencies: getTargetDependencies(project, target),\n };\n });\n}\n\nexport function isTargetOfType(target: PBXNativeTarget, targetType: TargetType): boolean {\n return trimQuotes(target.productType) === targetType;\n}\n\nexport function getNativeTargets(project: XcodeProject): NativeTargetSectionEntry[] {\n const section = project.pbxNativeTargetSection();\n return Object.entries(section).filter(isNotComment);\n}\n\nexport function findSignableTargets(project: XcodeProject): NativeTargetSectionEntry[] {\n const targets = getNativeTargets(project);\n const applicationTargets = targets.filter(\n ([, target]) =>\n isTargetOfType(target, TargetType.APPLICATION) ||\n isTargetOfType(target, TargetType.EXTENSION) ||\n isTargetOfType(target, TargetType.WATCH) ||\n isTargetOfType(target, TargetType.STICKER_PACK_EXTENSION)\n );\n if (applicationTargets.length === 0) {\n throw new Error(`Could not find any signable targets in project.pbxproj`);\n }\n return applicationTargets;\n}\n\nexport function findFirstNativeTarget(project: XcodeProject): NativeTargetSectionEntry {\n const targets = getNativeTargets(project);\n const applicationTargets = targets.filter(([, target]) =>\n isTargetOfType(target, TargetType.APPLICATION)\n );\n if (applicationTargets.length === 0) {\n throw new Error(`Could not find any application target in project.pbxproj`);\n }\n return applicationTargets[0];\n}\n\nexport function findNativeTargetByName(\n project: XcodeProject,\n targetName: string\n): NativeTargetSectionEntry {\n const nativeTargets = getNativeTargets(project);\n const nativeTargetEntry = nativeTargets.find(([, i]) => trimQuotes(i.name) === targetName);\n if (!nativeTargetEntry) {\n throw new Error(`Could not find target '${targetName}' in project.pbxproj`);\n }\n return nativeTargetEntry;\n}\n\nfunction findNativeTargetById(project: XcodeProject, targetId: string): NativeTargetSectionEntry {\n const nativeTargets = getNativeTargets(project);\n const nativeTargetEntry = nativeTargets.find(([key]) => key === targetId);\n if (!nativeTargetEntry) {\n throw new Error(`Could not find target with id '${targetId}' in project.pbxproj`);\n }\n return nativeTargetEntry;\n}\n"],"file":"Target.js"}
@@ -15,11 +15,11 @@ export declare enum Config {
15
15
  export declare function getSDKVersion(config: Pick<ExpoConfigUpdates, 'sdkVersion'>): string | null;
16
16
  export declare function getUpdatesEnabled(config: Pick<ExpoConfigUpdates, 'updates'>): boolean;
17
17
  export declare function getUpdatesTimeout(config: Pick<ExpoConfigUpdates, 'updates'>): number;
18
- export declare function getUpdatesCheckOnLaunch(config: Pick<ExpoConfigUpdates, 'updates'>): 'NEVER' | 'ALWAYS';
18
+ export declare function getUpdatesCheckOnLaunch(config: Pick<ExpoConfigUpdates, 'updates'>, expoUpdatesPackageVersion?: string | null): 'NEVER' | 'ERROR_RECOVERY_ONLY' | 'ALWAYS';
19
19
  export declare const withUpdates: ConfigPlugin<{
20
20
  expoUsername: string | null;
21
21
  }>;
22
- export declare function setUpdatesConfig(config: ExpoConfigUpdates, expoPlist: ExpoPlist, username: string | null): ExpoPlist;
22
+ export declare function setUpdatesConfig(config: ExpoConfigUpdates, expoPlist: ExpoPlist, username: string | null, expoUpdatesPackageVersion?: string | null): ExpoPlist;
23
23
  export declare function setVersionsConfig(config: ExpoConfigUpdates, expoPlist: ExpoPlist): ExpoPlist;
24
24
  interface ShellScriptBuildPhase {
25
25
  isa: 'PBXShellScriptBuildPhase';
@@ -38,6 +38,16 @@ function _resolveFrom() {
38
38
  return data;
39
39
  }
40
40
 
41
+ function _semver() {
42
+ const data = _interopRequireDefault(require("semver"));
43
+
44
+ _semver = function () {
45
+ return data;
46
+ };
47
+
48
+ return data;
49
+ }
50
+
41
51
  function _iosPlugins() {
42
52
  const data = require("../plugins/ios-plugins");
43
53
 
@@ -95,10 +105,15 @@ function getUpdatesTimeout(config) {
95
105
  return (_config$updates$fallb = (_config$updates2 = config.updates) === null || _config$updates2 === void 0 ? void 0 : _config$updates2.fallbackToCacheTimeout) !== null && _config$updates$fallb !== void 0 ? _config$updates$fallb : 0;
96
106
  }
97
107
 
98
- function getUpdatesCheckOnLaunch(config) {
108
+ function getUpdatesCheckOnLaunch(config, expoUpdatesPackageVersion) {
99
109
  var _config$updates3, _config$updates4;
100
110
 
101
111
  if (((_config$updates3 = config.updates) === null || _config$updates3 === void 0 ? void 0 : _config$updates3.checkAutomatically) === 'ON_ERROR_RECOVERY') {
112
+ // native 'ERROR_RECOVERY_ONLY' option was only introduced in 0.11.x
113
+ if (expoUpdatesPackageVersion && _semver().default.gte(expoUpdatesPackageVersion, '0.11.0')) {
114
+ return 'ERROR_RECOVERY_ONLY';
115
+ }
116
+
102
117
  return 'NEVER';
103
118
  } else if (((_config$updates4 = config.updates) === null || _config$updates4 === void 0 ? void 0 : _config$updates4.checkAutomatically) === 'ON_LOAD') {
104
119
  return 'ALWAYS';
@@ -111,17 +126,18 @@ const withUpdates = (config, {
111
126
  expoUsername
112
127
  }) => {
113
128
  return (0, _iosPlugins().withExpoPlist)(config, config => {
114
- config.modResults = setUpdatesConfig(config, config.modResults, expoUsername);
129
+ const expoUpdatesPackageVersion = (0, _Updates().getExpoUpdatesPackageVersion)(config.modRequest.projectRoot);
130
+ config.modResults = setUpdatesConfig(config, config.modResults, expoUsername, expoUpdatesPackageVersion);
115
131
  return config;
116
132
  });
117
133
  };
118
134
 
119
135
  exports.withUpdates = withUpdates;
120
136
 
121
- function setUpdatesConfig(config, expoPlist, username) {
137
+ function setUpdatesConfig(config, expoPlist, username, expoUpdatesPackageVersion) {
122
138
  const newExpoPlist = { ...expoPlist,
123
139
  [Config.ENABLED]: getUpdatesEnabled(config),
124
- [Config.CHECK_ON_LAUNCH]: getUpdatesCheckOnLaunch(config),
140
+ [Config.CHECK_ON_LAUNCH]: getUpdatesCheckOnLaunch(config, expoUpdatesPackageVersion),
125
141
  [Config.LAUNCH_WAIT_MS]: getUpdatesTimeout(config)
126
142
  };
127
143
  const updateUrl = (0, _Updates().getUpdateUrl)(config, username);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ios/Updates.ts"],"names":["CREATE_MANIFEST_IOS_PATH","Config","getSDKVersion","config","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;;;WAAAA,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;;AAWL,SAASC,aAAT,CAAuBC,MAAvB,EAAqF;AAC1F,SAAO,OAAOA,MAAM,CAACC,UAAd,KAA6B,QAA7B,GAAwCD,MAAM,CAACC,UAA/C,GAA4D,IAAnE;AACD;;AAEM,SAASC,iBAAT,CAA2BF,MAA3B,EAAgF;AAAA;;AACrF,SAAO,oBAAAA,MAAM,CAACG,OAAP,oEAAgBC,OAAhB,MAA4B,KAAnC;AACD;;AAEM,SAASC,iBAAT,CAA2BL,MAA3B,EAAuE;AAAA;;AAC5E,sDAAOA,MAAM,CAACG,OAAd,qDAAO,iBAAgBG,sBAAvB,yEAAiD,CAAjD;AACD;;AAEM,SAASC,uBAAT,CACLP,MADK,EAEe;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,KAA2B7C,SAAS,CAAC8C,mBAAV,IAAiC9C,SAAS,CAAC+C,uBAAtE,CADY,CAAd;AAGD;;AAEM,SAASC,0BAAT,CACL7D,MADK,EAELa,SAFK,EAGLC,QAHK,EAII;AACT,SACE,6BAAad,MAAb,EAAqBc,QAArB,MAAmCD,SAAS,CAAC6C,YAA7C,IACAxD,iBAAiB,CAACF,MAAD,CAAjB,KAA8Ba,SAAS,CAACiD,gBADxC,IAEAzD,iBAAiB,CAACL,MAAD,CAAjB,KAA8Ba,SAAS,CAACkD,qBAFxC,IAGAxD,uBAAuB,CAACP,MAAD,CAAvB,KAAoCa,SAAS,CAACmD,sBAH9C,IAIAC,iCAAiC,CAACjE,MAAD,EAASa,SAAT,CALnC;AAOD;;AAEM,SAASoD,iCAAT,CACLjE,MADK,EAELa,SAFK,EAGI;AAAA;;AACT,QAAMqD,sBAAsB,GAAG,0CAA0BlE,MAA1B,EAAkC,KAAlC,CAA/B;AACA,QAAMmE,kBAAkB,GAAGpE,aAAa,CAACC,MAAD,CAAxC;AAEA,QAAMoE,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 * 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, getRuntimeVersionNullable, 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\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, 'ios');\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 /**\n * runtime version maybe null in projects using classic updates. In that\n * case we use SDK version\n */\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, 'ios');\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","getSDKVersion","config","sdkVersion","getUpdatesEnabled","updates","enabled","getUpdatesTimeout","fallbackToCacheTimeout","getUpdatesCheckOnLaunch","expoUpdatesPackageVersion","checkAutomatically","semver","gte","withUpdates","expoUsername","modRequest","projectRoot","modResults","setUpdatesConfig","expoPlist","username","newExpoPlist","ENABLED","CHECK_ON_LAUNCH","LAUNCH_WAIT_MS","updateUrl","UPDATE_URL","setVersionsConfig","runtimeVersion","SDK_VERSION","RUNTIME_VERSION","formatConfigurationScriptPath","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","currentRu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,SAAS,CAAC6C,mBAAV,IAAiC7C,SAAS,CAAC8C,uBAAtE,CADY,CAAd;AAGD;;AAEM,SAASC,0BAAT,CACLjE,MADK,EAELkB,SAFK,EAGLC,QAHK,EAII;AACT,SACE,6BAAanB,MAAb,EAAqBmB,QAArB,MAAmCD,SAAS,CAAC4C,YAA7C,IACA5D,iBAAiB,CAACF,MAAD,CAAjB,KAA8BkB,SAAS,CAACgD,gBADxC,IAEA7D,iBAAiB,CAACL,MAAD,CAAjB,KAA8BkB,SAAS,CAACiD,qBAFxC,IAGA5D,uBAAuB,CAACP,MAAD,CAAvB,KAAoCkB,SAAS,CAACkD,sBAH9C,IAIAC,iCAAiC,CAACrE,MAAD,EAASkB,SAAT,CALnC;AAOD;;AAEM,SAASmD,iCAAT,CACLrE,MADK,EAELkB,SAFK,EAGI;AAAA;;AACT,QAAMoD,sBAAsB,GAAG,0CAA0BtE,MAA1B,EAAkC,KAAlC,CAA/B;AACA,QAAMuE,kBAAkB,GAAGxE,aAAa,CAACC,MAAD,CAAxC;AAEA,QAAMwE,qBAAqB,4BAAGtD,SAAS,CAAC8C,uBAAb,yEAAwC,IAAnE;AACA,QAAMS,iBAAiB,4BAAGvD,SAAS,CAAC6C,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 * as path from 'path';\nimport resolveFrom from 'resolve-from';\nimport semver from 'semver';\nimport xcode from 'xcode';\n\nimport { ConfigPlugin } from '../Plugin.types';\nimport { withExpoPlist } from '../plugins/ios-plugins';\nimport {\n ExpoConfigUpdates,\n getExpoUpdatesPackageVersion,\n getRuntimeVersionNullable,\n getUpdateUrl,\n} 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\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 expoUpdatesPackageVersion?: string | null\n): 'NEVER' | 'ERROR_RECOVERY_ONLY' | 'ALWAYS' {\n if (config.updates?.checkAutomatically === 'ON_ERROR_RECOVERY') {\n // native 'ERROR_RECOVERY_ONLY' option was only introduced in 0.11.x\n if (expoUpdatesPackageVersion && semver.gte(expoUpdatesPackageVersion, '0.11.0')) {\n return 'ERROR_RECOVERY_ONLY';\n }\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 const expoUpdatesPackageVersion = getExpoUpdatesPackageVersion(config.modRequest.projectRoot);\n config.modResults = setUpdatesConfig(\n config,\n config.modResults,\n expoUsername,\n expoUpdatesPackageVersion\n );\n return config;\n });\n};\n\nexport function setUpdatesConfig(\n config: ExpoConfigUpdates,\n expoPlist: ExpoPlist,\n username: string | null,\n expoUpdatesPackageVersion?: string | null\n): ExpoPlist {\n const newExpoPlist = {\n ...expoPlist,\n [Config.ENABLED]: getUpdatesEnabled(config),\n [Config.CHECK_ON_LAUNCH]: getUpdatesCheckOnLaunch(config, expoUpdatesPackageVersion),\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, 'ios');\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 /**\n * runtime version maybe null in projects using classic updates. In that\n * case we use SDK version\n */\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, 'ios');\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 @@
1
+ export declare function trimQuotes(s: string): string;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.trimQuotes = trimQuotes;
7
+
8
+ function trimQuotes(s) {
9
+ return s && s[0] === '"' && s[s.length - 1] === '"' ? s.slice(1, -1) : s;
10
+ }
11
+ //# sourceMappingURL=string.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/ios/utils/string.ts"],"names":["trimQuotes","s","length","slice"],"mappings":";;;;;;;AAAO,SAASA,UAAT,CAAoBC,CAApB,EAAuC;AAC5C,SAAOA,CAAC,IAAIA,CAAC,CAAC,CAAD,CAAD,KAAS,GAAd,IAAqBA,CAAC,CAACA,CAAC,CAACC,MAAF,GAAW,CAAZ,CAAD,KAAoB,GAAzC,GAA+CD,CAAC,CAACE,KAAF,CAAQ,CAAR,EAAW,CAAC,CAAZ,CAA/C,GAAgEF,CAAvE;AACD","sourcesContent":["export function trimQuotes(s: string): string {\n return s && s[0] === '\"' && s[s.length - 1] === '\"' ? s.slice(1, -1) : s;\n}\n"],"file":"string.js"}
@@ -1,5 +1,6 @@
1
1
  import { Android, ExpoConfig, IOS } from '@expo/config-types';
2
2
  export declare type ExpoConfigUpdates = Pick<ExpoConfig, 'sdkVersion' | 'owner' | 'runtimeVersion' | 'updates' | 'slug'>;
3
+ export declare function getExpoUpdatesPackageVersion(projectRoot: string): string | null;
3
4
  export declare function getUpdateUrl(config: Pick<ExpoConfigUpdates, 'owner' | 'slug' | 'updates'>, username: string | null): string | null;
4
5
  export declare function getNativeVersion(config: Pick<ExpoConfig, 'version'> & {
5
6
  android?: Pick<Android, 'versionCode'>;
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.getExpoUpdatesPackageVersion = getExpoUpdatesPackageVersion;
6
7
  exports.getNativeVersion = getNativeVersion;
7
8
  exports.getRuntimeVersion = getRuntimeVersion;
8
9
  exports.getRuntimeVersionNullable = getRuntimeVersionNullable;
@@ -19,6 +20,16 @@ function _sdkRuntimeVersions() {
19
20
  return data;
20
21
  }
21
22
 
23
+ function _fs() {
24
+ const data = _interopRequireDefault(require("fs"));
25
+
26
+ _fs = function () {
27
+ return data;
28
+ };
29
+
30
+ return data;
31
+ }
32
+
22
33
  function _getenv() {
23
34
  const data = require("getenv");
24
35
 
@@ -29,6 +40,16 @@ function _getenv() {
29
40
  return data;
30
41
  }
31
42
 
43
+ function _resolveFrom() {
44
+ const data = _interopRequireDefault(require("resolve-from"));
45
+
46
+ _resolveFrom = function () {
47
+ return data;
48
+ };
49
+
50
+ return data;
51
+ }
52
+
32
53
  function _() {
33
54
  const data = require("..");
34
55
 
@@ -39,6 +60,19 @@ function _() {
39
60
  return data;
40
61
  }
41
62
 
63
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
64
+
65
+ function getExpoUpdatesPackageVersion(projectRoot) {
66
+ const expoUpdatesPackageJsonPath = _resolveFrom().default.silent(projectRoot, 'expo-updates/package.json');
67
+
68
+ if (!expoUpdatesPackageJsonPath || !_fs().default.existsSync(expoUpdatesPackageJsonPath)) {
69
+ return null;
70
+ }
71
+
72
+ const packageJson = JSON.parse(_fs().default.readFileSync(expoUpdatesPackageJsonPath, 'utf8'));
73
+ return packageJson.version;
74
+ }
75
+
42
76
  function getUpdateUrl(config, username) {
43
77
  var _config$updates;
44
78