@zukhruf/nx 0.8.30 → 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 (102) hide show
  1. package/README.md +378 -19
  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.js +3 -3
  27. package/dist/generators/init/files.js.map +1 -1
  28. package/dist/generators/init/generator.d.ts.map +1 -1
  29. package/dist/generators/init/generator.js +1 -16
  30. package/dist/generators/init/generator.js.map +1 -1
  31. package/dist/generators/init/nx-json.d.ts +16 -3
  32. package/dist/generators/init/nx-json.d.ts.map +1 -1
  33. package/dist/generators/init/nx-json.js +20 -5
  34. package/dist/generators/init/nx-json.js.map +1 -1
  35. package/dist/generators/init/root-package-json.d.ts +6 -0
  36. package/dist/generators/init/root-package-json.d.ts.map +1 -1
  37. package/dist/generators/init/root-package-json.js +15 -12
  38. package/dist/generators/init/root-package-json.js.map +1 -1
  39. package/dist/generators/node-app/files.d.ts +43 -0
  40. package/dist/generators/node-app/files.d.ts.map +1 -0
  41. package/dist/generators/node-app/files.js +522 -0
  42. package/dist/generators/node-app/files.js.map +1 -0
  43. package/dist/generators/node-app/generator.d.ts +17 -0
  44. package/dist/generators/node-app/generator.d.ts.map +1 -0
  45. package/dist/generators/node-app/generator.js +319 -0
  46. package/dist/generators/node-app/generator.js.map +1 -0
  47. package/dist/generators/nx-plugin.d.ts +16 -0
  48. package/dist/generators/nx-plugin.d.ts.map +1 -0
  49. package/dist/generators/nx-plugin.js +27 -0
  50. package/dist/generators/nx-plugin.js.map +1 -0
  51. package/dist/generators/pair/files.d.ts +4 -0
  52. package/dist/generators/pair/files.d.ts.map +1 -0
  53. package/dist/generators/pair/files.js +73 -0
  54. package/dist/generators/pair/files.js.map +1 -0
  55. package/dist/generators/pair/generator.d.ts +19 -0
  56. package/dist/generators/pair/generator.d.ts.map +1 -0
  57. package/dist/generators/pair/generator.js +70 -0
  58. package/dist/generators/pair/generator.js.map +1 -0
  59. package/dist/generators/prisma/files.d.ts +20 -0
  60. package/dist/generators/prisma/files.d.ts.map +1 -0
  61. package/dist/generators/prisma/files.js +183 -0
  62. package/dist/generators/prisma/files.js.map +1 -0
  63. package/dist/generators/prisma/generator.d.ts +17 -0
  64. package/dist/generators/prisma/generator.d.ts.map +1 -0
  65. package/dist/generators/prisma/generator.js +258 -0
  66. package/dist/generators/prisma/generator.js.map +1 -0
  67. package/dist/generators/react-app/files.d.ts +7 -0
  68. package/dist/generators/react-app/files.d.ts.map +1 -0
  69. package/dist/generators/react-app/files.js +188 -0
  70. package/dist/generators/react-app/files.js.map +1 -0
  71. package/dist/generators/react-app/generator.d.ts +12 -0
  72. package/dist/generators/react-app/generator.d.ts.map +1 -0
  73. package/dist/generators/react-app/generator.js +242 -0
  74. package/dist/generators/react-app/generator.js.map +1 -0
  75. package/dist/generators/react.d.ts +29 -0
  76. package/dist/generators/react.d.ts.map +1 -0
  77. package/dist/generators/react.js +64 -0
  78. package/dist/generators/react.js.map +1 -0
  79. package/dist/generators/root-dependencies.d.ts +21 -0
  80. package/dist/generators/root-dependencies.d.ts.map +1 -0
  81. package/dist/generators/root-dependencies.js +56 -0
  82. package/dist/generators/root-dependencies.js.map +1 -0
  83. package/dist/generators/ui-package/files.d.ts +37 -0
  84. package/dist/generators/ui-package/files.d.ts.map +1 -0
  85. package/dist/generators/ui-package/files.js +118 -0
  86. package/dist/generators/ui-package/files.js.map +1 -0
  87. package/dist/generators/ui-package/generator.d.ts +14 -0
  88. package/dist/generators/ui-package/generator.d.ts.map +1 -0
  89. package/dist/generators/ui-package/generator.js +111 -0
  90. package/dist/generators/ui-package/generator.js.map +1 -0
  91. package/dist/generators/versions.d.ts +49 -1
  92. package/dist/generators/versions.d.ts.map +1 -1
  93. package/dist/generators/versions.js +61 -1
  94. package/dist/generators/versions.js.map +1 -1
  95. package/generators.json +30 -0
  96. package/package.json +24 -5
  97. package/src/generators/dokploy/schema.json +48 -0
  98. package/src/generators/node-app/schema.json +22 -0
  99. package/src/generators/pair/schema.json +18 -0
  100. package/src/generators/prisma/schema.json +21 -0
  101. package/src/generators/react-app/schema.json +17 -0
  102. package/src/generators/ui-package/schema.json +22 -0
