@zukhruf/nx 0.8.28 → 0.8.30

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 (51) hide show
  1. package/README.md +466 -9
  2. package/dist/generators/init/files.d.ts +81 -0
  3. package/dist/generators/init/files.d.ts.map +1 -0
  4. package/dist/generators/init/files.js +278 -0
  5. package/dist/generators/init/files.js.map +1 -0
  6. package/dist/generators/init/generator.d.ts +8 -0
  7. package/dist/generators/init/generator.d.ts.map +1 -0
  8. package/dist/generators/init/generator.js +87 -0
  9. package/dist/generators/init/generator.js.map +1 -0
  10. package/dist/generators/init/nx-json.d.ts +7 -0
  11. package/dist/generators/init/nx-json.d.ts.map +1 -0
  12. package/dist/generators/init/nx-json.js +111 -0
  13. package/dist/generators/init/nx-json.js.map +1 -0
  14. package/dist/generators/init/root-package-json.d.ts +19 -0
  15. package/dist/generators/init/root-package-json.d.ts.map +1 -0
  16. package/dist/generators/init/root-package-json.js +46 -0
  17. package/dist/generators/init/root-package-json.js.map +1 -0
  18. package/dist/generators/preset/generator.d.ts +14 -0
  19. package/dist/generators/preset/generator.d.ts.map +1 -0
  20. package/dist/generators/preset/generator.js +43 -0
  21. package/dist/generators/preset/generator.js.map +1 -0
  22. package/dist/generators/versions.d.ts +24 -0
  23. package/dist/generators/versions.d.ts.map +1 -0
  24. package/dist/generators/versions.js +50 -0
  25. package/dist/generators/versions.js.map +1 -0
  26. package/dist/generators/workspace-scope.d.ts +8 -0
  27. package/dist/generators/workspace-scope.d.ts.map +1 -0
  28. package/dist/generators/workspace-scope.js +15 -0
  29. package/dist/generators/workspace-scope.js.map +1 -0
  30. package/dist/opentofu/check-plan-fresh.d.ts +2 -0
  31. package/dist/opentofu/check-plan-fresh.d.ts.map +1 -0
  32. package/dist/opentofu/check-plan-fresh.js +47 -0
  33. package/dist/opentofu/check-plan-fresh.js.map +1 -0
  34. package/dist/opentofu/plugin.d.ts +9 -0
  35. package/dist/opentofu/plugin.d.ts.map +1 -0
  36. package/dist/opentofu/plugin.js +108 -0
  37. package/dist/opentofu/plugin.js.map +1 -0
  38. package/dist/prisma/plugin.d.ts +9 -0
  39. package/dist/prisma/plugin.d.ts.map +1 -0
  40. package/dist/prisma/plugin.js +83 -0
  41. package/dist/prisma/plugin.js.map +1 -0
  42. package/dist/project-roots.d.ts +5 -0
  43. package/dist/project-roots.d.ts.map +1 -1
  44. package/dist/project-roots.js +10 -0
  45. package/dist/project-roots.js.map +1 -1
  46. package/dist/test/plugin.js +1 -7
  47. package/dist/test/plugin.js.map +1 -1
  48. package/generators.json +14 -0
  49. package/package.json +25 -5
  50. package/src/generators/init/schema.json +8 -0
  51. package/src/generators/preset/schema.json +18 -0
