Commit Graph

14397 Commits

Author SHA1 Message Date
Rafael Oleza f661e0fb6e End metro server gracefully when there are some edge errors
Summary: This diff fixes a couple of edge cases that caused Metro to keep the process running when there were some specific errors (specially around the `dependencies` command and the transformer path).

Reviewed By: jrwats

Differential Revision: D9551834

fbshipit-source-id: 959cefcec9e2687dff89c94a871ae74c50d2dd77
2018-08-30 03:33:03 -07:00
Jonathan Kim f9e823fb5a Update loads for glob_defs.bzl
Reviewed By: mzlee

Differential Revision: D9565702

fbshipit-source-id: df38928394a90367492a25ed52ec552b89c1f903
2018-08-30 01:46:51 -07:00
Tim Yung 19a8a578dc RN: Improve ViewPropTypes
Summary:
Makes a couple improvements to `ViewPropTypes`.

- Remove deprecated transform props. We are now using exact object types, so they are already disallowed.
- Remove garbage types for `accessibilityLabel`.

Reviewed By: TheSavior

Differential Revision: D9542088

fbshipit-source-id: f9128353e19cff22caf52c896c9c137f01aea276
2018-08-29 17:49:24 -07:00
Kevin Gozali 6a1f48e06d TM iOS: rollout strategy 1 - added RCTEnableJSINativeModule(BOOL)
Summary:
To be able to test out new approach for NativeModules, introduce a simple runtime flag to enable the new system (doesn't exist yet). In addition, each module should declare a static `+ (BOOL)allowJSIBinding` in the objc class to be considered for the new approach. Doing so skips the processing of the module during bridge startup.

Note: this doesn't do anything special for `- (NSArray *)extraModulesForBridge:(RCTBridge *)bridge` impl yet.

Differential Revision: D9554296

fbshipit-source-id: 3508db6589e9f72367f62aa7ca15fce3d3adda72
2018-08-29 15:48:59 -07:00
David Vacca eb225fa173 Revert changes of the name for AndroidHorizontalScrollView
Summary: This diff reverts the changes in the name for AndroidHorizontalScrollView and AndroidHorizontalScrollContentView that caused a redbox for continuous OTA users

Reviewed By: fkgozali

Differential Revision: D9561972

fbshipit-source-id: 3d8e9ee8bb6081107bc8d315af16885bb003148e
2018-08-29 15:48:59 -07:00
Jonathan Kim 685b15679f @build-break fix usage of old RN DEFS.bzl path
Differential Revision: D9563036

fbshipit-source-id: ab87f479f45209b96ce82c3607c45fdfd622d099
2018-08-29 14:32:24 -07:00
Jonathan Kim 2515e4861a Move RN's DEFS.bzl to tools and rename to rn_defs.bzl
Reviewed By: mzlee

Differential Revision: D9553765

fbshipit-source-id: cb65081668ea2726f24d2c9c02661e859cc7a994
2018-08-29 13:21:52 -07:00
Andrew Chen (Eng) afe0843bee Move ReactNativeTestRule to OSS
Summary: And migrated ReactRootViewTestCase to use ReactNativeTestRule.

Reviewed By: mdvacca

Differential Revision: D9557362

fbshipit-source-id: 1469d0ad8c125b5ea729371d81956e61780c56cf
2018-08-29 12:54:13 -07:00
Rafael Oleza bf8e1b4ffa Upgrade to babel@7.0.0
Summary: Now that babel7 is stable, we can upgrade Metro and fbsource to use it, yay!!!!!

Reviewed By: mjesun

Differential Revision: D9518571

fbshipit-source-id: c85569cb3058235f4f9310949897f7955ecf7324
2018-08-29 11:02:52 -07:00
Andrew Chen (Eng) 251cbb3871 Eagerly initialize FrescoModule
Summary: It's unclear if this was a recent regression or not (too lazy to find out), but instrumentation tests are failing because FrescoModule is never initialized (see task for trace). Based on the initial introduction of this class (D2448321) it appears that FrescoModule was always intended to be initialized on startup. Let's eagerly init Fresco in that case.

Reviewed By: fkgozali

Differential Revision: D9556864

fbshipit-source-id: 0b670dec46f5087b3794330931ddf5d7782c8367
2018-08-29 10:03:26 -07:00
David Vacca 8b5e3fc16b Update size of Root ShadowNode when RootView changes its size
Summary: This diff updates the size of RootShadowNode and re-render RN views when the Size of the Android React View changes

Reviewed By: achen1

Differential Revision: D9173758

fbshipit-source-id: 7cc6bbfb646025c3ec1773ab041eb9207623af71
2018-08-28 23:03:34 -07:00
David Vacca 575f7d478d Implement HorizontalScrollView component
Summary: This diff implements the HorizontalScrollView component for Android Fabric C++, as part of this diff I also re-named the components AndroidHorizontalScrollContentView for RCTAndroidHorizontalScrollContentView and AndroidHorizontalScrollView for RCTAndroidHorizontalScrollView. This might sound against our plan of removing the RCT preffix, but it is to make it simpler to map components between current implementation of RN and Fabric (otherwise we don't know when to add the RCT preffix in Android side to find the right View Manager), later we can just remove the preffix from C++, Android, iOS and JS.

Reviewed By: shergin, achen1

Differential Revision: D9122729

fbshipit-source-id: e9299552857c6dd0c18abfa5fa49a3d50e221729
2018-08-28 23:03:33 -07:00
Ram N 01580de613 Move interfaces from Bridge to a new buck target
Reviewed By: achen1

Differential Revision: D9513130

fbshipit-source-id: f23e3274eed5f0adcffdc3e10d20a4d49e81bca5
2018-08-28 22:49:07 -07:00
Rafael Oleza f8f1870248 Make the --transformer CLI argument override the babelTransformerPath
Summary: D9070810 introduced a breaking change, making the `--transformer` CLI argument able to override the generic transformer instead of `babelTransformer`. Since we still have some scripts that assume `--transformer` is being used for overriding the babelTransformer path, we cannot do this breaking change yet, so this diff reverts the CLI handling to the old behaviour.

Reviewed By: jrwats

Differential Revision: D9550157

fbshipit-source-id: 8b4e26fcb5bca6e4b2f63b1e1a014bce23a31452
2018-08-28 19:01:57 -07:00
Eli White ee543ecf86 Bump Detox to 8.2.3
Summary: 8.2.2 was a broken version, bumping to 8.2.3.

Reviewed By: yungsters

Differential Revision: D9539442

fbshipit-source-id: 554cc34261d988464671d0c4e4a7a18b6d495b73
2018-08-28 12:59:37 -07:00
Peter Argany 58409be6b4 Eagerly create FBMarketplaceNativeModule [2/N]
Summary:
The full idea for eagerly creating Native Modules is articulated here https://fb.quip.com/vWcLAup3a6kR

TLDR:
1) Move lazy native module work from the mqt_js thread to the background thread which processes packages. This also moves it from post-network to pre-network.
2) For a quick test, decide which modules to eagerly create with a QE flag.
3) Eagerly create the modules by opting-out of the ReactModuleInfo pipeline which was built for lazy native modules.