@@ -0,0 +1,319 @@
1
+ import { formatFiles, installPackagesTask, runTasksInSerial, updateJson, writeJson, } from '@nx/devkit';
2
+ import { addLines } from "../add-lines.js";
3
+ import { appDirectory, projectNameOf } from "../app-directory.js";
4
+ import initGenerator from "../init/generator.js";
5
+ import { mergeGeneratorDefaults, unique, updateTargetDefault, } from "../init/nx-json.js";
6
+ import { nxPlugin } from "../nx-plugin.js";
7
+ import { rootDependencyNames, settleRootDependencies, } from "../root-dependencies.js";
8
+ import { appPackageVersions as versions } from "../versions.js";
9
+ import { workspaceScope } from "../workspace-scope.js";
10
+ import { appTestTs, appTs, clientManifest, clientTsconfig, dockerfile, dockerignore, envExample, envTs, eslintConfig, healthzRouteTs, loggingTs, sdkItConfig, serverTs, startupTs, } from "./files.js";
11
+ export const createRequireBanner = "import { createRequire as nodeCreateRequire } from 'node:module'; const require = nodeCreateRequire(import.meta.url);";
12
+ const tsSolutionTsconfigInput = {
13
+ json: '{workspaceRoot}/tsconfig.json',
14
+ fields: ['extends', 'files', 'include'],
15
+ };
16
+ /**
17
+ * A Hono backend on @hono/node-server: evlog, terminus, a zod env, one ESM
18
+ * esbuild bundle, a Dockerfile whose image reports its commit at /api/healthz,
19
+ * and a generated sdk-it client. It runs `init` first.
20
+ */
21
+ export default async function nodeAppGenerator(tree, options) {
22
+ const initTask = await initGenerator(tree);
23
+ const scope = workspaceScope(tree);
24
+ const { projectRoot, name, rootOffset } = appDirectory(options.directory);
25
+ const port = options.port ?? 3000;
26
+ const before = rootDependencyNames(tree);
27
+ const { applicationGenerator } = nxPlugin('@nx/node');
28
+ // @nx/node adds a VS Code launch configuration; the one that was there stays.
29
+ const launchJson = tree.read('.vscode/launch.json');
30
+ const appTask = await applicationGenerator(tree, {
31
+ directory: projectRoot,
32
+ framework: 'none',
33
+ bundler: 'esbuild',
34
+ linter: 'eslint',
35
+ unitTestRunner: 'none',
36
+ e2eTestRunner: 'none',
37
+ docker: false,
38
+ useProjectJson: false,
39
+ addPlugin: true,
40
+ port,
41
+ skipFormat: true,
42
+ });
43
+ if (launchJson === null) {
44
+ tree.delete('.vscode/launch.json');
45
+ }
46
+ else {
47
+ tree.write('.vscode/launch.json', launchJson);
48
+ }
49
+ const projectName = projectNameOf(tree, projectRoot);
50
+ tree.delete(`${projectRoot}/src/main.ts`);
51
+ tree.delete(`${projectRoot}/src/assets/.gitkeep`);
52
+ writeTsconfigs(tree, projectRoot, rootOffset);
53
+ writeProjectPackageJson(tree, {
54
+ projectRoot,
55
+ name,
56
+ projectName,
57
+ port,
58
+ scope,
59
+ });
60
+ tree.write(`${projectRoot}/eslint.config.mjs`, eslintConfig(projectRoot, rootOffset));
61
+ tree.write(`${projectRoot}/src/app.ts`, appTs);
62
+ tree.write(`${projectRoot}/src/app.test.ts`, appTestTs);
63
+ tree.write(`${projectRoot}/src/env.ts`, envTs(port));
64
+ tree.write(`${projectRoot}/src/logging.ts`, loggingTs(name));
65
+ tree.write(`${projectRoot}/src/routes/healthz.route.ts`, healthzRouteTs);
66
+ tree.write(`${projectRoot}/src/server.ts`, serverTs);
67
+ tree.write(`${projectRoot}/src/startup.ts`, startupTs);
68
+ // .env.example is the generator's; .env is the developer's copy.
69
+ tree.write(`${projectRoot}/.env.example`, envExample(port));
70
+ if (!tree.exists(`${projectRoot}/.env`)) {
71
+ tree.write(`${projectRoot}/.env`, envExample(port));
72
+ }
73
+ wireSdk(tree, { projectRoot, name, projectName, rootOffset, scope });
74
+ tree.write(`${projectRoot}/Dockerfile`, dockerfile({ projectRoot, projectName, port }));
75
+ if (!tree.exists('.dockerignore')) {
76
+ tree.write('.dockerignore', dockerignore);
77
+ }
78
+ mergeNodeNxJson(tree);
79
+ settleRootDependencies(tree, before, {
80
+ devDependencies: {
81
+ '@sdk-it/cli': versions['@sdk-it/cli'],
82
+ '@types/node': versions['@types/node'],
83
+ esbuild: versions.esbuild,
84
+ tslib: versions.tslib,
85
+ },
86
+ // @nx/js adds the swc toolchain, and nothing here runs it: esbuild
87
+ // bundles and typescript-eslint parses.
88
+ residue: ['@swc/cli', '@swc/core', '@swc/helpers'],
89
+ // esbuild's postinstall puts the native binary in place of its JS
90
+ // wrapper. @nx/node brings @parcel/watcher and fsevents through @nx/jest:
91
+ // the first builds from source only when asked, and the second ships
92
+ // prebuilt, so neither runs.
93
+ allowScripts: { esbuild: true, '@parcel/watcher': false, fsevents: false },
94
+ // sdk-it peers on typescript ^6.0.3, and the TypeScript 6 API alias of
95
+ // the root is 6.0.2, the last @typescript/typescript6. Each edge takes
96
+ // the root typescript.
97
+ overrides: {
98
+ '@sdk-it/cli': { typescript: '$typescript' },
99
+ '@sdk-it/hono': { typescript: '$typescript' },
100
+ },
101
+ });
102
+ await formatFiles(tree);
103
+ return runTasksInSerial(initTask, appTask, () => installPackagesTask(tree));
104
+ }
105
+ /**
106
+ * @nx/node writes the app tsconfigs with `module: nodenext` and dist as the
107
+ * outDir. The app keeps the workspace base (bundler resolution) and keeps dist
108
+ * free of type-check output: typecheck writes to out-tsc.
109
+ */
110
+ function writeTsconfigs(tree, projectRoot, rootOffset) {
111
+ const base = `${rootOffset}tsconfig.base.json`;
112
+ writeJson(tree, `${projectRoot}/tsconfig.json`, {
113
+ extends: base,
114
+ files: [],
115
+ include: [],
116
+ references: [
117
+ { path: './tsconfig.app.json' },
118
+ { path: './tsconfig.test.json' },
119
+ ],
120
+ });
121
+ writeJson(tree, `${projectRoot}/tsconfig.app.json`, {
122
+ extends: base,
123
+ compilerOptions: {
124
+ outDir: 'out-tsc',
125
+ rootDir: 'src',
126
+ tsBuildInfoFile: 'out-tsc/tsconfig.app.tsbuildinfo',
127
+ types: ['node'],
128
+ },
129
+ include: ['src/**/*.ts'],
130
+ exclude: ['src/**/*.test.ts'],
131
+ });
132
+ writeJson(tree, `${projectRoot}/tsconfig.test.json`, {
133
+ extends: base,
134
+ compilerOptions: {
135
+ outDir: 'out-tsc',
136
+ rootDir: 'src',
137
+ tsBuildInfoFile: 'out-tsc/tsconfig.test.tsbuildinfo',
138
+ types: ['node'],
139
+ },
140
+ include: ['src/**/*.test.ts'],
141
+ references: [{ path: './tsconfig.app.json' }],
142
+ });
143
+ }
144
+ /** The image tag of a project name, as @nx/node sanitizes it: `@acme/backend` gives `acme-backend`. */
145
+ export function imageTagFor(projectName) {
146
+ return projectName
147
+ .toLowerCase()
148
+ .replace(/[@/]/g, '-')
149
+ .replace(/[^a-z0-9._-]/g, '-')
150
+ .replace(/-+/g, '-')
151
+ .replace(/^-|-$/g, '');
152
+ }
153
+ /**
154
+ * The app manifest is its deploy manifest: `prune-lockfile` copies its
155
+ * dependencies into dist/package.json, and @nx/dependency-checks keeps them
156
+ * right, because the bundle leaves each npm package external.
157
+ */
158
+ function writeProjectPackageJson(tree, app) {
159
+ const imageTag = imageTagFor(app.projectName);
160
+ updateJson(tree, `${app.projectRoot}/package.json`, (packageJson) => {
161
+ const targets = { ...packageJson.nx?.targets };
162
+ // Workspace libraries are bundled, so nothing is copied at deploy time;
163
+ // prune-lockfile alone writes the runtime manifest and lockfile.
164
+ delete targets['copy-workspace-modules'];
165
+ delete targets['prune'];
166
+ packageJson.type = 'module';
167
+ packageJson.scripts = {};
168
+ packageJson.dependencies = {
169
+ ...packageJson.dependencies,
170
+ '@godaddy/terminus': versions['@godaddy/terminus'],
171
+ '@hono/node-server': versions['@hono/node-server'],
172
+ '@sdk-it/hono': versions['@sdk-it/hono'],
173
+ evlog: versions.evlog,
174
+ hono: versions.hono,
175
+ zod: versions.zod,
176
+ };
177
+ packageJson.nx = {
178
+ ...packageJson.nx,
179
+ // @nx/node writes no projectType into package.json. @zukhruf/eslint
180
+ // reads it: an application bundles, so its manifest declares the npm
181
+ // packages of each workspace package it imports, not the package.
182
+ projectType: 'application',
183
+ targets: {
184
+ ...targets,
185
+ build: buildTarget(app.projectRoot),
186
+ // @nx/js/tsx infers the command from the header of src/server.ts.
187
+ // @nx/node writes serve as continuous, and a project value wins
188
+ // over the discrete target default. The app turns on its
189
+ // development log drain only when NODE_ENV is development.
190
+ serve: {
191
+ dependsOn: ['^build'],
192
+ options: { env: { NODE_ENV: 'development' } },
193
+ },
194
+ portless: {
195
+ command: `portless --name ${app.name}.${app.scope} --app-port ${app.port} -- nx run ${app.projectName}:serve --output-style=stream-without-prefixes`,
196
+ },
197
+ 'docker:build': {
198
+ command: `docker build --file ${app.projectRoot}/Dockerfile --build-arg BUILD_SHA=$(git rev-parse HEAD) --tag ${imageTag} .`,
199
+ options: { cwd: '{workspaceRoot}' },
200
+ },
201
+ 'docker:run': {
202
+ command: `docker run --rm --publish ${app.port}:${app.port} ${imageTag}`,
203
+ },
204
+ },
205
+ };
206
+ return packageJson;
207
+ });
208
+ }
209
+ /**
210
+ * One ESM bundle in place of the CommonJS build of @nx/node. With `thirdParty`
211
+ * unset, @nx/esbuild leaves each npm package external, also one that a bundled
212
+ * workspace library imports, and inlines the workspace libraries.
213
+ * `declaration: false` stops the executor from taking `declaration` from the
214
+ * `composite` of the base tsconfig. The development configuration skips the
215
+ * type check; typecheck and the production build keep it. The banner gives
216
+ * the ESM bundle a `require` for an external CommonJS package.
217
+ */
218
+ function buildTarget(projectRoot) {
219
+ return {
220
+ executor: '@nx/esbuild:esbuild',
221
+ outputs: ['{options.outputPath}'],
222
+ defaultConfiguration: 'production',
223
+ options: {
224
+ platform: 'node',
225
+ target: 'esnext',
226
+ bundle: true,
227
+ format: ['esm'],
228
+ main: `${projectRoot}/src/server.ts`,
229
+ tsConfig: `${projectRoot}/tsconfig.app.json`,
230
+ outputPath: `${projectRoot}/dist`,
231
+ assets: [],
232
+ declaration: false,
233
+ sourcemap: true,
234
+ esbuildOptions: { banner: { js: createRequireBanner } },
235
+ },
236
+ configurations: {
237
+ development: { skipTypeCheck: true },
238
+ production: {},
239
+ },
240
+ };
241
+ }
242
+ function wireSdk(tree, options) {
243
+ const { projectRoot, name, projectName, rootOffset, scope } = options;
244
+ const packageName = `@${scope}/${name}-client`;
245
+ tree.write(`${projectRoot}/sdk-it.config.ts`, sdkItConfig(projectName, packageName));
246
+ const stubPath = `${projectRoot}/.sdk-it/package.json`;
247
+ if (!tree.exists(stubPath)) {
248
+ tree.write(stubPath, clientManifest(packageName, projectName));
249
+ }
250
+ const tsconfigPath = `${projectRoot}/.sdk-it/tsconfig.json`;
251
+ if (!tree.exists(tsconfigPath)) {
252
+ tree.write(tsconfigPath, clientTsconfig(rootOffset));
253
+ }
254
+ // A path, not a glob: npm matches workspace globs without `dot`, so
255
+ // `apps/*/.sdk-it` never links the package.
256
+ updateJson(tree, 'package.json', (packageJson) => {
257
+ packageJson.workspaces = unique([
258
+ ...(packageJson.workspaces ?? []),
259
+ `${projectRoot}/.sdk-it`,
260
+ ]);
261
+ return packageJson;
262
+ });
263
+ addLines(tree, '.gitignore', '**/.sdk-it/*\n!**/.sdk-it/package.json\n!**/.sdk-it/tsconfig.json\n');
264
+ addLines(tree, '.prettierignore', '.sdk-it\n');
265
+ }
266
+ /**
267
+ * The nx.json keys of a backend. An executor-keyed default wins over a
268
+ * name-keyed one (Nx takes the first key that matches and never merges two),
269
+ * so the esbuild entry keeps the Tailwind sync generator of the `build`
270
+ * default away from a backend build. `^sdk` builds a generated client before
271
+ * its consumers build, serve, typecheck or test; it does nothing for a
272
+ * project with no such dependency, and `...` keeps the `^build` that
273
+ * @zukhruf/nx/test infers for test.
274
+ */
275
+ function mergeNodeNxJson(tree) {
276
+ updateJson(tree, 'nx.json', (nxJson) => {
277
+ updateTargetDefault(nxJson, '@nx/esbuild:esbuild', (entry) => ({
278
+ ...entry,
279
+ cache: true,
280
+ dependsOn: unique([...(entry.dependsOn ?? []), '^build']),
281
+ inputs: unique([
282
+ ...(entry.inputs ?? []),
283
+ 'production',
284
+ '^production',
285
+ tsSolutionTsconfigInput,
286
+ ]),
287
+ }));
288
+ for (const [target, inferred] of [
289
+ ['build', []],
290
+ ['dev', []],
291
+ ['typecheck', []],
292
+ ['test', ['...']],
293
+ ]) {
294
+ updateTargetDefault(nxJson, target, (entry) => ({
295
+ ...entry,
296
+ dependsOn: unique([...inferred, ...(entry.dependsOn ?? []), '^sdk']),
297
+ }));
298
+ }
299
+ // sdk-it.config.ts imports the root CLI. Outside production, its closure
300
+ // stays out of the pruned runtime lockfile of the app.
301
+ nxJson.namedInputs ??= {};
302
+ nxJson.namedInputs['production'] = unique([
303
+ ...(nxJson.namedInputs['production'] ?? ['default']),
304
+ '!{projectRoot}/sdk-it.config.{js,ts,mjs,mts}',
305
+ ]);
306
+ nxJson.generators = mergeGeneratorDefaults(nxJson.generators, '@nx/node', {
307
+ application: {
308
+ framework: 'none',
309
+ bundler: 'esbuild',
310
+ linter: 'eslint',
311
+ unitTestRunner: 'none',
312
+ e2eTestRunner: 'none',
313
+ docker: false,
314
+ },
315
+ });
316
+ return nxJson;
317
+ });
318
+ }
319
+ //# sourceMappingURL=generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/generators/node-app/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,EACV,SAAS,GACV,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,aAAa,MAAM,sBAAsB,CAAC;AACjD,OAAO,EACL,sBAAsB,EACtB,MAAM,EACN,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EACL,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,kBAAkB,IAAI,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACL,SAAS,EACT,KAAK,EACL,cAAc,EACd,cAAc,EACd,UAAU,EACV,YAAY,EACZ,UAAU,EACV,KAAK,EACL,YAAY,EACZ,cAAc,EACd,SAAS,EACT,WAAW,EACX,QAAQ,EACR,SAAS,GACV,MAAM,YAAY,CAAC;AAmBpB,MAAM,CAAC,MAAM,mBAAmB,GAC9B,uHAAuH,CAAC;AAE1H,MAAM,uBAAuB,GAAG;IAC9B,IAAI,EAAE,+BAA+B;IACrC,MAAM,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,CAAC;CACxC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,gBAAgB,CAC5C,IAAU,E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MAAM;gBACrB,MAAM,EAAE,KAAK;aACd;SACF,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,16 @@
1
+ /** The entry points of the Nx plugins that the app generators call, by the package that holds each. */
2
+ interface NxPlugins {
3
+ '@nx/node': typeof import('@nx/node');
4
+ '@nx/react': typeof import('@nx/react');
5
+ '@nx/vitest/generators': typeof import('@nx/vitest/generators');
6
+ }
7
+ /**
8
+ * Loads an Nx plugin that an app generator calls, for example `@nx/node`. It
9
+ * takes the copy that resolves from this package, and else installs the plugin
10
+ * at `nxVersion` into a temporary folder, as an Nx generator does for its own
11
+ * plugins (`ensurePackage` of @nx/devkit). The plugin's own generator adds it
12
+ * to the root package.json.
13
+ */
14
+ export declare function nxPlugin<Entry extends keyof NxPlugins>(entry: Entry): NxPlugins[Entry];
15
+ export {};
16
+ //# sourceMappingURL=nx-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nx-plugin.d.ts","sourceRoot":"","sources":["../../src/generators/nx-plugin.ts"],"names":[],"mappings":"AAQA,uGAAuG;AACvG,UAAU,SAAS;IACjB,UAAU,EAAE,cAAc,UAAU,CAAC,CAAC;IACtC,WAAW,EAAE,cAAc,WAAW,CAAC,CAAC;IACxC,uBAAuB,EAAE,cAAc,uBAAuB,CAAC,CAAC;CACjE;AAQD;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,KAAK,SAAS,MAAM,SAAS,EACpD,KAAK,EAAE,KAAK,GACX,SAAS,CAAC,KAAK,CAAC,CASlB"}
@@ -0,0 +1,27 @@
1
+ import { createRequire } from 'node:module';
2
+ import { ensurePackage } from '@nx/devkit';
3
+ import { nxVersion } from "./versions.js";
4
+ const require = createRequire(import.meta.url);
5
+ function isModuleNotFound(error) {
6
+ return (Error.isError(error) && 'code' in error && error.code === 'MODULE_NOT_FOUND');
7
+ }
8
+ /**
9
+ * Loads an Nx plugin that an app generator calls, for example `@nx/node`. It
10
+ * takes the copy that resolves from this package, and else installs the plugin
11
+ * at `nxVersion` into a temporary folder, as an Nx generator does for its own
12
+ * plugins (`ensurePackage` of @nx/devkit). The plugin's own generator adds it
13
+ * to the root package.json.
14
+ */
15
+ export function nxPlugin(entry) {
16
+ try {
17
+ return require(entry);
18
+ }
19
+ catch (error) {
20
+ if (!isModuleNotFound(error))
21
+ throw error;
22
+ }
23
+ // ensurePackage adds the temporary folder to the paths that require reads.
24
+ ensurePackage(entry.split('/').slice(0, 2).join('/'), nxVersion);
25
+ return require(entry);
26
+ }
27
+ //# sourceMappingURL=nx-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nx-plugin.js","sourceRoot":"","sources":["../../src/generators/nx-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAS/C,SAAS,gBAAgB,CAAC,KAAc;IACtC,OAAO,CACL,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,kBAAkB,CAC7E,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CACtB,KAAY;IAEZ,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC;IAC5C,CAAC;IACD,2EAA2E;IAC3E,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC;IACjE,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare function apiTs(clientName: string): string;
2
+ /** `webDist` is the web build relative to the api build, for example `../../web/dist`. */
3
+ export declare function uiRouteTs(webDist: string): string;
4
+ //# sourceMappingURL=files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../src/generators/pair/files.ts"],"names":[],"mappings":"AAGA,wBAAgB,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAWhD;AAED,0FAA0F;AAC1F,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAwDjD"}
@@ -0,0 +1,73 @@
1
+ // The content of each file that pair writes. Each is a string in a .ts
2
+ // module, so tsc puts it in dist with no copy step (ADR 0009).
3
+ export function apiTs(clientName) {
4
+ return `import { Client } from '${clientName}';
5
+
6
+ // Same-origin in production (the API serves this SPA) and proxied by the vite
7
+ // dev server in development, so the page origin is always right. The client
8
+ // needs an absolute URL (its interceptor calls \`new URL(baseUrl)\`), and the
9
+ // API mounts its routes under /api, which the sdk-it analyzer cannot see.
10
+ export const api = new Client({
11
+ baseUrl: new URL('/api', globalThis.location.origin).toString(),
12
+ });
13
+ `;
14
+ }
15
+ /** `webDist` is the web build relative to the api build, for example `../../web/dist`. */
16
+ export function uiRouteTs(webDist) {
17
+ return `import { readFile } from 'node:fs/promises';
18
+ import { join, relative } from 'node:path';
19
+
20
+ import { serveStatic } from '@hono/node-server/serve-static';
21
+ import type { Hono } from 'hono';
22
+ import { compress } from 'hono/compress';
23
+ import { etag } from 'hono/etag';
24
+
25
+ // Same-origin SPA shell: hashed assets are immutable (served precompressed
26
+ // when the web build emitted .br/.gz), and every other GET returns index.html
27
+ // so the client router owns the URL. A GET under /api/ goes on to the API
28
+ // routes and their notFound.
29
+ export default function (router: Hono): void {
30
+ // The path starts from the folder of the server bundle, because Nx and the
31
+ // runtime image keep both app outputs under the workspace root.
32
+ const webDist = join(
33
+ relative(process.cwd(), import.meta.dirname),
34
+ '${webDist}',
35
+ );
36
+ const indexHtml = join(webDist, 'index.html');
37
+ router.use(
38
+ '/assets/*',
39
+ serveStatic({
40
+ root: webDist,
41
+ precompressed: true,
42
+ onFound: (_path, c) => {
43
+ c.header('Cache-Control', 'public, max-age=31536000, immutable');
44
+ },
45
+ }),
46
+ );
47
+ router.get('*', compress(), etag(), async (c, next) => {
48
+ if (c.req.path.startsWith('/api/')) {
49
+ await next();
50
+ return;
51
+ }
52
+ const html = await readFile(indexHtml, 'utf-8').catch(() => undefined);
53
+ if (html === undefined) {
54
+ return c.json(
55
+ {
56
+ error: 'Not Found',
57
+ cause: {
58
+ code: 'ui/build-missing',
59
+ detail:
60
+ process.env.NODE_ENV === 'development'
61
+ ? \`Build the web app first (expected \${indexHtml})\`
62
+ : 'The web build is not available',
63
+ },
64
+ },
65
+ 404,
66
+ );
67
+ }
68
+ return c.html(html);
69
+ });
70
+ }
71
+ `;
72
+ }
73
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.js","sourceRoot":"","sources":["../../../src/generators/pair/files.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,+DAA+D;AAE/D,MAAM,UAAU,KAAK,CAAC,UAAkB;IACtC,OAAO,2BAA2B,UAAU;;;;;;;;;CAS7C,CAAC;AACF,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,SAAS,CAAC,OAAe;IACvC,OAAO;;;;;;;;;;;;;;;;;OAiBF,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCb,CAAC;AACF,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export interface PairOptions {
3
+ /** The project root of a node-app, for example `apps/backend`. */
4
+ api: string;
5
+ /** The project root of a react-app, for example `apps/web`. */
6
+ web: string;
7
+ }
8
+ /** PORT is the generator's line in .env.example, so it is the one line worth reading. */
9
+ export declare function portOf(tree: Tree, apiRoot: string): number;
10
+ /**
11
+ * Pairs a react-app with a node-app: the web gets the generated client, and
12
+ * the api serves the web build and puts it in its image. The app generators
13
+ * never name each other, so pairing is one explicit step that is safe to run
14
+ * again. The web depends on the api only through the client library: an
15
+ * app-to-app edge would make dependency-checks ask the web for the runtime
16
+ * dependencies of the api, and fail @nx/enforce-module-boundaries.
17
+ */
18
+ export default function pairGenerator(tree: Tree, options: PairOptions): Promise<void>;
19
+ //# sourceMappingURL=generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generators/pair/generator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,IAAI,EAAqC,MAAM,YAAY,CAAC;AAO1E,MAAM,WAAW,WAAW;IAC1B,kEAAkE;IAClE,GAAG,EAAE,MAAM,CAAC;IACZ,+DAA+D;IAC/D,GAAG,EAAE,MAAM,CAAC;CACb;AAED,yFAAyF;AACzF,wBAAgB,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAI1D;AA8BD;;;;;;;GAOG;AACH,wBAA8B,aAAa,CACzC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC,CAgDf"}
@@ -0,0 +1,70 @@
1
+ import { posix } from 'node:path';
2
+ import { formatFiles, readJson, updateJson } from '@nx/devkit';
3
+ import { appDirectory, projectNameOf } from "../app-directory.js";
4
+ import { dockerfile } from "../node-app/files.js";
5
+ import { appPackageVersions as versions } from "../versions.js";
6
+ import { apiTs, uiRouteTs } from "./files.js";
7
+ /** PORT is the generator's line in .env.example, so it is the one line worth reading. */
8
+ export function portOf(tree, apiRoot) {
9
+ const example = tree.read(`${apiRoot}/.env.example`, 'utf-8') ?? '';
10
+ const match = /^PORT=(\d+)$/m.exec(example);
11
+ return match ? Number(match[1]) : 3000;
12
+ }
13
+ function mountUi(tree, apiRoot, webRoot) {
14
+ const appPath = `${apiRoot}/src/app.ts`;
15
+ const app = tree.read(appPath, 'utf-8');
16
+ if (app === null) {
17
+ throw new Error(`${appPath} does not exist.`);
18
+ }
19
+ const mount = `(await import('./routes/ui.route.ts')).default(app);`;
20
+ if (!app.includes(mount)) {
21
+ const marker = '\napp.notFound((c) =>';
22
+ if (!app.includes(marker)) {
23
+ throw new Error(`${appPath} has no app.notFound registration.`);
24
+ }
25
+ tree.write(appPath, app.replace(marker, `\n// pair fixed the path of the web build; development enters through the Vite proxy.\n${mount}\n${marker}`));
26
+ }
27
+ tree.write(`${apiRoot}/src/routes/ui.route.ts`, uiRouteTs(posix.relative(posix.join(apiRoot, 'dist'), posix.join(webRoot, 'dist'))));
28
+ }
29
+ /**
30
+ * Pairs a react-app with a node-app: the web gets the generated client, and
31
+ * the api serves the web build and puts it in its image. The app generators
32
+ * never name each other, so pairing is one explicit step that is safe to run
33
+ * again. The web depends on the api only through the client library: an
34
+ * app-to-app edge would make dependency-checks ask the web for the runtime
35
+ * dependencies of the api, and fail @nx/enforce-module-boundaries.
36
+ */
37
+ export default async function pairGenerator(tree, options) {
38
+ const apiRoot = appDirectory(options.api).projectRoot;
39
+ const webRoot = appDirectory(options.web).projectRoot;
40
+ if (!tree.exists(`${apiRoot}/sdk-it.config.ts`)) {
41
+ throw new Error(`${apiRoot} has no sdk-it.config.ts, so it is not a node-app. Run @zukhruf/nx:node-app ${apiRoot} first.`);
42
+ }
43
+ if (!tree.exists(`${webRoot}/vite.config.ts`)) {
44
+ throw new Error(`${webRoot} has no vite.config.ts, so it is not a react-app. Run @zukhruf/nx:react-app ${webRoot} first.`);
45
+ }
46
+ const apiName = projectNameOf(tree, apiRoot);
47
+ const webName = projectNameOf(tree, webRoot);
48
+ const client = readJson(tree, `${apiRoot}/.sdk-it/package.json`);
49
+ updateJson(tree, `${webRoot}/package.json`, (packageJson) => {
50
+ // The web bundles the client, so the runtime dependencies of the client
51
+ // are in the manifest of the web (dependency-checks of a bundled app).
52
+ packageJson.dependencies = {
53
+ ...packageJson.dependencies,
54
+ [client.name]: '*',
55
+ 'fast-content-type-parse': versions['fast-content-type-parse'],
56
+ zod: versions.zod,
57
+ };
58
+ return packageJson;
59
+ });
60
+ tree.write(`${webRoot}/src/api.ts`, apiTs(client.name));
61
+ mountUi(tree, apiRoot, webRoot);
62
+ tree.write(`${apiRoot}/Dockerfile`, dockerfile({
63
+ projectRoot: apiRoot,
64
+ projectName: apiName,
65
+ port: portOf(tree, apiRoot),
66
+ spa: { projectName: webName, projectRoot: webRoot },
67
+ }));
68
+ await formatFiles(tree);
69
+ }
70
+ //# sourceMappingURL=generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/generators/pair/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,OAAO,EAAa,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE1E,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,kBAAkB,IAAI,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAS9C,yFAAyF;AACzF,MAAM,UAAU,MAAM,CAAC,IAAU,EAAE,OAAe;IAChD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,OAAO,eAAe,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;IACpE,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5C,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,C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,CAAC;QAC3B,GAAG,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE;KACpD,CAAC,CACH,CAAC;IAEF,MAAM,WAAW,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,20 @@
1
+ export declare const schemaPrisma = "// The models go in models/*.prisma. The generate target writes the client into\n// src/prisma, which is not committed.\ngenerator client {\n provider = \"prisma-client\"\n output = \"src/prisma\"\n importFileExtension = \"ts\"\n}\n\ndatasource db {\n provider = \"postgresql\"\n}\n";
2
+ export declare const prismaConfigTs = "import { defineConfig, env } from 'prisma/config';\n\n// Nx loads the .env of this project into each task, and the migration image\n// gets CONNECTION_STRING from its environment. A URL is read only when it is\n// set, so `prisma generate` runs with none.\nexport default defineConfig({\n schema: '.',\n migrations: { path: 'migrations' },\n datasource: {\n url: process.env.CONNECTION_STRING ? env('CONNECTION_STRING') : undefined,\n shadowDatabaseUrl: process.env.SHADOW_CONNECTION_STRING\n ? env('SHADOW_CONNECTION_STRING')\n : undefined,\n },\n});\n";
3
+ export declare const migrationLockToml = "# Please do not edit this file manually\n# It should be added in your version-control system (i.e. Git)\nprovider = \"postgresql\"\n";
4
+ export declare const indexTs = "import { PrismaPg } from '@prisma/adapter-pg';\n\nimport { PrismaClient } from './prisma/client.ts';\n\n/**\n * A client on the Postgres adapter. It reads no environment and opens no pool\n * at import, so each caller passes its own connection string: the backend its\n * CONNECTION_STRING, and a test the database of @zukhruf/testing/postgres.\n */\nexport function createPrisma(options: {\n connectionString: string;\n}): PrismaClient {\n return new PrismaClient({ adapter: new PrismaPg(options) });\n}\n\nexport * from './prisma/client.ts';\n";
5
+ export declare const testingTs = "import { readFile, readdir } from 'node:fs/promises';\nimport { join, resolve } from 'node:path';\n\nimport pg from 'pg';\n\n// src/ (development) and dist/ (default) each sit one level below the package\n// root that holds migrations/.\nconst migrationsDir = resolve(import.meta.dirname, '..', 'migrations');\n\n/**\n * Builds the schema of the committed migrations in an empty database: it runs\n * each migrations/<name>/migration.sql in order. It keeps no\n * _prisma_migrations record, because a test database is thrown away and never\n * migrated again. The deploy target applies migrations everywhere else.\n */\nexport async function applySchema(connectionString: string): Promise<void> {\n const migrations = (await readdir(migrationsDir, { withFileTypes: true }))\n .filter((entry) => entry.isDirectory())\n .map((entry) => entry.name)\n .toSorted();\n const client = new pg.Client({ connectionString });\n await client.connect();\n try {\n for (const migration of migrations) {\n await client.query(\n await readFile(join(migrationsDir, migration, 'migration.sql'), 'utf8'),\n );\n }\n } finally {\n await client.end();\n }\n}\n";
6
+ /** The test of the db package, or of a backend that imports it. */
7
+ export declare function databaseTestTs(imports: {
8
+ client: string;
9
+ testing: string;
10
+ }): string;
11
+ export declare function eslintConfig(projectRoot: string, rootOffset: string): string;
12
+ export declare const envExample = "# Copy to `.env` (gitignored). Nx loads it into each task of this project, so\n# `nx run <project>:migrate` and `deploy` need no dotenv.\nCONNECTION_STRING=\n# Optional: the shadow database of `prisma migrate dev`.\nSHADOW_CONNECTION_STRING=\n";
13
+ export interface MigrationDockerfileOptions {
14
+ projectRoot: string;
15
+ packageName: string;
16
+ }
17
+ export declare function migrationDockerfile(options: MigrationDockerfileOptions): string;
18
+ /** The lines that a backend's startup.ts gets: the client, connected before the app serves. */
19
+ export declare function startupClientTs(packageName: string): string;
20
+ //# sourceMappingURL=files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../src/generators/prisma/files.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,2TAWxB,CAAC;AAEF,eAAO,MAAM,cAAc,kkBAe1B,CAAC;AAEF,eAAO,MAAM,iBAAiB,yIAG7B,CAAC;AAEF,eAAO,MAAM,OAAO,wiBAgBnB,CAAC;AAEF,eAAO,MAAM,SAAS,iqCAgCrB,CAAC;AAEF,mEAAmE;AACnE,wBAAgB,cAAc,CAAC,OAAO,EAAE;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,MAAM,CAsBT;AAED,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAyB5E;AAED,eAAO,MAAM,UAAU,wPAKtB,CAAC;AAEF,MAAM,WAAW,0BAA0B;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,0BAA0B,GAClC,MAAM,CA4BR;AAED,+FAA+F;AAC/F,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAW3D"}