@latticexyz/abi-ts 2.2.18-ebe1aea8d4afb690ce1c7c2bcb42dc0f1faf6e77 → 2.2.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.
@@ -1,3 +1,20 @@
1
1
  #!/usr/bin/env node
2
- import{a as r}from"../chunk-2LMRZYSL.js";import e from"yargs";import{hideBin as i}from"yargs/helpers";import o from"chalk";r.command="$0";e(i(process.argv)).scriptName("abi-ts").command(r).strict().fail(a=>{console.error(o.red(a)),a.includes("Missing required argument")&&console.log(o.yellow(`Run 'pnpm abi-ts ${process.argv[2]} --help' for a list of available and required arguments.`)),process.exit(1)}).alias({h:"help"}).argv;
2
+ import {
3
+ command
4
+ } from "../chunk-2EZH4CKN.js";
5
+
6
+ // src/bin/abi-ts.ts
7
+ import yargs from "yargs";
8
+ import { hideBin } from "yargs/helpers";
9
+ import chalk from "chalk";
10
+ command.command = "$0";
11
+ yargs(hideBin(process.argv)).scriptName("abi-ts").command(command).strict().fail((msg) => {
12
+ console.error(chalk.red(msg));
13
+ if (msg.includes("Missing required argument")) {
14
+ console.log(
15
+ chalk.yellow(`Run 'pnpm abi-ts ${process.argv[2]} --help' for a list of available and required arguments.`)
16
+ );
17
+ }
18
+ process.exit(1);
19
+ }).alias({ h: "help" }).argv;
3
20
  //# sourceMappingURL=abi-ts.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/bin/abi-ts.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { command as abiTsCommand } from \"../command\";\nimport chalk from \"chalk\";\n\n// $0 makes this a default command (as opposed to a sub-command),\n// which replaces `abi-ts abi-ts` with just `abi-ts`\nabiTsCommand.command = \"$0\";\n\nyargs(hideBin(process.argv))\n .scriptName(\"abi-ts\")\n // Use the commands directory to scaffold\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- command array overload isn't typed, see https://github.com/yargs/yargs/blob/main/docs/advanced.md#esm-hierarchy\n .command(abiTsCommand as any)\n // Enable strict mode.\n .strict()\n // Custom error handler\n .fail((msg) => {\n console.error(chalk.red(msg));\n if (msg.includes(\"Missing required argument\")) {\n console.log(\n chalk.yellow(`Run 'pnpm abi-ts ${process.argv[2]} --help' for a list of available and required arguments.`),\n );\n }\n\n process.exit(1);\n })\n // Useful aliases.\n .alias({ h: \"help\" }).argv;\n"],"mappings":";yCAEA,OAAOA,MAAW,QAClB,OAAS,WAAAC,MAAe,gBAExB,OAAOC,MAAW,QAIlBC,EAAa,QAAU,KAEvBC,EAAMC,EAAQ,QAAQ,IAAI,CAAC,EACxB,WAAW,QAAQ,EAGnB,QAAQF,CAAmB,EAE3B,OAAO,EAEP,KAAMG,GAAQ,CACb,QAAQ,MAAMJ,EAAM,IAAII,CAAG,CAAC,EACxBA,EAAI,SAAS,2BAA2B,GAC1C,QAAQ,IACNJ,EAAM,OAAO,oBAAoB,QAAQ,KAAK,CAAC,CAAC,0DAA0D,CAC5G,EAGF,QAAQ,KAAK,CAAC,CAChB,CAAC,EAEA,MAAM,CAAE,EAAG,MAAO,CAAC,EAAE","names":["yargs","hideBin","chalk","command","yargs","hideBin","msg"]}
