Repository navigation
Standardise configuration mechanism - #254
Conversation
|
I noticed that we only get configuration for direct dependencies of a user’s (Ideally we wouldn’t crawl |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
commented
Mar 21, 2019
|
WIP on the CocoaPods integration #256 |
|
EDIT: Android PR is up #258 - points to this branch. |
commented
Mar 22, 2019
|
@alloy, unfortunately, this is potentially a security issue. With auto linking, users are less aware of what gets linked and crawling through the entire I commented about that on Discord, so let's follow up there. |
commented
Mar 22, 2019
|
Submitted a draft PR for the template changes: react/react-native#24099 I can iterate/change as required - just gives some visibility of the changes required to the template. |
commented
Mar 22, 2019
|
@grabbou I disagree. Any dependency is a security risk, so if you already opt-in to that then I don’t think we should generate projects that are essentially broken. Like, one of the 20 file watchers in my node_modules dir could easily inject malicious code, hijack data from my machine, etc. |
commented
Mar 24, 2019
|
If this feature gets some opt-out way, or some kind of "opt-in only" mechanism (or even to choose one), the risks should be mitigated. Maybe let's not just look from a security perspective (as @alloy mentioned that adding dependencies itself is a risk), but have it looked at via some usability- and debugging-perspective. When having any automatic step, that does some "magic", makes it some kind of debugging hell to find out why some dependency is included. The current way of including things explicitly, makes me as a dev able to choose what I want to have inside my native app. Especially when having some kind of nasty transitive-dependency hack I have to apply (like changing some version), how can this be done when things are getting applied without me doing the plumbing? (sorry if this disrupts anything or is the wrong place to add my 2 cents) |
commented
Mar 24, 2019
|
@FibreFoX all feedback is welcome - so thank you :) Auto-linking on both platforms support opting-out (just don't include the ruby script in your Podfile or the Gradle script in your build.gradle); opt-in by default on new apps generated through |
commented
Mar 24, 2019
|
@Salakar So this is some all-or-nothing thing, means as developer I can opt-in to this by adding that line inside Just as some additional idea: could you add some "show me what I would add"-command, in case I'm coming from "auto-linking" and want to (or have to) add the modules manually (in cases where I need to override some dependency as described above)? In addition to being able to "switch", it would make debugging much easier, especially for native-module developers which want to check if their module gets included. |
| } | ||
| } | ||
|
|
||
| type JoiErrorT = { |
There was a problem hiding this comment.
maybe it would be easier to flow-typed install joi and use something from there?
commented
Apr 1, 2019
|
Yup. @thymikee, do we have a place for the docs right now? I am kinda bad at them, so just thinking where to start. |
commented
Apr 1, 2019
|
Cool! Let's add docs in next PR when I integrate this into a |
Summary:
This pull requests brings a new way of configuring the CLI and drops never properly standardised and documented "rnpm" configuration.
This is done in order to support new "auto-linking" feature and consolidate the configuration into a single place, that is easy to customise by developers.
Highlights
Given the scope of this PR, it's hard to write down every tiny detail. I've tried to leave as many comments as possible throughout the code to make it easier for you to navigate and understand some of the code patterns.
Please see the highlighted changes below:
We now use
cosmiconfigto load user preferences. We do that by taking "react-native" out of "package.json" and reading "react-native.config.js". We still read "rnpm" for legacy purposes and print appropriate deprecation messages along the instructions on what to do in order to upgrade. Jest validation library makes this kind of things super easy.We validate the provided configuration by user using Jest validation library. This gives instant feedback whether the configuration is correct or not.
We now read configuration in a single place (happens in main CLI file) and pass it down to commands. Previously, we used to call
findPluginsmultiple times w/o cache, causing expensive globs to be performed.Project configuration is lazy. We won't glob node_modules and/or look for native files unless you explicitly read for that package configuration.
Better support for out-of-tree-platforms - no need to define "haste" yourself, we are able to infer it from other properties. The files are also better organised now, causing less of maintenance pain with "linkConfig"
We consider our automatically generated configuration a set of defaults. Users can override settings for the project and each of the dependencies. Useful, especially with auto-linking feature to disable certain packages from it or when you don't want to link particular platform automatically. This has been historically really hard to implement
Global flags (e.g. "reactNativePath") can now be defined in configuration, instead of passing every time around. This fixes issues with "packager.sh" script (starting automatically Metro when running from Xcode) when run from RNTester.xcodeproj
Next steps
Once this PR is merged, we can concurrently start working/merging other "auto-linking" PRs. In the meantime, I'll submit a PR to move regular "link" (soon to be considered a legacy) to use the new configuration format as well.
The new configuration has been designed in the way to still include previous configuration keys to support "link" and other community packages.
For now, we print handy deprecation messages to help migrate the community from "rnpm" to "react-native" configuration.
When "link" gets deprecated/removed forever in favour of "auto-linking", we should revisit the configuration and eventually, remove extraneous keys out of it. With "auto-linking", we don't need majority of it.
Test Plan:
Run
react-native configto output the configuration.