UNPKG

4.05 kBSource Map (JSON)View Raw
1{"version":3,"file":"GoogleServices.js","sourceRoot":"","sources":["../../src/android/GoogleServices.ts"],"names":[],"mappings":";;;;;AAAA,wDAA0B;AAC1B,+BAA+B;AAG/B,MAAM,mBAAmB,GAAG,oCAAoC,CAAC;AAEjE,SAAgB,yBAAyB,CAAC,MAAkB;;IAC1D,kBAAO,MAAM,CAAC,OAAO,0CAAE,kBAAkB,uCAAI,IAAI,EAAC;AACpD,CAAC;AAFD,8DAEC;AAEM,KAAK,UAAU,qBAAqB,CACzC,MAAkB,EAClB,gBAAwB,EACxB,aAAqB,mBAAmB;IAExC,IAAI,iBAAiB,GAAG,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAC1D,IAAI,CAAC,iBAAiB,EAAE;QACtB,OAAO,KAAK,CAAC;KACd;IAED,MAAM,kBAAkB,GAAG,cAAO,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;IACxE,MAAM,eAAe,GAAG,cAAO,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC;IAE9D,IAAI;QACF,MAAM,kBAAE,CAAC,IAAI,CAAC,kBAAkB,EAAE,eAAe,CAAC,CAAC;KACpD;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CACb,yCAAyC,kBAAkB,OAAO,eAAe,4DAA4D,CAC9I,CAAC;KACH;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AArBD,sDAqBC;AAED,MAAM,uBAAuB,GAAG,gCAAgC,CAAC;AACjE,MAAM,oBAAoB,GAAG,gCAAgC,CAAC;AAE9D,+DAA+D;AAC/D,MAAM,qBAAqB,GAAG,OAAO,CAAC;AAEtC;;;;GAIG;AACH,SAAgB,YAAY,CAAC,MAAkB,EAAE,WAAmB;IAClE,IAAI,kBAAkB,GAAG,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAC3D,IAAI,CAAC,kBAAkB,EAAE;QACvB,OAAO,WAAW,CAAC;KACpB;IAED,IAAI,WAAW,CAAC,QAAQ,CAAC,uBAAuB,CAAC,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,MAAkB,EAAE,cAAsB;IACpE,IAAI,kBAAkB,GAAG,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAC3D,IAAI,CAAC,kBAAkB,EAAE;QACvB,OAAO,cAAc,CAAC;KACvB;IAED,yDAAyD;IACzD,IAAI,OAAO,GAAG,IAAI,MAAM,CAAC,2BAA2B,oBAAoB,MAAM,CAAC,CAAC;IAChF,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 fs from 'fs-extra';\nimport { resolve } from 'path';\nimport { ExpoConfig } from '../Config.types';\n\nconst DEFAULT_TARGET_PATH = './android/app/google-services.json';\n\nexport function getGoogleServicesFilePath(config: ExpoConfig) {\n return config.android?.googleServicesFile ?? null;\n}\n\nexport async function setGoogleServicesFile(\n config: ExpoConfig,\n projectDirectory: string,\n targetPath: string = DEFAULT_TARGET_PATH\n) {\n let partialSourcePath = getGoogleServicesFilePath(config);\n if (!partialSourcePath) {\n return false;\n }\n\n const completeSourcePath = resolve(projectDirectory, partialSourcePath);\n const destinationPath = resolve(projectDirectory, 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\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\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: ExpoConfig, buildGradle: string) {\n let 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: ExpoConfig, appBuildGradle: string) {\n let googleServicesFile = getGoogleServicesFilePath(config);\n if (!googleServicesFile) {\n return appBuildGradle;\n }\n\n // Make sure the project does not have the plugin already\n let 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"]}
\No newline at end of file