1
+ {"version":3,"sources":["../../src/bin/abi-ts.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { command as abiTsCommand } from \"../command\";\nimport chalk from \"chalk\";\n\n// $0 makes this a default command (as opposed to a sub-command),\n// which replaces `abi-ts abi-ts` with just `abi-ts`\nabiTsCommand.command = \"$0\";\n\nyargs(hideBin(process.argv))\n .scriptName(\"abi-ts\")\n // Use the commands directory to scaffold\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- command array overload isn't typed, see https://github.com/yargs/yargs/blob/main/docs/advanced.md#esm-hierarchy\n .command(abiTsCommand as any)\n // Enable strict mode.\n .strict()\n // Custom error handler\n .fail((msg) => {\n console.error(chalk.red(msg));\n if (msg.includes(\"Missing required argument\")) {\n console.log(\n chalk.yellow(`Run 'pnpm abi-ts ${process.argv[2]} --help' for a list of available and required arguments.`),\n );\n }\n\n process.exit(1);\n })\n // Useful aliases.\n .alias({ h: \"help\" }).argv;\n"],"mappings":";;;;;;AAEA,OAAO,WAAW;AAClB,SAAS,eAAe;AAExB,OAAO,WAAW;AAIlB,QAAa,UAAU;AAEvB,MAAM,QAAQ,QAAQ,IAAI,CAAC,EACxB,WAAW,QAAQ,EAGnB,QAAQ,OAAmB,EAE3B,OAAO,EAEP,KAAK,CAAC,QAAQ;AACb,UAAQ,MAAM,MAAM,IAAI,GAAG,CAAC;AAC5B,MAAI,IAAI,SAAS,2BAA2B,GAAG;AAC7C,YAAQ;AAAA,MACN,MAAM,OAAO,oBAAoB,QAAQ,KAAK,CAAC,CAAC,0DAA0D;AAAA,IAC5G;AAAA,EACF;AAEA,UAAQ,KAAK,CAAC;AAChB,CAAC,EAEA,MAAM,EAAE,GAAG,OAAO,CAAC,EAAE;","names":[]}
@@ -0,0 +1,62 @@
1
+ // src/command.ts
2
+ import { readFileSync, writeFileSync } from "fs";
3
+ import path from "path";
4
+ import { globSync } from "glob";
5
+
6
+ // src/debug.ts
7
+ import createDebug from "debug";
8
+ var debug = createDebug("abi-ts");
9
+ var error = createDebug("abi-ts");
10
+ debug.log = console.debug.bind(console);
11
+ error.log = console.error.bind(console);
12
+
13
+ // src/command.ts
14
+ var command = {
15
+ command: "abi-ts",
16
+ describe: "Convert a directory of JSON ABI files to a directory of TS or DTS files with `as const`.",
17
+ builder(yargs) {
18
+ return yargs.options({
19
+ input: {
20
+ type: "string",
21
+ desc: "Input glob of ABI JSON files.",
22
+ default: "**/*.abi.json"
23
+ },
24
+ extension: {
25
+ type: "string",
26
+ desc: "Extension of the resulting ABI TS or DTS file.",
27
+ default: ".json.d.ts"
28
+ }
29
+ });
30
+ },
31
+ handler({ input, extension: tsExtension }) {
32
+ const files = globSync(input).sort();
33
+ if (!files.length) {
34
+ console.error(`No files found for glob: ${input}`);
35
+ process.exit(1);
36
+ }
37
+ for (const jsonFilename of files) {
38
+ const json = readFileSync(jsonFilename, "utf8").trim();
39
+ if (json === "[]") {
40
+ debug("Skipping empty ABI file", jsonFilename);
41
+ continue;
42
+ }
43
+ const jsonExtension = path.extname(jsonFilename);
44
+ const tsFilename = `${jsonFilename.substring(0, jsonFilename.lastIndexOf(jsonExtension))}${tsExtension}`;
45
+ const ts = tsExtension.includes(".d.") ? `declare const abi: ${json};
46
+
47
+ export default abi;
48
+ ` : `const abi = ${json} as const;
49
+
50
+ export default abi;
51
+ `;
52
+ debug("Writing", tsFilename);
53
+ writeFileSync(tsFilename, ts);
54
+ }
55
+ process.exit(0);
56
+ }
57
+ };
58
+
59
+ export {
60
+ command
61
+ };
62
+ //# sourceMappingURL=chunk-2EZH4CKN.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/command.ts","../src/debug.ts"],"sourcesContent":["import type { CommandModule } from \"yargs\";\nimport { readFileSync, writeFileSync } from \"fs\";\nimport path from \"path\";\nimport { globSync } from \"glob\";\nimport { debug } from \"./debug\";\n\ntype Options = {\n input: string;\n extension: string;\n};\n\nexport const command: CommandModule<Options, Options> = {\n command: \"abi-ts\",\n\n describe: \"Convert a directory of JSON ABI files to a directory of TS or DTS files with `as const`.\",\n\n builder(yargs) {\n return yargs.options({\n input: {\n type: \"string\",\n desc: \"Input glob of ABI JSON files.\",\n default: \"**/*.abi.json\",\n },\n extension: {\n type: \"string\",\n desc: \"Extension of the resulting ABI TS or DTS file.\",\n default: \".json.d.ts\",\n },\n });\n },\n\n handler({ input, extension: tsExtension }) {\n const files = globSync(input).sort();\n\n if (!files.length) {\n console.error(`No files found for glob: ${input}`);\n process.exit(1);\n }\n\n for (const jsonFilename of files) {\n const json = readFileSync(jsonFilename, \"utf8\").trim();\n if (json === \"[]\") {\n debug(\"Skipping empty ABI file\", jsonFilename);\n continue;\n }\n\n const jsonExtension = path.extname(jsonFilename);\n const tsFilename = `${jsonFilename.substring(0, jsonFilename.lastIndexOf(jsonExtension))}${tsExtension}`;\n\n const ts = tsExtension.includes(\".d.\")\n ? `declare const abi: ${json};\\n\\nexport default abi;\\n`\n : `const abi = ${json} as const;\\n\\nexport default abi;\\n`;\n\n debug(\"Writing\", tsFilename);\n writeFileSync(tsFilename, ts);\n }\n\n process.exit(0);\n },\n};\n","import createDebug from \"debug\";\n\nexport const debug = createDebug(\"abi-ts\");\nexport const error = createDebug(\"abi-ts\");\n\n// Pipe debug output to stdout instead of stderr\ndebug.log = console.debug.bind(console);\n\n// Pipe error output to stderr\nerror.log = console.error.bind(console);\n"],"mappings":"AACA,OAAS,gBAAAA,EAAc,iBAAAC,MAAqB,KAC5C,OAAOC,MAAU,OACjB,OAAS,YAAAC,MAAgB,OCHzB,OAAOC,MAAiB,QAEjB,IAAMC,EAAQD,EAAY,QAAQ,EAC5BE,EAAQF,EAAY,QAAQ,EAGzCC,EAAM,IAAM,QAAQ,MAAM,KAAK,OAAO,EAGtCC,EAAM,IAAM,QAAQ,MAAM,KAAK,OAAO,EDE/B,IAAMC,EAA2C,CACtD,QAAS,SAET,SAAU,2FAEV,QAAQC,EAAO,CACb,OAAOA,EAAM,QAAQ,CACnB,MAAO,CACL,KAAM,SACN,KAAM,gCACN,QAAS,eACX,EACA,UAAW,CACT,KAAM,SACN,KAAM,iDACN,QAAS,YACX,CACF,CAAC,CACH,EAEA,QAAQ,CAAE,MAAAC,EAAO,UAAWC,CAAY,EAAG,CACzC,IAAMC,EAAQC,EAASH,CAAK,EAAE,KAAK,EAE9BE,EAAM,SACT,QAAQ,MAAM,4BAA4BF,CAAK,EAAE,EACjD,QAAQ,KAAK,CAAC,GAGhB,QAAWI,KAAgBF,EAAO,CAChC,IAAMG,EAAOC,EAAaF,EAAc,MAAM,EAAE,KAAK,EACrD,GAAIC,IAAS,KAAM,CACjBE,EAAM,0BAA2BH,CAAY,EAC7C,QACF,CAEA,IAAMI,EAAgBC,EAAK,QAAQL,CAAY,EACzCM,EAAa,GAAGN,EAAa,UAAU,EAAGA,EAAa,YAAYI,CAAa,CAAC,CAAC,GAAGP,CAAW,GAEhGU,EAAKV,EAAY,SAAS,KAAK,EACjC,sBAAsBI,CAAI;AAAA;AAAA;AAAA,EAC1B,eAAeA,CAAI;AAAA;AAAA;AAAA,EAEvBE,EAAM,UAAWG,CAAU,EAC3BE,EAAcF,EAAYC,CAAE,CAC9B,CAEA,QAAQ,KAAK,CAAC,CAChB,CACF","names":["readFileSync","writeFileSync","path","globSync","createDebug","debug","error","command","yargs","input","tsExtension","files","globSync","jsonFilename","json","readFileSync","debug","jsonExtension","path","tsFilename","ts","writeFileSync"]}
1
+ {"version":3,"sources":["../src/command.ts","../src/debug.ts"],"sourcesContent":["import type { CommandModule } from \"yargs\";\nimport { readFileSync, writeFileSync } from \"fs\";\nimport path from \"path\";\nimport { globSync } from \"glob\";\nimport { debug } from \"./debug\";\n\ntype Options = {\n input: string;\n extension: string;\n};\n\nexport const command: CommandModule<Options, Options> = {\n command: \"abi-ts\",\n\n describe: \"Convert a directory of JSON ABI files to a directory of TS or DTS files with `as const`.\",\n\n builder(yargs) {\n return yargs.options({\n input: {\n type: \"string\",\n desc: \"Input glob of ABI JSON files.\",\n default: \"**/*.abi.json\",\n },\n extension: {\n type: \"string\",\n desc: \"Extension of the resulting ABI TS or DTS file.\",\n default: \".json.d.ts\",\n },\n });\n },\n\n handler({ input, extension: tsExtension }) {\n const files = globSync(input).sort();\n\n if (!files.length) {\n console.error(`No files found for glob: ${input}`);\n process.exit(1);\n }\n\n for (const jsonFilename of files) {\n const json = readFileSync(jsonFilename, \"utf8\").trim();\n if (json === \"[]\") {\n debug(\"Skipping empty ABI file\", jsonFilename);\n continue;\n }\n\n const jsonExtension = path.extname(jsonFilename);\n const tsFilename = `${jsonFilename.substring(0, jsonFilename.lastIndexOf(jsonExtension))}${tsExtension}`;\n\n const ts = tsExtension.includes(\".d.\")\n ? `declare const abi: ${json};\\n\\nexport default abi;\\n`\n : `const abi = ${json} as const;\\n\\nexport default abi;\\n`;\n\n debug(\"Writing\", tsFilename);\n writeFileSync(tsFilename, ts);\n }\n\n process.exit(0);\n },\n};\n","import createDebug from \"debug\";\n\nexport const debug = createDebug(\"abi-ts\");\nexport const error = createDebug(\"abi-ts\");\n\n// Pipe debug output to stdout instead of stderr\ndebug.log = console.debug.bind(console);\n\n// Pipe error output to stderr\nerror.log = console.error.bind(console);\n"],"mappings":";AACA,SAAS,cAAc,qBAAqB;AAC5C,OAAO,UAAU;AACjB,SAAS,gBAAgB;;;ACHzB,OAAO,iBAAiB;AAEjB,IAAM,QAAQ,YAAY,QAAQ;AAClC,IAAM,QAAQ,YAAY,QAAQ;AAGzC,MAAM,MAAM,QAAQ,MAAM,KAAK,OAAO;AAGtC,MAAM,MAAM,QAAQ,MAAM,KAAK,OAAO;;;ADE/B,IAAM,UAA2C;AAAA,EACtD,SAAS;AAAA,EAET,UAAU;AAAA,EAEV,QAAQ,OAAO;AACb,WAAO,MAAM,QAAQ;AAAA,MACnB,OAAO;AAAA,QACL,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,MACA,WAAW;AAAA,QACT,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,QAAQ,EAAE,OAAO,WAAW,YAAY,GAAG;AACzC,UAAM,QAAQ,SAAS,KAAK,EAAE,KAAK;AAEnC,QAAI,CAAC,MAAM,QAAQ;AACjB,cAAQ,MAAM,4BAA4B,KAAK,EAAE;AACjD,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,eAAW,gBAAgB,OAAO;AAChC,YAAM,OAAO,aAAa,cAAc,MAAM,EAAE,KAAK;AACrD,UAAI,SAAS,MAAM;AACjB,cAAM,2BAA2B,YAAY;AAC7C;AAAA,MACF;AAEA,YAAM,gBAAgB,KAAK,QAAQ,YAAY;AAC/C,YAAM,aAAa,GAAG,aAAa,UAAU,GAAG,aAAa,YAAY,aAAa,CAAC,CAAC,GAAG,WAAW;AAEtG,YAAM,KAAK,YAAY,SAAS,KAAK,IACjC,sBAAsB,IAAI;AAAA;AAAA;AAAA,IAC1B,eAAe,IAAI;AAAA;AAAA;AAAA;AAEvB,YAAM,WAAW,UAAU;AAC3B,oBAAc,YAAY,EAAE;AAAA,IAC9B;AAEA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;","names":[]}
@@ -1,2 +1,7 @@
1
- import{a as o}from"../chunk-2LMRZYSL.js";export{o as command};
1
+ import {
2
+ command
3
+ } from "../chunk-2EZH4CKN.js";
4
+ export {
5
+ command
6
+ };
2
7
  //# sourceMappingURL=internal.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@latticexyz/abi-ts",
