@clearlydev/nx-archweave 0.5.1 → 0.5.3

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 (36) hide show
  1. package/README.md +6 -4
  2. package/dist/generators/_chunks/{chunk-ILICA6LC.js → chunk-23NN76E3.js} +1 -1
  3. package/dist/generators/_chunks/{chunk-624F6DEP.js → chunk-7EDJKUY4.js} +4 -106
  4. package/dist/generators/_chunks/chunk-AMOOSD5Q.js +79 -0
  5. package/dist/generators/_chunks/{chunk-M7OQWSNF.js → chunk-C2WELXMV.js} +11 -3
  6. package/dist/generators/_chunks/{chunk-WVMTOWLM.js → chunk-FBCIELXS.js} +4 -93
  7. package/dist/generators/_chunks/chunk-FZGN5NEP.js +31 -0
  8. package/dist/generators/_chunks/chunk-LJRFVE6B.js +55 -0
  9. package/dist/generators/_chunks/{chunk-Q7IYHKT3.js → chunk-M7UBCSYL.js} +5 -3
  10. package/dist/generators/_chunks/{chunk-ERCX7F6K.js → chunk-OEEWCZCO.js} +7 -7
  11. package/dist/generators/_chunks/chunk-SHKQSTV2.js +110 -0
  12. package/dist/generators/_chunks/{chunk-TJ6SCQLI.js → chunk-VCLVE4EQ.js} +10 -79
  13. package/dist/generators/_chunks/{chunk-ZNTGYYLU.js → chunk-VI7U5HS5.js} +5 -55
  14. package/dist/generators/_chunks/{chunk-AON4KGZT.js → chunk-WQDJYSOD.js} +13 -6
  15. package/dist/generators/_chunks/{chunk-N6B6VBHG.js → chunk-XXXON43Z.js} +205 -2
  16. package/dist/generators/_chunks/chunk-YEMQFSL6.js +95 -0
  17. package/dist/generators/_chunks/chunk-ZFCK3KMO.js +396 -0
  18. package/dist/generators/_chunks/{chunk-3ZHRZK5M.js → chunk-ZRHIFPUC.js} +4 -32
  19. package/dist/generators/add-agent-rules/generator.js +4 -3
  20. package/dist/generators/add-backend/generator.js +3 -2
  21. package/dist/generators/add-fsd-lite/generator.js +7 -5
  22. package/dist/generators/add-github-templates/generator.js +3 -2
  23. package/dist/generators/add-integration/generator.js +2 -2
  24. package/dist/generators/add-review/generator.js +3 -3
  25. package/dist/generators/doctor/generator.js +35 -21
  26. package/dist/generators/entity/generator.js +4 -3
  27. package/dist/generators/feature/generator.js +4 -3
  28. package/dist/generators/init/generator.js +30 -358
  29. package/dist/generators/install-integration/generator.js +2 -2
  30. package/dist/generators/page/generator.js +4 -3
  31. package/dist/generators/shared/generator.js +4 -3
  32. package/dist/generators/widget/generator.js +4 -3
  33. package/dist/migrations/update-0.5.3/add-toolkit-config-lint-input.js +62 -0
  34. package/generators.json +1 -1
  35. package/migrations.json +9 -0
  36. package/package.json +22 -9
