Skip to content

Commit 1bda600

Browse files
authored
Hardcoded allowlist for publishing packages (facebook#20485)
With separate lists for stable and experimental.
1 parent efc57e5 commit 1bda600

File tree

7 files changed

+62
-46
lines changed

7 files changed

+62
-46
lines changed

scripts/release/build-release-locally-commands/add-build-info-json.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ const {getPublicPackages, logPromise} = require('../utils');
1212
const theme = require('../theme');
1313

1414
const run = async ({branch, checksum, commit, reactVersion, tempDirectory}) => {
15-
const packages = getPublicPackages(join(tempDirectory, 'packages'));
15+
const isExperimental = reactVersion.includes('experimental');
16+
const packages = getPublicPackages(isExperimental);
1617
const packagesDir = join(tempDirectory, 'packages');
1718

1819
const buildInfoJSON = {

scripts/release/ci-add-build-info-json.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ const run = async () => {
2727
reactVersion,
2828
} = await getBuildInfo();
2929

30-
const packages = getPublicPackages(join(cwd, 'packages'));
30+
const isExperimental = process.env.RELEASE_CHANNEL === 'experimental';
31+
const packages = getPublicPackages(isExperimental);
3132
const packagesDir = join(cwd, 'packages');
3233

3334
const buildInfoJSON = {

scripts/release/download-experimental-build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const run = async () => {
1515
try {
1616
const params = parseParams();
1717
params.cwd = join(__dirname, '..', '..');
18-
params.packages = await getPublicPackages();
18+
params.packages = await getPublicPackages(true);
1919

2020
if (!params.build) {
2121
params.build = await getLatestMasterBuildNumber(true);

scripts/release/prepare-release-from-ci.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
'use strict';
44

55
const {join} = require('path');
6+
const {readJsonSync} = require('fs-extra');
67
const {getPublicPackages, handleError} = require('./utils');
78

89
const checkEnvironmentVariables = require('./shared-commands/check-environment-variables');
@@ -17,7 +18,6 @@ const run = async () => {
1718
try {
1819
const params = parseParams();
1920
params.cwd = join(__dirname, '..', '..');
20-
params.packages = await getPublicPackages();
2121

2222
if (!params.build) {
2323
params.build = await getLatestMasterBuildNumber(false);
@@ -26,6 +26,11 @@ const run = async () => {
2626
await checkEnvironmentVariables(params);
2727
await downloadBuildArtifacts(params);
2828

29+
const version = readJsonSync('./build/node_modules/react/package.json')
30+
.version;
31+
const isExperimental = version.includes('experimental');
32+
params.packages = await getPublicPackages(isExperimental);
33+
2934
if (!params.skipTests) {
3035
await testPackagingFixture(params);
3136
await testTracingFixture(params);

scripts/release/prepare-release-from-npm.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,21 @@ const run = async () => {
2020
try {
2121
const params = parseParams();
2222
params.cwd = join(__dirname, '..', '..');
23-
params.packages = await getPublicPackages();
2423

25-
// Map of package name to upcoming stable version.
26-
// This Map is initially populated with guesses based on local versions.
27-
// The developer running the release later confirms or overrides each version.
28-
const versionsMap = new Map();
24+
const isExperimental = params.version.includes('experimental');
2925

3026
if (!params.version) {
3127
params.version = await getLatestNextVersion();
3228
}
3329

34-
if (params.version.includes('experimental')) {
30+
params.packages = await getPublicPackages(isExperimental);
31+
32+
// Map of package name to upcoming stable version.
33+
// This Map is initially populated with guesses based on local versions.
34+
// The developer running the release later confirms or overrides each version.
35+
const versionsMap = new Map();
36+
37+
if (isExperimental) {
3538
console.error(
3639
theme.error`Cannot promote an experimental build to stable.`
3740
);

scripts/release/publish.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
'use strict';
44

55
const {join} = require('path');
6+
const {readJsonSync} = require('fs-extra');
67
const {getPublicPackages, handleError} = require('./utils');
78
const theme = require('./theme');
89

@@ -20,8 +21,13 @@ const validateSkipPackages = require('./publish-commands/validate-skip-packages'
2021
const run = async () => {
2122
try {
2223
const params = parseParams();
24+
25+
const version = readJsonSync('./build/node_modules/react/package.json')
26+
.version;
27+
const isExperimental = version.includes('experimental');
28+
2329
params.cwd = join(__dirname, '..', '..');
24-
params.packages = await getPublicPackages();
30+
params.packages = await getPublicPackages(isExperimental);
2531

2632
// Pre-filter any skipped packages to simplify the following commands.
2733
// As part of doing this we can also validate that none of the skipped packages were misspelled.

scripts/release/utils.js

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const {exec} = require('child-process-promise');
44
const {createPatch} = require('diff');
55
const {hashElement} = require('folder-hash');
6-
const {readdirSync, readFileSync, statSync, writeFileSync} = require('fs');
6+
const {readFileSync, writeFileSync} = require('fs');
77
const {readJson, writeJson} = require('fs-extra');
88
const http = require('request-promise-json');
99
const logUpdate = require('log-update');
@@ -12,14 +12,6 @@ const createLogger = require('progress-estimator');
1212
const prompt = require('prompt-promise');
1313
const theme = require('./theme');
1414

15-
// The following packages are published to NPM but not by this script.
16-
// They are released through a separate process.
17-
const RELEASE_SCRIPT_PACKAGE_SKIPLIST = [
18-
'react-devtools',
19-
'react-devtools-core',
20-
'react-devtools-inline',
21-
];
22-
2315
// https://www.npmjs.com/package/progress-estimator#configuration
2416
const logger = createLogger({
2517
storagePath: join(__dirname, '.progress-estimator'),
@@ -112,31 +104,38 @@ const getChecksumForCurrentRevision = async cwd => {
112104
return hashedPackages.hash.slice(0, 7);
113105
};
114106

115-
const getPublicPackages = () => {
116-
const packagesRoot = join(__dirname, '..', '..', 'packages');
117-
118-
return readdirSync(packagesRoot).filter(dir => {
119-
if (RELEASE_SCRIPT_PACKAGE_SKIPLIST.includes(dir)) {
120-
return false;
121-
}
122-
123-
const packagePath = join(packagesRoot, dir, 'package.json');
124-
125-
if (dir.charAt(0) !== '.') {
126-
let stat;
127-
try {
128-
stat = statSync(packagePath);
129-
} catch (err) {
130-
return false;
131-
}
132-
if (stat.isFile()) {
133-
const packageJSON = JSON.parse(readFileSync(packagePath));
134-
return packageJSON.private !== true;
135-
}
136-
}
137-
138-
return false;
139-
});
107+
const getPublicPackages = isExperimental => {
108+
if (isExperimental) {
109+
return [
110+
'create-subscription',
111+
'eslint-plugin-react-hooks',
112+
'jest-react',
113+
'react',
114+
'react-art',
115+
'react-dom',
116+
'react-is',
117+
'react-reconciler',
118+
'react-refresh',
119+
'react-test-renderer',
120+
'use-subscription',
121+
'scheduler',
122+
];
123+
} else {
124+
return [
125+
'create-subscription',
126+
'eslint-plugin-react-hooks',
127+
'jest-react',
128+
'react',
129+
'react-art',
130+
'react-dom',
131+
'react-is',
132+
'react-reconciler',
133+
'react-refresh',
134+
'react-test-renderer',
135+
'use-subscription',
136+
'scheduler',
137+
];
138+
}
140139
};
141140

142141
const handleError = error => {
@@ -199,7 +198,8 @@ const splitCommaParams = array => {
199198
// It is based on the version of React in the local package.json (e.g. 16.12.0-01974a867).
200199
// Both numbers will be replaced if the "next" release is promoted to a stable release.
201200
const updateVersionsForNext = async (cwd, reactVersion, version) => {
202-
const packages = getPublicPackages(join(cwd, 'packages'));
201+
const isExperimental = reactVersion.includes('experimental');
202+
const packages = getPublicPackages(isExperimental);
203203
const packagesDir = join(cwd, 'packages');
204204

205205
// Update the shared React version source file.

0 commit comments

Comments
 (0)