@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
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
import {
|
|
2
|
+
renderAddAgentRulesReport
|
|
3
|
+
} from "./chunk-LJRFVE6B.js";
|
|
4
|
+
import {
|
|
5
|
+
renderAddReviewReport
|
|
6
|
+
} from "./chunk-WQDJYSOD.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
|
+
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
renderAddGithubTemplatesReport
|
|
3
|
+
} from "./chunk-FZGN5NEP.js";
|
|
1
4
|
import {
|
|
2
5
|
generatorFilesDir,
|
|
3
6
|
renderTemplateFiles
|
|
@@ -11,40 +14,10 @@ import {
|
|
|
11
14
|
import {
|
|
12
15
|
readToolkitConfig,
|
|
13
16
|
resolveLocaleOption
|
|
14
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-C2WELXMV.js";
|
|
15
18
|
|
|
16
19
|
// src/generators/add-github-templates/generator.ts
|
|
17
20
|
import { join } from "node:path";
|
|
18
|
-
|
|
19
|
-
// src/generators/add-github-templates/render.ts
|
|
20
|
-
var ACTION_LINES = {
|
|
21
|
-
created: "created",
|
|
22
|
-
unchanged: "unchanged (already matches the generated version)",
|
|
23
|
-
skipped: "left as-is (a different file already exists there \u2014 never overwritten)"
|
|
24
|
-
};
|
|
25
|
-
function renderAddGithubTemplatesReport(report) {
|
|
26
|
-
const lines = [];
|
|
27
|
-
if (report.files.length === 0) {
|
|
28
|
-
lines.push("add-github-templates: nothing selected (issue/pr/codeowners all false) \u2014 no files to install.");
|
|
29
|
-
return lines.join("\n");
|
|
30
|
-
}
|
|
31
|
-
if (report.dryRun) {
|
|
32
|
-
lines.push("add-github-templates dry-run \u2014 no files were written.");
|
|
33
|
-
lines.push("");
|
|
34
|
-
for (const file of report.files) {
|
|
35
|
-
lines.push(`${file.filePath}:`);
|
|
36
|
-
lines.push(file.content);
|
|
37
|
-
lines.push("");
|
|
38
|
-
}
|
|
39
|
-
lines.push("Effective decision:");
|
|
40
|
-
}
|
|
41
|
-
for (const file of report.files) {
|
|
42
|
-
lines.push(` ${file.filePath}: ${ACTION_LINES[file.action]}`);
|
|
43
|
-
}
|
|
44
|
-
return lines.join("\n");
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// src/generators/add-github-templates/generator.ts
|
|
48
21
|
var BUG_REPORT_PATH = ".github/ISSUE_TEMPLATE/bug-report.yml";
|
|
49
22
|
var FEATURE_REQUEST_PATH = ".github/ISSUE_TEMPLATE/feature-request.yml";
|
|
50
23
|
var PULL_REQUEST_TEMPLATE_PATH = ".github/PULL_REQUEST_TEMPLATE.md";
|
|
@@ -81,7 +54,6 @@ async function addGithubTemplatesGenerator(tree, options) {
|
|
|
81
54
|
var generator_default = addGithubTemplatesGenerator;
|
|
82
55
|
|
|
83
56
|
export {
|
|
84
|
-
renderAddGithubTemplatesReport,
|
|
85
57
|
BUG_REPORT_PATH,
|
|
86
58
|
FEATURE_REQUEST_PATH,
|
|
87
59
|
PULL_REQUEST_TEMPLATE_PATH,
|
|
@@ -2,13 +2,14 @@ import {
|
|
|
2
2
|
addAgentRulesGenerator,
|
|
3
3
|
generator_default,
|
|
4
4
|
runAddAgentRules
|
|
5
|
-
} from "../_chunks/chunk-
|
|
6
|
-
import "../_chunks/chunk-
|
|
5
|
+
} from "../_chunks/chunk-VI7U5HS5.js";
|
|
6
|
+
import "../_chunks/chunk-LJRFVE6B.js";
|
|
7
|
+
import "../_chunks/chunk-WQDJYSOD.js";
|
|
7
8
|
import "../_chunks/chunk-5MI3O4VZ.js";
|
|
8
9
|
import "../_chunks/chunk-6ZTIUBB2.js";
|
|
9
10
|
import "../_chunks/chunk-JPS6XKYK.js";
|
|
10
11
|
import "../_chunks/chunk-TUN34LAQ.js";
|
|
11
|
-
import "../_chunks/chunk-
|
|
12
|
+
import "../_chunks/chunk-C2WELXMV.js";
|
|
12
13
|
import "../_chunks/chunk-5Z7VZPES.js";
|
|
13
14
|
export {
|
|
14
15
|
addAgentRulesGenerator,
|
|
@@ -2,12 +2,13 @@ import {
|
|
|
2
2
|
addBackendGenerator,
|
|
3
3
|
generator_default,
|
|
4
4
|
runAddBackend
|
|
5
|
-
} from "../_chunks/chunk-
|
|
5
|
+
} from "../_chunks/chunk-7EDJKUY4.js";
|
|
6
|
+
import "../_chunks/chunk-SHKQSTV2.js";
|
|
6
7
|
import "../_chunks/chunk-WNO3ZGBB.js";
|
|
7
8
|
import "../_chunks/chunk-TXAQ2GJC.js";
|
|
8
9
|
import "../_chunks/chunk-6ZTIUBB2.js";
|
|
9
10
|
import "../_chunks/chunk-TUN34LAQ.js";
|
|
10
|
-
import "../_chunks/chunk-
|
|
11
|
+
import "../_chunks/chunk-C2WELXMV.js";
|
|
11
12
|
import "../_chunks/chunk-5Z7VZPES.js";
|
|
12
13
|
export {
|
|
13
14
|
addBackendGenerator,
|
|
@@ -2,15 +2,17 @@ import {
|
|
|
2
2
|
addFsdLiteGenerator,
|
|
3
3
|
generator_default,
|
|
4
4
|
runAddFsdLite
|
|
5
|
-
} from "../_chunks/chunk-
|
|
6
|
-
import "../_chunks/chunk-
|
|
7
|
-
import "../_chunks/chunk-
|
|
5
|
+
} from "../_chunks/chunk-VCLVE4EQ.js";
|
|
6
|
+
import "../_chunks/chunk-AMOOSD5Q.js";
|
|
7
|
+
import "../_chunks/chunk-XXXON43Z.js";
|
|
8
|
+
import "../_chunks/chunk-FBCIELXS.js";
|
|
9
|
+
import "../_chunks/chunk-YEMQFSL6.js";
|
|
8
10
|
import "../_chunks/chunk-TXAQ2GJC.js";
|
|
9
11
|
import "../_chunks/chunk-6ZTIUBB2.js";
|
|
10
12
|
import "../_chunks/chunk-JPS6XKYK.js";
|
|
11
13
|
import "../_chunks/chunk-TUN34LAQ.js";
|
|
12
|
-
import "../_chunks/chunk-
|
|
13
|
-
import "../_chunks/chunk-
|
|
14
|
+
import "../_chunks/chunk-23NN76E3.js";
|
|
15
|
+
import "../_chunks/chunk-C2WELXMV.js";
|
|
14
16
|
import "../_chunks/chunk-5Z7VZPES.js";
|
|
15
17
|
export {
|
|
16
18
|
addFsdLiteGenerator,
|
|
@@ -6,11 +6,12 @@ import {
|
|
|
6
6
|
addGithubTemplatesGenerator,
|
|
7
7
|
generator_default,
|
|
8
8
|
runAddGithubTemplates
|
|
9
|
-
} from "../_chunks/chunk-
|
|
9
|
+
} from "../_chunks/chunk-ZRHIFPUC.js";
|
|
10
|
+
import "../_chunks/chunk-FZGN5NEP.js";
|
|
10
11
|
import "../_chunks/chunk-YNMLB4DL.js";
|
|
11
12
|
import "../_chunks/chunk-JPS6XKYK.js";
|
|
12
13
|
import "../_chunks/chunk-TUN34LAQ.js";
|
|
13
|
-
import "../_chunks/chunk-
|
|
14
|
+
import "../_chunks/chunk-C2WELXMV.js";
|
|
14
15
|
import "../_chunks/chunk-5Z7VZPES.js";
|
|
15
16
|
export {
|
|
16
17
|
BUG_REPORT_PATH,
|
|
@@ -10,8 +10,8 @@ import {
|
|
|
10
10
|
import "../_chunks/chunk-34V6HAJT.js";
|
|
11
11
|
import {
|
|
12
12
|
diskRunNx
|
|
13
|
-
} from "../_chunks/chunk-
|
|
14
|
-
import "../_chunks/chunk-
|
|
13
|
+
} from "../_chunks/chunk-23NN76E3.js";
|
|
14
|
+
import "../_chunks/chunk-C2WELXMV.js";
|
|
15
15
|
import "../_chunks/chunk-5Z7VZPES.js";
|
|
16
16
|
|
|
17
17
|
// src/generators/add-integration/render.ts
|
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
generator_default,
|
|
4
4
|
recordedReview,
|
|
5
5
|
runAddReview
|
|
6
|
-
} from "../_chunks/chunk-
|
|
6
|
+
} from "../_chunks/chunk-OEEWCZCO.js";
|
|
7
7
|
import "../_chunks/chunk-2WXAGWAJ.js";
|
|
8
|
-
import "../_chunks/chunk-
|
|
8
|
+
import "../_chunks/chunk-WQDJYSOD.js";
|
|
9
9
|
import "../_chunks/chunk-YNMLB4DL.js";
|
|
10
10
|
import "../_chunks/chunk-JPS6XKYK.js";
|
|
11
11
|
import "../_chunks/chunk-TUN34LAQ.js";
|
|
12
|
-
import "../_chunks/chunk-
|
|
12
|
+
import "../_chunks/chunk-C2WELXMV.js";
|
|
13
13
|
import "../_chunks/chunk-5Z7VZPES.js";
|
|
14
14
|
export {
|
|
15
15
|
addReviewGenerator,
|