@latticexyz/abi-ts 2.2.18-9fa07c8489f1fbf167d0db01cd9aaa645a29c8e2 → 2.2.18-c2ad22c7feb566e1731ff16e8be291746bdffb3e
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 +1 -18
- package/dist/bin/abi-ts.js.map +1 -1
- package/dist/chunk-2LMRZYSL.js +8 -0
- package/dist/{chunk-GU6G2RXN.js.map → chunk-2LMRZYSL.js.map} +1 -1
- package/dist/exports/internal.js +1 -6
- package/package.json +3 -12
- package/dist/bin/abi-ts.cjs +0 -100
- package/dist/bin/abi-ts.cjs.map +0 -1
- package/dist/bin/abi-ts.d.cts +0 -1
- package/dist/chunk-GU6G2RXN.js +0 -62
- package/dist/exports/internal.cjs +0 -98
- package/dist/exports/internal.cjs.map +0 -1
- package/dist/exports/internal.d.cts +0 -9
package/dist/bin/abi-ts.js
CHANGED
|
@@ -1,20 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
command
|
|
4
|
-
} from "../chunk-GU6G2RXN.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;
|
|
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;
|
|
20
3
|
//# sourceMappingURL=abi-ts.js.map
|
package/dist/bin/abi-ts.js.map
CHANGED
|
@@ -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":"
|
|
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"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
|
@@ -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":"
|
|
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"]}
|
package/dist/exports/internal.js
CHANGED
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-c2ad22c7feb566e1731ff16e8be291746bdffb3e",
|
|
4
4
|
"description": "Create TypeScript type declaration files (`.d.ts`) for your ABI JSON files.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -10,16 +10,7 @@
|
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"type": "module",
|
|
12
12
|
"exports": {
|
|
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
|
-
}
|
|
13
|
+
"./internal": "./dist/exports/internal.js"
|
|
23
14
|
},
|
|
24
15
|
"typesVersions": {
|
|
25
16
|
"*": {
|
|
@@ -52,7 +43,7 @@
|
|
|
52
43
|
"build": "tsup",
|
|
53
44
|
"clean": "shx rm -rf dist",
|
|
54
45
|
"dev": "tsup --watch",
|
|
55
|
-
"test": "vitest --run",
|
|
46
|
+
"test": "vitest typecheck --run --passWithNoTests && vitest --run --passWithNoTests",
|
|
56
47
|
"test:ci": "pnpm run test"
|
|
57
48
|
}
|
|
58
49
|
}
|
package/dist/bin/abi-ts.cjs
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
-
mod
|
|
24
|
-
));
|
|
25
|
-
|
|
26
|
-
// src/bin/abi-ts.ts
|
|
27
|
-
var import_yargs = __toESM(require("yargs"), 1);
|
|
28
|
-
var import_helpers = require("yargs/helpers");
|
|
29
|
-
|
|
30
|
-
// src/command.ts
|
|
31
|
-
var import_fs = require("fs");
|
|
32
|
-
var import_path = __toESM(require("path"), 1);
|
|
33
|
-
var import_glob = require("glob");
|
|
34
|
-
|
|
35
|
-
// src/debug.ts
|
|
36
|
-
var import_debug = __toESM(require("debug"), 1);
|
|
37
|
-
var debug = (0, import_debug.default)("abi-ts");
|
|
38
|
-
var error = (0, import_debug.default)("abi-ts");
|
|
39
|
-
debug.log = console.debug.bind(console);
|
|
40
|
-
error.log = console.error.bind(console);
|
|
41
|
-
|
|
42
|
-
// src/command.ts
|
|
43
|
-
var command = {
|
|
44
|
-
command: "abi-ts",
|
|
45
|
-
describe: "Convert a directory of JSON ABI files to a directory of TS or DTS files with `as const`.",
|
|
46
|
-
builder(yargs2) {
|
|
47
|
-
return yargs2.options({
|
|
48
|
-
input: {
|
|
49
|
-
type: "string",
|
|
50
|
-
desc: "Input glob of ABI JSON files.",
|
|
51
|
-
default: "**/*.abi.json"
|
|
52
|
-
},
|
|
53
|
-
extension: {
|
|
54
|
-
type: "string",
|
|
55
|
-
desc: "Extension of the resulting ABI TS or DTS file.",
|
|
56
|
-
default: ".json.d.ts"
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
},
|
|
60
|
-
handler({ input, extension: tsExtension }) {
|
|
61
|
-
const files = (0, import_glob.globSync)(input).sort();
|
|
62
|
-
if (!files.length) {
|
|
63
|
-
console.error(`No files found for glob: ${input}`);
|
|
64
|
-
process.exit(1);
|
|
65
|
-
}
|
|
66
|
-
for (const jsonFilename of files) {
|
|
67
|
-
const json = (0, import_fs.readFileSync)(jsonFilename, "utf8").trim();
|
|
68
|
-
if (json === "[]") {
|
|
69
|
-
debug("Skipping empty ABI file", jsonFilename);
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
const jsonExtension = import_path.default.extname(jsonFilename);
|
|
73
|
-
const tsFilename = `${jsonFilename.substring(0, jsonFilename.lastIndexOf(jsonExtension))}${tsExtension}`;
|
|
74
|
-
const ts = tsExtension.includes(".d.") ? `declare const abi: ${json};
|
|
75
|
-
|
|
76
|
-
export default abi;
|
|
77
|
-
` : `const abi = ${json} as const;
|
|
78
|
-
|
|
79
|
-
export default abi;
|
|
80
|
-
`;
|
|
81
|
-
debug("Writing", tsFilename);
|
|
82
|
-
(0, import_fs.writeFileSync)(tsFilename, ts);
|
|
83
|
-
}
|
|
84
|
-
process.exit(0);
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
// src/bin/abi-ts.ts
|
|
89
|
-
var import_chalk = __toESM(require("chalk"), 1);
|
|
90
|
-
command.command = "$0";
|
|
91
|
-
(0, import_yargs.default)((0, import_helpers.hideBin)(process.argv)).scriptName("abi-ts").command(command).strict().fail((msg) => {
|
|
92
|
-
console.error(import_chalk.default.red(msg));
|
|
93
|
-
if (msg.includes("Missing required argument")) {
|
|
94
|
-
console.log(
|
|
95
|
-
import_chalk.default.yellow(`Run 'pnpm abi-ts ${process.argv[2]} --help' for a list of available and required arguments.`)
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
process.exit(1);
|
|
99
|
-
}).alias({ h: "help" }).argv;
|
|
100
|
-
//# sourceMappingURL=abi-ts.cjs.map
|
package/dist/bin/abi-ts.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,mBAAkB;AAClB,qBAAwB;;;ACFxB,gBAA4C;AAC5C,kBAAiB;AACjB,kBAAyB;;;ACHzB,mBAAwB;AAEjB,IAAM,YAAQ,aAAAA,SAAY,QAAQ;AAClC,IAAM,YAAQ,aAAAA,SAAY,QAAQ;AAGzC,MAAM,MAAM,QAAQ,MAAM,KAAK,OAAO;AAGtC,MAAM,MAAM,QAAQ,MAAM,KAAK,OAAO;;;ADE/B,IAAM,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GAAG;AAC7C,YAAQ;AAAA,MACN,aAAAA,QAAM,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":["createDebug","yargs","path","yargs","chalk"]}
|
package/dist/bin/abi-ts.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
package/dist/chunk-GU6G2RXN.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
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-GU6G2RXN.js.map
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/exports/internal.ts
|
|
31
|
-
var internal_exports = {};
|
|
32
|
-
__export(internal_exports, {
|
|
33
|
-
command: () => command
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(internal_exports);
|
|
36
|
-
|
|
37
|
-
// src/command.ts
|
|
38
|
-
var import_fs = require("fs");
|
|
39
|
-
var import_path = __toESM(require("path"), 1);
|
|
40
|
-
var import_glob = require("glob");
|
|
41
|
-
|
|
42
|
-
// src/debug.ts
|
|
43
|
-
var import_debug = __toESM(require("debug"), 1);
|
|
44
|
-
var debug = (0, import_debug.default)("abi-ts");
|
|
45
|
-
var error = (0, import_debug.default)("abi-ts");
|
|
46
|
-
debug.log = console.debug.bind(console);
|
|
47
|
-
error.log = console.error.bind(console);
|
|
48
|
-
|
|
49
|
-
// src/command.ts
|
|
50
|
-
var command = {
|
|
51
|
-
command: "abi-ts",
|
|
52
|
-
describe: "Convert a directory of JSON ABI files to a directory of TS or DTS files with `as const`.",
|
|
53
|
-
builder(yargs) {
|
|
54
|
-
return yargs.options({
|
|
55
|
-
input: {
|
|
56
|
-
type: "string",
|
|
57
|
-
desc: "Input glob of ABI JSON files.",
|
|
58
|
-
default: "**/*.abi.json"
|
|
59
|
-
},
|
|
60
|
-
extension: {
|
|
61
|
-
type: "string",
|
|
62
|
-
desc: "Extension of the resulting ABI TS or DTS file.",
|
|
63
|
-
default: ".json.d.ts"
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
},
|
|
67
|
-
handler({ input, extension: tsExtension }) {
|
|
68
|
-
const files = (0, import_glob.globSync)(input).sort();
|
|
69
|
-
if (!files.length) {
|
|
70
|
-
console.error(`No files found for glob: ${input}`);
|
|
71
|
-
process.exit(1);
|
|
72
|
-
}
|
|
73
|
-
for (const jsonFilename of files) {
|
|
74
|
-
const json = (0, import_fs.readFileSync)(jsonFilename, "utf8").trim();
|
|
75
|
-
if (json === "[]") {
|
|
76
|
-
debug("Skipping empty ABI file", jsonFilename);
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
const jsonExtension = import_path.default.extname(jsonFilename);
|
|
80
|
-
const tsFilename = `${jsonFilename.substring(0, jsonFilename.lastIndexOf(jsonExtension))}${tsExtension}`;
|
|
81
|
-
const ts = tsExtension.includes(".d.") ? `declare const abi: ${json};
|
|
82
|
-
|
|
83
|
-
export default abi;
|
|
84
|
-
` : `const abi = ${json} as const;
|
|
85
|
-
|
|
86
|
-
export default abi;
|
|
87
|
-
`;
|
|
88
|
-
debug("Writing", tsFilename);
|
|
89
|
-
(0, import_fs.writeFileSync)(tsFilename, ts);
|
|
90
|
-
}
|
|
91
|
-
process.exit(0);
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
95
|
-
0 && (module.exports = {
|
|
96
|
-
command
|
|
97
|
-
});
|
|
98
|
-
//# sourceMappingURL=internal.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,gBAA4C;AAC5C,kBAAiB;AACjB,kBAAyB;;;ACHzB,mBAAwB;AAEjB,IAAM,YAAQ,aAAAA,SAAY,QAAQ;AAClC,IAAM,YAAQ,aAAAA,SAAY,QAAQ;AAGzC,MA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