(argv: ArgumentsResolver<CommandParameters>)
| 48 | } |
| 49 | |
| 50 | async function valdiExport(argv: ArgumentsResolver<CommandParameters>): Promise<void> { |
| 51 | const bazel = new BazelClient(); |
| 52 | // eslint-disable-next-line @typescript-eslint/no-non-null-assertion |
| 53 | const platform = argv.getArgument('platform') as PLATFORM; |
| 54 | const bazelArgs = resolveBazelBuildArgs( |
| 55 | platform, |
| 56 | argv.getArgument('build_config'), |
| 57 | ALL_ARCHITECTURES, |
| 58 | /* forDevice */ false, |
| 59 | argv.getArgument('enable_runtime_logs'), |
| 60 | argv.getArgument('enable_runtime_traces'), |
| 61 | argv.getArgument('bazel_args'), |
| 62 | ); |
| 63 | |
| 64 | const resolvedOutputPath = path.resolve(argv.getArgument('output_path')); |
| 65 | const expectedExtension = exportedLibraryExtensionForPlatform(platform); |
| 66 | if (!resolvedOutputPath.endsWith(expectedExtension)) { |
| 67 | throw new CliError(`Output path for platform '${platform}' must have ${expectedExtension} file extension`); |
| 68 | } |
| 69 | |
| 70 | removeFileOrDirAtPath(resolvedOutputPath); |
| 71 | const directoryPath = path.dirname(resolvedOutputPath); |
| 72 | if (!fs.existsSync(directoryPath)) { |
| 73 | fs.mkdirSync(directoryPath, { recursive: true }); |
| 74 | } |
| 75 | |
| 76 | const library = await argv.getArgumentOrResolve('library', () => { |
| 77 | console.log('No library specified querying available targets...'); |
| 78 | return selectBazelTarget( |
| 79 | bazel, |
| 80 | getExportedLibraryTargetTagForPlatform(platform), |
| 81 | 'valdi_exported_library', |
| 82 | 'Please select a library to export:', |
| 83 | ); |
| 84 | }); |
| 85 | |
| 86 | console.log('Resolving output paths...'); |
| 87 | |
| 88 | const bazelOutputExtension = platform === PLATFORM.IOS ? '.zip' : expectedExtension; |
| 89 | const bazelOutputFilePath = await argv.getArgumentOrResolve('target_output_path', () => { |
| 90 | console.log('Resolving output paths...'); |
| 91 | return getOutputFilePath(bazel, bazelOutputExtension, library, bazelArgs); |
| 92 | }); |
| 93 | |
| 94 | console.log(`Building: ${wrapInColor(library, ANSI_COLORS.GREEN_COLOR)}`); |
| 95 | |
| 96 | await bazel.buildTarget(library, bazelArgs); |
| 97 | |
| 98 | console.log(`Copying built target to ${resolvedOutputPath}...`); |
| 99 | if (platform === PLATFORM.IOS) { |
| 100 | await decompressAndMoveXCFrameworkIntoDestination(bazelOutputFilePath, resolvedOutputPath); |
| 101 | } else { |
| 102 | await fs.promises.copyFile(bazelOutputFilePath, resolvedOutputPath); |
| 103 | } |
| 104 | |
| 105 | logReproduceThisCommandIfNeeded(argv); |
| 106 | |
| 107 | console.log('All done!'); |
nothing calls this directly
no test coverage detected