@clearlydev/nx-archweave 0.5.2 → 0.6.0
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-VTXXW2B5.js → chunk-3HSNM6AS.js} +5 -55
- 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-E565RG2B.js → chunk-CSJZ4PP3.js} +15 -0
- 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-ND62HBKD.js → chunk-JNYQTW7S.js} +15 -8
- 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-SHKQSTV2.js +110 -0
- package/dist/generators/_chunks/{chunk-RDTB34IA.js → chunk-VCLVE4EQ.js} +10 -94
- package/dist/generators/_chunks/chunk-XSALM2IR.js +396 -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-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 +32 -367
- 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 +7 -2
- package/src/generators/add-review/schema.json +4 -0
- package/src/generators/init/schema.json +4 -0
|
@@ -2,10 +2,12 @@ import {
|
|
|
2
2
|
SEGMENT_NAME_PATTERN,
|
|
3
3
|
isEssenceSegmentName,
|
|
4
4
|
isUsableSliceApiName,
|
|
5
|
-
profileById,
|
|
6
5
|
resolveFrontendApp,
|
|
7
6
|
resolveSlicePublicApiName
|
|
8
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-FBCIELXS.js";
|
|
8
|
+
import {
|
|
9
|
+
profileById
|
|
10
|
+
} from "./chunk-YEMQFSL6.js";
|
|
9
11
|
import {
|
|
10
12
|
generatorFilesDir,
|
|
11
13
|
renderTemplateFiles
|
|
@@ -18,7 +20,7 @@ import {
|
|
|
18
20
|
readToolkitConfig,
|
|
19
21
|
recordedFrontends,
|
|
20
22
|
resolveLocaleOption
|
|
21
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-C2WELXMV.js";
|
|
22
24
|
|
|
23
25
|
// src/generators/slice/core.ts
|
|
24
26
|
import { join } from "node:path";
|
|
@@ -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-
|
|
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
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
import {
|
|
2
|
+
renderAddAgentRulesReport
|
|
3
|
+
} from "./chunk-LJRFVE6B.js";
|
|
4
|
+
import {
|
|
5
|
+
renderAddReviewReport
|
|
6
|
+
} from "./chunk-CSJZ4PP3.js";
|
|
7
|
+
import {
|
|
8
|
+
renderAddBackendBody
|
|
9
|
+
} from "./chunk-SHKQSTV2.js";
|
|
10
|
+
import {
|
|
11
|
+
renderAddFsdLiteReport
|
|
12
|
+
} from "./chunk-AMOOSD5Q.js";
|
|
13
|
+
import {
|
|
14
|
+
TOOLKIT_CONFIG_INPUT,
|
|
15
|
+
lintInputsKeySnippet,
|
|
16
|
+
lintInputsListSnippet,
|
|
17
|
+
lintInputsProjectSnippet,
|
|
18
|
+
lintInputsTargetDefaultsSnippet,
|
|
19
|
+
readTargetDefaults,
|
|
20
|
+
resolveTargetDefaults
|
|
21
|
+
} from "./chunk-XXXON43Z.js";
|
|
22
|
+
import {
|
|
23
|
+
ESLINT_CONFIG_CANDIDATES
|
|
24
|
+
} from "./chunk-6ZTIUBB2.js";
|
|
25
|
+
import {
|
|
26
|
+
renderAddGithubTemplatesReport
|
|
27
|
+
} from "./chunk-FZGN5NEP.js";
|
|
28
|
+
import {
|
|
29
|
+
applyJsonEdits
|
|
30
|
+
} from "./chunk-C2WELXMV.js";
|
|
31
|
+
import {
|
|
32
|
+
packageManagerCommands,
|
|
33
|
+
runNxCommand
|
|
34
|
+
} from "./chunk-5Z7VZPES.js";
|
|
35
|
+
|
|
36
|
+
// src/generators/init/left-for-you.ts
|
|
37
|
+
var PLUGIN = "@clearlydev/nx-archweave";
|
|
38
|
+
function leftForYou(report) {
|
|
39
|
+
const runNx = report.runNx ?? runNxCommand(report.packageManager);
|
|
40
|
+
const kept = [];
|
|
41
|
+
const manual = [];
|
|
42
|
+
for (const section of report.sections) {
|
|
43
|
+
if (!section.enabled || section.report === null) continue;
|
|
44
|
+
const sectionReport = section.report;
|
|
45
|
+
switch (sectionReport.kind) {
|
|
46
|
+
case "fsd": {
|
|
47
|
+
const fsd = sectionReport.report;
|
|
48
|
+
if (fsd.aborted) break;
|
|
49
|
+
if (fsd.eslint === "degraded-unrecognized") {
|
|
50
|
+
manual.push(
|
|
51
|
+
fsd.eslintPath === null ? `${fsd.project ?? "the app"}: no ESLint config found \u2014 add the archweave/fsd-boundaries rule to one (the snippet is above)` : `${fsd.eslintPath}: not recognized \u2014 add the archweave/fsd-boundaries rule yourself (the snippet is above)`
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
const steiger = fsd.steiger;
|
|
55
|
+
if (steiger !== null) {
|
|
56
|
+
if (steiger.config === "kept") kept.push(`${steiger.configPath}: an existing steiger config with other content \u2014 left as it is`);
|
|
57
|
+
if (steiger.target === "unrecognized") manual.push(`${fsd.project ?? "the app"}: add the fsd-check target yourself (no parseable project.json or package.json)`);
|
|
58
|
+
if (steiger.dependencies === "unrecognized") {
|
|
59
|
+
manual.push("package.json: could not be parsed \u2014 add steiger and @feature-sliced/steiger-plugin to devDependencies yourself");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
case "agentRules":
|
|
65
|
+
for (const file of sectionReport.report.files) {
|
|
66
|
+
if (file.action === "user-modified") {
|
|
67
|
+
kept.push(`${file.filePath}: its nx-archweave block was edited by hand \u2014 to replace it: ${runNx} g ${PLUGIN}:add-agent-rules --overwriteBlock`);
|
|
68
|
+
} else if (file.action === "unrecognized") {
|
|
69
|
+
kept.push(`${file.filePath}: left untouched (${file.reason ?? "its nx-archweave markers could not be placed"}) \u2014 fix the file, then rerun init`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
break;
|
|
73
|
+
case "githubTemplates":
|
|
74
|
+
for (const file of sectionReport.report.files) {
|
|
75
|
+
if (file.action === "skipped") {
|
|
76
|
+
kept.push(`${file.filePath}: a different file is already there \u2014 to use the generated one, delete it and run ${runNx} g ${PLUGIN}:add-github-templates`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
break;
|
|
80
|
+
case "review": {
|
|
81
|
+
const review = sectionReport.report;
|
|
82
|
+
if (review.workflowAction === "aborted") break;
|
|
83
|
+
if (review.workflowAction === "proposed" || review.workflowAction === "skipped") {
|
|
84
|
+
kept.push(`${review.workflowPath}: differs from the generated workflow \u2014 to replace it: ${runNx} g ${PLUGIN}:add-review --onConflict=overwrite`);
|
|
85
|
+
} else if (review.workflowAction === "alternate") {
|
|
86
|
+
manual.push(`${review.workflowPath}: written alongside the existing workflow \u2014 replace the main workflow file with it yourself`);
|
|
87
|
+
}
|
|
88
|
+
if (review.dependabot === "proposed") manual.push(".github/dependabot.yml: add the github-actions entry shown above");
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
case "backend": {
|
|
92
|
+
const backend = sectionReport.report;
|
|
93
|
+
if (backend.refused !== void 0) break;
|
|
94
|
+
if (backend.eslint === "degraded-unrecognized") manual.push("ESLint boundaries: your config was not recognized \u2014 merge the constraints shown above yourself");
|
|
95
|
+
if (backend.tsconfigPaths === "unrecognized") {
|
|
96
|
+
manual.push(`tsconfig.base.json: could not be parsed \u2014 add the ${backend.sharedTypesPackage ?? "shared-types"} path yourself`);
|
|
97
|
+
}
|
|
98
|
+
const linkedByPaths = backend.tsconfigPaths === "added" || backend.tsconfigPaths === "present";
|
|
99
|
+
if (backend.workspaceGlob === "unrecognized" && !linkedByPaths) {
|
|
100
|
+
const registry = packageManagerCommands(backend.packageManager ?? "pnpm").workspaceRegistration;
|
|
101
|
+
manual.push(`${registry}: shape not recognized \u2014 add '${backend.sharedTypesRoot ?? "libs/shared-types"}' to its workspace list yourself`);
|
|
102
|
+
}
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return { kept, manual };
|
|
108
|
+
}
|
|
109
|
+
function renderLeftForYou(left) {
|
|
110
|
+
const lines = [];
|
|
111
|
+
if (left.kept.length > 0) {
|
|
112
|
+
lines.push("", "Skipped to keep your changes:", ...left.kept.map((item) => ` ${item}`));
|
|
113
|
+
}
|
|
114
|
+
if (left.manual.length > 0) {
|
|
115
|
+
lines.push("", "Needs a manual step:", ...left.manual.map((item) => ` ${item}`));
|
|
116
|
+
}
|
|
117
|
+
return lines;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// src/generators/init/lint-inputs.ts
|
|
121
|
+
import { getProjects } from "@nx/devkit";
|
|
122
|
+
import { parse } from "jsonc-parser";
|
|
123
|
+
var ESLINT_PLUGIN = "@nx/eslint/plugin";
|
|
124
|
+
var INFERRED_EXECUTOR = "nx:run-commands";
|
|
125
|
+
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
126
|
+
function applyLintInputs(tree, input) {
|
|
127
|
+
const raw = tree.read("nx.json", "utf-8");
|
|
128
|
+
if (raw === null) return void 0;
|
|
129
|
+
const nxJson = parse(raw, [], { allowTrailingComma: true });
|
|
130
|
+
if (!isObject(nxJson)) return void 0;
|
|
131
|
+
const plugins = Array.isArray(nxJson["plugins"]) ? nxJson["plugins"] : [];
|
|
132
|
+
const registrations = plugins.filter((entry) => entry === ESLINT_PLUGIN || isObject(entry) && entry["plugin"] === ESLINT_PLUGIN);
|
|
133
|
+
const plugin = registrations[0];
|
|
134
|
+
const options = isObject(plugin) && isObject(plugin["options"]) ? plugin["options"] : {};
|
|
135
|
+
const target = typeof options["targetName"] === "string" ? options["targetName"] : "lint";
|
|
136
|
+
const targetDefaults = isObject(nxJson["targetDefaults"]) ? nxJson["targetDefaults"] : {};
|
|
137
|
+
const namedInputs = isObject(nxJson["namedInputs"]) ? nxJson["namedInputs"] : {};
|
|
138
|
+
const lintDefaults = readTargetDefaults(targetDefaults, target);
|
|
139
|
+
const carries = (inputs) => inputs.some((entry) => {
|
|
140
|
+
if (entry === TOOLKIT_CONFIG_INPUT) return true;
|
|
141
|
+
const named = typeof entry === "string" ? namedInputs[entry.replace(/^\^/, "")] : void 0;
|
|
142
|
+
return Array.isArray(named) && named.includes(TOOLKIT_CONFIG_INPUT);
|
|
143
|
+
});
|
|
144
|
+
const projects = getProjects(tree);
|
|
145
|
+
const ownTarget = (name) => {
|
|
146
|
+
const project = projects.get(name);
|
|
147
|
+
if (project === void 0) return void 0;
|
|
148
|
+
const written = project.targets?.[target];
|
|
149
|
+
if (isObject(written)) return { file: projectFile(tree, project.root), executor: typeof written.executor === "string" ? written.executor : void 0, inputs: written.inputs };
|
|
150
|
+
const pkg = readJson(tree, `${prefix(project.root)}package.json`);
|
|
151
|
+
if (isObject(pkg) && isObject(pkg["scripts"]) && typeof pkg["scripts"][target] === "string") {
|
|
152
|
+
return { file: `${prefix(project.root)}package.json`, executor: "nx:run-script", inputs: void 0 };
|
|
153
|
+
}
|
|
154
|
+
return void 0;
|
|
155
|
+
};
|
|
156
|
+
const ownTargets = [...projects.keys()].filter((name) => ownTarget(name) !== void 0).sort();
|
|
157
|
+
const resolveFor = (name) => {
|
|
158
|
+
const project = projects.get(name);
|
|
159
|
+
const own = ownTarget(name);
|
|
160
|
+
return resolveTargetDefaults(targetDefaults, target, {
|
|
161
|
+
executor: own === void 0 ? INFERRED_EXECUTOR : own.executor ?? (plugin === void 0 ? void 0 : INFERRED_EXECUTOR),
|
|
162
|
+
plugin: own === void 0 && plugin !== void 0 ? ESLINT_PLUGIN : void 0,
|
|
163
|
+
project: { name, root: project?.root ?? "", tags: project?.tags ?? [] }
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
const checked = input.fsdProjects.length > 0 ? input.fsdProjects : [""];
|
|
167
|
+
const resolved = checked.map((name) => ({ name, resolved: resolveFor(name), own: ownTarget(name) }));
|
|
168
|
+
const inputsOf = ({ resolved: r, own }) => own?.inputs ?? (r.kind === "found" ? r.inputs : void 0);
|
|
169
|
+
const listed = resolved.every((entry) => {
|
|
170
|
+
const inputs = inputsOf(entry);
|
|
171
|
+
return inputs !== void 0 && carries(inputs);
|
|
172
|
+
});
|
|
173
|
+
if (listed) return { action: "present", target };
|
|
174
|
+
const otherKey = resolved.map((entry) => entry.resolved).find((r) => r.kind !== "none" && r.key !== target);
|
|
175
|
+
const lintEntry = resolved.map((entry) => entry.resolved).find((r) => r.kind === "found" && r.key === target);
|
|
176
|
+
const defaultsInputs = lintEntry?.kind === "found" ? lintEntry.inputs : void 0;
|
|
177
|
+
const reason = !input.firstRun ? "not-first-run" : registrations.length === 0 ? "no-plugin" : registrations.length > 1 ? "several-plugins" : ownTargets.length > 0 ? "own-targets" : INFERRED_EXECUTOR in targetDefaults ? "run-commands-defaults" : lintDefaults.shape === "list" ? "list-defaults" : lintDefaults.shape === "other" ? "unreadable-defaults" : otherKey !== void 0 ? "other-key" : defaultsInputs !== void 0 ? "existing-inputs" : void 0;
|
|
178
|
+
if (reason === void 0) {
|
|
179
|
+
if (!input.dryRun) tree.write("nx.json", applyJsonEdits(raw, [[["targetDefaults", target, "inputs"], ["...", TOOLKIT_CONFIG_INPUT]]]));
|
|
180
|
+
return { action: "added", target };
|
|
181
|
+
}
|
|
182
|
+
const keyed = reason === "run-commands-defaults" ? INFERRED_EXECUTOR : otherKey?.key ?? INFERRED_EXECUTOR;
|
|
183
|
+
const keyedInputs = otherKey?.kind === "found" && otherKey.key === keyed ? otherKey.inputs !== void 0 : isObject(targetDefaults[keyed]) && Array.isArray(targetDefaults[keyed]["inputs"]);
|
|
184
|
+
const fsdProjects = input.fsdProjects.filter((name) => prefix(projects.get(name)?.root ?? "") !== "");
|
|
185
|
+
const snippet = reason === "existing-inputs" ? [`Add "${TOOLKIT_CONFIG_INPUT}" to targetDefaults["${target}"].inputs in nx.json.`] : reason === "run-commands-defaults" || reason === "other-key" ? lintInputsKeySnippet(keyed, target, keyedInputs) : plugin !== void 0 && ownTargets.length === 0 ? lintDefaults.shape === "list" ? lintInputsListSnippet(target) : lintDefaults.shape === "other" ? [`Replace targetDefaults["${target}"] in nx.json with an object, then:`, ...lintInputsTargetDefaultsSnippet(target)] : lintInputsTargetDefaultsSnippet(target) : fsdProjects.flatMap((name) => {
|
|
186
|
+
const root = projects.get(name)?.root ?? "";
|
|
187
|
+
const own = ownTarget(name);
|
|
188
|
+
return lintInputsProjectSnippet({
|
|
189
|
+
file: own?.file ?? projectFile(tree, root),
|
|
190
|
+
target,
|
|
191
|
+
ownInputs: own?.inputs !== void 0,
|
|
192
|
+
eslintConfigs: eslintConfigs(tree, root)
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
return {
|
|
196
|
+
action: "snippet",
|
|
197
|
+
target,
|
|
198
|
+
reason,
|
|
199
|
+
...reason === "own-targets" ? { ownTargets } : {},
|
|
200
|
+
...reason === "run-commands-defaults" || reason === "other-key" ? { key: keyed } : {},
|
|
201
|
+
snippet,
|
|
202
|
+
skipCache: fsdProjects.map((name) => `${input.runNx} ${target} ${name} --skip-nx-cache`)
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
function prefix(root) {
|
|
206
|
+
return root === "" || root === "." ? "" : `${root}/`;
|
|
207
|
+
}
|
|
208
|
+
function readJson(tree, path) {
|
|
209
|
+
const raw = tree.read(path, "utf-8");
|
|
210
|
+
return raw === null ? null : parse(raw, [], { allowTrailingComma: true });
|
|
211
|
+
}
|
|
212
|
+
function projectFile(tree, root) {
|
|
213
|
+
return tree.exists(`${prefix(root)}project.json`) ? `${prefix(root)}project.json` : `${prefix(root)}package.json`;
|
|
214
|
+
}
|
|
215
|
+
function eslintConfigs(tree, root) {
|
|
216
|
+
const own = ESLINT_CONFIG_CANDIDATES.find((name) => tree.exists(`${prefix(root)}${name}`));
|
|
217
|
+
const workspace = ESLINT_CONFIG_CANDIDATES.find((name) => tree.exists(name));
|
|
218
|
+
return [...own === void 0 || prefix(root) === "" ? [] : [`{projectRoot}/${own}`], ...workspace === void 0 ? [] : [`{workspaceRoot}/${workspace}`]];
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// src/generators/init/render.ts
|
|
222
|
+
var SECTION_TITLES = {
|
|
223
|
+
fsd: "add-fsd-lite",
|
|
224
|
+
agentRules: "add-agent-rules",
|
|
225
|
+
githubTemplates: "add-github-templates",
|
|
226
|
+
review: "add-review",
|
|
227
|
+
backend: "add-backend"
|
|
228
|
+
};
|
|
229
|
+
function renderSectionReport(report) {
|
|
230
|
+
switch (report.kind) {
|
|
231
|
+
case "fsd":
|
|
232
|
+
return renderAddFsdLiteReport(report.report);
|
|
233
|
+
case "agentRules":
|
|
234
|
+
return renderAddAgentRulesReport(report.report);
|
|
235
|
+
case "githubTemplates":
|
|
236
|
+
return renderAddGithubTemplatesReport(report.report);
|
|
237
|
+
case "review":
|
|
238
|
+
return renderAddReviewReport(report.report);
|
|
239
|
+
case "backend":
|
|
240
|
+
return renderAddBackendBody(report.report);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
function sectionAborted(section) {
|
|
244
|
+
if (section.thrownError !== void 0) return true;
|
|
245
|
+
if (section.report === null) return false;
|
|
246
|
+
if (section.report.kind === "fsd") return section.report.report.aborted;
|
|
247
|
+
if (section.report.kind === "review") return section.report.report.workflowAction === "aborted";
|
|
248
|
+
if (section.report.kind === "backend") return section.report.report.refused !== void 0;
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
function failedSections(report) {
|
|
252
|
+
const failed = report.sections.filter(sectionAborted).map((section) => SECTION_TITLES[section.id]);
|
|
253
|
+
return report.config?.action === "unrecognized" ? [...failed, "toolkit.config.json"] : failed;
|
|
254
|
+
}
|
|
255
|
+
function renderInitReport(report) {
|
|
256
|
+
const lines = [];
|
|
257
|
+
const backendSuffix = report.backend === "none" ? "" : `, backend: ${report.backend}`;
|
|
258
|
+
const header = `init (preset: ${report.preset}, frontend: ${report.frontend}${backendSuffix})`;
|
|
259
|
+
lines.push(report.dryRun ? `${header} \u2014 dry run` : header);
|
|
260
|
+
if (report.preset === "solo") {
|
|
261
|
+
lines.push("Note: solo is now an alias of quick-start \u2014 AI PR review stays off unless you pass --review.");
|
|
262
|
+
}
|
|
263
|
+
if (report.refused) {
|
|
264
|
+
lines.push("", ...renderRefusal(report.dirtyFiles));
|
|
265
|
+
return lines.join("\n");
|
|
266
|
+
}
|
|
267
|
+
for (const section of report.sections) {
|
|
268
|
+
if (section.id === "backend" && !section.enabled) continue;
|
|
269
|
+
lines.push("");
|
|
270
|
+
lines.push(`## ${SECTION_TITLES[section.id]}`);
|
|
271
|
+
if (!section.enabled) {
|
|
272
|
+
lines.push(
|
|
273
|
+
section.id === "fsd" && report.frontend === "none" ? " skipped (backend-only workspace \u2014 no frontend to structure)" : " skipped (disabled for this run)"
|
|
274
|
+
);
|
|
275
|
+
if (section.keptFiles !== void 0 && section.keptFiles.length > 0) {
|
|
276
|
+
lines.push(` Kept as they are: ${section.keptFiles.join(", ")}. To update them, run add-review.`);
|
|
277
|
+
}
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
if (section.thrownError !== void 0) {
|
|
281
|
+
lines.push(` aborted \u2014 unexpected error: ${section.thrownError}`);
|
|
282
|
+
lines.push(" Nothing was written for this section. Rerun add-fsd-lite directly once resolved.");
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
if (section.report !== null) {
|
|
286
|
+
lines.push(renderSectionReport(section.report));
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
if (report.config !== void 0 && (report.config.action !== "skipped" || report.config.notRecorded.length > 0)) {
|
|
290
|
+
lines.push("");
|
|
291
|
+
lines.push("## toolkit.config.json");
|
|
292
|
+
const fieldList = report.config.fields.join(", ");
|
|
293
|
+
switch (report.config.action) {
|
|
294
|
+
case "created":
|
|
295
|
+
case "updated":
|
|
296
|
+
lines.push(` ${report.dryRun ? "would record" : "recorded"} ${fieldList} (${report.config.action})`);
|
|
297
|
+
break;
|
|
298
|
+
case "unchanged":
|
|
299
|
+
lines.push(` already records ${fieldList} (unchanged)`);
|
|
300
|
+
break;
|
|
301
|
+
case "unrecognized":
|
|
302
|
+
lines.push(` aborted \u2014 the file is not a JSON object, so init left it alone (it never rewrites a shape it`);
|
|
303
|
+
lines.push(` does not recognize) and could not record ${fieldList}. The generators you run next read`);
|
|
304
|
+
lines.push(" them from here: make the file a JSON object (or delete it), then rerun init.");
|
|
305
|
+
break;
|
|
306
|
+
case "skipped":
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
if (report.config.notRecorded.length > 0) {
|
|
310
|
+
lines.push(` not recorded: ${report.config.notRecorded.map((n) => n.field).join(", ")} \u2014 that section did not apply cleanly`);
|
|
311
|
+
lines.push(" this run (aborted, or written as an alternate file). Once resolved, record it with:");
|
|
312
|
+
const runNx = report.runNx ?? runNxCommand(report.packageManager);
|
|
313
|
+
for (const entry of report.config.notRecorded) lines.push(` ${runNx} g @clearlydev/nx-archweave:${entry.rerun}`);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
if (report.lintInputs !== void 0) lines.push("", "## nx.json", ...renderLintInputs(report.lintInputs, report.dryRun));
|
|
317
|
+
const ranDirty = report.allowDirty === true && !report.cleanTree && !report.dryRun;
|
|
318
|
+
if (ranDirty && report.dirtyFromCaller !== true) {
|
|
319
|
+
lines.push("");
|
|
320
|
+
lines.push("Note: --allowDirty was set and the working tree already had uncommitted changes \u2014");
|
|
321
|
+
lines.push("restoring the files this run modified also reverts your earlier changes to them.");
|
|
322
|
+
}
|
|
323
|
+
const hadAbort = failedSections(report).length > 0;
|
|
324
|
+
if (!report.dryRun && hadAbort) {
|
|
325
|
+
lines.push("");
|
|
326
|
+
lines.push("One or more sections aborted. To undo what this run wrote:");
|
|
327
|
+
const written = report.written ?? { created: [], modified: [] };
|
|
328
|
+
if (written.modified.length > 0) {
|
|
329
|
+
lines.push(` git restore -- ${written.modified.join(" ")}`);
|
|
330
|
+
if (ranDirty) lines.push(" (--allowDirty: this also reverts the uncommitted changes those files already had.)");
|
|
331
|
+
}
|
|
332
|
+
if (written.created.length > 0) {
|
|
333
|
+
lines.push(" Created by this run (untracked \u2014 delete them yourself; `git clean -n` lists them):");
|
|
334
|
+
for (const path of written.created) lines.push(` ${path}`);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
lines.push(...renderLeftForYou(leftForYou(report)));
|
|
338
|
+
return lines.join("\n");
|
|
339
|
+
}
|
|
340
|
+
function renderLintInputs(outcome, dryRun) {
|
|
341
|
+
if (outcome.action === "present") return [` ${outcome.target} inputs already include toolkit.config.json`];
|
|
342
|
+
if (outcome.action === "added") {
|
|
343
|
+
return [
|
|
344
|
+
` ${dryRun ? "would add" : "added"} "{workspaceRoot}/toolkit.config.json" to targetDefaults.${outcome.target}.inputs, after "..." (which keeps`,
|
|
345
|
+
" the inputs @nx/eslint/plugin infers), so Nx re-runs lint after a change to the fsd policy"
|
|
346
|
+
];
|
|
347
|
+
}
|
|
348
|
+
const reason = {
|
|
349
|
+
"not-first-run": "init writes nx.json only when it sets a workspace up for the first time",
|
|
350
|
+
"no-plugin": "@nx/eslint/plugin is not registered, so targetDefaults would replace the lint targets' inputs",
|
|
351
|
+
"several-plugins": `@nx/eslint/plugin is registered more than once, so which ${outcome.target} targets it infers is up to each registration`,
|
|
352
|
+
"own-targets": `${(outcome.ownTargets ?? []).join(", ")} write their own ${outcome.target} target, which keeps only what targetDefaults lists`,
|
|
353
|
+
"run-commands-defaults": `targetDefaults["nx:run-commands"] comes before targetDefaults.${outcome.target} for the inferred ${outcome.target} targets`,
|
|
354
|
+
"other-key": `targetDefaults["${outcome.key ?? ""}"] is the entry Nx applies to ${outcome.target}, ahead of targetDefaults.${outcome.target}`,
|
|
355
|
+
"list-defaults": `targetDefaults.${outcome.target} is a list of entries, and the input belongs in each one that covers an FSD project`,
|
|
356
|
+
"unreadable-defaults": `targetDefaults.${outcome.target} is neither an object nor a list of entries`,
|
|
357
|
+
"existing-inputs": `targetDefaults already gives ${outcome.target} inputs of its own`
|
|
358
|
+
}[outcome.reason ?? "not-first-run"];
|
|
359
|
+
return [
|
|
360
|
+
" toolkit.config.json is not among lint's inputs, so Nx can replay a cached lint result after a change to the",
|
|
361
|
+
` fsd policy. Not written \u2014 ${reason}.`,
|
|
362
|
+
...(outcome.snippet ?? []).map((line) => ` ${line}`),
|
|
363
|
+
...(outcome.skipCache ?? []).length > 0 ? [` Or, after changing the fsd policy, check with: ${(outcome.skipCache ?? []).join(", ")}`] : []
|
|
364
|
+
];
|
|
365
|
+
}
|
|
366
|
+
var SHOWN_DIRTY_FILES = 20;
|
|
367
|
+
var LOCKFILES = /* @__PURE__ */ new Set(["pnpm-lock.yaml", "package-lock.json", "yarn.lock", "bun.lock", "bun.lockb"]);
|
|
368
|
+
function renderRefusal(dirtyFiles) {
|
|
369
|
+
const lines = ["Refused: the working tree has uncommitted changes."];
|
|
370
|
+
lines.push(" init only runs against a clean working tree, so a partial run can be rolled back exactly");
|
|
371
|
+
if (dirtyFiles === void 0 || dirtyFiles.length === 0) {
|
|
372
|
+
lines.push(" to what was committed \u2014 commit or stash your changes, then rerun.");
|
|
373
|
+
} else {
|
|
374
|
+
lines.push(" to what was committed. Uncommitted:");
|
|
375
|
+
for (const path of dirtyFiles.slice(0, SHOWN_DIRTY_FILES)) lines.push(` ${path}`);
|
|
376
|
+
if (dirtyFiles.length > SHOWN_DIRTY_FILES) lines.push(` \u2026 and ${dirtyFiles.length - SHOWN_DIRTY_FILES} more`);
|
|
377
|
+
const pluginInstall = dirtyFiles.includes("package.json") && dirtyFiles.every((path) => path === "package.json" || LOCKFILES.has(path));
|
|
378
|
+
if (pluginInstall) {
|
|
379
|
+
lines.push(" These are the plugin install. Commit them, then rerun init:");
|
|
380
|
+
lines.push(` git add ${dirtyFiles.join(" ")} && git commit -m "chore: add @clearlydev/nx-archweave"`);
|
|
381
|
+
} else {
|
|
382
|
+
lines.push(" Check them with `git status`, then commit or stash them, and rerun init.");
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
lines.push(" Or pass --allowDirty to run anyway: restoring a file this run modifies then also reverts");
|
|
386
|
+
lines.push(" the changes you had made to it.");
|
|
387
|
+
return lines;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
export {
|
|
391
|
+
leftForYou,
|
|
392
|
+
applyLintInputs,
|
|
393
|
+
failedSections,
|
|
394
|
+
renderInitReport,
|
|
395
|
+
renderLintInputs
|
|
396
|
+
};
|