Reviewed By: achen1

Differential Revision: D9503934

fbshipit-source-id: 0cd8337ad294cd0f8be692fecbf4292d204f3ec4
2018-08-28 11:02:52 -07:00
David Vacca e8c7cb1c04 Revert D9105838: [react-native][PR] Fix view indices with Android LayoutAnimation (attempt 2)
Differential Revision:
D9105838

Original commit changeset: 5ccb0957d1f4

fbshipit-source-id: f679eceac47c95d9138f1a91a77cc20a74e64e04
2018-08-27 20:19:15 -07:00
Rafael Oleza cfeb60c19b Bump metro@0.44.0
Summary: shipit-splash

Reviewed By: mjesun

Differential Revision: D9504325

fbshipit-source-id: 191f27ee33c1363f180b0c6c710f65096e139df1
2018-08-27 19:31:52 -07:00
Valentin Shergin 961b6aceca Fabric: Unified event pipeline: connecting the dots
Summary:
@public
This diff basically wires everything up.

Reviewed By: mdvacca

Differential Revision: D8886227

fbshipit-source-id: fb1a1e3222b3d693a8c28ed780b14f7315b7c019
2018-08-27 07:32:38 -07:00
Valentin Shergin b49c8add15 Fabric: Rethinking of EventEmitter's role
Summary:
@public
Now, one of the main purposes of `EventEmitter`s is to create RawEvent instances for all specific event invocations.

