@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
@@ -0,0 +1,278 @@
1
+ // The content of each root file that a generator writes (README, monorepo
2
+ // standard). Each is a string in a .ts module, so tsc puts it in dist with no
3
+ // copy step (ADR 0009).
4
+ export const gitignore = `# Dependencies and Nx state
5
+ node_modules/
6
+ .nx/
7
+
8
+ # Build and test output
9
+ dist/
10
+ out-tsc/
11
+ coverage/
12
+ test-results.xml
13
+ *.tsbuildinfo
14
+ vite.config.*.timestamp*
15
+ vitest.config.*.timestamp*
16
+
17
+ # Generated sdk-it clients: only the committed stubs stay
18
+ **/.sdk-it/*
19
+ !**/.sdk-it/package.json
20
+ !**/.sdk-it/tsconfig.json
21
+
22
+ # Local configuration
23
+ .env*
24
+ !.env.example
25
+
26
+ # Editors and operating systems
27
+ .DS_Store
28
+ .idea/
29
+ .vscode/*
30
+ !.vscode/extensions.json
31
+ !.vscode/settings.json
32
+ `;
33
+ export const prettierignore = `node_modules
34
+ .nx
35
+ coverage
36
+ dist
37
+ out-tsc
38
+ package-lock.json
39
+ *.tsbuildinfo
40
+ .sdk-it
41
+ `;
42
+ export const npmrc = `legacy-peer-deps=false
43
+ save-exact=true
44
+ strict-allow-scripts=true
45
+ `;
46
+ export const nvmrc = 'lts/*\n';
47
+ export const gitattributes = '* text=auto eol=lf\n';
48
+ export const editorconfig = `root = true
49
+
50
+ [*]
51
+ charset = utf-8
52
+ end_of_line = lf
53
+ insert_final_newline = true
54
+ indent_style = space
55
+ indent_size = 2
56
+ trim_trailing_whitespace = true
57
+
58
+ [*.md]
59
+ trim_trailing_whitespace = false
60
+ `;
61
+ export const tsconfigBase = {
62
+ compilerOptions: {
63
+ allowImportingTsExtensions: true,
64
+ composite: true,
65
+ declaration: true,
66
+ declarationMap: true,
67
+ emitDeclarationOnly: true,
68
+ erasableSyntaxOnly: true,
69
+ forceConsistentCasingInFileNames: true,
70
+ importHelpers: true,
71
+ isolatedModules: true,
72
+ lib: ['ESNext'],
73
+ module: 'ESNext',
74
+ moduleResolution: 'Bundler',
75
+ noEmitOnError: true,
76
+ noFallthroughCasesInSwitch: true,
77
+ noImplicitOverride: true,
78
+ noImplicitReturns: true,
79
+ noUncheckedIndexedAccess: true,
80
+ skipLibCheck: true,
81
+ strict: true,
82
+ target: 'ESNext',
83
+ useUnknownInCatchVariables: true,
84
+ verbatimModuleSyntax: true,
85
+ },
86
+ };
87
+ export const tsconfigSolution = {
88
+ extends: './tsconfig.base.json',
89
+ compileOnSave: false,
90
+ files: [],
91
+ references: [],
92
+ };
93
+ export function prettierrc(scope) {
94
+ return {
95
+ singleQuote: true,
96
+ // The first two entries keep the boot imports of a backend (./env,
97
+ // ./startup) before all others.
98
+ importOrder: [
99
+ '^\\./env(\\.ts)?$',
100
+ '^\\./startup(\\.ts)?$',
101
+ '^node:(.*)$',
102
+ '<THIRD_PARTY_MODULES>',
103
+ `^@${scope}/(.*)$`,
104
+ '^[./]',
105
+ ],
106
+ plugins: ['@trivago/prettier-plugin-sort-imports'],
107
+ importOrderSeparation: true,
108
+ importOrderSortSpecifiers: true,
109
+ overrides: [
110
+ {
111
+ files: ['*.css', '*.scss', '*.less'],
112
+ options: { singleQuote: false },
113
+ },
114
+ ],
115
+ };
116
+ }
117
+ export const eslintConfig = `import nx from '@nx/eslint-plugin';
118
+ import zukhruf from '@zukhruf/eslint';
119
+ import modernNode from '@zukhruf/eslint/modern-node';
120
+ import { manifest } from '@zukhruf/eslint/nx';
121
+ import { defineConfig } from 'eslint/config';
122
+
123
+ // Modern Node is for code that runs on Node. A browser bundle stays out. Each
124
+ // project has its own eslint.config.mjs that spreads the default export, so a
125
+ // Node project spreads this block too.
126
+ export const modernNodeRecommended = defineConfig({
127
+ plugins: { 'modern-node': modernNode },
128
+ extends: ['modern-node/recommended'],
129
+ });
130
+
131
+ export default [
132
+ ...nx.configs['flat/base'],
133
+ ...nx.configs['flat/typescript'],
134
+ ...nx.configs['flat/javascript'],
135
+ {
136
+ // Flat config never reads .gitignore, so build output is listed here.
137
+ ignores: [
138
+ '**/.nx',
139
+ '**/coverage',
140
+ '**/dist',
141
+ '**/node_modules',
142
+ '**/out-tsc',
143
+ '**/*.tsbuildinfo',
144
+ '**/vite.config.*.timestamp*',
145
+ '**/vitest.config.*.timestamp*',
146
+ '**/.sdk-it',
147
+ ],
148
+ },
149
+ {
150
+ files: ['**/*.{js,jsx,ts,tsx}'],
151
+ rules: {
152
+ '@nx/enforce-module-boundaries': [
153
+ 'error',
154
+ {
155
+ enforceBuildableLibDependency: true,
156
+ depConstraints: [{ sourceTag: '*', onlyDependOnLibsWithTags: ['*'] }],
157
+ },
158
+ ],
159
+ },
160
+ },
161
+ ...zukhruf.configs['base'],
162
+ ...zukhruf.configs['tests'],
163
+ ...zukhruf.configs['diagnostics'],
164
+ ...zukhruf.configs['env'],
165
+ ...zukhruf.configs['nx-project-json'],
166
+ ...manifest.configs.recommended,
167
+ // The files that this config lints itself, and the config files of each
168
+ // project: all of them run on Node.
169
+ ...defineConfig({
170
+ files: ['*.config.{ts,mjs}', '.husky/*.ts', 'tools/*.mjs'],
171
+ extends: [modernNodeRecommended],
172
+ }),
173
+ // Files that no tsconfig includes get the default project of typed lint,
174
+ // not a parse error. typescript-eslint refuses '**' here.
175
+ {
176
+ files: ['**/*.ts'],
177
+ languageOptions: {
178
+ parserOptions: {
179
+ projectService: {
180
+ allowDefaultProject: ['*.config.ts', '.husky/*.ts'],
181
+ },
182
+ },
183
+ },
184
+ },
185
+ ];
186
+ `;
187
+ /** The Git hooks, each in TypeScript. `.husky/<name>` is a link to `.husky/<name>.ts`. */
188
+ export const hooks = {
189
+ '.husky/pre-commit.ts': `#!/usr/bin/env node
190
+ // .husky/pre-commit is a link to this file. Each step reads the staged commit
191
+ // and stages only what it wrote: Sync stages the files that nx sync updates,
192
+ // and Format refuses a staged file that is not formatted. The other steps
193
+ // refuse a Node or npm version written as a number, an .npmrc without the
194
+ // install policy, a package-lock.json that does not record each staged
195
+ // package.json, a Dockerfile that installs without the lockfile, and a
196
+ // package.json that breaks the lint.
197
+ import {
198
+ DependencyChecks,
199
+ DockerfileInstallsFromLockfile,
200
+ Format,
201
+ LockfileSync,
202
+ NoNumericPins,
203
+ NpmrcPolicy,
204
+ Sync,
205
+ preCommit,
206
+ } from '@zukhruf/git-hooks';
207
+
208
+ await preCommit([
209
+ new Sync({ stage: ['**/tsconfig*.json', '**/styles.css'] }),
210
+ new Format(),
211
+ new NoNumericPins(),
212
+ new NpmrcPolicy(),
213
+ new LockfileSync(),
214
+ new DockerfileInstallsFromLockfile(),
215
+ new DependencyChecks(),
216
+ ]);
217
+ `,
218
+ '.husky/pre-push.ts': `#!/usr/bin/env node
219
+ // .husky/pre-push is a link to this file. Build builds each pushed commit in
220
+ // its own snapshot, never the working tree. NODE_ENV is set because Vite sets
221
+ // production only when NODE_ENV is not set.
222
+ import { Build, prePush } from '@zukhruf/git-hooks';
223
+
224
+ await prePush([new Build({ env: { NODE_ENV: 'production' } })]);
225
+ `,
226
+ '.husky/commit-msg.ts': `#!/usr/bin/env node
227
+ // .husky/commit-msg is a link to this file.
228
+ import { NxReleaseScope, commitMsg } from '@zukhruf/git-hooks';
229
+
230
+ await commitMsg([new NxReleaseScope()]);
231
+ `,
232
+ };
233
+ export const vscodeSettings = {
234
+ 'explorer.fileNesting.enabled': true,
235
+ 'explorer.fileNesting.expand': false,
236
+ 'explorer.fileNesting.patterns': {
237
+ 'tsconfig.base.json': '*.json',
238
+ 'tsconfig.json': '*.json, .gitignore',
239
+ },
240
+ 'files.watcherExclude': {
241
+ '**/node_modules/**': true,
242
+ '**/.nx/**': true,
243
+ '**/tmp/**': true,
244
+ '**/.git/objects/**': true,
245
+ '**/.git/subtree-cache/**': true,
246
+ },
247
+ 'search.exclude': {
248
+ '**/node_modules': true,
249
+ '**/.nx': true,
250
+ '**/tmp': true,
251
+ },
252
+ };
253
+ export const vscodeExtensions = {
254
+ recommendations: [
255
+ 'nrwl.angular-console',
256
+ 'esbenp.prettier-vscode',
257
+ 'dbaeumer.vscode-eslint',
258
+ ],
259
+ };
260
+ export const agents = `# Agents
261
+
262
+ Nx monorepo on npm workspaces. Runnable products are in \`apps/\`, shared modules in \`packages/\`, and repo tools in \`tools/\`.
263
+
264
+ ## Commands
265
+
266
+ - Run each command through an Nx target, from the workspace root: \`npx nx run <project>:<target>\`.
267
+ - \`npx nx run <project>:typecheck\` runs \`lint\`, \`format:check\`, then \`tsc\`. Never run raw \`tsc\`.
268
+ - \`npx nx run <project>:test\` builds the dependencies first.
269
+ - A check changes no file. \`npx nx run <project>:format\` writes the files.
270
+ - Read \`npx nx show project <project> --json\` before you say that a target exists. Most targets are inferred, so no file lists them.
271
+ - In zsh, quote a task name in a variable (\`"\${p}:lint"\`): \`:l\` and \`:t\` are modifiers.
272
+ - When Nx stops with an error that you do not expect, run it again with the output in a file: \`NX_DAEMON=false npx nx … > log 2>&1; echo $?\`.
273
+ `;
274
+ export const claude = '@AGENTS.md\n';
275
+ export function readme(name) {
276
+ return `# ${name}\n\nThe commands are in [AGENTS.md](./AGENTS.md).\n`;
277
+ }
278
+ //# sourceMappingURL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vB,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,IAAI;KACf;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,eAAe,EAAE;QACf,sBAAsB;QACtB,wBAAwB;QACxB,wBAAwB;KACzB;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG;;;;;;;;;;;;;CAarB,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,cAAc,CAAC;AAErC,MAAM,UAAU,MAAM,CAAC,IAAY;IACjC,OAAO,KAAK,IAAI,qDAAqD,CAAC;AACxE,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { type GeneratorCallback, type Tree } from '@nx/devkit';
2
+ /**
3
+ * Adds the root files of the monorepo standard to an Nx workspace. It creates
4
+ * a missing file, adds missing lines and merges keys, and never deletes. A
5
+ * second run changes nothing. `nx add @zukhruf/nx` runs it.
6
+ */
7
+ export default function initGenerator(tree: Tree): Promise<GeneratorCallback>;
8
+ //# sourceMappingURL=generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generators/init/generator.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,IAAI,EAKV,MAAM,YAAY,CAAC;AAmCpB;;;;GAIG;AACH,wBAA8B,aAAa,CACzC,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,iBAAiB,CAAC,CAiC5B"}
@@ -0,0 +1,72 @@
1
+ import { symlink } from 'node:fs/promises';
2
+ import { basename, join } from 'node:path';
3
+ import { formatFiles, installPackagesTask, runTasksInSerial, writeJson, } from '@nx/devkit';
4
+ import { addLines } from "../add-lines.js";
5
+ import { workspaceScope } from "../workspace-scope.js";
6
+ import { agents, claude, editorconfig, eslintConfig, gitattributes, gitignore, hooks, npmrc, nvmrc, prettierignore, prettierrc, tsconfigBase, tsconfigSolution, vscodeExtensions, vscodeSettings, } from "./files.js";
7
+ import { mergeNxJson } from "./nx-json.js";
8
+ import { mergeRootPackageJson } from "./root-package-json.js";
9
+ /** Writes a file only when it is missing. Returns whether it wrote. */
10
+ function create(tree, path, content) {
11
+ if (tree.exists(path))
12
+ return false;
13
+ if (typeof content === 'string') {
14
+ tree.write(path, content);
15
+ }
16
+ else {
17
+ writeJson(tree, path, content);
18
+ }
19
+ return true;
20
+ }
21
+ /**
22
+ * Adds the root files of the monorepo standard to an Nx workspace. It creates
23
+ * a missing file, adds missing lines and merges keys, and never deletes. A
24
+ * second run changes nothing. `nx add @zukhruf/nx` runs it.
25
+ */
26
+ export default async function initGenerator(tree) {
27
+ const scope = workspaceScope(tree);
28
+ mergeRootPackageJson(tree);
29
+ mergeNxJson(tree);
30
+ create(tree, 'tsconfig.base.json', tsconfigBase);
31
+ create(tree, 'tsconfig.json', tsconfigSolution);
32
+ addLines(tree, '.npmrc', npmrc);
33
+ create(tree, '.nvmrc', nvmrc);
34
+ create(tree, '.gitattributes', gitattributes);
35
+ create(tree, '.editorconfig', editorconfig);
36
+ addLines(tree, '.gitignore', gitignore);
37
+ create(tree, '.prettierrc', prettierrc(scope));
38
+ addLines(tree, '.prettierignore', prettierignore);
39
+ create(tree, 'eslint.config.mjs', eslintConfig);
40
+ const newHooks = Object.entries(hooks)
41
+ .filter(([path, content]) => create(tree, path, content))
42
+ .map(([path]) => path);
43
+ create(tree, '.vscode/settings.json', vscodeSettings);
44
+ create(tree, '.vscode/extensions.json', vscodeExtensions);
45
+ create(tree, 'AGENTS.md', agents);
46
+ create(tree, 'CLAUDE.md', claude);
47
+ await formatFiles(tree);
48
+ // formatFiles writes each file again with no mode, so the mode comes after it.
49
+ for (const path of newHooks) {
50
+ tree.changePermissions(path, '755');
51
+ }
52
+ return runTasksInSerial(() => installPackagesTask(tree), () => linkHooks(tree.root));
53
+ }
54
+ /**
55
+ * Git runs `.husky/pre-commit`, so it is a link to `pre-commit.ts`. The Tree
56
+ * has no links, so this writes each missing link after Nx writes the files.
57
+ */
58
+ async function linkHooks(root) {
59
+ for (const path of Object.keys(hooks)) {
60
+ try {
61
+ await symlink(basename(path), join(root, path.replace(/\.ts$/, '')));
62
+ }
63
+ catch (error) {
64
+ if (!(Error.isError(error) &&
65
+ 'code' in error &&
66
+ error.code === 'EEXIST')) {
67
+ throw error;
68
+ }
69
+ }
70
+ }
71
+ }
72
+ //# sourceMappingURL=generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/generators/init/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAGL,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,SAAS,GACV,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACL,MAAM,EACN,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,SAAS,EACT,KAAK,EACL,KAAK,EACL,KAAK,EACL,cAAc,EACd,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,uEAAuE;AACvE,SAAS,MAAM,CAAC,IAAU,EAAE,IAAY,EAAE,OAAwB;IAChE,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IACpC,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC5B,CAAC;SAAM,CAAC;QACN,SAAS,CAAC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uBAAuB,EAAE,cAAc,CAAC,CAAC;IACtD,MAAM,CAAC,IAAI,EAAE,yBAAyB,EAAE,gBAAgB,CAAC,CAAC;IAC1D,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IAClC,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IAElC,MAAM,WAAW,CAAC,IAAI,CAAC,CAAC;IACxB,+EAA+E;IAC/E,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC5B,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACtC,CAAC;IAED,OAAO,gBAAgB,CACrB,GAAG,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAC/B,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAC3B,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,KAAK,UAAU,SAAS,CAAC,IAAY;IACnC,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACtC,IAAI,CAAC;YACH,MAAM,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;QACvE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,CACH,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;gBACpB,MAAM,IAAI,KAAK;gBACf,KAAK,CAAC,IAAI,KAAK,QAAQ,CACxB,EAAE,CAAC;gBACF,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { type NxJsonConfiguration, type PluginConfiguration, type TargetConfiguration, type Tree } from '@nx/devkit';
2
+ export declare const pluginName: (entry: PluginConfiguration) => string;
3
+ export declare const unique: <T>(values: T[]) => T[];
4
+ type GeneratorDefaults = NonNullable<NxJsonConfiguration['generators']>;
5
+ /**
6
+ * Adds the defaults of one collection's generators, for example `@nx/node`,
7
+ * option by option. An option that is there stays, also one that the plugin
8
+ * wrote itself a moment before.
9
+ */
10
+ export declare function mergeGeneratorDefaults(generators: GeneratorDefaults | undefined, collection: string, defaults: Record<string, Record<string, unknown>>): GeneratorDefaults;
11
+ export type TargetDefault = Partial<TargetConfiguration>;
12
+ /** Changes each entry of a target default: Nx 24 takes one entry or a list of entries. */
13
+ export declare function updateTargetDefault(nxJson: NxJsonConfiguration, target: string, update: (entry: TargetDefault) => TargetDefault): void;
14
+ /**
15
+ * Merges the keys that the monorepo standard owns into nx.json and keeps the
16
+ * other keys. A list gets the entries that it does not have.
17
+ */
18
+ export declare function mergeNxJson(tree: Tree): void;
19
+ export {};
20
+ //# sourceMappingURL=nx-json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nx-json.d.ts","sourceRoot":"","sources":["../../../src/generators/init/nx-json.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,IAAI,EAEV,MAAM,YAAY,CAAC;AA+CpB,eAAO,MAAM,UAAU,GAAI,OAAO,mBAAmB,WACH,CAAC;AAEnD,eAAO,MAAM,MAAM,GAAI,CAAC,EAAE,QAAQ,CAAC,EAAE,QAQpC,CAAC;AAEF,KAAK,iBAAiB,GAAG,WAAW,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC,CAAC;AAExE;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,iBAAiB,GAAG,SAAS,EACzC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAChD,iBAAiB,CAQnB;AAED,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAEzD,0FAA0F;AAC1F,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,aAAa,GAC9C,IAAI,CAON;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAqD5C"}
@@ -0,0 +1,126 @@
1
+ import { updateJson, } from '@nx/devkit';
2
+ import { addMissingKeys } from "../add-keys.js";
3
+ const namedInputs = {
4
+ default: ['{projectRoot}/**/*', 'sharedGlobals'],
5
+ // The hash of a task does not read the environment, so NODE_ENV is an input:
6
+ // else a cached development build can ship to production.
7
+ production: [
8
+ 'default',
9
+ '!{projectRoot}/eslint.config.mjs',
10
+ '!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)',
11
+ '!{projectRoot}/tsconfig.test.json',
12
+ '!{projectRoot}/tsconfig.spec.json',
13
+ { env: 'NODE_ENV' },
14
+ ],
15
+ sharedGlobals: [
16
+ '{workspaceRoot}/eslint.config.mjs',
17
+ '{workspaceRoot}/tsconfig.base.json',
18
+ ],
19
+ };
20
+ // @zukhruf/nx/lint must come after @nx/eslint/plugin: it stops with an error
21
+ // when no @nx/eslint/plugin entry is before it.
22
+ const plugins = [
23
+ {
24
+ plugin: '@nx/js/typescript',
25
+ options: {
26
+ typecheck: { targetName: 'typecheck' },
27
+ build: {
28
+ targetName: 'build',
29
+ configName: 'tsconfig.lib.json',
30
+ buildDepsName: 'build-deps',
31
+ watchDepsName: 'watch-deps',
32
+ },
33
+ },
34
+ },
35
+ { plugin: '@nx/eslint/plugin', options: { targetName: 'lint' } },
36
+ '@zukhruf/nx/lint',
37
+ '@zukhruf/nx/format',
38
+ '@zukhruf/nx/test',
39
+ ];
40
+ export const pluginName = (entry) => typeof entry === 'string' ? entry : entry.plugin;
41
+ export const unique = (values) => {
42
+ const seen = new Set();
43
+ return values.filter((value) => {
44
+ const key = JSON.stringify(value);
45
+ if (seen.has(key))
46
+ return false;
47
+ seen.add(key);
48
+ return true;
49
+ });
50
+ };
51
+ /**
52
+ * Adds the defaults of one collection's generators, for example `@nx/node`,
53
+ * option by option. An option that is there stays, also one that the plugin
54
+ * wrote itself a moment before.
55
+ */
56
+ export function mergeGeneratorDefaults(generators, collection, defaults) {
57
+ const existing = {
58
+ ...generators?.[collection],
59
+ };
60
+ for (const [generator, options] of Object.entries(defaults)) {
61
+ existing[generator] = addMissingKeys(existing[generator], options);
62
+ }
63
+ return { ...generators, [collection]: existing };
64
+ }
65
+ /** Changes each entry of a target default: Nx 24 takes one entry or a list of entries. */
66
+ export function updateTargetDefault(nxJson, target, update) {
67
+ const targetDefaults = (nxJson.targetDefaults ??= {});
68
+ const current = targetDefaults[target] ?? {};
69
+ targetDefaults[target] = Array.isArray(current)
70
+ ? current.map(update)
71
+ : update(current);
72
+ }
73
+ /**
74
+ * Merges the keys that the monorepo standard owns into nx.json and keeps the
75
+ * other keys. A list gets the entries that it does not have.
76
+ */
77
+ export function mergeNxJson(tree) {
78
+ updateJson(tree, 'nx.json', (nxJson) => {
79
+ nxJson.analytics = false;
80
+ nxJson.tui = { ...nxJson.tui, enabled: false };
81
+ nxJson.namedInputs ??= {};
82
+ for (const [name, inputs] of Object.entries(namedInputs)) {
83
+ nxJson.namedInputs[name] = unique([
84
+ ...(nxJson.namedInputs[name] ?? []),
85
+ ...inputs,
86
+ ]);
87
+ }
88
+ const entries = [...(nxJson.plugins ?? [])];
89
+ let previous = -1;
90
+ for (const plugin of plugins) {
91
+ const index = entries.findIndex((entry) => pluginName(entry) === pluginName(plugin));
92
+ if (index === -1) {
93
+ entries.splice(previous + 1, 0, plugin);
94
+ previous += 1;
95
+ }
96
+ else {
97
+ previous = Math.max(previous, index);
98
+ }
99
+ }
100
+ nxJson.plugins = entries;
101
+ // One typecheck runs the whole gate. "..." keeps the ^typecheck of
102
+ // @nx/js/typescript, because a dependsOn list replaces the list of an
103
+ // earlier source.
104
+ updateTargetDefault(nxJson, 'typecheck', (entry) => ({
105
+ ...entry,
106
+ dependsOn: unique([
107
+ ...(entry.dependsOn ?? []),
108
+ 'lint',
109
+ 'format:check',
110
+ '...',
111
+ ]),
112
+ }));
113
+ // Nx 24 reports a continuous task that no task depends on as a success,
114
+ // whatever its exit code (handleContinuousTaskExit in
115
+ // packages/nx/src/tasks-runner/task-orchestrator.ts).
116
+ for (const target of ['dev', 'serve', 'preview', 'serve-static']) {
117
+ updateTargetDefault(nxJson, target, (entry) => ({
118
+ ...entry,
119
+ continuous: false,
120
+ }));
121
+ }
122
+ nxJson.sync = { ...nxJson.sync, applyChanges: true };
123
+ return nxJson;
124
+ });
125
+ }
126
+ //# sourceMappingURL=nx-json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nx-json.js","sourceRoot":"","sources":["../../../src/generators/init/nx-json.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,UAAU,GACX,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAMhD,MAAM,WAAW,GAAsC;IACrD,OAAO,EAAE,CAAC,oBAAoB,EAAE,eAAe,CAAC;IAChD,6EAA6E;IAC7E,0DAA0D;IAC1D,UAAU,EAAE;QACV,SAAS;QACT,kCAAkC;QAClC,uDAAuD;QACvD,mCAAmC;QACnC,mCAAmC;QACnC,EAAE,GAAG,EAAE,UAAU,EAAE;KACpB;IACD,aAAa,EAAE;QACb,mCAAmC;QACnC,oCAAoC;KACrC;CACF,CAAC;AAEF,6EAA6E;AAC7E,gDAAgD;AAChD,MAAM,OAAO,GAA0B;IACrC;QACE,MAAM,EAAE,mBAAmB;QAC3B,OAAO,EAAE;YACP,SAAS,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE;YACtC,KAAK,EAAE;gBACL,UAAU,EAAE,OAAO;gBACnB,UAAU,EAAE,mBAAmB;gBAC/B,aAAa,EAAE,YAAY;gBAC3B,aAA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: string;
4
+ private?: boolean;
5
+ type?: string;
6
+ workspaces?: string[];
7
+ packageManager?: string;
8
+ scripts?: Record<string, string>;
9
+ dependencies?: Record<string, string>;
10
+ devDependencies?: Record<string, string>;
11
+ allowScripts?: Record<string, boolean>;
12
+ overrides?: Record<string, unknown>;
13
+ }
14
+ /** Sets `nx` and each `@nx/*` of the record to `nxVersion`, also over a newer version (#4532). */
15
+ export declare function pinNxFamily(record?: Record<string, string>): void;
16
+ export declare const sortKeys: (record: Record<string, string>) => {
17
+ [k: string]: string;
18
+ };
19
+ /**
20
+ * Merges the keys that the standard owns into the root package.json: one
21
+ * exact version for the Nx family, also over another version, and each other
22
+ * root tool when it is missing.
23
+ */
24
+ export declare function mergeRootPackageJson(tree: Tree): void;
25
+ //# sourceMappingURL=root-package-json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"root-package-json.d.ts","sourceRoot":"","sources":["../../../src/generators/init/root-package-json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAc,MAAM,YAAY,CAAC;AAWnD,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAQD,kGAAkG;AAClG,wBAAgB,WAAW,CAAC,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAAG,IAAI,CAMrE;AAED,eAAO,MAAM,QAAQ,GAAI,QAAQ,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;CAGpD,CAAC;AAEJ;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CA8BrD"}
@@ -0,0 +1,49 @@
1
+ import { updateJson } from '@nx/devkit';
2
+ import { addMissingKeys } from "../add-keys.js";
3
+ import { nxFamily, nxVersion, rootToolVersions, zukhrufPackages, zukhrufVersion, } from "../versions.js";
4
+ // strict-allow-scripts=true in .npmrc fails an install when a package has an
5
+ // install script that is not named here. nx checks the platform and updates
6
+ // the Nx Cloud client, and no repo uses Nx Cloud. unrs-resolver (through
7
+ // eslint-plugin-import-x) ships its binaries prebuilt.
8
+ const allowScripts = { nx: false, 'unrs-resolver': false };
9
+ /** Sets `nx` and each `@nx/*` of the record to `nxVersion`, also over a newer version (#4532). */
10
+ export function pinNxFamily(record = {}) {
11
+ for (const name of Object.keys(record)) {
12
+ if (name === 'nx' || name.startsWith('@nx/')) {
13
+ record[name] = nxVersion;
14
+ }
15
+ }
16
+ }
17
+ export const sortKeys = (record) => Object.fromEntries(Object.entries(record).toSorted(([a], [b]) => a.localeCompare(b)));
18
+ /**
19
+ * Merges the keys that the standard owns into the root package.json: one
20
+ * exact version for the Nx family, also over another version, and each other
21
+ * root tool when it is missing.
22
+ */
23
+ export function mergeRootPackageJson(tree) {
24
+ updateJson(tree, 'package.json', (packageJson) => {
25
+ packageJson.private = true;
26
+ packageJson.type = 'module';
27
+ packageJson.workspaces ??= ['apps/*', 'packages/*', 'tools/*'];
28
+ packageJson.scripts = addMissingKeys(packageJson.scripts, {
29
+ prepare: 'git config core.hooksPath .husky || exit 0',
30
+ });
31
+ const dependencies = packageJson.dependencies ?? {};
32
+ const devDependencies = { ...packageJson.devDependencies };
33
+ for (const [name, version] of Object.entries({
34
+ ...Object.fromEntries(nxFamily.map((name) => [name, nxVersion])),
35
+ ...Object.fromEntries(zukhrufPackages.map((name) => [name, zukhrufVersion])),
36
+ ...rootToolVersions,
37
+ })) {
38
+ if (!(name in dependencies) && !(name in devDependencies)) {
39
+ devDependencies[name] = version;
40
+ }
41
+ }
42
+ pinNxFamily(dependencies);
43
+ pinNxFamily(devDependencies);
44
+ packageJson.devDependencies = sortKeys(devDependencies);
45
+ packageJson.allowScripts = addMissingKeys(packageJson.allowScripts, allowScripts);
46
+ return packageJson;
47
+ });
48
+ }
49
+ //# sourceMappingURL=root-package-json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"root-package-json.js","sourceRoot":"","sources":["../../../src/generators/init/root-package-json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EACL,QAAQ,EACR,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,cAAc,GACf,MAAM,gBAAgB,CAAC;AAexB,6EAA6E;AAC7E,4EAA4E;AAC5E,yEAAyE;AACzE,uDAAuD;AACvD,MAAM,YAAY,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;AAE3D,kGAAkG;AAClG,MAAM,UAAU,WAAW,CAAC,SAAiC,EAAE;IAC7D,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACvC,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YAC7C,MAAM,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;QAC3B,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,MAA8B,EAAE,EAAE,CACzD,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,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