@artblocks/abx-cli 0.1.0-alpha.16 → 0.1.0-alpha.18

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 (116) hide show
  1. package/CHANGELOG.md +385 -0
  2. package/dist/commands/deploy.d.ts +181 -0
  3. package/dist/commands/deploy.d.ts.map +1 -0
  4. package/dist/commands/deploy.js +2974 -0
  5. package/dist/commands/deploy.js.map +1 -0
  6. package/dist/commands/project.d.ts +134 -0
  7. package/dist/commands/project.d.ts.map +1 -0
  8. package/dist/commands/project.js +919 -0
  9. package/dist/commands/project.js.map +1 -0
  10. package/dist/commands/reads.d.ts +64 -0
  11. package/dist/commands/reads.d.ts.map +1 -0
  12. package/dist/commands/reads.js +635 -0
  13. package/dist/commands/reads.js.map +1 -0
  14. package/dist/commands/scaffold.d.ts +55 -0
  15. package/dist/commands/scaffold.d.ts.map +1 -0
  16. package/dist/commands/scaffold.js +470 -0
  17. package/dist/commands/scaffold.js.map +1 -0
  18. package/dist/commands/service.d.ts +41 -0
  19. package/dist/commands/service.d.ts.map +1 -0
  20. package/dist/commands/service.js +572 -0
  21. package/dist/commands/service.js.map +1 -0
  22. package/dist/commands/storage.d.ts +37 -0
  23. package/dist/commands/storage.d.ts.map +1 -0
  24. package/dist/commands/storage.js +335 -0
  25. package/dist/commands/storage.js.map +1 -0
  26. package/dist/config.d.ts +72 -2
  27. package/dist/config.d.ts.map +1 -1
  28. package/dist/config.js +201 -4
  29. package/dist/config.js.map +1 -1
  30. package/dist/deps.d.ts +6 -39
  31. package/dist/deps.d.ts.map +1 -1
  32. package/dist/deps.js +4 -68
  33. package/dist/deps.js.map +1 -1
  34. package/dist/errors.d.ts +20 -0
  35. package/dist/errors.d.ts.map +1 -0
  36. package/dist/errors.js +25 -0
  37. package/dist/errors.js.map +1 -0
  38. package/dist/flags.d.ts +34 -0
  39. package/dist/flags.d.ts.map +1 -1
  40. package/dist/flags.js +74 -0
  41. package/dist/flags.js.map +1 -1
  42. package/dist/jsonout.d.ts +37 -0
  43. package/dist/jsonout.d.ts.map +1 -0
  44. package/dist/jsonout.js +68 -0
  45. package/dist/jsonout.js.map +1 -0
  46. package/dist/main.js +133 -6223
  47. package/dist/main.js.map +1 -1
  48. package/dist/mintpage.d.ts.map +1 -1
  49. package/dist/mintpage.js +34 -40
  50. package/dist/mintpage.js.map +1 -1
  51. package/dist/output.d.ts +137 -0
  52. package/dist/output.d.ts.map +1 -0
  53. package/dist/output.js +504 -0
  54. package/dist/output.js.map +1 -0
  55. package/dist/ownerops.d.ts +37 -44
  56. package/dist/ownerops.d.ts.map +1 -1
  57. package/dist/ownerops.js +274 -233
  58. package/dist/ownerops.js.map +1 -1
  59. package/dist/preview.d.ts +8 -4
  60. package/dist/preview.d.ts.map +1 -1
  61. package/dist/preview.js +8 -17
  62. package/dist/preview.js.map +1 -1
  63. package/dist/provision.d.ts.map +1 -1
  64. package/dist/provision.js +10 -7
  65. package/dist/provision.js.map +1 -1
  66. package/dist/remote.d.ts +72 -7
  67. package/dist/remote.d.ts.map +1 -1
  68. package/dist/remote.js +211 -9
  69. package/dist/remote.js.map +1 -1
  70. package/dist/riskgate.d.ts +29 -0
  71. package/dist/riskgate.d.ts.map +1 -0
  72. package/dist/riskgate.js +91 -0
  73. package/dist/riskgate.js.map +1 -0
  74. package/dist/schema.d.ts +6 -0
  75. package/dist/schema.d.ts.map +1 -1
  76. package/dist/schema.js +12 -16
  77. package/dist/schema.js.map +1 -1
  78. package/dist/served.d.ts +30 -0
  79. package/dist/served.d.ts.map +1 -0
  80. package/dist/served.js +112 -0
  81. package/dist/served.js.map +1 -0
  82. package/dist/signer.d.ts +13 -0
  83. package/dist/signer.d.ts.map +1 -1
  84. package/dist/signer.js +42 -19
  85. package/dist/signer.js.map +1 -1
  86. package/dist/update-check.d.ts +27 -0
  87. package/dist/update-check.d.ts.map +1 -1
  88. package/dist/update-check.js +30 -0
  89. package/dist/update-check.js.map +1 -1
  90. package/package.json +6 -6
  91. package/skill/SKILL.md +9 -13
  92. package/skill/reference/code-projects.md +7 -6
  93. package/skill/reference/hosting.md +6 -6
  94. package/skill/reference/operating.md +2 -5
  95. package/skill/reference/setup.md +4 -3
  96. package/skill/reference/troubleshooting.md +14 -1
  97. package/dist/gas.d.ts +0 -63
  98. package/dist/gas.d.ts.map +0 -1
  99. package/dist/gas.js +0 -76
  100. package/dist/gas.js.map +0 -1
  101. package/dist/inspect.d.ts +0 -48
  102. package/dist/inspect.d.ts.map +0 -1
  103. package/dist/inspect.js +0 -290
  104. package/dist/inspect.js.map +0 -1
  105. package/dist/migrate.d.ts +0 -65
  106. package/dist/migrate.d.ts.map +0 -1
  107. package/dist/migrate.js +0 -180
  108. package/dist/migrate.js.map +0 -1
  109. package/dist/onchain-uri.d.ts +0 -81
  110. package/dist/onchain-uri.d.ts.map +0 -1
  111. package/dist/onchain-uri.js +0 -251
  112. package/dist/onchain-uri.js.map +0 -1
  113. package/dist/upload.d.ts +0 -28
  114. package/dist/upload.d.ts.map +0 -1
  115. package/dist/upload.js +0 -41
  116. package/dist/upload.js.map +0 -1
