-
Notifications
You must be signed in to change notification settings - Fork 235
feat(mongodb-compass): Generate package lock for Compass before packaging COMPASS-4963 #2369
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
feat(mongodb-compass): Generate package lock for Compass before packaging COMPASS-4963 #2369
Conversation
…orkspace in a monorepo
…ci command and prune dev deps separately
… Compass before packaging
As this PR touches evergreen config, I started a patch to make sure that I haven't break anything by accident |
async function resolvePackageMetaForLink(link) { | ||
const manifest = await pacote.manifest(`${link.name}@${link.version}`, { | ||
// if env is undefined, defaults to https://registry.npmjs.org | ||
registry: process.env.npm_config_registry |
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 it be an issue that we don't read .npmrc
?
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 question! So by default when you run an npm script, npm will automatically populate those environment variables (when the values are non-default), that means that all .npmrc configs and other ways to override those will be resolved the same way as npm would resolve them. So running this script through npm scripts will always set this value appropriately and I think to avoid of pulling in all this logic of resolving the value we can skip the use-case of using it not from npm scripts. What do you think?
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.
I'll merge this as-is, but will follow-up if we think we need to make this logic here more sturdy 👍
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.
Epic!
Due to the fact that we have to do a clean install when packaging Compass and that we have a monorepo setup with only one root package-lock file, every time we package Compass we are not guaranteed to package it with the exact same dependencies version as when running the application (or tests) from the monorepo itself. This is problematic as we can easily introduce a breaking change in published Compass due to some transitive version update between us running tests and actually packaging application for publishing.
This PR addresses the issue by providing a script that uses monorepo root dependency tree information to build a shrinkwrap data for compass workspace and put a package-lock file in the workspace before packaging.
I also refactored
hadron-build
a little, it usesnpm ci
with a follow-upprune
for the install now which first allows us to remove this explicit hack for the mongodb driver and second will make sure that the build will fail if generated package-lock file has any issues (which we definitely want to catch and address).