@@ -0,0 +1,110 @@
1
+ import {
2
+ packageManagerCommands
3
+ } from "./chunk-5Z7VZPES.js";
4
+
5
+ // src/generators/add-backend/render.ts
6
+ function renderAddBackendBody(report) {
7
+ const lines = [];
8
+ if (report.refused === "no-frontend") {
9
+ lines.push(`Refused: no frontend application and no "${report.apiName}" app found in this workspace.`);
10
+ lines.push(" add-backend wires a backend app \u2014 beside a frontend, or on its own in a backend-only");
11
+ lines.push(` workspace (create one with: npx create-nx-workspace --preset=${report.backend} --appName=${report.apiName}).`);
12
+ lines.push(" If the backend app has another name, pass --apiName=<its directory name>.");
13
+ return lines.join("\n");
14
+ }
15
+ if (report.refused === "frontend-not-found") {
16
+ lines.push(`Refused: --frontendProject "${report.frontendProject}" does not match any project.`);
17
+ lines.push(" Nothing was written. Check the name with `nx show projects`.");
18
+ return lines.join("\n");
19
+ }
20
+ if (report.refused === "ambiguous-frontend") {
21
+ lines.push("Refused: multiple frontend applications found \u2014 add-backend will not guess:");
22
+ for (const name of report.frontendCandidates ?? []) lines.push(` - ${name}`);
23
+ lines.push(" Nothing was written. Re-run with --frontendProject=<name> to pick one.");
24
+ return lines.join("\n");
25
+ }
26
+ if (report.refused === "invalid-project-json") {
27
+ lines.push("Refused: a project.json this run must update could not be parsed:");
28
+ for (const path of report.invalidProjects ?? []) lines.push(` - ${path}`);
29
+ lines.push(" Nothing was written \u2014 fix the JSON, then re-run add-backend.");
30
+ return lines.join("\n");
31
+ }
32
+ if (report.refused === "missing-api-project") {
33
+ lines.push(`Refused: no "${report.apiName}" application project found.`);
34
+ lines.push(" Create it with the official commands first (copy-paste, names already filled in),");
35
+ lines.push(" then re-run add-backend to wire it up:");
36
+ lines.push("");
37
+ for (const command of report.commands ?? []) lines.push(` ${command}`);
38
+ if (report.packageManagerNote !== void 0) lines.push(` note: ${report.packageManagerNote}`);
39
+ if (report.expressRange !== void 0) {
40
+ lines.push("");
41
+ lines.push(` The express line declares express@${report.expressRange}, the range this workspace's @nx/react supports \u2014`);
42
+ lines.push(" the official generator then keeps it instead of adding express 5, which npm rejects as a peer conflict.");
43
+ }
44
+ return lines.join("\n");
45
+ }
46
+ if (report.packageManagerNote !== void 0) lines.push(` note: ${report.packageManagerNote}`);
47
+ lines.push(` frontend project: ${report.frontendProject ?? "none (backend-only workspace)"}`);
48
+ const libPath = report.sharedTypesRoot ?? "libs/shared-types";
49
+ lines.push(
50
+ report.sharedTypes === "created" ? ` ${libPath}: created (import it as ${report.sharedTypesPackage})` : report.sharedTypes === "disabled" ? " shared-types lib: none (sharedTypes: false in toolkit.config.json)" : ` ${libPath}: already exists \u2014 skipped`
51
+ );
52
+ if (report.config !== void 0 && report.config !== "unchanged") {
53
+ lines.push(` toolkit.config.json: backend "${report.backend}" recorded (${report.config}) \u2014 doctor's backend checks now run`);
54
+ }
55
+ if (report.workspaceGlob !== void 0) {
56
+ const pmName = report.packageManager ?? "pnpm";
57
+ const registry = packageManagerCommands(pmName).workspaceRegistration;
58
+ lines.push(
59
+ {
60
+ added: ` ${registry}: '${libPath}' registered \u2014 run \`${pmName} install\` once to link it`,
61
+ present: ` ${registry}: already covers ${libPath}`,
62
+ unrecognized: (
63
+ // an integrated layout lists no workspace packages: the paths alias below links it
64
+ report.tsconfigPaths === "added" || report.tsconfigPaths === "present" ? ` ${registry}: no workspace package list (integrated layout) \u2014 the tsconfig paths alias links ${libPath}` : ` ${registry}: shape not recognized \u2014 add '${libPath}' to its workspace list yourself`
65
+ )
66
+ }[report.workspaceGlob]
67
+ );
68
+ }
69
+ for (const tag of report.tags) {
70
+ lines.push(` tag ${tag.project}: ${tag.action === "added" ? "added" : "already present"}`);
71
+ }
72
+ lines.push(
73
+ {
74
+ added: ` tsconfig.base.json paths: ${report.sharedTypesPackage} added (a classic or integrated setup \u2014 libs resolve through paths)`,
75
+ present: " tsconfig.base.json paths: already wired",
76
+ "workspace-link": " tsconfig paths: not needed \u2014 the workspace package link is the wiring",
77
+ unrecognized: " tsconfig.base.json: could not be parsed \u2014 left untouched",
78
+ none: " tsconfig paths: nothing to wire (no shared-types lib)"
79
+ }[report.tsconfigPaths]
80
+ );
81
+ switch (report.eslint) {
82
+ case "applied":
83
+ lines.push(" ESLint boundaries: cross-side deny rules written (existing imports stay allowed)");
84
+ break;
85
+ case "already-applied":
86
+ lines.push(" ESLint boundaries: already enforced \u2014 no change");
87
+ break;
88
+ case "degraded-unrecognized":
89
+ lines.push(" ESLint boundaries: your config was NOT recognized \u2014 left untouched.");
90
+ lines.push(" Merge this yourself (then boundaries are actually enforced):");
91
+ break;
92
+ case "snippet-only":
93
+ lines.push(" ESLint boundaries: report-only (pass --applyEslint to write them).");
94
+ lines.push(" Paste-ready snippet:");
95
+ break;
96
+ }
97
+ if (report.snippet) {
98
+ lines.push("");
99
+ lines.push(report.snippet);
100
+ }
101
+ return lines.join("\n");
102
+ }
103
+ function renderAddBackendReport(report, dryRun) {
104
+ return [`add-backend (${report.backend})${dryRun ? " \u2014 dry run" : ""}`, "", renderAddBackendBody(report)].join("\n");
105
+ }
106
+
107
+ export {
108
+ renderAddBackendBody,
109
+ renderAddBackendReport
110
+ };
@@ -1,12 +1,17 @@
1
+ import {
2
+ renderAddFsdLiteReport
3
+ } from "./chunk-AMOOSD5Q.js";
1
4
  import {
2
5
  applyFsdEslintConfig,
3
6
  buildFsdEslintPasteSnippet,
4
7
  composeFsdLayerGuide
5
- } from "./chunk-N6B6VBHG.js";
8
+ } from "./chunk-XXXON43Z.js";
6
9
  import {
7
- profileById,
8
10
  resolveFrontendApp
9
- } from "./chunk-WVMTOWLM.js";
11
+ } from "./chunk-FBCIELXS.js";
12
+ import {
13
+ profileById
14
+ } from "./chunk-YEMQFSL6.js";
10
15
  import {
11
16
  ESLINT_CONFIG_CANDIDATES
12
17
  } from "./chunk-6ZTIUBB2.js";
