Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(abi-ts): move logs to debug #1736

Merged
merged 2 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/new-falcons-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/abi-ts": minor
---

Moves log output behind a debug flag. You can enable logging with `DEBUG=abi-ts` environment variable.
2 changes: 2 additions & 0 deletions packages/abi-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@
},
"dependencies": {
"chalk": "^5.3.0",
"debug": "^4.3.4",
"execa": "^7.0.0",
"glob": "^8.0.3",
"yargs": "^17.7.1"
},
"devDependencies": {
"@types/debug": "^4.1.7",
"@types/glob": "^7.2.0",
"@types/node": "^18.15.11",
"@types/yargs": "^17.0.10",
Expand Down
3 changes: 3 additions & 0 deletions packages/abi-ts/src/debug.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import createDebug from "debug";

export const debug = createDebug("abi-ts");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

intentionally didn't prefix with mud: because this package doesn't have any MUD dependencies and kind of lives outside the framework

6 changes: 3 additions & 3 deletions packages/abi-ts/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { CommandModule } from "yargs";
import { readFileSync, writeFileSync } from "fs";
import glob from "glob";
import path from "path";
import { debug } from "./debug";

type Options = {
input: string;
Expand Down Expand Up @@ -34,14 +34,14 @@ const commandModule: CommandModule<Options, Options> = {
for (const jsonFilename of files) {
const json = readFileSync(jsonFilename, "utf8").trim();
if (json === "[]") {
console.log("Skipping empty ABI file", jsonFilename);
debug("Skipping empty ABI file", jsonFilename);
continue;
}

const ts = `declare const abi: ${json}; export default abi;\n`;
const tsFilename = `${jsonFilename}.d.ts`;

console.log("Writing", tsFilename);
debug("Writing", tsFilename);
writeFileSync(tsFilename, ts);
}

Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.