Skip to content

Update NPM packages #150

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

Merged
merged 9 commits into from
Sep 12, 2020
Merged

Update NPM packages #150

merged 9 commits into from
Sep 12, 2020

Conversation

angelocordon
Copy link
Contributor

What type of PR is this? (check all applicable)

  • 🎨 Enhancement
  • 🚩 Other (chores)

Context

Update NPM packages to handle vulnerability issues. Also updated packages that are way behind on their versions.

Implementation Details - what was your thought process as you changed the code?

1/ To find packages that are currently vulnerable, run npm audit. Running npm audit --fix can fix most of the issues. NPM itself (listed in our package.json) was not automatically fixed and had to be updated by running npm update npm@latest.

2/ Running npm outdated also gives us a list of packages that are way behind from their current release versions. Updated packages based on themes instead of updating all at once to see if it breaks anything. In between the package updates, I ran the tests to see if what we have still passed (although our test coverage is kind of lacking). While the packages were not updated to their latest available versions, their current versions listed here are considered "safe"; I suppose so long that we're not more than a whole version behind.

Added tests?

  • 🙅 no, because they aren't needed

Added to documentation (readme.md or contributing.md)?

  • 🙅 no documentation needed

@angelocordon angelocordon added the dependencies Pull requests that update a dependency file label Sep 10, 2020
@angelocordon angelocordon requested a review from lpatmo September 10, 2020 05:57
@angelocordon angelocordon self-assigned this Sep 10, 2020
@lpatmo
Copy link
Member

lpatmo commented Sep 10, 2020

Thanks Angelo! Will take a look at merging this in after #4 is merged.

@tgrrr
Copy link

tgrrr commented Sep 10, 2020

I tested this, for starters:

found 0 vulnerabilities

Well done!

What about updating the version of react?

It's still set at:

    "react": "16.11.0",
    "react-dom": "16.11.0",
    "react-scripts": "^3.4.0",

CRA's latest build includes:

    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.3"

After testing a re-install I had a couple of warnings. The usual stuff, but here's the things in our control:

@hapi/joi@17.1.1: joi is leaving the @hapi organization and moving back to 'joi' (https://github.com/sideway/joi/issues/2411)

We can move from @hapi/joi to joi: https://www.npmjs.com/package/joi

eslint-config-semistandard@15.0.1 requires a peer of eslint-config-standard@>=14.1.0 but none is installed. You must install peer dependencies yourself.

We can install eslint-config-standard@>=14.1.0

tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
react-docgen-typescript-loader@3.7.2 requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
react-docgen-typescript@1.20.4 requires a peer of typescript@>= 3.x but none is installed. You must install peer dependencies yourself.

We can install typescript@>= 3.x

@tgrrr tgrrr self-requested a review September 10, 2020 09:26
@@ -24,47 +23,44 @@
"@material-ui/icons": "4.9.1",
"@material-ui/lab": "^4.0.0-alpha.56",
"axios": "0.19.0",
"json-server": "0.15.1",
"npm-run-all": "4.1.5",
"prop-types": "^15.7.2",
"react": "16.11.0",
Copy link

Choose a reason for hiding this comment

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

What about updating the version of react?

It's still set at:

    "react": "16.11.0",
    "react-dom": "16.11.0",
    "react-scripts": "^3.4.0",

CRA's latest build includes:

    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.3"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @tgrrr - my goal with this PR is to get us up to the safest, stable version of our packages. There were a few cases where we were a good couple of major versions behind. I didn't opt in to upgrade us to the latest versions of packages because in my experience, sometimes latest versions of packages can get us in dependency hell. For example, some months ago, Testing Library was updated but it also required Jest to be at a certain version. As we were using Jest from CRA, we were pinned at their version. In the end, I ended up having to set up Jest manually for this project in order for our testing infrastructure to work cohesively. This is an extreme case, but I'd like to not have to deal with those kinds of problems too often.

As the versions you mentioned are only ~2 minor / patch versions behind, I think we are safe with where we are here.

Copy link

Choose a reason for hiding this comment

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

I also had a jest conflict with the current config @angelocordon

Copy link

Choose a reason for hiding this comment

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

16.3 is a significant update to react from 16.11 https://github.com/facebook/react/releases

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tgrrr re: Jest conflicts - can you expand more on what that conflict is on your end? I'm not seeing any issues on my end other than an async syntax error which I just fixed. Other than that, running npm run test passes all suites 👍🏽. But if you're having something bigger than that, it may be worth filing an issue so we can resolve it outside of this.

re: React updates - the changes from 16.11 to 16.13 don't apply to us, we're not using lazy or memo, nor do we have a multi-root app. We're not dealing with concurrent mode, nor do I see any of the issues from their updates with ReactDOM applying to us. I think we'll eventually get to 16.13 in due time, but as of now, this feels out of the scope of this PR.

"@babel/preset-env": "^7.8.4",
"@babel/core": "^7.11.6",
"@babel/plugin-transform-runtime": "^7.11.5",
"@babel/preset-env": "^7.11.5",
"@babel/preset-react": "^7.8.3",
"@sheerun/mutationobserver-shim": "^0.3.3",
"@storybook/addon-actions": "^5.3.9",
"@storybook/addon-links": "^5.3.9",
"@storybook/addons": "^5.3.9",
"@storybook/preset-create-react-app": "^1.5.2",
"@storybook/react": "^5.3.19",
Copy link

Choose a reason for hiding this comment

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

Storybook requires packages, which throw the following errors:

tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
react-docgen-typescript-loader@3.7.2 requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
react-docgen-typescript@1.20.4 requires a peer of typescript@>= 3.x but none is installed. You must install peer dependencies yourself.

We can install typescript@>= 3.x

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same comment from above; Storybook isn't currently on my priority list as we're not using it in a very effective way, yet.

Copy link

Choose a reason for hiding this comment

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

Typescript is also a requirement of material-ui, which this repo heavily depends upon. This is the one library that will provide the most stability if it's added to this PR @angelocordon

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'm not seeing anywhere in the Material UI docs that say we need Typescript in order to use Material UI. We've been able to use it this whole time without TS. I think perhaps you mean this page? I believe this only means that if we do have static typing in our codebase, we'd need at least TS 3.2 for it to work with Material.

Considering that this particular thread is about Storybook and we're now talking about Material, this is one of those opportunities where we can be much more practical and avoid some dependency pain points.

@angelocordon
Copy link
Contributor Author

Thanks for the review @tgrrr - I think the peer dependency issues are... minor 🤷🏽 Curious if you started getting them from upping the React versions?

Copy link
Member

@lpatmo lpatmo left a comment

Choose a reason for hiding this comment

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

I think this is OK to merge in first, actually, since there are a couple of updates to make in #4!

@tgrrr
Copy link

tgrrr commented Sep 11, 2020

Thanks for the review @tgrrr - I think the peer dependency issues are... minor 🤷🏽 Curious if you started getting them from upping the React versions?

The dependency requirements are based on this PR, without any changes implemented, including to React

npm -v 6.14.5
node -v v12.18.1
MacOS Mojave 10.14.6

With the current PR without any changes I have:

  • A bug with Jest and npm, asking me to install from scratch
  • The same bug installing with Yarn (not a good sign)
  • The missing peer-dependencies.

I understand that shaving the yak is tiresome, but I think there's a large chance of a new dev spending a significant amount of time trying to get this setup.

@angelocordon
Copy link
Contributor Author

With the current PR without any changes I have:

A bug with Jest and npm, asking me to install from scratch
The same bug installing with Yarn (not a good sign)
The missing peer-dependencies.

Thanks for the heads up @tgrrr. Something feels iffy with your local environment based on the description you're saying. I've removed node_modules and reinstalled the packages, and run the tests and everything seems to be in working order. I think the conflicts you're experiencing may not be related to this PR, but we should file an issue if they're persisting after a deeper investigation.

@angelocordon
Copy link
Contributor Author

Going ahead to merge this @tgrrr. If any of the discussion topics above need to be resolved further, let's discuss in our frontend channel, or if you continue to have technical issues, please write up an issue.

@angelocordon angelocordon merged commit 922a965 into main Sep 12, 2020
@angelocordon angelocordon deleted the update-npm-packages branch September 12, 2020 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants