@latticexyz/abi-ts 2.2.14 → 2.2.15-crosschain-08179949754e0b748e52ad2a51e7a4aa2547795e
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.
package/dist/bin/abi-ts.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as r}from"../chunk-
|
|
2
|
+
import{a as r}from"../chunk-3YTXQRSA.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;
|
|
3
3
|
//# sourceMappingURL=abi-ts.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{readFileSync as f,writeFileSync as p}from"fs";import m from"path";import{globSync as b}from"glob";import
|
|
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
2
|
|
|
3
3
|
export default abi;
|
|
4
|
-
`:`const abi = ${n};
|
|
4
|
+
`:`const abi = ${n} as const;
|
|
5
5
|
|
|
6
6
|
export default abi;
|
|
7
7
|
`;t("Writing",r),p(r,a)}process.exit(0)}};export{O as a};
|
|
8
|
-
//# sourceMappingURL=chunk-
|
|
8
|
+
//# sourceMappingURL=chunk-3YTXQRSA.js.map
|
|
@@ -0,0 +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,GAAO,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,SAGF,IAAMI,EAAgBC,EAAK,QAAQL,CAAY,EACzCM,EAAa,GAAGN,EAAa,UAAU,EAAGA,EAAa,YAAYI,CAAa,CAAC,IAAIP,IAErFU,EAAKV,EAAY,SAAS,KAAK,EACjC,sBAAsBI;AAAA;AAAA;AAAA,EACtB,eAAeA;AAAA;AAAA;AAAA,EAEnBE,EAAM,UAAWG,CAAU,EAC3BE,EAAcF,EAAYC,CAAE,EAG9B,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"]}
|
package/dist/exports/internal.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as o}from"../chunk-
|
|
1
|
+
import{a as o}from"../chunk-3YTXQRSA.js";export{o as command};
|
|
2
2
|
//# sourceMappingURL=internal.js.map
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
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};\\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,GAAO,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,SAGF,IAAMI,EAAgBC,EAAK,QAAQL,CAAY,EACzCM,EAAa,GAAGN,EAAa,UAAU,EAAGA,EAAa,YAAYI,CAAa,CAAC,IAAIP,IAErFU,EAAKV,EAAY,SAAS,KAAK,EACjC,sBAAsBI;AAAA;AAAA;AAAA,EACtB,eAAeA;AAAA;AAAA;AAAA,EAEnBE,EAAM,UAAWG,CAAU,EAC3BE,EAAcF,EAAYC,CAAE,EAG9B,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"]}
|