@zukhruf/nx 0.8.29 → 0.8.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/README.md +825 -9
  2. package/dist/generators/add-keys.d.ts +7 -0
  3. package/dist/generators/add-keys.d.ts.map +1 -0
  4. package/dist/generators/add-keys.js +14 -0
  5. package/dist/generators/add-keys.js.map +1 -0
  6. package/dist/generators/add-lines.d.ts +8 -0
  7. package/dist/generators/add-lines.d.ts.map +1 -0
  8. package/dist/generators/add-lines.js +21 -0
  9. package/dist/generators/add-lines.js.map +1 -0
  10. package/dist/generators/app-directory.d.ts +17 -0
  11. package/dist/generators/app-directory.d.ts.map +1 -0
  12. package/dist/generators/app-directory.js +34 -0
  13. package/dist/generators/app-directory.js.map +1 -0
  14. package/dist/generators/dokploy/files.d.ts +21 -0
  15. package/dist/generators/dokploy/files.d.ts.map +1 -0
  16. package/dist/generators/dokploy/files.js +755 -0
  17. package/dist/generators/dokploy/files.js.map +1 -0
  18. package/dist/generators/dokploy/generator.d.ts +75 -0
  19. package/dist/generators/dokploy/generator.d.ts.map +1 -0
  20. package/dist/generators/dokploy/generator.js +139 -0
  21. package/dist/generators/dokploy/generator.js.map +1 -0
  22. package/dist/generators/dokploy/providers.d.ts +15 -0
  23. package/dist/generators/dokploy/providers.d.ts.map +1 -0
  24. package/dist/generators/dokploy/providers.js +114 -0
  25. package/dist/generators/dokploy/providers.js.map +1 -0
  26. package/dist/generators/init/files.d.ts +81 -0
  27. package/dist/generators/init/files.d.ts.map +1 -0
  28. package/dist/generators/init/files.js +278 -0
  29. package/dist/generators/init/files.js.map +1 -0
  30. package/dist/generators/init/generator.d.ts +8 -0
  31. package/dist/generators/init/generator.d.ts.map +1 -0
  32. package/dist/generators/init/generator.js +72 -0
  33. package/dist/generators/init/generator.js.map +1 -0
  34. package/dist/generators/init/nx-json.d.ts +20 -0
  35. package/dist/generators/init/nx-json.d.ts.map +1 -0
  36. package/dist/generators/init/nx-json.js +126 -0
  37. package/dist/generators/init/nx-json.js.map +1 -0
  38. package/dist/generators/init/root-package-json.d.ts +25 -0
  39. package/dist/generators/init/root-package-json.d.ts.map +1 -0
  40. package/dist/generators/init/root-package-json.js +49 -0
  41. package/dist/generators/init/root-package-json.js.map +1 -0
  42. package/dist/generators/node-app/files.d.ts +43 -0
  43. package/dist/generators/node-app/files.d.ts.map +1 -0
  44. package/dist/generators/node-app/files.js +522 -0
  45. package/dist/generators/node-app/files.js.map +1 -0
  46. package/dist/generators/node-app/generator.d.ts +17 -0
  47. package/dist/generators/node-app/generator.d.ts.map +1 -0
  48. package/dist/generators/node-app/generator.js +319 -0
  49. package/dist/generators/node-app/generator.js.map +1 -0
  50. package/dist/generators/nx-plugin.d.ts +16 -0
  51. package/dist/generators/nx-plugin.d.ts.map +1 -0
  52. package/dist/generators/nx-plugin.js +27 -0
  53. package/dist/generators/nx-plugin.js.map +1 -0
  54. package/dist/generators/pair/files.d.ts +4 -0
  55. package/dist/generators/pair/files.d.ts.map +1 -0
  56. package/dist/generators/pair/files.js +73 -0
  57. package/dist/generators/pair/files.js.map +1 -0
  58. package/dist/generators/pair/generator.d.ts +19 -0
  59. package/dist/generators/pair/generator.d.ts.map +1 -0
  60. package/dist/generators/pair/generator.js +70 -0
  61. package/dist/generators/pair/generator.js.map +1 -0
  62. package/dist/generators/preset/generator.d.ts +14 -0
  63. package/dist/generators/preset/generator.d.ts.map +1 -0
  64. package/dist/generators/preset/generator.js +43 -0
  65. package/dist/generators/preset/generator.js.map +1 -0
  66. package/dist/generators/prisma/files.d.ts +20 -0
  67. package/dist/generators/prisma/files.d.ts.map +1 -0
  68. package/dist/generators/prisma/files.js +183 -0
  69. package/dist/generators/prisma/files.js.map +1 -0
  70. package/dist/generators/prisma/generator.d.ts +17 -0
  71. package/dist/generators/prisma/generator.d.ts.map +1 -0
  72. package/dist/generators/prisma/generator.js +258 -0
  73. package/dist/generators/prisma/generator.js.map +1 -0
  74. package/dist/generators/react-app/files.d.ts +7 -0
  75. package/dist/generators/react-app/files.d.ts.map +1 -0
  76. package/dist/generators/react-app/files.js +188 -0
  77. package/dist/generators/react-app/files.js.map +1 -0
  78. package/dist/generators/react-app/generator.d.ts +12 -0
  79. package/dist/generators/react-app/generator.d.ts.map +1 -0
  80. package/dist/generators/react-app/generator.js +242 -0
  81. package/dist/generators/react-app/generator.js.map +1 -0
  82. package/dist/generators/react.d.ts +29 -0
  83. package/dist/generators/react.d.ts.map +1 -0
  84. package/dist/generators/react.js +64 -0
  85. package/dist/generators/react.js.map +1 -0
  86. package/dist/generators/root-dependencies.d.ts +21 -0
  87. package/dist/generators/root-dependencies.d.ts.map +1 -0
  88. package/dist/generators/root-dependencies.js +56 -0
  89. package/dist/generators/root-dependencies.js.map +1 -0
  90. package/dist/generators/ui-package/files.d.ts +37 -0
  91. package/dist/generators/ui-package/files.d.ts.map +1 -0
  92. package/dist/generators/ui-package/files.js +118 -0
  93. package/dist/generators/ui-package/files.js.map +1 -0
  94. package/dist/generators/ui-package/generator.d.ts +14 -0
  95. package/dist/generators/ui-package/generator.d.ts.map +1 -0
  96. package/dist/generators/ui-package/generator.js +111 -0
  97. package/dist/generators/ui-package/generator.js.map +1 -0
  98. package/dist/generators/versions.d.ts +72 -0
  99. package/dist/generators/versions.d.ts.map +1 -0
  100. package/dist/generators/versions.js +110 -0
  101. package/dist/generators/versions.js.map +1 -0
  102. package/dist/generators/workspace-scope.d.ts +8 -0
  103. package/dist/generators/workspace-scope.d.ts.map +1 -0
  104. package/dist/generators/workspace-scope.js +15 -0
  105. package/dist/generators/workspace-scope.js.map +1 -0
  106. package/dist/opentofu/check-plan-fresh.d.ts +2 -0
  107. package/dist/opentofu/check-plan-fresh.d.ts.map +1 -0
  108. package/dist/opentofu/check-plan-fresh.js +47 -0
  109. package/dist/opentofu/check-plan-fresh.js.map +1 -0
  110. package/dist/opentofu/plugin.d.ts +9 -0
  111. package/dist/opentofu/plugin.d.ts.map +1 -0
  112. package/dist/opentofu/plugin.js +108 -0
  113. package/dist/opentofu/plugin.js.map +1 -0
  114. package/dist/prisma/plugin.d.ts +9 -0
  115. package/dist/prisma/plugin.d.ts.map +1 -0
  116. package/dist/prisma/plugin.js +83 -0
  117. package/dist/prisma/plugin.js.map +1 -0
  118. package/dist/project-roots.d.ts +5 -0
  119. package/dist/project-roots.d.ts.map +1 -1
  120. package/dist/project-roots.js +10 -0
  121. package/dist/project-roots.js.map +1 -1
  122. package/dist/test/plugin.js +1 -7
  123. package/dist/test/plugin.js.map +1 -1
  124. package/generators.json +44 -0
  125. package/package.json +44 -5
  126. package/src/generators/dokploy/schema.json +48 -0
  127. package/src/generators/init/schema.json +8 -0
  128. package/src/generators/node-app/schema.json +22 -0
  129. package/src/generators/pair/schema.json +18 -0
  130. package/src/generators/preset/schema.json +18 -0
  131. package/src/generators/prisma/schema.json +21 -0
  132. package/src/generators/react-app/schema.json +17 -0
  133. package/src/generators/ui-package/schema.json +22 -0
package/README.md CHANGED
@@ -1,22 +1,117 @@
1
1
  # @zukhruf/nx
2
2
 