package/dist/flags.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"flags.js","sourceRoot":"","sources":["../src/flags.ts"],"names":[],"mappings":"AAaA,8EAA8E;AAC9E,MAAM,CAAC,MAAM,gBAAgB,GAAwB,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AAEzF;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAwB,IAAI,GAAG,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC;AAE9E,MAAM,UAAU,UAAU,CAAC,IAAc;IACvC,MAAM,GAAG,GAAU,EAAE,CAAC;IACtB,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE;QACnC,GAAG,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG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,CAAC,CAAC;QAC3K,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;YACtB,MAAM,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;YAClC,IAAI,IAAI;gBAAE,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;AACH,CAAC;AAED;;kFAEkF;AAClF,MAAM,UAAU,kBAAkB,CAAC,KAAY;IAC7C,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QAC3C,IAAI,CAAC,2DAA2D,IAAI,CAAC,2CAA2C,CAAC,UAAU,IAAI,CAAC,sBAAsB,CAAC,uGAAuG,CAAC,CAAC;IAClQ,CAAC;AACH,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,aAAa,CAAC,GAAuB;IACnD,IAAI,CAAC,GAAG,IAAI,GAAG,KAAK,MAAM;QAAE,OAAO,SAAS,CAAC;IAC7C,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,0DAA0D,GAAG,GAAG,CAAC,CAAC;IACpF,CAAC;IACD,OAAO,GAAU,CAAC;AACpB,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type { Flags } from './flags.js';
2
+ /**
3
+ * `--json`: make **stdout a machine channel**.
4
+ *
5
+ * The rule this enforces, from an integrator who drove the CLI from a server: *a value a program
6
+ * needs must be obtainable without parsing prose.* They had to regex-scrape ANSI-coloured stdout for
7
+ * every value — and an escape code ended up inside a locator, was written into a stored player URL,
8
+ * and 404'd in production. The cause was found only by inspecting stored bytes.
9
+ *
10
+ * So under `--json`, stdout carries exactly one JSON document and nothing else. Every narration line
11
+ * the command would print for a human goes to **stderr** instead — not suppressed, because a human
12
+ * watching a deploy still wants to see it, and a program redirecting stdout still gets a clean parse.
13
+ * The update-check already wrote to stderr for precisely this reason; this carries that instinct
14
+ * through to the values themselves.
15
+ *
16
+ * It works by swapping `console.log` for the duration rather than threading a `quiet` flag through
17
+ * every command body. That is deliberate: the alternative is touching dozens of call sites, where the
18
+ * one that gets missed is a stray line that corrupts a parse — the exact failure mode being fixed.
19
+ * `console.error`/`console.warn` are untouched (already stderr), and the payload is written through a
20
+ * captured reference to the real `console.log`, so nothing can intercept it back.
21
+ */
22
+ export declare function jsonMode(flags: Flags): boolean;
23
+ /**
24
+ * Run `body` and, under `--json`, print whatever it returns as the sole contents of stdout.
25
+ *
26
+ * `body` receives an `emit` it may call to contribute the payload incrementally — for a command that
27
+ * discovers its value midway (a deploy learning its address) and would otherwise have to restructure
28
+ * to return it at the end. The last `emit` wins; a returned value overrides both.
29
+ *
30
+ * Without `--json` this is a plain pass-through: zero behaviour change on the human path.
31
+ */
32
+ export declare function withJson<T extends Record<string, unknown>>(flags: Flags, body: (emit: (payload: T) => void) => Promise<T | void>): Promise<void>;
33
+ /** BigInt-safe JSON: bigints become decimal strings rather than throwing. Every on-chain number a
34
+ * payload carries (supply, a token id, a block) arrives as a bigint, and `JSON.stringify` refuses
35
+ * them outright — so a payload builder that forgets one would fail at the last line of a deploy. */
36
+ export declare function jsonSafe<T>(value: T): T;
37
+ //# sourceMappingURL=jsonout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonout.d.ts","sourceRoot":"","sources":["../src/jsonout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAE9C;AAED;;;;;;;;GAQG;AACH,wBAAsB,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9D,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,KAAK,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,GACtD,OAAO,CAAC,IAAI,CAAC,CA2Bf;AAED;;qGAEqG;AACrG,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAEvC"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * `--json`: make **stdout a machine channel**.
3
+ *
4
+ * The rule this enforces, from an integrator who drove the CLI from a server: *a value a program
5
+ * needs must be obtainable without parsing prose.* They had to regex-scrape ANSI-coloured stdout for
6
+ * every value — and an escape code ended up inside a locator, was written into a stored player URL,
7
+ * and 404'd in production. The cause was found only by inspecting stored bytes.
8
+ *
9
+ * So under `--json`, stdout carries exactly one JSON document and nothing else. Every narration line
10
+ * the command would print for a human goes to **stderr** instead — not suppressed, because a human
11
+ * watching a deploy still wants to see it, and a program redirecting stdout still gets a clean parse.
12
+ * The update-check already wrote to stderr for precisely this reason; this carries that instinct
13
+ * through to the values themselves.
14
+ *
15
+ * It works by swapping `console.log` for the duration rather than threading a `quiet` flag through
16
+ * every command body. That is deliberate: the alternative is touching dozens of call sites, where the
17
+ * one that gets missed is a stray line that corrupts a parse — the exact failure mode being fixed.
18
+ * `console.error`/`console.warn` are untouched (already stderr), and the payload is written through a
19
+ * captured reference to the real `console.log`, so nothing can intercept it back.
20
+ */
21
+ export function jsonMode(flags) {
22
+ return flags.json !== undefined;
23
+ }
24
+ /**
25
+ * Run `body` and, under `--json`, print whatever it returns as the sole contents of stdout.
26
+ *
27
+ * `body` receives an `emit` it may call to contribute the payload incrementally — for a command that
28
+ * discovers its value midway (a deploy learning its address) and would otherwise have to restructure
29
+ * to return it at the end. The last `emit` wins; a returned value overrides both.
30
+ *
31
+ * Without `--json` this is a plain pass-through: zero behaviour change on the human path.
32
+ */
33
+ export async function withJson(flags, body) {
34
+ let payload;
35
+ const emit = (p) => {
36
+ payload = p;
37
+ };
38
+ if (!jsonMode(flags)) {
39
+ await body(emit);
40
+ return;
41
+ }
42
+ const realLog = console.log;
43
+ // Route human narration to stderr. Mirrors console.log's own formatting closely enough for
44
+ // progress text; nothing structured goes through here.
45
+ console.log = (...args) => process.stderr.write(args.map((a) => String(a)).join(' ') + '\n');
46
+ try {
47
+ const returned = await body(emit);
48
+ const out = returned ?? payload;
49
+ // A command that emitted nothing is a bug in that command, not a silent empty object — say so on
50
+ // stderr and leave stdout empty rather than writing `{}` that a caller would trust.
51
+ if (out === undefined) {
52
+ process.stderr.write('abx: --json produced no payload for this command (please report it)\n');
53
+ process.exitCode = 1;
54
+ return;
55
+ }
56
+ realLog(JSON.stringify(out, null, 2));
57
+ }
58
+ finally {
59
+ console.log = realLog;
60
+ }
61
+ }
62
+ /** BigInt-safe JSON: bigints become decimal strings rather than throwing. Every on-chain number a
63
+ * payload carries (supply, a token id, a block) arrives as a bigint, and `JSON.stringify` refuses
64
+ * them outright — so a payload builder that forgets one would fail at the last line of a deploy. */
65
+ export function jsonSafe(value) {
66
+ return JSON.parse(JSON.stringify(value, (_k, v) => (typeof v === 'bigint' ? v.toString() : v)));
67
+ }
68
+ //# sourceMappingURL=jsonout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonout.js","sourceRoot":"","sources":["../src/jsonout.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAY;IACnC,OAAO,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC;AAClC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,KAAY,EACZ,IAAuD;IAEvD,IAAI,OAAsB,CAAC;IAC3B,MAAM,IAAI,GAAG,CAAC,CAAI,EAAE,EAAE;QACpB,OAAO,GAAG,CAAC,CAAC;IACd,CAAC,CAAC;IACF,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC;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