@latticexyz/abi-ts 2.2.18-2762cefb93e90632e0b25e11d0238b5998852f8b → 2.2.18-41fe36dd2756fe87bfe141e15b6d102f4b070ab1
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.
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";var h=Object.create;var p=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var O=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of $(e))!I.call(o,n)&&n!==t&&p(o,n,{get:()=>e[n],enumerable:!(r=S(e,n))||r.enumerable});return o};var s=(o,e,t)=>(t=o!=null?h(v(o)):{},O(e||!o||!o.__esModule?p(t,"default",{value:o,enumerable:!0}):t,o));var g=s(require("yargs"),1),b=require("yargs/helpers");var a=require("fs"),f=s(require("path"),1),u=require("glob");var l=s(require("debug"),1),i=(0,l.default)("abi-ts"),j=(0,l.default)("abi-ts");i.log=console.debug.bind(console);j.log=console.error.bind(console);var c={command:"abi-ts",describe:"Convert a directory of JSON ABI files to a directory of TS or DTS files with `as const`.",builder(o){return o.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:o,extension:e}){let t=(0,u.globSync)(o).sort();t.length||(console.error(`No files found for glob: ${o}`),process.exit(1));for(let r of t){let n=(0,a.readFileSync)(r,"utf8").trim();if(n==="[]"){i("Skipping empty ABI file",r);continue}let x=f.default.extname(r),d=`${r.substring(0,r.lastIndexOf(x))}${e}`,y=e.includes(".d.")?`declare const abi: ${n};
|
|
3
|
+
|
|
4
|
+
export default abi;
|
|
5
|
+
`:`const abi = ${n} as const;
|
|
6
|
+
|
|
7
|
+
export default abi;
|
|
8
|
+
`;i("Writing",d),(0,a.writeFileSync)(d,y)}process.exit(0)}};var m=s(require("chalk"),1);c.command="$0";(0,g.default)((0,b.hideBin)(process.argv)).scriptName("abi-ts").command(c).strict().fail(o=>{console.error(m.default.red(o)),o.includes("Missing required argument")&&console.log(m.default.yellow(`Run 'pnpm abi-ts ${process.argv[2]} --help' for a list of available and required arguments.`)),process.exit(1)}).alias({h:"help"}).argv;
|
|
9
|
+
//# sourceMappingURL=abi-ts.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/bin/abi-ts.ts","../../src/command.ts","../../src/debug.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","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":";wdAEA,IAAAA,EAAkB,sBAClBC,EAAwB,yBCFxB,IAAAC,EAA4C,cAC5CC,EAAiB,qBACjBC,EAAyB,gBCHzB,IAAAC,EAAwB,sBAEXC,KAAQ,EAAAC,SAAY,QAAQ,EAC5BC,KAAQ,EAAAD,SAAY,QAAQ,EAGzCD,EAAM,IAAM,QAAQ,MAAM,KAAK,OAAO,EAGtCE,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,KAAQ,YAASF,CAAK,EAAE,KAAK,EAE9BE,EAAM,SACT,QAAQ,MAAM,4BAA4BF,CAAK,EAAE,EACjD,QAAQ,KAAK,CAAC,GAGhB,QAAWG,KAAgBD,EAAO,CAChC,IAAME,KAAO,gBAAaD,EAAc,MAAM,EAAE,KAAK,EACrD,GAAIC,IAAS,KAAM,CACjBC,EAAM,0BAA2BF,CAAY,EAC7C,QACF,CAEA,IAAMG,EAAgB,EAAAC,QAAK,QAAQJ,CAAY,EACzCK,EAAa,GAAGL,EAAa,UAAU,EAAGA,EAAa,YAAYG,CAAa,CAAC,CAAC,GAAGL,CAAW,GAEhGQ,EAAKR,EAAY,SAAS,KAAK,EACjC,sBAAsBG,CAAI;AAAA;AAAA;AAAA,EAC1B,eAAeA,CAAI;AAAA;AAAA;AAAA,EAEvBC,EAAM,UAAWG,CAAU,KAC3B,iBAAcA,EAAYC,CAAE,CAC9B,CAEA,QAAQ,KAAK,CAAC,CAChB,CACF,EDtDA,IAAAC,EAAkB,sBAIlBC,EAAa,QAAU,QAEvB,EAAAC,YAAM,WAAQ,QAAQ,IAAI,CAAC,EACxB,WAAW,QAAQ,EAGnB,QAAQD,CAAmB,EAE3B,OAAO,EAEP,KAAME,GAAQ,CACb,QAAQ,MAAM,EAAAC,QAAM,IAAID,CAAG,CAAC,EACxBA,EAAI,SAAS,2BAA2B,GAC1C,QAAQ,IACN,EAAAC,QAAM,OAAO,oBAAoB,QAAQ,KAAK,CAAC,CAAC,0DAA0D,CAC5G,EAGF,QAAQ,KAAK,CAAC,CAChB,CAAC,EAEA,MAAM,CAAE,EAAG,MAAO,CAAC,EAAE","names":["import_yargs","import_helpers","import_fs","import_path","import_glob","import_debug","debug","createDebug","error","command","yargs","input","tsExtension","files","jsonFilename","json","debug","jsonExtension","path","tsFilename","ts","import_chalk","command","yargs","msg","chalk"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";var g=Object.create;var i=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var O=(o,e)=>{for(var t in e)i(o,t,{get:e[t],enumerable:!0})},f=(o,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!I.call(o,n)&&n!==t&&i(o,n,{get:()=>e[n],enumerable:!(s=x(e,n))||s.enumerable});return o};var d=(o,e,t)=>(t=o!=null?g(S(o)):{},f(e||!o||!o.__esModule?i(t,"default",{value:o,enumerable:!0}):t,o)),h=o=>f(i({},"__esModule",{value:!0}),o);var A={};O(A,{command:()=>$});module.exports=h(A);var c=require("fs"),p=d(require("path"),1),m=require("glob");var l=d(require("debug"),1),r=(0,l.default)("abi-ts"),j=(0,l.default)("abi-ts");r.log=console.debug.bind(console);j.log=console.error.bind(console);var $={command:"abi-ts",describe:"Convert a directory of JSON ABI files to a directory of TS or DTS files with `as const`.",builder(o){return o.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:o,extension:e}){let t=(0,m.globSync)(o).sort();t.length||(console.error(`No files found for glob: ${o}`),process.exit(1));for(let s of t){let n=(0,c.readFileSync)(s,"utf8").trim();if(n==="[]"){r("Skipping empty ABI file",s);continue}let b=p.default.extname(s),a=`${s.substring(0,s.lastIndexOf(b))}${e}`,u=e.includes(".d.")?`declare const abi: ${n};
|
|
2
|
+
|
|
3
|
+
export default abi;
|
|
4
|
+
`:`const abi = ${n} as const;
|
|
5
|
+
|
|
6
|
+
export default abi;
|
|
7
|
+
`;r("Writing",a),(0,c.writeFileSync)(a,u)}process.exit(0)}};0&&(module.exports={command});
|
|
8
|
+
//# sourceMappingURL=internal.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/exports/internal.ts","../../src/command.ts","../../src/debug.ts"],"sourcesContent":["export * from \"../command\";\n","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":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GCCA,IAAAI,EAA4C,cAC5CC,EAAiB,qBACjBC,EAAyB,gBCHzB,IAAAC,EAAwB,sBAEXC,KAAQ,EAAAC,SAAY,QAAQ,EAC5BC,KAAQ,EAAAD,SAAY,QAAQ,EAGzCD,EAAM,IAAM,QAAQ,MAAM,KAAK,OAAO,EAGtCE,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,KAAQ,YAASF,CAAK,EAAE,KAAK,EAE9BE,EAAM,SACT,QAAQ,MAAM,4BAA4BF,CAAK,EAAE,EACjD,QAAQ,KAAK,CAAC,GAGhB,QAAWG,KAAgBD,EAAO,CAChC,IAAME,KAAO,gBAAaD,EAAc,MAAM,EAAE,KAAK,EACrD,GAAIC,IAAS,KAAM,CACjBC,EAAM,0BAA2BF,CAAY,EAC7C,QACF,CAEA,IAAMG,EAAgB,EAAAC,QAAK,QAAQJ,CAAY,EACzCK,EAAa,GAAGL,EAAa,UAAU,EAAGA,EAAa,YAAYG,CAAa,CAAC,CAAC,GAAGL,CAAW,GAEhGQ,EAAKR,EAAY,SAAS,KAAK,EACjC,sBAAsBG,CAAI;AAAA;AAAA;AAAA,EAC1B,eAAeA,CAAI;AAAA;AAAA;AAAA,EAEvBC,EAAM,UAAWG,CAAU,KAC3B,iBAAcA,EAAYC,CAAE,CAC9B,CAEA,QAAQ,KAAK,CAAC,CAChB,CACF","names":["internal_exports","__export","command","__toCommonJS","import_fs","import_path","import_glob","import_debug","debug","createDebug","error","command","yargs","input","tsExtension","files","jsonFilename","json","debug","jsonExtension","path","tsFilename","ts"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@latticexyz/abi-ts",
|
|
3
|
-
"version": "2.2.18-
|
|
3
|
+
"version": "2.2.18-41fe36dd2756fe87bfe141e15b6d102f4b070ab1",
|
|
4
4
|
"description": "Create TypeScript type declaration files (`.d.ts`) for your ABI JSON files.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -10,7 +10,16 @@
|
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"type": "module",
|
|
12
12
|
"exports": {
|
|
13
|
-
"./internal":
|
|
13
|
+
"./internal": {
|
|
14
|
+
"import": {
|
|
15
|
+
"import": "./dist/exports/internal.js",
|
|
16
|
+
"types": "./dist/exports/internal.d.ts"
|
|
17
|
+
},
|
|
18
|
+
"require": {
|
|
19
|
+
"require": "./dist/exports/internal.cjs",
|
|
20
|
+
"types": "./dist/exports/internal.d.cts"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
14
23
|
},
|
|
15
24
|
"typesVersions": {
|
|
16
25
|
"*": {
|