| 1 | #!/usr/bin/env node |
| 2 | |
| 3 | 'use strict'; |
| 4 | |
| 5 | const commandLineArgs = require('command-line-args'); |
| 6 | const theme = require('../theme'); |
| 7 | |
| 8 | const paramDefinitions = [ |
| 9 | { |
| 10 | name: 'build', |
| 11 | type: String, |
| 12 | description: |
| 13 | 'CI build ID corresponding to the "process_artifacts_combined" task.', |
| 14 | defaultValue: null, |
| 15 | }, |
| 16 | { |
| 17 | name: 'commit', |
| 18 | type: String, |
| 19 | description: |
| 20 | 'GitHub commit SHA. When provided, automatically finds corresponding CI build.', |
| 21 | defaultValue: null, |
| 22 | }, |
| 23 | { |
| 24 | name: 'skipTests', |
| 25 | type: Boolean, |
| 26 | description: 'Skip automated fixture tests.', |
| 27 | defaultValue: false, |
| 28 | }, |
| 29 | { |
| 30 | name: 'releaseChannel', |
| 31 | alias: 'r', |
| 32 | type: String, |
| 33 | description: 'Release channel (stable, experimental, or latest)', |
| 34 | }, |
| 35 | { |
| 36 | name: 'allowBrokenCI', |
| 37 | type: Boolean, |
| 38 | description: |
| 39 | 'Continue even if CI is failing. Useful if you need to debug a broken build.', |
| 40 | defaultValue: false, |
| 41 | }, |
| 42 | ]; |
| 43 | |
| 44 | module.exports = async () => { |
| 45 | const params = commandLineArgs(paramDefinitions); |
| 46 | |
| 47 | const channel = params.releaseChannel; |
| 48 | if ( |
| 49 | channel !== 'experimental' && |
| 50 | channel !== 'stable' && |
| 51 | channel !== 'rc' && |
| 52 | channel !== 'latest' |
| 53 | ) { |
| 54 | console.error( |
| 55 | theme.error`Invalid release channel (-r) "${channel}". Must be "stable", "experimental", "rc", or "latest".` |
| 56 | ); |
| 57 | process.exit(1); |
| 58 | } |
| 59 | |
| 60 | if (params.commit === null) { |
| 61 | console.error(theme.error`A --commit param must be specified.`); |
| 62 | process.exit(1); |
| 63 | } |
| 64 | |
| 65 | return params; |
| 66 | }; |