@@ -29857,10 +29857,10 @@ class GpgCli {
2985729857 }
2985829858 }
2985929859 async import(ascPath) {
29860- await execOutput(this.name, ['--import', ascPath]);
29860+ await execOutput(this.name, ['--import', ascPath], { silent: false, failOnStdErr: false } );
2986129861 }
2986229862 async verify(sigPath, binPath) {
29863- await execOutput(this.name, ['--verify', sigPath, binPath]);
29863+ await execOutput(this.name, ['--verify', sigPath, binPath], { silent: false, failOnStdErr: false } );
2986429864 }
2986529865 async help() {
2986629866 const { stdout } = await execOutput(this.name, ['--help']);
@@ -29914,6 +29914,10 @@ class TrdlCli {
2991429914 const { stdout } = await execOutput(this.name, ['list']);
2991529915 return stdout.slice(1).map(parseLineToItem);
2991629916 }
29917+ async version() {
29918+ const { stdout } = await execOutput(this.name, ['version'], { silent: false });
29919+ return stdout.join('');
29920+ }
2991729921}
2991829922function parseLineToItem(line) {
2991929923 const [name, url, default_, channel] = line.trim().split(/ +/);
@@ -29998,27 +30002,29 @@ async function downloadParallel(binUrl, sigUrl, ascUrl) {
2999830002function findTrdlCache(toolName, toolVersion) {
2999930003 return toolCacheExports.find(toolName, toolVersion);
3000030004}
30001- async function installTrdl(toolName, toolVersion, binPath ) {
30005+ async function installTrdl(binPath, toolName, toolVersion ) {
3000230006 // install tool
30003- const installedPath = await toolCacheExports.cacheFile(binPath, toolName, toolName, toolVersion);
30007+ const cachedPath = await toolCacheExports.cacheFile(binPath, toolName, format('%s%s', toolName, toolVersion), toolVersion);
30008+ coreExports.info(format('cached path=%s', cachedPath));
3000430009 // set permissions
30005- chmodSync(installedPath , 0o755);
30010+ chmodSync(cachedPath , 0o755);
3000630011 // add tool to $PATH
30007- coreExports.addPath(installedPath );
30012+ coreExports.addPath(cachedPath );
3000830013}
3000930014async function Run() {
30015+ coreExports.setCommandEcho(coreExports.isDebug());
3001030016 const trdlCli = new TrdlCli();
3001130017 const gpgCli = new GpgCli();
3001230018 const inputs = parseInputs();
3001330019 await Do(trdlCli, gpgCli, inputs);
3001430020}
3001530021async function Do(trdlCli, gpgCli, inputs) {
3001630022 coreExports.startGroup('Install or self-update trdl.');
30017- coreExports.debug (format(`parsed inputs=%o`, inputs));
30023+ coreExports.info (format(`parsed inputs=%o`, inputs));
3001830024 const defaults = trdlCli.defaults();
30019- coreExports.debug (format(`trdl defaults=%o`, defaults));
30025+ coreExports.info (format(`trdl defaults=%o`, defaults));
3002030026 const options = await getOptions(inputs, defaults);
30021- coreExports.debug (format(`installation options=%o`, options));
30027+ coreExports.info (format(`installation options=%o`, options));
3002230028 const toolCache = findTrdlCache(defaults.repo, options.version);
3002330029 if (toolCache) {
3002430030 coreExports.info(`Installation skipped. trdl@v${options.version} is found at path ${toolCache}.`);
@@ -30030,16 +30036,22 @@ async function Do(trdlCli, gpgCli, inputs) {
3003030036 }
3003130037 await gpgCli.mustGnuGP();
3003230038 const [binUrl, sigUrl, ascUrl] = formatDownloadUrls(options.version);
30033- coreExports.debug (format('%s bin_url =%s', defaults.repo, binUrl));
30034- coreExports.debug (format('%s sig_url =%s', defaults.repo, sigUrl));
30035- coreExports.debug (format('%s asc_url =%s', defaults.repo, ascUrl));
30036- coreExports.info('Downloading signatures.');
30039+ coreExports.info (format('%s binUrl =%s', defaults.repo, binUrl));
30040+ coreExports.info (format('%s sigUrl =%s', defaults.repo, sigUrl));
30041+ coreExports.info (format('%s ascUrl =%s', defaults.repo, ascUrl));
30042+ coreExports.info('Downloading binary and signatures.');
3003730043 const [binPath, sigPath, ascPath] = await downloadParallel(binUrl, sigUrl, ascUrl);
30044+ coreExports.info(format('%s binPath=%s', defaults.repo, binPath));
30045+ coreExports.info(format('%s sigPath=%s', defaults.repo, sigPath));
30046+ coreExports.info(format('%s ascPath=%s', defaults.repo, ascPath));
3003830047 coreExports.info('Importing and verifying gpg keys.');
3003930048 await gpgCli.import(ascPath);
3004030049 await gpgCli.verify(sigPath, binPath);
3004130050 coreExports.info('Installing trdl and adding it to the $PATH.');
30042- await installTrdl(defaults.repo, options.version, binPath);
30051+ await installTrdl(binPath, defaults.repo, options.version);
30052+ coreExports.info('Showing installed version.');
30053+ const version = await trdlCli.version();
30054+ coreExports.info(format('Installed version: trdl@%s', version));
3004330055 coreExports.endGroup();
3004430056}
3004530057
0 commit comments