@latticexyz/abi-ts 2.0.12-account-kit-10002da0 → 2.0.12-account-kit-9160f5e1a
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/package.json +4 -8
- package/src/abi-ts.ts +0 -31
- package/src/debug.ts +0 -10
- package/src/index.ts +0 -52
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@latticexyz/abi-ts",
|
|
3
|
-
"version": "2.0.12-account-kit-
|
|
3
|
+
"version": "2.0.12-account-kit-9160f5e1a",
|
|
4
4
|
"description": "Create TypeScript type declaration files (`.d.ts`) for your ABI JSON files.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,16 +12,12 @@
|
|
|
12
12
|
"exports": {
|
|
13
13
|
".": "./dist/index.js"
|
|
14
14
|
},
|
|
15
|
-
"typesVersions": {
|
|
16
|
-
"*": {
|
|
17
|
-
"index": [
|
|
18
|
-
"./src/index.ts"
|
|
19
|
-
]
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
15
|
"bin": {
|
|
23
16
|
"abi-ts": "./dist/abi-ts.js"
|
|
24
17
|
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
25
21
|
"dependencies": {
|
|
26
22
|
"chalk": "^5.3.0",
|
|
27
23
|
"debug": "^4.3.4",
|
package/src/abi-ts.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import yargs from "yargs";
|
|
4
|
-
import { hideBin } from "yargs/helpers";
|
|
5
|
-
import abiTsCommand from ".";
|
|
6
|
-
import chalk from "chalk";
|
|
7
|
-
|
|
8
|
-
// $0 makes this a default command (as opposed to a sub-command),
|
|
9
|
-
// which replaces `abi-ts abi-ts` with just `abi-ts`
|
|
10
|
-
abiTsCommand.command = "$0";
|
|
11
|
-
|
|
12
|
-
yargs(hideBin(process.argv))
|
|
13
|
-
.scriptName("abi-ts")
|
|
14
|
-
// Use the commands directory to scaffold
|
|
15
|
-
// 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
|
|
16
|
-
.command(abiTsCommand as any)
|
|
17
|
-
// Enable strict mode.
|
|
18
|
-
.strict()
|
|
19
|
-
// Custom error handler
|
|
20
|
-
.fail((msg) => {
|
|
21
|
-
console.error(chalk.red(msg));
|
|
22
|
-
if (msg.includes("Missing required argument")) {
|
|
23
|
-
console.log(
|
|
24
|
-
chalk.yellow(`Run 'pnpm abi-ts ${process.argv[2]} --help' for a list of available and required arguments.`),
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
process.exit(1);
|
|
29
|
-
})
|
|
30
|
-
// Useful aliases.
|
|
31
|
-
.alias({ h: "help" }).argv;
|
package/src/debug.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import createDebug from "debug";
|
|
2
|
-
|
|
3
|
-
export const debug = createDebug("abi-ts");
|
|
4
|
-
export const error = createDebug("abi-ts");
|
|
5
|
-
|
|
6
|
-
// Pipe debug output to stdout instead of stderr
|
|
7
|
-
debug.log = console.debug.bind(console);
|
|
8
|
-
|
|
9
|
-
// Pipe error output to stderr
|
|
10
|
-
error.log = console.error.bind(console);
|
package/src/index.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { CommandModule } from "yargs";
|
|
2
|
-
import { readFileSync, writeFileSync } from "fs";
|
|
3
|
-
import glob from "glob";
|
|
4
|
-
import { debug } from "./debug";
|
|
5
|
-
|
|
6
|
-
type Options = {
|
|
7
|
-
input: string;
|
|
8
|
-
output: string;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const commandModule: CommandModule<Options, Options> = {
|
|
12
|
-
command: "abi-ts",
|
|
13
|
-
|
|
14
|
-
describe: "Convert a directory of JSON ABI files to a directory of TS files with `as const`",
|
|
15
|
-
|
|
16
|
-
builder(yargs) {
|
|
17
|
-
return yargs.options({
|
|
18
|
-
input: {
|
|
19
|
-
type: "string",
|
|
20
|
-
desc: "Input glob of ABI JSON files",
|
|
21
|
-
default: "**/*.abi.json",
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
handler({ input }) {
|
|
27
|
-
const files = glob.sync(input);
|
|
28
|
-
|
|
29
|
-
if (!files.length) {
|
|
30
|
-
console.error(`No files found for glob: ${input}`);
|
|
31
|
-
process.exit(1);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
for (const jsonFilename of files) {
|
|
35
|
-
const json = readFileSync(jsonFilename, "utf8").trim();
|
|
36
|
-
if (json === "[]") {
|
|
37
|
-
debug("Skipping empty ABI file", jsonFilename);
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const ts = `declare const abi: ${json}; export default abi;\n`;
|
|
42
|
-
const tsFilename = `${jsonFilename}.d.ts`;
|
|
43
|
-
|
|
44
|
-
debug("Writing", tsFilename);
|
|
45
|
-
writeFileSync(tsFilename, ts);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
process.exit(0);
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export default commandModule;
|