Skip to content

Commit 25eec7c

Browse files
grabbouthymikee
andauthored
refactor(breaking): remove deprecated link, unlink and associated 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 <thymikee@gmail.com>
1 parent 2f819db commit 25eec7c

File tree

174 files changed

+463
-7470
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+463
-7470
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
"javascriptreact",
1818
"typescript",
1919
"typescriptreact"
20-
]
20+
],
21+
"typescript.tsdk": "node_modules/typescript/lib"
2122
}

__e2e__/__snapshots__/config.test.ts.snap

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ exports[`shows up current config without unnecessary output 1`] = `
3232
]
3333
}
3434
],
35-
"assets": [],
3635
"healthChecks": [],
3736
"platforms": {
3837
"ios": {},
@@ -41,30 +40,15 @@ exports[`shows up current config without unnecessary output 1`] = `
4140
"project": {
4241
"ios": {
4342
"sourceDir": "<<REPLACED_ROOT>>/TestProject/ios",
44-
"folder": "<<REPLACED_ROOT>>/TestProject",
45-
"pbxprojPath": "<<REPLACED_ROOT>>/TestProject/ios/TestProject.xcodeproj/project.pbxproj",
46-
"podfile": "<<REPLACED_ROOT>>/TestProject/ios/Podfile",
47-
"podspecPath": null,
48-
"projectPath": "<<REPLACED_ROOT>>/TestProject/ios/TestProject.xcodeproj",
49-
"projectName": "TestProject.xcodeproj",
50-
"libraryFolder": "Libraries",
51-
"sharedLibraries": [],
52-
"plist": [],
53-
"scriptPhases": []
43+
"xcodeProject": {
44+
"name": "TestProject.xcodeproj",
45+
"isWorkspace": false
46+
}
5447
},
5548
"android": {
5649
"sourceDir": "<<REPLACED_ROOT>>/TestProject/android",
57-
"isFlat": true,
58-
"folder": "<<REPLACED_ROOT>>/TestProject",
59-
"stringsPath": "<<REPLACED_ROOT>>/TestProject/android/app/src/main/res/values/strings.xml",
60-
"manifestPath": "<<REPLACED_ROOT>>/TestProject/android/app/src/main/AndroidManifest.xml",
61-
"buildGradlePath": "<<REPLACED_ROOT>>/TestProject/android/build.gradle",
62-
"settingsGradlePath": "<<REPLACED_ROOT>>/TestProject/android/settings.gradle",
63-
"assetsPath": "<<REPLACED_ROOT>>/TestProject/android/app/src/main/assets",
64-
"mainFilePath": "<<REPLACED_ROOT>>/TestProject/android/app/src/main/java/com/testproject/MainApplication.java",
65-
"packageName": "com.testproject",
66-
"packageFolder": "com/testproject",
67-
"appName": "app"
50+
"appName": "app",
51+
"packageName": "com.testproject"
6852
}
6953
}
7054
}

__e2e__/install.test.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.

__e2e__/uninstall.test.ts

Lines changed: 0 additions & 63 deletions
This file was deleted.

docs/autolinking.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ yarn react-native run-android
1515

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

18-
> 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.
19-
2018
## How does it work
2119

