Skip to content

Adopt Nadle Gradually ​

You do not have to convert a project in one go. Nadle can run next to the scripts you already have: every script becomes a task that calls it, and you replace one body at a time while CI and teammates keep using the same commands.

1. Wrap every script ​

Run the scaffolder with --wrap:

bash
npm create nadle -- --wrap
bash
yarn create nadle --wrap
bash
pnpm create nadle --wrap

Without --yes it also offers the choice as a prompt ("Wrap all"). Nothing is converted. Every script, lifecycle and long-running ones included, becomes a task that runs it through the package manager. For this package.json:

json
{
	"scripts": {
		"build": "tsc",
		"build:docs": "typedoc",
		"lint": "eslint . && prettier --check ."
	}
}

the scaffolder writes:

ts
import { tasks, NpmTask } from "nadle";

tasks.register("build", { run: NpmTask, options: { args: ["run", "build"] } });

tasks.register("build-docs", { run: NpmTask, options: { args: ["run", "build:docs"] } });

tasks.register("lint", { run: NpmTask, options: { args: ["run", "lint"] } });

npx nadle lint now runs npm run lint, shell operators and all, and prints its output. The wrapper is PnpmTask with pnpm and ExecTask with command: "yarn" or "bun". package.json is not touched.

A colon separates workspaces in nadle, so build:docs is the task build-docs. The scaffolder lists every rename. npm run build:docs and nadle build-docs do the same thing.

2. Convert one task at a time ​

Pick a task and replace its run and options with a native task. Keep the name, so dependsOn entries and CI commands keep working:

ts
import { tasks, NpmTask, ExecTask } from "nadle";

tasks.register("build", { run: ExecTask, options: { command: "tsc" } }); // converted

tasks.register("lint", { run: NpmTask, options: { args: ["run", "lint"] } }); // still wrapped

Wrapped and native tasks mix freely: either can be a dependsOn target. See Migrating from npm Scripts for how common script shapes map. Keep a script wrapped while it uses shell syntax (&&, pipes, redirects, quotes, globs), because ExecTask does not run a shell.

Without --wrap, the scaffolder does this conversion for the scripts it can and wraps the rest. It prints one line per script (converted, wrapped or skipped, and why), so nothing is dropped silently.

3. Point scripts at nadle ​

Once a task is native, a script can call it so npm run build and CI go through nadle:

diff
-"build": "tsc"
+"build": "nadle build"

Do this for converted tasks only. A script that a task wraps must keep its command: rewriting "lint" to "nadle lint" while the lint task runs npm run lint makes the task call itself.

The scaffolder can do it for you with --rewrite-scripts, or by a prompt in interactive mode. It is off by default, prints the diff it applies, and rewrites a script only when its task is native. It keeps a script as it is when:

  • the task calls the package manager (npm test), which could call the script back;
  • a pre<name> script exists, because the package manager would run the hook and the task would run it again.
text
package.json scripts:
  - "clean": "node clean.js"
  + "clean": "nadle clean"
  = "build" kept: the package manager runs "prebuild" first and the task runs it again

--rewrite-scripts applies only while the scaffolder writes nadle.config.ts. To change scripts later, edit them by hand following the rule above.

Things to know ​

  • Tasks that dependsOn several tasks may run them in parallel, unlike a && b. Add a dependency between them if order matters.
  • The scaffolder skips an existing nadle.config.ts in --yes mode and asks before overwriting it in interactive mode.
  • Extra flags typed after npm run <script> reach nadle once the script calls it. See Flags typed after a script.