Skip to content

Commit

Permalink
[release] Update publishing scripts to make publishing allowlisted pa…
Browse files Browse the repository at this point in the history
…ckages 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.
  • Loading branch information
poteto authored Feb 27, 2025
1 parent ebc22ef commit 2df9622
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ const paramDefinitions = [
'Skip NPM and use the build already present in "build/node_modules".',
defaultValue: false,
},
{
name: 'onlyPackages',
type: String,
multiple: true,
description: 'Packages to include in publishing',
defaultValue: [],
},
{
name: 'skipPackages',
type: String,
Expand Down
3 changes: 3 additions & 0 deletions scripts/release/prepare-release-from-npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ const run = async () => {

params.packages = await getPublicPackages(isExperimental);
params.packages = params.packages.filter(packageName => {
if (params.onlyPackages.length > 0) {
return params.onlyPackages.includes(packageName);
}
return !params.skipPackages.includes(packageName);
});

Expand Down
12 changes: 12 additions & 0 deletions scripts/release/publish-commands/parse-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ const paramDefinitions = [
description: 'NPM tags to point to the new release.',
defaultValue: ['untagged'],
},
{
name: 'onlyPackages',
type: String,
multiple: true,
description: 'Packages to include in publishing',
defaultValue: [],
},
{
name: 'skipPackages',
type: String,
Expand All @@ -32,6 +39,11 @@ const paramDefinitions = [
description: 'Run in automated environment, without interactive prompts.',
defaultValue: false,
},
{
name: 'publishVersion',
type: String,
description: 'Version to publish',
},
];

module.exports = () => {
Expand Down
12 changes: 9 additions & 3 deletions scripts/release/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,20 @@ const run = async () => {
try {
const params = parseParams();

const version = readJsonSync(
'./build/node_modules/react/package.json'
).version;
const version =
params.publishVersion ??
readJsonSync('./build/node_modules/react/package.json').version;
const isExperimental = version.includes('experimental');

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

if (params.onlyPackages.length > 0) {
params.packages = params.packages.filter(packageName => {
return params.onlyPackages.includes(packageName);
});
}

// 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.
params.skipPackages.forEach(packageName => {
Expand Down

0 comments on commit 2df9622

Please sign in to comment.