1import chalk from 'chalk'; 2 3import { ModPlatform } from '../Plugin.types'; 4 5/** 6 * Log a warning that doesn't disrupt the spinners. 7 * 8 * ```sh 9 * » android: android.package: property is invalid https://expo.fyi/android-package 10 * ``` 11 * 12 * @param property Name of the config property that triggered the warning (best-effort) 13 * @param text Main warning message 14 * @param link Useful link to resources related to the warning 15 */ 16export function addWarningAndroid(property: string, text: string, link?: string) { 17 console.warn(formatWarning('android', property, text, link)); 18} 19 20/** 21 * Log a warning that doesn't disrupt the spinners. 22 * 23 * ```sh 24 * » ios: ios.bundleIdentifier: property is invalid https://expo.fyi/bundle-identifier 25 * ``` 26 * 27 * @param property Name of the config property that triggered the warning (best-effort) 28 * @param text Main warning message 29 * @param link Useful link to resources related to the warning 30 */ 31export function addWarningIOS(property: string, text: string, link?: string) { 32 console.warn(formatWarning('ios', property, text, link)); 33} 34 35export function addWarningForPlatform( 36 platform: ModPlatform, 37 property: string, 38 text: string, 39 link?: string 40) { 41 console.warn(formatWarning(platform, property, text, link)); 42} 43 44function formatWarning(platform: string, property: string, warning: string, link?: string) { 45 return chalk.yellow`${'» ' + chalk.bold(platform)}: ${property}: ${warning}${ 46 link ? chalk.gray(' ' + link) : '' 47 }`; 48} 49