Files
lauren 2df9622477 [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.
2025-02-27 11:24:30 -05:00

72 lines
1.5 KiB
JavaScript

#!/usr/bin/env node
'use strict';
const commandLineArgs = require('command-line-args');
const {splitCommaParams} = require('../utils');
const paramDefinitions = [
{
name: 'dry',
type: Boolean,
description: 'Dry run command without actually publishing to NPM.',
defaultValue: false,
},
{
name: 'tags',
type: String,
multiple: true,
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,
multiple: true,
description: 'Packages to exclude from publishing',
defaultValue: [],
},
{
name: 'ci',
type: Boolean,
description: 'Run in automated environment, without interactive prompts.',
defaultValue: false,
},
{
name: 'publishVersion',
type: String,
description: 'Version to publish',
},
];
module.exports = () => {
const params = commandLineArgs(paramDefinitions);
splitCommaParams(params.skipPackages);
splitCommaParams(params.tags);
params.tags.forEach(tag => {
switch (tag) {
case 'latest':
case 'canary':
case 'next':
case 'experimental':
case 'alpha':
case 'beta':
case 'rc':
case 'untagged':
break;
default:
console.error('Unsupported tag: "' + tag + '"');
process.exit(1);
break;
}
});
return params;
};