import type { BundleDefinitionWithRequiredParameters } from "@rnx-kit/config" ; import { getBundleDefinition , getBundlePlatformDefinition , getKitConfig , } from "@rnx-kit/config" ; import { warn } from "@rnx-kit/console" ; import type { AllPlatforms } from "@rnx-kit/tools-react-native/platform" ; import chalk from "chalk" ; import type { KitBundleConfig } from "./types" ; param id returns export function getKitBundleDefinition ( id ? ) { const kitConfig = getKitConfig ( ) ; if ( ! kitConfig ) { throw new Error ( "No kit configuration found for this react-native experience" ) ; } if ( kitConfig . bundle === null || kitConfig . bundle === undefined ) { warn ( chalk . yellow ( "No bundle configuration found for this react-native experience -- skipping bundling" ) ) ; return undefined ; } else if ( ! kitConfig . bundle ) { warn ( chalk . yellow ( "Bundling is disabled for this react-native experience -- skipping" ) ) ; return undefined ; } return getBundleDefinition ( kitConfig . bundle , id ) ; } param overridePlatform param targetPlatforms returns export function getTargetPlatforms ( overridePlatform ? , targetPlatforms ? ) { if ( overridePlatform ) { return [ overridePlatform ] ; } if ( targetPlatforms && targetPlatforms . length > 0 ) { return targetPlatforms ; } throw new Error ( "No target platforms given. Update the kit configuration to include a target platform, or provide a target platform on the command-line." ) ; } param id param overridePlatform returns export function getKitBundleConfigs ( id ? , overridePlatform ? ) { const bundleDefinition = getKitBundleDefinition ( id ) ; if ( ! bundleDefinition ) { return undefined ; } const platforms = getTargetPlatforms ( overridePlatform , bundleDefinition . targets ) ; return platforms . map < KitBundleConfig > ( ( platform ) => { return { ... getBundlePlatformDefinition ( bundleDefinition , platform ) , platform } ; } ) ; }