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

1 line
14 KiB
Plaintext
Raw Normal View History

2023-10-07 19:42:30 +08:00
{"version":3,"names":["getUserAndroidPath","join","process","env","LOCALAPPDATA","getAndroidSdkRootInstallation","ANDROID_SDK_ROOT","ANDROID_HOME","installPath","pathExistsSync","installComponent","component","androidSdkRoot","Promise","done","error","sdkmanager","command","child","executeCommand","stderr","stdout","on","data","includes","stdin","write","toString","exitStatus","undefined","parseHypervisor","status","customHypervisor","hypervisor","installed","test","getEmulatorAccelOutputInformation","androidSDKRoot","e","createAVD","name","device","image","abi","tag","avdmanager","configPath","HOMEPATH","content","readFile","updatedContent","replace","writeFile","getBestHypervisor","getProcessorType","lines","split","line","enableWHPX","enableHAXM","androidSdkInstallPath","enableAMDH"],"sources":["../../../src/tools/windows/androidWinHelpers.ts"],"sourcesContent":["import {readFile, writeFile, pathExistsSync} from 'fs-extra';\nimport {join} from 'path';\nimport {executeCommand} from './executeWinCommand';\nimport {getProcessorType} from './processorType';\n\ntype HypervisorStatus = {\n hypervisor: 'WHPX' | 'HAXM' | 'AMDH' | 'none';\n installed: boolean;\n};\n\n/**\n * Returns the path to where all Android related things should be installed\n * locally to the user.\n */\nexport const getUserAndroidPath = () => {\n return join(process.env.LOCALAPPDATA || '', 'Android');\n};\n\n/**\n * Deals with ANDROID_HOME, ANDROID_SDK_ROOT or generates a new one\n */\nexport const getAndroidSdkRootInstallation = () => {\n const env = process.env.ANDROID_SDK_ROOT || process.env.ANDROID_HOME;\n const installPath = env\n ? // Happens if previous installations or not fully completed\n env\n : // All Android zip files have a root folder, using `Android` as the common place\n join(getUserAndroidPath(), 'Sdk');\n\n if (pathExistsSync(installPath)) {\n return installPath;\n } else {\n return '';\n }\n};\n\n/**\n * Installs an Android component (e.g.: `platform-tools`, `emulator`)\n * using the `sdkmanager` tool and automatically accepting the licenses.\n */\nexport const installComponent = (component: string, androidSdkRoot: string) => {\n return new Promise((done, error) => {\n const sdkmanager = join(androidSdkRoot, 'tools', 'bin', 'sdkmanager.bat');\n\n const command = `\"${sdkmanager}\" --sdk_root=\"${androidSdkRoot}\" \"${component}\"`;\n\n const child = executeCommand(command);\n let stderr = '';\n\n child.stdout?.on('data', (data) => {\n if (data.includes('(y/N)')) {\n child.stdin?.write('y\\n');\n }\n });\n\n child.stderr?.on('data', (data) => {\n stderr += data.toString('utf-8');\n });\n\n child.on('close', (exitStatus) => {\n if (exitStatus === 0) {\n done(undefined);\n } else {\n error({stderr});\n }\n });\n child.on('error', error);\n });\n};\n\n/**\n * For the given custom Hypervisor and the output of `emulator-check accel`\n * returns the preferred Hypervisor to use and its installation status.\n * The recommendation order is:\n * 1. WHPX\n * 2. HAXM if Intel\n * 3. AMDH if AMD\n */\nconst parseHypervisor = (\n status: string,\n customHypervisor: 'HAXM' | 'AMDH',\n): HypervisorStatus | null => {\n /**\n * Messages:\n * Android Emulator requires an Intel processor with VT-x and NX support. Your CPU: 'AuthenticAMD'\n * HAXM is not installed, but Windows Hypervisor Platform is available.\n * WHPX (10.0.19041) is installed and usable.\n * * This message outputs for WHPX and when the AMD Hypervisor is installed\n * HAXM version 6.2.1 (4) is installed and usable.\n * HAXM is not installed on this machine\n */\n\n if (\n status.includes(\n 'is not installed, but Windows Hypervisor Platform is available.',\n )\n ) {\n return {\n hypervisor: 'WHPX',\n installed: false,\n };\n }\n\n if (/WHPX \\((\\d|\\.)+\\) is installed and usable\\./.test(status)) {\n return {\n hypervisor: 'WHPX',\n installed: true,\n };\n }\n\n if (/is installed and usable\\./.test(sta