From 02eac18d9e90525d0c48674a37de1a7b8b867bbd Mon Sep 17 00:00:00 2001 From: Orie Steele Date: Sat, 10 Aug 2024 09:49:40 -0500 Subject: [PATCH] test --- src/action/run.ts | 12 ++++++------ src/cli/cose/diagnostic/diagnose.ts | 29 ----------------------------- src/cli/cose/diagnostic/index.ts | 6 ------ src/cli/index.ts | 1 - src/cli/{cose => jose}/index.ts | 0 src/cli/jose/key/generate.ts | 27 +++++++++++++++++++++++++++ src/cli/jose/key/index.ts | 6 ++++++ src/cli/{cose => jose}/module.ts | 4 ++-- 8 files changed, 41 insertions(+), 44 deletions(-) delete mode 100644 src/cli/cose/diagnostic/diagnose.ts delete mode 100644 src/cli/cose/diagnostic/index.ts rename src/cli/{cose => jose}/index.ts (100%) create mode 100644 src/cli/jose/key/generate.ts create mode 100644 src/cli/jose/key/index.ts rename src/cli/{cose => jose}/module.ts (93%) diff --git a/src/action/run.ts b/src/action/run.ts index 864a3064..597fe111 100644 --- a/src/action/run.ts +++ b/src/action/run.ts @@ -5,14 +5,14 @@ import * as core from '@actions/core' import cli from '../cli' async function run() { - try { - if (process.env.GITHUB_ACTION) { + if (process.env.GITHUB_ACTION) { + try { console.warn('todo github action') - } else { - await cli.init() + } catch (error) { + core.setFailed((error as Error).message) } - } catch (error) { - core.setFailed((error as Error).message) + } else { + await cli.init() } } diff --git a/src/cli/cose/diagnostic/diagnose.ts b/src/cli/cose/diagnostic/diagnose.ts deleted file mode 100644 index 2b5c4422..00000000 --- a/src/cli/cose/diagnostic/diagnose.ts +++ /dev/null @@ -1,29 +0,0 @@ -import fs from "fs" -import path from "path" - -import cose from "@transmute/cose" - - -interface RequestDiagnose { - input: string // path to input file - output?: string // path to output file -} - -const diagnose = async (argv: RequestDiagnose) => { - const { input, output } = argv - - const payload = fs.readFileSync(path.resolve(process.cwd(), input)) - // TODO: use @transmute/edn - const edn = await cose.cbor.diagnose(payload) - if (output) { - fs.writeFileSync( - path.resolve(process.cwd(), output), - edn - ) - } else { - console.info(edn) - } - -} - -export default diagnose \ No newline at end of file diff --git a/src/cli/cose/diagnostic/index.ts b/src/cli/cose/diagnostic/index.ts deleted file mode 100644 index c9d55481..00000000 --- a/src/cli/cose/diagnostic/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -import diagnose from "./diagnose" - - -const diagnostic = { diagnose } - -export default diagnostic \ No newline at end of file diff --git a/src/cli/index.ts b/src/cli/index.ts index c0c4c2f1..4b98eb68 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -5,7 +5,6 @@ import jose from './jose' const init = () => { yargs.scriptName('✨') - // jose yargs.command(jose) yargs.help().alias('help', 'h').demandCommand().argv diff --git a/src/cli/cose/index.ts b/src/cli/jose/index.ts similarity index 100% rename from src/cli/cose/index.ts rename to src/cli/jose/index.ts diff --git a/src/cli/jose/key/generate.ts b/src/cli/jose/key/generate.ts new file mode 100644 index 00000000..f2959c75 --- /dev/null +++ b/src/cli/jose/key/generate.ts @@ -0,0 +1,27 @@ +import fs from "fs" +import path from "path" + +interface RequestDiagnose { + input: string // path to input file + output?: string // path to output file +} + +const generate = async (argv: RequestDiagnose) => { + // const { input, output } = argv + + // const payload = fs.readFileSync(path.resolve(process.cwd(), input)) + // // TODO: use @transmute/edn + // const edn = await cose.cbor.diagnose(payload) + // if (output) { + // fs.writeFileSync( + // path.resolve(process.cwd(), output), + // edn + // ) + // } else { + // console.info(edn) + // } + console.log('todo jose key generate') + +} + +export default generate \ No newline at end of file diff --git a/src/cli/jose/key/index.ts b/src/cli/jose/key/index.ts new file mode 100644 index 00000000..6acab981 --- /dev/null +++ b/src/cli/jose/key/index.ts @@ -0,0 +1,6 @@ +import generate from "./generate" + + +const key = { generate } + +export default key \ No newline at end of file diff --git a/src/cli/cose/module.ts b/src/cli/jose/module.ts similarity index 93% rename from src/cli/cose/module.ts rename to src/cli/jose/module.ts index 1ab5e726..82f04542 100644 --- a/src/cli/cose/module.ts +++ b/src/cli/jose/module.ts @@ -1,6 +1,6 @@ -import diagnostic from "./key" +import key from "./key" export const action = `jose` @@ -9,7 +9,7 @@ export const command = `${action} ` export const describe = `${action} operations` const resources = { - diagnostic + key } export const handler = async function (argv) {