fix(js): support bun-only environments in release-publish executor#34835
Conversation
✅ Deploy Preview for nx-docs canceled.
|
✅ Deploy Preview for nx-dev canceled.
|
|
View your CI Pipeline Execution ↗ for commit 4acfc08
☁️ Nx Cloud last updated this comment at |
npm version-dependent warnings (e.g., "prefer-frozen-lockfile") cause snapshot flakiness across CI environments.
This reverts commit d8de646.
There was a problem hiding this comment.
Important
At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.
Nx Cloud is proposing a fix for your failed CI:
We added a third condition to the bun info error handler in release-publish.impl.ts to recognize bun's plain-text 404 Not Found stderr format as a "package not yet published" signal. Without this, the inner try block would parse an empty stdout as {}, find no E404 code, and incorrectly return success: false before the publish ever ran. This fix allows first-time bun publishes to proceed as expected.
Warning
❌ We could not verify this fix.
diff --git a/packages/js/src/executors/release-publish/release-publish.impl.ts b/packages/js/src/executors/release-publish/release-publish.impl.ts
index 69fb67b0a2..748ab96099 100644
--- a/packages/js/src/executors/release-publish/release-publish.impl.ts
+++ b/packages/js/src/executors/release-publish/release-publish.impl.ts
@@ -282,6 +282,10 @@ Please update the local dependency on "${depName}" to be a valid semantic versio
!(
err.stderr?.toString().includes('E404') &&
err.stderr?.toString().toLowerCase().includes('not found')
+ ) &&
+ !(
+ err.stderr?.toString().includes('404') &&
+ err.stderr?.toString().toLowerCase().includes('not found')
)
) {
console.error(
🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.
Because this branch comes from a fork, it is not possible for us to apply fixes directly, but you can apply the changes locally using the available options below.
Apply changes locally with:
npx nx-cloud apply-locally P7NN-0cbK
Apply fix locally with your editor ↗ View interactive diff ↗
🎓 Learn more about Self-Healing CI on nx.dev
Only switch to bun info when pm is bun. Keep npm view for npm/pnpm/yarn since detectPackageManager() can return pnpm in CI even when the project uses npm (due to npm_config_user_agent from the parent pnpm process).
|
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
Note
🤖 This PR was created by @AI-JamesHenry, an AI assistant account guided and overseen by @JamesHenry.
Current Behavior
nx release publishhardcodesnpm viewandnpm dist-tag addcommands, which fails in bun-only environments (e.g.,oven/bunDocker images) where npm is not installed, with/bin/sh: 1: npm: not found.Expected Behavior
nx release publishworks in bun-only environments by:bun infoinstead ofnpm viewfor checking existing versions/dist-tagsnpm dist-tag addwhen npm is not available (bun has no equivalent)Changes
execSync('npm --version'). If npm is missing and PM is not bun, returns a controlled error.bun info/yarn info/pnpm view/npm viewbased on detected package manager. Only npm/pnpm support field specifiers (versions dist-tags).npm dist-tag addsection inif (isNpmInstalled)since only npm has this command.This is a clean reimplementation incorporating all review feedback from the original #32252.
Notable: The
PackageManagerCommandsinterface is NOT modified — the view command is built locally in the executor as requested in review feedback.Related Issue(s)
Fixes #32126