1 line
4.0 KiB
Plaintext
1 line
4.0 KiB
Plaintext
{"version":3,"names":["searchPlaces","readConfigFromDisk","rootFolder","explorer","cosmiconfig","stopDir","searchResult","searchSync","config","undefined","result","schema","projectConfig","validate","error","JoiError","value","readDependencyConfigFromDisk","dependencyName","emptyDependencyConfig","dependencyConfig","abortEarly","validationError","logger","warn","inlineString","chalk","bold","message","dependency","platforms","commands"],"sources":["../src/readConfigFromDisk.ts"],"sourcesContent":["import cosmiconfig from 'cosmiconfig';\nimport {JoiError} from './errors';\nimport * as schema from './schema';\nimport {\n UserConfig,\n UserDependencyConfig,\n} from '@react-native-community/cli-types';\nimport {logger, inlineString} from '@react-native-community/cli-tools';\nimport chalk from 'chalk';\n\n/**\n * Places to look for the configuration file.\n */\nconst searchPlaces = ['react-native.config.js'];\n\n/**\n * Reads a project configuration as defined by the user in the current\n * workspace.\n */\nexport function readConfigFromDisk(rootFolder: string): UserConfig {\n const explorer = cosmiconfig('react-native', {\n searchPlaces,\n stopDir: rootFolder,\n });\n\n const searchResult = explorer.searchSync(rootFolder);\n const config = searchResult ? searchResult.config : undefined;\n const result = schema.projectConfig.validate(config);\n\n if (result.error) {\n throw new JoiError(result.error);\n }\n\n return result.value as UserConfig;\n}\n\n/**\n * Reads a dependency configuration as defined by the developer\n * inside `node_modules`.\n */\nexport function readDependencyConfigFromDisk(\n rootFolder: string,\n dependencyName: string,\n): UserDependencyConfig {\n const explorer = cosmiconfig('react-native', {\n stopDir: rootFolder,\n searchPlaces,\n });\n\n const searchResult = explorer.searchSync(rootFolder);\n const config = searchResult ? searchResult.config : emptyDependencyConfig;\n\n const result = schema.dependencyConfig.validate(config, {abortEarly: false});\n\n if (result.error) {\n const validationError = new JoiError(result.error);\n logger.warn(\n inlineString(`\n Package ${chalk.bold(\n dependencyName,\n )} contains invalid configuration: ${chalk.bold(\n validationError.message,\n )}.\n \n Please verify it's properly linked using \"react-native config\" command and contact the package maintainers about this.`),\n );\n }\n\n return result.value as UserDependencyConfig;\n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