Skip to content

Commit 2df9622

Browse files
authored
[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.
1 parent ebc22ef commit 2df9622

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

scripts/release/prepare-release-from-npm-commands/parse-params.js

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ const paramDefinitions = [
1313
'Skip NPM and use the build already present in "build/node_modules".',
1414
defaultValue: false,
1515
},
16+
{
17+
name: 'onlyPackages',
18+
type: String,
19+
multiple: true,
20+
description: 'Packages to include in publishing',
21+
defaultValue: [],
22+
},
1623
{
1724
name: 'skipPackages',
1825
type: String,

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

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ const run = async () => {
2828

2929
params.packages = await getPublicPackages(isExperimental);
3030
params.packages = params.packages.filter(packageName => {
31+
if (params.onlyPackages.length > 0) {
32+
return params.onlyPackages.includes(packageName);
33+
}
3134
return !params.skipPackages.includes(packageName);
3235
});
3336

scripts/release/publish-commands/parse-params.js

+12
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ const paramDefinitions = [
1919
description: 'NPM tags to point to the new release.',
2020
defaultValue: ['untagged'],
2121
},
22+
{
23+
name: 'onlyPackages',
24+
type: String,
25+
multiple: true,
26+
description: 'Packages to include in publishing',
27+
defaultValue: [],
28+
},
2229
{
2330
name: 'skipPackages',
2431
type: String,
@@ -32,6 +39,11 @@ const paramDefinitions = [
3239
description: 'Run in automated environment, without interactive prompts.',
3340
defaultValue: false,
3441
},
42+
{
43+
name: 'publishVersion',
44+
type: String,
45+
description: 'Version to publish',
46+
},
3547
];
3648

3749
module.exports = () => {

scripts/release/publish.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,20 @@ const run = async () => {
2323
try {
2424
const params = parseParams();
2525

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;
2929
const isExperimental = version.includes('experimental');
3030

3131
params.cwd = join(__dirname, '..', '..');
3232
params.packages = await getPublicPackages(isExperimental);
3333

34+
if (params.onlyPackages.length > 0) {
35+
params.packages = params.packages.filter(packageName => {
36+
return params.onlyPackages.includes(packageName);
37+
});
38+
}
39+
3440
// Pre-filter any skipped packages to simplify the following commands.
3541
// As part of doing this we can also validate that none of the skipped packages were misspelled.
3642
params.skipPackages.forEach(packageName => {

0 commit comments

Comments
 (0)