Reviewed By: mdvacca

Differential Revision: D8886226

fbshipit-source-id: 82a489174efcda097887e70650a2038dc986d149
2018-08-27 07:32:37 -07:00
Valentin Shergin 0dae893eec Fabric: Rethinking of `EventDispatcher`
Summary:
@public
Now, it's not just an abstract class, it's a regular class which unifies event delivery priorities using specific event beats and event pipe.

Reviewed By: mdvacca

Differential Revision: D8886232

fbshipit-source-id: c4360511e5fd477ca7407fc3ebbd99ca578e79cc
2018-08-27 07:32:37 -07:00
Valentin Shergin 5f8d5e0665 Fabric: Proper events priorities for touch events
Summary:
@public
The existing code does not use that at all but we need that for testing things and we will need this in the future.

Reviewed By: mdvacca

Differential Revision: D8886236

fbshipit-source-id: 5ca33e4f4d4ca13a6be0f55cc04b59d5f9b27fa9
2018-08-27 07:32:36 -07:00
Valentin Shergin 71295bcdac Fabric: Enabling and disabling EventEmitter at post commit phase
Summary:
@public
We need that to ensure that we will not deliver events to nodes with invalid state.

Reviewed By: mdvacca

Differential Revision: D8886234

fbshipit-source-id: 1d6ca129c97a5dca0411e85909aea48185f46c54
2018-08-27 07:32:36 -07:00
Valentin Shergin b784adc7ae Fabric: `FabricUIManager::dispatchEventToEmptyTarget` got coupled with `dispatchEventToTarget`
Summary:
@public
Instead of having two methods it's easier to have just one which can be abstracted as `EventPipe`.

Reviewed By: mdvacca

Differential Revision: D8886231

fbshipit-source-id: af9fd92dc4afa1219a11acce0aa021a85c94d232
2018-08-27 07:32:35 -07:00
Valentin Shergin 5965ba283f Fabric: Introducting EventQueue (+ Batched and Unbatched versions)
Summary:
@public
EventQueue is a queue of events that synchronizing event dispatching with given Event Beat.
The only difference between UnbatchedEventQueue and BatchedEventQueue is that UnbatchedEventQueue `induce` an Event Beat right after enqueing an event.

Reviewed By: mdvacca

Differential Revision: D8886225

fbshipit-source-id: fedba6fdff2ecb6f3c615cea09b5fdaa58890479
2018-08-27 07:32:35 -07:00
Valentin Shergin 504c7694c4 Fabric: Introducing `RawEvent`
Summary:
@public
RawEvent represents ready-to-dispatch event data, an event that can be processed uniformly.

Reviewed By: mdvacca

Differential Revision: D8886235

fbshipit-source-id: 1c905517814330c5ecbf39f0ebc95ff2b576d1f2
2018-08-27 07:32:35 -07:00
Valentin Shergin 26d0b05c80 Fabric: MessageQueueEventBeat
Summary:
@public
MessageQueueEventBeat implements particular Event Beat synchronized with Message Queue and calling a callback on the JS thread (aka Message Queue thread). The actual beat is synchronized with the main run loop.