@@ -18,7 +23,7 @@ import {
18
23
  } from "./chunk-TUN34LAQ.js";
19
24
  import {
20
25
  runNxFor
21
- } from "./chunk-ILICA6LC.js";
26
+ } from "./chunk-23NN76E3.js";
22
27
  import {
23
28
  applyJsonEdits,
24
29
  readToolkitConfig,
@@ -26,9 +31,8 @@ import {
26
31
  resolveLocaleOption,
27
32
  setJsonValue,
28
33
  treePackageManager
29
- } from "./chunk-M7OQWSNF.js";
34
+ } from "./chunk-C2WELXMV.js";
30
35
  import {
31
- INSTALL_ASSUMES_PNPM,
32
36
  detectYarnFlavor,
33
37
  packageManagerCommands,
34
38
  runNxCommand
@@ -81,78 +85,6 @@ function buildSteigerConfig({ renamedLayerDirs, locale }) {
81
85
  return lines.join("\n");
82
86
  }
83
87
 
84
- // src/generators/add-fsd-lite/render.ts
85
- function renderAddFsdLiteReport(report) {
86
- const lines = [];
87
- if (report.aborted) {
88
- lines.push("add-fsd-lite aborted \u2014 nothing was written.");
89
- const refusal = report.appRefusal;
90
- if (refusal !== null) {
91
- lines.push("");
92
- lines.push(" FSD layers live inside the frontend app's source root (e.g. apps/web/src), and no app could be picked:");
93
- if (refusal.reason === "project-not-found") {
94
- lines.push(` --project=${refusal.project} names no project in this workspace.`);
95
- } else if (refusal.reason === "ambiguous-frontend") {
96
- lines.push(" more than one frontend app was found \u2014 rerun with --project=<one of them>:");
97
- for (const name of refusal.candidates) lines.push(` - ${name}`);
98
- } else if (refusal.reason === "invalid-project-json") {
99
- lines.push(` a project.json could not be parsed (${refusal.detail}) \u2014 fix it, then rerun.`);
100
- } else if (refusal.otherProjects.length > 0) {
101
- lines.push(" no project was recognised as a frontend app. If one of these is it, rerun with --project=<name>:");
102
- for (const name of refusal.otherProjects) lines.push(` - ${name}`);
103
- } else {
104
- lines.push(" the workspace has no projects \u2014 create one (e.g. nx g @nx/react:app or nx g @nx/next:app), then rerun.");
105
- }
106
- }
107
- return lines.join("\n");
108
- }
109
- if (report.dryRun) {
110
- lines.push("add-fsd-lite dry-run \u2014 no files were written.");
111
- lines.push("");
112
- }
113
- lines.push(`FSD layers (in ${report.project}, ${report.sourceRoot}):`);
114
- if (report.layerGuide !== null && report.frontend === "generic") {
115
- lines.push("Frontend: framework not recognised \u2014 the common FSD rules apply, with no framework-specific layer names.");
116
- }
117
- if (report.layerGuide !== null) lines.push(report.layerGuide);
118
- lines.push("");
119
- const where = report.eslintPath ?? `${report.project}'s eslint.config.mjs`;
120
- switch (report.eslint) {
121
- case "applied":
122
- lines.push(`ESLint: archweave/fsd-boundaries (${report.enforcement}) written to ${where}`);
123
- break;
124
- case "already-applied":
125
- lines.push(`ESLint: archweave/fsd-boundaries already wired in ${where} \u2014 no change`);
126
- break;
127
- case "degraded-unrecognized":
128
- lines.push(`ESLint: ${report.eslintPath === null ? `no ESLint config found for ${report.project}` : `${where} was NOT recognized \u2014 left untouched`}.`);
129
- lines.push(" Add the rule yourself (then the layer rules are actually enforced):");
130
- break;
131
- case "snippet-only":
132
- lines.push(`ESLint: report-only (pass --applyEslint to write the rule into ${where}).`);
133
- break;
134
- case "not-applied":
135
- break;
136
- }
137
- if (report.snippet !== null) lines.push(report.snippet);
138
- if (report.steiger !== null) {
139
- const st = report.steiger;
140
- lines.push("");
141
- lines.push("steiger (official FSD linter, opt-in):");
142
- lines.push(
143
- ` ${st.configPath}: ${st.config === "created" ? "created" : st.config === "unchanged" ? "unchanged" : "kept \u2014 an existing config with other content is never replaced"}`
144
- );
145
- lines.push(
146
- st.target === "added" ? ` target ${"fsd-check"}: added to ${st.targetPath}` : st.target === "present" ? ` target ${"fsd-check"}: already present in ${st.targetPath}` : " target fsd-check: NOT added \u2014 no parseable project.json / package.json for the app"
147
- );
148
- lines.push(
149
- st.dependencies === "added" ? ` devDependencies: steiger + @feature-sliced/steiger-plugin added to package.json \u2014 run \`${st.installCommand}\`${st.installAssumed ? ` (${INSTALL_ASSUMES_PNPM})` : ""}` : st.dependencies === "present" ? " devDependencies: already present" : " devDependencies: NOT added \u2014 the root package.json could not be parsed"
150
- );
151
- lines.push(` run it with: ${st.runCommand} (steiger needs Node >= 22.18)`);
152
- }
153
- return lines.join("\n");
154
- }
155
-
156
88
  // src/generators/add-fsd-lite/generator.ts
157
89
  function resolveEnforcement(option, config) {
158
90
  if (option === "error" || option === "warn") return option;
@@ -286,7 +218,6 @@ var generator_default = addFsdLiteGenerator;
286
218
 
287
219
  export {
288
220
  DEFAULT_CONFLICT_POLICY,
289
- renderAddFsdLiteReport,
290
221
  runAddFsdLite,
291
222
  addFsdLiteGenerator,
292
223
  generator_default
@@ -1,6 +1,9 @@
1
+ import {
2
+ renderAddAgentRulesReport
3
+ } from "./chunk-LJRFVE6B.js";
1
4
  import {
2
5
  renderLineDiff
3
- } from "./chunk-AON4KGZT.js";
6
+ } from "./chunk-WQDJYSOD.js";
4
7
  import {
5
8
  resolveFsdPolicy
6
9
  } from "./chunk-5MI3O4VZ.js";
@@ -16,7 +19,7 @@ import {
16
19
  resolveAiHostsOption,
17
20
  resolveLocaleOption,
18
21
  rulesFilesFor
19
- } from "./chunk-M7OQWSNF.js";
22
+ } from "./chunk-C2WELXMV.js";
20
23
 
21
24
  // ../templates/dist/agents/agent-sections.js
22
25
  var UNIVERSAL_AGENT_SECTION_IDS = [
@@ -476,58 +479,6 @@ function applyAgentRulesBlock(existing, body, options = {}) {
476
479
  return { kind: "replace", text };
477
480
  }
478
481
 
479
- // src/generators/add-agent-rules/render.ts
480
- var ACTION_LINE = {
481
- created: (result) => `${result.filePath}: created`,
482
- appended: (result) => `${result.filePath}: nx-archweave block added after the existing content (nothing else changed)`,
483
- updated: (result) => `${result.filePath}: nx-archweave block updated (nothing outside it changed)`,
484
- unchanged: (result) => `${result.filePath}: unchanged`,
485
- unrecognized: (result) => `${result.filePath}: not written \u2014 ${result.reason ?? "the nx-archweave markers could not be placed"}`,
486
- "user-modified": (result) => `${result.filePath}: not written \u2014 the nx-archweave block was edited by hand, so it is kept`
487
- };
488
- function renderAddAgentRulesReport(report) {
489
- const lines = [];
490
- lines.push(report.dryRun ? "add-agent-rules dry-run \u2014 no files were written." : "add-agent-rules:");
491
- lines.push(` hosts: ${report.hosts.join(", ")}`);
492
- lines.push(` locale: ${report.locale}`);
493
- lines.push(` teamRules: ${report.teamRules}`);
494
- lines.push("");
495
- for (const file of report.files) {
496
- lines.push(` ${ACTION_LINE[file.action](file)}`);
497
- if (file.action === "user-modified") {
498
- lines.push(" What this run would write instead (your block \u2192 generated):");
499
- for (const line of (file.diff ?? "").split("\n")) lines.push(` ${line}`);
500
- lines.push(" Rerun with --overwriteBlock to replace the block with the generated one.");
501
- }
502
- }
503
- const RECORD_LINE = {
504
- created: "toolkit.config.json: aiHosts recorded (file created)",
505
- updated: "toolkit.config.json: aiHosts recorded",
506
- unchanged: "toolkit.config.json: aiHosts already recorded",
507
- unrecognized: "toolkit.config.json: not a JSON object \u2014 aiHosts not recorded (fix the file, then rerun)",
508
- "not-applied": "toolkit.config.json: aiHosts not recorded \u2014 a file above was not written",
509
- "not-requested": null
510
- };
511
- const recordLine = RECORD_LINE[report.hostsRecord];
512
- if (recordLine !== null) lines.push(` ${recordLine}`);
513
- if (report.files.some((file) => file.action === "unrecognized")) {
514
- lines.push("");
515
- lines.push('Manual fix needed: keep exactly one "<!-- nx-archweave:agent-rules start \u2026 -->" \u2026 "<!-- nx-archweave:agent-rules end -->"');
516
- lines.push("pair in the file (or remove both markers), then rerun add-agent-rules.");
517
- }
518
- if (report.dryRun) {
519
- lines.push("");
520
- lines.push("Generated content preview:");
521
- for (const file of report.files) {
522
- if (file.content === null) continue;
523
- lines.push("");
524
- lines.push(`--- ${file.filePath} ---`);
525
- lines.push(file.content);
526
- }
527
- }
528
- return lines.join("\n");
529
- }
530
-
531
482
  // src/generators/add-agent-rules/generator.ts
532
483
  function resolveTeamRules(option, config) {
533
484
  if (option !== void 0) return option;
@@ -610,7 +561,6 @@ async function addAgentRulesGenerator(tree, options) {
610
561
  var generator_default = addAgentRulesGenerator;
611
562
 
612
563
  export {
613
- renderAddAgentRulesReport,
614
564
  runAddAgentRules,
615
565
  addAgentRulesGenerator,
616
566
  generator_default
@@ -4,6 +4,7 @@ import {
4
4
 
5
5
  // src/generators/add-review/render.ts
6
6
  var DEPENDABOT_PATH = ".github/dependabot.yml";
7
+ var MOST_TESTED_PROVIDER = "claude";
7
8
  var PROVIDER_STATUS_URL = "https://github.com/clearlydev/nx-archweave/blob/main/docs/pr-review.md#provider-status";
8
9
  function renderLineDiff(existing, generated) {
9
10
  const a = normalizeFileText(existing).split("\n");
@@ -87,6 +88,7 @@ function renderAddReviewReport(report) {
87
88
  }
88
89
  if (report.dependabot === "created") {
89
90
  lines.push(` ${DEPENDABOT_PATH}: created \u2014 Dependabot proposes newer pins for the workflow's actions`);
91
+ lines.push(" Delete this file if you don't want those pull requests.");
90
92
  } else if (report.dependabot === "present") {
91
93
  lines.push(` ${DEPENDABOT_PATH}: already updates github-actions`);
92
94
  } else if (report.dependabot === "proposed") {
@@ -94,6 +96,11 @@ function renderAddReviewReport(report) {
94
96
  lines.push(" to a commit SHA; add this entry under `updates:` so those pins get update pull requests:");
95
97
  lines.push("");
96
98
  lines.push(report.dependabotProposal ?? "");
99
+ } else if (report.dependabot === "withheld") {
100
+ lines.push(` ${DEPENDABOT_PATH}: not created \u2014 the workflow wasn't written this run. To get update pull requests`);
101
+ lines.push(" for its pinned actions, add this file:");
102
+ lines.push("");
103
+ lines.push(report.dependabotProposal ?? "");
97
104
  }
98
105
  if (report.workflowAction === "alternate") {
99
106
  lines.push("");
@@ -102,12 +109,12 @@ function renderAddReviewReport(report) {
102
109
  }
103
110
  lines.push("");
104
111
  lines.push(`Note: the review workflow stays green-skipped until you register the ${report.requiredSecretName} secret.`);
105
- if (report.betaProvider !== void 0) {
106
- lines.push(`Note: the ${report.betaProvider} provider is in beta \u2014 its workflow hasn't finished a review end to end on`);
107
- lines.push(`GitHub Actions yet. Status, costs and known issues: ${PROVIDER_STATUS_URL}`);
108
- lines.push("Warning: the AI review doesn't replace a person's code review. Require a person's approval on every pull");
109
- lines.push("request.");
110
- }
112
+ lines.push(
113
+ report.reviewProvider === MOST_TESTED_PROVIDER ? `Note: AI PR review is in beta \u2014 ${MOST_TESTED_PROVIDER} is its most tested provider.` : `Note: AI PR review is in beta, and the ${report.reviewProvider} provider hasn't been verified end to end yet.`
114
+ );
115
+ lines.push(`Status, costs and known issues: ${PROVIDER_STATUS_URL}`);
116
+ lines.push("Warning: the AI review doesn't replace a person's code review. Require a person's approval on every pull");
117
+ lines.push("request.");
111
118
  lines.push("Note: this workflow runs with elevated permissions only after it is merged to the default branch \u2014");
112
119
  lines.push("merging is the first real validation.");
113
120
  return lines.join("\n");
@@ -126,14 +126,26 @@ function composeFsdLayerGuide({ profile, sourceRoot, locale, runNx }) {
126
126
 
127
127
  // ../template-engine/dist/fsd/lint-cache-inputs.js
128
128
  var TOOLKIT_CONFIG_INPUT = "{workspaceRoot}/toolkit.config.json";
129
+ var SPREAD_INPUT_NX_NOTE = "(Nx 23+)";
129
130
  function lintInputsTargetDefaultsSnippet(target) {
130
131
  return [
131
- "Add to nx.json:",
132
+ `Add to nx.json ${SPREAD_INPUT_NX_NOTE}:`,
132
133
  ` "targetDefaults": { "${target}": { "inputs": ["...", "${TOOLKIT_CONFIG_INPUT}"] } }`,
133
134
  'Keep "...": it stands for the inputs @nx/eslint/plugin infers (the sources, the ESLint config). Without it',
134
135
  "they are dropped, and lint is served from the cache after a source change."
135
136
  ];
136
137
  }
138
+ function lintInputsListSnippet(target) {
139
+ return [
140
+ `targetDefaults.${target} in nx.json is a list of entries, each for the projects its filter picks. Add`,
141
+ `"${TOOLKIT_CONFIG_INPUT}" to every entry that covers an FSD project:`,
142
+ ` an entry with inputs: add it to its "inputs"`,
143
+ ` an entry without inputs ${SPREAD_INPUT_NX_NOTE}: "inputs": ["...", "${TOOLKIT_CONFIG_INPUT}"]`,
144
+ 'Keep "...": it stands for the inputs @nx/eslint/plugin infers (the sources, the ESLint config). Without it',
145
+ "they are dropped, and lint is served from the cache after a source change. A lint target written in a",
146
+ 'project file keeps only what targetDefaults lists ("..." has nothing to keep there): give it its own inputs.'
147
+ ];
148
+ }
137
149
  function lintInputsProjectSnippet(input) {
138
150
  if (input.ownInputs)
139
151
  return [`Add "${TOOLKIT_CONFIG_INPUT}" to the inputs of the ${input.target} target in ${input.file}.`];
@@ -144,6 +156,193 @@ function lintInputsProjectSnippet(input) {
144
156
  ` "inputs": [${inputs.join(", ")}]`
145
157
  ];
146
158
  }
159
+ function lintInputsKeySnippet(key, target, hasInputs) {
160
+ return [
161
+ `targetDefaults["${key}"] in nx.json is the entry Nx applies to the ${target} target (it comes before targetDefaults.${target},`,
162
+ "and Nx applies one entry only). Add the input there:",
163
+ hasInputs ? ` add "${TOOLKIT_CONFIG_INPUT}" to its "inputs"` : ` "inputs": ["...", "${TOOLKIT_CONFIG_INPUT}"] ${SPREAD_INPUT_NX_NOTE}`
164
+ ];
165
+ }
166
+
167
+ // ../template-engine/dist/fsd/lint-target-defaults.js
168
+ var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
169
+ var inputsOf = (value) => isObject(value) && Array.isArray(value["inputs"]) ? value["inputs"] : void 0;
170
+ function readTargetDefaults(targetDefaults, key) {
171
+ const value = isObject(targetDefaults) ? targetDefaults[key] : void 0;
172
+ if (value === void 0)
173
+ return { shape: "absent" };
174
+ if (Array.isArray(value))
175
+ return { shape: "list", entries: value.map((entry) => ({ inputs: inputsOf(entry) })) };
176
+ if (isObject(value))
177
+ return { shape: "object", inputs: inputsOf(value) };
178
+ return { shape: "other" };
179
+ }
180
+ function resolveTargetDefaults(targetDefaults, targetName, ctx) {
181
+ if (!isObject(targetDefaults))
182
+ return { kind: "none" };
183
+ for (const key of orderedKeys(targetDefaults, targetName, ctx.executor)) {
184
+ if (key.kind === "unknown")
185
+ return { kind: "unknown", key: key.key };
186
+ const value = targetDefaults[key.key];
187
+ if (isObject(value))
188
+ return { kind: "found", key: key.key, inputs: inputsOf(value) };
189
+ if (!Array.isArray(value))
190
+ return { kind: "unknown", key: key.key };
191
+ let applied = false;
192
+ let inputs;
193
+ for (const entry of value) {
194
+ if (!isObject(entry))
195
+ return { kind: "unknown", key: key.key };
196
+ const matches = filterMatches(entry["filter"], ctx);
197
+ if (matches === void 0)
198
+ return { kind: "unknown", key: key.key };
199
+ if (!matches)
200
+ continue;
201
+ applied = true;
202
+ const own = inputsOf(entry);
203
+ if (own === void 0)
204
+ continue;
205
+ const earlier = inputs;
206
+ inputs = earlier !== void 0 && own.includes("...") ? own.flatMap((input) => input === "..." ? earlier : [input]) : own;
207
+ }
208
+ if (applied)
209
+ return { kind: "found", key: key.key, inputs };
210
+ }
211
+ return { kind: "none" };
212
+ }
213
+ function* orderedKeys(targetDefaults, targetName, executor) {
214
+ if (executor !== void 0 && executor in targetDefaults)
215
+ yield { kind: "key", key: executor };
216
+ if (targetName in targetDefaults && targetName !== executor)
217
+ yield { kind: "key", key: targetName };
218
+ const globs = [];
219
+ for (const key of Object.keys(targetDefaults)) {
220
+ if (key === targetName || key === executor || !isGlobPattern(key))
221
+ continue;
222
+ const matches = globMatch(key, targetName);
223
+ if (matches === void 0) {
224
+ yield { kind: "unknown", key };
225
+ return;
226
+ }
227
+ if (matches)
228
+ globs.push(key);
229
+ }
230
+ for (const key of globs.sort((a, b) => b.length - a.length))
231
+ yield { kind: "key", key };
232
+ }
233
+ function filterMatches(filter, ctx) {
234
+ if (filter === void 0)
235
+ return true;
236
+ if (!isObject(filter))
237
+ return void 0;
238
+ const results = [];
239
+ if (filter["projects"] !== void 0) {
240
+ results.push(Array.isArray(filter["projects"]) ? projectsMatch(filter["projects"].map(String), ctx.project) : void 0);
241
+ }
242
+ if (typeof filter["plugin"] === "string")
243
+ results.push(ctx.plugin === void 0 ? void 0 : filter["plugin"] === ctx.plugin);
244
+ if (typeof filter["executor"] === "string")
245
+ results.push(ctx.executor === void 0 ? void 0 : filter["executor"] === ctx.executor);
246
+ if (results.includes(false))
247
+ return false;
248
+ return results.includes(void 0) ? void 0 : true;
249
+ }
250
+ function projectsMatch(patterns, project) {
251
+ const list = patterns.filter((pattern) => pattern.length > 0);
252
+ if (list.length === 0)
253
+ return false;
254
+ let selected = list[0]?.startsWith("!") ?? false;
255
+ for (const raw of list) {
256
+ const exclude = raw.startsWith("!");
257
+ const pattern = exclude ? raw.slice(1) : raw;
258
+ if (pattern.startsWith("nx-cloud:"))
259
+ continue;
260
+ const matches = projectPatternMatch(pattern, project);
261
+ if (matches === void 0)
262
+ return void 0;
263
+ if (matches)
264
+ selected = !exclude;
265
+ }
266
+ return selected;
267
+ }
268
+ function projectPatternMatch(pattern, project) {
269
+ if (pattern === "*" || pattern === project.name)
270
+ return true;
271
+ const separator = pattern.indexOf(":");
272
+ const type = separator === -1 ? "unlabeled" : pattern.slice(0, separator);
273
+ const value = ["name", "tag", "directory", "unlabeled"].includes(type) && separator !== -1 ? pattern.slice(separator + 1) : pattern;
274
+ const byName = () => value === project.name ? true : isGlobPattern(value) ? globMatch(value, project.name) : new RegExp(`(?<![@a-zA-Z0-9-])${value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![@a-zA-Z0-9-])`, "i").test(project.name);
275
+ const byDirectory = () => globMatch(value, project.root);
276
+ switch (separator === -1 || !["name", "tag", "directory"].includes(type) ? "unlabeled" : type) {
277
+ case "name":
278
+ return byName();
279
+ case "tag":
280
+ if (project.tags.includes(value))
281
+ return true;
282
+ if (!isGlobPattern(value))
283
+ return false;
284
+ return anyOf(project.tags.map((tag) => globMatch(value, tag)));
285
+ case "directory":
286
+ return byDirectory();
287
+ default: {
288
+ const name = byName();
289
+ return name === false ? byDirectory() : name;
290
+ }
291
+ }
292
+ }
293
+ function anyOf(results) {
294
+ if (results.includes(true))
295
+ return true;
296
+ return results.includes(void 0) ? void 0 : false;
297
+ }
298
+ var GLOB_CHARACTERS = /* @__PURE__ */ new Set(["*", "|", "{", "}", "(", ")", "["]);
299
+ function isGlobPattern(pattern) {
300
+ return [...pattern].some((character) => GLOB_CHARACTERS.has(character));
301
+ }
302
+ function globMatch(pattern, subject) {
303
+ if (pattern.startsWith("!") || /[@!?+*]\(/.test(pattern) || pattern.includes("|"))
304
+ return void 0;
305
+ let source = "";
306
+ let braces = 0;
307
+ for (let index = 0; index < pattern.length; index++) {
308
+ const character = pattern.charAt(index);
309
+ if (character === "\\") {
310
+ const next = pattern[++index];
311
+ if (next === void 0)
312
+ return void 0;
313
+ source += next.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
314
+ } else if (character === "*") {
315
+ if (pattern[index + 1] === "*") {
316
+ source += ".*";
317
+ index++;
318
+ } else {
319
+ source += "[^/]*";
320
+ }
321
+ } else if (character === "?") {
322
+ source += "[^/]";
323
+ } else if (character === "[") {
324
+ const end = pattern.indexOf("]", index + 2);
325
+ if (end === -1)
326
+ return void 0;
327
+ const body = pattern.slice(index + 1, end);
328
+ source += `[${body.startsWith("!") ? `^${body.slice(1)}` : body}]`;
329
+ index = end;
330
+ } else if (character === "{") {
331
+ braces++;
332
+ source += "(?:";
333
+ } else if (character === "}" && braces > 0) {
334
+ braces--;
335
+ source += ")";
336
+ } else if (character === "," && braces > 0) {
337
+ source += "|";
338
+ } else {
339
+ source += character.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
340
+ }
341
+ }
342
+ if (braces !== 0)
343
+ return void 0;
344
+ return new RegExp(`^${source}$`).test(subject);
345
+ }
147
346
 
148
347
  export {
149
348
  classifyFsdEslintConfig,
@@ -152,5 +351,9 @@ export {
152
351
  composeFsdLayerGuide,
153
352
  TOOLKIT_CONFIG_INPUT,
154
353
  lintInputsTargetDefaultsSnippet,
155
- lintInputsProjectSnippet
354
+ lintInputsListSnippet,
355
+ lintInputsProjectSnippet,
356
+ lintInputsKeySnippet,
357
+ readTargetDefaults,
358
+ resolveTargetDefaults
156
359
  };