@clearlydev/nx-archweave 0.4.4 → 0.5.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/README.md +13 -13
- package/dist/bin/review-verdict.js +2 -1
- package/dist/generators/_chunks/{chunk-3AE7MQPM.js → chunk-3ZHRZK5M.js} +5 -2
- package/dist/generators/_chunks/{chunk-FQHFT5IH.js → chunk-5Z7VZPES.js} +8 -1
- package/dist/generators/_chunks/{chunk-PB4CFJD5.js → chunk-624F6DEP.js} +11 -6
- package/dist/generators/_chunks/{chunk-HGEMEXKF.js → chunk-AON4KGZT.js} +6 -2
- package/dist/generators/_chunks/{chunk-GPZEZVPN.js → chunk-ILICA6LC.js} +5 -4
- package/dist/generators/_chunks/chunk-JPS6XKYK.js +12 -0
- package/dist/generators/_chunks/{chunk-JEQQCSOB.js → chunk-L3T4H7OF.js} +19 -15
- package/dist/generators/_chunks/{chunk-AFAORV5O.js → chunk-M7OQWSNF.js} +1 -1
- package/dist/generators/_chunks/{chunk-L2RZ2LBO.js → chunk-N6B6VBHG.js} +32 -8
- package/dist/generators/_chunks/{chunk-SNM66KYS.js → chunk-Q7IYHKT3.js} +9 -3
- package/dist/generators/_chunks/{chunk-AEAL4ICT.js → chunk-SEUY3OCQ.js} +3 -3
- package/dist/generators/_chunks/{chunk-5HMB6HYW.js → chunk-TJ6SCQLI.js} +21 -10
- package/dist/generators/_chunks/{chunk-QQNDYJTR.js → chunk-WNO3ZGBB.js} +3 -2
- package/dist/generators/_chunks/{chunk-B55SAIUS.js → chunk-WVMTOWLM.js} +1 -1
- package/dist/generators/_chunks/{chunk-2V5LX5NK.js → chunk-ZNTGYYLU.js} +7 -6
- package/dist/generators/add-agent-rules/generator.js +5 -4
- package/dist/generators/add-backend/generator.js +4 -4
- package/dist/generators/add-fsd-lite/generator.js +7 -5
- package/dist/generators/add-github-templates/generator.js +4 -3
- package/dist/generators/add-integration/generator.js +5 -5
- package/dist/generators/add-review/generator.js +6 -5
- package/dist/generators/allow-builds/generator.js +1 -1
- package/dist/generators/doctor/generator.js +235 -30
- package/dist/generators/entity/generator.js +5 -4
- package/dist/generators/feature/generator.js +5 -4
- package/dist/generators/init/generator.js +306 -63
- package/dist/generators/install-integration/generator.js +5 -5
- package/dist/generators/page/generator.js +5 -4
- package/dist/generators/shared/generator.js +5 -4
- package/dist/generators/widget/generator.js +5 -4
- package/package.json +1 -1
- package/src/generators/add-fsd-lite/schema.json +1 -1
- package/src/generators/init/schema.json +3 -3
|
@@ -1,49 +1,58 @@
|
|
|
1
1
|
import {
|
|
2
2
|
recordedReview,
|
|
3
3
|
runAddReview
|
|
4
|
-
} from "../_chunks/chunk-
|
|
4
|
+
} from "../_chunks/chunk-SEUY3OCQ.js";
|
|
5
|
+
import "../_chunks/chunk-ASY3CK5L.js";
|
|
5
6
|
import {
|
|
6
7
|
DEFAULT_MAX_ROUNDS,
|
|
8
|
+
REVIEW_PROVIDERS,
|
|
7
9
|
buildReviewConfigSnippet
|
|
8
|
-
} from "../_chunks/chunk-
|
|
10
|
+
} from "../_chunks/chunk-L3T4H7OF.js";
|
|
9
11
|
import {
|
|
10
12
|
renderAddAgentRulesReport,
|
|
11
13
|
runAddAgentRules
|
|
12
|
-
} from "../_chunks/chunk-
|
|
14
|
+
} from "../_chunks/chunk-ZNTGYYLU.js";
|
|
13
15
|
import {
|
|
14
16
|
renderAddReviewReport
|
|
15
|
-
} from "../_chunks/chunk-
|
|
17
|
+
} from "../_chunks/chunk-AON4KGZT.js";
|
|
16
18
|
import "../_chunks/chunk-5MI3O4VZ.js";
|
|
17
19
|
import {
|
|
18
20
|
renderAddBackendBody,
|
|
19
21
|
runAddBackend
|
|
20
|
-
} from "../_chunks/chunk-
|
|
21
|
-
import "../_chunks/chunk-
|
|
22
|
+
} from "../_chunks/chunk-624F6DEP.js";
|
|
23
|
+
import "../_chunks/chunk-WNO3ZGBB.js";
|
|
22
24
|
import {
|
|
23
25
|
DEFAULT_CONFLICT_POLICY,
|
|
24
26
|
renderAddFsdLiteReport,
|
|
25
27
|
runAddFsdLite
|
|
26
|
-
} from "../_chunks/chunk-
|
|
27
|
-
import
|
|
28
|
+
} from "../_chunks/chunk-TJ6SCQLI.js";
|
|
29
|
+
import {
|
|
30
|
+
TOOLKIT_CONFIG_INPUT,
|
|
31
|
+
lintInputsProjectSnippet,
|
|
32
|
+
lintInputsTargetDefaultsSnippet
|
|
33
|
+
} from "../_chunks/chunk-N6B6VBHG.js";
|
|
28
34
|
import {
|
|
29
35
|
allFrameworkProfiles,
|
|
30
36
|
resolveFrontendApp
|
|
31
|
-
} from "../_chunks/chunk-
|
|
37
|
+
} from "../_chunks/chunk-WVMTOWLM.js";
|
|
32
38
|
import "../_chunks/chunk-TXAQ2GJC.js";
|
|
33
39
|
import {
|
|
40
|
+
ESLINT_CONFIG_CANDIDATES,
|
|
34
41
|
readBoundaryTags
|
|
35
42
|
} from "../_chunks/chunk-6ZTIUBB2.js";
|
|
36
43
|
import {
|
|
37
44
|
renderAddGithubTemplatesReport,
|
|
38
45
|
runAddGithubTemplates
|
|
39
|
-
} from "../_chunks/chunk-
|
|
46
|
+
} from "../_chunks/chunk-3ZHRZK5M.js";
|
|
40
47
|
import "../_chunks/chunk-YNMLB4DL.js";
|
|
48
|
+
import "../_chunks/chunk-JPS6XKYK.js";
|
|
41
49
|
import {
|
|
42
50
|
resolveDryRun
|
|
43
51
|
} from "../_chunks/chunk-TUN34LAQ.js";
|
|
44
52
|
import {
|
|
45
53
|
spawnableCommand
|
|
46
54
|
} from "../_chunks/chunk-34V6HAJT.js";
|
|
55
|
+
import "../_chunks/chunk-ILICA6LC.js";
|
|
47
56
|
import {
|
|
48
57
|
DEFAULT_AI_HOSTS,
|
|
49
58
|
RECORDED_BACKENDS,
|
|
@@ -59,10 +68,11 @@ import {
|
|
|
59
68
|
resolveLocaleOption,
|
|
60
69
|
reviewProviderFor,
|
|
61
70
|
treePackageManager
|
|
62
|
-
} from "../_chunks/chunk-
|
|
71
|
+
} from "../_chunks/chunk-M7OQWSNF.js";
|
|
63
72
|
import {
|
|
64
|
-
packageManagerCommands
|
|
65
|
-
|
|
73
|
+
packageManagerCommands,
|
|
74
|
+
runNxCommand
|
|
75
|
+
} from "../_chunks/chunk-5Z7VZPES.js";
|
|
66
76
|
|
|
67
77
|
// src/generators/init/generator.ts
|
|
68
78
|
import { execFileSync } from "node:child_process";
|
|
@@ -79,30 +89,16 @@ function buildFsdConfig(enforcement, frontend) {
|
|
|
79
89
|
layerMapping: Object.fromEntries(allFrameworkProfiles().map((profile) => [profile.id, [...profile.layers]]))
|
|
80
90
|
};
|
|
81
91
|
}
|
|
92
|
+
var QUICK_START_DEFAULTS = {
|
|
93
|
+
reviewEnabledDefault: false,
|
|
94
|
+
reviewMode: "fast",
|
|
95
|
+
fsdEnforcement: "warn",
|
|
96
|
+
agentRulesTeamRules: false,
|
|
97
|
+
githubTemplates: { issue: false, pr: true, codeowners: false }
|
|
98
|
+
};
|
|
82
99
|
var PRESET_DEFAULTS = {
|
|
83
|
-
"quick-start":
|
|
84
|
-
|
|
85
|
-
reviewEnabledDefault: false,
|
|
86
|
-
reviewMode: "fast",
|
|
87
|
-
// add-fsd-lite: enabled with every default layer, no questions — violations warn.
|
|
88
|
-
fsdEnforcement: "warn",
|
|
89
|
-
// add-agent-rules: enabled (simple version). Which files follow from the AI hosts
|
|
90
|
-
// picked, no longer from the preset.
|
|
91
|
-
agentRulesTeamRules: false,
|
|
92
|
-
// add-github-templates: minimal (PR template only).
|
|
93
|
-
githubTemplates: { issue: false, pr: true, codeowners: false }
|
|
94
|
-
},
|
|
95
|
-
solo: {
|
|
96
|
-
// add-review: `fast` mode by default — no opt-in question, so enabled by default.
|
|
97
|
-
reviewEnabledDefault: true,
|
|
98
|
-
reviewMode: "fast",
|
|
99
|
-
// add-fsd-lite: enabled — violations warn (no over-enforcement).
|
|
100
|
-
fsdEnforcement: "warn",
|
|
101
|
-
// add-agent-rules: enabled — files follow the AI hosts picked.
|
|
102
|
-
agentRulesTeamRules: false,
|
|
103
|
-
// add-github-templates: optional — see note #2 above.
|
|
104
|
-
githubTemplates: { issue: false, pr: true, codeowners: false }
|
|
105
|
-
},
|
|
100
|
+
"quick-start": QUICK_START_DEFAULTS,
|
|
101
|
+
solo: QUICK_START_DEFAULTS,
|
|
106
102
|
team: {
|
|
107
103
|
// Requiring review only for P2 findings when CODEOWNERS is wired up is out of v0.1
|
|
108
104
|
// scope and has no field here. The other two Team-only behaviors are the two
|
|
@@ -112,12 +108,12 @@ var PRESET_DEFAULTS = {
|
|
|
112
108
|
reviewEnabledDefault: true,
|
|
113
109
|
reviewMode: "standard",
|
|
114
110
|
// add-fsd-lite: enabled + stricter module boundaries — the canonical FSD rule
|
|
115
|
-
// reports as an error here, as a warning in
|
|
111
|
+
// reports as an error here, as a warning in quick-start.
|
|
116
112
|
fsdEnforcement: "error",
|
|
117
113
|
// add-agent-rules: enabled + an extra team-rules section — the extra section is
|
|
118
114
|
// content `template-engine/agent-rules` composes, not a different `files` list.
|
|
119
115
|
agentRulesTeamRules: true,
|
|
120
|
-
// add-github-templates: full (Issue+PR, CODEOWNERS
|
|
116
|
+
// add-github-templates: full (Issue+PR, CODEOWNERS opt-in).
|
|
121
117
|
githubTemplates: { issue: true, pr: true, codeowners: false }
|
|
122
118
|
}
|
|
123
119
|
};
|
|
@@ -154,6 +150,166 @@ function buildPresetConfig(input) {
|
|
|
154
150
|
};
|
|
155
151
|
}
|
|
156
152
|
|
|
153
|
+
// src/generators/init/left-for-you.ts
|
|
154
|
+
var PLUGIN = "@clearlydev/nx-archweave";
|
|
155
|
+
function leftForYou(report) {
|
|
156
|
+
const runNx = report.runNx ?? runNxCommand(report.packageManager);
|
|
157
|
+
const kept = [];
|
|
158
|
+
const manual = [];
|
|
159
|
+
for (const section of report.sections) {
|
|
160
|
+
if (!section.enabled || section.report === null) continue;
|
|
161
|
+
const sectionReport = section.report;
|
|
162
|
+
switch (sectionReport.kind) {
|
|
163
|
+
case "fsd": {
|
|
164
|
+
const fsd = sectionReport.report;
|
|
165
|
+
if (fsd.aborted) break;
|
|
166
|
+
if (fsd.eslint === "degraded-unrecognized") {
|
|
167
|
+
manual.push(
|
|
168
|
+
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)`
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
const steiger = fsd.steiger;
|
|
172
|
+
if (steiger !== null) {
|
|
173
|
+
if (steiger.config === "kept") kept.push(`${steiger.configPath}: an existing steiger config with other content \u2014 left as it is`);
|
|
174
|
+
if (steiger.target === "unrecognized") manual.push(`${fsd.project ?? "the app"}: add the fsd-check target yourself (no parseable project.json or package.json)`);
|
|
175
|
+
if (steiger.dependencies === "unrecognized") {
|
|
176
|
+
manual.push("package.json: could not be parsed \u2014 add steiger and @feature-sliced/steiger-plugin to devDependencies yourself");
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
case "agentRules":
|
|
182
|
+
for (const file of sectionReport.report.files) {
|
|
183
|
+
if (file.action === "user-modified") {
|
|
184
|
+
kept.push(`${file.filePath}: its nx-archweave block was edited by hand \u2014 to replace it: ${runNx} g ${PLUGIN}:add-agent-rules --overwriteBlock`);
|
|
185
|
+
} else if (file.action === "unrecognized") {
|
|
186
|
+
kept.push(`${file.filePath}: left untouched (${file.reason ?? "its nx-archweave markers could not be placed"}) \u2014 fix the file, then rerun init`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
break;
|
|
190
|
+
case "githubTemplates":
|
|
191
|
+
for (const file of sectionReport.report.files) {
|
|
192
|
+
if (file.action === "skipped") {
|
|
193
|
+
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`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
break;
|
|
197
|
+
case "review": {
|
|
198
|
+
const review = sectionReport.report;
|
|
199
|
+
if (review.workflowAction === "aborted") break;
|
|
200
|
+
if (review.workflowAction === "proposed" || review.workflowAction === "skipped") {
|
|
201
|
+
kept.push(`${review.workflowPath}: differs from the generated workflow \u2014 to replace it: ${runNx} g ${PLUGIN}:add-review --onConflict=overwrite`);
|
|
202
|
+
} else if (review.workflowAction === "alternate") {
|
|
203
|
+
manual.push(`${review.workflowPath}: written alongside the existing workflow \u2014 replace the main workflow file with it yourself`);
|
|
204
|
+
}
|
|
205
|
+
if (review.dependabot === "proposed") manual.push(".github/dependabot.yml: add the github-actions entry shown above");
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
case "backend": {
|
|
209
|
+
const backend = sectionReport.report;
|
|
210
|
+
if (backend.refused !== void 0) break;
|
|
211
|
+
if (backend.eslint === "degraded-unrecognized") manual.push("ESLint boundaries: your config was not recognized \u2014 merge the constraints shown above yourself");
|
|
212
|
+
if (backend.tsconfigPaths === "unrecognized") {
|
|
213
|
+
manual.push(`tsconfig.base.json: could not be parsed \u2014 add the ${backend.sharedTypesPackage ?? "shared-types"} path yourself`);
|
|
214
|
+
}
|
|
215
|
+
const linkedByPaths = backend.tsconfigPaths === "added" || backend.tsconfigPaths === "present";
|
|
216
|
+
if (backend.workspaceGlob === "unrecognized" && !linkedByPaths) {
|
|
217
|
+
const registry = packageManagerCommands(backend.packageManager ?? "pnpm").workspaceRegistration;
|
|
218
|
+
manual.push(`${registry}: shape not recognized \u2014 add '${backend.sharedTypesRoot ?? "libs/shared-types"}' to its workspace list yourself`);
|
|
219
|
+
}
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return { kept, manual };
|
|
225
|
+
}
|
|
226
|
+
function renderLeftForYou(left) {
|
|
227
|
+
const lines = [];
|
|
228
|
+
if (left.kept.length > 0) {
|
|
229
|
+
lines.push("", "Skipped to keep your changes:", ...left.kept.map((item) => ` ${item}`));
|
|
230
|
+
}
|
|
231
|
+
if (left.manual.length > 0) {
|
|
232
|
+
lines.push("", "Needs a manual step:", ...left.manual.map((item) => ` ${item}`));
|
|
233
|
+
}
|
|
234
|
+
return lines;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// src/generators/init/lint-inputs.ts
|
|
238
|
+
import { getProjects } from "@nx/devkit";
|
|
239
|
+
import { parse } from "jsonc-parser";
|
|
240
|
+
var ESLINT_PLUGIN = "@nx/eslint/plugin";
|
|
241
|
+
var ESLINT_EXECUTOR = "@nx/eslint:lint";
|
|
242
|
+
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
243
|
+
function applyLintInputs(tree, input) {
|
|
244
|
+
const raw = tree.read("nx.json", "utf-8");
|
|
245
|
+
if (raw === null) return void 0;
|
|
246
|
+
const nxJson = parse(raw, [], { allowTrailingComma: true });
|
|
247
|
+
if (!isObject(nxJson)) return void 0;
|
|
248
|
+
const plugins = Array.isArray(nxJson["plugins"]) ? nxJson["plugins"] : [];
|
|
249
|
+
const plugin = plugins.find((entry) => entry === ESLINT_PLUGIN || isObject(entry) && entry["plugin"] === ESLINT_PLUGIN);
|
|
250
|
+
const options = isObject(plugin) && isObject(plugin["options"]) ? plugin["options"] : {};
|
|
251
|
+
const target = typeof options["targetName"] === "string" ? options["targetName"] : "lint";
|
|
252
|
+
const targetDefaults = isObject(nxJson["targetDefaults"]) ? nxJson["targetDefaults"] : {};
|
|
253
|
+
const namedInputs = isObject(nxJson["namedInputs"]) ? nxJson["namedInputs"] : {};
|
|
254
|
+
const defaultsKey = [target, ESLINT_EXECUTOR].find((key) => isObject(targetDefaults[key]) && Array.isArray(targetDefaults[key]["inputs"]));
|
|
255
|
+
const defaultsInputs = defaultsKey === void 0 ? void 0 : targetDefaults[defaultsKey]["inputs"];
|
|
256
|
+
const carries = (inputs) => inputs.some((entry) => {
|
|
257
|
+
if (entry === TOOLKIT_CONFIG_INPUT) return true;
|
|
258
|
+
const named = typeof entry === "string" ? namedInputs[entry.replace(/^\^/, "")] : void 0;
|
|
259
|
+
return Array.isArray(named) && named.includes(TOOLKIT_CONFIG_INPUT);
|
|
260
|
+
});
|
|
261
|
+
if (defaultsInputs !== void 0 && carries(defaultsInputs)) return { action: "present", target };
|
|
262
|
+
const projects = getProjects(tree);
|
|
263
|
+
const ownTarget = (name) => {
|
|
264
|
+
const project = projects.get(name);
|
|
265
|
+
if (project === void 0) return void 0;
|
|
266
|
+
if (isObject(project.targets?.[target])) return { file: projectFile(tree, project.root), inputs: project.targets?.[target]?.inputs };
|
|
267
|
+
const pkg = readJson(tree, `${prefix(project.root)}package.json`);
|
|
268
|
+
if (isObject(pkg) && isObject(pkg["scripts"]) && typeof pkg["scripts"][target] === "string") return { file: `${prefix(project.root)}package.json`, inputs: void 0 };
|
|
269
|
+
return void 0;
|
|
270
|
+
};
|
|
271
|
+
const ownTargets = [...projects.keys()].filter((name) => ownTarget(name) !== void 0).sort();
|
|
272
|
+
const reason = !input.firstRun ? "not-first-run" : plugin === void 0 ? "no-plugin" : ownTargets.length > 0 ? "own-targets" : defaultsInputs !== void 0 ? "existing-inputs" : void 0;
|
|
273
|
+
if (reason === void 0) {
|
|
274
|
+
if (!input.dryRun) tree.write("nx.json", applyJsonEdits(raw, [[["targetDefaults", target, "inputs"], ["...", TOOLKIT_CONFIG_INPUT]]]));
|
|
275
|
+
return { action: "added", target };
|
|
276
|
+
}
|
|
277
|
+
const fsdProjects = input.fsdProjects.filter((name) => prefix(projects.get(name)?.root ?? "") !== "");
|
|
278
|
+
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 ? lintInputsTargetDefaultsSnippet(target) : fsdProjects.flatMap((name) => {
|
|
279
|
+
const root = projects.get(name)?.root ?? "";
|
|
280
|
+
const own = ownTarget(name);
|
|
281
|
+
return lintInputsProjectSnippet({
|
|
282
|
+
file: own?.file ?? projectFile(tree, root),
|
|
283
|
+
target,
|
|
284
|
+
ownInputs: own?.inputs !== void 0,
|
|
285
|
+
eslintConfigs: eslintConfigs(tree, root)
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
return {
|
|
289
|
+
action: "snippet",
|
|
290
|
+
target,
|
|
291
|
+
reason,
|
|
292
|
+
...reason === "own-targets" ? { ownTargets } : {},
|
|
293
|
+
snippet,
|
|
294
|
+
skipCache: fsdProjects.map((name) => `${input.runNx} ${target} ${name} --skip-nx-cache`)
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
function prefix(root) {
|
|
298
|
+
return root === "" || root === "." ? "" : `${root}/`;
|
|
299
|
+
}
|
|
300
|
+
function readJson(tree, path) {
|
|
301
|
+
const raw = tree.read(path, "utf-8");
|
|
302
|
+
return raw === null ? null : parse(raw, [], { allowTrailingComma: true });
|
|
303
|
+
}
|
|
304
|
+
function projectFile(tree, root) {
|
|
305
|
+
return tree.exists(`${prefix(root)}project.json`) ? `${prefix(root)}project.json` : `${prefix(root)}package.json`;
|
|
306
|
+
}
|
|
307
|
+
function eslintConfigs(tree, root) {
|
|
308
|
+
const own = ESLINT_CONFIG_CANDIDATES.find((name) => tree.exists(`${prefix(root)}${name}`));
|
|
309
|
+
const workspace = ESLINT_CONFIG_CANDIDATES.find((name) => tree.exists(name));
|
|
310
|
+
return [...own === void 0 || prefix(root) === "" ? [] : [`{projectRoot}/${own}`], ...workspace === void 0 ? [] : [`{workspaceRoot}/${workspace}`]];
|
|
311
|
+
}
|
|
312
|
+
|
|
157
313
|
// src/generators/init/render.ts
|
|
158
314
|
var SECTION_TITLES = {
|
|
159
315
|
fsd: "add-fsd-lite",
|
|
@@ -185,18 +341,19 @@ function sectionAborted(section) {
|
|
|
185
341
|
return false;
|
|
186
342
|
}
|
|
187
343
|
function failedSections(report) {
|
|
188
|
-
|
|
344
|
+
const failed = report.sections.filter(sectionAborted).map((section) => SECTION_TITLES[section.id]);
|
|
345
|
+
return report.config?.action === "unrecognized" ? [...failed, "toolkit.config.json"] : failed;
|
|
189
346
|
}
|
|
190
347
|
function renderInitReport(report) {
|
|
191
348
|
const lines = [];
|
|
192
349
|
const backendSuffix = report.backend === "none" ? "" : `, backend: ${report.backend}`;
|
|
193
350
|
const header = `init (preset: ${report.preset}, frontend: ${report.frontend}${backendSuffix})`;
|
|
194
351
|
lines.push(report.dryRun ? `${header} \u2014 dry run` : header);
|
|
352
|
+
if (report.preset === "solo") {
|
|
353
|
+
lines.push("Note: solo is now an alias of quick-start \u2014 AI PR review stays off unless you pass --review.");
|
|
354
|
+
}
|
|
195
355
|
if (report.refused) {
|
|
196
|
-
lines.push("");
|
|
197
|
-
lines.push("Refused: the working tree has uncommitted changes.");
|
|
198
|
-
lines.push(" init only runs against a clean working tree, so a partial run can be rolled back exactly");
|
|
199
|
-
lines.push(" to what was committed \u2014 commit or stash your changes, then rerun.");
|
|
356
|
+
lines.push("", ...renderRefusal(report.dirtyFiles));
|
|
200
357
|
return lines.join("\n");
|
|
201
358
|
}
|
|
202
359
|
for (const section of report.sections) {
|
|
@@ -207,6 +364,9 @@ function renderInitReport(report) {
|
|
|
207
364
|
lines.push(
|
|
208
365
|
section.id === "fsd" && report.frontend === "none" ? " skipped (backend-only workspace \u2014 no frontend to structure)" : " skipped (disabled for this run)"
|
|
209
366
|
);
|
|
367
|
+
if (section.keptFiles !== void 0 && section.keptFiles.length > 0) {
|
|
368
|
+
lines.push(` Kept as they are: ${section.keptFiles.join(", ")}. To update them, run add-review.`);
|
|
369
|
+
}
|
|
210
370
|
continue;
|
|
211
371
|
}
|
|
212
372
|
if (section.thrownError !== void 0) {
|
|
@@ -231,8 +391,9 @@ function renderInitReport(report) {
|
|
|
231
391
|
lines.push(` already records ${fieldList} (unchanged)`);
|
|
232
392
|
break;
|
|
233
393
|
case "unrecognized":
|
|
234
|
-
lines.push(`
|
|
235
|
-
lines.push(` does not recognize)
|
|
394
|
+
lines.push(` aborted \u2014 the file is not a JSON object, so init left it alone (it never rewrites a shape it`);
|
|
395
|
+
lines.push(` does not recognize) and could not record ${fieldList}. The generators you run next read`);
|
|
396
|
+
lines.push(" them from here: make the file a JSON object (or delete it), then rerun init.");
|
|
236
397
|
break;
|
|
237
398
|
case "skipped":
|
|
238
399
|
break;
|
|
@@ -240,17 +401,18 @@ function renderInitReport(report) {
|
|
|
240
401
|
if (report.config.notRecorded.length > 0) {
|
|
241
402
|
lines.push(` not recorded: ${report.config.notRecorded.map((n) => n.field).join(", ")} \u2014 that section did not apply cleanly`);
|
|
242
403
|
lines.push(" this run (aborted, or written as an alternate file). Once resolved, record it with:");
|
|
243
|
-
const runNx =
|
|
404
|
+
const runNx = report.runNx ?? runNxCommand(report.packageManager);
|
|
244
405
|
for (const entry of report.config.notRecorded) lines.push(` ${runNx} g @clearlydev/nx-archweave:${entry.rerun}`);
|
|
245
406
|
}
|
|
246
407
|
}
|
|
408
|
+
if (report.lintInputs !== void 0) lines.push("", "## nx.json", ...renderLintInputs(report.lintInputs, report.dryRun));
|
|
247
409
|
const ranDirty = report.allowDirty === true && !report.cleanTree && !report.dryRun;
|
|
248
410
|
if (ranDirty && report.dirtyFromCaller !== true) {
|
|
249
411
|
lines.push("");
|
|
250
412
|
lines.push("Note: --allowDirty was set and the working tree already had uncommitted changes \u2014");
|
|
251
413
|
lines.push("restoring the files this run modified also reverts your earlier changes to them.");
|
|
252
414
|
}
|
|
253
|
-
const hadAbort = report.
|
|
415
|
+
const hadAbort = failedSections(report).length > 0;
|
|
254
416
|
if (!report.dryRun && hadAbort) {
|
|
255
417
|
lines.push("");
|
|
256
418
|
lines.push("One or more sections aborted. To undo what this run wrote:");
|
|
@@ -264,8 +426,53 @@ function renderInitReport(report) {
|
|
|
264
426
|
for (const path of written.created) lines.push(` ${path}`);
|
|
265
427
|
}
|
|
266
428
|
}
|
|
429
|
+
lines.push(...renderLeftForYou(leftForYou(report)));
|
|
267
430
|
return lines.join("\n");
|
|
268
431
|
}
|
|
432
|
+
function renderLintInputs(outcome, dryRun) {
|
|
433
|
+
if (outcome.action === "present") return [` ${outcome.target} inputs already include toolkit.config.json`];
|
|
434
|
+
if (outcome.action === "added") {
|
|
435
|
+
return [
|
|
436
|
+
` ${dryRun ? "would add" : "added"} "{workspaceRoot}/toolkit.config.json" to targetDefaults.${outcome.target}.inputs, after "..." (which keeps`,
|
|
437
|
+
" the inputs @nx/eslint/plugin infers), so Nx re-runs lint after a change to the fsd policy"
|
|
438
|
+
];
|
|
439
|
+
}
|
|
440
|
+
const reason = {
|
|
441
|
+
"not-first-run": "init writes nx.json only when it sets a workspace up for the first time",
|
|
442
|
+
"no-plugin": "@nx/eslint/plugin is not registered, so targetDefaults would replace the lint targets' inputs",
|
|
443
|
+
"own-targets": `${(outcome.ownTargets ?? []).join(", ")} write their own ${outcome.target} target, which keeps only what targetDefaults lists`,
|
|
444
|
+
"existing-inputs": `targetDefaults already gives ${outcome.target} inputs of its own`
|
|
445
|
+
}[outcome.reason ?? "not-first-run"];
|
|
446
|
+
return [
|
|
447
|
+
" toolkit.config.json is not among lint's inputs, so Nx can replay a cached lint result after a change to the",
|
|
448
|
+
` fsd policy. Not written \u2014 ${reason}.`,
|
|
449
|
+
...(outcome.snippet ?? []).map((line) => ` ${line}`),
|
|
450
|
+
...(outcome.skipCache ?? []).length > 0 ? [` Or, after changing the fsd policy, check with: ${(outcome.skipCache ?? []).join(", ")}`] : []
|
|
451
|
+
];
|
|
452
|
+
}
|
|
453
|
+
var SHOWN_DIRTY_FILES = 20;
|
|
454
|
+
var LOCKFILES = /* @__PURE__ */ new Set(["pnpm-lock.yaml", "package-lock.json", "yarn.lock", "bun.lock", "bun.lockb"]);
|
|
455
|
+
function renderRefusal(dirtyFiles) {
|
|
456
|
+
const lines = ["Refused: the working tree has uncommitted changes."];
|
|
457
|
+
lines.push(" init only runs against a clean working tree, so a partial run can be rolled back exactly");
|
|
458
|
+
if (dirtyFiles === void 0 || dirtyFiles.length === 0) {
|
|
459
|
+
lines.push(" to what was committed \u2014 commit or stash your changes, then rerun.");
|
|
460
|
+
} else {
|
|
461
|
+
lines.push(" to what was committed. Uncommitted:");
|
|
462
|
+
for (const path of dirtyFiles.slice(0, SHOWN_DIRTY_FILES)) lines.push(` ${path}`);
|
|
463
|
+
if (dirtyFiles.length > SHOWN_DIRTY_FILES) lines.push(` \u2026 and ${dirtyFiles.length - SHOWN_DIRTY_FILES} more`);
|
|
464
|
+
const pluginInstall = dirtyFiles.includes("package.json") && dirtyFiles.every((path) => path === "package.json" || LOCKFILES.has(path));
|
|
465
|
+
if (pluginInstall) {
|
|
466
|
+
lines.push(" These are the plugin install. Commit them, then rerun init:");
|
|
467
|
+
lines.push(` git add ${dirtyFiles.join(" ")} && git commit -m "chore: add @clearlydev/nx-archweave"`);
|
|
468
|
+
} else {
|
|
469
|
+
lines.push(" Check them with `git status`, then commit or stash them, and rerun init.");
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
lines.push(" Or pass --allowDirty to run anyway: restoring a file this run modifies then also reverts");
|
|
473
|
+
lines.push(" the changes you had made to it.");
|
|
474
|
+
return lines;
|
|
475
|
+
}
|
|
269
476
|
|
|
270
477
|
// src/generators/init/validation.ts
|
|
271
478
|
import { spawnSync } from "node:child_process";
|
|
@@ -339,15 +546,15 @@ function recordPresetChoices(tree, choices, notRecorded, write) {
|
|
|
339
546
|
const { raw, parsed } = readToolkitConfigFile(tree);
|
|
340
547
|
if (raw !== null && parsed === null) return { action: "unrecognized", fields, notRecorded };
|
|
341
548
|
const existing = parsed ?? {};
|
|
342
|
-
const
|
|
549
|
+
const isObject2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
343
550
|
const edits = [];
|
|
344
551
|
for (const key of topLevel) {
|
|
345
552
|
if (existing[key] !== choices[key]) edits.push([[key], choices[key]]);
|
|
346
553
|
}
|
|
347
554
|
const nested = (parent, key, value) => {
|
|
348
555
|
const holder = existing[parent];
|
|
349
|
-
if (
|
|
350
|
-
edits.push(
|
|
556
|
+
if (isObject2(holder) && holder[key] === value) return;
|
|
557
|
+
edits.push(isObject2(holder) ? [[parent, key], value] : [[parent], { [key]: value }]);
|
|
351
558
|
};
|
|
352
559
|
if (choices.enforcement !== void 0) nested("fsd", "enforcement", choices.enforcement);
|
|
353
560
|
if (choices.teamRules !== void 0) nested("agentRules", "teamRules", choices.teamRules);
|
|
@@ -364,6 +571,10 @@ function recordPresetChoices(tree, choices, notRecorded, write) {
|
|
|
364
571
|
if (write) tree.write(TOOLKIT_CONFIG_PATH, applyJsonEdits(raw, edits));
|
|
365
572
|
return { action: raw === null ? "created" : "updated", fields, notRecorded };
|
|
366
573
|
}
|
|
574
|
+
function existingReviewFiles(tree, config) {
|
|
575
|
+
const workflows = Object.values(REVIEW_PROVIDERS).map((provider) => provider.workflowFileName).filter((path) => tree.exists(path));
|
|
576
|
+
return config?.["review"] === void 0 ? workflows : [...workflows, "toolkit.config.json (review field)"];
|
|
577
|
+
}
|
|
367
578
|
function keptReviewProvider(option, config) {
|
|
368
579
|
const recordedHosts = resolveAiHostsOption(void 0, config);
|
|
369
580
|
const hosts = resolveAiHostsOption(option, config);
|
|
@@ -387,6 +598,7 @@ function writtenSince(before, tree) {
|
|
|
387
598
|
}
|
|
388
599
|
function runInit(tree, options, deps) {
|
|
389
600
|
const before = pendingContents(tree);
|
|
601
|
+
const firstRun = !tree.exists("toolkit.config.json");
|
|
390
602
|
const recorded = readToolkitConfigFile(tree).parsed;
|
|
391
603
|
const preset = options.preset ?? recordedChoice(recorded, "preset", RECORDED_PRESETS);
|
|
392
604
|
if (preset === void 0) {
|
|
@@ -402,9 +614,10 @@ function runInit(tree, options, deps) {
|
|
|
402
614
|
const dryRun = options.dryRun ?? false;
|
|
403
615
|
const locale = resolveLocaleOption(options.locale, recorded);
|
|
404
616
|
const allowDirty = options.allowDirty ?? false;
|
|
405
|
-
const
|
|
617
|
+
const changes = dryRun ? [] : deps.workingTreeChanges(tree.root);
|
|
618
|
+
const cleanTree = changes !== null && changes.length === 0;
|
|
406
619
|
if (!cleanTree && !allowDirty) {
|
|
407
|
-
return { preset, frontend, backend, dryRun, cleanTree: false, allowDirty, refused: true, sections: [] };
|
|
620
|
+
return { preset, frontend, backend, dryRun, cleanTree: false, allowDirty, refused: true, ...changes === null ? {} : { dirtyFiles: changes }, sections: [] };
|
|
408
621
|
}
|
|
409
622
|
const knownPackageManager = options.packageManager ?? treePackageManager(tree, recorded);
|
|
410
623
|
const packageManager = knownPackageManager ?? "pnpm";
|
|
@@ -509,7 +722,7 @@ function runInit(tree, options, deps) {
|
|
|
509
722
|
});
|
|
510
723
|
sections.push({ id: "review", enabled: true, report: { kind: "review", report } });
|
|
511
724
|
} else {
|
|
512
|
-
sections.push({ id: "review", enabled: false, report: null });
|
|
725
|
+
sections.push({ id: "review", enabled: false, report: null, keptFiles: existingReviewFiles(tree, recorded) });
|
|
513
726
|
}
|
|
514
727
|
const fsdSections = sections.filter((s) => s.id === "fsd");
|
|
515
728
|
const fsdRan = fsdSections.some((s) => s.enabled);
|
|
@@ -532,6 +745,12 @@ function runInit(tree, options, deps) {
|
|
|
532
745
|
});
|
|
533
746
|
notRecorded.push({ field: "aiHosts", rerun: `add-agent-rules --hosts=${config.aiHosts.join(",")}` });
|
|
534
747
|
}
|
|
748
|
+
const lintInputs = fsdApplied ? applyLintInputs(tree, {
|
|
749
|
+
firstRun,
|
|
750
|
+
fsdProjects: fsdSections.flatMap((s) => s.report?.kind === "fsd" && s.report.report.project !== null ? [s.report.report.project] : []),
|
|
751
|
+
dryRun,
|
|
752
|
+
runNx: runNxCommand(knownPackageManager)
|
|
753
|
+
}) : void 0;
|
|
535
754
|
const configOutcome = recordPresetChoices(
|
|
536
755
|
tree,
|
|
537
756
|
{
|
|
@@ -560,6 +779,7 @@ function runInit(tree, options, deps) {
|
|
|
560
779
|
frontend,
|
|
561
780
|
backend,
|
|
562
781
|
packageManager,
|
|
782
|
+
runNx: runNxCommand(knownPackageManager),
|
|
563
783
|
dryRun,
|
|
564
784
|
cleanTree,
|
|
565
785
|
allowDirty,
|
|
@@ -567,21 +787,44 @@ function runInit(tree, options, deps) {
|
|
|
567
787
|
refused: false,
|
|
568
788
|
sections,
|
|
569
789
|
config: configOutcome,
|
|
790
|
+
...lintInputs === void 0 ? {} : { lintInputs },
|
|
570
791
|
written: dryRun ? void 0 : writtenSince(before, tree)
|
|
571
792
|
};
|
|
572
793
|
}
|
|
573
|
-
function
|
|
794
|
+
function gitWorkingTreeChanges(root) {
|
|
574
795
|
try {
|
|
575
|
-
const output = execFileSync("git", ["status", "--porcelain"], { cwd: root, encoding: "utf-8" });
|
|
576
|
-
|
|
796
|
+
const output = execFileSync("git", ["status", "--porcelain", "-z"], { cwd: root, encoding: "utf-8" });
|
|
797
|
+
const entries = output.split("\0");
|
|
798
|
+
const paths = [];
|
|
799
|
+
for (let index = 0; index < entries.length; index += 1) {
|
|
800
|
+
const entry = entries[index];
|
|
801
|
+
if (entry.length < 4) continue;
|
|
802
|
+
paths.push(entry.slice(3));
|
|
803
|
+
if (/[RC]/.test(entry.slice(0, 2))) index += 1;
|
|
804
|
+
}
|
|
805
|
+
return paths;
|
|
577
806
|
} catch (error) {
|
|
578
807
|
console.warn(
|
|
579
808
|
"init: could not determine the working tree status (the git command failed) \u2014 treating it as dirty for safety."
|
|
580
809
|
);
|
|
581
810
|
if (error instanceof Error) console.warn(` ${error.message}`);
|
|
582
|
-
return
|
|
811
|
+
return null;
|
|
583
812
|
}
|
|
584
813
|
}
|
|
814
|
+
function initFailure(report, strict) {
|
|
815
|
+
if (report.refused) return "init refused: the working tree has uncommitted changes \u2014 see the report above.";
|
|
816
|
+
const aborted = failedSections(report);
|
|
817
|
+
if (aborted.length > 0) return `init: a section aborted (${aborted.join(", ")}) \u2014 see the report above.`;
|
|
818
|
+
if (!strict) return null;
|
|
819
|
+
const left = leftForYou(report);
|
|
820
|
+
const count = left.kept.length + left.manual.length;
|
|
821
|
+
return count === 0 ? null : `init --strict: init couldn't do everything you asked for (${count} ${count === 1 ? "item" : "items"}) \u2014 see the report above.`;
|
|
822
|
+
}
|
|
823
|
+
function reportedFailure(message) {
|
|
824
|
+
const error = new Error(message);
|
|
825
|
+
error.stack = "";
|
|
826
|
+
return error;
|
|
827
|
+
}
|
|
585
828
|
function collectWrittenWorkflowPaths(report) {
|
|
586
829
|
const paths = [];
|
|
587
830
|
for (const section of report.sections) {
|
|
@@ -593,17 +836,17 @@ function collectWrittenWorkflowPaths(report) {
|
|
|
593
836
|
}
|
|
594
837
|
return paths;
|
|
595
838
|
}
|
|
596
|
-
async function initGenerator(tree, options, deps = {
|
|
839
|
+
async function initGenerator(tree, options, deps = { workingTreeChanges: gitWorkingTreeChanges }) {
|
|
597
840
|
const changesBefore = tree.listChanges().length;
|
|
598
841
|
const report = runInit(tree, { ...options, dryRun: resolveDryRun(options) }, deps);
|
|
599
842
|
console.log(renderInitReport(report));
|
|
600
|
-
const
|
|
601
|
-
const
|
|
602
|
-
if (
|
|
843
|
+
const message = initFailure(report, options.strict === true);
|
|
844
|
+
const failure = message === null ? null : reportedFailure(message);
|
|
845
|
+
if (failure !== null && (report.dryRun || report.refused)) throw failure;
|
|
603
846
|
if (report.dryRun || report.refused) return;
|
|
604
847
|
const wrote = tree.listChanges().length !== changesBefore;
|
|
605
848
|
if (!wrote) {
|
|
606
|
-
if (
|
|
849
|
+
if (failure !== null) throw failure;
|
|
607
850
|
return;
|
|
608
851
|
}
|
|
609
852
|
const workflowPaths = collectWrittenWorkflowPaths(report);
|
|
@@ -611,7 +854,7 @@ async function initGenerator(tree, options, deps = { isWorkingTreeClean: gitIsWo
|
|
|
611
854
|
const graphOutputFile = join(tmpdir(), `nx-archweave-init-graph-${Date.now()}.json`);
|
|
612
855
|
return () => {
|
|
613
856
|
runPostInitValidation({ root, workflowPaths, graphOutputFile }, createProcessExec());
|
|
614
|
-
if (
|
|
857
|
+
if (failure !== null) throw failure;
|
|
615
858
|
};
|
|
616
859
|
}
|
|
617
860
|
var generator_default = initGenerator;
|
|
@@ -2,9 +2,6 @@ import {
|
|
|
2
2
|
runRecordPipeline
|
|
3
3
|
} from "../_chunks/chunk-URV6FLUH.js";
|
|
4
4
|
import "../_chunks/chunk-U6LAFHSF.js";
|
|
5
|
-
import {
|
|
6
|
-
diskRunNx
|
|
7
|
-
} from "../_chunks/chunk-GPZEZVPN.js";
|
|
8
5
|
import {
|
|
9
6
|
DEFAULT_PLUGIN_SCOPE,
|
|
10
7
|
PLUGIN_IDS,
|
|
@@ -19,8 +16,11 @@ import {
|
|
|
19
16
|
verifyViaClaudeCli
|
|
20
17
|
} from "../_chunks/chunk-AQHV7DJS.js";
|
|
21
18
|
import "../_chunks/chunk-34V6HAJT.js";
|
|
22
|
-
import
|
|
23
|
-
|
|
19
|
+
import {
|
|
20
|
+
diskRunNx
|
|
21
|
+
} from "../_chunks/chunk-ILICA6LC.js";
|
|
22
|
+
import "../_chunks/chunk-M7OQWSNF.js";
|
|
23
|
+
import "../_chunks/chunk-5Z7VZPES.js";
|
|
24
24
|
|
|
25
25
|
// ../integrations/dist/config/declare-enabled-integration.js
|
|
26
26
|
import { existsSync, lstatSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
@@ -3,16 +3,17 @@ 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-Q7IYHKT3.js";
|
|
7
|
+
import "../_chunks/chunk-WVMTOWLM.js";
|
|
8
8
|
import "../_chunks/chunk-TXAQ2GJC.js";
|
|
9
9
|
import "../_chunks/chunk-6ZTIUBB2.js";
|
|
10
10
|
import "../_chunks/chunk-YNMLB4DL.js";
|
|
11
|
+
import "../_chunks/chunk-JPS6XKYK.js";
|
|
11
12
|
import {
|
|
12
13
|
resolveDryRun
|
|
13
14
|
} from "../_chunks/chunk-TUN34LAQ.js";
|
|
14
|
-
import "../_chunks/chunk-
|
|
15
|
-
import "../_chunks/chunk-
|
|
15
|
+
import "../_chunks/chunk-M7OQWSNF.js";
|
|
16
|
+
import "../_chunks/chunk-5Z7VZPES.js";
|
|
16
17
|
|
|
17
18
|
// src/generators/page/generator.ts
|
|
18
19
|
async function pageGenerator(tree, options) {
|
|
@@ -3,16 +3,17 @@ 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-Q7IYHKT3.js";
|
|
7
|
+
import "../_chunks/chunk-WVMTOWLM.js";
|
|
8
8
|
import "../_chunks/chunk-TXAQ2GJC.js";
|
|
9
9
|
import "../_chunks/chunk-6ZTIUBB2.js";
|
|
10
10
|
import "../_chunks/chunk-YNMLB4DL.js";
|
|
11
|
+
import "../_chunks/chunk-JPS6XKYK.js";
|
|
11
12
|
import {
|
|
12
13
|
resolveDryRun
|
|
13
14
|
} from "../_chunks/chunk-TUN34LAQ.js";
|
|
14
|
-
import "../_chunks/chunk-
|
|
15
|
-
import "../_chunks/chunk-
|
|
15
|
+
import "../_chunks/chunk-M7OQWSNF.js";
|
|
16
|
+
import "../_chunks/chunk-5Z7VZPES.js";
|
|
16
17
|
|
|
17
18
|
// src/generators/shared/generator.ts
|
|
18
19
|
async function sharedGenerator(tree, options) {
|