Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove "rnpm" #790

Merged
merged 32 commits into from
Oct 17, 2019
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
af98694
Remove legacy link
grabbou Oct 14, 2019
bff36a2
Clean up ios config
grabbou Oct 14, 2019
b8a9c8b
Remove install/uninstall
grabbou Oct 14, 2019
0532792
Update comments
grabbou Oct 14, 2019
34e1507
Update test on iOS
grabbou Oct 14, 2019
a1f7d7b
Clean up iOS dependencies
grabbou Oct 14, 2019
6965689
Type iOS config and set proper return types
grabbou Oct 14, 2019
df08c0d
Update scheme
grabbou Oct 14, 2019
d1d26c8
Update schema
grabbou Oct 14, 2019
2e247ac
Not all projects need native code
grabbou Oct 14, 2019
fbd732a
No assumptions on CocoaPods, different package managers might be used
grabbou Oct 14, 2019
6b1bbaa
Fix type errors
grabbou Oct 15, 2019
ddcd301
Update snapshots to reflect missing config properties
grabbou Oct 15, 2019
9cbb5e4
Void is not undefined
grabbou Oct 15, 2019
0fc2255
Clean up Android configuration
grabbou Oct 15, 2019
91ed178
Update schema
grabbou Oct 15, 2019
0b2d9d0
Serious rnpm/documentation removals and cleaned up tests
grabbou Oct 15, 2019
6ba3f2c
Remove remaining props
grabbou Oct 15, 2019
be58d25
Update snapshots for some of the tests
grabbou Oct 15, 2019
7fc2afa
Fix last test - fixture was broken
grabbou Oct 15, 2019
41f8dde
Update docs/dependencies.md
grabbou Oct 15, 2019
b81d3ad
Fix type for scriptPhases
grabbou Oct 17, 2019
4852932
Update to | undefined instead of elvis
grabbou Oct 17, 2019
2fec727
Add deprecated commands
grabbou Oct 17, 2019
5780f84
Merge branch 'feat/remove-link' of github.com:react-native-community/…
grabbou Oct 17, 2019
7b7505f
Add deprecation links
grabbou Oct 17, 2019
53e45c5
Move undefined to null
grabbou Oct 17, 2019
ae6bb4d
Add documentation back
grabbou Oct 17, 2019
cdf8aea
clean up
grabbou Oct 17, 2019
52ac627
chore
grabbou Oct 17, 2019
2e399d3
Update snapshots
grabbou Oct 17, 2019
4b3577d
And update unit test back to null
grabbou Oct 17, 2019
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
33 changes: 0 additions & 33 deletions __e2e__/install.test.ts

This file was deleted.

54 changes: 0 additions & 54 deletions __e2e__/uninstall.test.ts

This file was deleted.

104 changes: 1 addition & 103 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

React Native CLI has a configuration mechanism that allows changing its behavior and providing additional features.

> Note: Configuring CLI used to be possible via `rn-cli.config.js` (that has been renamed to `metro.config.js`) and never documented `rnpm` entry on the `package.json`. We have provided migration guides where possible.

React Native CLI can be configured by creating a `react-native.config.js` at the root of the project. Depending on the type of a package, the set of valid properties is different.

Check the documentation for
Expand All @@ -17,104 +15,4 @@ to learn more about different types of configuration and features available.

## Migration guide
thymikee marked this conversation as resolved.
Show resolved Hide resolved

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

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

There are different kinds of React Native projects, including apps, libraries and platforms. For each we prepared a brief "before & after" of the configuration shape with legacy `"rnpm"` and current `react-native.config.js`. Please mind that all configuration entries are optional.

### Apps

`package.json` entry:

```json
{
"rnpm": {
"ios": {},
"android": {},
"assets": ["./path-to-assets"],
"plugin": "./path-to-commands.js"
}
}
```

becomes `react-native.config.js`

```js
module.exports = {
project: {
ios: {},
android: {}, // grouped into "project"
},
assets: ['./path-to-assets'], // stays the same
commands: require('./path-to-commands.js'), // formerly "plugin", returns an array of commands
};
```

### Libraries

`package.json` entry:

```json
{
"rnpm": {
"ios": {},
"android": {},
"assets": ["./path-to-assets"],
"hooks": {
"prelink": "./path-to-a-prelink-hook"
}
}
}
```

becomes `react-native.config.js`:

```js
module.exports = {
// config for a library is scoped under "dependency" key
dependency: {
platforms: {
ios: {},
android: {}, // projects are grouped into "platforms"
},
assets: ['./path-to-assets'], // stays the same
// hooks are considered anti-pattern, please avoid them
hooks: {
prelink: './path-to-a-prelink-hook',
},
},
};
```

You'll find more details in [dependencies](./dependencies.md) docs.

### Out-of-tree platforms

`package.json` entry:

```json
{
"rnpm": {
"haste": {
"platforms": ["windows"],
"providesModuleNodeModules": ["react-native-windows"]
},
"platform": "./local-cli/platform.js"
}
}
```

becomes `react-native.config.js`

```js
module.exports = {
platforms: {
// grouped under "platforms" entry
windows: require('./local-cli/platform.js').windows,
},
// "haste" is no longer needed
};
```

