From abad4b045d20f159bfe2a72f07767a449ded37c8 Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Sun, 3 Jul 2022 12:03:21 -0700 Subject: [PATCH] Fix package publishing script 074861623e1b69cb12a6dd84d996a1dadbf79983 changed the workspace configuration with the result that 'react-native-web' appeared twice in the array of workspaces, causing an attempt to republish the package during the release task. --- scripts/releaseReactNativeWebPackages.js | 25 +++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/scripts/releaseReactNativeWebPackages.js b/scripts/releaseReactNativeWebPackages.js index aea9c9d6..c2109fea 100644 --- a/scripts/releaseReactNativeWebPackages.js +++ b/scripts/releaseReactNativeWebPackages.js @@ -18,21 +18,24 @@ const oneTimeCode = argv.otp; console.log(`Publishing react-native-web@${version}`); // Collect 'react-native-web' workspaces and package manifests -const workspacePaths = require('../package.json').workspaces; -const workspaces = workspacePaths.reduce((acc, curr) => { - const packageDirectories = glob.sync(curr); - const subsetOfpackageDirectories = packageDirectories.filter((dir) => { - return dir.includes('react-native-web'); - }); - subsetOfpackageDirectories.forEach((dir) => { - const directory = path.resolve(dir); - const packageJsonPath = path.join(directory, 'package.json'); - const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, { encoding: 'utf-8' })); - acc.push({ directory, packageJson, packageJsonPath }); +const workspacePaths = require('../package.json').workspaces.reduce((acc, w) => { + const resolvedPaths = glob.sync(w); + resolvedPaths.forEach((p) => { + // Remove duplicates and unrelated packages + if (p.includes('react-native-web') && acc.indexOf(p) === -1) { + acc.push(p); + } }); return acc; }, []); +const workspaces = workspacePaths.map((dir) => { + const directory = path.resolve(dir); + const packageJsonPath = path.join(directory, 'package.json'); + const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, { encoding: 'utf-8' })); + return { directory, packageJson, packageJsonPath }; +}); + // Update each package version and its dependencies const workspaceNames = workspaces.map(({ packageJson }) => packageJson.name); workspaces.forEach(({ directory, packageJson, packageJsonPath }) => {