From 826096fb6b73feb8687a462b1073d21d31789488 Mon Sep 17 00:00:00 2001 From: Cotton Hou Date: Mon, 29 Jul 2024 12:16:40 +0800 Subject: [PATCH] wip --- .github/workflows/bun.yml | 49 +++++++++++++++++++++++++++++++++++++++ package.json | 7 ++++++ src/bin.ts | 41 ++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 .github/workflows/bun.yml create mode 100644 package.json create mode 100644 src/bin.ts diff --git a/.github/workflows/bun.yml b/.github/workflows/bun.yml new file mode 100644 index 0000000..98e29f5 --- /dev/null +++ b/.github/workflows/bun.yml @@ -0,0 +1,49 @@ +name: Bundle + +on: push + +jobs: + + Build: + + runs-on: ubuntu-latest + timeout-minutes: 3 + + permissions: + contents: read + id-token: write + + steps: + + - uses: actions/checkout@v4 + + - uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + + - name: preBuild + run: |- + mkdir ./dist + bun install + + - name: Build + run: bun build ./src/bin.ts + --target node + --format esm + --outdir ./dist + --entry-naming [name].[hash].mjs + + - name: Minify + run: bun build ./dist/*js + --target node + --format esm + --outdir ./dist + --entry-naming [name]-min.[hash].mjs + --minify + + - name: Upload Artifacts + uses: actions/upload-artifact@v4 + with: + name: key-gen-${{ hashFiles('./dist/*') }} + path: ./dist + diff --git a/package.json b/package.json new file mode 100644 index 0000000..55d105c --- /dev/null +++ b/package.json @@ -0,0 +1,7 @@ +{ + "name": "at-key-gen-ssh-ed25519", + "version": "1.0.0", + "dependencies": { + "micro-key-producer": "~0.7.0" + } +} diff --git a/src/bin.ts b/src/bin.ts new file mode 100644 index 0000000..3bf014d --- /dev/null +++ b/src/bin.ts @@ -0,0 +1,41 @@ +import { main } from './main.ts'; + +import { args, webcrypto } from './utils.ts'; + + + + + +async function run () { + + const [ x, ...xs ] = args; + + if (x === 'uuid') { + return console.log(webcrypto.randomUUID()); + } + + const { publicKey, privateKey, fingerprint } = await main(xs); + + if (x === 'pub' || x === 'public') { + + console.log(publicKey); + + } else if (x === 'private') { + + console.log(privateKey); + + } else if (x === 'fingerprint') { + + console.log(fingerprint); + + } else { + + throw new Error(`unknown - ${ x }`); + + } + +} + +run(); + +