You'll find more details in [platforms](./platforms.md) docs.
Support for `rnpm` has been removed with the 4.x release of the CLI. If your project or library still uses `rnpm` for altering the behaviour of the CLI, please check [documentation of the older CLI release](https://github.com/react-native-community/cli/blob/3.x/docs/configuration.md) for steps on how to migrate.
119 changes: 23 additions & 96 deletions docs/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,22 @@ For example, `lodash` is a dependency that doesn't have any native code to link.

By default, CLI analyses the folder structure inside the dependency and looks for assets and native files to link. This simple heuristic works in most of the cases.

At the same time, a dependency can explicitly set its configuration in case CLI cannot infer it properly. A dependency can also define additional settings, such as a script to run after linking, in order to support some advanced use-cases.
At the same time, a dependency can explicitly set its configuration in case CLI cannot infer it properly.

## How does it work?

A dependency can define the following `react-native.config.js` at the root:

```js
module.exports = {
dependency: {
platforms: {
ios: {
project: './Custom.xcodeproj'
}
}
assets: ['./assets']
}
};
```

> The above configuration informs CLI of the additional assets to link and about a custom project location.

## Dependency interface
## Interface

The following type describes the configuration of a dependency that can be set under `dependency` key inside `react-native.config.js`.

```ts
type DependencyConfigT = {
interface Dependency = {
platforms: {
ios?: IOSDependencyParams | null;
android?: AndroidDependencyParams | null;
[key: string]: any;
};
assets: string[];
hooks: {
[key: string]: string;
};
};
```

> Note: This interface is subject to breaking changes. We may consider renaming some keys to simplify the configuration further. If you are going to use it, be prepared to update before we ship a stable 0.60.0 release.

### platforms

A map of specific settings that can be set per platform. The exact shape is always defined by the package that provides given platform.
Expand All @@ -54,18 +31,24 @@ In most cases, as a library author, you should not need to define any of these.
The following settings are available on iOS and Android:

```ts
type DependencyParamsIOST = {
interface IOSDependencyParams {
project?: string;
podspecPath?: string;
sharedLibraries?: string[];
};
scriptPhases?: Array<{
name: string;
path: string;
execution_position: string;
}>;
}

type DependencyParamsAndroidT = {
interface AndroidDependencyParams {
packageName?: string;
sourceDir?: string;
manifestPath?: string;

packageImportPath?: string;
packageInstance?: string;
};
}
```

#### platforms.ios.project
Expand All @@ -76,10 +59,6 @@ Custom path to `.xcodeproj`.

Custom path to `.podspec` file to use when auto-linking. Example: `node_modules/react-native-module/ios/module.podspec`.

#### platforms.ios.sharedLibraries

An array of shared iOS libraries to link with the dependency. E.g. `libc++`. This is mostly a requirement of the native code that a dependency ships with.

#### platforms.ios.scriptPhases

An array of iOS script phases to add to the project. Specifying a `path` property with a path relative to the dependency root will load the contents of the file at the path as the script contents.
Expand All @@ -91,7 +70,7 @@ An array of iOS script phases to add to the project. Specifying a `path` propert
module.exports = {
dependency: {
platforms: {
ios: {
ios: {
scriptPhases: [
{
name: '[MY DEPENDENCY] My Script',
Expand All @@ -111,6 +90,10 @@ See [`script_phase` options](https://www.rubydoc.info/gems/cocoapods-core/Pod/Po

A relative path to a folder with source files. E.g. `custom-android`, or `custom-android/app`. By default, CLI searches for `android` and `android/app` as source dirs.

#### platforms.android.packageName

Custom package name, unless the default one present under `AndroidManifest.xml` is wrong.

#### platforms.android.manifestPath

Path to a custom `AndroidManifest.xml`
Expand All @@ -125,62 +108,6 @@ Custom syntax to instantiate a package. By default, it's a `new AwesomePackage()

For settings applicable on other platforms, please consult their respective documentation.

### assets

An array of assets folders to glob for files to link.

### hooks

A map where key is the name of a hook and value is the path to a file to execute.

For example, `link` command supports `prelink` and `postlink` hooks to run before and after linking is done.

These are the only ones supported by CLI at the moment. Depending on the packages used in your project, you may find other hooks supported to.

> Note: This has nothing to do with React Hooks.

## Migrating from `rnpm` configuration

The changes are mostly cosmetic so the migration should be pretty straight-forward.

> Note: We read `rnpm` configuration to remain backwards-compatible. Dependency maintainers should update their configuration in the nearest future.

### Changing the configuration

Properties were renamed. Look at the following example for the differences.

```json
{
"rnpm": {
"ios": {},
"android": {},
"assets": ["./path-to-assets"],
"hooks": {
"prelink": "./path-to-a-prelink-hook"
}
}
}
```

to a `react-native.config.js`

```js
module.exports = {
dependency: {
platforms: {
ios: {},
android: {},
},
assets: ['./path-to-assets'],
hooks: {
prelink: './path-to-a-prelink-hook',
},
},
};
```

### Asking for params while linking has been removed

If your library needs it, do not upgrade over to the new config format.
## Migrating from `rnpm`

If you want to ask users for additional settings, consider setting a custom `postlink` hook, just like [`react-native-code-push`](https://github.com/Microsoft/react-native-code-push/blob/master/package.json#L53).
Support for `rnpm` has been removed with the 4.x release of the CLI. If your project or library still uses `rnpm` for altering the behaviour of the CLI, please check [documentation of the older CLI release](https://github.com/react-native-community/cli/blob/3.x/docs/dependencies.md#migrating-from-rnpm-configuration) for steps on how to migrate.
Loading