amis-rpc-design/node_modules/@react-native-community/cli-doctor/build/tools/healthchecks/androidSDK.js.map

1 line
11 KiB
Plaintext
Raw Normal View History

2023-10-07 19:42:30 +08:00
{"version":3,"names":["getBuildToolsVersion","projectRoot","findProjectRoot","logger","log","warn","gradleBuildFilePath","path","join","buildToolsVersionEntry","fs","existsSync","gradleBuildFile","readFileSync","buildToolsVersionIndex","indexOf","buildToolsVersion","substring","split","match","installMessage","chalk","dim","isSDKInstalled","environmentInfo","version","SDKs","label","description","getDiagnostics","config","requiredVersion","root","buildTools","isAndroidSDKInstalled","Array","isArray","isRequiredVersionInstalled","includes","versions","versionRange","needsToBeFixed","win32AutomaticFix","loader","cliToolsUrl","systemImage","componentsToInstall","androidSDKRoot","getAndroidSdkRootInstallation","fail","downloadAndUnzip","downloadUrl","component","installPath","text","installComponent","e","setEnvironment","updateEnvironment","hypervisor","installed","getBestHypervisor","enableAMDH","enableHAXM","enableWHPX","createAVD","succeed","runAutomaticFix","logManualInstallation","message","healthcheck","url","link","docs","hash","guide","platform"],"sources":["../../../src/tools/healthchecks/androidSDK.ts"],"sourcesContent":["import {findProjectRoot, logger, link} from '@react-native-community/cli-tools';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\nimport {EnvironmentInfo, HealthCheckInterface} from '../../types';\nimport {downloadAndUnzip} from '../downloadAndUnzip';\nimport {\n createAVD,\n enableAMDH,\n enableHAXM,\n enableWHPX,\n getAndroidSdkRootInstallation,\n getBestHypervisor,\n installComponent,\n} from '../windows/androidWinHelpers';\nimport {\n setEnvironment,\n updateEnvironment,\n} from '../windows/environmentVariables';\n\nconst getBuildToolsVersion = (projectRoot = ''): string => {\n try {\n // doctor is a detached command, so we may not be in a RN project.\n projectRoot = projectRoot || findProjectRoot();\n } catch {\n logger.log(); // for extra space\n logger.warn(\n \"We couldn't find a package.json in this directory. Android SDK checks may fail. Doctor works best in a React Native project root.\",\n );\n }\n\n const gradleBuildFilePath = path.join(projectRoot, 'android/build.gradle');\n\n const buildToolsVersionEntry = 'buildToolsVersion';\n\n if (!fs.existsSync(gradleBuildFilePath)) {\n return 'Not Found';\n }\n\n // Read the content of the `build.gradle` file\n const gradleBuildFile = fs.readFileSync(gradleBuildFilePath, 'utf-8');\n\n const buildToolsVersionIndex = gradleBuildFile.indexOf(\n buildToolsVersionEntry,\n );\n\n const buildToolsVersion = (\n gradleBuildFile\n // Get only the portion of the declaration of `buildToolsVersion`\n .substring(buildToolsVersionIndex)\n .split('\\n')[0]\n // Get only the the value of `buildToolsVersion`\n .match(/\\d|\\../g) || []\n ).join('');\n\n return buildToolsVersion || 'Not Found';\n};\n\nconst installMessage = `Read more about how to update Android SDK at ${chalk.dim(\n 'https://developer.android.com/studio',\n)}`;\n\nconst isSDKInstalled = (environmentInfo: EnvironmentInfo) => {\n const version = environmentInfo.SDKs['Android SDK'];\n return version !== 'Not Found';\n};\n\nexport default {\n label: 'Android SDK',\n description: 'Required for building and installing your app on Android',\n getDiagnostics: async ({SDKs}, config) => {\n const requiredVersion = getBuildToolsVersion(config?.root);\n const buildTools =\n typeof SDKs['Android SDK'] === 'string'\n ? SDKs['Android SDK']\n : SDKs['Android SDK']['Build Tools'];\n\n const isAndroidSDKInstalled = Array.isArray(buildTools);\n\n const isRequiredVersionInstalled = isAndroidSDKInstalled\n ? buildTools.includes(requiredVersion)\n : false;\n\n return {\n versions: isAndroidSDKInstalled ? buildTools : SDKs['Android SDK'],\n versionRange: requiredVersion,\n needsToBeFixed: !isRequiredVersionInstalled,\n };\n },\n win32AutomaticFix: async ({loader}) => {\n // Need a GitHub action to update automatically. See #1180\n const