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C,EAAE;QACjD,OAAO,WAAW,CAAC;KACpB;IAED,EAAE;IACF,OAAO,WAAW,CAAC,OAAO,CACxB,kBAAkB,EAClB;qBACiB,uBAAuB,IAAI,qBAAqB,GAAG,CACrE,CAAC;AACJ,CAAC;AAhBD,oCAgBC;AAED,SAAgB,WAAW,CAAC,MAAmC,EAAE,cAAsB;IACrF,MAAM,kBAAkB,GAAG,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAC7D,IAAI,CAAC,kBAAkB,EAAE;QACvB,OAAO,cAAc,CAAC;KACvB;IAED,yDAAyD;IACzD,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,2BAA2B,oBAAoB,MAAM,CAAC,CAAC;IAClF,IAAI,cAAc,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE;QACjC,OAAO,cAAc,CAAC;KACvB;IAED,gCAAgC;IAChC,OAAO,cAAc,GAAG,oBAAoB,oBAAoB,GAAG,CAAC;AACtE,CAAC;AAdD,kCAcC","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport fs from 'fs-extra';\nimport { resolve } from 'path';\n\nimport { ConfigPlugin } from '../Plugin.types';\nimport { withAppBuildGradle, withProjectBuildGradle } from '../plugins/android-plugins';\nimport { withDangerousMod } from '../plugins/core-plugins';\nimport * as WarningAggregator from '../utils/warnings';\n\nconst DEFAULT_TARGET_PATH = './android/app/google-services.json';\n\nconst googleServicesClassPath = 'com.google.gms:google-services';\nconst googleServicesPlugin = 'com.google.gms.google-services';\n\n// NOTE(brentvatne): This may be annoying to keep up to date...\nconst googleServicesVersion = '4.3.3';\n\nexport const withClassPath: ConfigPlugin = config => {\n return withProjectBuildGradle(config, config => {\n if (config.modResults.language === 'groovy') {\n config.modResults.contents = setClassPath(config, config.modResults.contents);\n } else {\n WarningAggregator.addWarningAndroid(\n 'android-google-services',\n `Cannot automatically configure project build.gradle if it's not groovy`\n );\n }\n return config;\n });\n};\n\nexport const withApplyPlugin: ConfigPlugin = config => {\n return withAppBuildGradle(config, config => {\n if (config.modResults.language === 'groovy') {\n config.modResults.contents = applyPlugin(config, config.modResults.contents);\n } else {\n WarningAggregator.addWarningAndroid(\n 'android-google-services',\n `Cannot automatically configure app build.gradle if it's not groovy`\n );\n }\n return config;\n });\n};\n\n/**\n * Add `google-services.json` to project\n */\nexport const withGoogleServicesFile: ConfigPlugin = config => {\n return withDangerousMod(config, [\n 'android',\n async config => {\n await setGoogleServicesFile(config, config.modRequest.projectRoot);\n return config;\n },\n ]);\n};\n\nexport function getGoogleServicesFilePath(config: Pick<ExpoConfig, 'android'>) {\n return config.android?.googleServicesFile ?? null;\n}\n\nexport async function setGoogleServicesFile(\n config: Pick<ExpoConfig, 'android'>,\n projectRoot: string,\n targetPath: string = DEFAULT_TARGET_PATH\n) {\n const partialSourcePath = getGoogleServicesFilePath(config);\n if (!partialSourcePath) {\n return false;\n }\n\n const completeSourcePath = resolve(projectRoot, partialSourcePath);\n const destinationPath = resolve(projectRoot, targetPath);\n\n try {\n await fs.copy(completeSourcePath, destinationPath);\n } catch (e) {\n throw new Error(\n `Cannot copy google-services.json from ${completeSourcePath} to ${destinationPath}. Please make sure the source and destination paths exist.`\n );\n }\n return true;\n}\n\n/**\n * Adding the Google Services plugin\n * NOTE(brentvatne): string replacement is a fragile approach! we need a\n * better solution than this.\n */\nexport function setClassPath(config: Pick<ExpoConfig, 'android'>, buildGradle: string) {\n const googleServicesFile = getGoogleServicesFilePath(config);\n if (!googleServicesFile) {\n return buildGradle;\n }\n\n if (buildGradle.includes(googleServicesClassPath)) {\n return buildGradle;\n }\n\n //\n return buildGradle.replace(\n /dependencies\\s?{/,\n `dependencies {\n classpath '${googleServicesClassPath}:${googleServicesVersion}'`\n );\n}\n\nexport function applyPlugin(config: Pick<ExpoConfig, 'android'>, appBuildGradle: string) {\n const googleServicesFile = getGoogleServicesFilePath(config);\n if (!googleServicesFile) {\n return appBuildGradle;\n }\n\n // Make sure the project does not have the plugin already\n const pattern = new RegExp(`apply\\\\s+plugin:\\\\s+['\"]${googleServicesPlugin}['\"]`);\n if (appBuildGradle.match(pattern)) {\n return appBuildGradle;\n }\n\n // Add it to the end of the file\n return appBuildGradle + `\\napply plugin: '${googleServicesPlugin}'`;\n}\n"]} |