|
| 1 | +# pnpm + Turborepo Workspace Example |
| 2 | + |
| 3 | +A minimal pnpm workspace with Turborepo task wiring, used to prove workspace-aware script routing on a realistic monorepo shape: |
| 4 | + |
| 5 | +```text |
| 6 | +apps/api @example/api (test, typecheck scripts) |
| 7 | +packages/utils @example/utils (test, typecheck scripts) |
| 8 | +package.json root turbo run test / typecheck |
| 9 | +``` |
| 10 | + |
| 11 | +`apps/api` depends on `@example/utils`, and both packages own separate `test` and `typecheck` scripts, so the right routing answer changes with the task. |
| 12 | + |
| 13 | +## Tasks and expected routing |
| 14 | + |
| 15 | +From the repository root: |
| 16 | + |
| 17 | +```bash |
| 18 | +npm install |
| 19 | +npm run build |
| 20 | +node packages/cli/dist/cli.js plan --issue "roundToCents keeps fractions of a cent when formatting currency" --repo examples/pnpm-turbo-workspace |
| 21 | +``` |
| 22 | + |
| 23 | +- Context should rank `packages/utils/src/currency.ts`. |
| 24 | +- The first test route should be `pnpm --dir packages/utils run test` — the nearest package, not the root `turbo run test`. |
| 25 | + |
| 26 | +```bash |
| 27 | +node packages/cli/dist/cli.js plan --issue "orderTotal ignores unknown discountCode values" --repo examples/pnpm-turbo-workspace |
| 28 | +``` |
| 29 | + |
| 30 | +- Context should rank `apps/api/src/orders.ts` first. |
| 31 | +- The first test route should switch to `pnpm --dir apps/api run test`. |
| 32 | + |
| 33 | +The full generated reports are checked in under [`../reports/`](../reports) (outside this example so the reports never feed back into their own scan): |
| 34 | + |
| 35 | +- [`../reports/workspace-utils-rounding.md`](../reports/workspace-utils-rounding.md) |
| 36 | +- [`../reports/workspace-api-discount.md`](../reports/workspace-api-discount.md) |
| 37 | + |
| 38 | +## CI guard |
| 39 | + |
| 40 | +`npm run smoke` runs [`scripts/smoke-workspace.mjs`](../../scripts/smoke-workspace.mjs), which asserts the nearest-package routing for both tasks and fails if the checked-in reports drift from generated output. After an intentional ranking change, refresh them with: |
| 41 | + |
| 42 | +```bash |
| 43 | +node scripts/smoke-workspace.mjs --update |
| 44 | +``` |
0 commit comments