From 0af7ad483c5e98c424f6a4186e7b273bca5d016c Mon Sep 17 00:00:00 2001 From: Austin Fahsl Date: Thu, 9 Nov 2023 23:58:05 -0700 Subject: [PATCH] fix(release): catch 403 when publishing an existing version (#20155) --- .../release-publish/release-publish.impl.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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 bfce09f905c82..1c368739cb8ea 100644 --- a/packages/js/src/executors/release-publish/release-publish.impl.ts +++ b/packages/js/src/executors/release-publish/release-publish.impl.ts @@ -102,10 +102,17 @@ export default async function runExecutor( const stdoutData = JSON.parse(err.stdout?.toString() || '{}'); if ( + // handle npm conflict error stdoutData.error?.code === 'EPUBLISHCONFLICT' || + // handle npm conflict error when the package has a scope (stdoutData.error?.code === 'E403' && - stdoutData.error?.body?.error?.includes( + stdoutData.error?.summary?.includes( 'You cannot publish over the previously published versions' + )) || + // handle verdaccio conflict error + (stdoutData.error?.code === 'E409' && + stdoutData.error?.summary?.includes( + 'this package is already present' )) ) { console.warn( @@ -123,6 +130,11 @@ export default async function runExecutor( if (stdoutData.error.detail) { console.error(stdoutData.error.detail); } + + if (context.isVerbose) { + console.error('npm publish stdout:'); + console.error(JSON.stringify(stdoutData, null, 2)); + } return { success: false, };