diff --git a/scripts/release/build-release-locally-commands/add-build-info-json.js b/scripts/release/build-release-locally-commands/add-build-info-json.js index 10ff6df371fec..5bae291953512 100644 --- a/scripts/release/build-release-locally-commands/add-build-info-json.js +++ b/scripts/release/build-release-locally-commands/add-build-info-json.js @@ -12,7 +12,8 @@ const {getPublicPackages, logPromise} = require('../utils'); const theme = require('../theme'); const run = async ({branch, checksum, commit, reactVersion, tempDirectory}) => { - const packages = getPublicPackages(join(tempDirectory, 'packages')); + const isExperimental = reactVersion.includes('experimental'); + const packages = getPublicPackages(isExperimental); const packagesDir = join(tempDirectory, 'packages'); const buildInfoJSON = { diff --git a/scripts/release/ci-add-build-info-json.js b/scripts/release/ci-add-build-info-json.js index de20e6e2aaa3d..92af86946af7d 100755 --- a/scripts/release/ci-add-build-info-json.js +++ b/scripts/release/ci-add-build-info-json.js @@ -27,7 +27,8 @@ const run = async () => { reactVersion, } = await getBuildInfo(); - const packages = getPublicPackages(join(cwd, 'packages')); + const isExperimental = process.env.RELEASE_CHANNEL === 'experimental'; + const packages = getPublicPackages(isExperimental); const packagesDir = join(cwd, 'packages'); const buildInfoJSON = { diff --git a/scripts/release/download-experimental-build.js b/scripts/release/download-experimental-build.js index 2df0459b0df71..97ba2d1bc32af 100755 --- a/scripts/release/download-experimental-build.js +++ b/scripts/release/download-experimental-build.js @@ -15,7 +15,7 @@ const run = async () => { try { const params = parseParams(); params.cwd = join(__dirname, '..', '..'); - params.packages = await getPublicPackages(); + params.packages = await getPublicPackages(true); if (!params.build) { params.build = await getLatestMasterBuildNumber(true); diff --git a/scripts/release/prepare-release-from-ci.js b/scripts/release/prepare-release-from-ci.js index 202054564bb50..f7222ba8ca8a0 100755 --- a/scripts/release/prepare-release-from-ci.js +++ b/scripts/release/prepare-release-from-ci.js @@ -3,6 +3,7 @@ 'use strict'; const {join} = require('path'); +const {readJsonSync} = require('fs-extra'); const {getPublicPackages, handleError} = require('./utils'); const checkEnvironmentVariables = require('./shared-commands/check-environment-variables'); @@ -17,7 +18,6 @@ const run = async () => { try { const params = parseParams(); params.cwd = join(__dirname, '..', '..'); - params.packages = await getPublicPackages(); if (!params.build) { params.build = await getLatestMasterBuildNumber(false); @@ -26,6 +26,11 @@ const run = async () => { await checkEnvironmentVariables(params); await downloadBuildArtifacts(params); + const version = readJsonSync('./build/node_modules/react/package.json') + .version; + const isExperimental = version.includes('experimental'); + params.packages = await getPublicPackages(isExperimental); + if (!params.skipTests) { await testPackagingFixture(params); await testTracingFixture(params); diff --git a/scripts/release/prepare-release-from-npm.js b/scripts/release/prepare-release-from-npm.js index 46a14d9b10692..0b0261b685516 100755 --- a/scripts/release/prepare-release-from-npm.js +++ b/scripts/release/prepare-release-from-npm.js @@ -20,18 +20,21 @@ const run = async () => { try { const params = parseParams(); params.cwd = join(__dirname, '..', '..'); - params.packages = await getPublicPackages(); - // Map of package name to upcoming stable version. - // This Map is initially populated with guesses based on local versions. - // The developer running the release later confirms or overrides each version. - const versionsMap = new Map(); + const isExperimental = params.version.includes('experimental'); if (!params.version) { params.version = await getLatestNextVersion(); } - if (params.version.includes('experimental')) { + params.packages = await getPublicPackages(isExperimental); + + // Map of package name to upcoming stable version. + // This Map is initially populated with guesses based on local versions. + // The developer running the release later confirms or overrides each version. + const versionsMap = new Map(); + + if (isExperimental) { console.error( theme.error`Cannot promote an experimental build to stable.` ); diff --git a/scripts/release/publish.js b/scripts/release/publish.js index 7df86c7b5019a..e51df5c45f8ab 100755 --- a/scripts/release/publish.js +++ b/scripts/release/publish.js @@ -3,6 +3,7 @@ 'use strict'; const {join} = require('path'); +const {readJsonSync} = require('fs-extra'); const {getPublicPackages, handleError} = require('./utils'); const theme = require('./theme'); @@ -20,8 +21,13 @@ const validateSkipPackages = require('./publish-commands/validate-skip-packages' const run = async () => { try { const params = parseParams(); + + const version = readJsonSync('./build/node_modules/react/package.json') + .version; + const isExperimental = version.includes('experimental'); + params.cwd = join(__dirname, '..', '..'); - params.packages = await getPublicPackages(); + params.packages = await getPublicPackages(isExperimental); // Pre-filter any skipped packages to simplify the following commands. // As part of doing this we can also validate that none of the skipped packages were misspelled. diff --git a/scripts/release/utils.js b/scripts/release/utils.js index cb0873d1c77f0..c86f9c886a534 100644 --- a/scripts/release/utils.js +++ b/scripts/release/utils.js @@ -3,7 +3,7 @@ const {exec} = require('child-process-promise'); const {createPatch} = require('diff'); const {hashElement} = require('folder-hash'); -const {readdirSync, readFileSync, statSync, writeFileSync} = require('fs'); +const {readFileSync, writeFileSync} = require('fs'); const {readJson, writeJson} = require('fs-extra'); const http = require('request-promise-json'); const logUpdate = require('log-update'); @@ -12,14 +12,6 @@ const createLogger = require('progress-estimator'); const prompt = require('prompt-promise'); const theme = require('./theme'); -// The following packages are published to NPM but not by this script. -// They are released through a separate process. -const RELEASE_SCRIPT_PACKAGE_SKIPLIST = [ - 'react-devtools', - 'react-devtools-core', - 'react-devtools-inline', -]; - // https://www.npmjs.com/package/progress-estimator#configuration const logger = createLogger({ storagePath: join(__dirname, '.progress-estimator'), @@ -112,31 +104,38 @@ const getChecksumForCurrentRevision = async cwd => { return hashedPackages.hash.slice(0, 7); }; -const getPublicPackages = () => { - const packagesRoot = join(__dirname, '..', '..', 'packages'); - - return readdirSync(packagesRoot).filter(dir => { - if (RELEASE_SCRIPT_PACKAGE_SKIPLIST.includes(dir)) { - return false; - } - - const packagePath = join(packagesRoot, dir, 'package.json'); - - if (dir.charAt(0) !== '.') { - let stat; - try { - stat = statSync(packagePath); - } catch (err) { - return false; - } - if (stat.isFile()) { - const packageJSON = JSON.parse(readFileSync(packagePath)); - return packageJSON.private !== true; - } - } - - return false; - }); +const getPublicPackages = isExperimental => { + if (isExperimental) { + return [ + 'create-subscription', + 'eslint-plugin-react-hooks', + 'jest-react', + 'react', + 'react-art', + 'react-dom', + 'react-is', + 'react-reconciler', + 'react-refresh', + 'react-test-renderer', + 'use-subscription', + 'scheduler', + ]; + } else { + return [ + 'create-subscription', + 'eslint-plugin-react-hooks', + 'jest-react', + 'react', + 'react-art', + 'react-dom', + 'react-is', + 'react-reconciler', + 'react-refresh', + 'react-test-renderer', + 'use-subscription', + 'scheduler', + ]; + } }; const handleError = error => { @@ -199,7 +198,8 @@ const splitCommaParams = array => { // It is based on the version of React in the local package.json (e.g. 16.12.0-01974a867). // Both numbers will be replaced if the "next" release is promoted to a stable release. const updateVersionsForNext = async (cwd, reactVersion, version) => { - const packages = getPublicPackages(join(cwd, 'packages')); + const isExperimental = reactVersion.includes('experimental'); + const packages = getPublicPackages(isExperimental); const packagesDir = join(cwd, 'packages'); // Update the shared React version source file.