Skip to content
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

Update to node 16 and npm 8 via nvm and updated many node packages #10439

Merged
merged 17 commits into from
Aug 19, 2022

Conversation

AndrewGable
Copy link
Contributor

@AndrewGable AndrewGable commented Aug 18, 2022

Details

Update to Node 16 and npm 8, there were quite a few updates that needed to be applied due to the peer dependency changes in npm 7. In npm 7 peer dependencies are installed by default, which creates a much stricter way of installing peer dependencies. For example, react-native-web upgraded to React 18, so now all other packages needed to be upgraded to use React 18.

This caused us to need to upgrade all of these packages:

  • @onfido/react-native-sdk - React 18
  • @pieter-pot/react-native-fast-image - React 18
  • @react-native-community/cameraroll - React 18
  • react-dom - React 18
  • react-pdf - React 18
  • react-plaid-link - React 18
  • @storybook/addon-react-native-web - React 18
  • @welldone-software/why-did-you-render - React 18
  • babel-plugin-react-native-web - react-native-web upgrade
  • eslint-plugin-jsx-a11y - Wasn't installed previously
  • react-native-flipper - React 18/ RN upgrade
  • rn-async-storage-flipper - Removed, I verified with @marcaaron this was OK.
  • tests/unit/nativeVersionUpdaterTest.js - Changes to Node 16 updated function return type

Fixed Issues

$ #10331

Tests

  • Verify that no errors appear in the JS console
  1. Run a general "smoke" test of the app by visiting lots of pages and doing lots of actions.

PR Review Checklist

Contributor (PR Author) Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct English and approved by marketing by tagging the marketing team on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • Any functional components have the displayName property
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

QA Steps

  1. Run a smoke test of the app, lots of libraries were changed

Screenshots

Web

Screen Shot 2022-08-18 at 2 57 50 PM

Desktop

Screen Shot 2022-08-18 at 3 00 38 PM

iOS

Screen Shot 2022-08-18 at 2 56 35 PM

Screen Shot 2022-08-18 at 2 56 31 PM

Android

Screen Shot 2022-08-18 at 2 44 50 PM

Screen Shot 2022-08-18 at 2 44 58 PM

@AndrewGable AndrewGable self-assigned this Aug 18, 2022
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
"@storybook/addon-a11y": "^6.5.9",
"@storybook/addon-essentials": "^6.5.9",
"@storybook/addon-react-native-web": "0.0.18",
"@storybook/addon-react-native-web": "0.0.19--canary.37.cb55428.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hack: This is a PR, but PR has been open for quite some time.

"react-native-clean-project": "^4.0.0-alpha4.0",
"react-native-flipper": "^0.146.1",
"react-native-flipper": "https://gitpkg.now.sh/facebook/flipper/react-native/react-native-flipper?9cacc9b59402550eae866e0e81e5f0c2f8203e6b",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hack: This was merged a few hours before I made this PR, I assume it will land soon-ish.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to their GitHub, this should land in 0.160.0 but I haven't seen it hit the npm registry yet.

@AndrewGable
Copy link
Contributor Author

GitHub actions are finally happy. I will work on cleaning this up some more, then open it up for review once it's clean!

@AndrewGable AndrewGable marked this pull request as ready for review August 18, 2022 21:33
@AndrewGable AndrewGable requested a review from a team as a code owner August 18, 2022 21:33
@melvin-bot melvin-bot bot requested review from NikkiWines and removed request for a team August 18, 2022 21:33
Copy link
Contributor

@luacmartins luacmartins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and tests well on all platforms!

@luacmartins luacmartins mentioned this pull request Aug 18, 2022
@parasharrajat
Copy link
Member

💥 💥
image

@@ -31,7 +31,7 @@ jobs:
if: ${{ fromJSON(needs.validateActor.outputs.IS_DEPLOYER) }}
runs-on: ubuntu-latest
steps:
- uses: Expensify/App/.github/actions/composite/setupNode@main
- uses: Expensify/App/.github/actions/composite/setupNode@andrew-npm-8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the idea is that we want to lock it to a branch, but we cannot lock it to main until this PR is merged. Using local files would work, but it wouldn't lock it to a commit.

Copy link
Member

@parasharrajat parasharrajat Aug 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I would say lock to a commit instead of the branch name. But I got it.

Copy link
Contributor

@NikkiWines NikkiWines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 aside from Rajat's comment!

@parasharrajat
Copy link
Member

We should change the PR title and more details as a lot of things are changed on this PR.

@AndrewGable AndrewGable changed the title Update to node 16 and npm 8 Update to node 16 and npm 8 via nvm and updated many node packages Aug 19, 2022
@AndrewGable
Copy link
Contributor Author

Updated, let me know if you think it's missing anything more!

@AndrewGable AndrewGable mentioned this pull request Aug 19, 2022
91 tasks
Copy link
Contributor

@roryabraham roryabraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blockers, LGTM 👍

})
));
])('updateAndroidVersion("%s", "%s")', (versionName, versionCode, expected) => {
updateAndroidVersion(versionName, versionCode).then(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB because I don't think we've standardized on this, but generally .then goes on the next line from what I've seen

@@ -25,9 +25,6 @@ export default function () {
// Setup Flipper plugins when on dev
if (__DEV__) {
require('flipper-plugin-bridgespy-client');
const RNAsyncStorageFlipper = require('rn-async-storage-flipper').default;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this not needed anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. It was breaking due to peer dependencies and the library not being maintained
  2. I believe @marcaaron said this was a debugging tool that is not used anymore

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be used by some (but I haven't used it in a long time). There are workarounds to this package e.g. if you need to know the contents of AsyncStorage you can always log out values. Might be interesting to do our own Flipper plugin for Onyx at some point 🤔

Copy link
Contributor

@marcaaron marcaaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm install worked well for me after adding the correct node version

@@ -7,7 +7,6 @@ install! 'cocoapods', :deterministic_uuids => false
target 'NewExpensify' do
permissions_path = '../node_modules/react-native-permissions/ios'

pod 'Plaid', '~> 2.3.1'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this auto-linked in a newer version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes correct. I don't know the history behind why we added this, but I think we should rely on auto linking all pod libraries unless there is a specific version breaking for us.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC the history is just that the Plaid react native package required manual linking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand their documentation.. It says it uses auto linking, so we shouldn't need to add it to the Podfile manually.

Plaid 2.5.1 is installed via autolinking and can be seen in the Podfile.lock: https://github.com/Expensify/App/pull/10439/files#diff-b7d85c35701918f25c9b2c418249f9b66fd9b067676e295a9eff493b73ee1752R231

And the Plaid SDK seems to boot just fine:
Screen Shot 2022-08-19 at 12 30 39 PM
Screen Shot 2022-08-19 at 12 31 34 PM

@AndrewGable
Copy link
Contributor Author

Ok all reviewers have approved so I'm going to:

@AndrewGable AndrewGable merged commit bef2d47 into main Aug 19, 2022
@AndrewGable AndrewGable deleted the andrew-npm-8 branch August 19, 2022 18:52
Comment on lines +187 to +190
"engines": {
"node": "16.15.1",
"npm": "8.11.0"
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This produces error when the node and npm version does not match exactly. Developer has to use the exact version. Maybe, we are fine with 16.x and 8.x.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the error is intentional and we want to use the exact version to avoid any harder to debug errors. It should be easy to install and change the version of node if you use nvm.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @AndrewGable in version: 1.1.89-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants