Repository navigation
feat(nodejs): bump pnpm version to 11.7.0 and support v11+ global bin layout - #6494
Conversation
… layout Bumps pnpm version to 11.7.0 in Dockerfile. Updates getPNPMEnv to use the parent directory of node bin directory as PNPM_HOME for pnpm v11+, ensuring global binaries are installed in the node bin directory. Also sets PNPM_CONFIG_DANGEROUSLY_ALLOW_ALL_BUILDS=true to bypass interactive build approval prompts.
Simplifies getPNPMEnv by assuming pnpm v11+ is always used, removing the version detection helper functions.
There was a problem hiding this comment.
Code Review
This pull request updates the PNPM version to 11.7.0 and adjusts the environment configuration (such as dynamically setting PNPM_HOME and enabling PNPM_CONFIG_DANGEROUSLY_ALLOW_ALL_BUILDS) to support PNPM v11+. Feedback is provided to improve the robustness of the version parsing logic in the newly added isV11OrGreater function.
I am having trouble creating individual review comments. Click here to see my feedback.
internal/librarian/nodejs/install.go (181-191)
The len(parts) == 0 check is redundant because strings.Split with a non-empty separator like "." always returns a slice of at least length 1. However, when splitting a string that is expected to have a specific number of parts, we should use strings.SplitN and check the length of the resulting slice to prevent panics. Additionally, we can make the version parsing more robust by trimming any leading 'v' prefix before splitting.
func isV11OrGreater(version string) bool {
version = strings.TrimPrefix(version, "v")
parts := strings.SplitN(version, ".", 2)
if len(parts) < 1 {
return false
}
major, err := strconv.Atoi(parts[0])
if err != nil {
return false
}
return major >= 11
}
References
- When splitting a string that is expected to have a specific number of parts, use strings.SplitN and check the length of the resulting slice to prevent panics.
Removes PNPM_CONFIG_DANGEROUSLY_ALLOW_ALL_BUILDS env var from getPNPMEnv and its assertion in tests, as it is deemed irrelevant.
Removes the specific PNPM_HOME value assertion from the test stub to keep it generic and consistent with other env var checks.
Simplifies PNPM_HOME to always use filepath.Dir(globalBin) without checking for 'bin' folder name. Reverts all changes to install_test.go to match upstream/main.
Adds a comment above PNPM_HOME calculation in getPNPMEnv referencing pnpm v11 release notes.
Bumps Node.js to 22 to satisfy pnpm v11 requirements. Sets PNPM_CONFIG_DANGEROUSLY_ALLOW_ALL_BUILDS=true during docker build to allow dependency builds.
The link is broken. |
… layout (googleapis#6494) This PR bumps `pnpm` version to `11.7.0` and `Node.js` to `22` in the Dockerfile, and updates the Node.js tool installer to support `pnpm` v11+ global bin directory layout. We assume `pnpm` v11 is used. ### Changes * **Dockerfile (pnpm & Node bump):** Bumps `NODEJS_PNPM_VERSION` to `11.7.0` and `NODEJS_NODE_VERSION` to `22` in `cmd/librarian/Dockerfile`. Node 22 is required for `pnpm` v11. * **Dockerfile (Build Fix):** Sets `PNPM_CONFIG_DANGEROUSLY_ALLOW_ALL_BUILDS=true` during the Docker image build (`librarian install nodejs`) to bypass interactive build approval prompts for dependencies (fixing `[ERR_PNPM_IGNORED_BUILDS]`). * *Reference:* Starting with pnpm v10, build scripts are blocked by default for security. See the [pnpm v10.0.0 release notes](https://github.com/pnpm/pnpm/releases/tag/v10.0.0) for details on why this is needed. * **PNPM_HOME Adjustment:** Updates `getPNPMEnv` in `internal/librarian/nodejs/install.go` to use the parent directory of Node bin directory as `PNPM_HOME` (`filepath.Dir(globalBin)`). This ensures `pnpm` (which installs to `PNPM_HOME/bin` in v11+) places the binaries back in the Node bin directory, which is in `PATH`. ### Scope Notes * The use of `LIBRARIAN_INSTALL_DIR` is outside the scope of this pull request. This pull request does not make it harder to use `LIBRARIAN_INSTALL_DIR`. Fixes googleapis#6480
The `node` and `pnpm` version are updated in #6494, we should update these versions in workflow.
🤖 I have created a release *beep* *boop* --- ## [0.23.0](v0.22.0...v0.23.0) (2026-06-29) ### Features * **internal/librarian/java:** add decamelize utility for README generation ([#6538](#6538)) ([a6d950a](a6d950a)), closes [#6515](#6515) * **internal/librarian/java:** Add JSpecify dep to proto module template ([#6564](#6564)) ([660ab2b](660ab2b)) * **internal/librarian/java:** add production sample filter ([#6545](#6545)) ([df213ec](df213ec)), closes [#6515](#6515) * **internal/librarian/java:** add README sample extraction helpers ([#6574](#6574)) ([500ba22](500ba22)), closes [#6515](#6515) * **internal/librarian/java:** add title override extractor ([#6546](#6546)) ([0986d6a](0986d6a)), closes [#6515](#6515) * **internal/librarian/python:** update gapic-generator to 1.36.0 ([#6548](#6548)) ([a0930f4](a0930f4)) * **nodejs:** bump pnpm version to 11.7.0 and support v11+ global bin layout ([#6494](#6494)) ([1373628](1373628)), closes [#6480](#6480) * **sidekick/rust:** track recording error info for discovery LROs ([#6304](#6304)) ([feb2ef2](feb2ef2)), closes [#6286](#6286) * **sidekick/swift:** generate synthetic messages ([#6530](#6530)) ([7303648](7303648)) * **sidekick/swift:** handle clashing names ([#6543](#6543)) ([56bf365](56bf365)) * **sidekick/swift:** swap client vs. protocol ([#6566](#6566)) ([14e186c](14e186c)) ### Bug Fixes * **internal/librarian:** gracefully handle nil defaults in applyDefaults ([#6571](#6571)) ([3ee938a](3ee938a)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
This PR bumps
pnpmversion to11.7.0andNode.jsto22in the Dockerfile, and updates the Node.js tool installer to supportpnpmv11+ global bin directory layout.We assume
pnpmv11 is used.Changes
NODEJS_PNPM_VERSIONto11.7.0andNODEJS_NODE_VERSIONto22incmd/librarian/Dockerfile. Node 22 is required forpnpmv11.PNPM_CONFIG_DANGEROUSLY_ALLOW_ALL_BUILDS=trueduring the Docker image build (librarian install nodejs) to bypass interactive build approval prompts for dependencies (fixing[ERR_PNPM_IGNORED_BUILDS]).getPNPMEnvininternal/librarian/nodejs/install.goto use the parent directory of Node bin directory asPNPM_HOME(filepath.Dir(globalBin)). This ensurespnpm(which installs toPNPM_HOME/binin v11+) places the binaries back in the Node bin directory, which is inPATH.Scope Notes
LIBRARIAN_INSTALL_DIRis outside the scope of this pull request. This pull request does not make it harder to useLIBRARIAN_INSTALL_DIR.Fixes #6480