From 3287014ee9d0028d2276fac5144145d06e515fe3 Mon Sep 17 00:00:00 2001 From: Blake Friedman Date: Thu, 21 Nov 2024 22:36:35 +0000 Subject: [PATCH] [LOCAL] fix GHA publishTemplate verification --- .../__tests__/publishTemplate-test.js | 11 +++++++++++ .github/workflow-scripts/publishTemplate.js | 5 +++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflow-scripts/__tests__/publishTemplate-test.js b/.github/workflow-scripts/__tests__/publishTemplate-test.js index a956b922b7e..a3d7ab80f91 100644 --- a/.github/workflow-scripts/__tests__/publishTemplate-test.js +++ b/.github/workflow-scripts/__tests__/publishTemplate-test.js @@ -80,6 +80,17 @@ describe('#publishTemplate', () => { describe('#verifyPublishedTemplate', () => { beforeEach(jest.clearAllMocks); + it("fixes versions prefixed with 'v'", async () => { + const dirtyVersion = 'v0.76.0'; + const cleanVersion = '0.76.0'; + await verifyPublishedTemplate(dirtyVersion); + + expect(mockGetNpmPackageInfo).toHaveBeenLastCalledWith( + '@react-native-community/template', + cleanVersion, + ); + }); + it("waits on npm updating for version and not 'latest'", async () => { const NOT_LATEST = false; mockGetNpmPackageInfo diff --git a/.github/workflow-scripts/publishTemplate.js b/.github/workflow-scripts/publishTemplate.js index b0c8946b679..ec7e73d8cde 100644 --- a/.github/workflow-scripts/publishTemplate.js +++ b/.github/workflow-scripts/publishTemplate.js @@ -68,6 +68,7 @@ module.exports.verifyPublishedTemplate = async ( latest = false, retries = MAX_RETRIES, ) => { + version = version.replace(/^v/, ''); log(`🔍 Is ${TEMPLATE_NPM_PKG}@${version} on npm?`); let count = retries; @@ -82,11 +83,11 @@ module.exports.verifyPublishedTemplate = async ( return; } if (json.version === version) { - log(`🎉 ${TEMPLATE_NPM_PKG}@latest → ${version} on npm`); + log(`🎉 ${TEMPLATE_NPM_PKG}@latest → ${json.version} on npm`); return; } log( - `🐌 ${TEMPLATE_NPM_PKG}@latest → ${pkg.version} on npm and not ${version} as expected, retrying...`, + `🐌 ${TEMPLATE_NPM_PKG}@latest → ${json.version} on npm and not ${version} as expected, retrying...`, ); } catch (e) { log(`Nope, fetch failed: ${e.message}`);