Skip to content

Conversation

gribnoysup
Copy link
Collaborator

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 uses npm ci with a follow-up prune 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).

@gribnoysup
Copy link
Collaborator Author

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
Copy link
Collaborator

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?

Copy link
Collaborator Author

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?

Copy link
Collaborator Author

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 👍

Copy link
Collaborator

@mcasimir mcasimir left a comment

Choose a reason for hiding this comment

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

Epic!

@gribnoysup gribnoysup merged commit 2a47315 into main Jul 30, 2021
@gribnoysup gribnoysup deleted the compass-4963-generate-package-lock-for-compass branch July 30, 2021 11:41
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.

2 participants