@zukhruf/nx 0.8.38 → 0.8.40

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 (75) hide show
  1. package/README.md +54 -32
  2. package/dist/generators/auth/files.d.ts +2 -2
  3. package/dist/generators/auth/files.d.ts.map +1 -1
  4. package/dist/generators/auth/files.js +21 -20
  5. package/dist/generators/auth/files.js.map +1 -1
  6. package/dist/generators/auth/generator.d.ts.map +1 -1
  7. package/dist/generators/auth/generator.js +13 -17
  8. package/dist/generators/auth/generator.js.map +1 -1
  9. package/dist/generators/dokploy/files.d.ts.map +1 -1
  10. package/dist/generators/dokploy/files.js +16 -1
  11. package/dist/generators/dokploy/files.js.map +1 -1
  12. package/dist/generators/env-file.d.ts +8 -0
  13. package/dist/generators/env-file.d.ts.map +1 -0
  14. package/dist/generators/env-file.js +13 -0
  15. package/dist/generators/env-file.js.map +1 -0
  16. package/dist/generators/init/files.js +2 -2
  17. package/dist/generators/init/nx-json.d.ts +7 -0
  18. package/dist/generators/init/nx-json.d.ts.map +1 -1
  19. package/dist/generators/init/nx-json.js +19 -1
  20. package/dist/generators/init/nx-json.js.map +1 -1
  21. package/dist/generators/node-app/files.d.ts +3 -3
  22. package/dist/generators/node-app/files.d.ts.map +1 -1
  23. package/dist/generators/node-app/files.js +48 -35
  24. package/dist/generators/node-app/files.js.map +1 -1
  25. package/dist/generators/node-app/generator.js +7 -23
  26. package/dist/generators/node-app/generator.js.map +1 -1
  27. package/dist/generators/pair/files.d.ts +11 -2
  28. package/dist/generators/pair/files.d.ts.map +1 -1
  29. package/dist/generators/pair/files.js +51 -34
  30. package/dist/generators/pair/files.js.map +1 -1
  31. package/dist/generators/pair/generator.d.ts.map +1 -1
  32. package/dist/generators/pair/generator.js +22 -8
  33. package/dist/generators/pair/generator.js.map +1 -1
  34. package/dist/generators/portless-env.d.ts +14 -0
  35. package/dist/generators/portless-env.d.ts.map +1 -0
  36. package/dist/generators/portless-env.js +26 -0
  37. package/dist/generators/portless-env.js.map +1 -0
  38. package/dist/generators/prisma/files.d.ts.map +1 -1
  39. package/dist/generators/prisma/files.js +2 -0
  40. package/dist/generators/prisma/files.js.map +1 -1
  41. package/dist/generators/prisma/generator.d.ts +35 -1
  42. package/dist/generators/prisma/generator.d.ts.map +1 -1
  43. package/dist/generators/prisma/generator.js +57 -36
  44. package/dist/generators/prisma/generator.js.map +1 -1
  45. package/dist/generators/react-app/generator.js +10 -20
  46. package/dist/generators/react-app/generator.js.map +1 -1
  47. package/dist/generators/ui-package/files.d.ts.map +1 -1
  48. package/dist/generators/ui-package/files.js +7 -8
  49. package/dist/generators/ui-package/files.js.map +1 -1
  50. package/dist/generators/ui-package/generator.d.ts.map +1 -1
  51. package/dist/generators/ui-package/generator.js +3 -1
  52. package/dist/generators/ui-package/generator.js.map +1 -1
  53. package/dist/migrations/update-0-8-40/add-local-postgres.d.ts +14 -0
  54. package/dist/migrations/update-0-8-40/add-local-postgres.d.ts.map +1 -0
  55. package/dist/migrations/update-0-8-40/add-local-postgres.js +125 -0
  56. package/dist/migrations/update-0-8-40/add-local-postgres.js.map +1 -0
  57. package/dist/migrations/update-0-8-40/add-portless-proxy-env.d.ts +9 -0
  58. package/dist/migrations/update-0-8-40/add-portless-proxy-env.d.ts.map +1 -0
  59. package/dist/migrations/update-0-8-40/add-portless-proxy-env.js +21 -0
  60. package/dist/migrations/update-0-8-40/add-portless-proxy-env.js.map +1 -0
  61. package/dist/migrations/update-0-8-40/add-prisma-client-inputs.d.ts +11 -0
  62. package/dist/migrations/update-0-8-40/add-prisma-client-inputs.d.ts.map +1 -0
  63. package/dist/migrations/update-0-8-40/add-prisma-client-inputs.js +20 -0
  64. package/dist/migrations/update-0-8-40/add-prisma-client-inputs.js.map +1 -0
  65. package/dist/migrations/update-0-8-40/node-env-production.d.ts +13 -0
  66. package/dist/migrations/update-0-8-40/node-env-production.d.ts.map +1 -0
  67. package/dist/migrations/update-0-8-40/node-env-production.js +189 -0
  68. package/dist/migrations/update-0-8-40/node-env-production.js.map +1 -0
  69. package/dist/migrations/workspace.d.ts +31 -0
  70. package/dist/migrations/workspace.d.ts.map +1 -0
  71. package/dist/migrations/workspace.js +53 -0
  72. package/dist/migrations/workspace.js.map +1 -0
  73. package/migrations.json +24 -0
  74. package/package.json +51 -3
  75. package/release.json +30 -0
