Skip to content

Build script improvements #212

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 5 commits into from
Mar 5, 2025
Merged

Build script improvements #212

merged 5 commits into from
Mar 5, 2025

Conversation

cwillisf
Copy link
Contributor

@cwillisf cwillisf commented Mar 3, 2025

Proposed Changes

Changes to some of the build scripts:

  • Add a top-level clean script and audit clean scripts for each workspace (some were missing, some were incomplete)
  • Explicitly list packages under workspaces to control the order of (for example) npm --workspaces run ...
  • Now that workspaces are ordered, simplify npm run build
  • Rebuild the version update

Reason for Changes

Most of this is just about developer ergonomics, but the version update also improves correctness. This approach ensures that several things happen:

update for in scope-specific package.json in package-lock.json (global)
root workspace (optional) added with new script added with new script
each package already worked correctly added with new script
package direct dependencies already worked correctly added with new script
package indirect dependencies N/A added with new script

Note that "package indirect dependencies" includes updating the version of indirect internal dependencies and updating indirect external dependencies if necessary. That can mean relatively complex package-lock.json changes that are difficult to predict or simulate with something like jq.

The details of the version update process are a little goofy and documented in the script itself.

Test Coverage

Tested locally with npm run clean, npm run build, and various npm version commands. Since the npm run build command is (now) used by CI, it's also tested by posting this PR.

Even with `--offline` and installing a dependency that's contained in an
internal worksace, `npm --workspace a install b` will put the latest
published version of `b` (that it knows about) into the lock file rather
than the current monorepo version of `b`.

The only way I've found to get the version updated correctly in both
`package.json` and `package-lock.json` is the way that
@MiroslavDionisiev did it in the previous versioning script: just
manually hammer the version number, then get `npm i --package-lock-only`
to make the lock file consistent afterward.
@cwillisf cwillisf requested a review from a team as a code owner March 3, 2025 19:56
@@ -11,21 +11,27 @@
},
"scripts": {
"refresh-gh-workflow": "ts-node scripts/build-gha-workflows.ts",
"build-monorepo": "bash ./scripts/build-monorepo.sh",
"build-monorepo": "cross-env-shell ./scripts/build-monorepo.sh",
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 just learned about cross-env-shell this week 😅

Comment on lines +97 to +99
npm install --offline --no-audit --no-fund --ignore-scripts --package-lock-only
# Sometimes it makes further changes the second time
npm install --offline --no-audit --no-fund --ignore-scripts --package-lock-only
Copy link
Contributor

Choose a reason for hiding this comment

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

we don't ask how npm works

@cwillisf cwillisf added this pull request to the merge queue Mar 5, 2025
github-merge-queue bot pushed a commit that referenced this pull request Mar 5, 2025
Merged via the queue into develop with commit 8f088d2 Mar 5, 2025
3 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Mar 5, 2025
@cwillisf cwillisf deleted the build-script-improvements branch June 10, 2025 19:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants