Audit-fix dependencies#4534
Merged
compulim merged 12 commits intomicrosoft:mainfrom Dec 1, 2022
Merged
Conversation
tdurnford
approved these changes
Dec 1, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog Entry
(No CHANGELOG update for audit fix)
Description
Running
npm audit fixon all packages and samples.We added a few helper scripts to do the work because this is not trivial:
npm audit fixandnpm install my-packagewill not work onpackage.jsonwith local peer dependenciesnpm audit fixornpm install my-package, we need to remove local peer dependencies frompackage.jsonbeforenpm audit fixand restore them afterwardlerna bootstrapto fix symlinkspackage.jsonlerna execpackage.jsonsitting next to the codelerna execwill not run for our samples, thus, we need to go through each folder individuallyWe added a few scripts to simplify our work. For simplicity and debuggability, these scripts will only work under WSL2/Linux. As these are very advanced scripts and not used on daily basis, it is okay to trade limitations for simplicity.
npm run auditnpm auditagainst everypackage.jsonunder/packages/and/samples/npm run auditfixnpm audit fixagainst everypackage.jsonunder/packages/and/samples/npm audit fix, it will remove local peer dependencies frompackage.jsonand restore them afterwardnpm audit fix, must runlerna bootstrapagain because NPM will break symlinks of local dependenciesnpm run bump@latestby runningnpm install my-package@latestagainst everypackage.jsonunder/packages/and/samples/package.json/skipBumpwill not be bumpedpackage.jsonunder/packages/, we will use exact version fordependenciesand caret version fordevDependenciespackage.jsonand restore them afterwardnpm run bump, must runlerna bootstrapagain because NPM will break symlinks of local dependenciesAfter this PR, the only issue left should be
nth-checkwhich is used byreact-scripts(a.k.a.create-react-scripts). This is not fixable untilreact-scriptsfixed their code.Design
Because we are using Lerna to maintain our mono-repo, running
npm audit fixunder Lerna is not trivial. Despite counterintuitive and we already have many NPM scripts, we added some helper scripts to simplify the work. For some other reasons, currently, we could not use NPM workspaces.Normally, before running
npm audit fixornpm installon apackage.jsonin the Lerna-maintained mono-repo:package.json/dependenciesandpackage.json/devDependenciesnpm audit fixornpm installlerna bootstrapto restore all symlinks for peer dependenciesThe new scripts will automate these steps by introducing a few new fields in the
package.json:localPeerDependenciesis very similar todependenciesbut only local peer dependencies are listedlocalPeerDevDependenciesis very similar todevDependenciesbut only local peer development dependencies are listedskipBumpindicates what dev/dependencies should not be bumped to@latestnode-fetch@^3does not support CommonJS. Before we upgrade our code to ES Modules, we need to continue to usenode-fetch@^2. We should skip bumpingnode-fetchIn the future, we should build a GitHub bot to run
npm run auditfixandnpm run bump. This will make pull request approval much faster.Specific Changes
package.jsonto include newaudit,auditfix, andbumpscriptsI have added tests and executed them locallyI have updatedCHANGELOG.mdI have updated documentationReview Checklist
Browser and platform compatibilities reviewedCSS styles reviewed (minimal rules, noz-index)Documents reviewed (docs, samples, live demo)Internationalization reviewed (strings, unit formatting)package.jsonandpackage-lock.jsonreviewedSecurity reviewed (no data URIs, check for nonce leak)