Files
react/scripts/release/shared-commands/parse-params.js
Andrew Clark f8b6969da6 Add --commit param to release scripts (#20703)
Alternative to `--build`. Uses same logic as sizebot and www
sync script.

Immediate motivation is I want sizebot to use the
`download-experimental-build` command in CI. Will do that next.
2021-02-01 08:27:59 -08:00

70 lines
1.6 KiB
JavaScript

#!/usr/bin/env node
'use strict';
const commandLineArgs = require('command-line-args');
const getBuildIdForCommit = require('../get-build-id-for-commit');
const paramDefinitions = [
{
name: 'build',
type: Number,
description:
'Circle CI build identifier (e.g. https://circleci.com/gh/facebook/react/<build>)',
defaultValue: null,
},
{
name: 'commit',
type: String,
description:
'GitHub commit SHA. When provided, automatically finds corresponding CI build.',
defaultValue: null,
},
{
name: 'skipTests',
type: Boolean,
description: 'Skip automated fixture tests.',
defaultValue: false,
},
{
name: 'releaseChannel',
alias: 'r',
type: String,
description: 'Release channel (stable or experimental)',
},
];
module.exports = async () => {
const params = commandLineArgs(paramDefinitions);
if (params.build !== null) {
if (params.commit !== null) {
console.error(
'`build` and `commmit` params are mutually exclusive. Choose one or the other.`'
);
process.exit(1);
}
} else {
if (params.commit === null) {
console.error('Must provide either `build` or `commit`.');
process.exit(1);
}
try {
params.build = await getBuildIdForCommit(params.commit);
} catch (error) {
console.error(error.message);
process.exit(1);
}
}
const channel = params.releaseChannel;
if (channel !== 'experimental' && channel !== 'stable') {
console.error(
`Invalid release channel (-r) "${channel}". Must be "stable" or "experimental".`
);
process.exit(1);
}
return params;
};