2220
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.
@@ -28,7 +26,7 @@ The [native_modules.rb](https://github.com/react-native-community/cli/blob/maste
2826
1. Adds dependencies via CocoaPods dev pods (using files from a local path).
2927
1. Adds build phase scripts to the App project’s build phase. (see examples below)
3028

31-
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.
29+
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.
3230

3331
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.
3432

docs/commands.md

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,12 @@ React Native CLI comes with following commands:
77
- [`doctor`](#doctor)
88
- [`init`](#init)
99
- [`info`](#info)
10-
- [`install`](#install)
11-
- [`link`](#link)
1210
- [`log-android`](#log-android)
1311
- [`log-ios`](#log-ios)
1412
- [`ram-bundle`](#ram-bundle)
1513
- [`run-android`](#run-android)
1614
- [`run-ios`](#run-ios)
1715
- [`start`](#start)
18-
- [`uninstall`](#uninstall)
19-
- [`unlink`](#unlink)
2016
- [`upgrade`](#upgrade)
2117
- [`profile-hermes`](#profile-hermes)
2218

@@ -239,38 +235,6 @@ react-native info
239235

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

242-
### `install`
243-
244-
Usage:
245-
246-
```sh
247-
react-native install <packageName>
248-
```
249-
250-
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.
251-
252-
### `link`
253-
254-
> Will be replaced by [autolinking](./autolinking.md) soon.
255-
256-
Usage:
257-
258-
```sh
259-
react-native link [packageName]
260-
```
261-
262-
Links assets and optionally native modules.
263-
264-
#### Options
265-
266-
#### `--all`
267-
268-
Link all native modules and assets.
269-
270-
#### `--platforms [list]`
271-
272-
Pass comma-separated list of platforms to scope `link` to.
273-
274238
### `log-android`
275239

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

426390
Explicitly set Xcode scheme to use.
427391

428-
#### `--project-path <string>`
429-
430-
Path relative to project root where the Xcode project (.xcodeproj) lives. default: 'ios'.
431-
432392
#### `--device [string]`
433393

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

520480
Disables interactive mode
521481

522-
### `uninstall`
523-
524-
Usage:
525-
526-
```sh
527-
react-native uninstall <packageName>
528-
```
529-
530-
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.
531-
532-
### `unlink`
533-
534-
> Will be replaced by [autolinking](./autolinking.md) soon.
535-
536-
Usage:
537-
538-
```
539-
react-native unlink <packageName> [options]
540-
```
541-
542-
Unlink native dependency linked with the `link` command.
543-
544-
#### Options
545-
546-
#### `--platforms [list]`
547-
548-
Scope unlinking to specified platforms
549-
550482
### `upgrade`
551483

552484
Usage:

docs/configuration.md

Lines changed: 0 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

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

5-
> 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.
6-
75
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.
86

97
Check the documentation for
@@ -14,107 +12,3 @@ Check the documentation for
1412
- [plugins](./plugins.md)
1513

1614
to learn more about different types of configuration and features available.
17-
18-
## Migration guide
19-
20-
`"rnpm"` is deprecated and support for it is removed since v4.x of the CLI.
21-
22-
> **Important**: Proceed further only if your project uses `"rnpm"` in `package.json`.
23-
24-
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.
25-
26-
### Apps
27-
28-
`package.json` entry:
29-
30-
```json
31-
{
32-
"rnpm": {
33-
"ios": {},
34-
"android": {},
35-
"assets": ["./path-to-assets"],
36-
"plugin": "./path-to-commands.js"
37-
}
38-
}
39-
```
40-
41-
becomes `react-native.config.js`
42-
43-
```js
44-
module.exports = {
45-
project: {
46-
ios: {},
47-
android: {}, // grouped into "project"
48-
},
49-
assets: ['./path-to-assets'], // stays the same
50-
commands: require('./path-to-commands.js'), // formerly "plugin", returns an array of commands
51-
};
52-
```
53-
54-
### Libraries
55-
56-
`package.json` entry:
57-
58-
```json
59-
{
60-
"rnpm": {
61-
"ios": {},
62-
"android": {},
63-
"assets": ["./path-to-assets"],
64-
"hooks": {
65-
"prelink": "./path-to-a-prelink-hook"
66-
}
67-
}
68-
}
69-
```
70-
71-
becomes `react-native.config.js`:
72-
73-
```js
74-
module.exports = {
75-
// config for a library is scoped under "dependency" key
76-
dependency: {
77-
platforms: {
78-
ios: {},
79-
android: {}, // projects are grouped into "platforms"
80-
},
81-
assets: ['./path-to-assets'], // stays the same
82-
// hooks are considered anti-pattern, please avoid them
83-
hooks: {
84-
prelink: './path-to-a-prelink-hook',
85-
},
86-
},
87-
};
88-
```
89-
90-
You'll find more details in [dependencies](./dependencies.md) docs.
91-
92-
### Out-of-tree platforms
93-
94-
`package.json` entry:
95-
96-
```json
97-
{
98-
"rnpm": {
99-
"haste": {
100-
"platforms": ["windows"],
101-
"providesModuleNodeModules": ["react-native-windows"]
102-
},
103-
"platform": "./local-cli/platform.js"
104-
}
105-
}
106-
```
107-
108-
becomes `react-native.config.js`
109-
110-
```js
111-
module.exports = {
112-
platforms: {
113-
// grouped under "platforms" entry
114-
windows: require('./local-cli/platform.js').windows,
115-
},
116-
// "haste" is no longer needed
117-
};
118-
```
119-
120-
You'll find more details in [platforms](./platforms.md) docs.

0 commit comments

Comments
 (0)