@@ -0,0 +1,125 @@
1
+ import { formatFiles, joinPathFragments, logger, offsetFromRoot, readJson, } from '@nx/devkit';
2
+ import { addMissingKeys } from "../../generators/add-keys.js";
3
+ import { addEnvEntry } from "../../generators/env-file.js";
4
+ import { unique } from "../../generators/init/nx-json.js";
5
+ import { composeDevYml, localConnectionString, } from "../../generators/prisma/files.js";
6
+ import { localDatabaseTargets } from "../../generators/prisma/generator.js";
7
+ import { workspaceScope } from "../../generators/workspace-scope.js";
8
+ import { envValue, projectRootsWith, sourceFiles, updateJsonIfChanged, } from "../workspace.js";
9
+ const composePath = 'compose.dev.yml';
10
+ /**
11
+ * #4792, ADR 0012 decisions 16 and 17: the local Postgres of development. For
12
+ * each db package of the prisma generator (a `prisma.config.ts` that reads
13
+ * CONNECTION_STRING), a repo gets what it does not have: a root
14
+ * compose.dev.yml on port 5432 with the database named after the workspace
15
+ * scope, the `up` and `down` targets, the local CONNECTION_STRING in the env
16
+ * files of the package and of each backend that imports it, and `^up` in the
17
+ * dependsOn of that backend's serve. A compose.dev.yml that is there names the
18
+ * port and the database. A file without the shape that the generator wrote
19
+ * gets no edit, and the log says the step to take by hand.
20
+ */
21
+ export default async function addLocalPostgres(tree) {
22
+ const packages = dbPackages(tree);
23
+ if (packages.length === 0)
24
+ return;
25
+ const database = localDatabase(tree, packages);
26
+ if (database === undefined)
27
+ return;
28
+ const connectionString = localConnectionString(database);
29
+ for (const db of packages) {
30
+ updateJsonIfChanged(tree, joinPathFragments(db.root, 'package.json'), (manifest) => {
31
+ manifest.nx = {
32
+ ...manifest.nx,
33
+ targets: addMissingKeys(manifest.nx?.targets, localDatabaseTargets(offsetFromRoot(db.root), database)),
34
+ };
35
+ });
36
+ addConnectionString(tree, db.root, connectionString);
37
+ for (const backend of backendsOf(tree, db.name)) {
38
+ addUpToServe(tree, backend);
39
+ addConnectionString(tree, backend, connectionString);
40
+ }
41
+ }
42
+ await formatFiles(tree);
43
+ }
44
+ /** Each db package of the prisma generator. One whose prisma.config.ts reads another variable is left alone. */
45
+ function dbPackages(tree) {
46
+ const packages = [];
47
+ for (const root of projectRootsWith(tree, 'prisma.config.ts')) {
48
+ const config = tree.read(joinPathFragments(root, 'prisma.config.ts'), 'utf-8') ?? '';
49
+ const { name } = readJson(tree, joinPathFragments(root, 'package.json'));
50
+ if (name === undefined)
51
+ continue;
52
+ if (!config.includes('CONNECTION_STRING')) {
53
+ logger.warn(`add-local-postgres: ${root}/prisma.config.ts does not read CONNECTION_STRING, so ${root} is not in the shape of @zukhruf/nx:prisma and got no edit. To take the local Postgres by hand, make prisma.config.ts read CONNECTION_STRING, and add what the prisma generator writes: the up and down targets of ${root}, the local CONNECTION_STRING in its .env.example and .env and in those of each backend that imports ${name}, and "^up" in the dependsOn of that backend's serve (ADR 0012 decisions 16 and 17 of @zukhruf/nx).`);
54
+ continue;
55
+ }
56
+ packages.push({ root, name });
57
+ }
58
+ return packages;
59
+ }
60
+ /**
61
+ * The database of compose.dev.yml. A missing file is written on port 5432
62
+ * with the database of the workspace scope, as the prisma generator writes it
63
+ * with no port option. A file that is there must have the `database` service
64
+ * that the generator writes, or nothing is changed.
65
+ */
66
+ function localDatabase(tree, packages) {
67
+ const compose = tree.read(composePath, 'utf-8');
68
+ if (compose === null) {
69
+ const database = { port: 5432, name: workspaceScope(tree) };
70
+ tree.write(composePath, composeDevYml(database, packages[0]?.name ?? ''));
71
+ return database;
72
+ }
73
+ const service = /^ {2}database:\n((?: {4,}.*\n|\s*\n)*)/m.exec(compose)?.[1];
74
+ const port = service && /['"]?127\.0\.0\.1:(\d+):5432['"]?/.exec(service)?.[1];
75
+ const name = service && /^\s+POSTGRES_DB:\s*['"]?([^'"\s]+)/m.exec(service)?.[1];
76
+ const credentials = service !== undefined &&
77
+ /^\s+POSTGRES_USER:\s*['"]?postgres['"]?\s*$/m.test(service) &&
78
+ /^\s+POSTGRES_PASSWORD:\s*['"]?postgres['"]?\s*$/m.test(service);
79
+ if (!port || !name || !credentials) {
80
+ logger.warn(`add-local-postgres: ${composePath} has no service "database" on 127.0.0.1:<port>:5432 with POSTGRES_USER postgres, POSTGRES_PASSWORD postgres and POSTGRES_DB, so ${packages.map((db) => db.root).join(', ')} got no up, down or CONNECTION_STRING. Give the service that shape, or add the up and down targets and the CONNECTION_STRING of your database by hand (ADR 0012 decisions 16 and 17 of @zukhruf/nx).`);
81
+ return undefined;
82
+ }
83
+ return { port: Number(port), name };
84
+ }
85
+ /** Each node-app whose source imports the db package, as the prisma generator wires one: `from '<package>'` in its src. */
86
+ function backendsOf(tree, packageName) {
87
+ const escaped = packageName.replace(/[.*+?^${}()|[\]\\/]/g, '\\$&');
88
+ const imports = new RegExp(`['"]${escaped}(?:/[^'"]*)?['"]`);
89
+ return projectRootsWith(tree, 'sdk-it.config.ts').filter((root) => sourceFiles(tree, joinPathFragments(root, 'src')).some((path) => imports.test(tree.read(path, 'utf-8') ?? '')));
90
+ }
91
+ /** `^up` reaches the db package through the import graph (zukhruf/no-depends-on-project refuses a named project). */
92
+ function addUpToServe(tree, backend) {
93
+ const path = joinPathFragments(backend, 'package.json');
94
+ const serve = readJson(tree, path).nx?.targets?.['serve'];
95
+ if (serve === undefined) {
96
+ logger.warn(`add-local-postgres: ${path} has no serve target, so it got no "^up". Add "^up" to the dependsOn of the serve target of ${backend}, so serve starts the local Postgres first.`);
97
+ return;
98
+ }
99
+ updateJsonIfChanged(tree, path, (manifest) => {
100
+ const target = manifest.nx?.targets?.['serve'];
101
+ if (target === undefined)
102
+ return;
103
+ target.dependsOn = unique([...(target.dependsOn ?? []), '^up']);
104
+ });
105
+ }
106
+ /**
107
+ * The local URL in `.env.example`, and in `.env` where it is, when the file
108
+ * has no CONNECTION_STRING or has it empty, as the generator wrote it before.
109
+ * A value that is there stays.
110
+ */
111
+ function addConnectionString(tree, root, connectionString) {
112
+ for (const file of ['.env.example', '.env']) {
113
+ const path = joinPathFragments(root, file);
114
+ const content = tree.read(path, 'utf-8');
115
+ if (content === null)
116
+ continue;
117
+ if (envValue(content, 'CONNECTION_STRING') === '') {
118
+ tree.write(path, content.replace(/^CONNECTION_STRING=$/m, `CONNECTION_STRING=${connectionString}`));
119
+ }
120
+ else {
121
+ addEnvEntry(tree, path, 'CONNECTION_STRING', connectionString);
122
+ }
123
+ }
124
+ }
125
+ //# sourceMappingURL=add-local-postgres.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-local-postgres.js","sourceRoot":"","sources":["../../../src/migrations/update-0-8-40/add-local-postgres.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,iBAAiB,EACjB,MAAM,EACN,cAAc,EACd,QAAQ,GACT,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAEL,aAAa,EACb,qBAAqB,GACtB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAEL,QAAQ,EACR,gBAAgB,EAChB,WAAW,EACX,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAOtC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,gBAAgB,CAAC,IAAU;IACvD,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,QAAQ,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CAAC,CAAC;QACjE,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ /**
3
+ * #4768: node-app and react-app add PORTLESS_UNPRIVILEGED=1 and
4
+ * PORTLESS_HTTPS=1 to `targetDefaults.portless.options.env` in nx.json. A
5
+ * repo with a `portless` target gets the keys it does not have; a key that is
6
+ * there stays, and no PORTLESS_TLD is added.
7
+ */
8
+ export default function addPortlessProxyEnvMigration(tree: Tree): Promise<void>;
9
+ //# sourceMappingURL=add-portless-proxy-env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-portless-proxy-env.d.ts","sourceRoot":"","sources":["../../../src/migrations/update-0-8-40/add-portless-proxy-env.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,IAAI,EAGV,MAAM,YAAY,CAAC;AAKpB;;;;;GAKG;AACH,wBAA8B,4BAA4B,CACxD,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,IAAI,CAAC,CASf"}
@@ -0,0 +1,21 @@
1
+ import { formatFiles, getProjects, } from '@nx/devkit';
2
+ import { addPortlessProxyEnv } from "../../generators/portless-env.js";
3
+ import { updateJsonIfChanged } from "../workspace.js";
4
+ /**
5
+ * #4768: node-app and react-app add PORTLESS_UNPRIVILEGED=1 and
6
+ * PORTLESS_HTTPS=1 to `targetDefaults.portless.options.env` in nx.json. A
7
+ * repo with a `portless` target gets the keys it does not have; a key that is
8
+ * there stays, and no PORTLESS_TLD is added.
9
+ */
10
+ export default async function addPortlessProxyEnvMigration(tree) {
11
+ const portless = getProjects(tree)
12
+ .values()
13
+ .some((project) => project.targets?.['portless'] !== undefined);
14
+ if (!portless)
15
+ return;
16
+ updateJsonIfChanged(tree, 'nx.json', (nxJson) => {
17
+ addPortlessProxyEnv(nxJson);
18
+ });
19
+ await formatFiles(tree);
20
+ }
21
+ //# sourceMappingURL=add-portless-proxy-env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-portless-proxy-env.js","sourceRoot":"","sources":["../../../src/migrations/update-0-8-40/add-portless-proxy-env.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,WAAW,EACX,WAAW,GACZ,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,4BAA4B,CACxD,IAAU;IAEV,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC;SAC/B,MAAM,EAAE;SACR,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,UAAU,CAAC,KAAK,SAAS,CAAC,CAAC;IAClE,IAAI,CAAC,QAAQ;QAAE,OAAO;IACtB,mBAAmB,CAAsB,IAAI,EAAE,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE;QACnE,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;IACH,MAAM,WAAW,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ /**
3
+ * #4826: the prisma generator adds `...` and
4
+ * `{ "dependentTasksOutputFiles": "**\/*.ts" }` to the `inputs` of
5
+ * `targetDefaults.typecheck` and `targetDefaults.build`, so a changed schema
6
+ * changes the hash of a db package's build (ADR 0012 decision 6). A repo whose
7
+ * nx.json lists `@zukhruf/nx/prisma` gets the inputs it does not have; the
8
+ * inputs that are there stay.
9
+ */
10
+ export default function addPrismaClientInputs(tree: Tree): Promise<void>;
11
+ //# sourceMappingURL=add-prisma-client-inputs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-prisma-client-inputs.d.ts","sourceRoot":"","sources":["../../../src/migrations/update-0-8-40/add-prisma-client-inputs.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,IAAI,EAAe,MAAM,YAAY,CAAC;AAK9E;;;;;;;GAOG;AACH,wBAA8B,qBAAqB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAM7E"}
@@ -0,0 +1,20 @@
1
+ import { formatFiles } from '@nx/devkit';
2
+ import { addPrismaTargetDefaults } from "../../generators/prisma/generator.js";
3
+ import { hasPlugin, updateJsonIfChanged } from "../workspace.js";
4
+ /**
5
+ * #4826: the prisma generator adds `...` and
6
+ * `{ "dependentTasksOutputFiles": "**\/*.ts" }` to the `inputs` of
7
+ * `targetDefaults.typecheck` and `targetDefaults.build`, so a changed schema
8
+ * changes the hash of a db package's build (ADR 0012 decision 6). A repo whose
9
+ * nx.json lists `@zukhruf/nx/prisma` gets the inputs it does not have; the
10
+ * inputs that are there stay.
11
+ */
12
+ export default async function addPrismaClientInputs(tree) {
13
+ if (!hasPlugin(tree, '@zukhruf/nx/prisma'))
14
+ return;
15
+ updateJsonIfChanged(tree, 'nx.json', (nxJson) => {
16
+ addPrismaTargetDefaults(nxJson);
17
+ });
18
+ await formatFiles(tree);
19
+ }
20
+ //# sourceMappingURL=add-prisma-client-inputs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-prisma-client-inputs.js","sourceRoot":"","sources":["../../../src/migrations/update-0-8-40/add-prisma-client-inputs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEjE;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,qBAAqB,CAAC,IAAU;IAC5D,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,oBAAoB,CAAC;QAAE,OAAO;IACnD,mBAAmB,CAAsB,IAAI,EAAE,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE;QACnE,uBAAuB,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IACH,MAAM,WAAW,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ /**
3
+ * #4833, ADR 0016: NODE_ENV is production in every setup, and code never
4
+ * reads it. A repo gets the configuration that the generators write now: the
5
+ * nx.json defaults of test and serve, the env of the generated targets, the
6
+ * web's two exceptions, NODE_ENV in each .env.example, the workflow env, and
7
+ * ALLOWED_ORIGINS in the production env of dokploy. A value that is there
8
+ * stays, except the development that the backend's generated targets set
9
+ * before. Source code is not rewritten: each NODE_ENV read is logged with its
10
+ * file and line, and zukhruf/no-node-env refuses it.
11
+ */
12
+ export default function nodeEnvProduction(tree: Tree): Promise<void>;
13
+ //# sourceMappingURL=node-env-production.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-env-production.d.ts","sourceRoot":"","sources":["../../../src/migrations/update-0-8-40/node-env-production.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,IAAI,EAIV,MAAM,YAAY,CAAC;AAgBpB;;;;;;;;;GASG;AACH,wBAA8B,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAyCzE"}
@@ -0,0 +1,189 @@
1
+ import { formatFiles, joinPathFragments, logger, } from '@nx/devkit';
2
+ import { envMarker, infraRoot } from "../../generators/dokploy/files.js";
3
+ import { addEnvEntry } from "../../generators/env-file.js";
4
+ import { addProductionNodeEnvDefaults } from "../../generators/init/nx-json.js";
5
+ import { hasPlugin, projectRootsWith, sourceFiles, updateJsonIfChanged, } from "../workspace.js";
6
+ const envComment = '# Every setup runs under production; no code reads NODE_ENV (ADR 0016).';
7
+ /**
8
+ * #4833, ADR 0016: NODE_ENV is production in every setup, and code never
9
+ * reads it. A repo gets the configuration that the generators write now: the
10
+ * nx.json defaults of test and serve, the env of the generated targets, the
11
+ * web's two exceptions, NODE_ENV in each .env.example, the workflow env, and
12
+ * ALLOWED_ORIGINS in the production env of dokploy. A value that is there
13
+ * stays, except the development that the backend's generated targets set
14
+ * before. Source code is not rewritten: each NODE_ENV read is logged with its
15
+ * file and line, and zukhruf/no-node-env refuses it.
16
+ */
17
+ export default async function nodeEnvProduction(tree) {
18
+ const backends = projectRootsWith(tree, 'sdk-it.config.ts');
19
+ const dbPackages = projectRootsWith(tree, 'prisma.config.ts');
20
+ // A react-app has an index.html beside its vite.config.ts; a ui-package, a
21
+ // Vite library, has none and gets no dev server.
22
+ const webs = hasPlugin(tree, '@nx/vite/plugin')
23
+ ? projectRootsWith(tree, 'vite.config.ts').filter((root) => tree.exists(joinPathFragments(root, 'index.html')))
24
+ : [];
25
+ if (backends.length + dbPackages.length + webs.length === 0)
26
+ return;
27
+ if (tree.exists('nx.json')) {
28
+ updateJsonIfChanged(tree, 'nx.json', addProductionNodeEnvDefaults);
29
+ }
30
+ for (const root of backends) {
31
+ setTargetEnv(tree, root, ['serve', 'auth:generate', 'auth:check'], {
32
+ value: 'production',
33
+ replaces: 'development',
34
+ });
35
+ setTargetEnv(tree, joinPathFragments(root, '.sdk-it'), ['sdk'], {
36
+ value: 'production',
37
+ });
38
+ addNodeEnvLine(tree, root);
39
+ }
40
+ for (const root of dbPackages) {
41
+ setTargetEnv(tree, root, ['up'], { value: 'production' });
42
+ addNodeEnvLine(tree, root);
43
+ }
44
+ for (const root of webs)
45
+ addWebExceptions(tree, root);
46
+ addNodeEnvLine(tree, infraRoot);
47
+ for (const workflow of ['ci.yml', 'deploy.yml']) {
48
+ addWorkflowEnv(tree, joinPathFragments('.github/workflows', workflow));
49
+ }
50
+ addAllowedOrigins(tree);
51
+ logNodeEnvReads(tree);
52
+ await formatFiles(tree);
53
+ }
54
+ /**
55
+ * Sets NODE_ENV in the env of each named target that the project's
56
+ * package.json has. A NODE_ENV that is there stays, unless it is `replaces`,
57
+ * the value the generator wrote before.
58
+ */
59
+ function setTargetEnv(tree, root, targets, { value, replaces }) {
60
+ const path = joinPathFragments(root, 'package.json');
61
+ if (!tree.exists(path))
62
+ return;
63
+ updateJsonIfChanged(tree, path, (manifest) => {
64
+ for (const name of targets) {
65
+ const target = manifest.nx?.targets?.[name];
66
+ if (target === undefined)
67
+ continue;
68
+ const env = { ...target.options?.env };
69
+ if (env['NODE_ENV'] === undefined || env['NODE_ENV'] === replaces) {
70
+ env['NODE_ENV'] = value;
71
+ }
72
+ target.options = { ...target.options, env };
73
+ }
74
+ });
75
+ }
76
+ /**
77
+ * The web's two exceptions (ADR 0016): Vite turns React Fast Refresh off under
78
+ * production, so dev and serve run under development, and Testing Library
79
+ * renders through act(), which production React does not have, so test runs
80
+ * under test. A target with an env of its own keeps it.
81
+ */
82
+ function addWebExceptions(tree, root) {
83
+ const path = joinPathFragments(root, 'package.json');
84
+ updateJsonIfChanged(tree, path, (manifest) => {
85
+ const targets = { ...manifest.nx?.targets };
86
+ for (const [name, value] of [
87
+ ['dev', 'development'],
88
+ ['serve', 'development'],
89
+ ['test', 'test'],
90
+ ]) {
91
+ const target = targets[name] ?? {};
92
+ if (target.options?.env !== undefined)
93
+ continue;
94
+ targets[name] = {
95
+ ...target,
96
+ options: { ...target.options, env: { NODE_ENV: value } },
97
+ };
98
+ }
99
+ manifest.nx = { ...manifest.nx, targets };
100
+ });
101
+ }
102
+ /** NODE_ENV=production in the .env.example of `root`, and in its .env where it is. */
103
+ function addNodeEnvLine(tree, root) {
104
+ for (const file of ['.env.example', '.env']) {
105
+ const path = joinPathFragments(root, file);
106
+ const content = tree.read(path, 'utf-8');
107
+ if (content === null || /^NODE_ENV=/m.test(content))
108
+ continue;
109
+ const separator = content === '' || content.endsWith('\n') ? '' : '\n';
110
+ tree.write(path, `${content}${separator}${envComment}\n`);
111
+ addEnvEntry(tree, path, 'NODE_ENV', 'production');
112
+ }
113
+ }
114
+ /**
115
+ * NODE_ENV: production and npm_config_include: dev in the workflow-level env
116
+ * of a workflow that dokploy writes. npm omits devDependencies under
117
+ * NODE_ENV=production, and CI needs them.
118
+ */
119
+ function addWorkflowEnv(tree, path) {
120
+ const content = tree.read(path, 'utf-8');
121
+ if (content === null)
122
+ return;
123
+ const lines = [
124
+ ...(/^ {2}NODE_ENV:/m.test(content)
125
+ ? []
126
+ : [
127
+ ' # Every setup runs under production (ADR 0016 of @zukhruf/nx).',
128
+ ' NODE_ENV: production',
129
+ ]),
130
+ ...(/^ {2}npm_config_include:/m.test(content)
131
+ ? []
132
+ : [
133
+ ' # npm omits devDependencies under NODE_ENV=production; CI needs them.',
134
+ ' npm_config_include: dev',
135
+ ]),
136
+ ];
137
+ if (lines.length === 0)
138
+ return;
139
+ if (/^env:\n/m.test(content)) {
140
+ tree.write(path, content.replace(/^env:\n/m, `env:\n${lines.join('\n')}\n`));
141
+ }
142
+ else if (/^jobs:/m.test(content)) {
143
+ tree.write(path, content.replace(/^jobs:/m, `env:\n${lines.join('\n')}\n\njobs:`));
144
+ }
145
+ else {
146
+ logger.warn(`node-env-production: ${path} has no workflow-level env and no jobs key, so it got no edit. Add "env: { NODE_ENV: production, npm_config_include: dev }" at its top level (ADR 0016 of @zukhruf/nx).`);
147
+ }
148
+ }
149
+ /**
150
+ * ALLOWED_ORIGINS in the production env of the dokploy infra: the generated
151
+ * backend now always derives the better-auth baseURL from its hosts, and
152
+ * better-auth refuses an empty list. The comment line ends the alignment
153
+ * group of tofu fmt, as the auth generator's lines do.
154
+ */
155
+ function addAllowedOrigins(tree) {
156
+ const path = joinPathFragments(infraRoot, 'src/environments/production/main.tf');
157
+ const content = tree.read(path, 'utf-8');
158
+ if (content === null || /^\s+ALLOWED_ORIGINS\s*=/m.test(content))
159
+ return;
160
+ const marker = new RegExp(`^( +)${escape(envMarker)}$`, 'm');
161
+ if (!marker.test(content)) {
162
+ logger.warn(`node-env-production: ${path} has no "${envMarker}" line, so it got no ALLOWED_ORIGINS. Add ALLOWED_ORIGINS = "https://\${local.host}" to the env map of module "stack": the backend derives the better-auth baseURL from it (ADR 0016 of @zukhruf/nx).`);
163
+ return;
164
+ }
165
+ tree.write(path, content.replace(marker, (line, indent) => `${indent}# The public origin: CORS and better-auth trust it (ADR 0016).\n${indent}ALLOWED_ORIGINS = "https://\${local.host}"\n${line}`));
166
+ }
167
+ // The reads that zukhruf/no-node-env reports, as text. A write
168
+ // (`process.env.NODE_ENV = …`) is not a read.
169
+ const nodeEnvRead = /process\.env(?:\.NODE_ENV|\[\s*['"`]NODE_ENV['"`]\s*\])(?!\s*=[^=])|import\.meta\.env\.NODE_ENV|\{[^}]*\bNODE_ENV\b[^}]*\}\s*=\s*process\.env/;
170
+ /** Logs each NODE_ENV read in source, which the code change must replace by hand. */
171
+ function logNodeEnvReads(tree) {
172
+ const reads = [];
173
+ for (const path of sourceFiles(tree)) {
174
+ if (path.includes('/node_modules/') || path.endsWith('.d.ts'))
175
+ continue;
176
+ const lines = (tree.read(path, 'utf-8') ?? '').split('\n');
177
+ lines.forEach((line, index) => {
178
+ if (nodeEnvRead.test(line))
179
+ reads.push(`${path}:${index + 1}`);
180
+ });
181
+ }
182
+ if (reads.length === 0)
183
+ return;
184
+ logger.warn(`node-env-production: ${reads.length} NODE_ENV reads in source, which zukhruf/no-node-env refuses. Give each behavior its own setting (ALLOWED_ORIGINS, HOST, LOG_DIR, LOG_PRETTY, UI_ROOT), as ADR 0016 of @zukhruf/nx lists:\n${reads.join('\n')}`);
185
+ }
186
+ function escape(text) {
187
+ return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
188
+ }
189
+ //# sourceMappingURL=node-env-production.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-env-production.js","sourceRoot":"","sources":["../../../src/migrations/update-0-8-40/node-env-production.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,WAAW,EACX,iBAAiB,EACjB,MAAM,GACP,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC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'@nx/devkit';
2
+ /** The package.json of a generated project: its targets are in its `nx` key. */
3
+ export interface ProjectManifest {
4
+ name?: string;
5
+ nx?: {
6
+ targets?: Record<string, TargetConfiguration>;
7
+ };
8
+ }
9
+ /**
10
+ * Changes a JSON file of the Tree only when `update` changes its value, so a
11
+ * second run writes nothing, and a file whose keys are in another order keeps
12
+ * its text. `update` changes the value it gets.
13
+ */
14
+ export declare function updateJsonIfChanged<T extends object>(tree: Tree, path: string, update: (value: T) => void): void;
15
+ /**
16
+ * The root of each project that holds `marker`, the file a generator leaves
17
+ * in the projects of its kind: `sdk-it.config.ts` for a node-app and
18
+ * `prisma.config.ts` for a db package. Only a project root with a package.json
19
+ * counts, because the generators write their targets there.
20
+ */
21
+ export declare function projectRootsWith(tree: Tree, marker: string): string[];
22
+ /** Whether nx.json registers the plugin, for example `@nx/vite/plugin`. */
23
+ export declare function hasPlugin(tree: Tree, plugin: string): boolean;
24
+ /** Each source file under `directory` that Git does not ignore, `.ts`, `.tsx`, `.js`, `.mjs` and the like. */
25
+ export declare function sourceFiles(tree: Tree, directory?: string): string[];
26
+ /**
27
+ * The value of `KEY` in an env file: undefined when the file has no line for
28
+ * the key, and `''` for `KEY=`.
29
+ */
30
+ export declare function envValue(content: string, key: string): string | undefined;
31
+ //# sourceMappingURL=workspace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/migrations/workspace.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,IAAI,EAMV,MAAM,YAAY,CAAC;AAIpB,gFAAgF;AAChF,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAA;KAAE,CAAC;CACxD;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,EAClD,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GACzB,IAAI,CAKN;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CASrE;AAED,2EAA2E;AAC3E,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAI7D;AAID,8GAA8G;AAC9G,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,SAAK,GAAG,MAAM,EAAE,CAMhE;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEzE"}
@@ -0,0 +1,53 @@
1
+ import { isDeepStrictEqual } from 'node:util';
2
+ import { getProjects, joinPathFragments, readJson, visitNotIgnoredFiles, writeJson, } from '@nx/devkit';
3
+ import { pluginName } from "../generators/init/nx-json.js";
4
+ /**
5
+ * Changes a JSON file of the Tree only when `update` changes its value, so a
6
+ * second run writes nothing, and a file whose keys are in another order keeps
7
+ * its text. `update` changes the value it gets.
8
+ */
9
+ export function updateJsonIfChanged(tree, path, update) {
10
+ const before = readJson(tree, path);
11
+ const after = structuredClone(before);
12
+ update(after);
13
+ if (!isDeepStrictEqual(before, after))
14
+ writeJson(tree, path, after);
15
+ }
16
+ /**
17
+ * The root of each project that holds `marker`, the file a generator leaves
18
+ * in the projects of its kind: `sdk-it.config.ts` for a node-app and
19
+ * `prisma.config.ts` for a db package. Only a project root with a package.json
20
+ * counts, because the generators write their targets there.
21
+ */
22
+ export function projectRootsWith(tree, marker) {
23
+ return [...getProjects(tree).values()]
24
+ .map((project) => project.root)
25
+ .filter((root) => tree.exists(joinPathFragments(root, marker)) &&
26
+ tree.exists(joinPathFragments(root, 'package.json')))
27
+ .toSorted();
28
+ }
29
+ /** Whether nx.json registers the plugin, for example `@nx/vite/plugin`. */
30
+ export function hasPlugin(tree, plugin) {
31
+ if (!tree.exists('nx.json'))
32
+ return false;
33
+ const { plugins = [] } = readJson(tree, 'nx.json');
34
+ return plugins.some((entry) => pluginName(entry) === plugin);
35
+ }
36
+ const SOURCE = /\.[cm]?[jt]sx?$/;
37
+ /** Each source file under `directory` that Git does not ignore, `.ts`, `.tsx`, `.js`, `.mjs` and the like. */
38
+ export function sourceFiles(tree, directory = '') {
39
+ const files = [];
40
+ visitNotIgnoredFiles(tree, directory, (path) => {
41
+ if (SOURCE.test(path))
42
+ files.push(path);
43
+ });
44
+ return files.toSorted();
45
+ }
46
+ /**
47
+ * The value of `KEY` in an env file: undefined when the file has no line for
48
+ * the key, and `''` for `KEY=`.
49
+ */
50
+ export function envValue(content, key) {
51
+ return new RegExp(`^${key}=(.*)$`, 'm').exec(content)?.[1];
52
+ }
53
+ //# sourceMappingURL=workspace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../src/migrations/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAIL,WAAW,EACX,iBAAiB,EACjB,QAAQ,EACR,oBAAoB,EACpB,SAAS,GACV,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAQ3D;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAU,EACV,IAAY,EACZ,MAA0B;IAE1B,MAAM,MAAM,GAAG,QAAQ,CAAI,IAAI,EAAE,IAAI,CAAC,CAAC;IACvC,MAAM,KAAK,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,CAAC,KAAK,CAAC,CAAC;IACd,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,KAAK,CAAC;QAAE,SAAS,CAAC,IAAI,EAAE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;AAC1B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAe,EAAE,GAAW;IACnD,OAAO,IAAI,MAAM,CAAC,IAAI,GAAG,QAAQ,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC7D,CAAC"}
@@ -0,0 +1,24 @@
1
+ {
2
+ "generators": {
3
+ "add-portless-proxy-env": {
4
+ "version": "0.8.40",
5
+ "description": "The portless proxy starts unprivileged on HTTPS: targetDefaults.portless gets PORTLESS_UNPRIVILEGED=1 and PORTLESS_HTTPS=1 (#4768).",
6
+ "implementation": "./dist/migrations/update-0-8-40/add-portless-proxy-env.js"
7
+ },
8
+ "add-local-postgres": {
9
+ "version": "0.8.40",
10
+ "description": "A db package gets the local Postgres of a root compose.dev.yml, its up and down targets, the local CONNECTION_STRING, and ^up in its backend's serve (ADR 0012 decisions 16 and 17).",
11
+ "implementation": "./dist/migrations/update-0-8-40/add-local-postgres.js"
12
+ },
13
+ "node-env-production": {
14
+ "version": "0.8.40",
15
+ "description": "NODE_ENV is production in every setup and code never reads it: the configuration of ADR 0016, and a log of each NODE_ENV read in source.",
16
+ "implementation": "./dist/migrations/update-0-8-40/node-env-production.js"
17
+ },
18
+ "add-prisma-client-inputs": {
19
+ "version": "0.8.40",
20
+ "description": "A repo with @zukhruf/nx/prisma hashes the generated Prisma client: targetDefaults.typecheck and .build get the inputs \"...\" and { \"dependentTasksOutputFiles\": \"**/*.ts\" } (#4826, ADR 0012 decision 6).",
21
+ "implementation": "./dist/migrations/update-0-8-40/add-prisma-client-inputs.js"
22
+ }
23
+ }
24
+ }