3
- This package is the Nx part of the monorepo standard. Each workspace copied the same Nx configuration into each project. This package gives that configuration one time, in areas. Each area has its own import path, and the package has no root entry point. The lint rules stay in `@zukhruf/eslint`, and the Git hooks stay in `@zukhruf/git-hooks`.
3
+ This package is the Nx part of the monorepo standard. Each workspace copied the same Nx configuration into each project. This package gives that configuration one time, in areas. Each area has its own import path, and the package has no root entry point. Two [generators](#generators) write the root files of a workspace, four [app generators](#app-generators) add its projects, the [prisma generator](#prisma-generator) adds a db package, and the [dokploy generator](#dokploy-generator) adds the delivery of a backend. The lint rules stay in `@zukhruf/eslint`, and the Git hooks stay in `@zukhruf/git-hooks`. [Monorepo standard](#monorepo-standard) says where each rule of the standard lives, and why.
4
4
 
5
5
  The words in these documents have one meaning each. See the glossary in [CONTEXT.md](./CONTEXT.md).
6
6
 
7
7
  ## Areas
8
8
 
9
- | Area | Import path | Status |
10
- | ---------------- | ---------------------- | --------------------------------------------------------------------------------------------- |
11
- | format | `@zukhruf/nx/format` | This README |
12
- | test | `@zukhruf/nx/test` | This README |
13
- | lint | `@zukhruf/nx/lint` | This README |
14
- | portless | `@zukhruf/nx/portless` | Candidate (#3336): 14 projects in 3 repos |
15
- | opentofu, prisma | — | Candidates (#3339): 5 places each |
16
- | generators | — | Candidates: the workspace generator of `@factory/foundation` (#3337); app kinds later (#3338) |
9
+ | Area | Import path | Status |
10
+ | ---------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
11
+ | format | `@zukhruf/nx/format` | This README |
12
+ | test | `@zukhruf/nx/test` | This README |
13
+ | lint | `@zukhruf/nx/lint` | This README |
14
+ | portless | `@zukhruf/nx/portless` | Candidate (#3336): 14 projects in 3 repos |
15
+ | opentofu, prisma | `@zukhruf/nx/<area>` | This README (#3339) |
16
+ | generators | `@zukhruf/nx:<name>` | This README: `preset` and `init` (#3337); `node-app`, `react-app`, `pair`, `ui-package` (#3338); `dokploy` (#4603); `prisma` (#4604) |
17
17
 
18
18
  The lint rules stay in `@zukhruf/eslint`. The `lint` area gives only the inputs of the `lint` target (#3335).
19
19
 
20
+ ## monorepo standard
21
+
22
+ The monorepo standard is the set of rules that each new Nx repo follows. The generators of this package write it. The Nx plugins of this package, the rules of `@zukhruf/eslint` and the steps of `@zukhruf/git-hooks` check it. It started as `docs/monorepo-standard.md` in whatisgoingon, which moved here in #4605. This section keeps only what no generator writes and no check runs: where each rule lives, the decisions with their reasons, the rules that are still prose, and the pitfalls. To read a rule that a generator writes, read the generator's section or its source.
23
+
24
+ ### Where each rule lives
25
+
26
+ | Part of the standard | Written by | Checked by |
27
+ | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
28
+ | Tooling: npm workspaces, one exact version of the Nx family, TypeScript 7 with the TypeScript 6 API, exact root versions, `allowScripts`, peer `overrides` | `init` ([`root-package-json.ts`](./src/generators/init/root-package-json.ts), [`versions.ts`](./src/generators/versions.ts)); `preset` refuses another package manager; `node-app` adds the sdk-it peer `overrides` | `manifest/nx-family-pinned` ([`@zukhruf/eslint`](../eslint/README.md#every-other-manifest)); [`NpmrcPolicy`](../git-hooks/README.md#decide-how-npm-installs-in-the-repo) (`legacy-peer-deps=false`, `strict-allow-scripts=true`); [`LockfileSync`](../git-hooks/README.md#keep-package-lockjson-in-step-with-each-packagejson) |
29
+ | Versions as LTS aliases: `.nvmrc` `lts/*`, `node:lts-*` images, `npm@latest`, no `engines` and no `packageManager` | `init` ([`files.ts`](./src/generators/init/files.ts)); the Dockerfiles of `node-app` and `prisma`; the workflows of `dokploy` | [`NoNumericPins`](../git-hooks/README.md#refuse-a-node-or-npm-version-written-as-a-number) |
30
+ | Root files and the layout `apps/`, `packages/`, `tools/` | `init` and `preset`: [What the generators write](#what-the-generators-write) | the `Format` step for the root files; `NpmrcPolicy` for `.npmrc` |
31
+ | TypeScript: the Bundler base, and project tsconfigs that write to `out-tsc` with `rootDir: "src"` | `init` (base and solution file); the app generators and `prisma` (project tsconfigs) | `zukhruf/no-enum` |
32
+ | Nx: `nx.json` keys, plugins, target defaults, generator defaults; targets in the `nx` key of the project's `package.json` | `init` ([`nx-json.ts`](./src/generators/init/nx-json.ts)); each app generator adds its wiring: [What only an app generator writes](#what-only-an-app-generator-writes) | the `format`, `test` and `lint` areas, which no default may replace ([ADR 0001](./docs/adr/0001-inferred-targets-not-copied-defaults.md)) |
33
+ | Format: `.prettierrc` and `.prettierignore` | `init`; `react-app` adds `prettier-plugin-tailwindcss` | `format:check`; the `Format` step |
34
+ | Lint: the root and the project `eslint.config.mjs` | `init` (root); each app generator and `prisma` (project) | the `lint` area; the configs of `@zukhruf/eslint` |
35
+ | Git hooks: `Sync`, `Format`, the manifest steps, `Build` on pre-push, `NxReleaseScope` on commit-msg | `init` | — |
36
+ | Tests: `node:test` everywhere, Vitest in a Vite app, no lifecycle hooks, `test:docker` for Docker tests | the `test` area; `react-app` (the Vitest block and its `test` target); `prisma` (the Docker test and the tag) | `zukhruf/no-other-test-runner`, `zukhruf/no-test-lifecycle-hooks` |
37
+ | Backend: Hono, terminus, evlog, zod env, sdk-it client, one ESM bundle, Dockerfile, build sha | `node-app` | the `hono` and `env` configs; [`DockerfileInstallsFromLockfile`](../git-hooks/README.md#install-from-the-lockfile-in-a-dockerfile) |
38
+ | Web: React Router in data mode, Vite, Tailwind, React Compiler, Vitest; a UI library | `react-app`; `ui-package` | `@zukhruf/eslint/react`, the `react-router` and `tailwind` configs |
39
+ | Mobile: Expo | no generator: [Mobile with Expo](#mobile-with-expo) | [`@zukhruf/eslint/react-native`](../eslint/README.md#react-native-hermes) |
40
+ | Pair of a web app and a backend | `pair` | — |
41
+ | Database: a Prisma 7 package on Postgres | `prisma` | the `prisma` area |
42
+ | Agent workflow: the commands in `AGENTS.md` | `init` (`AGENTS.md`, `CLAUDE.md`) | — |
43
+ | Delivery: CI, deploy, encrypted OpenTofu state applied only by CI | `dokploy` | the `opentofu` area (`typecheck` with no secret, no `apply` target, [ADR 0007](./docs/adr/0007-opentofu-targets-from-environments-with-no-apply.md)) |
44
+
45
+ ### Decisions and their reasons
46
+
47
+ | Topic | The sources disagreed | The standard | Why |
48
+ | --------------------- | ----------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
49
+ | Web tests | factory used Vitest and happy-dom; the zukhruf libraries used `node:test` only | Vitest in a Vite app, `node:test` everywhere else | The owner's decision of 2026-10-29. Vitest runs the app's own Vite config and transforms. |
50
+ | Vitest globals | factory set `globals: true` | `globals: false`, and RTL's `cleanup()` in the `finally` of each test | With `globals: true`, RTL registers an `afterEach`, which is a lifecycle hook. |
51
+ | Root scripts | factory had `build`, `check` and `lint` npm scripts; zukhruf, elt and context-compiler had only `prepare` | only `prepare` | Each command runs through an Nx target. |
52
+ | TypeScript | factory used `typescript@6.0.3`; elt and context-compiler used TypeScript 7 with the TypeScript 6 API alias | TypeScript 7, with the TypeScript 6 API for typescript-eslint and `@nx/js` | The newest setup (elt, 2026-10-10), and it follows the Nx guide `nx.dev/docs/kb/typescript-7`. typescript-eslint peers on TypeScript `<6.1`. |
53
+ | tsconfig base | factory used Bundler resolution; zukhruf and elt use NodeNext | Bundler for a workspace that bundles its apps | Different kinds of workspace. A workspace that Node runs from source uses `NodeNext` with `rewriteRelativeImportExtensions`; no generator writes it ([ADR 0009](./docs/adr/0009-a-preset-and-an-init-generator-start-a-repo-from-nothing.md)). |
54
+ | Expo | ipay used `@nx/expo` on Nx 21; bid and virtual-care wrote `run-commands` | `@nx/expo/plugin` | The official plugin, with inferred targets (2026-10-29). |
55
+ | Infrastructure | OpenTofu or Pulumi | OpenTofu with the state encrypted and committed, as text2sql v2 does | The pattern of text2sql v2. CI is the only writer of the state, and it commits the state back with `[skip ci]`. |
56
+ | Deploy trigger | text2sql deployed with a Dokploy webhook | the release job calls the Dokploy API with the panel key | The fewest long-lived credentials (2026-10-29): the apply needs the panel key in CI anyway, so the webhook URL and the PAT that wrote it into the Actions secrets go. |
57
+ | Delivery from day one | — | a new repo ships from `main` before its first feature | The owner's rule of 2026-10-29. Nobody runs a deploy, an apply or a build by hand. The owner runs each command that writes a secret. |
58
+
59
+ ### Rules that are still prose
60
+
61
+ No generator writes these and no check runs them. Each one cost time once.
62
+
63
+ - Pass Nx flags through `npx nx`, never `npm exec`: npm eats the flags.
64
+ - Review each install script before you name it in `allowScripts`, and name a package with no version. The reasons so far: `esbuild: true`, because its postinstall links the native binary over the Node wrapper and downloads it when the platform package is missing; `nx: false`, because its postinstall only updates the Nx Cloud client and exits 0 on each error, and no repo uses Nx Cloud; `unrs-resolver`, `@parcel/watcher` and `fsevents` are native fallbacks. Some scripts block only on Linux (`dtrace-provider` under `eas-cli`, `protobufjs`), so read the list from a Linux install too: `docker run node:lts-bookworm-slim … npm ci`.
65
+ - Keep one copy of each shared runtime package, and run `npm ls <pkg>` after each generator. When tooling pins an older major (`zod` 3 for `@expo/cli`), declare the runtime major as a root `devDependency`, so npm hoists it and nests the old one.
66
+ - Add a package only for a real second caller.
67
+ - No `paths` aliases between projects. Projects import each other by package name, and `nx sync` writes the references.
68
+ - Never set the same key in a `project.json` and in the `nx` key of a `package.json`.
69
+ - A shell target sets a top-level `command`, or `executor: "nx:run-commands"`. `options.command` with no executor becomes `nx:noop`, and the target passes without running.
70
+ - Build order comes from the import graph. Write no `dependsOn` on a named project.
71
+ - Fix each lint finding; no `warn` for later. A ban that names one repo goes in that repo's config, and a rule for each repo goes in `@zukhruf/eslint`. An ESLint config does not read the project graph when it loads.
72
+ - No lint-staged: it put the files of other sessions into commits. Never `--no-verify` without asking.
73
+ - Test fixtures (a Docker database, an HTTP server, a temp folder, msw) come from `@zukhruf/testing`, and `await using` cleans them up.
74
+ - A React component of a library package is tested with `node:test`: the test registers a DOM with `@happy-dom/global-registrator`, then imports `react`, `react-dom/client` and the component from the built package. Node cannot load `.tsx`.
75
+ - `serve` of a backend runs the source, so its `ui.route.ts` answers `/` with `ui/build-missing`. In development the web app runs on the Vite dev server.
76
+ - CI installs each tool that a target runs, for example OpenTofu for the `typecheck` of the infra project. It passed locally only because Homebrew had `tofu`.
77
+ - On a paid GitHub plan, move the deploy secrets into a `production` environment that only `main` can use.
78
+ - The owner does each one-time step: `gh auth refresh -s workflow` (a push of a workflow file needs the scope) and the repository secrets.
79
+
80
+ ### Mobile with Expo
81
+
82
+ No generator writes a mobile app yet. This is the Nx 24 shape of 2026-10-29:
83
+
84
+ - `nx g @nx/expo:app apps/<name>`, with `@nx/expo/plugin`. Set `buildTargetName: "eas-build"`: a target named `build` would run `eas build` in the cloud from `nx run-many -t build` and from the pre-push `Build` step.
85
+ - The latest Expo SDK and `expo-router` (`main: "expo-router/entry"`, routes in `src/app/`). Install Expo modules with the inferred `install` target, so the versions match the SDK.
86
+ - After the generator: move its root `dependencies` (Expo, React, React Native) into the app manifest with real versions (it writes `"*"`), delete `jest-expo` and `@testing-library/react-native`, and delete `tools/scripts/eas-build-{pre,post}-install.mjs`. The one EAS hook of the app is `eas-build-post-install`, which runs the `sdk` target of the generated client, because EAS installs from Git.
87
+ - Root `overrides` pin `react` and `react-dom` to the version of the Expo SDK, and each app declares it. Two copies fail with "Invalid hook call".
88
+ - `app.json`: set `slug` and `scheme` by hand (the scoped project name is not valid there), `owner`, `android.package`, `ios.bundleIdentifier`, and `ios.infoPlist.ITSAppUsesNonExemptEncryption: false`, or each build waits for an export-compliance answer. Then `eas init --non-interactive --force` from the app folder.
89
+ - `eas.json`: `cli.appVersionSource: "remote"`, and a `base` profile that each profile extends, with `node` as an exact version (EAS accepts no alias; `NoNumericPins` leaves `eas.json` out). The app's `eas-build-pre-install` runs `npm install -g npm@latest`. EAS uploads what Git tracks, so each profile sets its `EXPO_PUBLIC_*` values in `env`.
90
+ - `metro.config.js` wraps the config in `withNxMetro`. Keep the name: `@nx/expo/plugin` finds an Expo project only by that file. It is CommonJS, so turn off `@typescript-eslint/no-require-imports` for it.
91
+ - `tsconfig.app.json` extends `["../../tsconfig.base.json", "expo/tsconfig.base"]` with `noEmit: false`, `outDir: "out-tsc"`, `rootDir: "src"` and `types: ["expo/types"]`.
92
+ - `src/env.ts` reads each `process.env.EXPO_PUBLIC_<NAME>` by name: Expo inlines only those static reads, so the backend's `safeParse(process.env)` does not work.
93
+ - `ios/` and `android/` come from `prebuild` and are ignored by Git. `app.json` is the source of truth.
94
+ - The app calls the backend through the generated client with `baseUrl` from `EXPO_PUBLIC_API_URL`. The client builds URLs with `new URL(path, 'local://')`, which only the `URL` of the Expo runtime accepts, so the client does not work in bare React Native. `start`, `serve`, `run-ios`, `run-android` and `export` depend on `^sdk`.
95
+ - Verify with what CI runs (`expo export`, `eas build --local --non-interactive`). `grep -a` on the `.hbc` files shows whether a string made it into the bundle.
96
+ - TestFlight from CI: `eas build --auto-submit --non-interactive` needs `submit.production.ios.ascAppId`. The owner creates the App Store Connect app once in the web UI and runs `eas credentials -p ios` once (build credentials, then an App Store Connect API key; the App Manager role is enough). EAS then creates the internal TestFlight group. "Couldn't switch to provider" can be a stale Apple session: run it again.
97
+
98
+ ### Pitfalls
99
+
100
+ - After you move a project: `nx reset`, then `nx sync`, then diff the tsconfigs. A stale graph makes `sync` delete valid references.
101
+ - A phantom TS2307 or TS6305 comes from a stale `.tsbuildinfo`. Run `nx reset`; do not edit the references.
102
+ - An incremental `typecheck` can miss a `.tsx` call-site error after a move, and `tsc` does not see a bundler break. Verify with the real build.
103
+ - After you delete a workspace, delete its `extraneous` entries from `package-lock.json`. A commit that adds a package carries its lockfile entries and its root tsconfig reference.
104
+ - `@nx/esbuild`: `thirdParty` decides what is bundled; `additionalEntryPoints` duplicate shared classes and break `instanceof`; an asset that the root `.gitignore` matches is dropped; a failed watch rebuild deletes the output. `generatePackageJson` throws in a TS solution workspace: use `prune-lockfile`.
105
+ - `nx migrate --create-commits` runs `git add -A`. Read `migrations.json` first. `parallel` in `nx.json` takes only a number.
106
+ - A generator of Nx rewrites root files through an AST: it can drop the comments of `eslint.config.mjs` and add `@swc/helpers` again. Stage before a generator of Nx, and diff after.
107
+ - Nx applies a sync only in an interactive run. A piped or CI run stops with "The workspace is out of sync": run `npx nx sync`.
108
+ - When Nx detects an AI agent, it holds the output of a task until the task ends. Add `--output-style=stream-without-prefixes` to read a server while it runs.
109
+ - With no green CI run yet, `nrwl/nx-set-shas` falls back to `HEAD~1`, and `affected` sees only the last commit. The generated CI runs `run-many` when `noPreviousBuild` is set.
110
+ - On a Mac, Microsoft Defender has killed the `commit-msg` and `pre-push` hooks. A `pre-push` that dies with SIGKILL is that, not the build.
111
+ - The macOS firewall in stealth mode drops LAN connections to `node`, even from the same Mac, so Expo's LAN URL times out in Expo Go. On the simulator, start with `-- --ios --localhost`.
112
+ - The Claude Code TypeScript LSP finds no `tsserver.js` under the TypeScript 6 alias, so it shows no diagnostics. Use `nx run <project>:typecheck`.
113
+ - zsh does not split an unquoted variable into words: `kill $pids` with `pids="1 2 3"` passes one argument.
114
+
20
115
  ## format
21
116
 
22
117
  An Nx workspace formats its files with Prettier. The `format` area is an Nx inference plugin. It gives each project of the workspace two targets: `format`, which writes the files, and `format:check`, which only reads them. You list the plugin one time in `nx.json`. You do not copy targets into each project.
@@ -134,6 +229,7 @@ context-compiler already does this for `@nx/eslint/plugin`. See [ADR 0003](./doc
134
229
  | whatisgoingon | #3321 |
135
230
  | text2sql | #3322 |
136
231
  | deepagents | #3323 |
232
+ | meddit | #4606 (written by `preset`) |
137
233
 
138
234
  The umbrella item is #3317.
139
235
 
@@ -345,6 +441,7 @@ A `scripts.test` in a `package.json` replaces the inferred target. Nx runs it wi
345
441
  | elt | uses it (#3366) |
346
442
  | context-compiler | uses it (#3367) |
347
443
  | text2sql | uses it (#3368) |
444
+ | meddit | #4606 (written by `preset`) |
348
445
 
349
446
  The umbrella item is #3328.
350
447
 
@@ -493,5 +590,724 @@ The lockfile measured the edges on 2026-10-30. For factory, whatisgoingon, deepa
493
590
  | text2sql | uses it (#3389) |
494
591
  | elt | uses it (#3390) |
495
592
  | context-compiler | uses it (#3391) |
593
+ | meddit | #4606 (written by `preset`) |
496
594
 
497
595
  The umbrella item is #3335.
596
+
597
+ ## opentofu
598
+
599
+ > Status: shipped (#3339).
600
+
601
+ Five projects in two workspaces run OpenTofu through Nx: the `infra` project of whatisgoingon, and four projects of text2sql (`v2-terraform`, `authx-terraform`, `desktop-terraform`, `diagnostics-terraform`). Each one copies the same targets and the same freshness script. The `opentofu` area is an Nx inference plugin. It gives the OpenTofu targets to each project that has environments. You list the plugin one time in `nx.json`. You do not copy the targets or the script.
602
+
603
+ ### Use the opentofu area
604
+
605
+ You need Nx 23.2.1 or later and the `tofu` command on the `PATH`. Add the plugin to `plugins` in `nx.json`, after `@zukhruf/nx/format`:
606
+
607
+ ```json
608
+ {
609
+ "plugins": ["@zukhruf/nx/format", "@zukhruf/nx/opentofu"]
610
+ }
611
+ ```
612
+
613
+ The order is necessary. Both plugins give `format` and `format:check`, and a later plugin wins the merge. In the other order, an OpenTofu project gets the Prettier targets.
614
+
615
+ A workspace that builds this package lists the plugin by path, as zukhruf does for the other areas: `"./packages/nx/src/opentofu/plugin.ts"`.
616
+
617
+ ### Signature of the opentofu area
618
+
619
+ ```ts
620
+ // @zukhruf/nx/opentofu
621
+ export const createNodes: CreateNodes;
622
+ ```
623
+
624
+ The plugin takes no options. The commands are the same in each of the 5 copies. The differences between the copies are of a different kind, and they stay with the project (see [Give the secrets](#give-the-secrets) and [Check that a saved plan is fresh](#check-that-a-saved-plan-is-fresh)).
625
+
626
+ ### Which projects get the OpenTofu targets
627
+
628
+ An **environment** is a folder `src/environments/<name>` of a project root, with at least one `*.tf` file directly in it. Each environment is one OpenTofu root module, with its own state and its own saved plan. A project root gets the OpenTofu targets when it has at least one environment. The project roots are the same as for the other areas (see [ADR 0003](./docs/adr/0003-which-roots-get-targets.md)). A `*.tf` file belongs to its nearest project root.
629
+
630
+ The plugin adds `**/src/environments/*/*.tf` to the files that it reads. Thus Nx runs the plugin again when an environment is added or removed.
631
+
632
+ Each target that works on one environment has one configuration for each environment. The options select the **default environment**: `production` when it exists, else the first environment in name order. Select another environment with `-c`:
633
+
634
+ ```sh
635
+ nx run authx-terraform:preview -c staging
636
+ ```
637
+
638
+ A task dependency runs with the same configuration. Thus `preview -c staging` runs `init -c staging` first.
639
+
640
+ ### What each OpenTofu target runs
641
+
642
+ | Target | Command | `cwd` | Cached | Depends on |
643
+ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- | ------ | ---------- |
644
+ | `format` | `tofu fmt -recursive` | `{projectRoot}/src` | no | — |
645
+ | `format:check` | `tofu fmt -check -recursive` | `{projectRoot}/src` | yes | — |
646
+ | `typecheck` | for each environment: `tofu -chdir=environments/<name> init -backend=false -input=false -lockfile=readonly && tofu -chdir=environments/<name> validate` | `{projectRoot}/src` | yes | — |
647
+ | `init` | `tofu init -input=false` | `{projectRoot}/src/environments/<name>` | no | — |
648
+ | `preview` | `rm -f tfplan && tofu plan -out tfplan` | the environment | no | `init` |
649
+ | `show` | the freshness check, then `tofu show tfplan` | the environment | no | — |
650
+ | `output` | `tofu output` | the environment | no | — |
651
+
652
+ - `format` writes. `format:check` and `typecheck` only read, as for each check ([ADR 0002](./docs/adr/0002-a-check-never-writes.md)).
653
+ - The inputs of `format:check` and `typecheck` are `{projectRoot}/src/**/*.tf`, `{projectRoot}/src/**/*.hcl` and the output of `tofu version`. The provider lock file `.terraform.lock.hcl` is an `*.hcl` file. A new release of OpenTofu thus runs the checks again.
654
+ - `typecheck` needs no secret. `init -backend=false` reads no state, and `validate` reads no variable value. CI can run it with no secret.
655
+ - `typecheck` sets `TF_DATA_DIR=.terraform/validate`. Its `init` with no backend thus does not replace the working directory of the real `init`. text2sql already does this in its 4 projects.
656
+ - `typecheck` reads the provider lock file and does not write it (`-lockfile=readonly`). When a provider is added or its version changes, `typecheck` stops: "Provider dependency changes detected". Run `nx run <project>:init`, which writes the lock file, and commit the lock file. A new hash for another platform does not stop it: OpenTofu suppresses only that write.
657
+ - `typecheck` checks each environment. `-c` does not select one.
658
+ - `init`, `preview`, `show` and `output` need the state passphrase (see [Give the secrets](#give-the-secrets)).
659
+ - `preview` deletes the old plan first. A plan that fails thus leaves no plan for `show`.
660
+ - `show` does not depend on `preview`. It shows the plan that `preview` saved, and it stops when that plan is not fresh (see [Check that a saved plan is fresh](#check-that-a-saved-plan-is-fresh)).
661
+ - Arguments after `--` go to the last command. For example, `nx run infra:output -- -raw dokploy_api` runs `tofu output -raw dokploy_api`.
662
+
663
+ The plugin gives no `apply` target, on purpose. CI applies: main is the wanted state, and the reusable workflow `tofu-apply.yml` applies it and commits the state. A person does not apply from a laptop. Two old targets also go: `plan` is the same as `preview`, and `validate` is in `typecheck`. `refresh` stays in the project that needs it, as an override. See [ADR 0007](./docs/adr/0007-opentofu-targets-from-environments-with-no-apply.md).
664
+
665
+ ### Give the secrets
666
+
667
+ The state and the saved plans are encrypted. Each project reads the passphrase from the variable `tf_encryption_passphrase`. `init`, `preview`, `show` and `output` thus start with a guard. It stops the target when `TF_ENCRYPTION_PASSPHRASE` is empty or not set. Then the target gives the value to OpenTofu as `TF_VAR_tf_encryption_passphrase`.
668
+
669
+ The plugin sets no `envFile`. Nx already loads the `.env` file of the project root for each task, and `.env.<configuration>` for a task with a configuration (`nx/dist/src/tasks-runner/task-env-paths.js`). A variable that the environment already sets wins. Thus put the secrets in `<projectRoot>/.env`, and keep that file out of Git. With no `.env` file, the target reads the environment only. An `envFile` that does not exist stops the task with an error (`nx/dist/src/executors/run-commands/running-tasks.js:553-558`).
670
+
671
+ The other secrets are different in each project, so the plugin does not check them. OpenTofu reads each variable `<name>` from `TF_VAR_<name>`, and each provider reads its own token, for example `HCLOUD_TOKEN`. Give a variable with a different name in `.env`. Nx expands `${NAME}` in the file (`dotenv-expand`):
672
+
673
+ ```sh
674
+ TF_ENCRYPTION_PASSPHRASE=…
675
+ DOKPLOY_API_KEY=…
676
+ HCLOUD_TOKEN=…
677
+ TF_VAR_dokploy_api_key=${DOKPLOY_API_KEY}
678
+ ```
679
+
680
+ When a variable has no value, OpenTofu asks for it, or stops with "No value for required variable". The copies checked each secret in the shell first. That check predicts the error that OpenTofu already gives.
681
+
682
+ ### Check that a saved plan is fresh
683
+
684
+ `show` runs the freshness check first. The check is a Node script inside this package (`src/opentofu/check-plan-fresh.ts`). The plugin gives its path relative to the environment. The check stops `show` in two cases:
685
+
686
+ - The environment has no `tfplan`. Run `preview` first.
687
+ - A file of the project changed after `preview` wrote the plan. The message names the file.
688
+
689
+ A **file of the project** is each file under the project root that Git tracks or does not ignore (`git ls-files --cached --others --exclude-standard`). A tracked file that was deleted counts as changed. A file named `tfplan` does not count. Thus the check sees each input of the plan in the project: the environment, the modules, the scripts, `project.json`, the provider lock file, the committed state, and a template such as `compose.dokploy.yml`. The `.terraform` folders, `.env` and the plans of the other environments are ignored by Git, so a new `init` does not make the plan stale.
690
+
691
+ The copies listed the inputs by name, and the lists drifted: two copies did not list `src/modules`, and two listed a compose file outside the project root, `../compose.dokploy.yml`. Each project now keeps its plan inputs inside its root. Move a template that the configuration reads into the project root.
692
+
693
+ The check needs Git. Outside a Git work tree, it stops with the error of Git. OpenTofu also refuses to apply a plan when the state changed after the plan. The check adds the files that OpenTofu does not compare.
694
+
695
+ ### Override an OpenTofu target
696
+
697
+ A target in the `project.json` of a project replaces the inferred target, or merges into it. Nx applies the plugin first, then `targetDefaults`, then `project.json`. For example, a project that needs `refresh` adds it:
698
+
699
+ ```json
700
+ {
701
+ "targets": {
702
+ "refresh": {
703
+ "command": ": \"${TF_ENCRYPTION_PASSPHRASE:?TF_ENCRYPTION_PASSPHRASE missing}\" && TF_VAR_tf_encryption_passphrase=\"$TF_ENCRYPTION_PASSPHRASE\" tofu refresh",
704
+ "options": { "cwd": "{projectRoot}/src/environments/production" }
705
+ }
706
+ }
707
+ }
708
+ ```
709
+
710
+ ### Migrate a workspace to the opentofu area
711
+
712
+ 1. Add `@zukhruf/nx/opentofu` to `plugins` in `nx.json`, after `@zukhruf/nx/format`.
713
+ 2. Delete the targets that the plugin now gives from each OpenTofu project: `init`, `format`, `format:check`, `typecheck`, `preview`, `show` and `output`. Delete `plan`, `validate` and `apply`.
714
+ 3. Delete `scripts/check-plan-fresh.sh`.
715
+ 4. Move the secrets with a different name to `TF_VAR_<name>` in `<projectRoot>/.env`, for example `TF_VAR_dokploy_api_key=${DOKPLOY_API_KEY}` and, for authx, `TF_VAR_otlp_headers=${AUTHX_OTLP_HEADERS}`.
716
+ 5. Move a template that the configuration reads into the project root, for example `apps/v2/compose.dokploy.yml`.
717
+ 6. Run `nx run <project>:typecheck`. If it stops with "Provider dependency changes detected", run `nx run <project>:init` and commit the lock file.
718
+ 7. Compare `nx show project <project> --json` before and after.
719
+
720
+ | Workspace | Projects | Changes |
721
+ | ------------- | ------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
722
+ | whatisgoingon | `infra` | `TF_VAR_dokploy_api_key` in `infra/.env`; `preview` no longer runs `typecheck` first, because `plan` validates the configuration |
723
+ | text2sql | `v2-terraform`, `authx-terraform`, `desktop-terraform`, `diagnostics-terraform` | `init` no longer depends on `typecheck`; the compose files of v2 and authx move into the project roots; authx keeps its 2 environments as configurations |
724
+
725
+ ### Who uses the opentofu area
726
+
727
+ | Workspace | Backlog item |
728
+ | ------------- | ------------ |
729
+ | whatisgoingon | #4612 |
730
+ | text2sql | #4613 |
731
+ | meddit | #4608 |
732
+
733
+ The backlog item of the area is #3339.
734
+
735
+ ## prisma
736
+
737
+ > Status: shipped (#3339).
738
+
739
+ Six projects in two workspaces run Prisma through Nx: `@factory/db` of factory, and five projects of text2sql (`v2-db`, `authx-db`, `desktop-db`, `db` and `@workspace/amail`). Each one copies a cached `generate` target, and five also copy the migrate targets. The `prisma` area is an Nx inference plugin. It gives the Prisma targets to each project with a `prisma.config.ts`. You list the plugin one time in `nx.json`.
740
+
741
+ ### Use the prisma area
742
+
743
+ You need Nx 23.2.1 or later, and `prisma` and `@prisma/client` in the lockfile. Add the plugin to `plugins` in `nx.json`. Then add `generate` to the `dependsOn` of `typecheck` and `build` in `targetDefaults`:
744
+
745
+ ```jsonc
746
+ {
747
+ "plugins": ["@zukhruf/nx/prisma"],
748
+ "targetDefaults": {
749
+ "typecheck": {
750
+ "dependsOn": ["lint", "format:check", "generate", "..."],
751
+ },
752
+ "build": {
753
+ "dependsOn": ["generate", "..."],
754
+ },
755
+ },
756
+ }
757
+ ```
758
+
759
+ Keep the entries that are already in the lists. Nx skips a `dependsOn` on a target that the project does not have, so a project with no Prisma is not changed. The plugin does not change `typecheck` or `build`. Those targets belong to other plugins, as for `format:check` ([ADR 0001](./docs/adr/0001-inferred-targets-not-copied-defaults.md)). The `typecheck:generate` tag of text2sql is then not necessary. See [ADR 0008](./docs/adr/0008-prisma-targets-from-prisma-config-with-outputs-from-the-schema.md).
760
+
761
+ ### Signature of the prisma area
762
+
763
+ ```ts
764
+ // @zukhruf/nx/prisma
765
+ export const createNodes: CreateNodes;
766
+ ```
767
+
768
+ The plugin takes no options. The commands are the same in each copy. The output folder of `generate` is different in each project, and the schema already gives it.
769
+
770
+ ### Which projects get the Prisma targets
771
+
772
+ A project root gets the Prisma targets when it has a `prisma.config.ts` directly in it. Prisma 7 reads its config from that file. The project roots are the same as for the other areas (see [ADR 0003](./docs/adr/0003-which-roots-get-targets.md)). The plugin also reads the `*.prisma` files of the project. A `*.prisma` file belongs to its nearest project root.
773
+
774
+ ### What each Prisma target runs
775
+
776
+ Each target runs in `{projectRoot}`.
777
+
778
+ | Target | Command | Cached | Depends on |
779
+ | ---------- | ----------------------- | ------ | ---------- |
780
+ | `generate` | `prisma generate` | yes | — |
781
+ | `migrate` | `prisma migrate dev` | no | `generate` |
782
+ | `deploy` | `prisma migrate deploy` | no | — |
783
+ | `reset` | `prisma migrate reset` | no | — |
784
+ | `pull` | `prisma db pull` | no | — |
785
+
786
+ - The inputs of `generate` are `{projectRoot}/**/*.prisma`, `{projectRoot}/prisma.config.ts`, and the packages `prisma` and `@prisma/client` (`externalDependencies`). Thus a new model file in `models/` runs `generate` again, and an update of Prisma does too. The copies had the whole `package-lock.json` as an input, so each update of any package ran `generate` again.
787
+ - The outputs of `generate` are the `output` folders of the `generator` blocks in the `*.prisma` files of the project. A path is relative to the file of its block, as Prisma reads it. For example, `output = "src/prisma"` in `schema.prisma` gives `{projectRoot}/src/prisma`. Nx restores these folders from the cache.
788
+ - When a `generator` block has no `output`, Prisma writes into `node_modules`. The plugin then gives `generate` with no cache, because Nx cannot restore that folder.
789
+ - `migrate`, `reset` and `pull` change the database or the schema. Run them on purpose. No target depends on them.
790
+ - Prisma reads the connection string. `prisma.config.ts` reads it from the environment, and Nx loads the `.env` file of the project root for each task.
791
+
792
+ text2sql also has a target `prisma` that runs the Prisma CLI with the arguments that you give. It stays in each project that wants it.
793
+
794
+ ### Migrate a workspace to the prisma area
795
+
796
+ 1. Add `@zukhruf/nx/prisma` to `plugins` in `nx.json`.
797
+ 2. Add `generate` to `targetDefaults.typecheck.dependsOn` and `targetDefaults.build.dependsOn`.
798
+ 3. Delete `generate`, `migrate`, `deploy`, `reset` and `pull` from each Prisma project, and the `typecheck` entry that only adds `generate`.
799
+ 4. Delete the `typecheck:generate` tag and its `targetDefaults` filter.
800
+ 5. Compare `nx show project <project> --json` before and after.
801
+
802
+ | Workspace | Projects | Changes |
803
+ | --------- | --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
804
+ | factory | `@factory/db` | the project gets `reset` and `pull`; `build` gets `generate` from `targetDefaults` |
805
+ | text2sql | `v2-db`, `authx-db`, `desktop-db`, `db` | `migrate` depends on `generate`, not on `build`; `desktop-db` gets `deploy`; `bundle` keeps its own `dependsOn` on `generate` |
806
+ | text2sql | `@workspace/amail` (`tools/playground/amail`) | it has a `prisma.config.ts`, so it gets the targets too; its `generate` in `package.json` goes; the output is `prisma/client` |
807
+
808
+ ### Who uses the prisma area
809
+
810
+ | Workspace | Backlog item |
811
+ | --------- | ------------ |
812
+ | factory | #4611 |
813
+ | text2sql | #4613 |
814
+ | meddit | #4607 |
815
+
816
+ The backlog item of the area is #3339.
817
+
818
+ ## generators
819
+
820
+ The root files of a workspace are the same in each repo: `package.json`, `nx.json`, the tsconfig files, `.npmrc`, the Git hooks and more (see [monorepo standard](#monorepo-standard)). factory writes them with the `workspace` generator of its private package `@factory/foundation`. Other repos copy them by hand: 3 to 7 copies of each file. meddit is the third repo that starts from the standard, so the generator moves here (#3259).
821
+
822
+ The package gives two Nx generators:
823
+
824
+ - `preset` starts a repo. `create-nx-workspace` runs it.
825
+ - `init` adds the root files of the standard to an Nx workspace. It is safe to run again. `nx add @zukhruf/nx` runs it.
826
+
827
+ The generators write only the root files that each repo needs. The wiring of one kind of app (Hono, React, Vite, Tailwind, Vitest) comes from the app generators `node-app`, `react-app`, `pair` and `ui-package` (#3338).
828
+
829
+ ### Start a repo in a new folder
830
+
831
+ ```sh
832
+ npx create-nx-workspace@latest <name> --preset=@zukhruf/nx --pm=npm --nxCloud=skip --aiAgents=none
833
+ ```
834
+
835
+ The name is the folder name, and the scope of the workspace. `acme` gives the folder `acme` and the root package `@acme/source`.
836
+
837
+ ### Start a repo in an empty Git repo
838
+
839
+ Give `.` as the name, in the folder of the repo:
840
+
841
+ ```sh
842
+ cd ~/Desktop/mo/meddit
843
+ npx create-nx-workspace@latest . --preset=@zukhruf/nx --pm=npm --nxCloud=skip --aiAgents=none
844
+ ```
845
+
846
+ This is the path for meddit, which has only `.git`. Nx 24 supports it, and no step deletes the folder or `.git`:
847
+
848
+ - `.` gives the name of the current folder, and the parent folder as the working folder (`create-nx-workspace/dist/bin/create-nx-workspace.js:612-617`, 24.0.6). The folder must exist, so the "directory exists" check does not apply (`:646-660`).
849
+ - `nx new` then gets `skipEmptyDirCheck`, so it writes into a folder that is not empty (`create-nx-workspace/dist/src/create-empty-workspace.js:31-37`; the check is at `@nx/workspace/dist/src/generators/new/new.js:68-73`).
850
+ - An Nx generator writes files through a `Tree`. It never removes a folder that it did not write, so `.git` stays.
851
+ - In a folder that is already a Git work tree, create-nx-workspace runs no `git init`, no `git add` and no commit (`create-nx-workspace/dist/src/utils/git/git.js:141-149`). The first commit is yours.
852
+
853
+ A smoke test on 2026-11-18 ran this command with the `@zukhruf/nx` preset in a folder with only `git init` (see [Test the preset before a release](#test-the-preset-before-a-release)). The folder and `.git` stayed, `git log` showed no commit, `git status` showed each file as new, `core.hooksPath` was `.husky`, and the first commit passed the hooks. The preset `npm` behaves differently: create-nx-workspace maps it to the template flow for an agent (`bin/create-nx-workspace.js:362-380`), and that flow amends the README and can leave an `error.log` (`create-workspace.js:269-288`).
854
+
855
+ Two other seams do not work for an empty repo:
856
+
857
+ - `nx g @zukhruf/nx:init` needs a workspace. With no `nx.json`, Nx prints "The current directory isn't part of an Nx workspace" and stops with exit code 1 (`nx/dist/bin/nx.js:63`, `:108-110`, `:151-167`).
858
+ - `nx init` in a folder with no `package.json` sets up Nx for a repo that is not JavaScript: a `.nx/installation` folder and an `nx` wrapper script (`nx/dist/src/command-line/init/init-v2.js:137-141`). That is not an npm workspace.
859
+
860
+ The flags:
861
+
862
+ | Flag | Why |
863
+ | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
864
+ | `--pm=npm` | The standard uses npm workspaces only. The preset stops with an error for another package manager. |
865
+ | `--nxCloud=skip` | No repo uses Nx Cloud. |
866
+ | `--aiAgents=none` | Without it, create-nx-workspace detects the agent and writes `AGENTS.md`, `CLAUDE.md`, `.claude/settings.json` and more before the preset runs (`@nx/workspace/dist/src/generators/new/generate-workspace-files.js:146-153`). |
867
+
868
+ In a terminal, create-nx-workspace asks you to trust the third-party preset. An agent or CI run does not ask (`create-nx-workspace/dist/src/internal-utils/prompts.js:194-208`).
869
+
870
+ ### What create-nx-workspace runs
871
+
872
+ For a preset from npm, create-nx-workspace runs these steps in order:
873
+
874
+ 1. It installs `nx` and `@nx/workspace` at its own version in a temporary folder (`create-nx-workspace/dist/src/create-sandbox.js:18-29`).
875
+ 2. It runs `nx new` there. `nx new` writes `package.json`, `nx.json`, `.gitignore`, `.editorconfig`, `.vscode/extensions.json` and `README.md`, adds `@zukhruf/nx` to `dependencies`, and runs `npm install` (`@nx/workspace/dist/src/generators/new/new.js:12-35`, `generate-workspace-files.js:119-176`, `generate-preset.js:271-276`). The root `package.json` gets `nx` and `@nx/workspace` at the version of create-nx-workspace, and a `packageManager` key (`generate-workspace-files.js:132-135`).
876
+ 3. It runs `nx g @zukhruf/nx:preset` in the new folder, with the options of the command line (`create-nx-workspace/dist/src/create-preset.js:8-38`).
877
+ 4. It runs `nx format --all` when the workspace has a formatter (`create-nx-workspace/dist/src/create-workspace.js:158-196`).
878
+ 5. It runs `git init` and the first commit, but only when the folder is not a Git work tree (step 4 of the list above).
879
+
880
+ `NX_SKIP_FORMAT=true` is set from step 2 to step 3 (`create-workspace.js:36-41`), so the `formatFiles` of the preset does nothing there (`@nx/devkit/dist/src/generators/format-files.js:40-44`). Step 4 formats all the files with the `.prettierrc` that the preset wrote.
881
+
882
+ ### Add the standard to an Nx workspace
883
+
884
+ ```sh
885
+ npx nx add @zukhruf/nx
886
+ ```
887
+
888
+ `nx add` installs the package and runs its `init` generator (`nx/dist/src/command-line/init/configure-plugins.js:61-87`, 24.0.6). When the package is already installed, run the generator itself:
889
+
890
+ ```sh
891
+ npx nx g @zukhruf/nx:init
892
+ ```
893
+
894
+ Run it in a workspace that has `nx.json` and `@zukhruf/nx`. It writes each missing root file and each missing key. It keeps what is there. A second run changes nothing.
895
+
896
+ ### Signature of the generators
897
+
898
+ ```jsonc
899
+ // packages/nx/generators.json, named by "generators" in package.json
900
+ {
901
+ "generators": {
902
+ "preset": {
903
+ "implementation": "./dist/generators/preset/generator.js",
904
+ "schema": "./src/generators/preset/schema.json",
905
+ "description": "Start a repo of the monorepo standard. create-nx-workspace runs it.",
906
+ },
907
+ "init": {
908
+ "implementation": "./dist/generators/init/generator.js",
909
+ "schema": "./src/generators/init/schema.json",
910
+ "description": "Add the root files of the monorepo standard. Safe to run again.",
911
+ },
912
+ },
913
+ }
914
+ ```
915
+
916
+ ```ts
917
+ // @zukhruf/nx:preset
918
+ interface PresetOptions {
919
+ name: string; // the folder name, from create-nx-workspace
920
+ packageManager?: string; // anything other than 'npm' is an error
921
+ }
922
+
923
+ // @zukhruf/nx:init
924
+ type InitOptions = Record<string, never>;
925
+ ```
926
+
927
+ - The schema of `preset` does not set `additionalProperties: false`. create-nx-workspace passes each option of its command line to the preset, for example `preset`, `defaultBase`, `workspaces` and `aiAgents` (`create-preset.js:9-17`). Nx stops with "'x' is not found in schema" only when the schema sets `additionalProperties: false` (`nx/dist/src/utils/params.js:175-185`). The preset reads `name` and `packageManager`, and ignores the others.
928
+ - `package.json` gets `"generators": "./generators.json"`, and `files` adds `generators.json` and `src/generators/*/schema.json`. `tsc` builds only `.ts` files, so the content of each file that a generator writes is a string in a `.ts` module, not a file in a `files/` folder. Then `dist` has it, and no build step copies assets.
929
+ - `init` takes no options, as `format` and `lint` take none. The workspace scope comes from the root package name (see [The workspace scope](#the-workspace-scope)). Each difference between the copies is the wiring of one kind of app, and the app generators own it.
930
+
931
+ ### What the generators write
932
+
933
+ `init` writes a file in one of three ways:
934
+
935
+ - **Create**: it writes the file only when it is missing, and never changes it later.
936
+ - **Add lines**: it adds each missing line, and never removes or reorders a line.
937
+ - **Merge keys**: it sets the keys that the standard owns, and keeps the other keys.
938
+
939
+ `preset` runs just after `nx new`, so it knows that each file in the folder came from `nx new`. It replaces 4 files of `nx new` with the files of the standard, and it cleans `package.json`. It deletes `apps/.gitkeep` and `libs/.gitkeep`, which `nx g` writes into the `Tree` before it calls a generator named `preset` (`nx/dist/src/command-line/generate/generate.js:250-253`). Then it runs `init`.
940
+
941
+ | File | Content | `init` | `preset` |
942
+ | ------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
943
+ | `package.json` | `private: true`, `type: "module"`, `workspaces: ["apps/*", "packages/*", "tools/*"]` when missing, `scripts.prepare: "git config core.hooksPath .husky \|\| exit 0"` when missing, the root `devDependencies` (see [Versions](#versions-that-the-generators-write)), `allowScripts` for the packages it installs | merge keys | also deletes `packageManager`, the empty `dependencies` and `@nx/workspace`; moves `@zukhruf/nx` from `dependencies` to `devDependencies`; `name` stays `@<name>/source` |
944
+ | `nx.json` | `analytics: false`; `tui.enabled: false`; `namedInputs` `default`, `production` (with `{ "env": "NODE_ENV" }`, without the ESLint config, the tests and the test tsconfigs) and `sharedGlobals` (the root ESLint config, `tsconfig.base.json`); `plugins` in this order: `@nx/js/typescript`, `@nx/eslint/plugin`, `@zukhruf/nx/lint`, `@zukhruf/nx/format`, `@zukhruf/nx/test`; `targetDefaults` below; `sync.applyChanges: true` | merge keys | — |
945
+ | `tsconfig.base.json` | the base for bundled apps (`moduleResolution: "Bundler"`, `strict`, `verbatimModuleSyntax`, `erasableSyntaxOnly`), with `noUncheckedIndexedAccess`; `tsconfigBase` in [`files.ts`](./src/generators/init/files.ts) | create | — |
946
+ | `tsconfig.json` | the solution file: `extends` the base, `files: []`, `references: []`; `nx sync` writes the references | create | — |
947
+ | `.npmrc` | `legacy-peer-deps=false`, `save-exact=true`, `strict-allow-scripts=true` | add lines | — |
948
+ | `.nvmrc` | `lts/*` | create | — |
949
+ | `.gitattributes` | `* text=auto eol=lf` | create | — |
950
+ | `.editorconfig` | utf-8, lf, a final newline, 2 spaces, trim trailing whitespace except in `*.md` | create | replaces the file of `nx new` |
951
+ | `.gitignore` | `gitignore` in [`files.ts`](./src/generators/init/files.ts) | add lines | replaces the file of `nx new` |
952
+ | `.prettierrc` | single quotes, the sort-imports plugin, `importOrder` with `./env` and `./startup` first and `^@<scope>/(.*)$`, and no Tailwind plugin | create | — |
953
+ | `.prettierignore` | `prettierignore` in [`files.ts`](./src/generators/init/files.ts) | add lines | — |
954
+ | `eslint.config.mjs` | `flat/base`, `flat/typescript` and `flat/javascript` of `@nx/eslint-plugin`; the build-output `ignores`; `@nx/enforce-module-boundaries`; the `base`, `tests`, `diagnostics`, `env` and `nx-project-json` configs of `@zukhruf/eslint`; `manifest.configs.recommended`; Modern Node for the config files and `.husky/*.ts`; `allowDefaultProject` for `*.config.ts` and `.husky/*.ts` | create | — |
955
+ | `.husky/pre-commit.ts`, `pre-push.ts`, `commit-msg.ts` | `Sync`, `Format`, `NoNumericPins`, `NpmrcPolicy`, `LockfileSync`, `DockerfileInstallsFromLockfile` and `DependencyChecks` on pre-commit, `Build` with `NODE_ENV=production` on pre-push, `NxReleaseScope` on commit-msg; mode `755` | create | — |
956
+ | `.husky/pre-commit`, `pre-push`, `commit-msg` | a link to the `.ts` file of the same name | create | — |
957
+ | `.vscode/settings.json` | file nesting, watcher and search excludes for `node_modules`, `.nx`, `tmp` | create | — |
958
+ | `.vscode/extensions.json` | `nrwl.angular-console`, `esbenp.prettier-vscode`, `dbaeumer.vscode-eslint` | create | replaces the file of `nx new` |
959
+ | `AGENTS.md`, `CLAUDE.md` | `AGENTS.md` holds the commands of the agent workflow; `CLAUDE.md` is one line, `@AGENTS.md` | create | — |
960
+ | `README.md` | `# <name>` and a link to `AGENTS.md` | — | replaces the file of `nx new` |
961
+
962
+ The `targetDefaults` that `init` writes:
963
+
964
+ | Target | Default |
965
+ | ----------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
966
+ | `typecheck` | `dependsOn: ["lint", "format:check", "..."]`; `"..."` keeps the `^typecheck` of `@nx/js/typescript` |
967
+ | `dev`, `serve`, `preview`, `serve-static` | `continuous: false`; Nx reports a continuous task that no task depends on as a success, whatever its exit code |
968
+
969
+ It writes no `format`, `format:check`, `lint` or `test` default. The `format`, `lint` and `test` areas give those targets, and a default would replace them (see the sections above).
970
+
971
+ ### What only an app generator writes
972
+
973
+ A root file holds no wiring of one kind of app. A pattern that matches no file is not wiring: the root `.gitignore`, `.prettierignore` and ESLint `ignores` keep `.sdk-it` and the Vite timestamp files, and the first two `importOrder` entries (`./env`, `./startup`) stay in `.prettierrc`.
974
+
975
+ | Wiring | Generator |
976
+ | ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- |
977
+ | `@nx/node` and `@nx/esbuild`; the `@nx/esbuild:esbuild` target default; `generators["@nx/node"]` | `node-app` (#3338) |
978
+ | `^sdk` in `build`, `dev`, `typecheck` and `test`; `!{projectRoot}/sdk-it.config.*` in `production` | `node-app` (#3338) |
979
+ | the `hono` config of `@zukhruf/eslint` and the `env` settings, in the project's own `eslint.config.mjs` | `node-app` (#3338) |
980
+ | `Dockerfile`, `.dockerignore`, `esbuild: true` in `allowScripts` | `node-app` (#3338) |
981
+ | `@nx/react`, `@nx/vite`, `@nx/vitest`, Vite, Vitest, Testing Library, happy-dom; `generators["@nx/react"]` | `react-app` (#3338) |
982
+ | `@zukhruf/eslint/react` and its 3 optional peers; the `react-router` and `tailwind` configs, in the project config | `react-app` (#3338) |
983
+ | Tailwind, `prettier-plugin-tailwindcss` in `.prettierrc` `plugins`, the Tailwind sync generator in `sync` and in `build`, `dev`, `serve` | `react-app` (#3338) |
984
+ | `allowDefaultProject` for `sdk-it.config.ts` and `prisma.config.ts`, in the project config | `node-app`, `prisma` (#4604) |
985
+
986
+ The Git hooks are the same in each repo. `Sync` stages `**/tsconfig*.json` and `**/styles.css`: it stages only a file that a sync generator wrote, so the second glob matches nothing in a repo with no Tailwind.
987
+
988
+ ### Versions that the generators write
989
+
990
+ - **The Nx family has one exact version.** `init` sets the root `nx` and each root `@nx/*` to `nxVersion`, also when the version is already there and is another one, a newer one included. Then npm installs one `nx` (#4532). An app generator adds its `@nx/*` packages at the same `nxVersion`. A test checks that the root `nx` equals `nxVersion` after `preset`, and that no root `@nx/*` has another version.
991
+ - **A missing `@zukhruf/*` package gets the version of `@zukhruf/nx` itself.** nx release gives each public package of zukhruf the same version, so the generator reads its own `package.json` and writes no list of versions. A version that is already there stays, for example a `file:` tarball in a smoke test.
992
+ - **The other root tools have exact versions** from one module, `src/generators/versions.ts`, that the app generators share: TypeScript 7 as `@typescript/native: "npm:typescript@7.x"` and the TypeScript 6 API as `typescript: "npm:@typescript/typescript6@6.x"` (see [Decisions and their reasons](#decisions-and-their-reasons)), ESLint 10, Prettier 3, `@trivago/prettier-plugin-sort-imports`, and the peers of `@zukhruf/eslint` that the root config loads. `init` adds a missing package at that version, and keeps a version that is already there.
993
+ - **`allowScripts`** names each install script of a package that the generator installs: `nx: false` and `unrs-resolver: false`. `init` adds a missing name, and keeps a decision that is already there. The smoke test of 2026-11-18 proved the list: `npm install` with `strict-allow-scripts=true` passed.
994
+
995
+ ### The workspace scope
996
+
997
+ The root package name is `@<scope>/source`. `nx new` writes it from the folder name (`@nx/workspace/dist/src/generators/new/files-integrated-repo/package.json__tmpl__`). One function reads the scope from that name, and each generator calls it: the `importOrder` of `.prettierrc` here, and the name of a generated client (`@<scope>/<app>-client`) and the portless domain in `node-app` (#3338). That is 3 places (#4080). The function stops with an error when the name has no scope. A generator never writes a fallback scope, so no repo gets the scope of another repo (factory falls back to `@factory`).
998
+
999
+ ### Install the dependencies and the hook links
1000
+
1001
+ A generator returns its install as a callback. Nx runs the callback after it writes the files, and not in a dry run.
1002
+
1003
+ - Both generators return `runTasksInSerial(installPackagesTask(tree), linkHooks)` (`@nx/devkit/dist/src/generators/run-tasks-in-serial.js:9-15`, `@nx/devkit/dist/src/tasks/install-packages-task.js:15-42`). `installPackagesTask` runs `npm install` only when the generator changed `package.json`, so a second run of `init` installs nothing.
1004
+ - After `preset`, `nx format --all` of create-nx-workspace finds Prettier and the sort-imports plugin installed.
1005
+
1006
+ The `Tree` keeps a file mode, but it has no links:
1007
+
1008
+ - **Mode.** The generator calls `tree.changePermissions('.husky/<hook>.ts', '755')` after `formatFiles`. `formatFiles` writes each file again with no options, so a mode set before it is lost (`@nx/devkit/dist/src/generators/format-files.js:119`; `nx/dist/src/generators/tree.js:45-68`). Nx applies the mode when it writes the file (`tree.js:185-211`, `:279-292`).
1009
+ - **Links.** Git runs `.husky/pre-commit`, so `.husky/pre-commit` is a link to `pre-commit.ts`. The `Tree` cannot write a link, so the callback writes each missing link with `fs.symlink`.
1010
+
1011
+ `prepare` sets `core.hooksPath` when npm installs. In an empty Git repo, the install of the preset runs it. In a new folder, `git init` comes after the install, so the first `npm install` after create-nx-workspace sets it.
1012
+
1013
+ ### What the generators do not do
1014
+
1015
+ - **They do not write CI, deploy or infra files.** The `dokploy` generator writes them (#4603).
1016
+ - **They do not write a NodeNext base.** The base is the one for bundled apps. zukhruf and elt run code from source with NodeNext, and they do not use the generators.
1017
+ - **They do not change an ESLint config that is already there.** factory splices the configs of `@zukhruf/eslint` into an existing `eslint.config.mjs`. No consumer needs that now: the generator writes the file in a new repo, and factory and whatisgoingon already have their config.
1018
+ - **They do not commit.** create-nx-workspace commits only in a new folder. In an existing repo, you make the first commit.
1019
+ - **They do not delete a file or a folder** that the standard does not own. Only `preset` deletes, and only what `nx new` and `nx g` wrote a moment before: keys of `package.json`, `apps/.gitkeep` and `libs/.gitkeep`.
1020
+
1021
+ ### What stays in factory
1022
+
1023
+ - The brand: the `@factory` scope fallback, the fonts, colors and favicons (#3338).
1024
+ - The mirror tests `tests/workspace-mirror.test.ts` and `tests/templates-mirror.test.ts`. They prove that factory's own root files equal the output of the generator. factory keeps them, and calls `@zukhruf/nx:init` (#4611).
1025
+ - `--test-force-exit` for each project: factory sets it in the options of `@zukhruf/nx/test`. The standard adds it only for the tag `test:docker` ([Docker tests](#docker-tests)), so `init` writes the plugin with no options.
1026
+
1027
+ ### Tests of the generators
1028
+
1029
+ The tests use a virtual `Tree` from `createTreeWithEmptyWorkspace` of `@nx/devkit/testing`, as the tests of `@factory/foundation` do (`src/generators/init/generator.test.ts`, `src/generators/preset/generator.test.ts`). They port these tests of `tools/foundation/tests/workspace.test.ts`: the scope in `importOrder`, the full baseline, a second run that changes nothing, `targetDefaults` that are already there, and a `.prettierrc` that is already there. They drop the test of an ESLint config with a multi-line import, because `init` does not change an existing config. New tests:
1030
+
1031
+ - `preset` on the files of `nx new`: the result has no `packageManager`, no `apps/.gitkeep` and no `libs/.gitkeep`, `@zukhruf/nx` is in `devDependencies`, and the root `nx` and each `@nx/*` equal `nxVersion` (#4532).
1032
+ - `preset` with `packageManager: 'pnpm'` stops with an error.
1033
+ - `init` on a root package name with no scope stops with an error.
1034
+ - `init` sets a newer `nx` and `@nx/*` down to `nxVersion`, and keeps the version of another root tool.
1035
+ - Each hook that `init` creates has the mode `755`.
1036
+ - The backend-neutral output: no React, Vite, Vitest or Tailwind package in `package.json`, and no app wiring in `nx.json`.
1037
+
1038
+ ### Test the preset before a release
1039
+
1040
+ create-nx-workspace takes the version of a third-party preset from `NX_E2E_PRESET_VERSION` when it is set (`@nx/workspace/dist/src/generators/new/new.js:114-118`). So the preset runs from a tarball of the checkout, before a release:
1041
+
1042
+ ```sh
1043
+ npx nx run nx:build
1044
+ (cd packages/nx && npm pack --pack-destination <scratch>)
1045
+ mkdir <scratch>/acme && cd <scratch>/acme && git init
1046
+ NX_E2E_PRESET_VERSION=file:<scratch>/zukhruf-nx-<version>.tgz \
1047
+ npx create-nx-workspace@latest . --preset=@zukhruf/nx --pm=npm --nxCloud=skip --aiAgents=none
1048
+ ```
1049
+
1050
+ Then check that `npm install` passes, that `npx nx run-many -t typecheck` and `npx nx run-many -t lint` pass, and that the first `git commit` passes the hooks. Delete the folder at the end. On 2026-11-18 both paths passed: a new folder (`acme`), and a folder with only `git init` (`.`). In the new folder, a demo package also passed `typecheck` (TypeScript 7.0.2) and `lint`, and its commit passed each hook. A second run of `npx nx g @zukhruf/nx:init` in the generated repo changed no file.
1051
+
1052
+ ### Who uses the generators
1053
+
1054
+ | Workspace | Generators | Backlog item |
1055
+ | --------- | ----------------------------------------------------- | ------------ |
1056
+ | meddit | `preset`, `node-app`, `react-app`, `pair` | #4606 |
1057
+ | meddit | `prisma` | #4607 |
1058
+ | meddit | `dokploy` | #4608 |
1059
+ | factory | `init`, `node-app`, `react-app`, `pair`, `ui-package` | #4611 |
1060
+
1061
+ The decisions are in [ADR 0009](./docs/adr/0009-a-preset-and-an-init-generator-start-a-repo-from-nothing.md). The backlog item of the generators is #3337.
1062
+
1063
+ ## app generators
1064
+
1065
+ Four generators add the projects of the standard: a backend, a web app, the pair of the two, and a UI package. factory wrote them in its private package `@factory/foundation`; whatisgoingon, text2sql and deepagents hold copies. meddit is the third repo of the same kinds, so they move here (#3338). Each runs [`init`](#add-the-standard-to-an-nx-workspace) first.
1066
+
1067
+ ### Add a backend, a web app and their pair
1068
+
1069
+ ```sh
1070
+ npx nx g @zukhruf/nx:node-app apps/backend
1071
+ npx nx g @zukhruf/nx:react-app apps/web
1072
+ npx nx g @zukhruf/nx:pair --api apps/backend --web apps/web
1073
+ npm install
1074
+ npx nx sync
1075
+ ```
1076
+
1077
+ Then `npx nx run-many -t typecheck lint test build` passes, and `npx nx run @acme/backend:docker:build` builds the image of the backend with the web build in it. The image reports its commit:
1078
+
1079
+ ```sh
1080
+ npx nx run @acme/backend:docker:run
1081
+ curl -s http://localhost:3000/api/healthz # {"status":"ok","sha":"<git rev-parse HEAD>"}
1082
+ ```
1083
+
1084
+ ### Add a UI package
1085
+
1086
+ ```sh
1087
+ npx nx g @zukhruf/nx:ui-package packages/ui --importPath @acme/ui
1088
+ ```
1089
+
1090
+ ### Signature of the app generators
1091
+
1092
+ ```ts
1093
+ // @zukhruf/nx:node-app
1094
+ interface NodeAppOptions {
1095
+ directory: string; // the project root, for example apps/backend
1096
+ port?: number; // 3000: PORT in .env.example, portless --app-port, EXPOSE
1097
+ }
1098
+
1099
+ // @zukhruf/nx:react-app
1100
+ interface ReactAppOptions {
1101
+ directory: string; // the project root, for example apps/web
1102
+ }
1103
+
1104
+ // @zukhruf/nx:pair
1105
+ interface PairOptions {
1106
+ api: string; // the project root of a node-app
1107
+ web: string; // the project root of a react-app
1108
+ }
1109
+
1110
+ // @zukhruf/nx:ui-package
1111
+ interface UiPackageOptions {
1112
+ directory: string; // under packages/, for example packages/ui
1113
+ importPath: string; // a scoped package name, for example @acme/ui
1114
+ }
1115
+ ```
1116
+
1117
+ Each schema sets `additionalProperties: false`. The project name is the package name: `@<scope>/<last segment of directory>`, for example `@acme/backend`.
1118
+
1119
+ ### What each app generator writes
1120
+
1121
+ | Generator | Files of the project | Root and nx.json |
1122
+ | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1123
+ | `node-app` | `src/server.ts` (terminus, the `@nx-target-name: serve` header), `app.ts` (Hono on `/api`), `env.ts` (zod, `BUILD_SHA`), `logging.ts` (evlog), `startup.ts`, `routes/healthz.route.ts`, `app.test.ts`; `.env.example` (always) and `.env` (when missing); `Dockerfile`; `sdk-it.config.ts` and the client stub in `.sdk-it/`; the tsconfigs; `eslint.config.mjs` with `hono`, Modern Node and the env settings | `@nx/node`, `@nx/esbuild`, `esbuild`, `@sdk-it/cli`; `.dockerignore` when missing; the client in `workspaces`; the `.sdk-it` lines of `.gitignore` and `.prettierignore`; the `@nx/esbuild:esbuild` default; `^sdk` in `build`, `dev`, `typecheck` and `test` (`["...", "^sdk"]`); the sdk-it exclusion of `production`; `generators["@nx/node"]` |
1124
+ | `react-app` | `index.html`, `src/main.tsx` (React Router 8 in data mode), `src/app/app.tsx` and its test, `src/styles.css` (Tailwind with the sync markers), `vite.config.ts` (the React Compiler, Tailwind, brotli and gzip, the portless and `/api` dev proxy, the `test` block), `tsconfig.app.json` writing to `out-tsc`, `tsconfig.spec.json`, `eslint.config.mjs` with `@zukhruf/eslint/react`, `react-router` and `tailwind` | `@nx/react`, `@nx/vite`, `@nx/vitest` with `testMode: "run"`, Vite, Vitest, Testing Library, happy-dom, Tailwind, the 4 React lint plugins; `prettier-plugin-tailwindcss` in `.prettierrc`; the Tailwind sync generator in `sync` and in `build`, `dev`, `serve`; `generators["@nx/react"]`; the `test` default as it was |
1125
+ | `pair` | in the web: `src/api.ts` and the client, `zod` and `fast-content-type-parse` in its manifest; in the api: `src/routes/ui.route.ts`, its mount in `app.ts`, and the Dockerfile again with the web build | — |
1126
+ | `ui-package` | `package.json` with the `development` export of `src/index.ts`, `vite.config.ts` (a library with `vite-plugin-dts`), the tsconfigs, `eslint.config.mjs` with `@zukhruf/eslint/react` and `tailwind`, `tests/public-api.test.mjs` | the React root packages |
1127
+
1128
+ The targets of a project are in the `nx` key of its `package.json`: the generators pass `useProjectJson: false` and `addPlugin: true` to Nx, so Nx 23 and 24 write the same shape. `format`, `lint`, `test` (node) and `typecheck` come from the inference plugins; `node-app` writes `build` (one ESM esbuild bundle, each npm package external, with a `require` banner), `serve` (with `NODE_ENV=development`), `portless` (`<app>.<scope>`), `docker:build` and `docker:run`, and keeps `prune-lockfile` of `@nx/node`. `react-app` writes `portless` and the `test` target of the project (`^sdk`, `NODE_ENV=test`).
1129
+
1130
+ ### The commit of an image
1131
+
1132
+ `docker:build` runs `docker build --file <root>/Dockerfile --build-arg BUILD_SHA=$(git rev-parse HEAD) --tag <scope>-<app> .` from the workspace root. The runtime stage has `ARG BUILD_SHA` and `ENV ... BUILD_SHA=$BUILD_SHA`, `env.ts` accepts a non-empty string or nothing, and `/api/healthz` returns `{ "status": "ok", "sha": <BUILD_SHA or null> }`. So a deploy can tell the new container from the old one. An image built without the build arg gets an empty `BUILD_SHA`, and `env.ts` stops it at start. terminus answers `/healthz` (no `/api`) for the `HEALTHCHECK`.
1133
+
1134
+ ### Versions that the app generators write
1135
+
1136
+ - The packages of the apps have exact versions in `appPackageVersions` of `src/generators/versions.ts`, the latest on 2026-11-18: Hono 4.13, `@hono/node-server` 2.1, evlog 2.35, zod 4.6, sdk-it 0.46.11, esbuild 0.28, React 19.3, React Router 8.5, Vite 8.3, Vitest 5.1, Tailwind 4.3, `@vitejs/plugin-react` 6.3, `@rolldown/plugin-babel` 0.3, `vite-plugin-dts` 5.1.
1137
+ - An app generator reads the root package names before the generator of Nx runs. After it, a package of the app that was not there gets its pin, also over the version that Nx wrote; a version that was there stays. Each root `nx` and `@nx/*` gets `nxVersion`.
1138
+ - Residue goes when the run added it: the swc toolchain, `eslint-plugin-import`, `eslint-plugin-jsx-a11y` and `eslint-plugin-react` (they cap ESLint below 10), the root `react` and `react-dom` (each project declares its own), `@vitest/ui`, and for `ui-package` `@babel/core`, `@babel/preset-react`, `ajv` and the root `vite-plugin-dts`.
1139
+ - `allowScripts`: `esbuild: true`, `@parcel/watcher: false` and `fsevents: false` from `node-app`. A decision that is there stays.
1140
+ - `overrides`: `@juristr/nx-tailwind-sync` takes the one `@nx/devkit` (#4532); `@sdk-it/cli` and `@sdk-it/hono` take the root `typescript`, because sdk-it peers on `^6.0.3` and the TypeScript 6 alias is 6.0.2.
1141
+
1142
+ ### Where the Nx plugins come from
1143
+
1144
+ `@nx/node`, `@nx/react`, `@nx/vite` and `@nx/vitest` are optional peers. An app generator requires the plugin from `@zukhruf/nx`, and else installs it at `nxVersion` into a temporary folder with `ensurePackage` of `@nx/devkit`, as the generators of Nx do. The plugin's own generator adds it to the root `package.json`. A repo with only a backend installs no React, Vite, Vitest or Tailwind package.
1145
+
1146
+ ### Errors of the app generators
1147
+
1148
+ | Error | When |
1149
+ | ---------------------------------------------------------------------- | ------------------------------------------------------------- |
1150
+ | `The root package name "acme" has no scope.` | The root package is not named `@<scope>/source` (from `init`) |
1151
+ | `The directory "../x" is not a folder in the workspace.` | `directory` leaves the workspace or is empty |
1152
+ | `apps/backend has no sdk-it.config.ts, so it is not a node-app. Run …` | `pair --api` names a project that `node-app` did not write |
1153
+ | `apps/web has no vite.config.ts, so it is not a react-app. Run …` | `pair --web` names a project that `react-app` did not write |
1154
+ | `A UI package goes under packages/, not "…".` | `ui-package` outside `packages/` |
1155
+ | `<root> already belongs to <name>.` | `ui-package` on a folder of another package |
1156
+
1157
+ ### What stays in factory after the move
1158
+
1159
+ The brand: the fonts, colors and favicons of `index.html`. The generated `index.html` has none of them; it keeps the theme script (light, dark or system, set before the first paint) and `styles.css` keeps the `dark` variant, because the standard puts them in each web app (ADR 0010). factory switches to these generators in #4611.
1160
+
1161
+ ### Tests of the app generators
1162
+
1163
+ The tests run each generator on a virtual `Tree` with Nx 23.2.1, which zukhruf's root installs (`src/generators/*/generator.test.ts`, helpers in `src/testing/generator-tree.ts`). They port factory's `node-app`, `react-app`, `pair` and `ui-package` tests, and add the build sha, `testMode: "run"`, `test.dependsOn` after `node-app` and `react-app`, a backend-only workspace with no React, Vite, Vitest or Tailwind package, the workspace scope in the portless domain, and no brand in the web files. They drop factory's `modern-node.test.ts` and `root-vite.test.ts`, which write to disk and read zukhruf's installed versions; the smoke test below runs lint and a strict `npm install` instead. What Nx 24.0.6 writes itself is proven by the smoke test.
1164
+
1165
+ ### Test the app generators before a release
1166
+
1167
+ After the steps of [Test the preset before a release](#test-the-preset-before-a-release), in the generated repo: run the 3 commands of [Add a backend, a web app and their pair](#add-a-backend-a-web-app-and-their-pair), then `npx nx run-many -t typecheck lint test build`, the first commit (each hook passes), `npx nx run @acme/backend:docker:build`, and a container whose `/api/healthz` reports `git rev-parse HEAD`.
1168
+
1169
+ The decisions are in [ADR 0010](./docs/adr/0010-the-app-generators-move-here-and-call-the-generators-of-nx.md). The backlog item of the app generators is #3338.
1170
+
1171
+ ## prisma generator
1172
+
1173
+ `prisma` writes a Postgres db package on Prisma 7 and `@prisma/adapter-pg`, and can connect a node-app to it. text2sql holds 5 copies of the package and factory 1, and meddit is the next one, so the shape moves here (#4604). The targets come from the [prisma area](#prisma): the generator writes none.
1174
+
1175
+ ### Add a db package
1176
+
1177
+ ```sh
1178
+ npx nx g @zukhruf/nx:prisma packages/db --backend apps/backend
1179
+ npm install
1180
+ npx nx sync
1181
+ npx nx run @acme/db:generate
1182
+ ```
1183
+
1184
+ Then `npx nx run-many -t typecheck lint test build` passes, and the tests of `@acme/db` and `@acme/backend` run against a Postgres of `@zukhruf/testing`. Leave out `--backend` for a package that no backend uses yet.
1185
+
1186
+ ### Signature of the prisma generator
1187
+
1188
+ ```ts
1189
+ // @zukhruf/nx:prisma
1190
+ interface PrismaOptions {
1191
+ directory: string; // the project root, for example packages/db
1192
+ backend?: string; // the project root of a node-app, for example apps/backend
1193
+ }
1194
+ ```
1195
+
1196
+ The schema sets `additionalProperties: false`. The package name is `@<scope>/<last segment of directory>`, for example `@acme/db`.
1197
+
1198
+ ### What the prisma generator writes
1199
+
1200
+ | File | Content |
1201
+ | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1202
+ | `schema.prisma` | the `prisma-client` generator with `output = "src/prisma"` and `importFileExtension = "ts"`, and the `postgresql` datasource; the models go in `models/*.prisma` |
1203
+ | `prisma.config.ts` | `schema: '.'`, `migrations.path: 'migrations'`, `url` from `CONNECTION_STRING` and `shadowDatabaseUrl` from `SHADOW_CONNECTION_STRING`, each read only when set, so `generate` runs with none; no dotenv |
1204
+ | `migrations/migration_lock.toml` | `provider = "postgresql"` |
1205
+ | `models/.gitkeep` | the image copies `models/`, so the folder is in Git before the first model |
1206
+ | `src/index.ts` | `createPrisma({ connectionString })` on the Postgres adapter, and each export of the generated client; it reads no environment |
1207
+ | `src/testing.ts` | `applySchema(connectionString)`: runs each `migrations/*/migration.sql` in order with `pg`, with no `_prisma_migrations` record, for a test database that is thrown away |
1208
+ | `src/index.test.ts` | a query on a database of `@zukhruf/testing/postgres` after `applySchema`; the project has the tag `test:docker` |
1209
+ | `package.json` | the `.` and `./testing` exports (`development` the source, `import` `dist`); `@prisma/client`, `@prisma/adapter-pg`, `pg` and `tslib` in `dependencies`; `prisma` and `@types/pg` in `devDependencies` |
1210
+ | `tsconfig.lib.json` | the build: JavaScript and declarations into `dist`, with `rewriteRelativeImportExtensions`, because the generated client imports `.ts` files |
1211
+ | `tsconfig.json`, `tsconfig.test.json` | the solution file and the tests, as in node-app |
1212
+ | `eslint.config.mjs` | ignores `src/prisma`; Modern Node; `allowDefaultProject` for `prisma.config.ts` |
1213
+ | `.env.example`, `.env` | `CONNECTION_STRING=` and `SHADOW_CONNECTION_STRING=`; `.env` only when missing |
1214
+ | `Dockerfile.migration` | `npm ci --workspace=<package>` installs the CLI from the lockfile, and `CMD npx prisma migrate deploy` applies the migrations to the `CONNECTION_STRING` of the container |
1215
+
1216
+ At the root: `@zukhruf/nx/prisma` in `plugins`; `generate` in the `dependsOn` of the `typecheck` and `build` defaults, with `...`; `<root>/src/prisma` in `.gitignore` and `.prettierignore`; `.dockerignore` when missing; the package root in `workspaces` when no `<parent>/*` glob holds it; `@zukhruf/testing`; and `@prisma/engines: true`, `prisma: false`, `ssh2: false`, `cpu-features: false` in `allowScripts`. A second run keeps the files of the package and adds no line or key twice.
1217
+
1218
+ With `--backend`, the node-app gets:
1219
+
1220
+ - `CONNECTION_STRING: z.string().min(1)` in `src/env.ts`, and the key in `.env.example` and in a `.env` that has none.
1221
+ - In `src/startup.ts`, the client and one `SELECT 1` before the app serves, so a database that refuses the connection stops the boot. `$connect()` alone opens no connection on a driver adapter.
1222
+ - `await prisma.$disconnect()` in the terminus `onSignal` of `src/server.ts`.
1223
+ - `src/database.test.ts`, which imports the package through its exports, and the tag `test:docker`.
1224
+ - The npm packages of the db package in its `dependencies`, not the package: the bundle inlines the package and leaves them external, so `prune-lockfile` puts them in the image.
1225
+
1226
+ ### Versions that the prisma generator writes
1227
+
1228
+ `prisma`, `@prisma/client` and `@prisma/adapter-pg` have one exact version, 7.10.1, in `appPackageVersions`. The `latest` tag of `prisma` is a release candidate of 8 (8.0.0-rc.34 on 2026-11-18) while the other two are at 7.10.1, so no version comes from `latest`, and a test checks that the three are equal and stable.
1229
+
1230
+ ### Migrations
1231
+
1232
+ Write a migration by hand, or with `npx prisma migrate diff --from-empty --to-schema . --script` in the package for the first one, into `migrations/<timestamp>_<name>/migration.sql`. Apply it with `nx run @acme/db:deploy`, or with the image. `migrate dev` needs a TTY, so an agent does not run it, and nothing runs `migrate reset` on a shared database.
1233
+
1234
+ ### Errors of the prisma generator
1235
+
1236
+ | Error | When |
1237
+ | ---------------------------------------------------------------------- | --------------------------------------------------------- |
1238
+ | `apps/api has no sdk-it.config.ts, so it is not a node-app. Run …` | `--backend` names a project that `node-app` did not write |
1239
+ | `packages/db already belongs to @acme/other.` | `directory` holds another package |
1240
+ | `apps/backend/src/server.ts has no "import './startup.ts';", so the …` | a backend file lost the line that the wiring changes |
1241
+
1242
+ ### Test the prisma generator before a release
1243
+
1244
+ After the steps of [Test the preset before a release](#test-the-preset-before-a-release): `node-app apps/backend`, the 4 commands of [Add a db package](#add-a-db-package), and `npx nx run-many -t typecheck lint test build`. Then add a model and a first migration, put `@zukhruf/nx` back on the registry version (`npm ci` in an image cannot read a `file:` tarball), build `Dockerfile.migration`, and run its container against a new `postgres:18-alpine`: `prisma migrate deploy` applies the migration. On 2026-11-18 each step passed, and the backend image served `/api/healthz` with one database session and stopped at start with a wrong password.
1245
+
1246
+ The decisions are in [ADR 0012](./docs/adr/0012-the-prisma-generator-writes-a-postgres-db-package-and-wires-a-backend.md). The backlog item is #4604.
1247
+
1248
+ ## dokploy generator
1249
+
1250
+ `dokploy` writes the GitOps delivery of a node-app on Dokploy: an OpenTofu project in `infra/` that stores the compose in Dokploy, and the workflows that build the images, apply the stack and roll it out. text2sql (v2, authx) and whatisgoingon hold copies, and meddit is the third repo, so the shape moves here (#4603). The workflows call zukhruf's kit at `@main`: the reusable `tofu-apply.yml`, and the `dokploy-deploy` and `wait-for-health` actions.
1251
+
1252
+ ### Deliver a backend
1253
+
1254
+ ```sh
1255
+ npx nx g @zukhruf/nx:dokploy --api apps/backend --owner <github-owner>
1256
+ npx nx run @acme/infra:typecheck
1257
+ ```
1258
+
1259
+ With Postgres, a Prisma package, a private GHCR and a DNS name:
1260
+
1261
+ ```sh
1262
+ npx nx g @zukhruf/nx:dokploy --api apps/backend --owner Phi-Science \
1263
+ --database packages/db --registryUser <github-user> --host app.example.com
1264
+ ```
1265
+
1266
+ Then add the repository secrets `TF_ENCRYPTION_PASSPHRASE`, `DOKPLOY_API_KEY` and `HCLOUD_TOKEN`, and `GHCR_PULL_TOKEN` with `--registryUser`. A push to `main` runs CI, and a green CI run deploys.
1267
+
1268
+ ### Signature of the dokploy generator
1269
+
1270
+ ```ts
1271
+ // @zukhruf/nx:dokploy
1272
+ interface DokployOptions {
1273
+ api: string; // the project root of a node-app
1274
+ owner: string; // the GitHub owner; the images are ghcr.io/<owner, lowercase>/<name>-<app>
1275
+ name?: string; // the Dokploy project and the image prefix; the workspace scope
1276
+ dokployHost?: string; // https://dokploy.limerence.sh/api
1277
+ server?: string; // the Hetzner server that runs Dokploy: limerence-dokploy
1278
+ host?: string; // a DNS name in a Hetzner zone; without it, <name>.<server ipv4>.sslip.io
1279
+ zone?: string; // the Hetzner zone of host: host without its first label
1280
+ database?: string; // the project root of a Prisma package: adds Postgres and the migrate service
1281
+ registryUser?: string; // the GitHub user of GHCR_PULL_TOKEN: adds a Dokploy registry for private images
1282
+ }
1283
+ ```
1284
+
1285
+ ### What the dokploy generator writes
1286
+
1287
+ | File | What it holds |
1288
+ | ---------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1289
+ | `infra/project.json` | `@<scope>/infra`; `@zukhruf/nx/opentofu` gives its targets, and the generator lists that plugin after `@zukhruf/nx/format` in `nx.json` |
1290
+ | `infra/compose.dokploy.yml` | the app image on `dokploy-network` with the Traefik labels (`web` redirects, `websecure` with Let's Encrypt); with `database`, `postgres:18-alpine` and the one-shot `migrate`, which the app waits for |
1291
+ | `infra/.env.example`, `infra/.gitignore` | the secrets of a local run, `TF_VAR_dokploy_api_key=${DOKPLOY_API_KEY}` (and `TF_VAR_ghcr_pull_token`); the plaintext backups, `.terraform/` and `tfplan` |
1292
+ | `src/environments/production/*.tf` | `versions`, `backend` (local, the encrypted state committed), `encryption` (pbkdf2 and aes_gcm, enforced), `providers`, `dns`, `main`, `outputs` (`dokploy_api`, `compose_id`, `host`), `variables`, `registry` |
1293
+ | `.terraform.lock.hcl` | the providers for `linux_amd64` and `darwin_arm64`, so `typecheck` (`-lockfile=readonly`) passes on CI and a Mac |
1294
+ | `.github/workflows/deploy.yml` | gate, image (a matrix: the app and `migrate`), promote to `:latest`, infra (`tofu-apply.yml`), release (`dokploy-deploy`, `wait-for-health`) |
1295
+ | `.github/workflows/ci.yml` | only when missing: setup-workspace, OpenTofu, nx-set-shas, `sync:check` and `prettier --check` in parallel, then `nx affected -t lint typecheck test build` |
1296
+
1297
+ The compose reads `PUBLIC_HOST`, and with `database` `POSTGRES_PASSWORD` and `CONNECTION_STRING`, from the env that `main.tf` stores with it. Postgres 18 keeps its data under `/var/lib/postgresql/18/docker`, so the volume is mounted at `/var/lib/postgresql`. Each variable refuses an empty value, because CI renders an unset secret as `""`. The stack has no `terraform_data` deployment: the release job deploys after a new image, after an apply that changed the stack, and while the infra project is affected since the last successful deploy, and it checks the build sha only after a new image. `.prettierignore` gets `.terraform`, `tfplan` and the state.
1298
+
1299
+ ### Errors of the dokploy generator
1300
+
1301
+ | Error | When |
1302
+ | ------------------------------------------------------------------------------- | -------------------------------------------------------- |
1303
+ | `apps/backend has no Dockerfile, so it is not a node-app. Run …` | `--api` names a project that `node-app` did not write |
1304
+ | `packages/db has no Dockerfile.migration, so it is not a Prisma package. Run …` | `--database` names a project that `prisma` did not write |
1305
+ | `The zone "example.com" needs a host in it.` | `--zone` without `--host` |
1306
+ | `The host "app.example.org" is not a name in the zone "example.com".` | `--host` outside `--zone` |
1307
+ | `The name "My App" is not a lowercase name that starts with a letter.` | `--name`, or the scope, is not a lowercase name |
1308
+
1309
+ ### Test the dokploy generator before a release
1310
+
1311
+ After the steps of [Test the app generators before a release](#test-the-app-generators-before-a-release), run `prisma` and then `dokploy` with `--database`, `--registryUser` and no `--host`, then `npm install`, `npx nx sync`, `npx nx run @acme/infra:typecheck`, `actionlint .github/workflows/*.yml`, `npx nx run-many -t typecheck lint`, `npx prettier --check .`, and `docker compose -f infra/compose.dokploy.yml config`. actionlint 1.7.12 does not know the `parallel:` step of `ci.yml`, which GitHub runs. On 2026-11-18 each passed, also after a run with `--host` and no `--database` or `--registryUser`; after that, two runs with the first options passed again, and the second of them changed no file.
1312
+
1313
+ The decisions are in [ADR 0011](./docs/adr/0011-the-dokploy-generator-writes-the-gitops-delivery-of-a-node-app.md). The backlog item of the dokploy generator is #4603.