From 679387106a5851c28b36435044186f9f4526a63d Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Tue, 5 May 2026 11:06:11 +0100 Subject: [PATCH 1/2] JS: fix npmPublish skip detection that always reported "already published" PR #7552 added an `onlyIf` block that ran `npm view @openrewrite/rewrite@ version` and skipped publishing if the captured output contained the version string. With `redirectErrorStream(true)`, npm's 404 error message also contains the requested version (e.g. "The requested resource '@openrewrite/rewrite@' could not be found"), so the contains-check matched on every miss and silently skipped npm publish for any newly-stamped snapshot. The npm prerelease tag has been frozen at 8.82.0-20260502-150813 since then, while Maven snapshots continue to advance with the latest commit timestamp. Downstream consumers that try to spawn the JS RPC subprocess via `npx --package=@openrewrite/rewrite@ rewrite-rpc` then fail with ETARGET because the version baked into the JAR's resource is not on npm, breaking CI in repositories like rewrite-static-analysis. Switch the check to use `npm view`'s exit code (and verify the version appears on its own line in stdout) so we only skip when the version is genuinely already published. --- rewrite-javascript/build.gradle.kts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rewrite-javascript/build.gradle.kts b/rewrite-javascript/build.gradle.kts index 563c6a35f5..e8a2c59bb7 100644 --- a/rewrite-javascript/build.gradle.kts +++ b/rewrite-javascript/build.gradle.kts @@ -263,9 +263,8 @@ val npmPublish = tasks.register("npmPublish") { .directory(file("rewrite")) .redirectErrorStream(true) .start() - process.waitFor() val output = process.inputStream.bufferedReader().readText().trim() - val alreadyPublished = output.contains(versionToCheck) + val alreadyPublished = process.waitFor() == 0 && output.lines().any { it.trim() == versionToCheck } if (alreadyPublished) { logger.lifecycle("Skipping npmPublish: @openrewrite/rewrite@$versionToCheck already published") } From e69b5867ffe1ddd8e15151bd6b8da59cd04526fe Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Tue, 5 May 2026 11:40:45 +0100 Subject: [PATCH 2/2] JS: simplify npmPublish version match to contains Address review feedback: with the exit-code gate in place, the merged stderr/stdout 404 case can no longer reach this check, so a simple contains is enough and is more forgiving of minor npm view output formatting differences. --- rewrite-javascript/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rewrite-javascript/build.gradle.kts b/rewrite-javascript/build.gradle.kts index e8a2c59bb7..0df31ff1e2 100644 --- a/rewrite-javascript/build.gradle.kts +++ b/rewrite-javascript/build.gradle.kts @@ -264,7 +264,7 @@ val npmPublish = tasks.register("npmPublish") { .redirectErrorStream(true) .start() val output = process.inputStream.bufferedReader().readText().trim() - val alreadyPublished = process.waitFor() == 0 && output.lines().any { it.trim() == versionToCheck } + val alreadyPublished = process.waitFor() == 0 && output.contains(versionToCheck) if (alreadyPublished) { logger.lifecycle("Skipping npmPublish: @openrewrite/rewrite@$versionToCheck already published") }