From 60e1b2974fb74f54ff0e5fb4131bcb6ac90a539c Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Thu, 18 Jul 2024 11:55:51 -0400 Subject: [PATCH] Update [ghstack-poisoned] --- .../download-experimental-build-ghaction.js | 70 ++++++++++++++----- 1 file changed, 54 insertions(+), 16 deletions(-) diff --git a/scripts/release/download-experimental-build-ghaction.js b/scripts/release/download-experimental-build-ghaction.js index c57ec4f1bf664..a8f79d8994515 100755 --- a/scripts/release/download-experimental-build-ghaction.js +++ b/scripts/release/download-experimental-build-ghaction.js @@ -2,28 +2,66 @@ 'use strict'; -const {join} = require('path'); -const { - addDefaultParamValue, - getPublicPackages, - handleError, -} = require('./utils'); +const {join, relative} = require('path'); +const {getPublicPackages, handleError} = require('./utils'); +const yargs = require('yargs'); +const clear = require('clear'); +const theme = require('./theme'); -const downloadBuildArtifacts = require('./shared-commands/download-build-artifacts'); -const parseParams = require('./shared-commands/parse-params'); -const printSummary = require('./download-experimental-build-commands/print-summary'); +const argv = yargs.wrap(yargs.terminalWidth()).options({ + releaseChannel: { + alias: 'r', + describe: 'Download the given release channel.', + requiresArg: true, + type: 'string', + choices: ['experimental', 'stable'], + default: 'experimental', + }, + commit: { + alias: 'c', + describe: 'Commit hash to download.', + requiresArg: true, + type: 'string', + }, + skipTests: { + requiresArg: false, + type: 'boolean', + default: false, + }, + allowBrokenCI: { + requiresArg: false, + type: 'boolean', + default: false, + }, +}).argv; + +// Inlined from scripts/release/download-experimental-build-commands/print-summary.js +function printSummary(commit) { + const commandPath = relative( + process.env.PWD, + join(__dirname, '../download-experimental-build-ghaction.js') + ); + + clear(); + + const message = theme` + {caution An experimental build has been downloaded!} + + You can download this build again by running: + {path ${commandPath}} --commit={commit ${commit}} + `; + + console.log(message.replace(/\n +/g, '\n').trim()); +} const run = async () => { try { - addDefaultParamValue('-r', '--releaseChannel', 'experimental'); - - const params = await parseParams(); - params.cwd = join(__dirname, '..', '..'); - params.packages = await getPublicPackages(true); + argv.cwd = join(__dirname, '..', '..'); + argv.packages = await getPublicPackages(true); - await downloadBuildArtifacts(params); + console.log(argv); - printSummary(params); + printSummary(argv.commit); } catch (error) { handleError(error); }