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
8 changes: 0 additions & 8 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -461,14 +461,6 @@ Specify any additional asset extensions to be used by the packager

Specify any additional source extensions to be used by the packager

#### `--platforms [list]`

Specify any additional platforms to be used by the packager

#### `--providesModuleNodeModules [list]`

Specify any npm packages that import dependencies with providesModule

#### `--max-workers [number]`

Specifies the maximum number of workers the worker-pool will spawn for transforming files. This defaults to the number of the cores available on your machine
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ to learn more about different types of configuration and features available.

## Migration guide

`"rnpm"` is deprecated and support for it will be removed in next major version of the CLI.
`"rnpm"` is deprecated and support for it is removed since v4.x of the CLI.

> **Important**: Proceed further only if your project uses `"rnpm"` in `package.json`.

Expand Down
16 changes: 3 additions & 13 deletions packages/cli-types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ export type ProjectConfig = {
* @property dependencies - Map of the dependencies that are present in the project
* @property platforms - Map of available platforms (build-ins and dynamically loaded)
* @property commands - An array of commands that are present in 3rd party packages
* @property haste - Haste configuration resolved based on available plugins
*/
export type Config = {
root: string;
Expand All @@ -150,18 +149,14 @@ export type Config = {
[name: string]: PlatformConfig<any, any, any, any>;
};
commands: Command[];
haste: {
platforms: Array<string>;
providesModuleNodeModules: Array<string>;
};
};

/**
* Shares some structure with Config, except that haste and root
* are calculated and can't be defined
* Shares some structure with Config, except that root is calculated and can't
* be defined
*/

export type UserConfig = Omit<Config, 'root' | 'haste'> & {
export type UserConfig = Omit<Config, 'root'> & {
reactNativePath: string | void;
// Additional project settings
project: {
Expand All @@ -178,11 +173,6 @@ export type UserDependencyConfig = {
commands: Command[];
// An array of extra platforms to load
platforms: Config['platforms'];
// Haste config defined by legacy `rnpm`
haste?: {
platforms: string[];
providesModuleNodeModules: string[];
};
};

export {
Expand Down
12 changes: 0 additions & 12 deletions packages/cli/src/commands/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,6 @@ export default {
'Specify any additional source extensions to be used by the packager',
parse: (val: string) => val.split(','),
},
{
name: '--platforms [list]',
description:
'Specify any additional platforms to be used by the packager',
parse: (val: string) => val.split(','),
},
{
name: '--providesModuleNodeModules [list]',
description:
'Specify any npm packages that import dependencies with providesModule',
parse: (val: string) => val.split(','),
},
{
name: '--max-workers [number]',
description:
Expand Down
4 changes: 0 additions & 4 deletions packages/cli/src/tools/config/__mocks__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,5 @@ export default function mockedLoadConfig() {
},
dependencies: {},
assets: [],
haste: {
providesModuleNodeModules: [],
platforms: [],
},
};
}
Original file line number Diff line number Diff line change
@@ -1,55 +1,17 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`should handle deprecated "rnpm" in project root: returns valid config 1`] = `
Object {
"assets": Array [
"<<REPLACED>>/fonts/SampleFont.ttf",
],
"commands": Array [],
"dependencies": Object {},
"haste": Object {
"platforms": Array [],
"providesModuleNodeModules": Array [],
},
"platforms": Object {},
"project": Object {},
"reactNativePath": "<<REPLACED>>/node_modules/react-native",
"root": "<<REPLACED>>",
}
`;

exports[`should have a valid structure by default 1`] = `
Object {
"assets": Array [],
"commands": Array [],
"dependencies": Object {},
"haste": Object {
"platforms": Array [],
"providesModuleNodeModules": Array [],
},
"platforms": Object {},
"project": Object {},
"reactNativePath": "<<REPLACED>>",
"root": "<<REPLACED>>",
}
`;

exports[`should load an out-of-tree "windows" platform that ships with a dependency 1`] = `
Object {
"haste": Object {
"platforms": Array [
"windows",
],
"providesModuleNodeModules": Array [
"react-native-windows",
],
},
"platforms": Object {
"windows": Object {},
},
}
`;

exports[`should load commands from "react-native-foo" and "react-native-bar" packages 1`] = `
Array [
Object {
Expand Down Expand Up @@ -91,46 +53,6 @@ Object {
}
`;

exports[`should read \`rnpm\` config from a dependency and transform it to a new format: foo config 1`] = `
Object {
"assets": Array [],
"hooks": Object {},
"name": "react-native-foo",
"params": Array [],
"platforms": Object {
"android": null,
"ios": Object {
"folder": "<<REPLACED>>/node_modules/react-native-foo",
"libraryFolder": "Libraries",
"pbxprojPath": "<<REPLACED>>/node_modules/react-native-foo/customLocation/customProject.xcodeproj/project.pbxproj",
"plist": Array [],
"podfile": null,
"podspecPath": null,
"projectName": "customProject.xcodeproj",
"projectPath": "<<REPLACED>>/node_modules/react-native-foo/customLocation/customProject.xcodeproj",
"scriptPhases": Array [],
"sharedLibraries": Array [],
"sourceDir": "<<REPLACED>>/node_modules/react-native-foo/customLocation",
},
},
"root": "<<REPLACED>>/node_modules/react-native-foo",
}
`;

exports[`should read \`rnpm\` config from a dependency and transform it to a new format: haste config 1`] = `
Object {
"platforms": Array [
"ios",
"android",
"dummy",
],
"providesModuleNodeModules": Array [
"react-native",
"react-native-dummy",
],
}
`;

exports[`should read a config of a dependency and use it to load other settings 1`] = `
Object {
"assets": Array [],
Expand Down
79 changes: 0 additions & 79 deletions packages/cli/src/tools/config/__tests__/index-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,6 @@ test('should have a valid structure by default', () => {
expect(removeString(config, DIR)).toMatchSnapshot();
});

test('should handle deprecated "rnpm" in project root', () => {
writeFiles(DIR, {
'package.json': `{
"rnpm": {
"assets": ["./fonts"]
}
}`,
'fonts/SampleFont.ttf': '',
});
const config = loadConfig(DIR);

expect(removeString(config, DIR)).toMatchSnapshot('returns valid config');
expect(logger.warn).toBeCalledWith(
expect.stringMatching(/Your project is using deprecated/),
);
});

test('should return dependencies from package.json', () => {
writeFiles(DIR, {
...REACT_NATIVE_MOCK,
Expand Down Expand Up @@ -167,35 +150,6 @@ test('should merge project configuration with default values', () => {
);
});

test('should read `rnpm` config from a dependency and transform it to a new format', () => {
writeFiles(DIR, {
...REACT_NATIVE_MOCK,
'node_modules/react-native-foo/package.json': `{
"name": "react-native-foo",
"rnpm": {
"ios": {
"project": "./customLocation/customProject.xcodeproj"
},
"haste": {
"platforms": ["dummy"],
"providesModuleNodeModules": ["react-native-dummy"]
}
}
}`,
'package.json': `{
"dependencies": {
"react-native": "0.0.1",
"react-native-foo": "0.0.1"
}
}`,
});
const {dependencies, haste} = loadConfig(DIR);
expect(removeString(dependencies['react-native-foo'], DIR)).toMatchSnapshot(
'foo config',
);
expect(haste).toMatchSnapshot('haste config');
});

test('should load commands from "react-native-foo" and "react-native-bar" packages', () => {
writeFiles(DIR, {
'node_modules/react-native-foo/package.json': '{}',
Expand Down Expand Up @@ -227,39 +181,6 @@ test('should load commands from "react-native-foo" and "react-native-bar" packag
expect(commands).toMatchSnapshot();
});

test('should load an out-of-tree "windows" platform that ships with a dependency', () => {
writeFiles(DIR, {
'node_modules/react-native-windows/platform.js': `
module.exports = {"windows": {}};
`,
'node_modules/react-native-windows/plugin.js': `
module.exports = [];
`,
'node_modules/react-native-windows/package.json': `{
"name": "react-native-windows",
"rnpm": {
"haste": {
"platforms": [
"windows"
],
"providesModuleNodeModules": [
"react-native-windows"
]
},
"plugin": "./plugin.js",
"platform": "./platform.js"
}
}`,
'package.json': `{
"dependencies": {
"react-native-windows": "0.0.1"
}
}`,
});
const {haste, platforms} = loadConfig(DIR);
expect(removeString({haste, platforms}, DIR)).toMatchSnapshot();
});

// @todo: figure out why this test is so flaky
// eslint-disable-next-line jest/no-disabled-tests
test.skip('should skip packages that have invalid configuration', () => {
Expand Down
49 changes: 1 addition & 48 deletions packages/cli/src/tools/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ function loadConfig(projectRoot: string = findProjectRoot()): Config {
return findAssets(projectRoot, userConfig.assets);
},
platforms: userConfig.platforms,
haste: {
providesModuleNodeModules: [],
platforms: Object.keys(userConfig.platforms),
},
get project() {
if (lazyProject) {
return lazyProject;
Expand All @@ -99,8 +95,6 @@ function loadConfig(projectRoot: string = findProjectRoot()): Config {
},
};

let depsWithWarnings: Array<[string, string]> = [];

const finalConfig = Array.from(
new Set([
...Object.keys(userConfig.dependencies),
Expand All @@ -116,15 +110,7 @@ function loadConfig(projectRoot: string = findProjectRoot()): Config {
root =
localDependencyRoot ||
resolveNodeModuleDir(projectRoot, dependencyName);
const output = readDependencyConfigFromDisk(root);
config = output.config;

if (output.legacy && !localDependencyRoot) {
const pkg = require(path.join(root, 'package.json'));
const link =
pkg.homepage || `https://npmjs.com/package/${dependencyName}`;
depsWithWarnings.push([dependencyName, link]);
}
config = readDependencyConfigFromDisk(root);
} catch (error) {
logger.warn(
inlineString(`
Expand All @@ -139,17 +125,6 @@ function loadConfig(projectRoot: string = findProjectRoot()): Config {

const isPlatform = Object.keys(config.platforms).length > 0;

/**
* Legacy `rnpm` config required `haste` to be defined. With new config,
* we do it automatically.
*
* @todo: Remove this once `rnpm` config is deprecated and all major RN libs are converted.
*/
const haste = config.haste || {
providesModuleNodeModules: isPlatform ? [dependencyName] : [],
platforms: Object.keys(config.platforms),
};

return assign({}, acc, {
dependencies: assign({}, acc.dependencies, {
get [dependencyName](): Dependency {
Expand All @@ -168,31 +143,9 @@ function loadConfig(projectRoot: string = findProjectRoot()): Config {
...acc.platforms,
...config.platforms,
},
haste: {
providesModuleNodeModules: [
...acc.haste.providesModuleNodeModules,
...haste.providesModuleNodeModules,
],
platforms: [...acc.haste.platforms, ...haste.platforms],
},
}) as Config;
}, initialConfig);

if (depsWithWarnings.length) {
logger.warn(
`The following packages use deprecated "rnpm" config that will stop working from next release:\n${depsWithWarnings
.map(
([name, link]) =>
` - ${chalk.bold(name)}: ${chalk.dim(chalk.underline(link))}`,
)
.join(
'\n',
)}\nPlease notify their maintainers about it. You can find more details at ${chalk.dim.underline(
'https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide',
)}.`,
);
}

return finalConfig;
}

Expand Down
Loading