Skip to content

chore: replace prepare script with prepublishOnly across workspace packages - #9361

Draft
bshaffer wants to merge 3 commits into
mainfrom
prepublish-only
Draft

bshaffer wants to merge 3 commits into
mainfrom
prepublish-only

Conversation

@bshaffer

Copy link
Copy Markdown
Contributor
  • Replace prepare with prepublishOnly across all workspace packages and generator templates so pnpm install does not trigger 280+ uncached builds (reducing install time from 6+ min to ~13s).
  • Update pretest in nodejs-proto-files, logging-utils, and tools where prepare was explicitly invoked.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates numerous package.json files across the repository, replacing the 'prepare' script with 'prepublishOnly' to ensure compilation occurs specifically before publishing. The review feedback highlights two opportunities to eliminate redundant steps: first, in 'core/packages/nodejs-proto-files/package.json', where the 'pretest' script performs a duplicate compilation; and second, in 'handwritten/spanner/package.json', where the 'prepublishOnly' script includes an unnecessary manual copy step that is already handled by the 'compile' script.

"clean": "gts clean",
"compile": "tsc -p .",
"pretest": "npm run prepare && npm run compile",
"pretest": "npm run prepublishOnly && npm run compile",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The pretest script runs npm run prepublishOnly followed by npm run compile. Since prepublishOnly already runs npm run compile as its first step, running npm run compile again is redundant and slows down the test execution. Simplifying this to just run prepublishOnly avoids the duplicate compilation.

Suggested change
"pretest": "npm run prepublishOnly && npm run compile",
"pretest": "npm run prepublishOnly",

Comment thread handwritten/spanner/package.json Outdated
"clean": "gts clean",
"compile": "tsc -p . && cp -r protos build && cp -r test/data build/test",
"prepare": "cp -r protos build && npm run compile",
"prepublishOnly": "cp -r protos build && npm run compile",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The prepublishOnly script explicitly runs cp -r protos build before invoking npm run compile. However, the compile script itself already handles copying the protos directory to build (via tsc -p . && cp -r protos build && cp -r test/data build/test). This makes the manual copy step in prepublishOnly redundant. Simplifying it to just run compile keeps the script clean and avoids duplicate file copying.

Suggested change
"prepublishOnly": "cp -r protos build && npm run compile",
"prepublishOnly": "npm run compile",

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.

1 participant