Buckets:
| # Using Zuke in a Node/npm project | |
| Zuke can drive a Node project's build without touching its dependencies — build | |
| logic in a `build/` folder that lives next to the code. Deno is the only | |
| prerequisite (it runs the build; your app keeps its Node toolchain): | |
| ``` | |
| my-app/ | |
| package.json # your app — no zuke dependency added | |
| src/ ... | |
| build/ | |
| deno.json # the build project's config | |
| zuke.ts # your targets | |
| ``` | |
| 1. Install Deno: <https://docs.deno.com/runtime/getting_started/installation/> | |
| 2. Create `build/deno.json`: | |
| ```json | |
| { | |
| "imports": { | |
| "@zuke/core": "jsr:@zuke/core@^1", | |
| "@zuke/npm": "jsr:@zuke/npm@^1" | |
| } | |
| } | |
| ``` | |
| 3. Create `build/zuke.ts` — targets drive the repo root via `.cwd("..")`: | |
| <!-- check --> | |
| ```ts | |
| import { Build, run, target } from "@zuke/core"; | |
| import { NpmTasks } from "@zuke/npm"; | |
| class AppBuild extends Build { | |
| install = target() | |
| .description("Clean-install dependencies") | |
| .executes(async () => { | |
| await NpmTasks.ci((s) => s.cwd("..")); | |
| }); | |
| test = target() | |
| .description("Run the app's test script") | |
| .dependsOn(this.install) | |
| .executes(async () => { | |
| await NpmTasks.run((s) => s.script("test").cwd("..")); | |
| }); | |
| pack = target() | |
| .description("Verify the publishable tarball") | |
| .dependsOn(this.test) | |
| .executes(async () => { | |
| await NpmTasks.publish((s) => s.dryRun().cwd("..")); | |
| }); | |
| default = target() | |
| .description("Default: install → test → pack") | |
| .dependsOn(this.pack) | |
| .executes(() => {}); | |
| } | |
| await run(AppBuild); | |
| ``` | |
| 4. Bridge it for npm-centric contributors — in `package.json`: | |
| ```json | |
| { | |
| "scripts": { | |
| "build": "deno run -A build/zuke.ts" | |
| } | |
| } | |
| ``` | |
| Now `npm run build` runs the default pipeline, `npm run build -- test` runs one | |
| target, and `npm run build -- --list` / `-- graph` show what the build can do — | |
| no one has to learn Deno commands. | |
| > **`zuke` command note.** The [`zuke` command](./install.md) runs the `zuke.ts` | |
| > beside the project's `zuke.json` marker at the repo root, as does the | |
| > bootstrap launcher (`./zuke` / `zuke.ps1`) it stands in for — neither knows | |
| > about a `build/` subdirectory. With this layout, invoke the build directly | |
| > with `deno run -A build/zuke.ts` (or the `npm run build` script above), not | |
| > `zuke`. If you'd rather use `zuke`, put `zuke.ts` at the repo root instead of | |
| > under `build/` — the layout `zuke setup` scaffolds. | |
| ## Other package managers | |
| The same pattern applies to the other JS package managers, each with its own | |
| wrapper: [`@zuke/bun`](../packages/bun) (`BunTasks` — also `bun test`), | |
| [`@zuke/pnpm`](../packages/pnpm) (`PnpmTasks`, with `--filter` for workspaces), | |
| and [`@zuke/yarn`](../packages/yarn) (`YarnTasks`, Classic and Berry). For | |
| example, `await PnpmTasks.install((s) => s.frozenLockfile())` or | |
| `await BunTasks.run((s) => s.script("build"))`. | |
| To download and run a package binary in one step, [`@zuke/npx`](../packages/npx) | |
| (`NpxTasks`) wraps `npx` — npm's sibling of `bun x` and `pnpm dlx`. For example, | |
| `await NpxTasks.npx((s) => s.command("cowsay").yes().execArgs("hello"))`. | |
Xet Storage Details
- Size:
- 3.13 kB
- Xet hash:
- 49d5b010922cdd31a3781154e32136bb089d3f7bdd5b0fe9732153a1e74629f2
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.