@@ -27303,7 +27303,7 @@ function getUpdateArgs(presetVal) {
2730327303function parsePresetInput() {
2730427304 const p = coreExports.getInput('preset') || preset.unknown;
2730527305 if (!(p in preset)) {
27306- throw new Error(`preset "${p}" not found. Available presets: ${Object.values(preset).join(' , ')}`);
27306+ throw new Error(`preset "${p}" not found. Available presets: ${Object.values(preset).join(', ')}`);
2730727307 }
2730827308 return p;
2730927309}
@@ -27336,14 +27336,6 @@ async function execOutput(commandLine, args, options) {
2733627336 };
2733727337}
2733827338
27339- // optional array element
27340- function optionalToArray(arg) {
27341- return arg ? [arg] : [];
27342- }
27343- function optionalToObject(key, value) {
27344- return value ? { [key]: value } : {};
27345- }
27346-
2734727339class TrdlCli {
2734827340 name;
2734927341 constructor() {
@@ -27371,15 +27363,17 @@ class TrdlCli {
2737127363 async update(args, opts) {
2737227364 const { repo, group, channel } = args;
2737327365 const env = { ...process.env, ...(opts && toUpdateEnvs(opts)) };
27374- await execOutput(this.name, ['update', repo, group, ...optionalToArray(channel)], { env });
27366+ const channelOpt = channel !== undefined ? [channel] : []; // optional field
27367+ await execOutput(this.name, ['update', repo, group, ...channelOpt], { env });
2737527368 }
2737627369 async binPath(args) {
2737727370 const { repo, group, channel } = args;
2737827371 const execOpts = {
2737927372 failOnStdErr: false,
2738027373 ignoreReturnCode: true
2738127374 };
27382- const { stdout } = await execOutput(this.name, ['bin-path', repo, group, ...optionalToArray(channel)], execOpts);
27375+ const channelOpt = channel !== undefined ? [channel] : []; // optional field
27376+ const { stdout } = await execOutput(this.name, ['bin-path', repo, group, ...channelOpt], execOpts);
2738327377 return stdout.join('');
2738427378 }
2738527379 async list() {
@@ -27388,22 +27382,46 @@ class TrdlCli {
2738827382 }
2738927383}
2739027384function parseLineToItem(line) {
27391- const [name, url, default_, channel] = line.split(/ +/);
27385+ const [name, url, default_, channel] = line.trim(). split(/ +/);
2739227386 return {
2739327387 name,
2739427388 url,
2739527389 default: default_,
27396- channel
27390+ ...( channel !== undefined ? { channel } : {}) // optional field
2739727391 };
2739827392}
2739927393function toUpdateEnvs(opts) {
2740027394 const env = {};
27401- if (opts?.inBackground) {
27395+ // eslint-disable-next-line no-prototype-builtins
27396+ if (opts.hasOwnProperty('inBackground')) {
2740227397 env['TRDL_IN_BACKGROUND'] = String(opts.inBackground);
2740327398 }
2740427399 return env;
2740527400}
2740627401
27402+ class GpgCli {
27403+ name;
27404+ constructor() {
27405+ this.name = 'gpg';
27406+ }
27407+ async mustGnuGP() {
27408+ const help = await this.help();
27409+ if (!help.includes('GnuPG')) {
27410+ throw new Error('gpg is not GnuPG. Please install GnuPG');
27411+ }
27412+ }
27413+ async import(ascPath) {
27414+ await execOutput(this.name, ['--import', ascPath]);
27415+ }
27416+ async verify(sigPath, binPath) {
27417+ await execOutput(this.name, ['--verify', sigPath, binPath]);
27418+ }
27419+ async help() {
27420+ const { stdout } = await execOutput(this.name, ['--help']);
27421+ return stdout.join('\n');
27422+ }
27423+ }
27424+
2740727425var libExports = requireLib();
2740827426
2740927427var toolCache = {};
@@ -29976,38 +29994,15 @@ function requireToolCache () {
2997629994
2997729995var toolCacheExports = requireToolCache();
2997829996
29979- class GpgCli {
29980- name;
29981- constructor() {
29982- this.name = 'gpg';
29983- }
29984- async mustGnuGP() {
29985- const help = await this.help();
29986- if (!help.includes('GnuPG')) {
29987- throw new Error('gpg is not GnuPG. Please install GnuPG');
29988- }
29989- }
29990- async import(ascPath) {
29991- await execOutput(this.name, ['--import', ascPath]);
29992- }
29993- async verify(sigPath, binPath) {
29994- await execOutput(this.name, ['--verify', sigPath, binPath]);
29995- }
29996- async help() {
29997- const { stdout } = await execOutput(this.name, ['--help']);
29998- return stdout.join('');
29999- }
30000- }
30001-
3000229997async function fetchVersion(group, channel) {
3000329998 const client = new libExports.HttpClient();
3000429999 const resp = await client.get(`https://tuf.trdl.dev/targets/channels/${group}/${channel}`);
3000530000 const version = await resp.readBody();
3000630001 return version.trim();
3000730002}
3000830003async function getOptions(inputs, defaults) {
30009- const channel = inputs? .channel || defaults.channel;
30010- const version = inputs? .version || await fetchVersion(defaults.group, defaults.channel); // prettier-ignore
30004+ const channel = inputs.channel ?? defaults.channel;
30005+ const version = inputs.version ?? await fetchVersion(defaults.group, defaults.channel); // prettier-ignore
3001130006 return {
3001230007 channel,
3001330008 version
@@ -30064,7 +30059,7 @@ async function installTrdl(toolName, toolVersion, binPath) {
3006430059 // add tool to $PATH
3006530060 coreExports.addPath(installedPath);
3006630061}
30067- async function Do$2(trdlCli, inputs) {
30062+ async function Do$2(trdlCli, gpgCli, inputs) {
3006830063 coreExports.startGroup('Install or self-update trdl.');
3006930064 coreExports.debug(format(`parsed inputs=%o`, inputs));
3007030065 const defaults = trdlCli.defaults();
@@ -30080,7 +30075,6 @@ async function Do$2(trdlCli, inputs) {
3008030075 coreExports.endGroup();
3008130076 return;
3008230077 }
30083- const gpgCli = new GpgCli();
3008430078 await gpgCli.mustGnuGP();
3008530079 const [binUrl, sigUrl, ascUrl] = formatDownloadUrls(options.version);
3008630080 coreExports.debug(format('%s bin_url=%s', defaults.repo, binUrl));
@@ -30098,7 +30092,7 @@ async function Do$2(trdlCli, inputs) {
3009830092
3009930093function parseInputs$1(required) {
3010030094 return {
30101- force: coreExports.getBooleanInput('force', { required } ),
30095+ force: coreExports.getBooleanInput('force'),
3010230096 repo: coreExports.getInput('repo', { required }),
3010330097 url: coreExports.getInput('url', { required }),
3010430098 rootVersion: coreExports.getInput('root-version', { required }),
@@ -30225,27 +30219,28 @@ var slugifyExports = requireSlugify();
3022530219var slugify = /*@__PURE__*/getDefaultExportFromCjs(slugifyExports);
3022630220
3022730221function parseInputs(required) {
30222+ const channel = coreExports.getInput('channel');
3022830223 return {
30229- force: coreExports.getBooleanInput('force', { required } ),
30224+ force: coreExports.getBooleanInput('force'),
3023030225 repo: coreExports.getInput('repo', { required }),
3023130226 group: coreExports.getInput('group', { required }),
30232- ...optionalToObject(' channel', coreExports.getInput('channel') ) // optional field
30227+ ...( channel !== '' ? { channel } : {} ) // optional field
3023330228 };
3023430229}
3023530230function mapInputsToCmdArgs(inputs) {
3023630231 const { repo, group, channel } = inputs;
3023730232 return {
3023830233 repo,
3023930234 group,
30240- ...optionalToObject(' channel', channel) // optional field
30235+ ...( channel !== undefined ? { channel } : {} ) // optional field
3024130236 };
3024230237}
3024330238function formatTrdlUseEnv(args) {
3024430239 const slugOpts = {
3024530240 strict: true
3024630241 };
3024730242 return {
30248- key: format('TRDL_USE_%s_GROUP_CHANNEL', slugify(args.repo, slugOpts)),
30243+ key: format('TRDL_USE_%s_GROUP_CHANNEL', slugify(args.repo, slugOpts).toUpperCase() ),
3024930244 value: format(`%s %s`, args.group, args.channel || '')
3025030245 };
3025130246}
@@ -30260,18 +30255,14 @@ async function Do(trdlCli, p) {
3026030255 await trdlCli.mustExist();
3026130256 let appPath = await trdlCli.binPath(args);
3026230257 coreExports.debug(format(`"trdl bin-path" application path=%s`, appPath));
30263- if (!appPath) {
30264- const opts = { inBackground: false };
30265- coreExports.info(format('Updating application via "trdl update" with args=%o and options=%o.', args, opts));
30266- await trdlCli.update(args, opts);
30258+ const hasAppPath = appPath !== '';
30259+ const opts = { inBackground: hasAppPath };
30260+ coreExports.info(format('Updating application via "trdl update" with args=%o and options=%o.', args, opts));
30261+ await trdlCli.update(args, opts);
30262+ if (!hasAppPath) {
3026730263 appPath = await trdlCli.binPath(args);
3026830264 coreExports.debug(format(`"trdl bin-path" application path=%s`, appPath));
3026930265 }
30270- else {
30271- const opts = { inBackground: true };
30272- coreExports.info(format('Updating application via "trdl update" with args=%o and options=%o.', args, opts));
30273- await trdlCli.update(args, opts);
30274- }
3027530266 const trdlUseEnv = formatTrdlUseEnv(args);
3027630267 coreExports.info(format('Exporting $%s=%s', trdlUseEnv.key, trdlUseEnv.value));
3027730268 coreExports.exportVariable(trdlUseEnv.key, trdlUseEnv.value);
@@ -30282,10 +30273,11 @@ async function Do(trdlCli, p) {
3028230273
3028330274async function Run() {
3028430275 const p = parsePresetInput();
30285- const cli = new TrdlCli();
30286- await Do$2(cli, {});
30287- await Do$1(cli, p);
30288- await Do(cli, p);
30276+ const trdlCli = new TrdlCli();
30277+ const gpgCli = new GpgCli();
30278+ await Do$2(trdlCli, gpgCli, {});
30279+ await Do$1(trdlCli, p);
30280+ await Do(trdlCli, p);
3028930281}
3029030282
3029130283/**
0 commit comments