Maintaining code around the CLI tool
The code is in src/cli/. The CLI commands are built using steps set in package.json.
- See
cli:installandbinsection, which are both related and work withnpm link. - See
make cli-buildwhich is for building binaries withpkgfor distribution. See pkg page on NPM docs.
Run a script directly without compiling:
$ npx ts-node src/cli/diffIndexGenerate.ts
$ npx ts-node src/cli/diffIndexGenerateCommit.ts
$ npx ts-node src/cli/generate.ts$ npm install
$ npm run cli:installSee Releases for info on the release pipeline to publish the binaries.
Build the CLI as a binary which can be installed without the source code or Node.
$ make cli-buildNote
In Makefile, Node 18 is set to avoid errors from pkg. Even though 22 is set in package.json and is active with NVM. Check the pkg docs for more info on available versions.
Check the dist directory once it is created. These are added to a release.
On macOS, installed here as a symlink pointing to the .js file in the repo:
/opt/homebrew/bin/acm
If you get permissions issues, it is because the .js file was rebuilt and with standard permissions and needs to be linked again.
$ npm run cliCheck:
ls -l $(realpath /opt/homebrew/bin/acm)See package.json.
Supposedly you should be able to leave out the project name when running npm link via an npm run ... command but I found this causes issues, so decided to always use the full name in the configuration. But removed it later . And to always unlink then link in one go because of permissions issues.