armory-cli 0.3.8 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +85 -28
  2. package/package.json +5 -3
package/dist/cli.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { join } from 'path';
3
2
  import { mkdir, writeFile } from 'fs/promises';
4
- import prompts from 'prompts';
3
+ import { join } from 'path';
5
4
  import { resolveNetwork, isResolvedNetwork, resolveToken, isResolvedToken, getTokensByChain, getAllTokens, getTestnets, getMainnets } from '@armory-sh/base';
5
+ import prompts from 'prompts';
6
6
 
7
7
  var GITIGNORE = `node_modules
8
8
  dist
@@ -16,7 +16,11 @@ var EXTENSIONS_INFO = [
16
16
  name: "bazaar",
17
17
  description: "Resource discovery - let clients discover your API resources",
18
18
  package: "@armory-sh/extensions",
19
- hooks: ["declareDiscoveryExtension", "extractDiscoveryInfo", "validateDiscoveryExtension"]
19
+ hooks: [
20
+ "declareDiscoveryExtension",
21
+ "extractDiscoveryInfo",
22
+ "validateDiscoveryExtension"
23
+ ]
20
24
  },
21
25
  {
22
26
  name: "siwx",
@@ -433,7 +437,9 @@ function printHelp() {
433
437
  console.log("Usage:");
434
438
  console.log(" armory <command> [options]");
435
439
  console.log("Templates:");
436
- console.log(" bun-server, express-server, hono-server, elysia-server, next-server");
440
+ console.log(
441
+ " bun-server, express-server, hono-server, elysia-server, next-server"
442
+ );
437
443
  console.log(" viem-client, ethers-client, web3-client, facilitator");
438
444
  console.log("Examples:");
439
445
  console.log(" armory create bun-server my-api");
@@ -490,21 +496,35 @@ function printHelp() {
490
496
  `);
491
497
  }
492
498
  function formatNetworkTable(networks) {
493
- console.log("\n\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510");
494
- console.log("\u2502 Name \u2502 Chain ID \u2502 RPC URL \u2502");
495
- console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");
499
+ console.log(
500
+ "\n\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"
501
+ );
502
+ console.log(
503
+ "\u2502 Name \u2502 Chain ID \u2502 RPC URL \u2502"
504
+ );
505
+ console.log(
506
+ "\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524"
507
+ );
496
508
  for (const network of networks) {
497
509
  const name = network.name.padEnd(19);
498
510
  const chainId = String(network.chainId).padEnd(8);
499
511
  const rpc = network.rpcUrl.substring(0, 34).padEnd(34);
500
512
  console.log(`\u2502 ${name} \u2502 ${chainId} \u2502 ${rpc} \u2502`);
501
513
  }
502
- console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n");
514
+ console.log(
515
+ "\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n"
516
+ );
503
517
  }