Reviewed By: mdvacca

Differential Revision: D8886230

fbshipit-source-id: 97ef7d10f705789b4b0cd3a12389db960159f289
2018-08-27 07:32:34 -07:00
Valentin Shergin 57bbce9bd9 Fabric: Introducing EventBeat concept (and MainRunLoopEventBeat)
Summary:
@public
EventBeat is an abstraction around proper event scheduling combining proper timing and proper threading. Event Queues use Event Beat to ensure that events are delivered on proper threads and in proper timing (probably batched). Consumers can `request` the next beat and `induce` immediatly beat.
MainRunLoopEventBeat implements particular Event Beat synchronized with the main event loop and calling a callback on the main thread.

Reviewed By: mdvacca

Differential Revision: D8886229

fbshipit-source-id: 1a42fcbf4cd61c6cb4c502890566c98b00226f31
2018-08-27 07:32:34 -07:00
Logan Daniels 122dc37afe Deeply compare viewabilityConfigs to avoid triggering invariant unnecessarily
Summary:
Currently, modifying a component that renders a FlatLists while Hot Reloading is enabled will trigger an invariant inside FlatList for changing viewabilityConfig on the fly. This happens because it checks object equality between the configs.

By checking equality of the config's *properties* instead, we maintain the efficacy of the invariant but keep it from falsely triggering during development.

Reviewed By: sahrens

Differential Revision: D9466129

fbshipit-source-id: 67149e9e70ad7b2e2584bb7ec03e2dea26ef45e8
2018-08-24 14:32:07 -07:00
Eli White d2c27f5bff Remove view configs from JS
Summary: Apparently different apps have different implementations of view managers that support different props. This is a problem that we will need to address. Unfortunately, this means we can't have a static config defined in JS. We will need to find another approach to this problem.

Reviewed By: sahrens

Differential Revision: D9500178

fbshipit-source-id: b591559164fcf29f5fd43e13a0f2da15011491c6
2018-08-24 14:04:09 -07:00
Eli White 035597566f Explain why and how to keep JS<->Naitve view configs in sync
Reviewed By: sahrens

Differential Revision: D9485764

fbshipit-source-id: 673748b0ded666b8d17ed221e1208cffefb6c859
2018-08-24 14:04:09 -07:00
Mehdi Mulani 64a52532fe Text: send metrics after rendering (iOS)
Summary: This adds a callback for <Text> to get metrics about the rendered text. It's divided by line but that could be changed to "fragments" (which makes more sense for multi-lingual). Right now by line is convenient as you frequently want to know where the first and last line end (though we could make this work with fragments I suppose).

Reviewed By: shergin

Differential Revision: D9440914

fbshipit-source-id: bb011bb7a52438380d3f604ffe7019b98c18d978
2018-08-24 13:33:08 -07:00
Andrew Chen (Eng) 1f96ff62cf Fix accessibilityRole value lookup
Summary:
Accessibility roles are enums that are looked up by matching a string accessibility role from JS to the enum's name using .toUpperCase(). .toUpperCase() causes issues in certain languages such as Turkish because the "i"s translate to "?".

D9402330 tried to address this by forcing the .toUpperCase to use Locale.US, but now it sometimes translates to "?"

Use .equalsIgnoreCase() instead to avoid translations.

Reviewed By: mdvacca, mmmulani

Differential Revision: D9497494

fbshipit-source-id: 0f8b7f2071b08ccb86655fee7bfd2d009ddde8eb
2018-08-24 13:21:21 -07:00
Tim Yung 47dc31d464 RN: Nullable Image, Text, & View Props
Summary:
Changes the Flow prop types for `Image`, `Text`, and `View` to be nullable and optional.

This makes these components easier to compose.

Reviewed By: sahrens

Differential Revision: D9494285

