@clearlydev/nx-archweave 0.5.2 → 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.
- package/dist/generators/_chunks/{chunk-ILICA6LC.js → chunk-23NN76E3.js} +1 -1
- package/dist/generators/_chunks/{chunk-624F6DEP.js → chunk-7EDJKUY4.js} +4 -106
- package/dist/generators/_chunks/chunk-AMOOSD5Q.js +79 -0
- package/dist/generators/_chunks/{chunk-M7OQWSNF.js → chunk-C2WELXMV.js} +11 -3
- package/dist/generators/_chunks/{chunk-WVMTOWLM.js → chunk-FBCIELXS.js} +4 -93
- package/dist/generators/_chunks/chunk-FZGN5NEP.js +31 -0
- package/dist/generators/_chunks/chunk-LJRFVE6B.js +55 -0
- package/dist/generators/_chunks/{chunk-Q7IYHKT3.js → chunk-M7UBCSYL.js} +5 -3
- package/dist/generators/_chunks/{chunk-ND62HBKD.js → chunk-OEEWCZCO.js} +4 -4
- package/dist/generators/_chunks/chunk-SHKQSTV2.js +110 -0
- package/dist/generators/_chunks/{chunk-RDTB34IA.js → chunk-VCLVE4EQ.js} +10 -94
- package/dist/generators/_chunks/{chunk-VTXXW2B5.js → chunk-VI7U5HS5.js} +5 -55
- package/dist/generators/_chunks/{chunk-E565RG2B.js → chunk-WQDJYSOD.js} +6 -0
- package/dist/generators/_chunks/{chunk-LBYZDAWS.js → chunk-XXXON43Z.js} +194 -3
- package/dist/generators/_chunks/chunk-YEMQFSL6.js +95 -0
- package/dist/generators/_chunks/chunk-ZFCK3KMO.js +396 -0
- package/dist/generators/_chunks/{chunk-3ZHRZK5M.js → chunk-ZRHIFPUC.js} +4 -32
- package/dist/generators/add-agent-rules/generator.js +4 -3
- package/dist/generators/add-backend/generator.js +3 -2
- package/dist/generators/add-fsd-lite/generator.js +7 -5
- package/dist/generators/add-github-templates/generator.js +3 -2
- package/dist/generators/add-integration/generator.js +2 -2
- package/dist/generators/add-review/generator.js +3 -3
- package/dist/generators/doctor/generator.js +32 -19
- package/dist/generators/entity/generator.js +4 -3
- package/dist/generators/feature/generator.js +4 -3
- package/dist/generators/init/generator.js +30 -366
- package/dist/generators/install-integration/generator.js +2 -2
- package/dist/generators/page/generator.js +4 -3
- package/dist/generators/shared/generator.js +4 -3
- package/dist/generators/widget/generator.js +4 -3
- package/dist/migrations/update-0.5.3/add-toolkit-config-lint-input.js +62 -0
- package/migrations.json +9 -0
- package/package.json +6 -1
|
@@ -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-
|
|
8
|
+
} from "./chunk-XXXON43Z.js";
|
|
6
9
|
import {
|
|
7
|
-
profileById,
|
|
8
10
|
resolveFrontendApp
|
|
9
|
-
} from "./chunk-
|
|
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-
|
|
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-
|
|
34
|
+
} from "./chunk-C2WELXMV.js";
|
|
30
35
|
import {
|
|
31
|
-
INSTALL_ASSUMES_PNPM,
|
|
32
36
|
detectYarnFlavor,
|
|
33
37
|
packageManagerCommands,
|
|
34
38
|
runNxCommand
|
|
@@ -81,92 +85,6 @@ function buildSteigerConfig({ renamedLayerDirs, locale }) {
|
|
|
81
85
|
return lines.join("\n");
|
|
82
86
|
}
|
|
83
87
|
|
|
84
|
-
// ../template-engine/dist/fsd/lint-target-defaults.js
|
|
85
|
-
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
86
|
-
var inputsOf = (value) => isObject(value) && Array.isArray(value["inputs"]) ? value["inputs"] : void 0;
|
|
87
|
-
function readTargetDefaults(targetDefaults, key) {
|
|
88
|
-
const value = isObject(targetDefaults) ? targetDefaults[key] : void 0;
|
|
89
|
-
if (value === void 0)
|
|
90
|
-
return { shape: "absent" };
|
|
91
|
-
if (Array.isArray(value))
|
|
92
|
-
return { shape: "list", entries: value.map((entry) => ({ inputs: inputsOf(entry) })) };
|
|
93
|
-
if (isObject(value))
|
|
94
|
-
return { shape: "object", inputs: inputsOf(value) };
|
|
95
|
-
return { shape: "other" };
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// src/generators/add-fsd-lite/render.ts
|
|
99
|
-
function renderAddFsdLiteReport(report) {
|
|
100
|
-
const lines = [];
|
|
101
|
-
if (report.aborted) {
|
|
102
|
-
lines.push("add-fsd-lite aborted \u2014 nothing was written.");
|
|
103
|
-
const refusal = report.appRefusal;
|
|
104
|
-
if (refusal !== null) {
|
|
105
|
-
lines.push("");
|
|
106
|
-
lines.push(" FSD layers live inside the frontend app's source root (e.g. apps/web/src), and no app could be picked:");
|
|
107
|
-
if (refusal.reason === "project-not-found") {
|
|
108
|
-
lines.push(` --project=${refusal.project} names no project in this workspace.`);
|
|
109
|
-
} else if (refusal.reason === "ambiguous-frontend") {
|
|
110
|
-
lines.push(" more than one frontend app was found \u2014 rerun with --project=<one of them>:");
|
|
111
|
-
for (const name of refusal.candidates) lines.push(` - ${name}`);
|
|
112
|
-
} else if (refusal.reason === "invalid-project-json") {
|
|
113
|
-
lines.push(` a project.json could not be parsed (${refusal.detail}) \u2014 fix it, then rerun.`);
|
|
114
|
-
} else if (refusal.otherProjects.length > 0) {
|
|
115
|
-
lines.push(" no project was recognised as a frontend app. If one of these is it, rerun with --project=<name>:");
|
|
116
|
-
for (const name of refusal.otherProjects) lines.push(` - ${name}`);
|
|
117
|
-
} else {
|
|
118
|
-
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.");
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return lines.join("\n");
|
|
122
|
-
}
|
|
123
|
-
if (report.dryRun) {
|
|
124
|
-
lines.push("add-fsd-lite dry-run \u2014 no files were written.");
|
|
125
|
-
lines.push("");
|
|
126
|
-
}
|
|
127
|
-
lines.push(`FSD layers (in ${report.project}, ${report.sourceRoot}):`);
|
|
128
|
-
if (report.layerGuide !== null && report.frontend === "generic") {
|
|
129
|
-
lines.push("Frontend: framework not recognised \u2014 the common FSD rules apply, with no framework-specific layer names.");
|
|
130
|
-
}
|
|
131
|
-
if (report.layerGuide !== null) lines.push(report.layerGuide);
|
|
132
|
-
lines.push("");
|
|
133
|
-
const where = report.eslintPath ?? `${report.project}'s eslint.config.mjs`;
|
|
134
|
-
switch (report.eslint) {
|
|
135
|
-
case "applied":
|
|
136
|
-
lines.push(`ESLint: archweave/fsd-boundaries (${report.enforcement}) written to ${where}`);
|
|
137
|
-
break;
|
|
138
|
-
case "already-applied":
|
|
139
|
-
lines.push(`ESLint: archweave/fsd-boundaries already wired in ${where} \u2014 no change`);
|
|
140
|
-
break;
|
|
141
|
-
case "degraded-unrecognized":
|
|
142
|
-
lines.push(`ESLint: ${report.eslintPath === null ? `no ESLint config found for ${report.project}` : `${where} was NOT recognized \u2014 left untouched`}.`);
|
|
143
|
-
lines.push(" Add the rule yourself (then the layer rules are actually enforced):");
|
|
144
|
-
break;
|
|
145
|
-
case "snippet-only":
|
|
146
|
-
lines.push(`ESLint: report-only (pass --applyEslint to write the rule into ${where}).`);
|
|
147
|
-
break;
|
|
148
|
-
case "not-applied":
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
if (report.snippet !== null) lines.push(report.snippet);
|
|
152
|
-
if (report.steiger !== null) {
|
|
153
|
-
const st = report.steiger;
|
|
154
|
-
lines.push("");
|
|
155
|
-
lines.push("steiger (official FSD linter, opt-in):");
|
|
156
|
-
lines.push(
|
|
157
|
-
` ${st.configPath}: ${st.config === "created" ? "created" : st.config === "unchanged" ? "unchanged" : "kept \u2014 an existing config with other content is never replaced"}`
|
|
158
|
-
);
|
|
159
|
-
lines.push(
|
|
160
|
-
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"
|
|
161
|
-
);
|
|
162
|
-
lines.push(
|
|
163
|
-
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"
|
|
164
|
-
);
|
|
165
|
-
lines.push(` run it with: ${st.runCommand} (steiger needs Node >= 22.18)`);
|
|
166
|
-
}
|
|
167
|
-
return lines.join("\n");
|
|
168
|
-
}
|
|
169
|
-
|
|
170
88
|
// src/generators/add-fsd-lite/generator.ts
|
|
171
89
|
function resolveEnforcement(option, config) {
|
|
172
90
|
if (option === "error" || option === "warn") return option;
|
|
@@ -300,8 +218,6 @@ var generator_default = addFsdLiteGenerator;
|
|
|
300
218
|
|
|
301
219
|
export {
|
|
302
220
|
DEFAULT_CONFLICT_POLICY,
|
|
303
|
-
readTargetDefaults,
|
|
304
|
-
renderAddFsdLiteReport,
|
|
305
221
|
runAddFsdLite,
|
|
306
222
|
addFsdLiteGenerator,
|
|
307
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-
|
|
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-
|
|
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
|
|
@@ -88,6 +88,7 @@ function renderAddReviewReport(report) {
|
|
|
88
88
|
}
|
|
89
89
|
if (report.dependabot === "created") {
|
|
90
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.");
|
|
91
92
|
} else if (report.dependabot === "present") {
|
|
92
93
|
lines.push(` ${DEPENDABOT_PATH}: already updates github-actions`);
|
|
93
94
|
} else if (report.dependabot === "proposed") {
|
|
@@ -95,6 +96,11 @@ function renderAddReviewReport(report) {
|
|
|
95
96
|
lines.push(" to a commit SHA; add this entry under `updates:` so those pins get update pull requests:");
|
|
96
97
|
lines.push("");
|
|
97
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 ?? "");
|
|
98
104
|
}
|
|
99
105
|
if (report.workflowAction === "alternate") {
|
|
100
106
|
lines.push("");
|
|
@@ -126,9 +126,10 @@ 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
|
-
|
|
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."
|
|
@@ -139,7 +140,7 @@ function lintInputsListSnippet(target) {
|
|
|
139
140
|
`targetDefaults.${target} in nx.json is a list of entries, each for the projects its filter picks. Add`,
|
|
140
141
|
`"${TOOLKIT_CONFIG_INPUT}" to every entry that covers an FSD project:`,
|
|
141
142
|
` an entry with inputs: add it to its "inputs"`,
|
|
142
|
-
` an entry without inputs: "inputs": ["...", "${TOOLKIT_CONFIG_INPUT}"]`,
|
|
143
|
+
` an entry without inputs ${SPREAD_INPUT_NX_NOTE}: "inputs": ["...", "${TOOLKIT_CONFIG_INPUT}"]`,
|
|
143
144
|
'Keep "...": it stands for the inputs @nx/eslint/plugin infers (the sources, the ESLint config). Without it',
|
|
144
145
|
"they are dropped, and lint is served from the cache after a source change. A lint target written in a",
|
|
145
146
|
'project file keeps only what targetDefaults lists ("..." has nothing to keep there): give it its own inputs.'
|
|
@@ -155,6 +156,193 @@ function lintInputsProjectSnippet(input) {
|
|
|
155
156
|
` "inputs": [${inputs.join(", ")}]`
|
|
156
157
|
];
|
|
157
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
|
+
}
|
|
158
346
|
|
|
159
347
|
export {
|
|
160
348
|
classifyFsdEslintConfig,
|
|
@@ -164,5 +352,8 @@ export {
|
|
|
164
352
|
TOOLKIT_CONFIG_INPUT,
|
|
165
353
|
lintInputsTargetDefaultsSnippet,
|
|
166
354
|
lintInputsListSnippet,
|
|
167
|
-
lintInputsProjectSnippet
|
|
355
|
+
lintInputsProjectSnippet,
|
|
356
|
+
lintInputsKeySnippet,
|
|
357
|
+
readTargetDefaults,
|
|
358
|
+
resolveTargetDefaults
|
|
168
359
|
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// ../template-engine/dist/frameworks/profiles.js
|
|
2
|
+
var ALL_LAYERS = ["app", "pages", "features", "entities", "shared"];
|
|
3
|
+
var NEXT = {
|
|
4
|
+
id: "next",
|
|
5
|
+
recognised: true,
|
|
6
|
+
// Next.js's own app/ (App Router) directory is the composition root; FSD's Next.js guide
|
|
7
|
+
// names the FSD app and pages layers _app and _pages, since Next.js reads src/app and
|
|
8
|
+
// src/pages as its routers.
|
|
9
|
+
layers: ["pages", "features", "entities", "shared"],
|
|
10
|
+
layerDirs: { app: "_app", pages: "_pages" },
|
|
11
|
+
buildOutputDirs: [".next", "out"],
|
|
12
|
+
platformSuffixes: [],
|
|
13
|
+
routerDirs: ["pages"]
|
|
14
|
+
};
|
|
15
|
+
var REACT_VITE = {
|
|
16
|
+
id: "react-vite",
|
|
17
|
+
recognised: true,
|
|
18
|
+
layers: ALL_LAYERS,
|
|
19
|
+
layerDirs: {},
|
|
20
|
+
buildOutputDirs: ["dist"],
|
|
21
|
+
platformSuffixes: [],
|
|
22
|
+
routerDirs: []
|
|
23
|
+
};
|
|
24
|
+
var EXPO_ROUTER = {
|
|
25
|
+
id: "expo",
|
|
26
|
+
recognised: true,
|
|
27
|
+
layers: ALL_LAYERS,
|
|
28
|
+
layerDirs: { app: "_app" },
|
|
29
|
+
buildOutputDirs: [".expo", "dist"],
|
|
30
|
+
platformSuffixes: ["ios", "android", "native", "web"],
|
|
31
|
+
routerDirs: []
|
|
32
|
+
};
|
|
33
|
+
var EXPO = { ...EXPO_ROUTER, layerDirs: {} };
|
|
34
|
+
var GENERIC = {
|
|
35
|
+
id: "generic",
|
|
36
|
+
recognised: false,
|
|
37
|
+
layers: ALL_LAYERS,
|
|
38
|
+
layerDirs: {},
|
|
39
|
+
buildOutputDirs: ["dist", "build"],
|
|
40
|
+
platformSuffixes: [],
|
|
41
|
+
routerDirs: []
|
|
42
|
+
};
|
|
43
|
+
var PROFILES = { next: NEXT, "react-vite": REACT_VITE, expo: EXPO_ROUTER, generic: GENERIC };
|
|
44
|
+
function profileById(id) {
|
|
45
|
+
return PROFILES[id];
|
|
46
|
+
}
|
|
47
|
+
function allFrameworkProfiles() {
|
|
48
|
+
return Object.values(PROFILES);
|
|
49
|
+
}
|
|
50
|
+
var NEXT_CONFIGS = ["next.config.js", "next.config.mjs", "next.config.ts", "next.config.cjs"];
|
|
51
|
+
var VITE_CONFIGS = ["vite.config.ts", "vite.config.mts", "vite.config.js", "vite.config.mjs"];
|
|
52
|
+
var EXPO_CONFIGS = ["app.config.ts", "app.config.js", "app.config.mjs"];
|
|
53
|
+
function hasExpoKey(input, file) {
|
|
54
|
+
const text = input.read(file);
|
|
55
|
+
if (typeof text !== "string")
|
|
56
|
+
return false;
|
|
57
|
+
try {
|
|
58
|
+
return typeof JSON.parse(text)["expo"] === "object";
|
|
59
|
+
} catch {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function dependsOn(input, manifest, name) {
|
|
64
|
+
const text = input.read(manifest);
|
|
65
|
+
if (typeof text !== "string")
|
|
66
|
+
return false;
|
|
67
|
+
try {
|
|
68
|
+
const parsed = JSON.parse(text);
|
|
69
|
+
return ["dependencies", "devDependencies", "peerDependencies"].some((field) => parsed[field]?.[name] !== void 0);
|
|
70
|
+
} catch {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function detectFramework(input) {
|
|
75
|
+
const prefix = input.projectRoot === "" || input.projectRoot === "." ? "" : `${input.projectRoot}/`;
|
|
76
|
+
const executors = input.executors ?? [];
|
|
77
|
+
if (NEXT_CONFIGS.some((file) => input.exists(`${prefix}${file}`)) || executors.some((executor) => executor.startsWith("@nx/next:"))) {
|
|
78
|
+
return NEXT;
|
|
79
|
+
}
|
|
80
|
+
const dependsAnywhere = (name) => dependsOn(input, `${prefix}package.json`, name) || dependsOn(input, "package.json", name);
|
|
81
|
+
const usesExpo = executors.some((executor) => executor.startsWith("@nx/expo:")) || hasExpoKey(input, `${prefix}app.json`) || EXPO_CONFIGS.some((file) => input.exists(`${prefix}${file}`)) || dependsOn(input, `${prefix}package.json`, "expo");
|
|
82
|
+
if (usesExpo)
|
|
83
|
+
return dependsAnywhere("expo-router") ? EXPO_ROUTER : EXPO;
|
|
84
|
+
const usesReact = dependsAnywhere("react");
|
|
85
|
+
const usesVite = VITE_CONFIGS.some((file) => input.exists(`${prefix}${file}`)) || executors.some((executor) => executor.startsWith("@nx/vite:"));
|
|
86
|
+
if (usesVite && usesReact)
|
|
87
|
+
return REACT_VITE;
|
|
88
|
+
return GENERIC;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export {
|
|
92
|
+
profileById,
|
|
93
|
+
allFrameworkProfiles,
|
|
94
|
+
detectFramework
|
|
95
|
+
};
|