-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
Improvement: Adjust template to match new init command #24138
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI this needs the mentioned PR to be merged in CLI before landing
template/index.js
Outdated
|
||
AppRegistry.registerComponent(appName, () => App); | ||
AppRegistry.registerComponent('HelloWorld', () => App); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could take placeholderName
from template.config.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scratch that, forgot we aim for easy replacement of template name and don't want to tie template to the config anyhow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate? I don't think we should hardcode HelloWorld
anywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a placeholder, that will be globally replaced in the initialization process. This placeholder is used everywhere in the template: ios, android etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it!
template/_watchmanconfig
Outdated
@@ -1 +0,0 @@ | |||
{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you bring this file back please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure C: Removed it by mistake :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need an empty watchman config in a regular React Native app?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is no watchmanconfig file like this, watchman will not be enabled for the project. We want it to be enabled by default if watchman is installed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you confirm this with somebody from Watchman team at FB? We don't need that file in projects that use Jest and it uses watchman without issues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, it may actually be a thing that we only need at FB given our settings here. In that case, I'm alright with you removing it.
I don't think having dotfiles like this will work within FB. We have various tools that run based on the existence of, for example, a |
Also, is there a reason we are moving away from |
@cpojer can you check if it will work with dotfiles? One of my main goals in this refactor was getting rid of this underscores prefixes. |
One benefit is just being able to open the template as a root and work with these dot files to make sure everything passes (e.g. Flow works or Jest works). Not a deal breaker, but would be a good improvement.
Not at all. We are going to use our own configuration. I would remove it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cpojer has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Seems like we may be able to land this after all, with a few internal changes. Let me know once it is ready. |
Add compatibility to older init Remove oopsie
Let me explain why there are so many changes: |
@@ -50,7 +50,8 @@ | |||
"README.md", | |||
"third-party-podspecs", | |||
"template", | |||
"local-cli" | |||
"local-cli", | |||
"template.config.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you confirm with npm pack
that .gitignore
from template/
is published as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not so relevant now, will matter for 3rd party templates though
I am -1 on this solution, maintaining two set of folder is too much work. |
@gengjiawen We will have one template. I am working on a solution in |
This one maybe need to cope with more caution. Filename starts with |
@@ -50,7 +50,8 @@ | |||
"README.md", | |||
"third-party-podspecs", | |||
"template", | |||
"local-cli" | |||
"local-cli", | |||
"template.config.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not so relevant now, will matter for 3rd party templates though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Thanks for making this change minimal, I really appreciate it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
@cpojer forgot about |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cpojer has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
This pull request was successfully merged by @Esemesek in 770da3a. When will my fix make it into a release? | Upcoming Releases |
Note I removed the |
Summary: --------- New `init` command will exist in `@react-native-community/cli` and will deprecate current initialization flow. ### What has been done: - [x] - Added `init` command to `cli` (the previous implementation was partially existing in `global cli`) - [x] - Created a more friendly interface to create custom templates for initialization - [x] - Redesigned template to match custom template interface (https://github.com/Esemesek/react-native-new-template) - [x] - Added support to pass local repositories to `--version` and `--template` options through `file:` ### New template Structure: ``` . ├── package.json ├── template │ ├── App.js │ ├── __tests__ │ ├── android │ ├── babel.config.js │ ├── index.js │ ├── ios │ ├── metro.config.js │ ├── package.json │ └── yarn.lock └── template.config.js ``` * Root level `package.json` defines package * `template.config.js` is a configuration file. Not a lot of properties we can configure for now, but can be extended in the future. (https://github.com/Esemesek/react-native-new-template/blob/master/template.config.js - supported properties) * Directory with `template` which will be copied and processed during initialization process. In this structure it is called `template`, but it can be configured. ### Initalization You can try out this PR, by cloning repository, checkouting to `Esemesek/init` branch, building `cli` and then running command: ```sh node react-native-cli/packages/cli/buld init {projectName} --template react-native-new-template ``` To test intialization process without using custom template, `react-native` package you are using should contain update template. You can either create new version of `react-native` and publish it to local npm repository or use `--version file:{/absolute/path/to/update/react-native}` ### Example usage Init with custom version: ``` npx react-native init ProjectName --version 0.60.0 ``` Init with custom local version: ``` npx react-native init ProjectName --version file:///Users/username/local/version/of/react-native ``` Init with custom template: ``` npx react-native init ProjectName --template custom-template ``` Inite with custom local template: ``` npx react-native init ProjectName --template file:///Users/username/local/custom/template ``` > Note that `--template` needs to be valid absolute URL to react native or custom template Initialization could also be done by first installing `react-native` and then running init. ```sh mkdir SomeDir && cd SomeDir yarn add react-native react-native init ProjectName ``` Hopefully we will be able to support yarn flows in the future: yarnpkg/rfcs#113 ### TODO: - [x] - Add better logging - [x] - Add more unit tests - [x] - Update template in `react-native` repository (facebook/react-native#24138) - [ ] - Update documentation Test Plan: ---------- - [x] - Tested manually - [x] - Unit tests - [x] - E2E tests - probably most important one
Summary: Adjusting template to new init command (react-native-community/cli#241). PR with new init command needs to be merged before we land this. [General] [Changed] - Adjust template to match new init command Pull Request resolved: facebook#24138 Differential Revision: D14617568 Pulled By: cpojer fbshipit-source-id: f4b90920d47d3e0d2b08470e0eaad1abd733e4cc
Expose collapsable as React Prop in LayoutShadowNode Summary: This diff exposes the collapsable prop as part of LayoutShadowNode, fixing the bug of the collapsable prop being filtered by JS in Fabric Reviewed By: shergin Differential Revision: D14594522 fbshipit-source-id: a892ba8228e76f11232acc6fe5c8d75e991d8fc6 Add logs in mounting layer Summary: Adds debug logging in FabricUIManager and the mounting layer of Fabric. Reviewed By: shergin Differential Revision: D14594521 fbshipit-source-id: a5c0ee39e1bac8a340849ca3e044694cbee5427e Refactor mapping of FabricComponentNames Summary: Simple diff that refactors the usage of the sComponentNames to not require components to be part of the mapping when the name in JS is the same as the name in Native side. Reviewed By: shergin Differential Revision: D14594659 fbshipit-source-id: d1948b27e04686fefbf9b6e2b06d4f9317b97062 Fix scrolling of Android Horizontal Scroll View Summary: This diff fixes the scrolling of Android Horizontal Scroll View, the root cause was that Binding was mounting a ScrollView instead of an AndroidHorizontalScrollView component. This will be automatically fixed when all the View components are autogenerated. Reviewed By: shergin Differential Revision: D14594622 fbshipit-source-id: 7c477ca167188ea9c473f61145461d3cf1696e17 Small changes to State objects to support Android Summary: Small changes to State objects to support Android. See following diffs. Reviewed By: mdvacca Differential Revision: D14663470 fbshipit-source-id: 878f4dc39265991a7b8ff54ca80bdb862f1dd3de TM iOS: force flush message queue when calling into JS from native Summary: When calling into JS (e.g. promise resolve/reject, callback) in TurboModule, we bypass the bridge's message queue. At times this causes race condition, where there are a bunch of pending UI operations (in RCTUImanager) waiting to be flushed, but nothing adds calls to the message queue. Usually tapping the screen will trigger the flush because we're sending down touch events to JS. Reviewed By: JoshuaGross Differential Revision: D14656466 fbshipit-source-id: cb3a174e97542bf80f0a37b4170b6a8e6780fa35 Fix invalid CGContext when invalidate layer (#24195) Summary: If size is zero, the `CGContext` would invalid, so we need to filter zero things. cc. shergin [iOS] [Fixed] - Fix invalid CGContext when invalidate layer Pull Request resolved: https://github.com/facebook/react-native/pull/24195 Differential Revision: D14683396 Pulled By: shergin fbshipit-source-id: b5b45fb86ca3158284281460cf1d95d1b22eab0d use shared mutex in RCTSurfacePresenter Summary: Otherwise reloading from metro deadlocks like this: `[RCTSurfaceRegistry _stopAllSurfaces]` is calling `[RCTSurfaceRegistry enumerateWithBlock]` which locks `_mutex` and then we call `surfaceForRootTag` which then deadlocks on the same mutex: https://pxl.cl/tmm1 Reviewed By: shergin Differential Revision: D14679843 fbshipit-source-id: 9f4ecdfa7a79fcf7f3fc2ce437d4399b00910f26 TM Android: temporarily disable callback support to unbreak build Summary: With the recent change, JSCallInvoker now expects `Instance` to be passed in, not just the `MessageQueueThread`. There needs to be more plumbing to get the instance of `Instance` from the Java side, but this commit is just to unbreak the build temporarily. Reviewed By: JoshuaGross Differential Revision: D14687622 fbshipit-source-id: 42e0173ee8336fc5660fe8188a1e1f8517611521 Move WebView JS files to FB internal Summary: This moves all the JS files and updates the BUCK files. The next step is to move the Android and iOS native files. Reviewed By: TheSavior Differential Revision: D14618890 fbshipit-source-id: 42984acdf5920e712f272d5742c778943be37ac5 Back out "[react-native][PR] There is a small gap in the SynchronizedWeakHashSet implementation. T?" Summary: Original commit changeset: 2998bffb06e2 Reviewed By: JoshuaGross Differential Revision: D14689422 fbshipit-source-id: 2638bed8005859cc95972ba5f78a9e9cace878ef Back out "[react-native][PR][Microsoft] This change fixes currently broken ReactContext listeners mechanism." Summary: Original commit changeset: d506e5035a7f Reviewed By: JoshuaGross Differential Revision: D14689559 fbshipit-source-id: 9a8c8be0d2b7b9dd9be1ec038d7c3b356a5e3adf Move requireNativeComponent calls to standalone files Summary: Moves a number of requireNativeComponent calls to standalone files to support codegen Reviewed By: TheSavior Differential Revision: D14654018 fbshipit-source-id: 349b975cd3a99a9373b2b9b1a19aa311d7c36399 Fabric: Fixed a bug in Diffing algorithm Summary: Before the fix, the algorithm compares ShadowViews to make a decision should it recursively call itself or not; that didn't work properly because a ShadowView doesn't fully represent the state of the subtree tree (e.g. they don't have information about children nodes). After the fix, we compare pointers to ShadowNodes (by comparing pairs). Reviewed By: mdvacca Differential Revision: D14696996 fbshipit-source-id: 560d623b15a272f13b08a11745dec6be39a5dbdd Fabric: Removed log leftover Summary: Trivial. Reviewed By: mdvacca Differential Revision: D14696997 fbshipit-source-id: 5f093ae5f343f2a2a2ee060f0574a6acf4c186d4 Disable view pooling Summary: Temporarily disable View Pooling in Fabric Naming of classes will change in the near future Reviewed By: JoshuaGross Differential Revision: D14685009 fbshipit-source-id: 83573dd09af0202a67d0d0aa11e37c1660c3991f Implement auto-conversions from primitives to Objects Summary: If a NativeModule method requires an optional boolean argument, our codegen translates those optional booleans into `NSNumber*` instead of `BOOL`. The reason why is probably because this is the closest object analogue to `BOOL` in Objective C. The same boxing occurs with numbers. If the type of a number argument in JavaScript is optional, we'll map it to the `NSNumber*` Objective C type instead of `double`. Our existing TurboModules argument conversion code would not take this behaviour into account. Therefore, we'd try to insert a `BOOL` where the `NSInvocation` would expect a `NSNumber*`. This, in turn, would cause the app to crash. (Why would it crash at the point of NSInvocation retainArguments, I'm still not sure). Our flow typechecking ensures that if the type of a method argument is a boolean, we pass in a boolean. Therefore, on the Native side, if we detect a boolean, we can check the type of the Native argument to see whether we should box the primitive. If the native argument type is an object, then we know it has to be an `NSNumber*` in both cases, so we simply wrap the `BOOL` or `double` in a `NSNumber*`. Reviewed By: shergin Differential Revision: D14679590 fbshipit-source-id: c394a878492aab8e98c71d74ec8740a94fc3a6c5 Use constructor attribute instead of +load objc method (#24155) Summary: Xcode 10.2 forbids creating categories for swift class that uses `+load` method. In react-native categories like this are used to register swift classes as modules (macro `RCT_EXTERN_MODULE`) This PR changes it to use `__attribute__((constructor))` instead of objc `+load` method. I introduced new macro for this purpose, `RCT_EXPORT_MODULE_NO_LOAD`, it expands in something like: ``` void RCTRegisterModule(Class); + (NSString *)moduleName { return @"jsNameFoo"; } __attribute__((constructor)) static void initialize_ObjcClassFoo{ RCTRegisterModule([ObjcClassFoo class]); } ``` Functions marked with `__attribute__((constructor))` are run before main and after all `+load` methods, so it seems like correct thing to do. Fixes https://github.com/facebook/react-native/issues/24139 Doc about loading order https://developer.apple.com/documentation/objectivec/nsobject/1418815-load?language=objc [iOS] [Fixed] - Fix runtime crash in xcode 10.2 when using RCT_EXTERN_MODULE for swift classes. Pull Request resolved: https://github.com/facebook/react-native/pull/24155 Reviewed By: javache Differential Revision: D14668235 Pulled By: shergin fbshipit-source-id: 0c19e69ce2a68327387809773848d4ecd36d7461 Move Android code for Geolocation out Reviewed By: cpojer Differential Revision: D14692916 fbshipit-source-id: 6bcfda8aa8c7d22dce36828dae9f57068815ce20 moved all the properties used for layout outputs to YogaNodeJNI Summary: Moved layout outputs transfer logic from YogaNodeJNIBase to YogaNodeJNI. This change set is for adding experiment for layout outputs batching using a float array Reviewed By: davidaurelio Differential Revision: D14642995 fbshipit-source-id: 5d0bc7fa18c1985be7e216d7351f5eab2e03861d added test for reset method in YogaNodeJNI to verify all layout outputs are reset properly Summary: This diff adds a test for reset method in YogaNodeJNI to verify all layout outputs are reset properly Reviewed By: davidaurelio Differential Revision: D14643926 fbshipit-source-id: fffbcd07ccb6d2df83fc0bf187d992ef194f3bd0 Added implementation for YogaNodeJNIBatching and logic for passing array from c++ to java Summary: This diff adds the logic to transfer layout outputs using a float array Reviewed By: davidaurelio Differential Revision: D14368120 fbshipit-source-id: d1f22283bcea051d15657f42c15b90edaa0a8a7a added flag for useBatchingForLayoutOutputs experiment Summary: Using a config flag to switch between different implementations of transferring layout outputs - YogaNodeJNI uses multiple access of java fields to pass all properties like width, height, margin etc... - YogaNodeJNIBatching uses a float array to pass all the data in one java field access Reviewed By: davidaurelio Differential Revision: D14378301 fbshipit-source-id: 0da5b28e6a67ad8fd60eb7efe622d9b2deaf177f Turn on react-hooks/exhaustive-deps in FBSource Summary: Looks like there are already a bunch of issues in the codebase because this wasn't on. Reviewed By: cpojer Differential Revision: D14701084 fbshipit-source-id: 09ff8e0d905b81fbe08c41d4f58758479b38187b fix typo in DatePickerAndroidTypes.js (#24234) Summary: fix typo in DatePickerAndroidTypes.js, fixes https://github.com/facebook/react-native/issues/24137 [Android] [Changed] - fix typo in DatePickerAndroidTypes.js Pull Request resolved: https://github.com/facebook/react-native/pull/24234 Differential Revision: D14705691 Pulled By: cpojer fbshipit-source-id: 0d4aee045f7ec36b0cfcd5b4ce5a2cd47cee9ec5 Remove navigator.geolocation, use Geolocation Summary: This is the first diff in an effort to remove Geolocation from React Native. This diff removes the globally injected navigator.geolocation feature and instead requires explicit importing of `Geolocation`. When using Web APIs, people will need to patch `navigator.geolocation` on their own from now on. Reviewed By: sahrens Differential Revision: D14692386 fbshipit-source-id: c57b290b49728101250d726d67b1956ff23a9a92 Fabric `ShadowTree` (and co) was moved to `mounting` module Summary: Because it's kinda more logical and we will rely on this in comming diffs. Reviewed By: mdvacca Differential Revision: D14587124 fbshipit-source-id: 94ae9410b4ffeffd0fcb4da4a0518f0bb0d2ba63 Fabric: Introspection (self testing in debug mode) in ShadowTree Summary: We suspect that we have some error in diffing algorithm that cause some crashes in mounting layer, so we decided to write a comprehensive unit tests for that. Writing them we realized that it would be cool to also enable that for normal app run in the debug more, so we can catch the problem in real environment when/if it happens. Reviewed By: mdvacca Differential Revision: D14587123 fbshipit-source-id: 6dcdf451b39489dec751cd6787de33f3b8ffb3fd Add the ability to customize webview response to client cert requests Summary: Add the ability to set a custom handler on ReactWebViewManager to handle client certificate challenges during TLS authentication. [Android][Added] - Public method setCustomClientCertRequestHandler to the native com.facebook.react.views.webview.ReactWebViewManager, that allows using a custom response for client certificate challenges. Reviewed By: mjhu Differential Revision: D14609697 fbshipit-source-id: 567c95458af638d1f8233fc3ca0d9cefc061c2bf Harmonize spacing after colons (#24186) Summary: Harmonizes the spacing after colons to have a more consistent coding style. Pull Request resolved: https://github.com/facebook/react-native/pull/24186 Differential Revision: D14668167 Pulled By: cpojer fbshipit-source-id: 8f1ba71eec186b3a2221d1f4fac851e51afc52cc Fix setting the contentOffset value when refresh ends (#24191) Summary: It closes #24170. I opened the issue yesterday, and I think I found the way how to resolve it. So, I'm opening this PR directly without any comment on the issue. In the `endRefreshProgrammatically` of `RCTRefreshControl.m`, the comment says that " The contentOffset of the scrollview MUST be greater than 0". However, if the `contentInset` prop is set for the `FlatList`, I think `contentOffset` can be a negative value after refreshing and should be greater than `-contentInset.top`. As I reported the bug in that issue, If I am using `contentInset` prop to the `FlatList`, making `contentOffset` value be always 0 when refreshing ends causes something wrong situation. [iOS] [Fixed] - Fix setting the contnetOffset when refreshing ends Pull Request resolved: https://github.com/facebook/react-native/pull/24191 Differential Revision: D14710987 Pulled By: sahrens fbshipit-source-id: 03f06df9a93a2a46a7cc0b56269091778805917e Revert D14423742: Use of TraceCompat Summary: D14423742 introduced a regression on OSS test_android due to androidx.core.os not being available. I spent some time investigating a fix forward this morning, with no success. Reverting. Changelog: [Android] [Changed] - Revert 92f019c666c4933b8553b60038803819f4204e5d Reviewed By: cpojer Differential Revision: D14668728 fbshipit-source-id: c7542992805551dc4302626e1536759794efaa82 Fix retain cycle in RCTDevMenu Summary: A retain-cycle regression was added by D14162776 and detected here: T41208740. Fix should be trivial. Reviewed By: shergin Differential Revision: D14709784 fbshipit-source-id: bad6ab31a5170e9320c4432cbd20d02ec6164f38 Move Geolocation JS code to FB internal Summary: This removes the JS parts of Geolocation from React Native open source. Reviewed By: yungsters Differential Revision: D14693179 fbshipit-source-id: 1da5b7ec0e3e9d21d2019b7ee43e5f85661795b4 Improvement: Adjust template to match new init command (#24138) Summary: Adjusting template to new init command (https://github.com/react-native-community/react-native-cli/pull/241). PR with new init command needs to be merged before we land this. [General] [Changed] - Adjust template to match new init command Pull Request resolved: https://github.com/facebook/react-native/pull/24138 Differential Revision: D14617568 Pulled By: cpojer fbshipit-source-id: f4b90920d47d3e0d2b08470e0eaad1abd733e4cc Android: Enable views to be nested within <Text> (#23195) Summary: Potential breaking change: The signature of ReactShadowNode's onBeforeLayout method was changed - Before: public void onBeforeLayout() - After: public void onBeforeLayout(NativeViewHierarchyOptimizer nativeViewHierarchyOptimizer) Implements same feature as this iOS PR: https://github.com/facebook/react-native/pull/7304 Previously, only Text and Image could be nested within Text. Now, any view can be nested within Text. One restriction of this feature is that developers must give inline views a width and a height via the style prop. Previously, inline Images were supported via FrescoBasedReactTextInlineImageSpan. To get support for nesting views within Text, we create one special kind of span per inline view. This span is called TextInlineViewPlaceholderSpan. It is the same size as the inline view. Its job is just to occupy space -- it doesn't render any visual. After the text is rendered, we query the Android Layout object associated with the TextView to find out where it has positioned each TextInlineViewPlaceholderSpan. We then position the views to be at those locations. One tricky aspect of the implementation is that the Text component needs to be able to render native children (the inline views) but the Android TextView cannot have children. This is solved by having the native parent of the ReactTextView also host the inline views. Implementation-wise, this was accomplished by extending the NativeViewHierarchyOptimizer to handle this case. The optimizer now handles these cases: - Node is not in the native tree. An ancestor must host its children. - Node is in the native tree and it can host its own children. - (new) Node is in the native tree but it cannot host its own children. An ancestor must host both this node and its children. I added the `onInlineViewLayout` event which is useful for writing tests for verifying that the inline views are positioned properly. Limitation: Clipping ---------- If Text's height/width is small such that an inline view doesn't completely fit, the inline view may still be fully visible due to hoisting (the inline view isn't actually parented to the Text which has the limited size. It is parented to an ancestor which may have a different clipping rectangle.). Prior to this change, layout-only views had a similar limitation. Pull Request resolved: https://github.com/facebook/react-native/pull/23195 Differential Revision: D14014668 Pulled By: shergin fbshipit-source-id: d46130f3d19cc83ac7ddf423adcc9e23988245d3 update url for apk-splits user-guide (#24253) Summary: Changed apk-splits user-guide url. [ANDROID] [CHANGED] - Apk tools url. Pull Request resolved: https://github.com/facebook/react-native/pull/24253 Differential Revision: D14724834 Pulled By: cpojer fbshipit-source-id: 8e9e21ebdcb0d585f1f262640e259ccf71112adb Bump react-native version in template in release script (#24262) Summary: Since template has a fixed version in `template/package.json`, we want to automate this process. [General] [Added] - Bump react-native in `template/package.json` Pull Request resolved: https://github.com/facebook/react-native/pull/24262 Differential Revision: D14724831 Pulled By: cpojer fbshipit-source-id: 164d13001a889941398f3db3b9b96eb9d5114cc3 add ram bundle to android template (#24264) Summary: I plan to do this for a long time :) Still a little surprised so much people not know it https://twitter.com/geekykaran/status/1112756026611257344 [Android] [Feature] - add ram bundle to android template Pull Request resolved: https://github.com/facebook/react-native/pull/24264 Differential Revision: D14725396 Pulled By: cpojer fbshipit-source-id: b8e424f0be81978465259c82024f206d232acb55 Prevent crash when setting underlineColorAndroid (#24183) Summary: Try to prevent the crash described in https://github.com/facebook/react-native/issues/17530 There seems to be a bug in `Drawable.mutate()` in some devices/android os versions even after you check the constant state. This error is hard to reproduce and to fix, so just try to catch the exception to prevent crash. [Android][Fixed] Prevent random crash when setting underlineColorAndroid Pull Request resolved: https://github.com/facebook/react-native/pull/24183 Differential Revision: D14710484 Pulled By: cpojer fbshipit-source-id: 3af20a5cb0ecd40839beaf85118c0f5aa6905414 Move WebView Android files to FB internal Summary: This moves the Java files to FB internal and updates all the buck files Reviewed By: TheSavior Differential Revision: D14622521 fbshipit-source-id: a8d293e9f9e08868cca3ed2986a08d0db16dec15 bump gradle to 5.2.1 (#23879) Summary: Bump Gradle to 5.2.1, includes many bug fixes and improvements, especially improved Kotlin DSL support. [Android] [Changed] - bump Gradle to 5.2.1 Pull Request resolved: https://github.com/facebook/react-native/pull/23879 Reviewed By: hramos Differential Revision: D14486430 Pulled By: cpojer fbshipit-source-id: 3476516352ff2c947d65103cff6f37e27d888c2d @allow-large-files xplat flow 0.96 upgrade Summary: bypass-lint allow_many_files Reviewed By: panagosg7 Differential Revision: D14727932 fbshipit-source-id: 66b2fce7753450204c5daa131ffe43dcd4736539 Move iOS Geolocation code out from the repo Summary: @public This resolves the iOS side of #20879. Reviewed By: natestedman, cpojer Differential Revision: D14712066 fbshipit-source-id: 88dd0ff80d3467b314cacb9349029dadca4ddf19 Make it possible to run JSBigString tests Summary: Add a target for JSBigString tests that can be run with a normal `buck test` invocation. Also fix an issue in the test when `getenv` returns null by defaulting to `/tmp`. Reviewed By: ridiculousfish Differential Revision: D14716270 fbshipit-source-id: f2eb6d3aab93c32a4b41f5786aedd04a70468d75 TM iOS: Use weak_ptr to pass around Instance to avoid unreleased refs Summary: There is a timing issue when reloading the bridge (in dev mode) and the tear down of the TurboModules. This causes `Instance` to never get freed, hence the "bridge" isn't cleaning up properly. The side effect can be bogus error saying that it's unable to find a module. To address this, JSCallInvoker should just take in weak_ptr<Instance>. Reviewed By: RSNara Differential Revision: D14739181 fbshipit-source-id: f9f2a55486debaeb28d3d293df3cf1d3f6b9a031 Guard against content view being null in onOverScrolled Summary: It seems that the content view can sometimes be null when onOverScrolled is called (presumably when the scrollview gets unmounted while it's in the middle of scrolling?). Changelog: [Android][fixed] - Guard against content view being null in onOverScrolled. Reviewed By: mdvacca Differential Revision: D14737534 fbshipit-source-id: e88ec6f585e50517b734a8809fc3843c0b22df10 Log uri for guessContentTypeFromName exceptions Summary: Add additional logging around the exception to figure out what kind of uris are causing the exception for `getContentTypeForFileName` Reviewed By: PeteTheHeat Differential Revision: D14715917 fbshipit-source-id: 46299d2ff3f1f06991d7800784a025a85815ae8c Remove legacy AnimationManagerModule Summary: This code was shipped as part of the initial open-source release but was never used. Reviewed By: sahrens Differential Revision: D14649389 fbshipit-source-id: 0c068ca69b91d275008f4a7af77a23a4f1470c18 Implement completion callback for LayoutAnimation on Android Summary: All animations are scheduled by the UIManager while it processes a batch of changes, so we can just wait to see what the longest animation is and cancel+reschedule the callback. Reviewed By: mdvacca Differential Revision: D14656733 fbshipit-source-id: 4cbbb7e741219cd43f511f2ce750c53c30e2b2ca Remove experimental gating for LayoutAnimation on Android Reviewed By: sahrens Differential Revision: D14658087 fbshipit-source-id: 378ef4a5c5336d428b5045772d094a297b2767c7 Removing unused and very old versions of the support library resources Summary: TSIA Differential Revision: D14727969 fbshipit-source-id: 1c73534dea7225f2d952ef0f20ea602894d78f04 Change default Inspector Proxy port to 8081 Summary: Change default Inspector Proxy port to 8081 Reviewed By: cwdick Differential Revision: D14745974 fbshipit-source-id: f4b3b158f55c6f5f1b3d9cc2528c5ddb59774a8b Move `YGSetUsedCachedEntries` to internal header Summary: @public In order to get out of pre-releases again, we move `YGSetUsedCachedEntries` from `Yoga.h` to `Yoga-internal.h`. This way, it’s obvious that the function is not public, and we can remove it from future versions without breaking semver contracts. Reviewed By: SidharthGuglani Differential Revision: D14726029 fbshipit-source-id: 8d7e747e843bf5c4b5e1d4cfbfa37ca9d240dffb Make Jest transform @react-native-community packages by default (#24294) Summary: Currently, `react-native` Jest preset will not automatically transpile extracted Lean Core modules (all under `react-native-community` org), so maintainers will likely need to update their docs on how to do that (it's a common pain in RN testing story). We can make it easier for users and maintainers by adding RNC modules to the `transformIgnorePatterns` whitelist we have in Jest preset. Some of them are not necessary to transpile, but I'd say it's a small sacrifice to make (having first test run possibly slower) for having less friction around migrating to extracted modules. [General] [Added] - make Jest transform react-native-community/ packages by default Pull Request resolved: https://github.com/facebook/react-native/pull/24294 Differential Revision: D14748962 Pulled By: cpojer fbshipit-source-id: 36300ee021f03b8c13275a6e0cf28d988ee5beba fix gradle wrapper in template (#24275) Summary: Fix Gradle wrapper in template [Android] [Changed] - fix Gradle wrapper in template Pull Request resolved: https://github.com/facebook/react-native/pull/24275 Differential Revision: D14750280 Pulled By: cpojer fbshipit-source-id: 9aadb1a674503f3fbbdf6cc03a8f8e3d9d2692aa bump fresco to 1.13 (#24274) Summary: Bump Fresco to 1.13, which uses libc++ and many improvements. [Android] [Changed] - Bump Fresco to 1.13 Pull Request resolved: https://github.com/facebook/react-native/pull/24274 Differential Revision: D14750275 Pulled By: cpojer fbshipit-source-id: 3c040fccd4cb484e31d9c6e849ec285666f140c7 Rename ios project name with new template (#24292) Summary: With new `init` implementation we replace all occurrences of the project name (`HelloWorld`) inside `ios` and `android` directories. For some reason, a product name field in `ios` was named wrongly. This shouldn't impact initialization using `global-cli` [iOS] [Fixed] - Change productName in iOS in new init. Pull Request resolved: https://github.com/facebook/react-native/pull/24292 Differential Revision: D14749249 Pulled By: cpojer fbshipit-source-id: aaf4294ab23180770aac3075789d3ffb4d5a4f3f Avoid failing Obj-C tests when xcpretty is not installed (#24173) Summary: Fixes an issue where `scripts/objc-test-ios.sh` would fail if `xcpretty` is not installed. As this tool is not bundled with macOS, and it's not explicitly called out in our docs on testing, the script should not fail if it's not present. In a related change, JUnit reports are written to a more sensible location when the script is run outside of Circle CI. [iOS] [Fixed] - Fixed test script failure when xcpretty is not present Pull Request resolved: https://github.com/facebook/react-native/pull/24173 Differential Revision: D14726101 Pulled By: hramos fbshipit-source-id: 9f3081a75a4a262f55aef8498241fe7d1e04b931 fixed touchable longpress (#24238) Summary: This diff fixes a bug in TouchableNativeFeedback where a long press is not registered. cause of the bug is _touchableHandleResponderMove_ being invoked **regardless** of a moving gesture ( even when movedDistance is 0) in some devices ( including OnePlus5t ), which was eventually clearing out the long-press timeout. fix is to prevent _touchableHandleResponderMove_ from Implementing if the state of touchable is RESPONDER_INACTIVE_PRESS_IN. [General] [Fixed] - Touchable onLongPress fix. Pull Request resolved: https://github.com/facebook/react-native/pull/24238 Reviewed By: cpojer Differential Revision: D14712986 Pulled By: rickhanlonii fbshipit-source-id: e85a66a7e8b61e0a33146b2472e2e055726a0e93 Add YogaNode.cloneWithoutChildren Summary: Adding flat clone method back to YogaNode for reconciliation. Reviewed By: davidaurelio Differential Revision: D14683019 fbshipit-source-id: 08ed2ffbb16052cb11aa464f67a7ba9a64297985 TM Android: fixed up JSCallInvoker creation Summary: A previous commit changed the signature of the Instance (the arg to JSCallInvoker) to be a weak ref, so this callsite needs updating. Reviewed By: mmmulani Differential Revision: D14757188 fbshipit-source-id: 1a8663e56a42b26c6202881c57a7caafa71da2ab Add scrollToOverflowEnabled prop to ScrollView (#24296) Summary: ScrollView's scrollTo behavior on iOS was recently changed to limit the offset to the content size plus any content inset (see #23427). This departure from the old behavior created UI issues for anyone that is using the over-scroll ability for the purpose of positioning elements at specific coordinates on the screen. Examples include using this behavior to position TextInputs above the virtual keyboard programmatically when focused or moving drop down elements positioned near the bottom of the content toward the top of the screen when selected to show a larger absolutely positioned item list. Default behavior does not change and this is an "opt-in" type of prop to re-enable the old behavior. [iOS] [Added] - Added scrollToOverflowEnabled prop to ScrollView Pull Request resolved: https://github.com/facebook/react-native/pull/24296 Differential Revision: D14762619 Pulled By: cpojer fbshipit-source-id: d2a552b5cb321d52e8ea4116327bf9ec647a3aae Pre-allocate Fabric views even when React is running in the UI Thread Summary: Before D14297477, the pre-allocation of views was ONLY necessary when react was running in the JS Thread, this is because the batch of mount items used to contain mount items for creation of views. After D14297477, views are only created during pre-allocation, that means that pre-allocation of views need to be trated the same way independently the thread where it is running. Reviewed By: shergin Differential Revision: D14714933 fbshipit-source-id: 7bd19cd33b624a5b0daaafabb476bb06707eea17 Implement AxialGradientView in Fabric Android Summary: This diff integreates AxialGradientView in Fabric Android Reviewed By: shergin Differential Revision: D14631690 fbshipit-source-id: 54785466ab4cd7251c6667c8dc12d69d9d194832 Fix crash in RCTText in open source RNTester Summary: See https://github.com/facebook/react-native/issues/24288 Reviewed By: sahrens Differential Revision: D14765625 fbshipit-source-id: f7275f3735691e1f0c87e682f6dd675e5ba5a7c0 Android - Add a ReactFragment (#12199) Summary: React Native on Android has currently been focused and targeted at using an [Activity](https://developer.android.com/reference/android/app/Activity.html) for its main form of instantiation. While this has probably worked for most companies and developers, you lose some of the modularity of a more cohesive application when working in a "brown-field" project that is currently native. This hurts more companies that are looking to adopt React Native and slowly implement it in a fully native application. A lot of developers follow Android's guidelines of using Fragments in their projects, even if it is a debated subject in the Android community, and this addition will allow others to embrace React Native more freely. (I even assume it could help with managing navigation state in applications that contain a decent amount of Native code and would be appreciated in those projects. Such as sharing the Toolbar, TabBar, ViewPager, etc in Native Android) Even with this addition, a developer will still need to host the fragment in an activity, but now that activity can contain native logic like a Drawer, Tabs, ViewPager, etc. **Test plan (required)** * We have been using this class at Hudl for over a couple of months and have found it valuable. * If the community agrees on the addition, I can add documentation to the Android sections to include notes about the potential of this Fragment. * If the community agrees on the addition, I can update one or more of the examples in the `/Examples` folder and make use of the Fragment, or even create a new example that uses a native layout manager like Drawer, Tabs, Viewpager, etc) Make sure tests pass on both Travis and Circle CI. _To Note:_ * There is also talk of using React Native inside Android Fragment's without any legit documentation, this could help remedy some of that with more documentation included in this PR https://facebook.github.io/react-native/releases/0.26/docs/embedded-app-android.html#sharing-a-reactinstance-across-multiple-activities-fragments-in-your-app * Others have also requested something similar and have a half-baked solution as well http://stackoverflow.com/questions/35221447/react-native-inside-a-fragment [ANDROID][FEATURE][ReactAndroid/src/main/java/com/facebook/react/ReactFragment.java] - Adds support for Android's Fragment system. This allows for a more hybrid application. <!-- Help reviewers and the release process by writing your own release notes **INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.** CATEGORY [----------] TYPE [ CLI ] [-------------] LOCATION [ DOCS ] [ BREAKING ] [-------------] [ GENERAL ] [ BUGFIX ] [-{Component}-] [ INTERNAL ] [ ENHANCEMENT ] [ {File} ] [ IOS ] [ FEATURE ] [ {Directory} ] |-----------| [ ANDROID ] [ MINOR ] [ {Framework} ] - | {Message} | [----------] [-------------] [-------------] |-----------| [CATEGORY] [TYPE] [LOCATION] - MESSAGE EXAMPLES: [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see --> Pull Request resolved: https://github.com/facebook/react-native/pull/12199 Differential Revision: D14590665 Pulled By: mdvacca fbshipit-source-id: b50b708cde458f9634e0c14b3952fa32f9d82048 Back out "[react-native] Remove experimental gating for LayoutAnimation on Android" Summary: We've identified a couple of remaining issues that need to be re-tested before we can ship this more broadly. Reviewed By: fred2028 Differential Revision: D14775730 fbshipit-source-id: 22402149066c5fbe72c36fcf7f547d63feaf5241 Do not overwrite Object.freeze Summary: Now that React Native ships with a newer version of JSC, we do not need this code to wrap `Object.freeze` any longer. Reviewed By: mmmulani Differential Revision: D14779239 fbshipit-source-id: 1a6e1a9c7f4312572bd08ba604fa8c9d6b1927e1 Adding Flow types for FabricUIManager measure calls Summary: These are the same types as the existing measure calls on Paper's UIManager except ReactTag has been replaced with Node Reviewed By: fkgozali Differential Revision: D14732142 fbshipit-source-id: b757e0d1f8d168232d8ba58938cdcd3b30e006ff Fabric: Improvements in DebugStringConvertible Summary: * Small improvements in pretty-printing algorirhm (adding spaces and new-line caracters). Now it's even more pretty. * The `depth` parameter was integrated into `DebugStringConvertibleOptions` which simplifies evething a bit and reduce amount of arguments that `getDebugDescription` requires. Reviewed By: sahrens Differential Revision: D14715082 fbshipit-source-id: 3ea0b8db3c1816c5cb43f40ccec9cdc1943f33a5 Fabric: `toString` methods were moved into `DebugStringConvertible` with an implementation in .cpp file Summary: They need to be in DebugStringConvertible because it depends on they (and because `debugStringConvertibleUtils` depends on `DebugStringConvertible`). We also moved they implementation to cpp file to avoid leaking Folly's features to consumer namespace. Reviewed By: mdvacca Differential Revision: D14715080 fbshipit-source-id: 7277e17b39a14a2d7ba7e5a9b44a70178feb1045 Fabric: *Informal* `DebugStringConvertible` interface Summary: Informal `DebugStringConvertible` interface serves the same purpose as `DebugStringConvertible` abstract class (providing universal pretty-printing interface) but relies on C++ static overloading instead of virtual dispatch. This approach has some advantages and disadvantages: Pros: * It's more clear and scoped. It's simpler to implement debug-printing functionality aside of normal production code. * It's more composable. * It allows print types that are not classes. * For some classes using `DebugStringConvertible` means that we have to use virtual inheritance (which might be undesirable and affect *production* performance (if a compiler isn't smart enough to remove empty base class). * For some highly lean classes (that designed to be as small as possible) adding base (even empty-in-prod) classes kinda... smells. Cons: The particular implementations cannot rely on dynamic dispatch which can complicate printing classes with meaningful differences between sampling classes (e.g. ShadowNode subclasses). That's why we don't remove `DebugStringConvertible` class yet. Reviewed By: mdvacca Differential Revision: D14715081 fbshipit-source-id: 1d397dbf81dc6d1dff0cc3f64ad09f10afe0085d Fabric: `getDebugDescription` implementation for `shared_ptr`, `weak_ptr` and `unique_ptr` Summary: Trivial. Reviewed By: mdvacca Differential Revision: D14715083 fbshipit-source-id: 92031cbbf166ea00569a6076d41575a9fd741043 Fabric: `getDebugDescription` for `ShadowView` and `ShadowViewMutation` Summary: Trivial. Now we can print actual list of mutations in case of some failure in the diffing algorithm. Reviewed By: mdvacca Differential Revision: D14715079 fbshipit-source-id: d0af7c756287643892d7120c199bc8028a6b3431 Fix crash if set text and set selection at the same time. (#22723) Summary: Since text and selection has dependency, handle text selection in updateExtraData as well. The root cause is due to setText is handled on extra data update but setSelection is handled on set property. And extra data update will be handled after all properties are handled. Since selection and text has dependency, move selection to extra data update as well. Changelog: ---------- [Android] [Fixed] - Fix crash when set text and selection on textinput at the same time Pull Request resolved: https://github.com/facebook/react-native/pull/22723 Differential Revision: D14783791 Pulled By: cpojer fbshipit-source-id: a4065f3e151d23f4813d76e91d68362cfd4daaf4 Use node package dependency to manage JSC version (#24276) Summary: In origin approach, we packed libjsc.so inside react-native.aar and it is difficult for user to choose different JSC variants. E.g., [the Intl supported version](https://github.com/react-native-community/jsc-android-buildscripts#international-variant). This change list allows application to determine JSC versions or variants by npm/yarn package. There is a |useIntlJsc| flag in build.gradle, it will use the same JSC version but with Intl support. `yarn add jsc-android@canary` [Android] [Changed] - Allow application to select different JSC variants **MIGRATION** Note that there are some changes in build.gradle. Existing application needs to change their android/build.gradle and android/app/build.gradle. Hopefully, the rn-diff-purge should handle the case well. Pull Request resolved: https://github.com/facebook/react-native/pull/24276 Differential Revision: D14752359 Pulled By: cpojer fbshipit-source-id: a4bfb135ad8e328f404a2d1a062412f40ebf4622 - VirtualizedSectionList/SectionList: replace enableVirtualization prop annotation by correct underlying disableVirtualisation of VirtualizedList (#24312) Summary: It seems (I used git history to confirm) that FlatList/VirtualizedList have ([since the begining](https://github.com/facebook/react-native/blame/c13f5d48cfe3e7c0f6c6d0b745b50a089d6993ef/Libraries/Lists/VirtualizedList.js#L79)) a `disableVirtualization` prop. SectionList ([since it's begining](https://github.com/facebook/react-native/blame/abe737fe746406533798f9670e8e243cb18d5634/Libraries/Lists/VirtualizedSectionList.js#L98)) have a `enableVirtualization` prop, but since SectionList is VirtualizedSectionList which use VirtualizedList, this prop probably never did something. This fix just rename the prop properly so it can have an effect on the underlying VirtualizedList when you use a SectionList. Since props are spread it's kind of working already, but the flow annotation are wrong (so it tells you it won't work/ you can't use it) which sucks. (NB: I am doing this since I was trying to use a SectionList with react-native-web & server side rendering to get the all list, you can laugh). [General] [Fixed] - VirtualizedSectionList/SectionList: replace enableVirtualization prop annotation by correct underlying disableVirtualisation of VirtualizedList Pull Request resolved: https://github.com/facebook/react-native/pull/24312 Differential Revision: D14779449 Pulled By: cpojer fbshipit-source-id: e51e1d639d2bb265b5b286786010d01ffd9d90e0 Remove Polyfills from RN Open Source Summary: We don't need these polyfills in RN Open Source any longer because JSC supports these features natively. We also don't need these internally at FB, but I want the removal to be a step by step process and separate from the open source work. Reviewed By: rickhanlonii Differential Revision: D14762827 fbshipit-source-id: 114626bd18516c42ced43c3f7aa29d42d1d95335 Move iOS WebView files to FB internal Summary: This moves the iOS WebView files to be fb internal which completes the removal of WebView from React Native open source as part of the Lean Core effort. Reviewed By: TheSavior Differential Revision: D14630076 fbshipit-source-id: 7bc11d6c1470bb748c823c86cbb8b5ee94b508ff Fix #23755 ("RCTImagePickerManager requires main queue setup" warning) (#24314) Summary: Fix #23755 - Which is to remove the warning: ``` Module RCTImagePickerManager requires main queue setup since it overrides `init` but doesn't implement `requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of. ``` General Fixed - Warning "RCTImagePickerManager requires main queue setup Pull Request resolved: https://github.com/facebook/react-native/pull/24314 Differential Revision: D14788772 Pulled By: cpojer fbshipit-source-id: e2017136008367d36468debb258afa698b5402bc Fix duplicate definition Flow error in HMRLoadingView Summary: Fix duplicate definition Flow error in HMRLoadingView, and match latest changes made to Facebook's internal .flowconfig Reviewed By: cpojer Differential Revision: D13110965 fbshipit-source-id: 8c22cab8232e1f539e77014b21e258de8b08d2b3 Back out "[react-native][PR] Android - Add a ReactFragment" Summary: Original commit changeset: b50b708cde45 Reviewed By: mdvacca Differential Revision: D14792438 fbshipit-source-id: c5e0b5f7663fe70110f73ae94a6fa99388f87ae3 Support experimental re-mmap wrappers Summary: Add experimental support for reordering the pages of a file that is mmap:ed by JSBigFileString. The wrapper is auto-detected (by checking file size and magic header) and transparently reorders the pages. Reviewed By: ridiculousfish Differential Revision: D14721397 fbshipit-source-id: 34e095350a9eeb9b07105bed6f3379f2fe472ae6 add flow check to windows ci (#21401) Summary: add flow check to windows ci Pull Request resolved: https://github.com/facebook/react-native/pull/21401 Differential Revision: D14807935 Pulled By: hramos fbshipit-source-id: 38354aa498fe7783966e8bf1895286c690eed90a Set scroll view throttle by default Summary: Setting the scroll throttle for every animated scrollview is a pain, and if you forget it's super janky and can be confusing and frustrating. Enables setting default props in createAnimatedComponent and uses it for scrollview. Reviewed By: TheSavior Differential Revision: D14790093 fbshipit-source-id: dd8f6f6540813245e87d696351f09ebb2e6ed5f2 Cleanup native anim example Summary: Makes things a little more clear. Reviewed By: TheSavior, yungsters Differential Revision: D14790256 fbshipit-source-id: 42e47487adfd48b8de5e987ac0e73a128a200824 Upgrade Jest to 24.7.1 Summary: Update Jest to 24.7.1, which has performance improvements I've built over the last few weeks. Reviewed By: rubennorte Differential Revision: D14766905 fbshipit-source-id: 9ebb3b6f2a9ed656ca0a41a27099fe1ea6e92710 Android plumbing for State and LocalData update mount items Summary: Android plumbing for State and LocalData update mount items. See other commits in stack for usage Reviewed By: mdvacca Differential Revision: D14663522 fbshipit-source-id: 5604a6a9af292805e9ce46c68e5ce7472eef0218 Fabric: Fixing const correctness in ShadowNodeFragment (and some prettification) Summary: Previously, all placeholders methods have return type `SomeType &` which is not correct because it allows the called to modify enclosed `static` value of the placeholders; the type should be `SomeType const &`. Besides that this diff migrates some type aliases to the new style (which makes evething much prettier and readable). Reviewed By: mdvacca Differential Revision: D14819076 fbshipit-source-id: 87e68d546f16d7a9ad1fb65e1b238859f9381eb7 fix typo (#24343) Summary: "Built from source" is past tense - if anything, it should be "Build from source". However, all other heading end with "ing" so it makes sense here too. Pull Request resolved: https://github.com/facebook/react-native/pull/24343 Differential Revision: D14822098 Pulled By: cpojer fbshipit-source-id: 3d07f2e6f8ed4a21e0311ef4f675f2d41553b619 change jest native method mocks to jest functions (#24337) Summary: Currently calling native methods on internal react native components throw a warning. I believe this is problematic because _users_ aren't calling native methods on internal components, the _component_ is making the call. So for instance, if I unmount a component that has a form with a few uses of `TextInput`, which is a perfectly valid test case, my test output will be full of warnings that I can't call `.blur()` in the test renderer environment. That's very misleading, because I didn't, the internal component did. In fact, as far as I can tell, there's not really even anything I can do to stop that call or use the output from it, its all internal. `TextInput` is a black box, and 99% of users writing tests probably won't even know it calls `.blur()` under the hood on unmount. I want to change these to `jest.fn()` because I think this eliminates a lot of chatter in test output, but also doesn't send users down a rabbit hole of trying to find workarounds that may involve filtering console output, which could potentially lead them to inadvertently filter out real warnings that they should see. So I'm willing to change the implementation of how I did this, but I don't think its right to warn users that they called a native method when they didn't. If they build a component that calls these methods, I believe it's on them to do something similar to this, and maybe we can make this exposed as a helper that can be used for third party component mocks? [General] [Changes] - Changed MockNativeMethods for core components to `jest.fn()` instead of function that warns about calling native methods. Pull Request resolved: https://github.com/facebook/react-native/pull/24337 Differential Revision: D14822126 Pulled By: cpojer fbshipit-source-id: 2199b8c8da8e289d38823bdcd2c43c82f3f635c9 useAndroidX and enableJetifier config in template gradle.properties (#24319) Summary: enable useAndroidX and enableJetifier that transforms non-Androidx third-party libraries to use AndroidX. [Android] [Changed] - useAndroidX and enableJetifier config in template gradle.properties Pull Request resolved: https://github.com/facebook/react-native/pull/24319 Differential Revision: D14822125 Pulled By: cpojer fbshipit-source-id: 596a92f26fb06b077da507583b72af2b5abf712a Fix bugs around `align-content` Summary: @public Regenerating the “golden master” tests with chrome surfaced different bugs around `align-content`: - a misunderstanding that values in `align-content` only applied *if there is only one line.* In fact, it applies *every time* a container is set to `flex-wrap: wrap`. Chrome had this wrong, and as such our tests were generated with incorrect parameters. - empty children growing to the cross axis size of the container, even when `align-content` is different from `stretch`. This was implemented incorrectly in Chrome as well. Here, we fix it with an extra check. Reviewed By: SidharthGuglani Differential Revision: D14725402 fbshipit-source-id: a45bebdadb9c694dc0eb7e27cb52b3d247f81c50 Support callbacks in synchronous native functions Summary: We need to move animated native module calls to synchronous so we can properly thread them in with mounting instructions in Fabric. Some of them take callbacks so we need to add support for that when switching to synchronous. A side benefit is that we can unify codepaths a little more with async callbacks. Reviewed By: shergin Differential Revision: D14790898 fbshipit-source-id: dc222b9e74375e046e8a9b1b19d72f652dc6722c Add some native module method test cases Summary: Just a little more rigorous Reviewed By: shergin Differential Revision: D14790912 fbshipit-source-id: 0a4c9b6ea68466efb060c9c90572ff8987fdbd26 More iOS animation fixes Summary: Main change is to the property diffing - we now use the last known props set on the view rather than the default props to compute the diff. This requires exposing a `getProps` method on all view components which should be fine I think. I also realized that in more complex animations with multiple nodes, the node that the animation starts on might not be connected to a view, so we don't know if it's fabric just based on that, so we have to do a recursive search through the children to find if there are any that are associated with a fabric view to decide we should start the animation immediately. Unfortunately there can still be a timing gap here since the animated API is async and the uimanager API is sync - I'll need to change the animated API to be sync to completely fix this. Reviewed By: shergin Differential Revision: D14732028 fbshipit-source-id: 882c056b0b63aa576f8e42439be405cf7fb3147a ignore dropView method when view is null (#24347) Summary: In #20288, we solved `com.facebook.react.uimanager.NativeViewHierarchyManager.dropView (NativeViewHierarchyManager.java:536)` by adding codes that prevent to run method on `view` object when `view.getId()` is null. But if `view` is null, `view.getId()` can make error about NullPointerException. So, I think `dropView` method needs to check if `view` is null. If you need more information, Please read #24346. [Android] [Fixed] - Ignore dropView method when view is null. Pull Request resolved: https://github.com/facebook/react-native/pull/24347 Differential Revision: D14833822 Pulled By: cpojer fbshipit-source-id: 88b6a05090ea8e8d6737c1f10b40e93649fab151 Remove wrapper around ListEmptyComponent (#24339) Summary: This pull request fixes #24257. The wrapper around ListEmptyComponent doesn't allow to use flex on the ListEmptyComponent. The wrapper was removed in this [commit](https://github.com/facebook/react-native/commit/db061ea8c7b78d7e9df4a450c9e7a24d9b2382b4), and then put back in this [commit](https://github.com/facebook/react-native/commit/e94d3444dcface90bd20234d13143462690ff23c) but I think the relevant part was removing the condition on `itemCount !== 0` to apply the inversionStyle on the ScrollView and everything is still working without the wrapper. [GENERAL] [FIXED] - Remove wrapper around ListEmptyComponent Pull Request resolved: https://github.com/facebook/react-native/pull/24339 Differential Revision: D14822221 Pulled By: cpojer fbshipit-source-id: 623e1ab3f228e9b75b92cdcd568683232a403c1a Make FlatList's renderItem return React.Node Summary: Flow typing can be annoying because the `renderItem` prop for FlatList always has to specifically be of type `React.Element`. Since really we just want to return something renderable, it should be fine to type this as `React.Node` instead. I'm not sure if this is valid, but it seems like since we just need to implant the `key` property, we should be able to accomplish this with a `React.Fragment` wrapper instead of needing to call `cloneElement`. Looking for feedback on if this is a sensible fix. Changelog: [General][Changed] Updated FlatList's renderItem Flow type from React.Element<any> to React.Node Reviewed By: sahrens Differential Revision: D14814805 fbshipit-source-id: ce6793dea5a92619babe048dcfddee0e4519979c Set up .flowconfig to support Haste and path-based imports (#24318) Summary: See https://github.com/facebook/react-native/issues/24316 for the motivation. By adding the .android.js and .ios.js extensions to the respective .flowconfig files, Flow is able to find files that either: - Are required using Haste - Are required using standard paths and have a .js extension - Are required using standard paths and have a .platform.js subextension [General] [Changed] - Adjusted .flowconfig to support both Haste and standard path-based requires Pull Request resolved: https://github.com/facebook/react-native/pull/24318 Differential Revision: D14822356 Pulled By: cpojer fbshipit-source-id: dde0c83692d6170f4a44cd3fb8ede162054157e9 Export JNativeRunnable from react/jni Summary: Adding JNativeRunnable to exported headers in react/jni/BUCK so I can use it outside of CatalystInstance. Reviewed By: axe-fb Differential Revision: D14817655 fbshipit-source-id: 15aa794e50f273778da337956c887c235a5aec3d Fix Docker Android tests container issue related to the JSC (#24360) Summary: [Fixes an issue where the Docker Android tests container cannot be built.](https://github.com/facebook/react-native/pull/24276#issuecomment-480915232) The JSC is now pulled from the npm registry, so we need to run `yarn` prior to pulling the Gradle dependencies. [Android] [Fixed] - Fixed React Native Android tests Docker container issue related to the JSC Pull Request resolved: https://github.com/facebook/react-native/pull/24360 Differential Revision: D14842534 Pulled By: hramos fbshipit-source-id: 3a1a714879e9c52a812b1077dce449470c30bddd Fix tests with JavaOnlyMap Summary: Need to force the double thing in more places. Reviewed By: cpojer Differential Revision: D14835792 fbshipit-source-id: fb7a5435675b322d5fbbe9858e08804e9abe65db
* chore: use @react-native-community/eslint-config (#205) Summary: --------- I changed @callstack/eslint-config to @react-native-community/eslint-config and fixed all lint issues. Test Plan: ---------- Green CI * fix: change diff links for upgrade command (#206) * fix: change diff links for upgrade command * use prettier without @format pragma * fix: correct paths for eject command (#208) Summary: --------- `eject` had wrong paths (pointing to old RN directories), so this PR fixes that. Fixes #207 Test Plan: ---------- 1. Init new project RN 0.59+ 2. Remove `android` and/or `ios` 3. Use the `eject` command to generate ios/android projects * chore: simplify commander/minimist usage (#209) * chore: simplify commander/minimist usage * feedback * remove extra parse * add options back * rephrase comment * remove excess whitespace * chore: remove unnecessary noHelp option for a command (#215) `noHelp` doesn't work because we override `printHelpInformation` and we need to handle `description` (that can be undefined) manually * chore: remove unnecessary checks for react peer dep (#216) * docs: fix cli path in contributing doc (#218) Summary: --------- Fix incorrect path to cli index.js in Contributing documentation. * fix: path to InitializeCore module in default metro config (#220) Summary: --------- Fix path to React Native `InitializeCore` module in default metro config. For some reason, this path was modified when moving the `loadMetroConfig.js` file in new `tools` directory. In current released version (v1.3.2) of the cli, the path is the correct one, as seen in the [loadMetroConfig.js](https://github.com/react-native-community/react-native-cli/blob/%40react-native-community/cli%401.3.2/packages/cli/src/util/loadMetroConfig.js#L52) of v1.3.2. Test Plan: ---------- Was trying out `react-native run-ios` / `run-android` commands, after a fresh `react-native init` with current master branch of the cli, and was facing following metro bundler error: ``` error: bundling failed: Error: Cannot find module '/Users/blemair/Code/foo/node_modules/react-native/Libraries/tools/InitializeCore' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15) at Function.resolve (internal/modules/cjs/helpers.js:30:19) at Object.getModulesRunBeforeMainModule (/Users/blemair/Code/foo/node_modules/@react-native-community/cli/build/tools/loadMetroConfig.js:80:53) [...] ``` After fixing the path, bundling error was gone. * chore: remove some unused files (#217) * fix: android unlink regression (#221) * Fix Android unlink regression * Update regex to accept extra whitespaces * Extract dependency regex string to own function With this approach we have one source of truth for both the regex and the dependency types. * Rename dependency types to dependency configs The Gradle documentation calls "configurations" what we have been referring to as "types". * docs: fix verdaccio command in contributing doc (#219) * fix: re-export findPlugins under cli/core for backcompat with RN 0.59 (#224) * v1.4.0 * fix: set proper peer dependencies (#227) * fix: debugger-ui incorrect path (#226) Summary: --------- Missed this one while moving files around in https://github.com/react-native-community/react-native-cli/pull/201. Fixes https://github.com/react-native-community/react-native-cli/issues/225 Test Plan: ---------- Verified locally on a clean project. * v1.4.1 * fix: refine upgrade error handling; improve the output (#232) * fix: refine upgrade error handling * moar refinements to the output * fix: linking assets on Android (#231) * v1.4.2 * fix: correct export of findPlugins * Publish - @react-native-community/cli@1.4.3 * Revert "fix: correct export of findPlugins" This reverts commit df17527c6819d3f707fa9ebf3bbfd4df1f0e1998. * chore: export findPlugins for ReactNative * Publish - @react-native-community/cli@1.4.4 * fix: reactNativePath and projectRoot not being parsed by commander (#234) * fix: reactNativePath and projectRoot not being parsed by commander * add minimist * v1.4.5 * build: remove dependepcies command * chore: bump metro to 0.53 * chore: remove legacy core/findPlugins (#235) Summary: --------- Now that we prepare 2.0 release, we can remove it. Also added `build-clean` to `postinstall` hook to avoid publishing extras when not using lerna. Test Plan: ---------- @grabbou * v2.0.0 * Bring back lost customDebugger function (#237) * fix: throw an error if an invalid platform is passed to the bundle (#240) Summary: --------- This pull request adds a new error message to the `react-native bundle` command that will throw an error if an invalid platform is passed to the `--platform` command, instead of failing with cryptic Haste errors. The error message looks like this: ``` > react-native bundle --entry-file index.js --platform foo --bundle-output test.jsbundle Invalid platform (foo) selected. Available platforms are: ios, android, native If you are trying to bundle for an out-of-tree platform, it may not be installed. error Invalid platform selected. ``` Test Plan: ---------- If you provide a platform that is not installed to `react-native bundle`, it will throw this error. If you provide a valid platform, it will continue bundling without issue. * Add verbose logging flag, debug logging for (un)link commands (#239) Summary: --------- This PR addresses #96 and: * Adds the `--verbose` flag to enable `DEBUG` logs * Adds `setVerbose(boolean)` to `tools/logger.js` so that it can enable/disable `DEBUG` logs * Adds debug logs for the (un)link commands * Adds Flow typings to `commands/link/android/unlinkAssets.js` I haven't added `DEBUG` logs to other parts of the CLI because: * I'm not that familiar with the other CLI commands * I'd like some feedback on what I've done so far before going on Also, would it be better to add debug logs in chunks, say one PR per command? I suspect this PR would become too big otherwise. Test Plan: ---------- These additions do not change any implementations but I ran the tests anyway, all green. I also ran it against two existing projects and a freshly created one: no changes in behavior. Screenshots: ---------- How the new flag is presented when using `--help`: <img width="500" alt="Screenshot 2019-03-15 at 22 07 26" src="https://user-images.githubusercontent.com/1713151/54462920-a2d11a00-4771-11e9-812a-00972da67f1a.png"> How `link packageName --verbose` looks like: <img width="816" alt="Screenshot 2019-03-15 at 22 09 08" src="https://user-images.githubusercontent.com/1713151/54463021-f2afe100-4771-11e9-9213-d1f783c1f0d5.png"> How `link packageName --verbose` looks like (module with assets): <img width="789" alt="Screenshot 2019-03-15 at 22 33 28" src="https://user-images.githubusercontent.com/1713151/54463179-7b2e8180-4772-11e9-9547-1e8907d6151d.png"> How `unlink packageName --verbose` looks like: <img width="803" alt="Screenshot 2019-03-15 at 22 09 34" src="https://user-images.githubusercontent.com/1713151/54463217-a022f480-4772-11e9-8130-9824bb0bb0f9.png"> <img width="805" alt="Screenshot 2019-03-15 at 22 13 58" src="https://user-images.githubusercontent.com/1713151/54463227-a618d580-4772-11e9-9420-315e35d3d55c.png"> * Refactor: Rework PackageManager implementation (#243) Summary: --------- Removed nasty `class`, and replaced it with grouped methods. `projectDir` is always the same in `cli` lifecycle, so we set it once on the start. Based on the presence of `yarn.lock` we decide either to use yarn or not to use it. `preferYarn` is overriding this behavior, and can later be used in `init` command which lacks correct `projectDir`. Test Plan: ---------- - [x] - Unit tests passing - [x] - Manual testing * refactor: don't add purge as remote when upgrading (#245) * feat: Add hint for browser extensions that may break debug (#253) * Add hint for browser extensions that may break debug * Update getSecurityHeadersMiddleware.js * Fix lint error * feat: Add `eslint` to react native project template. (#229) * chore: add eslint to RN template * Change .eslintrc to .eslintrc.js * fix: pass `--projectRoot` argument to Metro (#259) * fix: set project directory to install packages in init command (#262) Fixes https://github.com/react-native-community/react-native-cli/issues/260 and https://github.com/facebook/react-native/issues/24103 by setting project directory on PackageManager which is needed to check for yarn.lock file. Summary: --------- I'm not sure how to test this but creating new projects fail with the exception ``` info Adding required dependencies internal/validators.js:125 throw new ERR_INVALID_ARG_TYPE(name, 'string', value); ^ TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined at validateString (internal/validators.js:125:11) at Object.join (path.js:1147:7) at isProjectUsingYarn (/path/to/app/node_modules/@react-native-community/cli/build/tools/yarn.js:101:51) at shouldUseYarn (/path/to/app/node_modules/@react-native-community/cli/build/tools/PackageManager.js:36:39) at Object.install (/path/to/app/node_modules/@react-native-community/cli/build/tools/PackageManager.js:44:10) at generateProject (/path/to/app/node_modules/@react-native-community/cli/build/commands/init/init.js:111:18) at Object.init (/path/to/app/node_modules/@react-native-community/cli/build/commands/init/init.js:94:3) at run (/Users/xxx/.config/yarn/global/node_modules/react-native-cli/index.js:302:7) at createProject (/Users/xxx/.config/yarn/global/node_modules/react-native-cli/index.js:249:3) at init (/Users/xxx/.config/yarn/global/node_modules/react-native-cli/index.js:200:5) ``` The error seems to be stemming from passing `undefined` for `projectDir` to `path.join`. Added a line to fix this. Test Plan: ---------- `react-native init TestProject` should not fail. * chore: setup e2e tests (#264) * chore: setup e2e tests * add flowfixmes * use test.each * add docs to install/uninstall * remove dead code * [General] [Fixed] - Fixes Xcode 10.2 simulator not found issue (#274) * feat: upgrade envinfo for better output of info command (#265) * feat: upgrade envinfo for better output * remove --packages options * chore: update deps to avoid security warnings (#270) Summary: --------- Upgrading deps. Test Plan: ---------- Green CI * Refactor: Remove eject (#275) Summary: --------- Since `create-react-native-app` is deprecated this functionality is no longer needed. * Standardise configuration mechanism (#254) 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 `cosmiconfig` to 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 `findPlugins` multiple 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 config` to output the configuration. * fix: set correct peer dep of RN 0.60 for CLI@2.x (#280) * fix: sort modules in debugger delta patcher to match source map order (#279) Summary: --------- Context: https://github.com/facebook/metro/issues/380, https://github.com/facebook/react-native/issues/23955 Fixes a discrepancy between the order of modules in the source map and in the actual bundle, caused by a change in Metro (see details in https://github.com/facebook/metro/issues/380#issuecomment-478633831). Consequently fixes React Native remote JS debugging. Test Plan: ---------- 1. Made the same change in my checkout of the repro code from https://github.com/facebook/metro/issues/380 and verified debugging works. 2. Added unit tests. * fix: flaky tests; upgrade Jest to 24.6 (#282) Summary: --------- While working on #241 we discovered some flaky tests. This diff aims to fix those. It also updates Jest to 24.6 which comes with pretty nice perf improvements. Test Plan: ---------- Green CI * feat: new `init` command, leave legacy (#241) Summary: --------- New `init` command will exist in `@react-native-community/cli` and will deprecate current initialization flow. ### What has been done: - [x] - Added `init` command to `cli` (the previous implementation was partially existing in `global cli`) - [x] - Created a more friendly interface to create custom templates for initialization - [x] - Redesigned template to match custom template interface (https://github.com/Esemesek/react-native-new-template) - [x] - Added support to pass local repositories to `--version` and `--template` options through `file:` ### New template Structure: ``` . ├── package.json ├── template │ ├── App.js │ ├── __tests__ │ ├── android │ ├── babel.config.js │ ├── index.js │ ├── ios │ ├── metro.config.js │ ├── package.json │ └── yarn.lock └── template.config.js ``` * Root level `package.json` defines package * `template.config.js` is a configuration file. Not a lot of properties we can configure for now, but can be extended in the future. (https://github.com/Esemesek/react-native-new-template/blob/master/template.config.js - supported properties) * Directory with `template` which will be copied and processed during initialization process. In this structure it is called `template`, but it can be configured. ### Initalization You can try out this PR, by cloning repository, checkouting to `Esemesek/init` branch, building `cli` and then running command: ```sh node react-native-cli/packages/cli/buld init {projectName} --template react-native-new-template ``` To test intialization process without using custom template, `react-native` package you are using should contain update template. You can either create new version of `react-native` and publish it to local npm repository or use `--version file:{/absolute/path/to/update/react-native}` ### Example usage Init with custom version: ``` npx react-native init ProjectName --version 0.60.0 ``` Init with custom local version: ``` npx react-native init ProjectName --version file:///Users/username/local/version/of/react-native ``` Init with custom template: ``` npx react-native init ProjectName --template custom-template ``` Inite with custom local template: ``` npx react-native init ProjectName --template file:///Users/username/local/custom/template ``` > Note that `--template` needs to be valid absolute URL to react native or custom template Initialization could also be done by first installing `react-native` and then running init. ```sh mkdir SomeDir && cd SomeDir yarn add react-native react-native init ProjectName ``` Hopefully we will be able to support yarn flows in the future: https://github.com/yarnpkg/rfcs/pull/113 ### TODO: - [x] - Add better logging - [x] - Add more unit tests - [x] - Update template in `react-native` repository (https://github.com/facebook/react-native/pull/24138) - [ ] - Update documentation Test Plan: ---------- - [x] - Tested manually - [x] - Unit tests - [x] - E2E tests - probably most important one * feat: point to --verbose when command fails (#283) * v2.0.0-alpha.1 * fix: properly copy template binary files (#285) Summary: --------- `fs.copySync` does not properly copy binary files. I am using the copy method that we already have in the repo. Test Plan: ---------- Without this change `react-native run-android` breaks with the following error: <img width="962" alt="Screen Shot 2019-04-02 at 16 58 14" src="https://user-images.githubusercontent.com/13352/55443764-b8638380-5568-11e9-94ba-0d33322d24da.png"> * chore: make legacyInit test less flaky (#286) Summary: --------- Get rid of moving parts in legacy init test Test Plan: ---------- Test runs fine * feat: make legacy `link` use new configuration (#281) Summary: --------- This PR switches `link` to rely on the new configuration (from "ctx") that is also used by "react-native config" and soon, "auto linking". Test Plan: ---------- You should be able to run link w/o any issues * chore: add better error handling for failing e2e tests (#289) * feat: add React logo and spinners to make `init` UI nicer (#292) * Implement spinners for initializing flow * Use execa module * Change banner * Ignore silent flag when in verbose mode * Refactor packageManager test * Change loader exports * Fix e2e test * Rename packageManager * Add e2e test * smaller paddings for React logo * Cleanup tests * fix flowfixme * add space for post install script * rename packageManager.test as well * feat: extract iOS and Android specific linking files out of the core (#290) Summary: --------- Historically, Android and iOS platform were hardcoded inside CLI and provided by default. Then, other packages could export additional platforms on top of it. React Native as a platform was hardcoded in Metro configuration (default platforms, default extensions) and inside link. That means all new features were always developed with these platforms in mind, leaving others behind. We often used private APIs, which made things more complicated for 3rd party platform developers. From this PR on, there's no longer concept of an out-of-tree platform inside of the CLI. In a follow up PR to React Native, I am going to configure iOS and Android platforms inside React Native, just like React Native Windows exposes Windows platform. This will open room for improvements and should make it even easier for the CLI to welcome other platforms. * remove clean on postinstall * v2.0.0-alpha.4 * feat: apply upgrade patch in subdirectory if necessary (#272) * bug: apply update patch in subdirectory if necessary * add tests instead of changing existing ones * fix: copy `.keystore` files as binary extensions. (#300) * v2.0.0-alpha.5 * feat: use `logkitty` to format android logs (#294) feat: use `logkitty` to format android logs * feat: commands should be defined as object, unless defined via legacy config (#295) Summary: --------- This PR moves the logic for loading commands from CLI to the dependency authors. They should define a JavaScript configuration and return an array of commands (an object with required properties) they want to load. Previously, we would require them to define paths (relative to root) to a JavaScript file to require. This is necessary to send a follow-up PR, which removes built-in platform commands to be bundled with React Native. WIP: Need to check tests and update one or two snapshots to make sure we output Objects, instead of strings in a configuration. * fix: resolve relative paths for reactNativePath (#297) * Fix for relative paths * Update snapshots * chore: bump Jest and Flow to latest (#304) * feat: infer package and project name for upgrade from config (#299) * feat: infer packageName and projectName for upgrade from config * extract merge to tools and use it in tests * warn if unsupported platform is being upgraded * feat: extract commands out to platform packages (#302) * wip * Finish it up * Clean up packages * Move files around * Simplify regex * Remove unused type * Move packages around * Fix type * Update snapshot * Make snapshot even smaller * Throw unlink error * fix: pass maxWorkers arg to server (#305) Summary: --------- I've noticed that the `max-workers` CLI flag is not behaving as expected for the bundle command. We need it in one of our CI builds where the container is a bit memory-starved and the default of `numberOfWorkers = numberOfCores` isn't always accurate in a virtualized environment. This fix ensures the flag makes it to the server config and that the number of node processes reflect the number provided + 1. Test Plan: ---------- I made a reproduction repo: https://github.com/sterlingwes/rn-cli-repro The values in the "expected output" reflect the fact: * i already have a node process running for an unrelated task * the number of node processes should be `maxWorkersValue + 1`, since there's a parent node process that spawns the child workers So in the success case, `maxWorkers: 2` would lead to 3 node processes for the RN cli * chore: don't apply RN config automatically (#306) Summary: --------- Thanks to this change, CLI will not add default React Native configuration when one is present. I can now go to React Native, add the configuration and release it and CLI will pick that one. The below temporary workaround allows us to run on 0.59, where config is not yet present. * v2.0.0-alpha.6 * feat: skip packages that have invalid config instead of throwing an error (#309) * Do not throw on invalid packages * Fix type error * Update test * add dot * Update snapshots * feat: skip successful Metro server requests if --verbose not set (#291) Summary: --------- Metro server can become too verbose if there are a lot of assets due to morgan verbosely logging every request. Trying to make use of `verbose` flag to allow users skipping successful requests if 'verbose' is set to false (default) <!-- Thank you for sending the PR! We appreciate you spending the time to work on these changes. Help us understand your motivation by explaining why you decided to make this change: --> Test Plan: ---------- 1. run `react-native start` Expected Result: no console output on a successful request 2. run `react-native start --verbose` Expected Result: console output for every request <!-- Write your test plan here (**REQUIRED**). If you changed any code, please provide us with clear instructions on how you verified your changes work. Bonus points for screenshots and videos! Increase test coverage whenever possible. --> * chore: fix typo in link debug message (#311) Typo * chore: use files instead of npmignore for publishing (#314) * fix: add new line to the help message (#319) Summary: --------- There is a problem with the line break of command help as below. <img width="561" src="https://user-images.githubusercontent.com/3139234/56199103-3484bd80-6077-11e9-9c00-9aa4f45bc185.png"> Test Plan: ---------- Not required. * chore: add documentation on link, unlink, start, upgrade (#316) * chore: move shared types to root; moar link styles; bye promiseWaterfall (#312) * chore: move shared types to root; moar link styles; bye promiseWaterfall * fix test * add alias for global types * bump Flow to 0.97 * add lint annotation to bin * enable babel module resolver plugin * import inquirer prompt type * Add support for assetPlugins argument to start command (#318) * Add support for assetPlugins argument to start command * Add assetPlugins arg type * feat: autolink on iOS * chore: fix CI * fix: give a better error message when CocoaPods linking fails (#321) * initial commit * Remove log * fix: failing cocoa-pods tests * Improve accessibility * fix: prevent run-android failure when updating APK (#323) Summary: --------- If we run `react-native run-android` while it's already installed, it will fail with the following error. ```bash info Installing the app on the device (cd android && adb -s emulator-5554 install app/build/outputs/apk/debug/app-x86-debug.apk adb: failed to install app/build/outputs/apk/debug/app-x86-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install me.mycake without first uninstalling.] ``` In the development phase, I think using adb's install options below is much more efficient. ``` -r : Reinstall an existing app, keeping its data. -d : Allow version code downgrade. ``` Test Plan: ---------- Not required. * fix: open Metro in the correct terminal (#310) * Put `isPackagerRunning` function on `cli-tools` to share between iOS & Android * Fix `terminal` argument not working when not being provided * Fallback to the default terminal of the machine when starting the packager on `run-android` * Delete `isPackagerRunning` as it was moved to `tools` * Add `terminal` argument to `run-ios` * Launch Metro from within the `runIOS` command * Remove code & add `—terminal` argument * Try using `REACT_TERMINAL` before the default terminal * Put `isPackagerRunning` function on `cli-tools` to share between iOS & Android * Fix `terminal` argument not working when not being provided * Fallback to the default terminal of the machine when starting the packager on `run-android` * Delete `isPackagerRunning` as it was moved to `tools` * Add `terminal` argument to `run-ios` * Launch Metro from within the `runIOS` command * Remove code & add `—terminal` argument * Try using `REACT_TERMINAL` before the default terminal * Add tool function to get the default user terminal * Fix `terminal` arg type * Remove spread and specify entry twice instead * Improve `args` being passed through functions * Reduce code duplication * Put `device` and `udid` variable up in the scope * v2.0.0-alpha.7 * fix: prevent unnecessary actions if android build failed (#325) * feat: refactor `run-ios` for readability and better error messages (#328) Summary: --------- Refactor `run-ios` for readability and better error messages: <img width="737" alt="Screenshot 2019-04-17 at 22 04 38" src="https://user-images.githubusercontent.com/5106466/56317371-e0540900-615c-11e9-82e2-e8ef4e706721.png"> <img width="535" alt="Screenshot 2019-04-17 at 22 05 04" src="https://user-images.githubusercontent.com/5106466/56317372-e0540900-615c-11e9-9c82-774889ee2b05.png"> <img width="621" alt="Screenshot 2019-04-17 at 22 08 00" src="https://user-images.githubusercontent.com/5106466/56317551-4e003500-615d-11e9-92dc-c06f0e092e90.png"> Followup to #310 cc @lucasbento Test Plan: ---------- Verified that following commands work properly: - `run-ios` - `run-ios --device` - `run-ios --device phone-name` - `run-ios --uuid asd123` * fix: publish native_modules.rb file (#331) * v2.0.0-alpha.8 * Support functions in default (#333) * v2.0.0-alpha.9 * fix: allow empty strings to be used as defaults * v2.0.0-alpha.10 * feat: support platforms that ship with project (#335) * Project can also have platforms * strip unknown * Remove stripUnknown and prefer allowUnknown on one level only * fix: update haste config with platforms too * v2.0.0-alpha.11 * handle haste (#336) * v2.0.0-alpha.12 * chore: top-level unknown keys are now allowed, update test case * fix: modify wrong install arguments (#337) * feat: check `ios-deploy` installation before proceeding to build on device (#332) Summary: --------- This PR fixes #330, it checks if `ios-deploy` is installed or not before it actually starts building. Test Plan: ---------- - Run `npm uninstall -g ios-deploy`; - Run the CLI with `--device` argument and wait for it to fail; - Run `npm i -g ios-deploy`; - Run the CLI again and see it working. cc @thymikee --- ### Error about `ios-deploy` not installed ![image](https://user-images.githubusercontent.com/6207220/56423345-e7d5f800-62ab-11e9-9acf-e5336685904a.png) ### Random error when executing `ios-deploy` ![image](https://user-images.githubusercontent.com/6207220/56423377-12c04c00-62ac-11e9-863a-82c12800893a.png) * feat: support init inside monorepos (#320) * feat: autolinking for Android with Gradle (#258) Provides the Android/Gradle functionality to go with https://github.com/react-native-community/react-native-cli/pull/256 & https://github.com/react-native-community/react-native-cli/pull/254 ## CLI Changes - Updated `react-native config` to include the android `sourceDir` for react native module packages ---- ## Usage These are the one-off changes required to enable this in the React Native init template (or for existing user projects). ### Modify `android/settings.gradle` Include the following line in your Android projects `settings.gradle` file: ```groovy apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) ``` ### Modify `android/app/build.gradle` Add the following line at the bottom of your Android projects `android/app/build.gradle` file: ```groovy apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) ``` ### Modify `MainApplication.java` Import the PackageList class; ```java import com.facebook.react.PackageList; ``` Replace the `protected List<ReactPackage> getPackages()` method with the following: ```java @Override protected List<ReactPackage> getPackages() { @SuppressWarnings("UnnecessaryLocalVariable") List<ReactPackage> packages = new PackageList(this).getPackages(); // additional non auto detected packages can still be added here: // packages.add(new SomeReactNativePackage()); return packages; } ``` ### Testing I've tested the following scenarios locally: - User has no React Native global CLI installed - Will warn but continue without issue - User has no React Native packages installed yet - Continues as normal with no warning - User has more than one React Native package installed - Correctly adds multiple packages without issue - User has a package installed that does not support autodetection (config == null) - Prints a warning but continues gracefully - User has custom/non-linked React Native packages - Can be sucessfully manually added via `packages.add(new SomeReactNativePackage());` as documented above in `MainApplication.java` To test this in a new `react-native init` project locally: - Clone the CLI project - Run `yarn` in the CLI project - Run `cd packages/cli && yarn && yarn link` in the CLI project - (a little hacky as it's a mono-repo) - Run `yarn link "@react-native-community/cli"` on your React Native project - Make the required changes as above to your React Native project ---- ### Codegen Output Example An example of the generated `PackageList.java` class: ```java package com.facebook.react; import android.app.Application; import android.content.Context; import android.content.res.Resources; import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; import java.util.Arrays; import java.util.List; import com.test.BuildConfig; // react-native-webview import com.reactnativecommunity.webview.RNCWebViewPackage; public class PackageList { private ReactNativeHost reactNativeHost; public PackageList(ReactNativeHost reactNativeHost) { this.reactNativeHost = reactNativeHost; } private ReactNativeHost getReactNativeHost() { return this.reactNativeHost; } private Resources getResources() { return this.getApplication().getResources(); } private Application getApplication() { return this.reactNativeHost.getApplication(); } private Context getApplicationContext() { return this.getApplication().getApplicationContext(); } public List<ReactPackage> getPackages() { return Arrays.<ReactPackage>asList( new MainReactPackage(), new RNCWebViewPackage() ); } } ``` * v2.0.0-alpha.13 * fix(autolinking): remove deprecated Gradle task syntax (#339) Summary: --------- Gradle 5 no longer supports the `<<` syntax - swapped to the non-shorthand syntax of `doLast {}` Test Plan: ---------- Builds successfully with the updated syntax and `PackageList.java` file generated ![image](https://user-images.githubusercontent.com/5347038/56444115-57b9a200-62ef-11e9-94bc-16818c33e65e.png) ![image](https://user-images.githubusercontent.com/5347038/56444122-5f794680-62ef-11e9-962a-5beb06e90667.png) * v2.0.0-alpha.14 * fix: [android] remove forward slashes from package name (#340) Summary: --------- The previous CLI config use to return names with `/`'s replaced with `_`'s - it no longer does this so I've moved the replacing logic into the auto-linking build script so as to avoid breaking on Gradle 5+: ![image](https://user-images.githubusercontent.com/5347038/56455870-2b883a80-635c-11e9-90ef-53f00282391f.png) Test Plan: ---------- After change build no longer fails: ![image](https://user-images.githubusercontent.com/5347038/56455888-8883f080-635c-11e9-9bda-905baf83d3bd.png) ![image](https://user-images.githubusercontent.com/5347038/56455892-98033980-635c-11e9-9cc6-8005e866bc2b.png) * fix: stop resolving "react-native" from package.json as a config (#341) * fix: stop resolving "react-native" as a valid package.json config property * add missing editTemplate file * docs: update and rearrange documentation (#338) * docs: update and rearrange documentation * add autolinking base docs * add init docs * chore: remove unsupported CocoaPods options from a documentation This is currently not supported. Let's have it as a "todo" for the future releases, ideally, upon request from someone. * docs: initial documentation of plugins (#345) * fix: typos in Autolinking & use same repo for both examples * structure new files * Add documentation for plugins and update naming in one place * Update index.js * Fix flow and update docs * Update * Prefix * Updates * Take advantage of Joi * Update docs/plugins.md Co-Authored-By: grabbou <grabbou@gmail.com> * Update docs/plugins.md Co-Authored-By: grabbou <grabbou@gmail.com> * Some other tweaks * Placeholder for dependency * Updates * Delete linking.md * fix tests * docs: add init documentation (#347) * docs: add init documentation * docs: add mentions in other files * docs: revert * Update docs/init.md Co-Authored-By: Esemesek <kacperwiszczuk@gmail.com> * feat: add `platforms` doc (#349) * Add platforms doc * Migration guide * Update docs/platforms.md Co-Authored-By: grabbou <grabbou@gmail.com> * feat: add dependency and project documentation (#350) * Add dependency documentation and links * Update * Update * Add project desc * Move notice above * add catch-all doc * Typo * Rename the type * Update docs/configuration.md Co-Authored-By: grabbou <grabbou@gmail.com> * Update docs/configuration.md Co-Authored-By: grabbou <grabbou@gmail.com> * Do where not when * Plural * v2.0.0-alpha.15 * fix: ignore undefined when renaming * chore: update wording in docs * chore: change `upgrade` to use new diff files approach (#348) * use diff files and dont rely on gh * lint * update snapshots * update link to diff table * feat: improve copying binary files in `init` (#353) * Update autolinking.md (#355) * [ios] Ensure that the right cwd is set up for auto-linking dependencies (#354) * [ios] Ensure that the right cwd is set up for auto-linking dependencies * [autolink] Switch to DIing in the root path as a param in to use_native_modules * [autolink] Docs for autolink root changes * v2.0.0-alpha.17 * feat(breaking): remove legacy `library` command (#358) feat(breaking): remove legacy `library` command * fix: init from url (#361) * feat: init from tarball (#362) * feat: init from tarball * adjust error message * skip flaky config test * update docs * update snapshots * feat: copy all files in `init` through streams (#363) * feat: copy all files in init through streams * fix asynchrony * only replace file if necessary * docs: add `maintainers` section (#369) * Add `maintainers` section * Update README.md * Polacy nie gęsi, swój język mają xd * fix: refactor init for less duplication; fix handling versioned templates (#364) * chore: refactor init for less duplication * fix handling versioned packages * polish error messages a bit * support npm tags * fix: reporter config option (#370) The `loadConfig` function in `metro-config` reads the `reporter` option from the second argument (`defaultConfigOverrides`) instead of the first argument (`argv`), so we need to pass it in that object to make the `customLogReporterPath` CLI option work. * chore: Update prettier config (#379) * Use `require.resolve` to resolve package path (#378) * Use `require.resolve` to resolve package path * resolveNodeModule -> resolveNodeModuleDir * feat: improve `run-android` error messages; rename "installDebug" -> "task" (#372) * chore: cleanup run-android implementation * feat: overhaul gradle install errors * fix copying executables by bringing back chmod * rename 'installDebug' -> 'task' * cleanup unused args from refactor * use inherit and don't show null error * simplify creating gradle args * adjust descriptions * use logger * Add support for multiple tasks * Change function name to match current functionality * Change task to tasks * v2.0.0-alpha.18 * feat: automatically run `pod install` when running `init` command (#373) * Specify `.xcworkspace` on run instructions instead of `.xcodeproj` * Add `command-exists` package * Remove unneeded space after log message * Run `pod install` and check for cocoa pods when running `init` command * Put pods installation directly on `init` file and verify if `Podfile` exists before running * Revert change to space * Remove unneeded `console.log` * `cd` back to the directory after pod installation * Throw with `CLIError` instead of `Error` * Remove unneeded `try…catch` * Fix wrong uppercased word * Try to install `cocoapods` without sudo before trying with it * Run pods installation only on macOS * Check which extension for the project to print out on the run instructions for iOS * Use `fs` instead of `fs-extra` * Move `installPods` to separate file * Add missing `logger` import * Fix warnings on duplicated variable declaration * fixups * Add openURLMiddleware (#383) * Add openURLMiddleware This allow’s react-native to open Chrome windows arbitrarily. * Upgrade open, add launchBrowser command. * v2.0.0-alpha.19 * fix: run "config" from react-native binary in autolinking scripts (#384) * fix: run "config" from react-native binary * use yarn run when necessary and fallback to accessing binary with Node * filter out non-json stuff in gradle implementation * use yarn --silent * Improve CocoaPods prompt question when running `init` (#389) * chore: upgrade joi to @hapi/joi to remove npm warnings (#388) * fix: config.reporter undefined bug (#376) * fix: config.reporter undefined bug * refactor * Update loadMetroConfig.js * feat: automatically install pods in legacy init (#386) * feat: Show message if CocoaPods installation takes long (#390) * Add message that shows only if `cocoapods` installation take more than 30 seconds * adjustments * chore: bump lerna to latest * v2.0.0-alpha.20 * chore: Update npm version badge link (#391) * feat: support `init` with custom project directory (#365) * Change `packageName` to `projectName` & add `projectPath` argument * Add a way to specify a custom project path to init the app on * Force the `init` command to create the project path recursively * Add test for providing the project path on init * Throw error if custom project path doesn’t exist and can’t be created * Fix type error on `customProjectPath` * Create directory before running the test with custom project path * Use `mkdirp` to create project folder & Use `inquirer` to prompt for a directory replace * Specify `directory` as an option * Handle custom directory path after react logo * Check if `ios` folder exists before trying to open it * Update `init` tests * Add `directory` type * Remove unused `inquirer` from `init` test * Only remove the project folder if it didn’t exist before running `init` * Remove correct directory if it didn’t exist before `init` * simplify * make directory an argument instead of a flag * update descriptions * fix test * use --directory after all * address feedback; remove version handling from createFromTemplate * flip the default * chore: migrate `tools` to TypeScript (#296) * Migrate tools package to Typescript * Prebuild ts * Improve yarn build-clean * Remove unnecessary statements * Fix linting * Fix eslint * Update packages/tools/src/isPackagerRunning.ts Co-Authored-By: Michał Pierzchała <thymikee@gmail.com> * adjust package.json * add vscode helper settings * remove dead node-fetch references * chore: improve RNPM warnings (#395) * Improve RNPM warnings * Update packages/cli/src/tools/config/readConfigFromDisk.js Co-Authored-By: Michał Pierzchała <thymikee@gmail.com> * Fix lint error * v2.0.0-alpha.21 * feat: allow `dependencyConfig` to override `podspec` name (#393) * [ios][docs] document podspec param * [ios] add podspec to dependencyConfig schema * [types] add podspec to config * [config] add podspec param override to config * feat: remove manifest from config output (#398) * feat: remove manifest from config output * fix typo in the docs * v2.0.0-alpha.22 * feat: log error stacktrace by default (#396) * [CI] Migrate to Circle 2.1, add Node LTS tests (#402) * fix: Ensure that bundle URL origin matches debugger page origin (#403) This structurally sets up the Chrome debugger not to have CORS issues if the bundle URL domain differs from the Chrome debugger page domain. This bug was initially fixed in https://github.com/facebook/react-native/pull/17720 and regressed in https://github.com/react-native-community/cli/pull/194. This commit fixes the original bug without changing the behavior introduced in #194. This commit makes the debugger page use its own URL origin when loading the bundle URL. This addresses the case where the native client may have a bundle URL with a domain like xip.io. Fundamentally, unless the development server allows cross-origin requests, the bundle URL's domain must match the domain used by the Chrome debugger page, which is what this commit achieves. * [android] Fixed a crash when adding non-autolinked custom `ReactPackages` (#407) * v2.0.0-alpha.23 * chore: add CODEOWNERS file (#404) * chore(docs): update CONTRIBUTING.md (#409) * fix: no active iOS device case in `logIOS` (#410) * fix: Add a simulator.isAvailable check for true value (#414) * Add a simulator.isAvailable check for true Installing the Xcode 11 beta changes the result of isAvailable to `true` and `false`. * Fix lint error * feat: Only pass `hasteImplModulePath` if the `hasteImpl` file is available in RN (#417) * chore: remove deprecated entries in DevTools middleware (#415) * feat(breaking): link only assets by default; add `--all` flag (#416) Change the default behavior of `link` to only link assets. Since autolinking, manual linking of packages is quickly becoming obsolete, however there's no easy way to autolink assets (can be automated with CocoaPods podspecs, but not sure about Gradle cc @Salakar. EDIT: should be doable, @Salakar is on it). That's why I think it makes sense to default `link` to process assets only, unless the `--all` flag is passed explicitly. Additional changes that accumulated while testing: - fix linking hooks failing to execute - fix handling assets from legacy "rnpm" config - overhaul linking logs and error messages - disable flaky e2e tests in lts-tests phase * feat: notify of new major RN version at most once a week (#268) Summary: --------- This PR addresses the first part of #189: notifying the user when a newer version of React Native is available to upgrade to when using the CLI. **Behaviour** * The remote release check mechanism uses the [GitHub API](https://developer.github.com/v3/repos/releases/#get-the-latest-release). * The mechanism is triggered for any CLI command. * Nothing will be displayed if the project is already up-to-date. * The release data returned from the API call is cached per-project. Caching is necessary to not hit the GitHub API rate limit. * For the time being, there is no way to "mute" this behaviour if a project is intentionally using an older RN version because we have not discussed yet how the UX for that will be. **Caveats** The GitHub API we are using is specific to [Releases](https://help.github.com/en/articles/creating-releases), so we need to make sure that each new version of React Native has one. For example, 0.59.1 has been cut and published on NPM on March 14th but the release has been made only on the 25th. During that interval, the CLI would have not notified users of the newer version. Test Plan: ---------- * Clone this branch * Install dependencies with `yarn install` * Test the behaviour in newer and older projects by calling `cli.js` directly from the cloned repository as described in `CONTRIBUTING.md`. Screenshots: --------- Linking a module in an older project: ![Screenshot from 2019-03-25 19-22-14](https://user-images.githubusercontent.com/1713151/54944577-1a523680-4f34-11e9-8d28-5c4b3e00b8f9.png) Output when a project is up-to-date (showing debug messages as normally there would be no output): ![Screenshot from 2019-03-25 19-35-42](https://user-images.githubusercontent.com/1713151/54945093-55a13500-4f35-11e9-879e-69780ae7a59c.png) * v2.0.0-rc.0 * chore: bump Metro to 0.54.1 (#420) * chore: bump Metro to 0.54.1 * fix hasteImpl path resolving * v2.0.0-rc.1 * feat: Pass along CLI port configuration for Android (#421) This commit operates in conjunction with a change to React Native Android to allow the overriding of the development server port. * fix: make sure the port passed to Metro is a number (#424) * v2.0.0-rc.2 * Log `console` invocations to the terminal. (#426) * fix: Add fallback path check when not found app file for iOS (#428) * chore: update init docs to be more descriptive (#427) * updated docs to match the current implementation * added note about the shebang * re-added the .js extension as it works with it as well * fix: allow upgrading with binary files in the diff (#432) * feat: allow upgrading with binary files in the diff * fix tests * chore: bump Flow to 0.101 (#431) * fix: Add import for `applicationId.R` class in generated `PackageList.java` (#435) * Add import for `applicationId.R` class * Remove redundant semicolon * chore: refactor packageManager.js for less redundancy (#433) * feat: filter out non-native deps from config output; fix missing hooks (#436) * fix: use `packageName` instead of `applicationId` in gradle script (#439) * Use `packageName` instead of `applicationId` * Use pre-parsed config for `packageName` * Remove param `packageName` Co-Authored-By: Michał Pierzchała <thymikee@gmail.com> * feat(breaking): use 'podspecPath' instead of 'podspec', make it smarter (#442) * docs: document how to disable autolinking for unsupported packag… (#444) * v2.0.0-rc.3 * fix: don't use yarn for spawning 'config' command (#449) * feat: add warnings for `run-ios` and `run-android` when manually… (#447) * wip * add warnings for run-ios and run-android * memoize in place * cleanup * chore: group deprecated rnpm warnings, add migration guide (#450) * chore: group deprecated rnpm warnings, add migration guide * Update packages/cli/src/tools/config/index.js Co-Authored-By: Satyajit Sahoo <satyajit.happy@gmail.com> * remove parens from links * chore: fix grammar in warning (#453) * chore: fix grammar in warning * adjust wording * fix: incorrect condition for upgrade newer version check (#455) * chore(docs): simplify autolinking (#454) * chore(docs): simplify autolinking * address feedback * feat: simplify passing root to gradle autolinking (#457) * feat: simplify passing root to gradle autolinking * improve docs * v2.0.0-rc.4 * feat: support local RN libraries in autolinking (#451) * feat: support local RN libraries in autolinking * simplify local deps config * address feedback * v2.0.0-rc.5 * feat: improve `upgrade` when patches fail to apply (#461) * v2.0.1 * fix: config on Windows & warnings breaking config JSON output on… (#464) * fix: warnings breaking config JSON output * fix legacy test * v2.0.2 * fix: Changed the URL to be valid for configuration.md (#466) * Changed the URL to be valid for configuration.md * Update packages/cli/src/tools/config/index.js Co-Authored-By: Kacper Wiszczuk <kacperwiszczuk@gmail.com> * fix: log-android not working. update logkitty. (#469) * fix: log-android not working. update logkitty. * fix registry * fix: run release checker only after `start` and `info` command (#479) * fix: run release checker only after `start` command * fix test * fix: autolinking bug on Windows when reading config (#480) * fix: duplicate entires in rnpm warning (#481) * feat: make run-ios output leaner (#472) * feat: make run-ios output leaner * --ammend * chore: use StringBuffer when getting config (#482) * v2.1.0 * chore: revamp README for readability, about and updating info (#490) * chore: add updating guide & improve about * update readme * fix typo * docs: add table of contents (#491) * fix: support an Application instance in PackageList for Android (#493) * fix: Metro Bundler crashing on `run-android` on Windows (#489) * fix: passing iOS simulator name with brackets in latest Xcode (#460) * Fixed cli --simulator not working with latest Xcode simulator name with brackets * Updated test case * Fixed findMatchingSimulator unit test * v2.1.1 * fix: `init` command with scoped templates without version (#497) * fix: don't set `projetRoot` for Metro (#496) * chore: fix typo in contribution guide (#501) * v2.1.2 * chore: add more information to autolinking guide (#505) * feat: use relative paths for Podfile.lock (#502) * fix: use_native_modules! warns and skips dependencies without a podspec (#507) * fix: correct project directory in run instructions after `init` (#504) * fix: fix project directory name in run instructions * fix: pass the right project directory to printRunInstructions * v2.2.0 * chore: remove unstable `init --template` shorthand support (#495) * feat: support `unlink --platforms` (#511) * v2.3.0 * docs: add docs for `unlink --platforms` * feat: add `xed -b ios` for opening Xcode to init instructions (#514) * fix: run `pod repo update` after installing CocoaPods (#513) * fix: run `pod repo update` after installing CocoaPods (#487) Added `pod repo update` command call after CocoaPods installation to avoid issues with pod command being unable to find specification for dependency. Added loader to CocoaPods installation step for consistency with other steps of init and better DX, removed logger info after 30s timeout because of redundancy with loader. Changed loader method before prompt for CocoaPods installation from `stop` to `info` for better prompt visibility. * always show installing pods step * add notice back * minor loader refactor * fix false positive for pod command being available * use pod --version for smaller output * v2.4.0 * fix: add chalk as dependency of cli-platform-android (#517) * v2.4.1 * fix: don't copy node_modules in templates (#519) * v2.4.2 * fix: cache lazy project getter for perf when accessed repeatedly (#520) * adjust build-clean and publish scirpts * v2.4.3
Summary: --------- New `init` command will exist in `@react-native-community/cli` and will deprecate current initialization flow. ### What has been done: - [x] - Added `init` command to `cli` (the previous implementation was partially existing in `global cli`) - [x] - Created a more friendly interface to create custom templates for initialization - [x] - Redesigned template to match custom template interface (https://github.com/Esemesek/react-native-new-template) - [x] - Added support to pass local repositories to `--version` and `--template` options through `file:` ### New template Structure: ``` . ├── package.json ├── template │ ├── App.js │ ├── __tests__ │ ├── android │ ├── babel.config.js │ ├── index.js │ ├── ios │ ├── metro.config.js │ ├── package.json │ └── yarn.lock └── template.config.js ``` * Root level `package.json` defines package * `template.config.js` is a configuration file. Not a lot of properties we can configure for now, but can be extended in the future. (https://github.com/Esemesek/react-native-new-template/blob/master/template.config.js - supported properties) * Directory with `template` which will be copied and processed during initialization process. In this structure it is called `template`, but it can be configured. ### Initalization You can try out this PR, by cloning repository, checkouting to `Esemesek/init` branch, building `cli` and then running command: ```sh node react-native-cli/packages/cli/buld init {projectName} --template react-native-new-template ``` To test intialization process without using custom template, `react-native` package you are using should contain update template. You can either create new version of `react-native` and publish it to local npm repository or use `--version file:{/absolute/path/to/update/react-native}` ### Example usage Init with custom version: ``` npx react-native init ProjectName --version 0.60.0 ``` Init with custom local version: ``` npx react-native init ProjectName --version file:///Users/username/local/version/of/react-native ``` Init with custom template: ``` npx react-native init ProjectName --template custom-template ``` Inite with custom local template: ``` npx react-native init ProjectName --template file:///Users/username/local/custom/template ``` > Note that `--template` needs to be valid absolute URL to react native or custom template Initialization could also be done by first installing `react-native` and then running init. ```sh mkdir SomeDir && cd SomeDir yarn add react-native react-native init ProjectName ``` Hopefully we will be able to support yarn flows in the future: yarnpkg/rfcs#113 ### TODO: - [x] - Add better logging - [x] - Add more unit tests - [x] - Update template in `react-native` repository (facebook/react-native#24138) - [ ] - Update documentation Test Plan: ---------- - [x] - Tested manually - [x] - Unit tests - [x] - E2E tests - probably most important one
Summary
Adjusting template to new init command (react-native-community/cli#241).
PR with new init command needs to be merged before we land this.
Changelog
[General] [Changed] - Adjust template to match new init command
Test Plan
A project is initializing successfully with the new init command.
cc @grabbou @thymikee