fbshipit-source-id: c3f17147f063b31217b239a3abc085d1850f8df9
2018-08-24 10:48:08 -07:00
Lars Graubner 8dc209a523 improve contrast ratio in debugger-ui dark mode (#20559)
Summary:
The font colors in the debugger-ui dark mode are not accessible. This PR ensures [Level AAA Conformance to Web Content Accessibility Guidelines 2.0](https://www.w3.org/WAI/WCAG2AAA-Conformance) which makes it better to read for everyone.
Pull Request resolved: https://github.com/facebook/react-native/pull/20559

Differential Revision: D9495584

Pulled By: hramos

fbshipit-source-id: 1a9bdd015935fb27e2d74d2399e687787282a987
2018-08-24 02:32:29 -07:00
Eli White a700044e2e Move Android's Image ViewConfig to JS
Reviewed By: sahrens

Differential Revision: D9492683

fbshipit-source-id: 035aa00650ee4908452fe18384d953882bc2a8d8
2018-08-23 21:48:04 -07:00
Eli White daec505144 Put RCTTextInlineImage ViewConfig in JS
Summary: Moving this config to native for android so we skip the native lookup for the config.

Reviewed By: yungsters

Differential Revision: D9485645

fbshipit-source-id: cc0a6e9f12dad0c08aac32ca210373c388d307d6
2018-08-23 21:48:04 -07:00
Héctor Ramos 1fe7b40a33 Fix eslint code analysis bot (#20822)
Summary:
The eslint bot has not been working since the migration to Circle 2.0.
Pull Request resolved: https://github.com/facebook/react-native/pull/20822

Differential Revision: D9492680

Pulled By: hramos

fbshipit-source-id: 7f2f9ac125b6cab1750902c485a6d27d6c3cf302
2018-08-23 20:34:51 -07:00
Rafael Oleza e4621f4ce1 Expose the actual transformer in the config
Summary:
This diff exposes the new more generic way to configure transformers in `Metro` via the config parameter `transformerPath`.

The new generic transformers can be used to transform any kind of file, since they don't call any JS-specific method and their API is generic. They only need to implement a single `transform` method:

```
async function transform(
  absolutePath: string,
  relativePath: string,
  fileContents: Buffer,
  options: TransformOptions, // very soon these will be configurable
): Promise<{
  output: Array<mixed>,
  dependencies: Array<{
    name: string,
    data: mixed, // very soon
  }>,
}> {
  // ...
}
```

Metro already had a `transformModulePath` config param, which was used to configure how babel was called in order to generate the AST. In order to avoid confusion, but keep the current open source transformer worker, I've renamed this param to `babelTransformerPath`. We can add a layer of compatibility and detect old config params in order to show a deprecation warning.

Reviewed By: pvdz

Differential Revision: D9070810

fbshipit-source-id: aebde879736026c09537f5d236eae24c06640abf
2018-08-23 15:48:04 -07:00
Rafael Oleza dd0900a03a Standarize options passed to the transformer
Summary:
This is the first step to make transformers fully customizable (and not be tied to JS, or RN). In order to do that, I'm changing the signature of the transformers, which currently is:

```
function transformCode(
  filename: string,
  localPath: LocalPath,
  transformerPath: string,
  options: WorkerOptions,
  assetExts: $ReadOnlyArray<string>,
  assetRegistryPath: string,
  minifierPath: string,
  asyncRequireModulePath: string,
  dynamicDepsInPackages: DynamicRequiresBehavior,
)
```

to be:

```
async function transformCode(
  filename: string,
  localPath: LocalPath,
  options: WorkerOptions,
)
```

(so basically, all the RN-custom properties are moved to `WorkerOptions`, which in the future will be a generic to allow anybody pass any random option to their transformers).

In order to make all this work, I've had to get rid of the logic that calculates the base cache key hash based on a subset of worker options (the ones that Metro knows that are not going to change between runs).

This could potentially cause a perf regression (since we're now making the hash calculation a bit more costly), and in fact I could measure a ~400ms regression on the worse case scenario (which happens when restarting Metro and re-transforming a Wilde from a warm local cache).

I've benchmarked this regression and could find that it's caused by the array of `assetExtensions` (which is potentially large). I have a followup diff to improve this, which is able to remove the regression completely.

Reviewed By: pvdz

Differential Revision: D8695766

fbshipit-source-id: eccd18a4cbc91854f34d5c9ba7f95088f19483a1
2018-08-23 15:48:03 -07:00
Héctor Ramos d0f0e8e248 Gate failing steps behind a username check (#20818)
Summary:
There are some steps known to be failing on master. This pollutes checks for unrelated PRs.

This PR will make it so that PRs submitted by anyone other than myself will no-op on these steps.

Future work: Have an array of whitelisted contributors, and make it much easier to turn individual tests on and off.
Pull Request resolved: https://github.com/facebook/react-native/pull/20818

Differential Revision: D9484946

Pulled By: hramos

fbshipit-source-id: d6c187b341f13552b33d0f1d569b65f6c66ae48f
2018-08-23 15:18:04 -07:00
Vladimir Zdravkovic 3b688ae6b2 Updated the glog library version from 0.3.4 to 0.3.5 (#20811)
Summary:
While the original reason for this change was because of an issue #20780, with further investigation I concluded that the issue is till present for this combo of versions:
glog - 0.3.5
google-cast-sdk - 4.3.1

Downgrading google-cast-sdk to 4.3.0 fixed the build issue.

Release Notes:
--------------
Updated glog version from 0.3.4 to 0.3.5 for iOS

[IOS] [ENHANCEMENT] [GLOG]
Pull Request resolved: https://github.com/facebook/react-native/pull/20811

Differential Revision: D9485221

Pulled By: hramos

fbshipit-source-id: 65caf0839588384a5229a6165506dc6ef62e5fc5
2018-08-23 14:17:18 -07:00
Simon Jensen 966bb63a80 make Object.assign polyfill conditional and spec compliant
Summary: Replace the non-compliant `Object.assign` with a spec compliant version from Mozilla. Since its spec compliant we can apply conditionally only when a native version is not available.

Reviewed By: yungsters

Differential Revision: D8896359

fbshipit-source-id: 4999fe3094eba2206293bbe28760a4e46cbee6aa
2018-08-23 14:02:10 -07:00
Eli White 1329d18c6a Require that JS defined Component Attributes match Native ones in dev
Summary: As we move these configs to JS from native, until we have codegen that ensures everything stays up to date, this adds a dev mode check to ensure they are consistent.

Reviewed By: yungsters

Differential Revision: D9475011

fbshipit-source-id: 9d6f7b6c649229cae569d840eda3d5f7b7aa7cb2
2018-08-23 13:01:41 -07:00
gengjiawen e2f2e41f09 refine android config (#20731)
Summary:
By this change we can unify version early, like we can make kotlin version share in buildscript and app dependency the same time ([butterknife](https://github.com/JakeWharton/butterknife/blob/master/build.gradle) use the same).
pass all current ci and one of my project https://github.com/gengjiawen/ReactNative64bitDemo.
none
 [GENERAL] [ANDROID] [TEMPLATE] - refine android config
Pull Request resolved: https://github.com/facebook/react-native/pull/20731

Differential Revision: D9482954

Pulled By: hramos

fbshipit-source-id: d864adbdbc624bc311ccc5f44a15d0334d2d8a59
2018-08-23 12:17:57 -07:00
Vladimir Timofeev 3949e937cc Make SafeAreaView to work on iOS < 11 (#18534)
Summary:
Currently `SafeAreaView` works only on iOS 11, because implemented in terms of native safeArea API, that not exists in older iOS versions. But this make it hard to use the component in real applications, because content will be under top bars on older versions of iOS and no reliable way to workaround this in js. More motivation in #17638

This changeset emulate safe area in terms of `UIViewController` layout guides API if safeArea not available.

Fixes #17638, #18255

I run RNTester with these simulators: iPhone6 (9.3), iPhone6 (10.0), iPhone6 (11.2), iPhoneX (11.2)
- Start RNTester application
- Look on top header, it should not overlap status bar
- Go to the `<SafeAreaView>` example, open modal
- Modal area should not overlap status bar

<img src="http://vovkasm.skitch.vovkasm.org/iPhone6_10_20662C5B.png" width="40%"> <img src="http://vovkasm.skitch.vovkasm.org/iPhone6_11_20662CC8.png" width="40%">

<img src="http://vovkasm.skitch.vovkasm.org/iPhone6_10_pr_20662DE6.png" width="40%"> <img src="http://vovkasm.skitch.vovkasm.org/iPhone6_11_pr_20662DA8.png" width="40%">

[IOS] [BUGFIX] [SafeAreaView] - Make SafeAreaView to work on iOS < 11
Pull Request resolved: https://github.com/facebook/react-native/pull/18534

Reviewed By: PeteTheHeat, shergin

Differential Revision: D9166052

Pulled By: hramos

fbshipit-source-id: c086e1ae4af13110a7453b770ca75b6e0d5321ea
2018-08-23 12:02:35 -07:00
Eli White 97472892d7 Back out "[react-native][PR] Make Flow and PropType types checks consistent for view style props."
Summary: Reverting due to problems with prepack.

Reviewed By: gaearon

Differential Revision: D9482931

fbshipit-source-id: 0ec5d0fb80dab32a07521a465dd2a501e6bb4d30
2018-08-23 11:34:26 -07:00
Héctor Ramos 0bad11b610 Bump iOS min in Readme (#20805)
Summary:
iOS 8 was dropped as of 0.56.
Pull Request resolved: https://github.com/facebook/react-native/pull/20805

Differential Revision: D9481968

Pulled By: hramos

fbshipit-source-id: 23e74ac3145ba92e2c119be365f2435e290c3f61
2018-08-23 10:47:30 -07:00
Tim Yung 055c941c40 A11Y: Leverage New `AccessibilityProps` Props
Summary: Adds new accessibility props more widely.

Reviewed By: TheSavior

Differential Revision: D9466018

fbshipit-source-id: 63ce58f725c7fd924d979d821037011d83c0334e
2018-08-23 00:18:47 -07:00
Héctor Ramos aae3a7816e Use one time password when publishing to npm (#20701)
Summary:
This pull request addresses the failing publish-npm.js script from earlier this week. For background, last month we reset all npm access tokens for any package related to Facebook, and we now require all accounts with publish permissions to have two factor enabled.

The publish-npm.js script relied on one such token that is configured in Circle CI as a envvar. The token has been updated in Circle CI, but we now need a way of passing the one time password to npm.

With this PR, we can now grab the otp from Circle CI's envvars. Considering otps are ephemeral, this requires the NPM_CONFIG_OTP envvar to be set by someone with publishing permissions anytime a new release will be pushed to npm. The token is short lived, but it would still be good to clear the envvar after the package is published. Circle CI envvars are not passed on to PR/forked builds.

This PR is effectively a breaking change for the release process, as the publish step will not succeed if the OTP is not valid.

OTPs are short-lived, and the publish_npm_package job will definitely outlive the token. Unfortunately this will require some timing to get right, but the alternative is to ssh into the Circle CI machine and re-run the `npm publish --otp` command, which again would still require someone with publish access to provide the otp.
Pull Request resolved: https://github.com/facebook/react-native/pull/20701

Differential Revision: D9478488

Pulled By: hramos

fbshipit-source-id: 6af631a9cb425271b98c03d158aec390ebc95304
2018-08-22 23:32:27 -07:00