main
js 70 lines 1.5 KB
Raw
1 #!/usr/bin/env node
2
3 'use strict';
4
5 const {join, relative} = require('path');
6 const {handleError} = require('./utils');
7 const yargs = require('yargs');
8 const clear = require('clear');
9 const theme = require('./theme');
10 const {
11 downloadBuildArtifacts,
12 } = require('./shared-commands/download-build-artifacts');
13
14 const argv = yargs.wrap(yargs.terminalWidth()).options({
15 releaseChannel: {
16 alias: 'r',
17 describe: 'Download the given release channel.',
18 requiresArg: true,
19 type: 'string',
20 choices: ['experimental', 'stable'],
21 default: 'experimental',
22 },
23 commit: {
24 alias: 'c',
25 describe: 'Commit hash to download.',
26 requiresArg: true,
27 demandOption: true,
28 type: 'string',
29 },
30 noVerify: {
31 describe: 'Skip verification',
32 requiresArg: false,
33 type: 'boolean',
34 default: false,
35 },
36 }).argv;
37
38 function printSummary(commit) {
39 const commandPath = relative(
40 process.env.PWD,
41 join(__dirname, '../download-experimental-build.js')
42 );
43
44 clear();
45
46 const message = theme`
47 {caution An experimental build has been downloaded!}
48
49 You can download this build again by running:
50 {path ${commandPath}} --commit={commit ${commit}}
51 `;
52
53 console.log(message.replace(/\n +/g, '\n').trim());
54 }
55
56 const main = async () => {
57 const {commit, releaseChannel, noVerify} = argv;
58 try {
59 await downloadBuildArtifacts({
60 commit,
61 releaseChannel,
62 noVerify,
63 });
64 printSummary(argv.commit);
65 } catch (error) {
66 handleError(error);
67 }
68 };
69
70 main();