504
518
  function formatTokenTable(tokens) {
505
- console.log("\n\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510");
506
- console.log("\u2502 Symbol \u2502 Name \u2502 Chain ID \u2502 Address \u2502");
507
- console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");
519
+ console.log(
520
+ "\n\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"
521
+ );
522
+ console.log(
523
+ "\u2502 Symbol \u2502 Name \u2502 Chain ID \u2502 Address \u2502"
524
+ );
525
+ console.log(
526
+ "\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524"
527
+ );
508
528
  for (const token of tokens) {
509
529
  const symbol = token.symbol.padEnd(7);
510
530
  const name = token.name.substring(0, 15).padEnd(15);
@@ -512,7 +532,9 @@ function formatTokenTable(tokens) {
512
532
  const address = token.contractAddress.padEnd(40);
513
533
  console.log(`\u2502 ${symbol} \u2502 ${name} \u2502 ${chainId} \u2502 ${address} \u2502`);
514
534
  }
515
- console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n");
535
+ console.log(
536
+ "\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n"
537
+ );
516
538
  }
517
539
  function networksCommand(args) {
518
540
  const showTestnets = args.includes("--testnet") || args.includes("-t");
@@ -543,9 +565,11 @@ function tokensCommand(args) {
543
565
  if (tokens.length === 0) {
544
566
  console.log(`No tokens configured for ${resolved.name}`);
545
567
  } else {
546
- console.log(`
568
+ console.log(
569
+ `
547
570
  \u{1F4B0} Tokens on ${resolved.name} (Chain ID: ${resolved.chainId}):
548
- `);
571
+ `
572
+ );
549
573
  formatTokenTable(tokens);
550
574
  }
551
575
  } else {
@@ -599,17 +623,27 @@ function validateCommand(args) {
599
623
  }
600
624
  function extensionsCommand() {
601
625
  console.log("\n\u{1F50C} Available x402 Extensions:\n");
602
- console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510");
603
- console.log("\u2502 Extension \u2502 Description \u2502");
604
- console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");
626
+ console.log(
627
+ "\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"
628
+ );
629
+ console.log(
630
+ "\u2502 Extension \u2502 Description \u2502"
631
+ );
632
+ console.log(
633
+ "\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524"
634
+ );
605
635
  for (const ext of EXTENSIONS_INFO) {
606
636
  const name = ext.name.padEnd(13);
607
637
  const desc = ext.description.substring(0, 51).padEnd(51);
608
638
  console.log(`\u2502 ${name} \u2502 ${desc} \u2502`);
609
639
  }
610
- console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n");
640
+ console.log(
641
+ "\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n"
642
+ );
611
643
  console.log("Usage:");
612
- console.log(" import { createSIWxHook, createPaymentIdHook } from '@armory-sh/extensions';\n");
644
+ console.log(
645
+ " import { createSIWxHook, createPaymentIdHook } from '@armory-sh/extensions';\n"
646
+ );
613
647
  console.log("Extension Hooks:");
614
648
  for (const ext of EXTENSIONS_INFO) {
615
649
  console.log(` ${ext.name}: ${ext.hooks.slice(0, 2).join(", ")}`);
@@ -640,8 +674,10 @@ async function verifyCommand(args) {
640
674
  console.log("\n\u2139\uFE0F No payment required for this endpoint");
641
675
  }
642
676
  } catch (error) {
643
- console.error(`
644
- \u274C Failed to fetch: ${error instanceof Error ? error.message : "Unknown error"}`);
677
+ console.error(
678
+ `
679
+ \u274C Failed to fetch: ${error instanceof Error ? error.message : "Unknown error"}`
680
+ );
645
681
  process.exit(1);
646
682
  }
647
683
  }
@@ -666,14 +702,35 @@ async function createCommand(args) {
666
702
  const result = await p.select({
667
703
  message: "What do you want to create?",
668
704
  choices: [
669
- { title: "Bun Server - Simple x402 payment server", value: "bun-server" },
670
- { title: "Express Server - Express v5 with x402 middleware", value: "express-server" },
671
- { title: "Hono Server - Hono with extensions support", value: "hono-server" },
672
- { title: "Elysia Server - Elysia/Bun x402 server", value: "elysia-server" },
673
- { title: "Next.js Middleware - Next.js payment middleware", value: "next-server" },
705
+ {
706
+ title: "Bun Server - Simple x402 payment server",
707
+ value: "bun-server"
708
+ },
709
+ {
710
+ title: "Express Server - Express v5 with x402 middleware",
711
+ value: "express-server"
712
+ },
713
+ {
714
+ title: "Hono Server - Hono with extensions support",
715
+ value: "hono-server"
716
+ },
717
+ {
718
+ title: "Elysia Server - Elysia/Bun x402 server",
719
+ value: "elysia-server"
720
+ },
721
+ {
722
+ title: "Next.js Middleware - Next.js payment middleware",
723
+ value: "next-server"
724
+ },
674
725
  { title: "Viem Client - x402 client with Viem", value: "viem-client" },
675
- { title: "Ethers Client - x402 client with Ethers.js", value: "ethers-client" },
676
- { title: "Web3 Client - x402 client with Web3.js", value: "web3-client" }
726
+ {
727
+ title: "Ethers Client - x402 client with Ethers.js",
728
+ value: "ethers-client"
729
+ },
730
+ {
731
+ title: "Web3 Client - x402 client with Web3.js",
732
+ value: "web3-client"
733
+ }
677
734
  ]
678
735
  });
679
736
  template = result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "armory-cli",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "description": "Scaffold x402 payment-enabled apps",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -43,12 +43,14 @@
43
43
  "scripts": {
44
44
  "build": "rm -rf dist && tsup",
45
45
  "dev": "bun run src/cli.ts",
46
+ "lint": "bun run build",
47
+ "format": "bun run lint",
46
48
  "prepublishOnly": "bun run build",
47
49
  "test": "bun test"
48
50
  },
49
51
  "dependencies": {
50
- "@armory-sh/base": "0.2.28",
51
- "@armory-sh/extensions": "0.1.9",
52
+ "@armory-sh/base": "0.2.29",
53
+ "@armory-sh/extensions": "0.1.10",
52
54
  "prompts": "2.4.2"
53
55
  },
54
56
  "devDependencies": {