Skip to content

Commit

Permalink
refactor(breaking): remove deprecated link, unlink and associated…
Browse files Browse the repository at this point in the history
… code (#1537)

* chore: initial commit - remove files

* chore: further removal

* chore: wip

* continue work

* chore: fix warnings and errors

* chore: move findXcodeProj to config and upgrade run-ios

* chore: add todo

* chore: remove example

* chore: update source dir and update dependnecy config for ios

* chore: remove logger

* chore: fix type issues

* chore: remove tests for missing properties, prefer snapshots instead for broader coverage

* chore: update snapshots for iOS config (removed properties)

* chore: fix upgrade tests

* chore: remove extra tests

* chore: update config tests

* chore: two tests tbd to support new resolution mechanism

* chore: fix ios tests and bring back configurable sourceDir

* feat: align findPodfilePath with old findProject heuristics

* chore: fix lint

* chore: update snapshot

* fix: filter invalid deps

* chore: update tests

* chore: add missing properties to Joi schema

* chore: another update

* chore: fix Joi schema

* chore: update schema

* chore: fix snapshot

* chore: note on the future development for this file

* chore: update snapshot one more time - nitpick

* one last time

* feat: print when multiple podfiles are found

* update docs

* chore: fix

* Update autolinking.md

* chore: remove xmldoc dep

* chore: remove xcode dep

* chore: return type for dependencyConfig

* Update index.ts

Co-authored-by: Michał Pierzchała <[email protected]>
  • Loading branch information
grabbou and thymikee authored Feb 7, 2022
1 parent 2f819db commit 25eec7c
Show file tree
Hide file tree
Showing 174 changed files with 463 additions and 7,470 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
"javascriptreact",
"typescript",
"typescriptreact"
]
],
"typescript.tsdk": "node_modules/typescript/lib"
}
28 changes: 6 additions & 22 deletions __e2e__/__snapshots__/config.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ exports[`shows up current config without unnecessary output 1`] = `
]
}
],
"assets": [],
"healthChecks": [],
"platforms": {
"ios": {},
Expand All @@ -41,30 +40,15 @@ exports[`shows up current config without unnecessary output 1`] = `
"project": {
"ios": {
"sourceDir": "<<REPLACED_ROOT>>/TestProject/ios",
"folder": "<<REPLACED_ROOT>>/TestProject",
"pbxprojPath": "<<REPLACED_ROOT>>/TestProject/ios/TestProject.xcodeproj/project.pbxproj",
"podfile": "<<REPLACED_ROOT>>/TestProject/ios/Podfile",
"podspecPath": null,
"projectPath": "<<REPLACED_ROOT>>/TestProject/ios/TestProject.xcodeproj",
"projectName": "TestProject.xcodeproj",
"libraryFolder": "Libraries",
"sharedLibraries": [],
"plist": [],
"scriptPhases": []
"xcodeProject": {
"name": "TestProject.xcodeproj",
"isWorkspace": false
}
},
"android": {
"sourceDir": "<<REPLACED_ROOT>>/TestProject/android",
"isFlat": true,
"folder": "<<REPLACED_ROOT>>/TestProject",
"stringsPath": "<<REPLACED_ROOT>>/TestProject/android/app/src/main/res/values/strings.xml",
"manifestPath": "<<REPLACED_ROOT>>/TestProject/android/app/src/main/AndroidManifest.xml",
"buildGradlePath": "<<REPLACED_ROOT>>/TestProject/android/build.gradle",
"settingsGradlePath": "<<REPLACED_ROOT>>/TestProject/android/settings.gradle",
"assetsPath": "<<REPLACED_ROOT>>/TestProject/android/app/src/main/assets",
"mainFilePath": "<<REPLACED_ROOT>>/TestProject/android/app/src/main/java/com/testproject/MainApplication.java",
"packageName": "com.testproject",
"packageFolder": "com/testproject",
"appName": "app"
"appName": "app",
"packageName": "com.testproject"
}
}
}
Expand Down
38 changes: 0 additions & 38 deletions __e2e__/install.test.ts

