@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
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applyLintInputs,
|
|
3
|
+
failedSections,
|
|
4
|
+
leftForYou,
|
|
5
|
+
renderInitReport
|
|
6
|
+
} from "../_chunks/chunk-XSALM2IR.js";
|
|
1
7
|
import {
|
|
2
8
|
recordedReview,
|
|
3
9
|
runAddReview
|
|
4
|
-
} from "../_chunks/chunk-
|
|
10
|
+
} from "../_chunks/chunk-JNYQTW7S.js";
|
|
5
11
|
import "../_chunks/chunk-ASY3CK5L.js";
|
|
6
12
|
import {
|
|
7
13
|
DEFAULT_MAX_ROUNDS,
|
|
@@ -9,43 +15,36 @@ import {
|
|
|
9
15
|
buildReviewConfigSnippet
|
|
10
16
|
} from "../_chunks/chunk-2WXAGWAJ.js";
|
|
11
17
|
import {
|
|
12
|
-
renderAddAgentRulesReport,
|
|
13
18
|
runAddAgentRules
|
|
14
|
-
} from "../_chunks/chunk-
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
} from "../_chunks/chunk-E565RG2B.js";
|
|
19
|
+
} from "../_chunks/chunk-3HSNM6AS.js";
|
|
20
|
+
import "../_chunks/chunk-LJRFVE6B.js";
|
|
21
|
+
import "../_chunks/chunk-CSJZ4PP3.js";
|
|
18
22
|
import "../_chunks/chunk-5MI3O4VZ.js";
|
|
19
23
|
import {
|
|
20
|
-
renderAddBackendBody,
|
|
21
24
|
runAddBackend
|
|
22
|
-
} from "../_chunks/chunk-
|
|
25
|
+
} from "../_chunks/chunk-7EDJKUY4.js";
|
|
26
|
+
import "../_chunks/chunk-SHKQSTV2.js";
|
|
23
27
|
import "../_chunks/chunk-WNO3ZGBB.js";
|
|
24
28
|
import {
|
|
25
29
|
DEFAULT_CONFLICT_POLICY,
|
|
26
|
-
readTargetDefaults,
|
|
27
|
-
renderAddFsdLiteReport,
|
|
28
30
|
runAddFsdLite
|
|
29
|
-
} from "../_chunks/chunk-
|
|
30
|
-
import
|
|
31
|
-
|
|
32
|
-
lintInputsListSnippet,
|
|
33
|
-
lintInputsProjectSnippet,
|
|
34
|
-
lintInputsTargetDefaultsSnippet
|
|
35
|
-
} from "../_chunks/chunk-LBYZDAWS.js";
|
|
31
|
+
} from "../_chunks/chunk-VCLVE4EQ.js";
|
|
32
|
+
import "../_chunks/chunk-AMOOSD5Q.js";
|
|
33
|
+
import "../_chunks/chunk-XXXON43Z.js";
|
|
36
34
|
import {
|
|
37
|
-
allFrameworkProfiles,
|
|
38
35
|
resolveFrontendApp
|
|
39
|
-
} from "../_chunks/chunk-
|
|
36
|
+
} from "../_chunks/chunk-FBCIELXS.js";
|
|
37
|
+
import {
|
|
38
|
+
allFrameworkProfiles
|
|
39
|
+
} from "../_chunks/chunk-YEMQFSL6.js";
|
|
40
40
|
import "../_chunks/chunk-TXAQ2GJC.js";
|
|
41
41
|
import {
|
|
42
|
-
ESLINT_CONFIG_CANDIDATES,
|
|
43
42
|
readBoundaryTags
|
|
44
43
|
} from "../_chunks/chunk-6ZTIUBB2.js";
|
|
45
44
|
import {
|
|
46
|
-
renderAddGithubTemplatesReport,
|
|
47
45
|
runAddGithubTemplates
|
|
48
|
-
} from "../_chunks/chunk-
|
|
46
|
+
} from "../_chunks/chunk-ZRHIFPUC.js";
|
|
47
|
+
import "../_chunks/chunk-FZGN5NEP.js";
|
|
49
48
|
import "../_chunks/chunk-YNMLB4DL.js";
|
|
50
49
|
import "../_chunks/chunk-JPS6XKYK.js";
|
|
51
50
|
import {
|
|
@@ -54,7 +53,7 @@ import {
|
|
|
54
53
|
import {
|
|
55
54
|
spawnableCommand
|
|
56
55
|
} from "../_chunks/chunk-34V6HAJT.js";
|
|
57
|
-
import "../_chunks/chunk-
|
|
56
|
+
import "../_chunks/chunk-23NN76E3.js";
|
|
58
57
|
import {
|
|
59
58
|
DEFAULT_AI_HOSTS,
|
|
60
59
|
RECORDED_BACKENDS,
|
|
@@ -62,6 +61,7 @@ import {
|
|
|
62
61
|
RECORDED_PRESETS,
|
|
63
62
|
TOOLKIT_CONFIG_PATH,
|
|
64
63
|
applyJsonEdits,
|
|
64
|
+
messageOnlyError,
|
|
65
65
|
readToolkitConfigFile,
|
|
66
66
|
recordedChoice,
|
|
67
67
|
recordedFrontends,
|
|
@@ -70,9 +70,8 @@ import {
|
|
|
70
70
|
resolveLocaleOption,
|
|
71
71
|
reviewProviderFor,
|
|
72
72
|
treePackageManager
|
|
73
|
-
} from "../_chunks/chunk-
|
|
73
|
+
} from "../_chunks/chunk-C2WELXMV.js";
|
|
74
74
|
import {
|
|
75
|
-
packageManagerCommands,
|
|
76
75
|
runNxCommand
|
|
77
76
|
} from "../_chunks/chunk-5Z7VZPES.js";
|
|
78
77
|
|
|
@@ -152,336 +151,6 @@ function buildPresetConfig(input) {
|
|
|
152
151
|
};
|
|
153
152
|
}
|
|
154
153
|
|
|
155
|
-
// src/generators/init/left-for-you.ts
|
|
156
|
-
var PLUGIN = "@clearlydev/nx-archweave";
|
|
157
|
-
function leftForYou(report) {
|
|
158
|
-
const runNx = report.runNx ?? runNxCommand(report.packageManager);
|
|
159
|
-
const kept = [];
|
|
160
|
-
const manual = [];
|
|
161
|
-
for (const section of report.sections) {
|
|
162
|
-
if (!section.enabled || section.report === null) continue;
|
|
163
|
-
const sectionReport = section.report;
|
|
164
|
-
switch (sectionReport.kind) {
|
|
165
|
-
case "fsd": {
|
|
166
|
-
const fsd = sectionReport.report;
|
|
167
|
-
if (fsd.aborted) break;
|
|
168
|
-
if (fsd.eslint === "degraded-unrecognized") {
|
|
169
|
-
manual.push(
|
|
170
|
-
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)`
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
const steiger = fsd.steiger;
|
|
174
|
-
if (steiger !== null) {
|
|
175
|
-
if (steiger.config === "kept") kept.push(`${steiger.configPath}: an existing steiger config with other content \u2014 left as it is`);
|
|
176
|
-
if (steiger.target === "unrecognized") manual.push(`${fsd.project ?? "the app"}: add the fsd-check target yourself (no parseable project.json or package.json)`);
|
|
177
|
-
if (steiger.dependencies === "unrecognized") {
|
|
178
|
-
manual.push("package.json: could not be parsed \u2014 add steiger and @feature-sliced/steiger-plugin to devDependencies yourself");
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
break;
|
|
182
|
-
}
|
|
183
|
-
case "agentRules":
|
|
184
|
-
for (const file of sectionReport.report.files) {
|
|
185
|
-
if (file.action === "user-modified") {
|
|
186
|
-
kept.push(`${file.filePath}: its nx-archweave block was edited by hand \u2014 to replace it: ${runNx} g ${PLUGIN}:add-agent-rules --overwriteBlock`);
|
|
187
|
-
} else if (file.action === "unrecognized") {
|
|
188
|
-
kept.push(`${file.filePath}: left untouched (${file.reason ?? "its nx-archweave markers could not be placed"}) \u2014 fix the file, then rerun init`);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
break;
|
|
192
|
-
case "githubTemplates":
|
|
193
|
-
for (const file of sectionReport.report.files) {
|
|
194
|
-
if (file.action === "skipped") {
|
|
195
|
-
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`);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
break;
|
|
199
|
-
case "review": {
|
|
200
|
-
const review = sectionReport.report;
|
|
201
|
-
if (review.workflowAction === "aborted") break;
|
|
202
|
-
if (review.workflowAction === "proposed" || review.workflowAction === "skipped") {
|
|
203
|
-
kept.push(`${review.workflowPath}: differs from the generated workflow \u2014 to replace it: ${runNx} g ${PLUGIN}:add-review --onConflict=overwrite`);
|
|
204
|
-
} else if (review.workflowAction === "alternate") {
|
|
205
|
-
manual.push(`${review.workflowPath}: written alongside the existing workflow \u2014 replace the main workflow file with it yourself`);
|
|
206
|
-
}
|
|
207
|
-
if (review.dependabot === "proposed") manual.push(".github/dependabot.yml: add the github-actions entry shown above");
|
|
208
|
-
break;
|
|
209
|
-
}
|
|
210
|
-
case "backend": {
|
|
211
|
-
const backend = sectionReport.report;
|
|
212
|
-
if (backend.refused !== void 0) break;
|
|
213
|
-
if (backend.eslint === "degraded-unrecognized") manual.push("ESLint boundaries: your config was not recognized \u2014 merge the constraints shown above yourself");
|
|
214
|
-
if (backend.tsconfigPaths === "unrecognized") {
|
|
215
|
-
manual.push(`tsconfig.base.json: could not be parsed \u2014 add the ${backend.sharedTypesPackage ?? "shared-types"} path yourself`);
|
|
216
|
-
}
|
|
217
|
-
const linkedByPaths = backend.tsconfigPaths === "added" || backend.tsconfigPaths === "present";
|
|
218
|
-
if (backend.workspaceGlob === "unrecognized" && !linkedByPaths) {
|
|
219
|
-
const registry = packageManagerCommands(backend.packageManager ?? "pnpm").workspaceRegistration;
|
|
220
|
-
manual.push(`${registry}: shape not recognized \u2014 add '${backend.sharedTypesRoot ?? "libs/shared-types"}' to its workspace list yourself`);
|
|
221
|
-
}
|
|
222
|
-
break;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
return { kept, manual };
|
|
227
|
-
}
|
|
228
|
-
function renderLeftForYou(left) {
|
|
229
|
-
const lines = [];
|
|
230
|
-
if (left.kept.length > 0) {
|
|
231
|
-
lines.push("", "Skipped to keep your changes:", ...left.kept.map((item) => ` ${item}`));
|
|
232
|
-
}
|
|
233
|
-
if (left.manual.length > 0) {
|
|
234
|
-
lines.push("", "Needs a manual step:", ...left.manual.map((item) => ` ${item}`));
|
|
235
|
-
}
|
|
236
|
-
return lines;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// src/generators/init/lint-inputs.ts
|
|
240
|
-
import { getProjects } from "@nx/devkit";
|
|
241
|
-
import { parse } from "jsonc-parser";
|
|
242
|
-
var ESLINT_PLUGIN = "@nx/eslint/plugin";
|
|
243
|
-
var ESLINT_EXECUTOR = "@nx/eslint:lint";
|
|
244
|
-
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
245
|
-
function applyLintInputs(tree, input) {
|
|
246
|
-
const raw = tree.read("nx.json", "utf-8");
|
|
247
|
-
if (raw === null) return void 0;
|
|
248
|
-
const nxJson = parse(raw, [], { allowTrailingComma: true });
|
|
249
|
-
if (!isObject(nxJson)) return void 0;
|
|
250
|
-
const plugins = Array.isArray(nxJson["plugins"]) ? nxJson["plugins"] : [];
|
|
251
|
-
const plugin = plugins.find((entry) => entry === ESLINT_PLUGIN || isObject(entry) && entry["plugin"] === ESLINT_PLUGIN);
|
|
252
|
-
const options = isObject(plugin) && isObject(plugin["options"]) ? plugin["options"] : {};
|
|
253
|
-
const target = typeof options["targetName"] === "string" ? options["targetName"] : "lint";
|
|
254
|
-
const targetDefaults = isObject(nxJson["targetDefaults"]) ? nxJson["targetDefaults"] : {};
|
|
255
|
-
const namedInputs = isObject(nxJson["namedInputs"]) ? nxJson["namedInputs"] : {};
|
|
256
|
-
const defaultsKey = [target, ESLINT_EXECUTOR].find((key) => isObject(targetDefaults[key]) && Array.isArray(targetDefaults[key]["inputs"]));
|
|
257
|
-
const defaultsInputs = defaultsKey === void 0 ? void 0 : targetDefaults[defaultsKey]["inputs"];
|
|
258
|
-
const carries = (inputs) => inputs.some((entry) => {
|
|
259
|
-
if (entry === TOOLKIT_CONFIG_INPUT) return true;
|
|
260
|
-
const named = typeof entry === "string" ? namedInputs[entry.replace(/^\^/, "")] : void 0;
|
|
261
|
-
return Array.isArray(named) && named.includes(TOOLKIT_CONFIG_INPUT);
|
|
262
|
-
});
|
|
263
|
-
if (defaultsInputs !== void 0 && carries(defaultsInputs)) return { action: "present", target };
|
|
264
|
-
const lintDefaults = readTargetDefaults(targetDefaults, target);
|
|
265
|
-
if (lintDefaults.shape === "list" && lintDefaults.entries.length > 0 && lintDefaults.entries.every((entry) => entry.inputs !== void 0 && carries(entry.inputs))) {
|
|
266
|
-
return { action: "present", target };
|
|
267
|
-
}
|
|
268
|
-
const projects = getProjects(tree);
|
|
269
|
-
const ownTarget = (name) => {
|
|
270
|
-
const project = projects.get(name);
|
|
271
|
-
if (project === void 0) return void 0;
|
|
272
|
-
if (isObject(project.targets?.[target])) return { file: projectFile(tree, project.root), inputs: project.targets?.[target]?.inputs };
|
|
273
|
-
const pkg = readJson(tree, `${prefix(project.root)}package.json`);
|
|
274
|
-
if (isObject(pkg) && isObject(pkg["scripts"]) && typeof pkg["scripts"][target] === "string") return { file: `${prefix(project.root)}package.json`, inputs: void 0 };
|
|
275
|
-
return void 0;
|
|
276
|
-
};
|
|
277
|
-
const ownTargets = [...projects.keys()].filter((name) => ownTarget(name) !== void 0).sort();
|
|
278
|
-
const reason = !input.firstRun ? "not-first-run" : plugin === void 0 ? "no-plugin" : ownTargets.length > 0 ? "own-targets" : lintDefaults.shape === "list" ? "list-defaults" : lintDefaults.shape === "other" ? "unreadable-defaults" : defaultsInputs !== void 0 ? "existing-inputs" : void 0;
|
|
279
|
-
if (reason === void 0) {
|
|
280
|
-
if (!input.dryRun) tree.write("nx.json", applyJsonEdits(raw, [[["targetDefaults", target, "inputs"], ["...", TOOLKIT_CONFIG_INPUT]]]));
|
|
281
|
-
return { action: "added", target };
|
|
282
|
-
}
|
|
283
|
-
const fsdProjects = input.fsdProjects.filter((name) => prefix(projects.get(name)?.root ?? "") !== "");
|
|
284
|
-
const snippet = reason === "existing-inputs" && defaultsKey !== void 0 ? [`Add "${TOOLKIT_CONFIG_INPUT}" to targetDefaults["${defaultsKey}"].inputs in nx.json.`] : 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) => {
|
|
285
|
-
const root = projects.get(name)?.root ?? "";
|
|
286
|
-
const own = ownTarget(name);
|
|
287
|
-
return lintInputsProjectSnippet({
|
|
288
|
-
file: own?.file ?? projectFile(tree, root),
|
|
289
|
-
target,
|
|
290
|
-
ownInputs: own?.inputs !== void 0,
|
|
291
|
-
eslintConfigs: eslintConfigs(tree, root)
|
|
292
|
-
});
|
|
293
|
-
});
|
|
294
|
-
return {
|
|
295
|
-
action: "snippet",
|
|
296
|
-
target,
|
|
297
|
-
reason,
|
|
298
|
-
...reason === "own-targets" ? { ownTargets } : {},
|
|
299
|
-
snippet,
|
|
300
|
-
skipCache: fsdProjects.map((name) => `${input.runNx} ${target} ${name} --skip-nx-cache`)
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
function prefix(root) {
|
|
304
|
-
return root === "" || root === "." ? "" : `${root}/`;
|
|
305
|
-
}
|
|
306
|
-
function readJson(tree, path) {
|
|
307
|
-
const raw = tree.read(path, "utf-8");
|
|
308
|
-
return raw === null ? null : parse(raw, [], { allowTrailingComma: true });
|
|
309
|
-
}
|
|
310
|
-
function projectFile(tree, root) {
|
|
311
|
-
return tree.exists(`${prefix(root)}project.json`) ? `${prefix(root)}project.json` : `${prefix(root)}package.json`;
|
|
312
|
-
}
|
|
313
|
-
function eslintConfigs(tree, root) {
|
|
314
|
-
const own = ESLINT_CONFIG_CANDIDATES.find((name) => tree.exists(`${prefix(root)}${name}`));
|
|
315
|
-
const workspace = ESLINT_CONFIG_CANDIDATES.find((name) => tree.exists(name));
|
|
316
|
-
return [...own === void 0 || prefix(root) === "" ? [] : [`{projectRoot}/${own}`], ...workspace === void 0 ? [] : [`{workspaceRoot}/${workspace}`]];
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
// src/generators/init/render.ts
|
|
320
|
-
var SECTION_TITLES = {
|
|
321
|
-
fsd: "add-fsd-lite",
|
|
322
|
-
agentRules: "add-agent-rules",
|
|
323
|
-
githubTemplates: "add-github-templates",
|
|
324
|
-
review: "add-review",
|
|
325
|
-
backend: "add-backend"
|
|
326
|
-
};
|
|
327
|
-
function renderSectionReport(report) {
|
|
328
|
-
switch (report.kind) {
|
|
329
|
-
case "fsd":
|
|
330
|
-
return renderAddFsdLiteReport(report.report);
|
|
331
|
-
case "agentRules":
|
|
332
|
-
return renderAddAgentRulesReport(report.report);
|
|
333
|
-
case "githubTemplates":
|
|
334
|
-
return renderAddGithubTemplatesReport(report.report);
|
|
335
|
-
case "review":
|
|
336
|
-
return renderAddReviewReport(report.report);
|
|
337
|
-
case "backend":
|
|
338
|
-
return renderAddBackendBody(report.report);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
function sectionAborted(section) {
|
|
342
|
-
if (section.thrownError !== void 0) return true;
|
|
343
|
-
if (section.report === null) return false;
|
|
344
|
-
if (section.report.kind === "fsd") return section.report.report.aborted;
|
|
345
|
-
if (section.report.kind === "review") return section.report.report.workflowAction === "aborted";
|
|
346
|
-
if (section.report.kind === "backend") return section.report.report.refused !== void 0;
|
|
347
|
-
return false;
|
|
348
|
-
}
|
|
349
|
-
function failedSections(report) {
|
|
350
|
-
const failed = report.sections.filter(sectionAborted).map((section) => SECTION_TITLES[section.id]);
|
|
351
|
-
return report.config?.action === "unrecognized" ? [...failed, "toolkit.config.json"] : failed;
|
|
352
|
-
}
|
|
353
|
-
function renderInitReport(report) {
|
|
354
|
-
const lines = [];
|
|
355
|
-
const backendSuffix = report.backend === "none" ? "" : `, backend: ${report.backend}`;
|
|
356
|
-
const header = `init (preset: ${report.preset}, frontend: ${report.frontend}${backendSuffix})`;
|
|
357
|
-
lines.push(report.dryRun ? `${header} \u2014 dry run` : header);
|
|
358
|
-
if (report.preset === "solo") {
|
|
359
|
-
lines.push("Note: solo is now an alias of quick-start \u2014 AI PR review stays off unless you pass --review.");
|
|
360
|
-
}
|
|
361
|
-
if (report.refused) {
|
|
362
|
-
lines.push("", ...renderRefusal(report.dirtyFiles));
|
|
363
|
-
return lines.join("\n");
|
|
364
|
-
}
|
|
365
|
-
for (const section of report.sections) {
|
|
366
|
-
if (section.id === "backend" && !section.enabled) continue;
|
|
367
|
-
lines.push("");
|
|
368
|
-
lines.push(`## ${SECTION_TITLES[section.id]}`);
|
|
369
|
-
if (!section.enabled) {
|
|
370
|
-
lines.push(
|
|
371
|
-
section.id === "fsd" && report.frontend === "none" ? " skipped (backend-only workspace \u2014 no frontend to structure)" : " skipped (disabled for this run)"
|
|
372
|
-
);
|
|
373
|
-
if (section.keptFiles !== void 0 && section.keptFiles.length > 0) {
|
|
374
|
-
lines.push(` Kept as they are: ${section.keptFiles.join(", ")}. To update them, run add-review.`);
|
|
375
|
-
}
|
|
376
|
-
continue;
|
|
377
|
-
}
|
|
378
|
-
if (section.thrownError !== void 0) {
|
|
379
|
-
lines.push(` aborted \u2014 unexpected error: ${section.thrownError}`);
|
|
380
|
-
lines.push(" Nothing was written for this section. Rerun add-fsd-lite directly once resolved.");
|
|
381
|
-
continue;
|
|
382
|
-
}
|
|
383
|
-
if (section.report !== null) {
|
|
384
|
-
lines.push(renderSectionReport(section.report));
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
if (report.config !== void 0 && (report.config.action !== "skipped" || report.config.notRecorded.length > 0)) {
|
|
388
|
-
lines.push("");
|
|
389
|
-
lines.push("## toolkit.config.json");
|
|
390
|
-
const fieldList = report.config.fields.join(", ");
|
|
391
|
-
switch (report.config.action) {
|
|
392
|
-
case "created":
|
|
393
|
-
case "updated":
|
|
394
|
-
lines.push(` ${report.dryRun ? "would record" : "recorded"} ${fieldList} (${report.config.action})`);
|
|
395
|
-
break;
|
|
396
|
-
case "unchanged":
|
|
397
|
-
lines.push(` already records ${fieldList} (unchanged)`);
|
|
398
|
-
break;
|
|
399
|
-
case "unrecognized":
|
|
400
|
-
lines.push(` aborted \u2014 the file is not a JSON object, so init left it alone (it never rewrites a shape it`);
|
|
401
|
-
lines.push(` does not recognize) and could not record ${fieldList}. The generators you run next read`);
|
|
402
|
-
lines.push(" them from here: make the file a JSON object (or delete it), then rerun init.");
|
|
403
|
-
break;
|
|
404
|
-
case "skipped":
|
|
405
|
-
break;
|
|
406
|
-
}
|
|
407
|
-
if (report.config.notRecorded.length > 0) {
|
|
408
|
-
lines.push(` not recorded: ${report.config.notRecorded.map((n) => n.field).join(", ")} \u2014 that section did not apply cleanly`);
|
|
409
|
-
lines.push(" this run (aborted, or written as an alternate file). Once resolved, record it with:");
|
|
410
|
-
const runNx = report.runNx ?? runNxCommand(report.packageManager);
|
|
411
|
-
for (const entry of report.config.notRecorded) lines.push(` ${runNx} g @clearlydev/nx-archweave:${entry.rerun}`);
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
if (report.lintInputs !== void 0) lines.push("", "## nx.json", ...renderLintInputs(report.lintInputs, report.dryRun));
|
|
415
|
-
const ranDirty = report.allowDirty === true && !report.cleanTree && !report.dryRun;
|
|
416
|
-
if (ranDirty && report.dirtyFromCaller !== true) {
|
|
417
|
-
lines.push("");
|
|
418
|
-
lines.push("Note: --allowDirty was set and the working tree already had uncommitted changes \u2014");
|
|
419
|
-
lines.push("restoring the files this run modified also reverts your earlier changes to them.");
|
|
420
|
-
}
|
|
421
|
-
const hadAbort = failedSections(report).length > 0;
|
|
422
|
-
if (!report.dryRun && hadAbort) {
|
|
423
|
-
lines.push("");
|
|
424
|
-
lines.push("One or more sections aborted. To undo what this run wrote:");
|
|
425
|
-
const written = report.written ?? { created: [], modified: [] };
|
|
426
|
-
if (written.modified.length > 0) {
|
|
427
|
-
lines.push(` git restore -- ${written.modified.join(" ")}`);
|
|
428
|
-
if (ranDirty) lines.push(" (--allowDirty: this also reverts the uncommitted changes those files already had.)");
|
|
429
|
-
}
|
|
430
|
-
if (written.created.length > 0) {
|
|
431
|
-
lines.push(" Created by this run (untracked \u2014 delete them yourself; `git clean -n` lists them):");
|
|
432
|
-
for (const path of written.created) lines.push(` ${path}`);
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
lines.push(...renderLeftForYou(leftForYou(report)));
|
|
436
|
-
return lines.join("\n");
|
|
437
|
-
}
|
|
438
|
-
function renderLintInputs(outcome, dryRun) {
|
|
439
|
-
if (outcome.action === "present") return [` ${outcome.target} inputs already include toolkit.config.json`];
|
|
440
|
-
if (outcome.action === "added") {
|
|
441
|
-
return [
|
|
442
|
-
` ${dryRun ? "would add" : "added"} "{workspaceRoot}/toolkit.config.json" to targetDefaults.${outcome.target}.inputs, after "..." (which keeps`,
|
|
443
|
-
" the inputs @nx/eslint/plugin infers), so Nx re-runs lint after a change to the fsd policy"
|
|
444
|
-
];
|
|
445
|
-
}
|
|
446
|
-
const reason = {
|
|
447
|
-
"not-first-run": "init writes nx.json only when it sets a workspace up for the first time",
|
|
448
|
-
"no-plugin": "@nx/eslint/plugin is not registered, so targetDefaults would replace the lint targets' inputs",
|
|
449
|
-
"own-targets": `${(outcome.ownTargets ?? []).join(", ")} write their own ${outcome.target} target, which keeps only what targetDefaults lists`,
|
|
450
|
-
"list-defaults": `targetDefaults.${outcome.target} is a list of entries, and the input belongs in each one that covers an FSD project`,
|
|
451
|
-
"unreadable-defaults": `targetDefaults.${outcome.target} is neither an object nor a list of entries`,
|
|
452
|
-
"existing-inputs": `targetDefaults already gives ${outcome.target} inputs of its own`
|
|
453
|
-
}[outcome.reason ?? "not-first-run"];
|
|
454
|
-
return [
|
|
455
|
-
" toolkit.config.json is not among lint's inputs, so Nx can replay a cached lint result after a change to the",
|
|
456
|
-
` fsd policy. Not written \u2014 ${reason}.`,
|
|
457
|
-
...(outcome.snippet ?? []).map((line) => ` ${line}`),
|
|
458
|
-
...(outcome.skipCache ?? []).length > 0 ? [` Or, after changing the fsd policy, check with: ${(outcome.skipCache ?? []).join(", ")}`] : []
|
|
459
|
-
];
|
|
460
|
-
}
|
|
461
|
-
var SHOWN_DIRTY_FILES = 20;
|
|
462
|
-
var LOCKFILES = /* @__PURE__ */ new Set(["pnpm-lock.yaml", "package-lock.json", "yarn.lock", "bun.lock", "bun.lockb"]);
|
|
463
|
-
function renderRefusal(dirtyFiles) {
|
|
464
|
-
const lines = ["Refused: the working tree has uncommitted changes."];
|
|
465
|
-
lines.push(" init only runs against a clean working tree, so a partial run can be rolled back exactly");
|
|
466
|
-
if (dirtyFiles === void 0 || dirtyFiles.length === 0) {
|
|
467
|
-
lines.push(" to what was committed \u2014 commit or stash your changes, then rerun.");
|
|
468
|
-
} else {
|
|
469
|
-
lines.push(" to what was committed. Uncommitted:");
|
|
470
|
-
for (const path of dirtyFiles.slice(0, SHOWN_DIRTY_FILES)) lines.push(` ${path}`);
|
|
471
|
-
if (dirtyFiles.length > SHOWN_DIRTY_FILES) lines.push(` \u2026 and ${dirtyFiles.length - SHOWN_DIRTY_FILES} more`);
|
|
472
|
-
const pluginInstall = dirtyFiles.includes("package.json") && dirtyFiles.every((path) => path === "package.json" || LOCKFILES.has(path));
|
|
473
|
-
if (pluginInstall) {
|
|
474
|
-
lines.push(" These are the plugin install. Commit them, then rerun init:");
|
|
475
|
-
lines.push(` git add ${dirtyFiles.join(" ")} && git commit -m "chore: add @clearlydev/nx-archweave"`);
|
|
476
|
-
} else {
|
|
477
|
-
lines.push(" Check them with `git status`, then commit or stash them, and rerun init.");
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
lines.push(" Or pass --allowDirty to run anyway: restoring a file this run modifies then also reverts");
|
|
481
|
-
lines.push(" the changes you had made to it.");
|
|
482
|
-
return lines;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
154
|
// src/generators/init/validation.ts
|
|
486
155
|
import { spawnSync } from "node:child_process";
|
|
487
156
|
function createProcessExec() {
|
|
@@ -554,15 +223,15 @@ function recordPresetChoices(tree, choices, notRecorded, write) {
|
|
|
554
223
|
const { raw, parsed } = readToolkitConfigFile(tree);
|
|
555
224
|
if (raw !== null && parsed === null) return { action: "unrecognized", fields, notRecorded };
|
|
556
225
|
const existing = parsed ?? {};
|
|
557
|
-
const
|
|
226
|
+
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
558
227
|
const edits = [];
|
|
559
228
|
for (const key of topLevel) {
|
|
560
229
|
if (existing[key] !== choices[key]) edits.push([[key], choices[key]]);
|
|
561
230
|
}
|
|
562
231
|
const nested = (parent, key, value) => {
|
|
563
232
|
const holder = existing[parent];
|
|
564
|
-
if (
|
|
565
|
-
edits.push(
|
|
233
|
+
if (isObject(holder) && holder[key] === value) return;
|
|
234
|
+
edits.push(isObject(holder) ? [[parent, key], value] : [[parent], { [key]: value }]);
|
|
566
235
|
};
|
|
567
236
|
if (choices.enforcement !== void 0) nested("fsd", "enforcement", choices.enforcement);
|
|
568
237
|
if (choices.teamRules !== void 0) nested("agentRules", "teamRules", choices.teamRules);
|
|
@@ -610,14 +279,14 @@ function runInit(tree, options, deps) {
|
|
|
610
279
|
const recorded = readToolkitConfigFile(tree).parsed;
|
|
611
280
|
const preset = options.preset ?? recordedChoice(recorded, "preset", RECORDED_PRESETS);
|
|
612
281
|
if (preset === void 0) {
|
|
613
|
-
throw
|
|
282
|
+
throw messageOnlyError("init: pass --preset=quick-start|solo|team (toolkit.config.json records none).");
|
|
614
283
|
}
|
|
615
284
|
const app = options.frontend === void 0 && recordedChoice(recorded, "frontend", RECORDED_FRONTENDS) === void 0 ? resolveFrontendApp(tree, void 0) : null;
|
|
616
285
|
const detected = app?.kind === "found" && app.framework !== "generic" ? app.framework : void 0;
|
|
617
286
|
const frontend = resolveInitFrontend(options.frontend ?? detected, recorded);
|
|
618
287
|
const backend = options.backend ?? recordedChoice(recorded, "backend", RECORDED_BACKENDS) ?? "none";
|
|
619
288
|
if (frontend === "none" && backend === "none") {
|
|
620
|
-
throw
|
|
289
|
+
throw messageOnlyError("init: --frontend=none is a backend-only workspace \u2014 pass --backend=express|nest.");
|
|
621
290
|
}
|
|
622
291
|
const dryRun = options.dryRun ?? false;
|
|
623
292
|
const locale = resolveLocaleOption(options.locale, recorded);
|
|
@@ -726,7 +395,8 @@ function runInit(tree, options, deps) {
|
|
|
726
395
|
dryRun,
|
|
727
396
|
// The first AI host's provider — buildPresetConfig
|
|
728
397
|
// resolved it; claude when no host was picked.
|
|
729
|
-
provider: config.review.provider
|
|
398
|
+
provider: config.review.provider,
|
|
399
|
+
...options.dependabot !== void 0 ? { dependabot: options.dependabot } : {}
|
|
730
400
|
});
|
|
731
401
|
sections.push({ id: "review", enabled: true, report: { kind: "review", report } });
|
|
732
402
|
} else {
|
|
@@ -828,11 +498,6 @@ function initFailure(report, strict) {
|
|
|
828
498
|
const count = left.kept.length + left.manual.length;
|
|
829
499
|
return count === 0 ? null : `init --strict: init couldn't do everything you asked for (${count} ${count === 1 ? "item" : "items"}) \u2014 see the report above.`;
|
|
830
500
|
}
|
|
831
|
-
function reportedFailure(message) {
|
|
832
|
-
const error = new Error(message);
|
|
833
|
-
error.stack = "";
|
|
834
|
-
return error;
|
|
835
|
-
}
|
|
836
501
|
function collectWrittenWorkflowPaths(report) {
|
|
837
502
|
const paths = [];
|
|
838
503
|
for (const section of report.sections) {
|
|
@@ -849,7 +514,7 @@ async function initGenerator(tree, options, deps = { workingTreeChanges: gitWork
|
|
|
849
514
|
const report = runInit(tree, { ...options, dryRun: resolveDryRun(options) }, deps);
|
|
850
515
|
console.log(renderInitReport(report));
|
|
851
516
|
const message = initFailure(report, options.strict === true);
|
|
852
|
-
const failure = message === null ? null :
|
|
517
|
+
const failure = message === null ? null : messageOnlyError(message);
|
|
853
518
|
if (failure !== null && (report.dryRun || report.refused)) throw failure;
|
|
854
519
|
if (report.dryRun || report.refused) return;
|
|
855
520
|
const wrote = tree.listChanges().length !== changesBefore;
|
|
@@ -18,8 +18,8 @@ import {
|
|
|
18
18
|
import "../_chunks/chunk-34V6HAJT.js";
|
|
19
19
|
import {
|
|
20
20
|
diskRunNx
|
|
21
|
-
} from "../_chunks/chunk-
|
|
22
|
-
import "../_chunks/chunk-
|
|
21
|
+
} from "../_chunks/chunk-23NN76E3.js";
|
|
22
|
+
import "../_chunks/chunk-C2WELXMV.js";
|
|
23
23
|
import "../_chunks/chunk-5Z7VZPES.js";
|
|
24
24
|
|
|
25
25
|
// ../integrations/dist/config/declare-enabled-integration.js
|
|
@@ -3,8 +3,9 @@ import {
|
|
|
3
3
|
} from "../_chunks/chunk-H222FPLK.js";
|
|
4
4
|
import {
|
|
5
5
|
runFsdSlice
|
|
6
|
-
} from "../_chunks/chunk-
|
|
7
|
-
import "../_chunks/chunk-
|
|
6
|
+
} from "../_chunks/chunk-M7UBCSYL.js";
|
|
7
|
+
import "../_chunks/chunk-FBCIELXS.js";
|
|
8
|
+
import "../_chunks/chunk-YEMQFSL6.js";
|
|
8
9
|
import "../_chunks/chunk-TXAQ2GJC.js";
|
|
9
10
|
import "../_chunks/chunk-6ZTIUBB2.js";
|
|
10
11
|
import "../_chunks/chunk-YNMLB4DL.js";
|
|
@@ -12,7 +13,7 @@ import "../_chunks/chunk-JPS6XKYK.js";
|
|
|
12
13
|
import {
|
|
13
14
|
resolveDryRun
|
|
14
15
|
} from "../_chunks/chunk-TUN34LAQ.js";
|
|
15
|
-
import "../_chunks/chunk-
|
|
16
|
+
import "../_chunks/chunk-C2WELXMV.js";
|
|
16
17
|
import "../_chunks/chunk-5Z7VZPES.js";
|
|
17
18
|
|
|
18
19
|
// src/generators/page/generator.ts
|
|
@@ -3,8 +3,9 @@ import {
|
|
|
3
3
|
} from "../_chunks/chunk-H222FPLK.js";
|
|
4
4
|
import {
|
|
5
5
|
runFsdSlice
|
|
6
|
-
} from "../_chunks/chunk-
|
|
7
|
-
import "../_chunks/chunk-
|
|
6
|
+
} from "../_chunks/chunk-M7UBCSYL.js";
|
|
7
|
+
import "../_chunks/chunk-FBCIELXS.js";
|
|
8
|
+
import "../_chunks/chunk-YEMQFSL6.js";
|
|
8
9
|
import "../_chunks/chunk-TXAQ2GJC.js";
|
|
9
10
|
import "../_chunks/chunk-6ZTIUBB2.js";
|
|
10
11
|
import "../_chunks/chunk-YNMLB4DL.js";
|
|
@@ -12,7 +13,7 @@ import "../_chunks/chunk-JPS6XKYK.js";
|
|
|
12
13
|
import {
|
|
13
14
|
resolveDryRun
|
|
14
15
|
} from "../_chunks/chunk-TUN34LAQ.js";
|
|
15
|
-
import "../_chunks/chunk-
|
|
16
|
+
import "../_chunks/chunk-C2WELXMV.js";
|
|
16
17
|
import "../_chunks/chunk-5Z7VZPES.js";
|
|
17
18
|
|
|
18
19
|
// src/generators/shared/generator.ts
|
|
@@ -3,8 +3,9 @@ import {
|
|
|
3
3
|
} from "../_chunks/chunk-H222FPLK.js";
|
|
4
4
|
import {
|
|
5
5
|
runFsdSlice
|
|
6
|
-
} from "../_chunks/chunk-
|
|
7
|
-
import "../_chunks/chunk-
|
|
6
|
+
} from "../_chunks/chunk-M7UBCSYL.js";
|
|
7
|
+
import "../_chunks/chunk-FBCIELXS.js";
|
|
8
|
+
import "../_chunks/chunk-YEMQFSL6.js";
|
|
8
9
|
import "../_chunks/chunk-TXAQ2GJC.js";
|
|
9
10
|
import "../_chunks/chunk-6ZTIUBB2.js";
|
|
10
11
|
import "../_chunks/chunk-YNMLB4DL.js";
|
|
@@ -12,7 +13,7 @@ import "../_chunks/chunk-JPS6XKYK.js";
|
|
|
12
13
|
import {
|
|
13
14
|
resolveDryRun
|
|
14
15
|
} from "../_chunks/chunk-TUN34LAQ.js";
|
|
15
|
-
import "../_chunks/chunk-
|
|
16
|
+
import "../_chunks/chunk-C2WELXMV.js";
|
|
16
17
|
import "../_chunks/chunk-5Z7VZPES.js";
|
|
17
18
|
|
|
18
19
|
// src/generators/widget/generator.ts
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applyLintInputs,
|
|
3
|
+
renderLintInputs
|
|
4
|
+
} from "../../generators/_chunks/chunk-XSALM2IR.js";
|
|
5
|
+
import "../../generators/_chunks/chunk-LJRFVE6B.js";
|
|
6
|
+
import "../../generators/_chunks/chunk-CSJZ4PP3.js";
|
|
7
|
+
import "../../generators/_chunks/chunk-SHKQSTV2.js";
|
|
8
|
+
import "../../generators/_chunks/chunk-AMOOSD5Q.js";
|
|
9
|
+
import {
|
|
10
|
+
classifyFsdEslintConfig
|
|
11
|
+
} from "../../generators/_chunks/chunk-XXXON43Z.js";
|
|
12
|
+
import "../../generators/_chunks/chunk-YEMQFSL6.js";
|
|
13
|
+
import {
|
|
14
|
+
ESLINT_CONFIG_CANDIDATES
|
|
15
|
+
} from "../../generators/_chunks/chunk-6ZTIUBB2.js";
|
|
16
|
+
import "../../generators/_chunks/chunk-FZGN5NEP.js";
|
|
17
|
+
import "../../generators/_chunks/chunk-JPS6XKYK.js";
|
|
18
|
+
import {
|
|
19
|
+
readToolkitConfig,
|
|
20
|
+
treePackageManager
|
|
21
|
+
} from "../../generators/_chunks/chunk-C2WELXMV.js";
|
|
22
|
+
import {
|
|
23
|
+
runNxCommand
|
|
24
|
+
} from "../../generators/_chunks/chunk-5Z7VZPES.js";
|
|
25
|
+
|
|
26
|
+
// src/migrations/update-0.5.3/add-toolkit-config-lint-input.ts
|
|
27
|
+
import { getProjects } from "@nx/devkit";
|
|
28
|
+
async function addToolkitConfigLintInput(tree) {
|
|
29
|
+
const config = readToolkitConfig(tree);
|
|
30
|
+
if (config === null) return [];
|
|
31
|
+
const fsdProjects = [...getProjects(tree)].filter(([, project]) => wiresFsdRule(tree, project.root)).map(([name]) => name);
|
|
32
|
+
if (fsdProjects.length === 0) return [];
|
|
33
|
+
const outcome = applyLintInputs(tree, {
|
|
34
|
+
firstRun: true,
|
|
35
|
+
fsdProjects,
|
|
36
|
+
dryRun: false,
|
|
37
|
+
runNx: runNxCommand(treePackageManager(tree, config))
|
|
38
|
+
});
|
|
39
|
+
if (outcome === void 0 || outcome.action !== "snippet") return [];
|
|
40
|
+
return asNextSteps(renderLintInputs(outcome, false));
|
|
41
|
+
}
|
|
42
|
+
function asNextSteps(report) {
|
|
43
|
+
const reason = report.filter((line) => /^ {2}\S/.test(line)).map((line) => line.trim()).join(" ");
|
|
44
|
+
const steps = [];
|
|
45
|
+
for (const line of report.filter((entry) => entry.startsWith(" ")).map((entry) => entry.slice(4).trimEnd())) {
|
|
46
|
+
const previous = steps.at(-1);
|
|
47
|
+
const continues = previous !== void 0 && !/^\s/.test(previous) && !/^\s/.test(line) && !/[.:]$/.test(previous);
|
|
48
|
+
if (continues) steps[steps.length - 1] = `${previous} ${line}`;
|
|
49
|
+
else steps.push(line);
|
|
50
|
+
}
|
|
51
|
+
return [reason, ...steps];
|
|
52
|
+
}
|
|
53
|
+
function wiresFsdRule(tree, root) {
|
|
54
|
+
const prefix = root === "" || root === "." ? "" : `${root}/`;
|
|
55
|
+
return ESLINT_CONFIG_CANDIDATES.some((name) => {
|
|
56
|
+
const text = tree.read(`${prefix}${name}`, "utf-8");
|
|
57
|
+
return text !== null && classifyFsdEslintConfig(text) === "applied";
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
export {
|
|
61
|
+
addToolkitConfigLintInput as default
|
|
62
|
+
};
|
package/migrations.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"generators": {
|
|
3
|
+
"add-toolkit-config-lint-input": {
|
|
4
|
+
"version": "0.5.3",
|
|
5
|
+
"description": "Add toolkit.config.json to the inputs of the lint targets @nx/eslint/plugin infers, so Nx re-runs lint after the FSD policy changes",
|
|
6
|
+
"implementation": "./dist/migrations/update-0.5.3/add-toolkit-config-lint-input"
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
}
|