[release] Update publishing scripts to make publishing allowlisted packages easier (#32486)
It's getting unwieldy to list every single package to skip in these commands when you only want to publish one, ie eslint-plugin-react-hooks. This adds a new `onlyPackages` and `publishVersion` option to the publish commands to make that easier.
lauren committed
Feb 27, 2025 at 11:24 UTC
2df96224779237f532ca64c8c7e8a8605c06f067
4 files changed
+31
-3
scripts/release/prepare-release-from-npm-commands/parse-params.js
+7
@@ -13,6 +13,13 @@ const paramDefinitions = [
13
'Skip NPM and use the build already present in "build/node_modules".',
14
defaultValue: false,
15
},
16
+ {
17
+ name: 'onlyPackages',
18
+ type: String,
19
+ multiple: true,
20
+ description: 'Packages to include in publishing',
21
+ defaultValue: [],
22
+ },
23
{
24
name: 'skipPackages',
25
type: String,
scripts/release/prepare-release-from-npm.js
+3
@@ -28,6 +28,9 @@ const run = async () => {
28
29
params.packages = await getPublicPackages(isExperimental);
30
params.packages = params.packages.filter(packageName => {
31
+ if (params.onlyPackages.length > 0) {
32
+ return params.onlyPackages.includes(packageName);
33
+ }
34
return !params.skipPackages.includes(packageName);
35
});
36
scripts/release/publish-commands/parse-params.js
+12
@@ -19,6 +19,13 @@ const paramDefinitions = [
19
description: 'NPM tags to point to the new release.',
20
defaultValue: ['untagged'],
21
},
22
+ {
23
+ name: 'onlyPackages',
24
+ type: String,
25
+ multiple: true,
26
+ description: 'Packages to include in publishing',
27
+ defaultValue: [],
28
+ },
29
{
30
name: 'skipPackages',
31
type: String,
@@ -32,6 +39,11 @@ const paramDefinitions = [
39
description: 'Run in automated environment, without interactive prompts.',
40
defaultValue: false,
41
},
42
+ {
43
+ name: 'publishVersion',
44
+ type: String,
45
+ description: 'Version to publish',
46
+ },
47
];
48
49
module.exports = () => {
scripts/release/publish.js
+9
-3
@@ -23,14 +23,20 @@ const run = async () => {
23
try {
24
const params = parseParams();
25
26
- const version = readJsonSync(
27
- './build/node_modules/react/package.json'
28
- ).version;
26
+ const version =
27
+ params.publishVersion ??
28
+ readJsonSync('./build/node_modules/react/package.json').version;
29
const isExperimental = version.includes('experimental');
30
31
params.cwd = join(__dirname, '..', '..');
32
params.packages = await getPublicPackages(isExperimental);
33
34
+ if (params.onlyPackages.length > 0) {
35
+ params.packages = params.packages.filter(packageName => {
36
+ return params.onlyPackages.includes(packageName);
37
+ });
38
+ }
39
+
40
// Pre-filter any skipped packages to simplify the following commands.
41
// As part of doing this we can also validate that none of the skipped packages were misspelled.
42
params.skipPackages.forEach(packageName => {