3
- "version": "2.2.18-ebe1aea8d4afb690ce1c7c2bcb42dc0f1faf6e77",
3
+ "version": "2.2.18",
4
4
  "description": "Create TypeScript type declaration files (`.d.ts`) for your ABI JSON files.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -43,7 +43,7 @@
43
43
  "build": "tsup",
44
44
  "clean": "shx rm -rf dist",
45
45
  "dev": "tsup --watch",
46
- "test": "vitest typecheck --run --passWithNoTests && vitest --run --passWithNoTests",
46
+ "test": "vitest --run",
47
47
  "test:ci": "pnpm run test"
48
48
  }
49
49
  }
@@ -1,8 +0,0 @@
1
- import{readFileSync as f,writeFileSync as p}from"fs";import m from"path";import{globSync as b}from"glob";import c from"debug";var t=c("abi-ts"),d=c("abi-ts");t.log=console.debug.bind(console);d.log=console.error.bind(console);var O={command:"abi-ts",describe:"Convert a directory of JSON ABI files to a directory of TS or DTS files with `as const`.",builder(e){return e.options({input:{type:"string",desc:"Input glob of ABI JSON files.",default:"**/*.abi.json"},extension:{type:"string",desc:"Extension of the resulting ABI TS or DTS file.",default:".json.d.ts"}})},handler({input:e,extension:s}){let i=b(e).sort();i.length||(console.error(`No files found for glob: ${e}`),process.exit(1));for(let o of i){let n=f(o,"utf8").trim();if(n==="[]"){t("Skipping empty ABI file",o);continue}let l=m.extname(o),r=`${o.substring(0,o.lastIndexOf(l))}${s}`,a=s.includes(".d.")?`declare const abi: ${n};
2
-
3
- export default abi;
4
- `:`const abi = ${n} as const;
5
-
6
- export default abi;
7
- `;t("Writing",r),p(r,a)}process.exit(0)}};export{O as a};
8
- //# sourceMappingURL=chunk-2LMRZYSL.js.map