Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions packages/cli/src/tools/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import makeHook from './makeHook';
import {
readConfigFromDisk,
readDependencyConfigFromDisk,
readLegacyDependencyConfigFromDisk,
} from './readConfigFromDisk';

import {type ConfigT} from 'types';
Expand All @@ -39,9 +38,7 @@ function loadConfig(projectRoot: string = process.cwd()): ConfigT {
let config;
try {
root = resolveNodeModuleDir(projectRoot, dependencyName);
config =
readLegacyDependencyConfigFromDisk(root) ||
readDependencyConfigFromDisk(root);
config = readDependencyConfigFromDisk(root);
} catch (error) {
logger.warn(
inlineString(`
Expand Down
18 changes: 7 additions & 11 deletions packages/cli/src/tools/config/readConfigFromDisk.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ export function readDependencyConfigFromDisk(
searchPlaces,
});

const {config} = explorer.searchSync(rootFolder) || {config: undefined};
const {config} = explorer.searchSync(rootFolder) || {
config: readLegacyDependencyConfigFromDisk(rootFolder),
};

const result = Joi.validate(config, schema.dependencyConfig);

Expand Down Expand Up @@ -90,7 +92,7 @@ const loadProjectCommands = (
/**
* Reads a legacy configuration from a `package.json` "rnpm" key.
*/
export function readLegacyDependencyConfigFromDisk(
function readLegacyDependencyConfigFromDisk(
rootFolder: string,
): ?UserDependencyConfigT {
const {rnpm: config, name} = require(path.join(rootFolder, 'package.json'));
Expand All @@ -113,21 +115,15 @@ export function readLegacyDependencyConfigFromDisk(
commands: loadProjectCommands(rootFolder, config.plugin),
platforms: config.platform
? require(path.join(rootFolder, config.platform))
: undefined,
: {},
};

// @todo: paste a link to documentation that explains the migration steps
logger.warn(
`Package ${chalk.bold(
path.basename(name),
)} is using deprecated "rnpm" config that will stop working from next release. Consider upgrading to the new config format.`,
)} is using deprecated "rnpm" config that will stop working from next release. Please notify its maintainers about it.`,
);

const result = Joi.validate(transformedConfig, schema.dependencyConfig);

if (result.error) {
throw new JoiError(result.error);
}

return result.value;
return transformedConfig;
}