@@ -0,0 +1,278 @@
1
+ // The content of each root file that a generator writes (monorepo standard
2
+ // §2-8). Each is a string in a .ts module, so tsc puts it in dist with no copy
3
+ // 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=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.js","sourceRoot":"","sources":["../../../src/generators/init/files.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,+EAA+E;AAC/E,mBAAmB;AAEnB,MAAM,C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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;AAoDpB;;;;GAIG;AACH,wBAA8B,aAAa,CACzC,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,iBAAiB,CAAC,CAiC5B"}
@@ -0,0 +1,87 @@
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 { workspaceScope } from "../workspace-scope.js";
5
+ import { agents, claude, editorconfig, eslintConfig, gitattributes, gitignore, hooks, npmrc, nvmrc, prettierignore, prettierrc, tsconfigBase, tsconfigSolution, vscodeExtensions, vscodeSettings, } from "./files.js";
6
+ import { mergeNxJson } from "./nx-json.js";
7
+ import { mergeRootPackageJson } from "./root-package-json.js";
8
+ /** Writes a file only when it is missing. Returns whether it wrote. */
9
+ function create(tree, path, content) {
10
+ if (tree.exists(path))
11
+ return false;
12
+ if (typeof content === 'string') {
13
+ tree.write(path, content);
14
+ }
15
+ else {
16
+ writeJson(tree, path, content);
17
+ }
18
+ return true;
19
+ }
20
+ /** Adds each line of `content` that the file does not have. Comments and empty lines are not added. */
21
+ function addLines(tree, path, content) {
22
+ const existing = tree.read(path, 'utf-8');
23
+ if (existing === null) {
24
+ tree.write(path, content);
25
+ return;
26
+ }
27
+ const present = new Set(existing.split(/\r?\n/).map((line) => line.trim()));
28
+ const missing = content
29
+ .split('\n')
30
+ .filter((line) => line !== '' && !line.startsWith('#') && !present.has(line));
31
+ if (missing.length === 0)
32
+ return;
33
+ const separator = existing === '' || existing.endsWith('\n') ? '' : '\n';
34
+ tree.write(path, `${existing}${separator}${missing.join('\n')}\n`);
35
+ }
36
+ /**
37
+ * Adds the root files of the monorepo standard to an Nx workspace. It creates
38
+ * a missing file, adds missing lines and merges keys, and never deletes. A
39
+ * second run changes nothing. `nx add @zukhruf/nx` runs it.
40
+ */
41
+ export default async function initGenerator(tree) {
42
+ const scope = workspaceScope(tree);
43
+ mergeRootPackageJson(tree);
44
+ mergeNxJson(tree);
45
+ create(tree, 'tsconfig.base.json', tsconfigBase);
46
+ create(tree, 'tsconfig.json', tsconfigSolution);
47
+ addLines(tree, '.npmrc', npmrc);
48
+ create(tree, '.nvmrc', nvmrc);
49
+ create(tree, '.gitattributes', gitattributes);
50
+ create(tree, '.editorconfig', editorconfig);
51
+ addLines(tree, '.gitignore', gitignore);
52
+ create(tree, '.prettierrc', prettierrc(scope));
53
+ addLines(tree, '.prettierignore', prettierignore);
54
+ create(tree, 'eslint.config.mjs', eslintConfig);
55
+ const newHooks = Object.entries(hooks)
56
+ .filter(([path, content]) => create(tree, path, content))
57
+ .map(([path]) => path);
58
+ create(tree, '.vscode/settings.json', vscodeSettings);
59
+ create(tree, '.vscode/extensions.json', vscodeExtensions);
60
+ create(tree, 'AGENTS.md', agents);
61
+ create(tree, 'CLAUDE.md', claude);
62
+ await formatFiles(tree);
63
+ // formatFiles writes each file again with no mode, so the mode comes after it.
64
+ for (const path of newHooks) {
65
+ tree.changePermissions(path, '755');
66
+ }
67
+ return runTasksInSerial(() => installPackagesTask(tree), () => linkHooks(tree.root));
68
+ }
69
+ /**
70
+ * Git runs `.husky/pre-commit`, so it is a link to `pre-commit.ts`. The Tree
71
+ * has no links, so this writes each missing link after Nx writes the files.
72
+ */
73
+ async function linkHooks(root) {
74
+ for (const path of Object.keys(hooks)) {
75
+ try {
76
+ await symlink(basename(path), join(root, path.replace(/\.ts$/, '')));
77
+ }
78
+ catch (error) {
79
+ if (!(Error.isError(error) &&
80
+ 'code' in error &&
81
+ error.code === 'EEXIST')) {
82
+ throw error;
83
+ }
84
+ }
85
+ }
86
+ }
87
+ //# 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,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,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AAgB,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,7 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ /**
3
+ * Merges the keys that the standard owns into nx.json (monorepo standard §4)
4
+ * and keeps the other keys. A list gets the entries that it does not have.
5
+ */
6
+ export declare function mergeNxJson(tree: Tree): void;
7
+ //# 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,EAIL,KAAK,IAAI,EAEV,MAAM,YAAY,CAAC;AA0EpB;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAqD5C"}
@@ -0,0 +1,111 @@
1
+ import { updateJson, } from '@nx/devkit';
2
+ const namedInputs = {
3
+ default: ['{projectRoot}/**/*', 'sharedGlobals'],
4
+ // The hash of a task does not read the environment, so NODE_ENV is an input:
5
+ // else a cached development build can ship to production.
6
+ production: [
7
+ 'default',
8
+ '!{projectRoot}/eslint.config.mjs',
9
+ '!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)',
10
+ '!{projectRoot}/tsconfig.test.json',
11
+ '!{projectRoot}/tsconfig.spec.json',
12
+ { env: 'NODE_ENV' },
13
+ ],
14
+ sharedGlobals: [
15
+ '{workspaceRoot}/eslint.config.mjs',
16
+ '{workspaceRoot}/tsconfig.base.json',
17
+ ],
18
+ };
19
+ // @zukhruf/nx/lint must come after @nx/eslint/plugin: it stops with an error
20
+ // when no @nx/eslint/plugin entry is before it.
21
+ const plugins = [
22
+ {
23
+ plugin: '@nx/js/typescript',
24
+ options: {
25
+ typecheck: { targetName: 'typecheck' },
26
+ build: {
27
+ targetName: 'build',
28
+ configName: 'tsconfig.lib.json',
29
+ buildDepsName: 'build-deps',
30
+ watchDepsName: 'watch-deps',
31
+ },
32
+ },
33
+ },
34
+ { plugin: '@nx/eslint/plugin', options: { targetName: 'lint' } },
35
+ '@zukhruf/nx/lint',
36
+ '@zukhruf/nx/format',
37
+ '@zukhruf/nx/test',
38
+ ];
39
+ const pluginName = (entry) => typeof entry === 'string' ? entry : entry.plugin;
40
+ const unique = (values) => {
41
+ const seen = new Set();
42
+ return values.filter((value) => {
43
+ const key = JSON.stringify(value);
44
+ if (seen.has(key))
45
+ return false;
46
+ seen.add(key);
47
+ return true;
48
+ });
49
+ };
50
+ /** Changes each entry of a target default: Nx 24 takes one entry or a list of entries. */
51
+ function updateTargetDefault(nxJson, target, update) {
52
+ const targetDefaults = (nxJson.targetDefaults ??= {});
53
+ const current = targetDefaults[target] ?? {};
54
+ targetDefaults[target] = Array.isArray(current)
55
+ ? current.map(update)
56
+ : update(current);
57
+ }
58
+ /**
59
+ * Merges the keys that the standard owns into nx.json (monorepo standard §4)
60
+ * and keeps the other keys. A list gets the entries that it does not have.
61
+ */
62
+ export function mergeNxJson(tree) {
63
+ updateJson(tree, 'nx.json', (nxJson) => {
64
+ nxJson.analytics = false;
65
+ nxJson.tui = { ...nxJson.tui, enabled: false };
66
+ nxJson.namedInputs ??= {};
67
+ for (const [name, inputs] of Object.entries(namedInputs)) {
68
+ nxJson.namedInputs[name] = unique([
69
+ ...(nxJson.namedInputs[name] ?? []),
70
+ ...inputs,
71
+ ]);
72
+ }
73
+ const entries = [...(nxJson.plugins ?? [])];
74
+ let previous = -1;
75
+ for (const plugin of plugins) {
76
+ const index = entries.findIndex((entry) => pluginName(entry) === pluginName(plugin));
77
+ if (index === -1) {
78
+ entries.splice(previous + 1, 0, plugin);
79
+ previous += 1;
80
+ }
81
+ else {
82
+ previous = Math.max(previous, index);
83
+ }
84
+ }
85
+ nxJson.plugins = entries;
86
+ // One typecheck runs the whole gate. "..." keeps the ^typecheck of
87
+ // @nx/js/typescript, because a dependsOn list replaces the list of an
88
+ // earlier source.
89
+ updateTargetDefault(nxJson, 'typecheck', (entry) => ({
90
+ ...entry,
91
+ dependsOn: unique([
92
+ ...(entry.dependsOn ?? []),
93
+ 'lint',
94
+ 'format:check',
95
+ '...',
96
+ ]),
97
+ }));
98
+ // Nx 24 reports a continuous task that no task depends on as a success,
99
+ // whatever its exit code (handleContinuousTaskExit in
100
+ // packages/nx/src/tasks-runner/task-orchestrator.ts).
101
+ for (const target of ['dev', 'serve', 'preview', 'serve-static']) {
102
+ updateTargetDefault(nxJson, target, (entry) => ({
103
+ ...entry,
104
+ continuous: false,
105
+ }));
106
+ }
107
+ nxJson.sync = { ...nxJson.sync, applyChanges: true };
108
+ return nxJson;
109
+ });
110
+ }
111
+ //# 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;AAMpB,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,aAAa,EAAE,YAAY;aAC5B;SACF;KACF;IACD,EAAE,MAAM,EAAE,mBAAmB,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE;IAChE,kBAAkB;IAClB,oBAAoB;IACpB,kBAAkB;CACnB,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,KAA0B,EAAE,EAAE,CAChD,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;AAEnD,MAAM,MAAM,GAAG,CAAI,MAAW,EAAE,EAAE;IAChC,MAAM,IAAI,GAAG,IAAI,GAA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K,EAAE,EAAE,CAAC,CAAC;gBAC9C,GAAG,KAAK;gBACR,UAAU,EAAE,KAAK;aAClB,CAAC,CAAC,CAAC;QACN,CAAC;QAED,MAAM,CAAC,IAAI,GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;QACrD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export interface RootPackageJson {
3
+ name?: 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
+ }
13
+ /**
14
+ * Merges the keys that the standard owns into the root package.json: one
15
+ * exact version for the Nx family, also over another version, and each other
16
+ * root tool when it is missing.
17
+ */
18
+ export declare function mergeRootPackageJson(tree: Tree): void;
19
+ //# 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;AAUnD,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;CACxC;AAaD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAiCrD"}
@@ -0,0 +1,46 @@
1
+ import { updateJson } from '@nx/devkit';
2
+ import { nxFamily, nxVersion, rootToolVersions, zukhrufPackages, zukhrufVersion, } from "../versions.js";
3
+ // strict-allow-scripts=true in .npmrc fails an install when a package has an
4
+ // install script that is not named here. nx checks the platform and updates
5
+ // the Nx Cloud client, and no repo uses Nx Cloud. unrs-resolver (through
6
+ // eslint-plugin-import-x) ships its binaries prebuilt.
7
+ const allowScripts = { nx: false, 'unrs-resolver': false };
8
+ const sortKeys = (record) => Object.fromEntries(Object.entries(record).toSorted(([a], [b]) => a.localeCompare(b)));
9
+ /**
10
+ * Merges the keys that the standard owns into the root package.json: one
11
+ * exact version for the Nx family, also over another version, and each other
12
+ * root tool when it is missing.
13
+ */
14
+ export function mergeRootPackageJson(tree) {
15
+ updateJson(tree, 'package.json', (packageJson) => {
16
+ packageJson.private = true;
17
+ packageJson.type = 'module';
18
+ packageJson.workspaces ??= ['apps/*', 'packages/*', 'tools/*'];
19
+ packageJson.scripts = {
20
+ prepare: 'git config core.hooksPath .husky || exit 0',
21
+ ...packageJson.scripts,
22
+ };
23
+ const dependencies = packageJson.dependencies ?? {};
24
+ const devDependencies = { ...packageJson.devDependencies };
25
+ for (const [name, version] of Object.entries({
26
+ ...Object.fromEntries(nxFamily.map((name) => [name, nxVersion])),
27
+ ...Object.fromEntries(zukhrufPackages.map((name) => [name, zukhrufVersion])),
28
+ ...rootToolVersions,
29
+ })) {
30
+ if (!(name in dependencies) && !(name in devDependencies)) {
31
+ devDependencies[name] = version;
32
+ }
33
+ }
34
+ for (const record of [dependencies, devDependencies]) {
35
+ for (const name of Object.keys(record)) {
36
+ if (name === 'nx' || name.startsWith('@nx/')) {
37
+ record[name] = nxVersion;
38
+ }
39
+ }
40
+ }
41
+ packageJson.devDependencies = sortKeys(devDependencies);
42
+ packageJson.allowScripts = { ...allowScripts, ...packageJson.allowScripts };
43
+ return packageJson;
44
+ });
45
+ }
46
+ //# 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,EACL,QAAQ,EACR,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,cAAc,GACf,MAAM,gBAAgB,CAAC;AAcxB,6EAA6E;AAC7E,4EAA4E;AAC5E,yEAAyE;AACzE,uDAAuD;AACvD,MAAM,YAAY,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;AAE3D,MAAM,QAAQ,GAAG,CAAC,MAA8B,EAAE,EAAE,CAClD,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAClE,CAAC;AAEJ;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAU;IAC7C,UAAU,CAAC,IAAI,EAAE,cAAc,EAAE,CAAC,WAA4B,EAAE,EAAE;QAChE,WAAW,CAAC,OAAO,GAAG,IAAI,CAAC;QAC3B,WAAW,CAAC,IAAI,GAAG,QAAQ,CAAC;QAC5B,WAAW,CAAC,UAAU,KAAK,CAAC,QAAQ,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;QAC/D,WAAW,CAAC,OAAO,GAAG;YACpB,OAAO,EAAE,4CAA4C;YACrD,GAAG,WAAW,CAAC,OAAO;SACvB,CAAC;QACF,MAAM,YAAY,GAAG,WAAW,CAAC,YAAY,IAAI,EAAE,C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export interface PresetOptions {
3
+ /** The folder name, from create-nx-workspace. */
4
+ name: string;
5
+ /** Anything other than `npm` is an error. */
6
+ packageManager?: string;
7
+ }
8
+ /**
9
+ * Starts a repo of the monorepo standard. create-nx-workspace runs it just
10
+ * after `nx new`, so each file in the folder came from `nx new`: it replaces 4
11
+ * of them, cleans package.json, and then runs `init`.
12
+ */
13
+ export default function presetGenerator(tree: Tree, options: PresetOptions): Promise<GeneratorCallback>;
14
+ //# sourceMappingURL=generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generators/preset/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,IAAI,EAGV,MAAM,YAAY,CAAC;AAWpB,MAAM,WAAW,aAAa;IAC5B,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAA8B,eAAe,CAC3C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,iBAAiB,CAAC,CAwC5B"}