UNPKG

20.2 kBSource Map (JSON)View Raw
1{"version":3,"file":"CocoaPodsPackageManager.js","sourceRoot":"","sources":["../src/CocoaPodsPackageManager.ts"],"names":[],"mappings":";;;;;;AAAA,oEAA0E;AAC1E,kDAA0B;AAC1B,2BAAgC;AAEhC,gDAAwB;AAExB,qDAAkE;AAIlE,MAAa,cAAe,SAAQ,KAAK;IAIvC,YAAY,OAAe,EAAS,IAAwB,EAAS,KAAa;QAChF,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,OAAO,eAAe,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QADhC,SAAI,GAAJ,IAAI,CAAoB;QAAS,UAAK,GAAL,KAAK,CAAQ;QAHzE,SAAI,GAAG,gBAAgB,CAAC;QACxB,0BAAqB,GAAG,IAAI,CAAC;IAItC,CAAC;CACF;AAPD,wCAOC;AAED,SAAgB,6BAA6B,CAAC,KAAa;IACzD,wGAAwG;IACxG,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CACzB,qGAAqG,CACtG,CAAC;IACF,IAAI,OAAO,EAAE;QACX,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;KACjC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AATD,sEASC;AAED,MAAa,uBAAuB;IAwIlC,YAAY,EAAE,GAAG,EAAE,MAAM,EAAqC;QAC5D,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG;YACb,GAAG;YACH,GAAG,CAAC,MAAM;gBACR,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE;gBACnB,CAAC,CAAC;oBACE,KAAK,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC;iBACtC,CAAC;SACP,CAAC;IACJ,CAAC;IA7ID,MAAM,CAAC,iBAAiB,CAAC,WAAmB;QAC1C,IAAI,uBA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';\nimport { existsSync } from 'fs';\nimport { Ora } from 'ora';\nimport path from 'path';\n\nimport { PackageManager, spawnSudoAsync } from './PackageManager';\n\nexport type CocoaPodsErrorCode = 'NON_INTERACTIVE' | 'NO_CLI' | 'COMMAND_FAILED';\n\nexport class CocoaPodsError extends Error {\n readonly name = 'CocoaPodsError';\n readonly isPackageManagerError = true;\n\n constructor(message: string, public code: CocoaPodsErrorCode, public cause?: Error) {\n super(cause ? `${message}\\n└─ Cause: ${cause.message}` : message);\n }\n}\n\nexport function extractMissingDependencyError(error: string): [string, string] | null {\n // [!] Unable to find a specification for `expo-dev-menu-interface` depended upon by `expo-dev-launcher`\n const results = error.match(\n /Unable to find a specification for ['\"`]([\\w-_\\d\\s]+)['\"`] depended upon by ['\"`]([\\w-_\\d\\s]+)['\"`]/\n );\n if (results) {\n return [results[1], results[2]];\n }\n return null;\n}\n\nexport class CocoaPodsPackageManager implements PackageManager {\n options: SpawnOptions;\n\n private silent: boolean;\n\n static getPodProjectRoot(projectRoot: string): string | null {\n if (CocoaPodsPackageManager.isUsingPods(projectRoot)) return projectRoot;\n const iosProject = path.join(projectRoot, 'ios');\n if (CocoaPodsPackageManager.isUsingPods(iosProject)) return iosProject;\n const macOsProject = path.join(projectRoot, 'macos');\n if (CocoaPodsPackageManager.isUsingPods(macOsProject)) return macOsProject;\n return null;\n }\n\n static isUsingPods(projectRoot: string): boolean {\n return existsSync(path.join(projectRoot, 'Podfile'));\n }\n\n static async gemInstallCLIAsync(\n nonInteractive: boolean = false,\n spawnOptions: SpawnOptions = { stdio: 'inherit' }\n ): Promise<void> {\n const options = ['install', 'cocoapods', '--no-document'];\n\n try {\n // In case the user has run sudo before running the command we can properly install CocoaPods without prompting for an interaction.\n await spawnAsync('gem', options, spawnOptions);\n } catch (error) {\n if (nonInteractive) {\n throw new CocoaPodsError(\n 'Failed to install CocoaPods CLI with gem (recommended)',\n 'COMMAND_FAILED',\n error\n );\n }\n // If the user doesn't have permission then we can prompt them to use sudo.\n await spawnSudoAsync(['gem', ...options], spawnOptions);\n }\n }\n\n static async brewLinkCLIAsync(spawnOptions: SpawnOptions = { stdio: 'inherit' }): Promise<void> {\n await spawnAsync('brew', ['link', 'cocoapods'], spawnOptions);\n }\n\n static async brewInstallCLIAsync(\n spawnOptions: SpawnOptions = { stdio: 'inherit' }\n ): Promise<void> {\n await spawnAsync('brew', ['install', 'cocoapods'], spawnOptions);\n }\n\n static async installCLIAsync({\n nonInteractive = false,\n spawnOptions = { stdio: 'inherit' },\n }: {\n nonInteractive?: boolean;\n spawnOptions?: SpawnOptions;\n }): Promise<boolean> {\n if (!spawnOptions) {\n spawnOptions = { stdio: 'inherit' };\n }\n const silent = !!spawnOptions.ignoreStdio;\n\n try {\n !silent && console.log(`\\u203A Attempting to install CocoaPods CLI with Gem`);\n await CocoaPodsPackageManager.gemInstallCLIAsync(nonInteractive, spawnOptions);\n !silent && console.log(`\\u203A Successfully installed CocoaPods CLI with Gem`);\n return true;\n } catch (error) {\n if (!silent) {\n console.log(chalk.yellow(`\\u203A Failed to install CocoaPods CLI with Gem`));\n console.log(chalk.red(error.stderr ?? error.message));\n console.log(`\\u203A Attempting to install CocoaPods CLI with Homebrew`);\n }\n try {\n await CocoaPodsPackageManager.brewInstallCLIAsync(spawnOptions);\n if (!(await CocoaPodsPackageManager.isCLIInstalledAsync(spawnOptions))) {\n try {\n await CocoaPodsPackageManager.brewLinkCLIAsync(spawnOptions);\n // Still not available after linking? Bail out\n if (!(await CocoaPodsPackageManager.isCLIInstalledAsync(spawnOptions))) {\n throw new CocoaPodsError(\n 'CLI could not be installed automatically with gem or Homebrew, please install CocoaPods manually and try again',\n 'NO_CLI',\n error\n );\n }\n } catch (error) {\n throw new CocoaPodsError(\n 'Homebrew installation appeared to succeed but CocoaPods CLI not found in PATH and unable to link.',\n 'NO_CLI',\n error\n );\n }\n }\n\n !silent && console.log(`\\u203A Successfully installed CocoaPods CLI with Homebrew`);\n return true;\n } catch (error) {\n !silent &&\n console.warn(\n chalk.yellow(\n `\\u203A Failed to install CocoaPods with Homebrew. Please install CocoaPods CLI manually and try again.`\n )\n );\n throw new CocoaPodsError(\n `Failed to install CocoaPods with Homebrew. Please install CocoaPods CLI manually and try again.`,\n 'NO_CLI',\n error\n );\n }\n }\n }\n\n static isAvailable(projectRoot: string, silent: boolean): boolean {\n if (process.platform !== 'darwin') {\n !silent && console.log(chalk.red('CocoaPods is only supported on macOS machines'));\n return false;\n }\n if (!CocoaPodsPackageManager.isUsingPods(projectRoot)) {\n !silent && console.log(chalk.yellow('CocoaPods is not supported in this project'));\n return false;\n }\n return true;\n }\n\n static async isCLIInstalledAsync(\n spawnOptions: SpawnOptions = { stdio: 'inherit' }\n ): Promise<boolean> {\n try {\n await spawnAsync('pod', ['--version'], spawnOptions);\n return true;\n } catch {\n return false;\n }\n }\n\n constructor({ cwd, silent }: { cwd: string; silent?: boolean }) {\n this.silent = !!silent;\n this.options = {\n cwd,\n ...(silent\n ? { stdio: 'pipe' }\n : {\n stdio: ['inherit', 'inherit', 'pipe'],\n }),\n };\n }\n\n get name() {\n return 'CocoaPods';\n }\n\n async installAsync({ spinner }: { spinner?: Ora } = {}) {\n await this._installAsync({ spinner });\n }\n\n public isCLIInstalledAsync() {\n return CocoaPodsPackageManager.isCLIInstalledAsync(this.options);\n }\n\n public installCLIAsync() {\n return CocoaPodsPackageManager.installCLIAsync({\n nonInteractive: true,\n spawnOptions: this.options,\n });\n }\n\n private async _installAsync({\n spinner,\n shouldUpdate = true,\n }: { spinner?: Ora; shouldUpdate?: boolean } = {}): Promise<SpawnResult> {\n try {\n return await this._runAsync(['install']);\n } catch (error) {\n const output = error.output.join('\\n').trim();\n\n const isPodRepoUpdateError = output.includes('pod repo update');\n // When pods are outdated, they'll throw an error informing you to run \"pod repo update\"\n // Attempt to run that command and try installing again.\n if (isPodRepoUpdateError && shouldUpdate) {\n const warningInfo = extractMissingDependencyError(output);\n let message: string;\n if (warningInfo) {\n message = `Couldn't install: ${warningInfo[1]} » ${chalk.underline(warningInfo[0])}.`;\n } else {\n message = `Couldn't install Pods.`;\n }\n message += ` Updating the Pods project and trying again...`;\n if (spinner) {\n spinner.text = chalk.bold(message);\n }\n !this.silent && console.warn(chalk.yellow(message));\n await this.podRepoUpdateAsync();\n // Include a boolean to ensure pod repo update isn't invoked in the unlikely case where the pods fail to update.\n return await this._installAsync({ spinner, shouldUpdate: false });\n } else {\n const cwd = this.options.cwd || process.cwd();\n if (error.stdout.match(/No [`'\"]Podfile[`'\"] found in the project directory/)) {\n error.message = `No Podfile found in directory: ${cwd}. Ensure CocoaPods is setup any try again.`;\n } else if (isPodRepoUpdateError) {\n const warningInfo = extractMissingDependencyError(output);\n let reason: string;\n if (warningInfo) {\n reason = `Couldn't install: ${warningInfo[1]} » ${chalk.underline(warningInfo[0])}`;\n } else {\n reason = `This is often due to native package versions mismatching`;\n }\n\n let solution: string;\n if (warningInfo?.[0]) {\n // If the missing package is named `expo-dev-menu`, `react-native`, etc. then it might not be installed in the project.\n if (warningInfo[0].match(/^(?:@?expo|@?react)(-|\\/)/)) {\n solution = `Ensure the node module \"${warningInfo[0]}\" is installed in your project, then run \\`npx pod-install\\` to try again.`;\n } else {\n solution = `Ensure the CocoaPod \"${warningInfo[0]}\" is installed in your project, then run \\`npx pod-install\\` to try again.`;\n }\n } else {\n solution = `Try deleting the \\`ios/Pods\\` folder or the \\`ios/Podfile.lock\\` file and running \\`npx pod-install\\` to resolve.`;\n }\n error.message = `${reason}. ${solution}`;\n throw new CocoaPodsError('Command `pod repo update` failed.', 'COMMAND_FAILED', error);\n } else {\n let stderr = error.stderr.trim();\n\n // CocoaPods CLI prints the useful error to stdout...\n const usefulError = error.stdout.match(/\\[!\\]\\s((?:.|\\n)*)/)?.[1];\n\n // If there is a useful error message then prune the less useful info.\n if (usefulError) {\n // Delete unhelpful CocoaPods CLI error message.\n if (error.message.match(/pod exited with non-zero code: 1/)) {\n error.message = null;\n }\n // Remove `<PBXResourcesBuildPhase UUID=`13B07F8E1A680F5B00A75B9A`>` type errors when useful messages exist.\n if (stderr.match(/PBXResourcesBuildPhase/)) {\n stderr = null;\n }\n }\n\n error.message = [usefulError, error.message, stderr].filter(Boolean).join('\\n');\n }\n\n throw new CocoaPodsError('Command `pod install` failed.', 'COMMAND_FAILED', error);\n }\n }\n }\n\n async addAsync(...names: string[]) {\n throw new Error('Unimplemented');\n }\n\n async addDevAsync(...names: string[]) {\n throw new Error('Unimplemented');\n }\n\n async versionAsync() {\n const { stdout } = await spawnAsync('pod', ['--version'], this.options);\n return stdout.trim();\n }\n\n async getConfigAsync(key: string): Promise<string> {\n throw new Error('Unimplemented');\n }\n\n async removeLockfileAsync() {\n throw new Error('Unimplemented');\n }\n\n async cleanAsync() {\n throw new Error('Unimplemented');\n }\n\n // Private\n private async podRepoUpdateAsync(): Promise<void> {\n try {\n await this._runAsync(['repo', 'update']);\n } catch (error) {\n error.message = error.message || (error.stderr ?? error.stdout);\n\n throw new CocoaPodsError('The command `pod repo update` failed', 'COMMAND_FAILED', error);\n }\n }\n\n private async _runAsync(args: string[]): Promise<SpawnResult> {\n if (!this.silent) {\n console.log(`> pod ${args.join(' ')}`);\n }\n return spawnAsync('pod', [...args], this.options);\n }\n}\n"]}
\No newline at end of file