Hi, I am looking for documentation on how to use the
tools in the Nx monorepo setup
Let’s for example say that I have custom node script that I want to execute using an “npm script”, but want to write it in typescript. Is the
tools folder the right place to do this?
What are some best practices for this?
Yes, that’s what tools are there for. Anything that is related to your codebase, but isn’t actually application code.
Thanks for your quick answer :slightly_smiling_face: Is there documentation around this somewhere? I don’t seem to find it
I generally use it like this in package.json’s scripts:
"setup": "ts-node -P ./tools/tsconfig.tools.json ./tools/setup.ts",
"migrate:reset": "ts-node -P ./tools/tsconfig.tools.json ./tools/migrate-reset.ts",
Just a couple sentences here: https://nx.dev/angular/workspace/workspace-overview
it would be worthwhile to add a section on writing and executing node scripts in the /tools directory. Zack DeRose is also working on an article all about how to make a “workspace” builder inside your tools directory - similar to the way workspace schematics are placed in the tools directory.
If you’re going to make a custom node script, it might be worthwhile to run it with the
run-commands builder, like this: https://nx.dev/angular/workspace/builders/run-commands-builder
That way you can use it with affected and also take advantage of caching.