amis-rpc-design/node_modules/@react-native-community/cli-platform-android/build/commands/buildAndroid/index.js.map
2023-10-07 19:42:30 +08:00

1 line
10 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{"version":3,"names":["runPackager","args","config","packager","result","isPackagerRunning","port","logger","info","warn","startServerInNewWindow","terminal","root","reactNativePath","error","Error","message","buildAndroid","_argv","androidProject","getAndroidProject","variant","tasks","mode","interactive","selectedTask","promptForTaskSelection","sourceDir","gradleArgs","getTaskNames","appName","extraParams","push","activeArchOnly","adbPath","getAdbPath","devices","adb","getDevices","architectures","map","device","getCPU","filter","arch","index","array","indexOf","length","join","build","process","chdir","cmd","platform","startsWith","debug","execa","sync","stdio","cwd","printRunDoctorTip","CLIError","options","name","description","default","env","RCT_METRO_PORT","parse","Number","getDefaultUserTerminal","val","split","func"],"sources":["../../../src/commands/buildAndroid/index.ts"],"sourcesContent":["import {\n CLIError,\n getDefaultUserTerminal,\n isPackagerRunning,\n logger,\n printRunDoctorTip,\n} from '@react-native-community/cli-tools';\nimport {Config} from '@react-native-community/cli-types';\nimport execa from 'execa';\nimport {getAndroidProject} from '../../config/getAndroidProject';\nimport adb from '../runAndroid/adb';\nimport getAdbPath from '../runAndroid/getAdbPath';\nimport {startServerInNewWindow} from './startServerInNewWindow';\nimport {getTaskNames} from '../runAndroid/getTaskNames';\nimport {promptForTaskSelection} from '../runAndroid/listAndroidTasks';\n\nexport interface BuildFlags {\n mode?: string;\n variant?: string;\n activeArchOnly?: boolean;\n packager?: boolean;\n port: number;\n terminal: string;\n tasks?: Array<string>;\n extraParams?: Array<string>;\n interactive?: boolean;\n}\n\nexport async function runPackager(args: BuildFlags, config: Config) {\n if (!args.packager) {\n return;\n }\n const result = await isPackagerRunning(args.port);\n if (result === 'running') {\n logger.info('JS server already running.');\n } else if (result === 'unrecognized') {\n logger.warn('JS server not recognized, continuing with build...');\n } else {\n // result == 'not_running'\n logger.info('Starting JS server...');\n\n try {\n startServerInNewWindow(\n args.port,\n args.terminal,\n config.root,\n config.reactNativePath,\n );\n } catch (error) {\n if (error instanceof Error) {\n logger.warn(\n `Failed to automatically start the packager server. Please run \"react-native start\" manually. Error details: ${error.message}`,\n );\n }\n }\n }\n}\n\nasync function buildAndroid(\n _argv: Array<string>,\n config: Config,\n args: BuildFlags,\n) {\n const androidProject = getAndroidProject(config);\n\n if (args.variant) {\n logger.warn(\n '\"variant\" flag is deprecated and will be removed in future release. Please switch to \"mode\" flag.',\n );\n }\n\n if (args.tasks && args.mode) {\n logger.warn(\n 'Both \"tasks\" and \"mode\" parameters were passed to \"build\" command. Using \"tasks\" for building the app.',\n );\n }\n\n let {tasks} = args;\n\n if (args.interactive) {\n const selectedTask = await promptForTaskSelection(\n 'build',\n androidProject.sourceDir,\n );\n if (selectedTask) {\n tasks = [selectedTask];\n }\n }\n\n let gradleArgs = getTaskNames(\n androidProject.appName,\n args.mode || args.variant,\n tasks,\n 'bundle',\n androidProject.sourceDir,\n );\n\n if (args.extraParams) {\n gradleArgs.push(...args.extraParams);\n }\n\n if (args.activeArchOnly) {\n const adbPath = getAdbPath();\n const devices = adb.getDevices(adbPath);\n const architectures = devices\n .map((device) => {\n return adb.getCPU(adbPath, device);\n })\n .filter(\n (arch, index, array) => arch != null && array.indexOf(arch) === index,\n );\n if (architectures.length > 0) {\n logger.info(`Detected architectures ${architectures.join(', ')}`);\n // `reactNativeDebugArchitectures` was renamed to `reactNativeArchitectures` in 0.68.\n // Can be removed when 0.67 no longer needs to be supported.\n gradleArgs.push(\n '-PreactNativeDebugArchitectures=' + architectures.join(','),\n );\n gradleArgs.push('-PreactNativeArchitectures=' + architectures.join(','));\n }\n }\n await runPackager(args, config);\n return build(gradleArgs, androidProject.sourceDir);\n}\n\nexport function build(gradleArgs: string[], sourceDir: string) {\n process.chdir(sourceDir);\n const cmd = process.platform.startsWith('win') ? 'gradlew.bat' : './gradlew';\n logger.info('Building the app...');\n logger.debug(`Running command \"${cmd} ${gradleArgs.join(' ')}\"`);\n try {\n execa.sync(cmd, gradleArgs, {\n stdio: 'inherit',\n cwd: sourceDir,\n });\n } catch (error) {\n printRunDoctorTip();\n throw new CLIError('Failed to build the app.', error as Error);\n }\n}\n\nexport const options = [\n {\n name: '--mode <string>',\n description: \"Specify your app's build variant\",\n },\n {\n name: '--variant <string>',\n description:\n \"Specify your app's build variant. Deprecated! Use 'mode' instead\",\n },\n {\n name: '--no-packager',\n description: 'Do not launch packager while building',\n },\n {\n name: '--port <number>',\n default: process.env.RCT_METRO_PORT || 8081,\n parse: Number,\n },\n {\n name: '--terminal <string>',\n description:\n 'Launches the Metro Bundler in a new window using the specified terminal path.',\n default: getDefaultUserTerminal(),\n },\n {\n name: '--tasks <list>',\n description:\n 'Run custom Gradle tasks. By default it\\'s \"assembleDebug\". Will override passed mode and variant arguments.',\n parse: (val: string) => val.split(','),\n },\n {\n name: '--active-arch-only',\n description:\n 'Build native libraries only for the current device architecture for debug builds.',\n default: false,\n },\n {\n name: '--extra-params <string>',\n description: 'Custom params passed to gradle build command',\n parse: (val: string) => val.split(' '),\n },\n {\n name: '--interactive',\n description:\n 'Explicitly select build type and flavour to use before running a build',\n },\n];\n\nexport default {\n name: 'build-android',\n description: 'builds your app',\n func: buildAndroid,\n options,\n};\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAQA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAAsE;AAc/D,eAAeA,WAAW,CAACC,IAAgB,EAAEC,MAAc,EAAE;EAClE,IAAI,CAACD,IAAI,CAACE,QAAQ,EAAE;IAClB;EACF;EACA,MAAMC,MAAM,GAAG,MAAM,IAAAC,6BAAiB,EAACJ,IAAI,CAACK,IAAI,CAAC;EACjD,IAAIF,MAAM,KAAK,SAAS,EAAE;IACxBG,kBAAM,CAACC,IAAI,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