Skip to content

Commit

Permalink
chore(cli): support and document debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesLefrere committed Jan 18, 2025
1 parent 9e1af4c commit a5b96a3
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
30 changes: 29 additions & 1 deletion packages/cli/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
# cli

docs coming soon
## Usage

See usage documentation on the [MUD docs](https://mud.dev/cli/tablegen).

## Development

### Debugging

The CLI can be run in a debug environment:

1. Set the `MUD_PACKAGES` environment variable (see `tsup.config.ts`)
```bash
export MUD_PACKAGES=$(tsx ./scripts/log-mud-packages)
```
2. Setup your debugger with `tsx` as the TypeScript loader and `src/mud.ts` as the entrypoint
3. Set the arguments to whichever command you want to run (e.g. `deploy`) and its options.
- Important: add the `--configPath` option as the path of your project's `mud.config.ts` file, because the current working directory will otherwise be the CLI source.

The CLI should now run in your debugger with TypeScript support.

### Production build

The project can be built for production with `tsup`:

```bash
pnpm build
```

`pnpm link` can be used to run the locally-built package.
5 changes: 5 additions & 0 deletions packages/cli/scripts/log-mud-packages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import defineConfig from "../tsup.config";

// Log out the MUD_PACKAGES env var so it can be used to run the CLI in development mode
// @ts-expect-error: defineConfig return type is not properly inferred
console.log(defineConfig({}).env.MUD_PACKAGES);
3 changes: 3 additions & 0 deletions packages/cli/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { defineConfig } from "tsup";
import { globSync } from "glob";
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import path from "node:path";
import { MudPackages } from "./src/common";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const mudWorkspace = path.normalize(`${__dirname}/../..`);

const mudPackages: MudPackages = Object.fromEntries(
Expand Down

0 comments on commit a5b96a3

Please sign in to comment.