Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit 171bed0

Browse files
committed
dev(trdl-actions): rebuild actions
Signed-off-by: Alexandr Zaytsev <[email protected]>
1 parent c71a77e commit 171bed0

File tree

4 files changed

+71
-82
lines changed

4 files changed

+71
-82
lines changed

install/dist/index.mjs

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29864,20 +29864,12 @@ class GpgCli {
2986429864
}
2986529865
async help() {
2986629866
const { stdout } = await execOutput(this.name, ['--help']);
29867-
return stdout.join('');
29867+
return stdout.join('\n');
2986829868
}
2986929869
}
2987029870

2987129871
var ioExports = requireIo();
2987229872

29873-
// optional array element
29874-
function optionalToArray(arg) {
29875-
return arg ? [arg] : [];
29876-
}
29877-
function optionalToObject(key, value) {
29878-
return value ? { [key]: value } : {};
29879-
}
29880-
2988129873
class TrdlCli {
2988229874
name;
2988329875
constructor() {
@@ -29905,15 +29897,17 @@ class TrdlCli {
2990529897
async update(args, opts) {
2990629898
const { repo, group, channel } = args;
2990729899
const env = { ...process.env, ...(opts && toUpdateEnvs(opts)) };
29908-
await execOutput(this.name, ['update', repo, group, ...optionalToArray(channel)], { env });
29900+
const channelOpt = channel !== undefined ? [channel] : []; // optional field
29901+
await execOutput(this.name, ['update', repo, group, ...channelOpt], { env });
2990929902
}
2991029903
async binPath(args) {
2991129904
const { repo, group, channel } = args;
2991229905
const execOpts = {
2991329906
failOnStdErr: false,
2991429907
ignoreReturnCode: true
2991529908
};
29916-
const { stdout } = await execOutput(this.name, ['bin-path', repo, group, ...optionalToArray(channel)], execOpts);
29909+
const channelOpt = channel !== undefined ? [channel] : []; // optional field
29910+
const { stdout } = await execOutput(this.name, ['bin-path', repo, group, ...channelOpt], execOpts);
2991729911
return stdout.join('');
2991829912
}
2991929913
async list() {
@@ -29922,26 +29916,29 @@ class TrdlCli {
2992229916
}
2992329917
}
2992429918
function parseLineToItem(line) {
29925-
const [name, url, default_, channel] = line.split(/ +/);
29919+
const [name, url, default_, channel] = line.trim().split(/ +/);
2992629920
return {
2992729921
name,
2992829922
url,
2992929923
default: default_,
29930-
channel
29924+
...(channel !== undefined ? { channel } : {}) // optional field
2993129925
};
2993229926
}
2993329927
function toUpdateEnvs(opts) {
2993429928
const env = {};
29935-
if (opts?.inBackground) {
29929+
// eslint-disable-next-line no-prototype-builtins
29930+
if (opts.hasOwnProperty('inBackground')) {
2993629931
env['TRDL_IN_BACKGROUND'] = String(opts.inBackground);
2993729932
}
2993829933
return env;
2993929934
}
2994029935

2994129936
function parseInputs() {
29937+
const channel = coreExports.getInput('channel');
29938+
const version = coreExports.getInput('version');
2994229939
return {
29943-
...optionalToObject('channel', coreExports.getInput('channel')), // optional field
29944-
...optionalToObject('version', coreExports.getInput('version')) // optional field
29940+
...(channel !== '' ? { channel } : {}), // optional field
29941+
...(version !== '' ? { version } : {}) // optional field
2994529942
};
2994629943
}
2994729944
async function fetchVersion(group, channel) {
@@ -29951,8 +29948,8 @@ async function fetchVersion(group, channel) {
2995129948
return version.trim();
2995229949
}
2995329950
async function getOptions(inputs, defaults) {
29954-
const channel = inputs?.channel || defaults.channel;
29955-
const version = inputs?.version || await fetchVersion(defaults.group, defaults.channel); // prettier-ignore
29951+
const channel = inputs.channel ?? defaults.channel;
29952+
const version = inputs.version ?? await fetchVersion(defaults.group, defaults.channel); // prettier-ignore
2995629953
return {
2995729954
channel,
2995829955
version
@@ -30011,10 +30008,11 @@ async function installTrdl(toolName, toolVersion, binPath) {
3001130008
}
3001230009
async function Run() {
3001330010
const trdlCli = new TrdlCli();
30011+
const gpgCli = new GpgCli();
3001430012
const inputs = parseInputs();
30015-
await Do(trdlCli, inputs);
30013+
await Do(trdlCli, gpgCli, inputs);
3001630014
}
30017-
async function Do(trdlCli, inputs) {
30015+
async function Do(trdlCli, gpgCli, inputs) {
3001830016
coreExports.startGroup('Install or self-update trdl.');
3001930017
coreExports.debug(format(`parsed inputs=%o`, inputs));
3002030018
const defaults = trdlCli.defaults();
@@ -30030,7 +30028,6 @@ async function Do(trdlCli, inputs) {
3003030028
coreExports.endGroup();
3003130029
return;
3003230030
}
30033-
const gpgCli = new GpgCli();
3003430031
await gpgCli.mustGnuGP();
3003530032
const [binUrl, sigUrl, ascUrl] = formatDownloadUrls(options.version);
3003630033
coreExports.debug(format('%s bin_url=%s', defaults.repo, binUrl));

install/dist/index.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

setup-app/dist/index.mjs

Lines changed: 51 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -27303,7 +27303,7 @@ function getUpdateArgs(presetVal) {
2730327303
function 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-
2734727339
class 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
}
2739027384
function 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
}
2739927393
function 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+
2740727425
var libExports = requireLib();
2740827426

2740927427
var toolCache = {};
@@ -29976,38 +29994,15 @@ function requireToolCache () {
2997629994

2997729995
var 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-
3000229997
async 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
}
3000830003
async 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

3009930093
function 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();
3022530219
var slugify = /*@__PURE__*/getDefaultExportFromCjs(slugifyExports);
3022630220

3022730221
function 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
}
3023530230
function 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
}
3024330238
function 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

3028330274
async 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
/**

setup-app/dist/index.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)