This document contains instructions for development of the smi-serve tool itself, since the main README.md is intended for external users of the tool.

## Testing changes to smi-serve

Inside the `/packages/smi-serve` directory in plush-toys, run `npm link`. This should make your local version of the package available across your system.

In a new directory outside of plush-toys, run `npx @ordergroove/smi-serve init` or whatever command you want to test. This should use your local version of smi-serve. You can verify that it is working correctly by adding a console.log message inside `smi-serve.js`. You can also verify by running `npm ls --global @ordergroove/smi-serve` - it should point to your local plush-toys directory:

```
/Users/username/node/v18.18.2/lib
└── @ordergroove/smi-serve@1.7.5 -> ./../../../../../code/plush-toys/packages/smi-serve
```

## Unlinking smi-serve

If you want to use the published version of the package instead, you will need to uninstall the package globally. Since smi-serve is not added as a project dependency, it is installed in the global npm scope.

To remove the link to your local package, run `npm uninstall @ordergroove/smi-serve -g`. You can verify that the command succeeded by running `npm ls --global @ordergroove/smi-serve`. It should show something like:

```
/Users/username/node/v18.18.2/lib
└── (empty)
```

## Debugging

After linking to your local version of smi-serve, you can debug the tool inside VS Code. First, add a `debugger` statement inside the smi-serve code you are running. Then, inside your test project directory, open the [JavaScript debug terminal](https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_javascript-debug-terminal) and run the command you want to debug. VS Code's debugger should launch and automatically break when it gets to that statement. You can then set breakpoints in the code and inspect the running process.