This file was deleted.

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

This file was deleted.

4 changes: 1 addition & 3 deletions docs/autolinking.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ yarn react-native run-android

That's it. No more editing build config files to use native code.

> Autolinking is a replacement for [react-native link](https://github.com/react-native-community/cli/blob/master/docs/commands.md#link). If you have been using React Native before version 0.60, please `unlink` native dependencies if you have any from a previous install.
## How does it work

Each platform defines its own [`platforms`](./platforms.md) configuration. It instructs the CLI on how to find information about native dependencies. This information is exposed through the [`config`](./commands.md#config) command in a JSON format. It's then used by the scripts run by the platform's build tools. Each script applies the logic to link native dependencies specific to its platform.
Expand All @@ -28,7 +26,7 @@ The [native_modules.rb](https://github.com/react-native-community/cli/blob/maste
1. Adds dependencies via CocoaPods dev pods (using files from a local path).
1. Adds build phase scripts to the App project’s build phase. (see examples below)

This means that all libraries need to ship a Podspec either in the root of their folder or where the Xcode project is. Podspec references the native code that your library depends on.
This means that all libraries need to ship a Podspec in the root of their folder. Podspec references the native code that your library depends on.

The implementation ensures that a library is imported only once. If you need to have a custom `pod` directive then include it above the `use_native_modules!` function.

Expand Down
68 changes: 0 additions & 68 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@ React Native CLI comes with following commands:
- [`doctor`](#doctor)
- [`init`](#init)
- [`info`](#info)
- [`install`](#install)
- [`link`](#link)
- [`log-android`](#log-android)
- [`log-ios`](#log-ios)
- [`ram-bundle`](#ram-bundle)
- [`run-android`](#run-android)
- [`run-ios`](#run-ios)
- [`start`](#start)
- [`uninstall`](#uninstall)
- [`unlink`](#unlink)
- [`upgrade`](#upgrade)
- [`profile-hermes`](#profile-hermes)

Expand Down Expand Up @@ -239,38 +235,6 @@ react-native info

Get relevant version info about OS, toolchain and libraries. Useful when sending bug reports.

### `install`

Usage:

```sh
react-native install <packageName>
```

Installs single package from npm and then links native dependencies. If `install` detects `yarn.lock` in your project, it will use Yarn as package manager. Otherwise `npm` will be used.

### `link`

> Will be replaced by [autolinking](./autolinking.md) soon.
Usage:

```sh
react-native link [packageName]
```

Links assets and optionally native modules.

#### Options

#### `--all`

Link all native modules and assets.

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

Pass comma-separated list of platforms to scope `link` to.

### `log-android`

Usage:
Expand Down Expand Up @@ -425,10 +389,6 @@ Explicitly set the scheme configuration to use default: 'Debug'.

Explicitly set Xcode scheme to use.

#### `--project-path <string>`

Path relative to project root where the Xcode project (.xcodeproj) lives. default: 'ios'.

#### `--device [string]`

Explicitly set device to use by name. The value is not required if you have a single device connected.
Expand Down Expand Up @@ -519,34 +479,6 @@ Path to the CLI configuration file

Disables interactive mode

### `uninstall`

Usage:

```sh
react-native uninstall <packageName>
```

Unlinks single package native dependencies and then uninstalls it from `package.json`. If `uninstall` detects `yarn.lock` in your project, it will use Yarn as package manager. Otherwise `npm` will be used.

### `unlink`

> Will be replaced by [autolinking](./autolinking.md) soon.
Usage:

```
react-native unlink <packageName> [options]
```

Unlink native dependency linked with the `link` command.

#### Options

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

Scope unlinking to specified platforms

### `upgrade`

Usage:
Expand Down
106 changes: 0 additions & 106 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 @@ -14,107 +12,3 @@ Check the documentation for
- [plugins](./plugins.md)

to learn more about different types of configuration and features available.

## Migration guide

`"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`.
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.
Loading

0 comments on commit 25eec7c

Please sign in to comment.