react/scripts/release/publish-commands/parse-params.js
Andrew Clark 3be750eee9
Add --ci option to publish script (#20727)
When running in CI, the publish script will skip interactive prompts,
including the prompt for a one-time password.

Instead, CI will need to use an automation access token:
https://docs.npmjs.com/using-private-packages-in-a-ci-cd-workflow
2021-02-03 12:17:40 -08:00

56 lines
1.2 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: '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,
},
];
module.exports = () => {
const params = commandLineArgs(paramDefinitions);
splitCommaParams(params.skipPackages);
splitCommaParams(params.tags);
params.tags.forEach(tag => {
switch (tag) {
case 'latest':
case 'next':
case 'experimental':
case 'untagged':
break;
default:
console.error('Unsupported tag: "' + tag + '"');
process.exit(1);
break;
}
});
return params;
};