2018-11-24 04:37:18 +08:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
const commandLineArgs = require('command-line-args');
|
2021-05-07 20:53:39 +08:00
|
|
|
const getBuildIdForCommit = require('./get-build-id-for-commit');
|
2021-02-04 00:11:56 +08:00
|
|
|
const theme = require('../theme');
|
2021-05-07 20:53:39 +08:00
|
|
|
const {logPromise} = require('../utils');
|
2018-11-24 04:37:18 +08:00
|
|
|
|
|
|
|
|
const paramDefinitions = [
|
2021-05-07 20:53:39 +08:00
|
|
|
{
|
|
|
|
|
name: 'build',
|
|
|
|
|
type: String,
|
|
|
|
|
description:
|
|
|
|
|
'CI build ID corresponding to the "process_artifacts_combined" task.',
|
|
|
|
|
defaultValue: null,
|
|
|
|
|
},
|
2021-02-02 00:27:59 +08:00
|
|
|
{
|
|
|
|
|
name: 'commit',
|
|
|
|
|
type: String,
|
|
|
|
|
description:
|
|
|
|
|
'GitHub commit SHA. When provided, automatically finds corresponding CI build.',
|
|
|
|
|
defaultValue: null,
|
2018-11-24 04:37:18 +08:00
|
|
|
},
|
2018-12-03 03:25:45 +08:00
|
|
|
{
|
|
|
|
|
name: 'skipTests',
|
|
|
|
|
type: Boolean,
|
|
|
|
|
description: 'Skip automated fixture tests.',
|
|
|
|
|
defaultValue: false,
|
|
|
|
|
},
|
2021-01-15 01:20:20 +08:00
|
|
|
{
|
|
|
|
|
name: 'releaseChannel',
|
|
|
|
|
alias: 'r',
|
|
|
|
|
type: String,
|
2021-06-04 02:00:08 +08:00
|
|
|
description: 'Release channel (stable, experimental, or latest)',
|
2021-01-15 01:20:20 +08:00
|
|
|
},
|
2022-06-03 09:55:35 +08:00
|
|
|
{
|
|
|
|
|
name: 'allowBrokenCI',
|
|
|
|
|
type: Boolean,
|
|
|
|
|
description:
|
|
|
|
|
'Continue even if CI is failing. Useful if you need to debug a broken build.',
|
|
|
|
|
defaultValue: false,
|
|
|
|
|
},
|
2018-11-24 04:37:18 +08:00
|
|
|
];
|
|
|
|
|
|
2021-02-02 00:27:59 +08:00
|
|
|
module.exports = async () => {
|
2018-11-24 04:37:18 +08:00
|
|
|
const params = commandLineArgs(paramDefinitions);
|
|
|
|
|
|
2021-01-15 01:20:20 +08:00
|
|
|
const channel = params.releaseChannel;
|
2021-06-04 02:00:08 +08:00
|
|
|
if (
|
|
|
|
|
channel !== 'experimental' &&
|
|
|
|
|
channel !== 'stable' &&
|
|
|
|
|
channel !== 'latest'
|
|
|
|
|
) {
|
2021-01-15 01:20:20 +08:00
|
|
|
console.error(
|
2021-06-04 02:00:08 +08:00
|
|
|
theme.error`Invalid release channel (-r) "${channel}". Must be "stable", "experimental", or "latest".`
|
2021-01-15 01:20:20 +08:00
|
|
|
);
|
|
|
|
|
process.exit(1);
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-07 20:53:39 +08:00
|
|
|
if (params.build === null && params.commit === null) {
|
|
|
|
|
console.error(
|
|
|
|
|
theme.error`Either a --commit or --build param must be specified.`
|
|
|
|
|
);
|
2021-02-04 00:11:56 +08:00
|
|
|
process.exit(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
2021-05-07 20:53:39 +08:00
|
|
|
if (params.build === null) {
|
|
|
|
|
params.build = await logPromise(
|
2022-06-03 09:55:35 +08:00
|
|
|
getBuildIdForCommit(params.commit, params.allowBrokenCI),
|
2021-05-07 20:53:39 +08:00
|
|
|
theme`Getting build ID for commit "${params.commit}"`
|
|
|
|
|
);
|
|
|
|
|
}
|
2021-02-04 00:11:56 +08:00
|
|
|
} catch (error) {
|
|
|
|
|
console.error(theme.error(error));
|
|
|
|
|
process.exit(1);
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-24 04:37:18 +08:00
|
|
|
return params;
|
|
|
|
|
};
|