@clearlydev/nx-archweave 0.6.1 → 0.7.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 +34 -3
- package/dist/eslint/index.js +1 -1
- package/dist/generators/_chunks/{chunk-MQNQJOWA.js → chunk-22FVJUNE.js} +4 -2
- package/dist/generators/_chunks/{chunk-CH5AF5S2.js → chunk-2ADC6RKP.js} +1 -1
- package/dist/generators/_chunks/{chunk-2K4JADTK.js → chunk-6PKKKQMD.js} +46 -3
- package/dist/generators/_chunks/chunk-72D3GWHO.js +269 -0
- package/dist/generators/_chunks/{chunk-2TQWFUMC.js → chunk-736LFDT4.js} +21 -1
- package/dist/generators/_chunks/{chunk-D7J7HTND.js → chunk-7RTT5NBN.js} +4 -4
- package/dist/generators/_chunks/chunk-AOKTOS3U.js +294 -0
- package/dist/generators/_chunks/chunk-B6RBCUIL.js +325 -0
- package/dist/generators/_chunks/{chunk-XZM354ZH.js → chunk-CHZPA6OE.js} +5 -3
- package/dist/generators/_chunks/{chunk-UAPIAMRL.js → chunk-DAXD47YO.js} +1 -1
- package/dist/generators/_chunks/chunk-GN76UMTK.js +28 -0
- package/dist/generators/_chunks/{chunk-L52OUT5T.js → chunk-J24X4EOB.js} +1 -1
- package/dist/generators/_chunks/{chunk-EHYC6FUR.js → chunk-JSHZ6VSW.js} +1 -1
- package/dist/generators/_chunks/chunk-KNVBFTH4.js +64 -0
- package/dist/generators/_chunks/chunk-MF75SQM6.js +98 -0
- package/dist/generators/_chunks/chunk-N6SPEKJB.js +106 -0
- package/dist/generators/_chunks/chunk-OX7W4SJ2.js +214 -0
- package/dist/generators/_chunks/chunk-R2VEJGNP.js +84 -0
- package/dist/generators/_chunks/chunk-SBOQHME6.js +140 -0
- package/dist/generators/_chunks/{chunk-WD2HL2RE.js → chunk-STGNMZLM.js} +1 -1
- package/dist/generators/_chunks/{chunk-XXXON43Z.js → chunk-SZRBDQCU.js} +4 -51
- package/dist/generators/_chunks/{chunk-LKXSS5E2.js → chunk-W2BBF5MS.js} +3 -86
- package/dist/generators/add-agent-rules/generator.js +2 -2
- package/dist/generators/add-backend/generator.js +2 -2
- package/dist/generators/add-fsd-lite/generator.js +7 -5
- package/dist/generators/add-github-templates/generator.js +2 -2
- package/dist/generators/add-integration/generator.js +2 -2
- package/dist/generators/add-review/generator.js +2 -2
- package/dist/generators/add-storybook/files/example/button/button.stories.tsx.template +13 -0
- package/dist/generators/add-storybook/files/example/button/button.tsx.template +7 -0
- package/dist/generators/add-storybook/files/example/index.ts.template +1 -0
- package/dist/generators/add-storybook/files/library/tailwind.css.template +2 -0
- package/dist/generators/add-storybook/generator.js +28 -0
- package/dist/generators/add-tailwind/files/next/postcss.config.mjs.template +7 -0
- package/dist/generators/add-tailwind/files/react-vite/index.css.template +2 -0
- package/dist/generators/add-tailwind/generator.js +26 -0
- package/dist/generators/allow-builds/generator.js +7 -207
- package/dist/generators/doctor/generator.js +388 -29
- package/dist/generators/entity/generator.js +4 -3
- package/dist/generators/feature/generator.js +4 -3
- package/dist/generators/init/generator.js +49 -10
- 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 +7 -3
- package/generators.json +10 -0
- package/package.json +1 -1
- package/src/generators/add-storybook/schema.json +33 -0
- package/src/generators/add-tailwind/schema.json +18 -0
- package/src/generators/init/schema.json +8 -0
|
@@ -3,7 +3,31 @@ import {
|
|
|
3
3
|
} from "../_chunks/chunk-U6LAFHSF.js";
|
|
4
4
|
import {
|
|
5
5
|
detectUnitTestRunner
|
|
6
|
-
} from "../_chunks/chunk-
|
|
6
|
+
} from "../_chunks/chunk-CHZPA6OE.js";
|
|
7
|
+
import {
|
|
8
|
+
STORYBOOK_TAILWIND_CSS,
|
|
9
|
+
STORYBOOK_UNKNOWN_VITE_TARGET,
|
|
10
|
+
STORYBOOK_VITE_CONFIG_PLUGIN_TARGET,
|
|
11
|
+
STORYBOOK_VITE_PLUGIN_TARGET,
|
|
12
|
+
TAILWIND_VITE_IMPORT,
|
|
13
|
+
ensurePreviewImport,
|
|
14
|
+
ensureTailwindCss,
|
|
15
|
+
hasTailwindImport,
|
|
16
|
+
loadedViteStylesheets,
|
|
17
|
+
loadsTailwindVitePlugin,
|
|
18
|
+
nextRootLayout,
|
|
19
|
+
postcssHasTailwind,
|
|
20
|
+
storiesCoverSource,
|
|
21
|
+
storybookDefaultViteConfig,
|
|
22
|
+
storybookEslintStatus,
|
|
23
|
+
storybookMainFramework,
|
|
24
|
+
storybookViteTarget,
|
|
25
|
+
tailwindEntryStylesheet,
|
|
26
|
+
tailwindSourceLine,
|
|
27
|
+
tailwindSourcePaths,
|
|
28
|
+
viteAppLayerStylesheet,
|
|
29
|
+
viteTailwindEntry
|
|
30
|
+
} from "../_chunks/chunk-B6RBCUIL.js";
|
|
7
31
|
import "../_chunks/chunk-ASY3CK5L.js";
|
|
8
32
|
import {
|
|
9
33
|
REVIEW_MODES,
|
|
@@ -15,7 +39,7 @@ import {
|
|
|
15
39
|
import {
|
|
16
40
|
createGroupDetector,
|
|
17
41
|
indexFilePattern
|
|
18
|
-
} from "../_chunks/chunk-
|
|
42
|
+
} from "../_chunks/chunk-22FVJUNE.js";
|
|
19
43
|
import {
|
|
20
44
|
resolveFsdPolicy
|
|
21
45
|
} from "../_chunks/chunk-5MI3O4VZ.js";
|
|
@@ -29,15 +53,22 @@ import {
|
|
|
29
53
|
lintInputsProjectSnippet,
|
|
30
54
|
lintInputsTargetDefaultsSnippet,
|
|
31
55
|
resolveTargetDefaults
|
|
32
|
-
} from "../_chunks/chunk-
|
|
56
|
+
} from "../_chunks/chunk-SZRBDQCU.js";
|
|
57
|
+
import "../_chunks/chunk-KNVBFTH4.js";
|
|
58
|
+
import "../_chunks/chunk-R2VEJGNP.js";
|
|
33
59
|
import {
|
|
60
|
+
inferredRootApp,
|
|
34
61
|
isBackend,
|
|
35
62
|
isEndToEnd,
|
|
36
63
|
resolveFrontendApp,
|
|
37
64
|
sourceRootOf
|
|
38
|
-
} from "../_chunks/chunk-
|
|
39
|
-
import
|
|
40
|
-
|
|
65
|
+
} from "../_chunks/chunk-W2BBF5MS.js";
|
|
66
|
+
import {
|
|
67
|
+
detectFramework
|
|
68
|
+
} from "../_chunks/chunk-YEMQFSL6.js";
|
|
69
|
+
import {
|
|
70
|
+
resolveProjectType
|
|
71
|
+
} from "../_chunks/chunk-TXAQ2GJC.js";
|
|
41
72
|
import {
|
|
42
73
|
ESLINT_CONFIG_CANDIDATES,
|
|
43
74
|
classifyBoundaryConstraints,
|
|
@@ -55,11 +86,11 @@ import {
|
|
|
55
86
|
import "../_chunks/chunk-34V6HAJT.js";
|
|
56
87
|
import {
|
|
57
88
|
diskRunNx
|
|
58
|
-
} from "../_chunks/chunk-
|
|
89
|
+
} from "../_chunks/chunk-JSHZ6VSW.js";
|
|
59
90
|
import {
|
|
60
91
|
readToolkitConfig,
|
|
61
92
|
recordedFrontends
|
|
62
|
-
} from "../_chunks/chunk-
|
|
93
|
+
} from "../_chunks/chunk-736LFDT4.js";
|
|
63
94
|
import {
|
|
64
95
|
detectWorkspacePackageManager,
|
|
65
96
|
runNxCommand
|
|
@@ -143,7 +174,7 @@ function detectEnvironment(root) {
|
|
|
143
174
|
|
|
144
175
|
// ../template-engine/dist/doctor/run-doctor-checks.js
|
|
145
176
|
import { existsSync as existsSync7 } from "node:fs";
|
|
146
|
-
import { join as
|
|
177
|
+
import { join as join9 } from "node:path";
|
|
147
178
|
|
|
148
179
|
// ../template-engine/dist/doctor/review-checks.js
|
|
149
180
|
import { existsSync as existsSync2, readdirSync, readFileSync as readFileSync2 } from "node:fs";
|
|
@@ -1094,6 +1125,293 @@ function buildLintInputsSpreadCheck(root, projects) {
|
|
|
1094
1125
|
});
|
|
1095
1126
|
}
|
|
1096
1127
|
|
|
1128
|
+
// ../template-engine/dist/doctor/storybook-setup-check.js
|
|
1129
|
+
import { posix } from "node:path";
|
|
1130
|
+
|
|
1131
|
+
// ../template-engine/dist/doctor/recorded-tools.js
|
|
1132
|
+
import { readdirSync as readdirSync6, readFileSync as readFileSync7, statSync } from "node:fs";
|
|
1133
|
+
import { join as join8 } from "node:path";
|
|
1134
|
+
function recordedToolProjects(root, key, field = "projects") {
|
|
1135
|
+
try {
|
|
1136
|
+
const config = JSON.parse(readFileSync7(join8(root, "toolkit.config.json"), "utf-8"));
|
|
1137
|
+
const section = typeof config === "object" && config !== null ? config[key] : void 0;
|
|
1138
|
+
const projects = typeof section === "object" && section !== null ? section[field] : void 0;
|
|
1139
|
+
return Array.isArray(projects) ? projects.filter((entry) => typeof entry === "string") : [];
|
|
1140
|
+
} catch {
|
|
1141
|
+
return [];
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
function diskFiles(root) {
|
|
1145
|
+
return {
|
|
1146
|
+
read: (path) => {
|
|
1147
|
+
try {
|
|
1148
|
+
return readFileSync7(join8(root, path), "utf-8");
|
|
1149
|
+
} catch {
|
|
1150
|
+
return null;
|
|
1151
|
+
}
|
|
1152
|
+
},
|
|
1153
|
+
children: (dir) => {
|
|
1154
|
+
try {
|
|
1155
|
+
return readdirSync6(join8(root, dir));
|
|
1156
|
+
} catch {
|
|
1157
|
+
return [];
|
|
1158
|
+
}
|
|
1159
|
+
},
|
|
1160
|
+
isFile: (path) => {
|
|
1161
|
+
try {
|
|
1162
|
+
return statSync(join8(root, path)).isFile();
|
|
1163
|
+
} catch {
|
|
1164
|
+
return true;
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
};
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
// ../template-engine/dist/doctor/storybook-setup-check.js
|
|
1171
|
+
var STORYBOOK_MAINS = ["main.ts", "main.mts", "main.js"];
|
|
1172
|
+
var STORYBOOK_PREVIEWS = ["preview.ts", "preview.tsx", "preview.mts", "preview.js", "preview.jsx"];
|
|
1173
|
+
var ESLINT_CONFIGS = ["eslint.config.mjs", "eslint.config.js", "eslint.config.cjs", "eslint.config.ts", "eslint.config.mts"];
|
|
1174
|
+
var SOURCE_STORIES_GLOB = "'../src/**/*.@(mdx|stories.@(js|jsx|ts|tsx))'";
|
|
1175
|
+
var REACT_VITE = "@storybook/react-vite";
|
|
1176
|
+
var NEXTJS = "@storybook/nextjs";
|
|
1177
|
+
var LIBRARY_SOURCE_LINE = '@source "../src";';
|
|
1178
|
+
var prefixOf = (root) => root === "" || root === "." ? "" : `${root}/`;
|
|
1179
|
+
function commonProblems(root, project, main) {
|
|
1180
|
+
const files = diskFiles(root);
|
|
1181
|
+
const exists = (path) => files.read(path) !== null;
|
|
1182
|
+
const name = project.name;
|
|
1183
|
+
const dir = prefixOf(project.root);
|
|
1184
|
+
const problems = [];
|
|
1185
|
+
if (!storiesCoverSource(files.read(main) ?? "")) {
|
|
1186
|
+
problems.push(`${name}: ${main}'s stories don't reach every layer under ${project.sourceRoot} \u2014 use ${SOURCE_STORIES_GLOB}`);
|
|
1187
|
+
}
|
|
1188
|
+
const eslint = ESLINT_CONFIGS.map((file) => `${dir}${file}`).find(exists);
|
|
1189
|
+
if (eslint !== void 0) {
|
|
1190
|
+
const rootConfig = dir === "" ? void 0 : ESLINT_CONFIGS.find(exists);
|
|
1191
|
+
const status = storybookEslintStatus(files.read(eslint) ?? "", rootConfig === void 0 ? "" : files.read(rootConfig) ?? "");
|
|
1192
|
+
if (!status.plugin)
|
|
1193
|
+
problems.push(`${name}: ${eslint} does not load eslint-plugin-storybook`);
|
|
1194
|
+
if (!status.ignore)
|
|
1195
|
+
problems.push(`${name}: ${eslint} does not ignore storybook-static \u2014 lint reads the built Storybook otherwise`);
|
|
1196
|
+
}
|
|
1197
|
+
return problems;
|
|
1198
|
+
}
|
|
1199
|
+
function appProblems(root, project, tailwindApps) {
|
|
1200
|
+
const files = diskFiles(root);
|
|
1201
|
+
const exists = (path) => files.read(path) !== null;
|
|
1202
|
+
const name = project.name;
|
|
1203
|
+
const storybookDir = `${prefixOf(project.root)}.storybook`;
|
|
1204
|
+
const framework = detectFramework({ exists, read: files.read, projectRoot: project.root }).id;
|
|
1205
|
+
if (framework !== "react-vite" && framework !== "next") {
|
|
1206
|
+
return [`${name}: not a React (Vite) or Next.js app (${framework}) \u2014 add-storybook supports those two`];
|
|
1207
|
+
}
|
|
1208
|
+
const main = STORYBOOK_MAINS.map((file) => `${storybookDir}/${file}`).find(exists);
|
|
1209
|
+
if (main === void 0)
|
|
1210
|
+
return [`${name}: no .storybook/main in ${project.root} \u2014 run Nx's Storybook setup (nx g @nx/storybook:configuration ${name})`];
|
|
1211
|
+
const problems = commonProblems(root, project, main);
|
|
1212
|
+
if (tailwindApps.includes(name)) {
|
|
1213
|
+
const stylesheet = tailwindEntryStylesheet({ root: project.root, sourceRoot: project.sourceRoot, framework }, files);
|
|
1214
|
+
const preview = STORYBOOK_PREVIEWS.map((file) => `${storybookDir}/${file}`).find(exists) ?? `${storybookDir}/preview.ts`;
|
|
1215
|
+
if (stylesheet !== null && !exists(stylesheet)) {
|
|
1216
|
+
problems.push(`${name}: the app's Tailwind stylesheet ${stylesheet} is missing (see tailwind-setup), so the preview can't import it`);
|
|
1217
|
+
} else if (stylesheet !== null) {
|
|
1218
|
+
const relative = posix.relative(storybookDir, stylesheet);
|
|
1219
|
+
const spec = relative.startsWith(".") ? relative : `./${relative}`;
|
|
1220
|
+
const text = files.read(preview);
|
|
1221
|
+
if (text === null || ensurePreviewImport(text, spec).status !== "already-applied") {
|
|
1222
|
+
problems.push(`${name}: ${preview} does not import ${stylesheet} \u2014 add import '${spec}'; first`);
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
return problems;
|
|
1227
|
+
}
|
|
1228
|
+
function libraryProblems(root, project, tailwindLibraries) {
|
|
1229
|
+
const files = diskFiles(root);
|
|
1230
|
+
const exists = (path) => files.read(path) !== null;
|
|
1231
|
+
const name = project.name;
|
|
1232
|
+
const storybookDir = `${prefixOf(project.root)}.storybook`;
|
|
1233
|
+
const main = STORYBOOK_MAINS.map((file) => `${storybookDir}/${file}`).find(exists);
|
|
1234
|
+
if (main === void 0) {
|
|
1235
|
+
return [`${name}: no .storybook/main in ${project.root} \u2014 run Nx's Storybook setup (nx g @nx/storybook:configuration ${name} --uiFramework=${REACT_VITE})`];
|
|
1236
|
+
}
|
|
1237
|
+
const mainText = files.read(main) ?? "";
|
|
1238
|
+
const framework = storybookMainFramework(mainText);
|
|
1239
|
+
if (framework !== null && framework !== REACT_VITE) {
|
|
1240
|
+
const steps = framework === NEXTJS ? `; rerun add-storybook --project=${name} for the steps that switch it` : "";
|
|
1241
|
+
return [`${name}: its Storybook uses ${framework} \u2014 add-storybook supports React (Vite) libraries only${steps}`];
|
|
1242
|
+
}
|
|
1243
|
+
const problems = commonProblems(root, project, main);
|
|
1244
|
+
if (!tailwindLibraries.includes(name))
|
|
1245
|
+
return problems;
|
|
1246
|
+
const add = `add ${TAILWIND_VITE_IMPORT} and tailwindcss() in`;
|
|
1247
|
+
const target = storybookViteTarget(mainText);
|
|
1248
|
+
if (target.kind === "viteFinal" && !loadsTailwindVitePlugin(mainText)) {
|
|
1249
|
+
problems.push(`${name}: ${main} does not load Tailwind \u2014 ${add} ${STORYBOOK_VITE_PLUGIN_TARGET}`);
|
|
1250
|
+
} else if (target.kind === "viteConfigPath") {
|
|
1251
|
+
const viteConfig = posix.join(project.root, target.path);
|
|
1252
|
+
if (!loadsTailwindVitePlugin(files.read(viteConfig) ?? "")) {
|
|
1253
|
+
problems.push(`${name}: ${viteConfig} does not load Tailwind \u2014 its Storybook loads this Vite config (viteConfigPath); ${add} ${STORYBOOK_VITE_CONFIG_PLUGIN_TARGET}`);
|
|
1254
|
+
}
|
|
1255
|
+
} else if (target.kind === "none") {
|
|
1256
|
+
const viteConfig = storybookDefaultViteConfig(project.root, exists);
|
|
1257
|
+
if (viteConfig === null) {
|
|
1258
|
+
problems.push(`${name}: ${main} has no viteFinal or viteConfigPath \u2014 ${add} ${STORYBOOK_UNKNOWN_VITE_TARGET}`);
|
|
1259
|
+
} else if (!loadsTailwindVitePlugin(files.read(viteConfig) ?? "")) {
|
|
1260
|
+
problems.push(`${name}: ${viteConfig} does not load Tailwind \u2014 .storybook/main names no viteConfigPath, so its Storybook loads this Vite config; ${add} ${STORYBOOK_VITE_CONFIG_PLUGIN_TARGET}`);
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
const css = `${storybookDir}/tailwind.css`;
|
|
1264
|
+
const cssText = files.read(css);
|
|
1265
|
+
if (cssText === null) {
|
|
1266
|
+
problems.push(`${name}: ${css} is missing \u2014 rerun add-storybook --project=${name}`);
|
|
1267
|
+
} else if (ensureTailwindCss(cssText, LIBRARY_SOURCE_LINE).status !== "already-applied") {
|
|
1268
|
+
problems.push(`${name}: ${css} does not load Tailwind with @source "../src" \u2014 add @import "tailwindcss"; and ${LIBRARY_SOURCE_LINE}`);
|
|
1269
|
+
}
|
|
1270
|
+
const preview = STORYBOOK_PREVIEWS.map((file) => `${storybookDir}/${file}`).find(exists) ?? `${storybookDir}/preview.ts`;
|
|
1271
|
+
const previewText = files.read(preview);
|
|
1272
|
+
if (previewText === null || ensurePreviewImport(previewText, STORYBOOK_TAILWIND_CSS).status !== "already-applied") {
|
|
1273
|
+
problems.push(`${name}: ${preview} does not import ${STORYBOOK_TAILWIND_CSS} \u2014 add import '${STORYBOOK_TAILWIND_CSS}'; first`);
|
|
1274
|
+
}
|
|
1275
|
+
return problems;
|
|
1276
|
+
}
|
|
1277
|
+
function buildStorybookSetupCheck(root, projects) {
|
|
1278
|
+
const recorded = recordedToolProjects(root, "storybook");
|
|
1279
|
+
const base = { id: "storybook-setup", label: "Storybook setup" };
|
|
1280
|
+
if (recorded.length === 0) {
|
|
1281
|
+
return createDoctorCheck({ ...base, status: "pass", message: "Storybook was not added by nx-archweave \u2014 nothing to check", evidence: [] });
|
|
1282
|
+
}
|
|
1283
|
+
if (projects === void 0) {
|
|
1284
|
+
return createDoctorCheck({
|
|
1285
|
+
...base,
|
|
1286
|
+
status: "warning",
|
|
1287
|
+
message: "Could not read the workspace projects \u2014 the recorded Storybook apps were not checked",
|
|
1288
|
+
evidence: recorded.map((name) => `recorded: ${name}`),
|
|
1289
|
+
suggestedAction: "Fix the project.json that Nx cannot parse, then run doctor again."
|
|
1290
|
+
});
|
|
1291
|
+
}
|
|
1292
|
+
const tailwindApps = recordedToolProjects(root, "tailwind");
|
|
1293
|
+
const tailwindLibraries = recordedToolProjects(root, "storybook", "tailwind");
|
|
1294
|
+
const problems = recorded.flatMap((name) => {
|
|
1295
|
+
const project = projects.find((candidate) => candidate.name === name);
|
|
1296
|
+
if (project === void 0)
|
|
1297
|
+
return [`recorded project ${name} not found`];
|
|
1298
|
+
return project.projectType === "library" ? libraryProblems(root, project, tailwindLibraries) : appProblems(root, project, tailwindApps);
|
|
1299
|
+
});
|
|
1300
|
+
if (problems.length === 0) {
|
|
1301
|
+
return createDoctorCheck({ ...base, status: "pass", message: `Storybook is set up in ${recorded.join(", ")}`, evidence: recorded });
|
|
1302
|
+
}
|
|
1303
|
+
return createDoctorCheck({
|
|
1304
|
+
...base,
|
|
1305
|
+
status: "warning",
|
|
1306
|
+
message: "Storybook setup is incomplete in the recorded projects",
|
|
1307
|
+
evidence: problems,
|
|
1308
|
+
suggestedAction: "Add what each line names, or rerun add-storybook --project=<project> (--applyEslint for the ESLint lines). Remove a project that no longer exists from toolkit.config.json's storybook.projects."
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
// ../template-engine/dist/doctor/tailwind-setup-check.js
|
|
1313
|
+
import { posix as posix2 } from "node:path";
|
|
1314
|
+
var VITE_CONFIGS = ["vite.config.mts", "vite.config.ts", "vite.config.mjs", "vite.config.js", "vite.config.cts", "vite.config.cjs"];
|
|
1315
|
+
var POSTCSS_CONFIGS = ["postcss.config.mjs", "postcss.config.js", "postcss.config.cjs", "postcss.config.ts", "postcss.config.mts", "postcss.config.json"];
|
|
1316
|
+
var prefixOf2 = (root) => root === "" || root === "." ? "" : `${root}/`;
|
|
1317
|
+
var within = (path, dir) => dir === "" || dir === "." || path === dir || path.startsWith(`${dir}/`);
|
|
1318
|
+
function globBase(path) {
|
|
1319
|
+
const wildcard = path.search(/[*?[{]/);
|
|
1320
|
+
if (wildcard === -1)
|
|
1321
|
+
return path;
|
|
1322
|
+
const slash = path.lastIndexOf("/", wildcard);
|
|
1323
|
+
return slash === -1 ? "." : path.slice(0, slash);
|
|
1324
|
+
}
|
|
1325
|
+
function appProblems2(root, project, projects) {
|
|
1326
|
+
const files = diskFiles(root);
|
|
1327
|
+
const read = files.read;
|
|
1328
|
+
const exists = (path) => read(path) !== null;
|
|
1329
|
+
const name = project.name;
|
|
1330
|
+
const appDir = prefixOf2(project.root);
|
|
1331
|
+
const src = prefixOf2(project.sourceRoot);
|
|
1332
|
+
const framework = detectFramework({ exists, read, projectRoot: project.root }).id;
|
|
1333
|
+
const problems = [];
|
|
1334
|
+
let stylesheet = null;
|
|
1335
|
+
if (framework === "react-vite") {
|
|
1336
|
+
const configs = VITE_CONFIGS.map((file) => `${appDir}${file}`).filter(exists);
|
|
1337
|
+
if (!configs.some((path) => loadsTailwindVitePlugin(read(path) ?? ""))) {
|
|
1338
|
+
problems.push(`${name}: ${configs[0] ?? `${appDir}vite.config.mts`} does not load @tailwindcss/vite`);
|
|
1339
|
+
}
|
|
1340
|
+
const loaded = loadedViteStylesheets(project, files);
|
|
1341
|
+
const entry = viteTailwindEntry(project, files, loaded);
|
|
1342
|
+
const appLayer = viteAppLayerStylesheet(project.sourceRoot);
|
|
1343
|
+
if (entry !== null) {
|
|
1344
|
+
stylesheet = entry;
|
|
1345
|
+
} else {
|
|
1346
|
+
const css2 = read(appLayer);
|
|
1347
|
+
if (css2 === null) {
|
|
1348
|
+
problems.push(`${name}: no stylesheet the app loads has @import "tailwindcss", and ${appLayer} is missing`);
|
|
1349
|
+
} else {
|
|
1350
|
+
if (!loaded.includes(appLayer)) {
|
|
1351
|
+
problems.push(`${name}: nothing under ${project.sourceRoot} imports ${appLayer} \u2014 add import './styles/index.css'; to ${src}app/app.tsx`);
|
|
1352
|
+
}
|
|
1353
|
+
stylesheet = appLayer;
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
} else if (framework === "next") {
|
|
1357
|
+
if (!POSTCSS_CONFIGS.map((file) => `${appDir}${file}`).some((path) => postcssHasTailwind(read(path) ?? ""))) {
|
|
1358
|
+
problems.push(`${name}: no PostCSS config in ${project.root} loads @tailwindcss/postcss`);
|
|
1359
|
+
}
|
|
1360
|
+
stylesheet = tailwindEntryStylesheet({ ...project, framework }, files);
|
|
1361
|
+
if (stylesheet === null) {
|
|
1362
|
+
problems.push(`${name}: ${nextRootLayout(project, files) ?? `${src}app/layout.tsx`} imports no single local stylesheet to load Tailwind from`);
|
|
1363
|
+
}
|
|
1364
|
+
} else {
|
|
1365
|
+
problems.push(`${name}: not a React (Vite) or Next.js app (${framework}) \u2014 add-tailwind supports those two`);
|
|
1366
|
+
}
|
|
1367
|
+
const css = stylesheet === null ? null : read(stylesheet);
|
|
1368
|
+
if (stylesheet !== null && css === null)
|
|
1369
|
+
problems.push(`${name}: ${stylesheet} is missing`);
|
|
1370
|
+
if (stylesheet !== null && css !== null) {
|
|
1371
|
+
if (!hasTailwindImport(css))
|
|
1372
|
+
problems.push(`${name}: ${stylesheet} has no @import "tailwindcss"`);
|
|
1373
|
+
const sources = tailwindSourcePaths(css).map((path) => posix2.normalize(posix2.join(posix2.dirname(stylesheet), globBase(path))));
|
|
1374
|
+
for (const dependency of project.dependencies ?? []) {
|
|
1375
|
+
const library = projects.find((other) => other.packageName === dependency && other.name !== project.name);
|
|
1376
|
+
if (library === void 0 || within(library.root, project.root) || sources.some((source) => within(library.root, source)))
|
|
1377
|
+
continue;
|
|
1378
|
+
const line = tailwindSourceLine(posix2.relative(posix2.dirname(stylesheet), library.root));
|
|
1379
|
+
problems.push(`${name}: depends on ${dependency} (${library.root}), which no @source in ${stylesheet} covers \u2014 add ${line}`);
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
return problems;
|
|
1383
|
+
}
|
|
1384
|
+
function buildTailwindSetupCheck(root, projects) {
|
|
1385
|
+
const recorded = recordedToolProjects(root, "tailwind");
|
|
1386
|
+
const base = { id: "tailwind-setup", label: "Tailwind setup" };
|
|
1387
|
+
if (recorded.length === 0) {
|
|
1388
|
+
return createDoctorCheck({ ...base, status: "pass", message: "Tailwind was not added by nx-archweave \u2014 nothing to check", evidence: [] });
|
|
1389
|
+
}
|
|
1390
|
+
if (projects === void 0) {
|
|
1391
|
+
return createDoctorCheck({
|
|
1392
|
+
...base,
|
|
1393
|
+
status: "warning",
|
|
1394
|
+
message: "Could not read the workspace projects \u2014 the recorded Tailwind apps were not checked",
|
|
1395
|
+
evidence: recorded.map((name) => `recorded: ${name}`),
|
|
1396
|
+
suggestedAction: "Fix the project.json that Nx cannot parse, then run doctor again."
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
const problems = recorded.flatMap((name) => {
|
|
1400
|
+
const project = projects.find((candidate) => candidate.name === name);
|
|
1401
|
+
return project === void 0 ? [`recorded project ${name} not found`] : appProblems2(root, project, projects);
|
|
1402
|
+
});
|
|
1403
|
+
if (problems.length === 0) {
|
|
1404
|
+
return createDoctorCheck({ ...base, status: "pass", message: `Tailwind CSS v4 is wired in ${recorded.join(", ")}`, evidence: recorded });
|
|
1405
|
+
}
|
|
1406
|
+
return createDoctorCheck({
|
|
1407
|
+
...base,
|
|
1408
|
+
status: "warning",
|
|
1409
|
+
message: "Tailwind setup is incomplete in the recorded apps",
|
|
1410
|
+
evidence: problems,
|
|
1411
|
+
suggestedAction: "Add what each line names, or rerun add-tailwind --project=<app>. Remove an app that no longer exists from toolkit.config.json's tailwind.projects."
|
|
1412
|
+
});
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1097
1415
|
// ../template-engine/dist/doctor/run-doctor-checks.js
|
|
1098
1416
|
var NOT_APPLICABLE_IDS = [
|
|
1099
1417
|
"fsd-like-structure",
|
|
@@ -1101,6 +1419,8 @@ var NOT_APPLICABLE_IDS = [
|
|
|
1101
1419
|
"fsd-rule-anchored",
|
|
1102
1420
|
"fsd-lint-cache",
|
|
1103
1421
|
"lint-inputs-spread",
|
|
1422
|
+
"tailwind-setup",
|
|
1423
|
+
"storybook-setup",
|
|
1104
1424
|
"nx-version",
|
|
1105
1425
|
"package-manager",
|
|
1106
1426
|
"workspace-root",
|
|
@@ -1149,6 +1469,8 @@ function runDoctorChecks(root, projects, nxSupport) {
|
|
|
1149
1469
|
buildFsdRuleAnchoredCheck(root, projects),
|
|
1150
1470
|
buildLintCacheCheck(root, projects),
|
|
1151
1471
|
buildLintInputsSpreadCheck(root, projects),
|
|
1472
|
+
buildTailwindSetupCheck(root, projects),
|
|
1473
|
+
buildStorybookSetupCheck(root, projects),
|
|
1152
1474
|
createDoctorCheck({
|
|
1153
1475
|
id: "package-manager",
|
|
1154
1476
|
label: "Package manager",
|
|
@@ -1174,8 +1496,9 @@ function runDoctorChecks(root, projects, nxSupport) {
|
|
|
1174
1496
|
const overallStatus = computeOverallStatus(checks);
|
|
1175
1497
|
return { checks, overallStatus };
|
|
1176
1498
|
}
|
|
1177
|
-
var VALIDATED_NX_MAJORS = [
|
|
1178
|
-
var VALIDATED_RANGE_TEXT = `${VALIDATED_NX_MAJORS[0]}.x\u2013${VALIDATED_NX_MAJORS[VALIDATED_NX_MAJORS.length - 1]}.x`;
|
|
1499
|
+
var VALIDATED_NX_MAJORS = [24];
|
|
1500
|
+
var VALIDATED_RANGE_TEXT = VALIDATED_NX_MAJORS.length === 1 ? `${VALIDATED_NX_MAJORS[0]}.x` : `${VALIDATED_NX_MAJORS[0]}.x\u2013${VALIDATED_NX_MAJORS[VALIDATED_NX_MAJORS.length - 1]}.x`;
|
|
1501
|
+
var NEWEST_VALIDATED_MAJOR = VALIDATED_NX_MAJORS[VALIDATED_NX_MAJORS.length - 1];
|
|
1179
1502
|
function extractMajor(version) {
|
|
1180
1503
|
const match = /(\d+)/.exec(version);
|
|
1181
1504
|
return match ? Number(match[1]) : null;
|
|
@@ -1231,6 +1554,16 @@ function buildNxVersionCheck(env, nxSupport) {
|
|
|
1231
1554
|
evidence: [`nx@${env.nxVersion}`]
|
|
1232
1555
|
});
|
|
1233
1556
|
}
|
|
1557
|
+
if (nxSupport !== void 0 && major >= nxSupport.supportedMajors.min && major <= nxSupport.supportedMajors.max) {
|
|
1558
|
+
return createDoctorCheck({
|
|
1559
|
+
id: "nx-version",
|
|
1560
|
+
label: "Nx version",
|
|
1561
|
+
status: "warning",
|
|
1562
|
+
message: `Nx ${env.nxVersion} is outside the toolkit-validated range (${VALIDATED_RANGE_TEXT}) \u2014 may work, unvalidated`,
|
|
1563
|
+
evidence: [`nx@${env.nxVersion}`],
|
|
1564
|
+
suggestedAction: major < VALIDATED_NX_MAJORS[0] ? `Upgrade to Nx ${NEWEST_VALIDATED_MAJOR}, or stay on @clearlydev/nx-archweave 0.6.x.` : "Proceed with care and report issues; validation for newer majors lands with toolkit updates."
|
|
1565
|
+
});
|
|
1566
|
+
}
|
|
1234
1567
|
if (major < VALIDATED_NX_MAJORS[0]) {
|
|
1235
1568
|
return createDoctorCheck({
|
|
1236
1569
|
id: "nx-version",
|
|
@@ -1238,7 +1571,7 @@ function buildNxVersionCheck(env, nxSupport) {
|
|
|
1238
1571
|
status: "warning",
|
|
1239
1572
|
message: `Nx ${env.nxVersion} is below the toolkit-validated range (${VALIDATED_RANGE_TEXT}) \u2014 generator behavior is not guaranteed`,
|
|
1240
1573
|
evidence: [`nx@${env.nxVersion}`],
|
|
1241
|
-
suggestedAction: `Upgrade the workspace to Nx ${
|
|
1574
|
+
suggestedAction: `Upgrade the workspace to Nx ${NEWEST_VALIDATED_MAJOR}.x before running the generators.`
|
|
1242
1575
|
});
|
|
1243
1576
|
}
|
|
1244
1577
|
return createDoctorCheck({
|
|
@@ -1294,7 +1627,7 @@ function buildFrameworkChecks(env) {
|
|
|
1294
1627
|
];
|
|
1295
1628
|
}
|
|
1296
1629
|
function buildExistingConfigCheck(root) {
|
|
1297
|
-
const exists = existsSync7(
|
|
1630
|
+
const exists = existsSync7(join9(root, "toolkit.config.json"));
|
|
1298
1631
|
return createDoctorCheck({
|
|
1299
1632
|
id: "existing-config",
|
|
1300
1633
|
label: "toolkit.config.json",
|
|
@@ -1304,7 +1637,7 @@ function buildExistingConfigCheck(root) {
|
|
|
1304
1637
|
});
|
|
1305
1638
|
}
|
|
1306
1639
|
function buildIntegrationManifestCheck(root) {
|
|
1307
|
-
const exists = existsSync7(
|
|
1640
|
+
const exists = existsSync7(join9(root, "archweave-integrations.json"));
|
|
1308
1641
|
return createDoctorCheck({
|
|
1309
1642
|
id: "integration-manifest",
|
|
1310
1643
|
label: "Integration manifest",
|
|
@@ -1314,8 +1647,8 @@ function buildIntegrationManifestCheck(root) {
|
|
|
1314
1647
|
});
|
|
1315
1648
|
}
|
|
1316
1649
|
function buildAgentRulesCheck(root) {
|
|
1317
|
-
const claudeExists = existsSync7(
|
|
1318
|
-
const agentsExists = existsSync7(
|
|
1650
|
+
const claudeExists = existsSync7(join9(root, "CLAUDE.md"));
|
|
1651
|
+
const agentsExists = existsSync7(join9(root, "AGENTS.md"));
|
|
1319
1652
|
const exists = claudeExists || agentsExists;
|
|
1320
1653
|
const evidence = [claudeExists && "CLAUDE.md", agentsExists && "AGENTS.md"].filter(Boolean);
|
|
1321
1654
|
return createDoctorCheck({
|
|
@@ -1327,8 +1660,8 @@ function buildAgentRulesCheck(root) {
|
|
|
1327
1660
|
});
|
|
1328
1661
|
}
|
|
1329
1662
|
function buildGithubTemplatesCheck(root) {
|
|
1330
|
-
const issueTemplateExists = existsSync7(
|
|
1331
|
-
const prTemplateExists = existsSync7(
|
|
1663
|
+
const issueTemplateExists = existsSync7(join9(root, ".github", "ISSUE_TEMPLATE"));
|
|
1664
|
+
const prTemplateExists = existsSync7(join9(root, ".github", "PULL_REQUEST_TEMPLATE.md"));
|
|
1332
1665
|
const exists = issueTemplateExists || prTemplateExists;
|
|
1333
1666
|
const managed = isToolkitManaged(root);
|
|
1334
1667
|
return createDoctorCheck({
|
|
@@ -1465,16 +1798,16 @@ function buildIntegrationDoctorChecks(results) {
|
|
|
1465
1798
|
}
|
|
1466
1799
|
|
|
1467
1800
|
// ../integrations/dist/config/read-enabled-integrations.js
|
|
1468
|
-
import { existsSync as existsSync8, readFileSync as
|
|
1469
|
-
import { join as
|
|
1801
|
+
import { existsSync as existsSync8, readFileSync as readFileSync8 } from "node:fs";
|
|
1802
|
+
import { join as join10 } from "node:path";
|
|
1470
1803
|
var CONFIG_FILENAME = "toolkit.config.json";
|
|
1471
1804
|
function readEnabledIntegrationIds(root) {
|
|
1472
|
-
const configPath =
|
|
1805
|
+
const configPath = join10(root, CONFIG_FILENAME);
|
|
1473
1806
|
if (!existsSync8(configPath)) {
|
|
1474
1807
|
return [];
|
|
1475
1808
|
}
|
|
1476
1809
|
try {
|
|
1477
|
-
const parsed = JSON.parse(
|
|
1810
|
+
const parsed = JSON.parse(readFileSync8(configPath, "utf8"));
|
|
1478
1811
|
const enabled = parsed?.integrations?.enabled;
|
|
1479
1812
|
return Array.isArray(enabled) && enabled.every((id) => typeof id === "string") ? enabled : [];
|
|
1480
1813
|
} catch {
|
|
@@ -1534,16 +1867,42 @@ async function applyLiveVerification(driftResults, ctx) {
|
|
|
1534
1867
|
|
|
1535
1868
|
// src/generators/doctor/workspace-checks.ts
|
|
1536
1869
|
import { getProjects, joinPathFragments } from "@nx/devkit";
|
|
1870
|
+
function packageFacts(tree, root) {
|
|
1871
|
+
const raw = tree.read(joinPathFragments(root, "package.json"), "utf-8");
|
|
1872
|
+
if (raw === null) return {};
|
|
1873
|
+
let pkg;
|
|
1874
|
+
try {
|
|
1875
|
+
pkg = JSON.parse(raw);
|
|
1876
|
+
} catch {
|
|
1877
|
+
return {};
|
|
1878
|
+
}
|
|
1879
|
+
if (typeof pkg !== "object" || pkg === null || Array.isArray(pkg)) return {};
|
|
1880
|
+
const record = pkg;
|
|
1881
|
+
const names = (field) => {
|
|
1882
|
+
const value = record[field];
|
|
1883
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? Object.keys(value) : [];
|
|
1884
|
+
};
|
|
1885
|
+
return {
|
|
1886
|
+
...typeof record["name"] === "string" ? { packageName: record["name"] } : {},
|
|
1887
|
+
dependencies: [.../* @__PURE__ */ new Set([...names("dependencies"), ...names("devDependencies")])]
|
|
1888
|
+
};
|
|
1889
|
+
}
|
|
1537
1890
|
function doctorProjects(tree) {
|
|
1538
1891
|
try {
|
|
1539
1892
|
const backendTag = readBoundaryTags(readToolkitConfig(tree)).backend;
|
|
1540
|
-
|
|
1893
|
+
const projects = getProjects(tree);
|
|
1894
|
+
const listed = [...projects.entries()].map(([name, config]) => ({
|
|
1541
1895
|
name,
|
|
1542
1896
|
root: config.root,
|
|
1543
1897
|
sourceRoot: sourceRootOf(tree, config),
|
|
1544
1898
|
tags: config.tags ?? [],
|
|
1545
|
-
|
|
1546
|
-
|
|
1899
|
+
projectType: resolveProjectType(tree, config.root, config.projectType),
|
|
1900
|
+
...isEndToEnd(config.root) || isBackend(config.root, config, backendTag) ? { fsdScan: false } : {},
|
|
1901
|
+
...packageFacts(tree, config.root)
|
|
1902
|
+
}));
|
|
1903
|
+
const rootApp = inferredRootApp(tree, projects);
|
|
1904
|
+
if (rootApp?.kind === "found") listed.push({ name: rootApp.project, root: ".", sourceRoot: rootApp.sourceRoot, tags: [], projectType: "application", ...packageFacts(tree, ".") });
|
|
1905
|
+
return listed.sort((a, b) => a.name.localeCompare(b.name));
|
|
1547
1906
|
} catch {
|
|
1548
1907
|
return void 0;
|
|
1549
1908
|
}
|
|
@@ -1686,9 +2045,9 @@ function buildPolicySuggestion(tree, sourceRoot, current) {
|
|
|
1686
2045
|
}
|
|
1687
2046
|
|
|
1688
2047
|
// src/generators/doctor/nx-support.ts
|
|
1689
|
-
import { readFileSync as
|
|
2048
|
+
import { readFileSync as readFileSync9 } from "node:fs";
|
|
1690
2049
|
import { createRequire } from "node:module";
|
|
1691
|
-
import { join as
|
|
2050
|
+
import { join as join11 } from "node:path";
|
|
1692
2051
|
var MAJORS_EITHER_SIDE = 1;
|
|
1693
2052
|
function majorOf(version) {
|
|
1694
2053
|
const match = /^(\d+)\./.exec(version.trim());
|
|
@@ -1697,7 +2056,7 @@ function majorOf(version) {
|
|
|
1697
2056
|
function readOwnDevkitVersion() {
|
|
1698
2057
|
try {
|
|
1699
2058
|
const path = createRequire(import.meta.url).resolve("@nx/devkit/package.json");
|
|
1700
|
-
const version = JSON.parse(
|
|
2059
|
+
const version = JSON.parse(readFileSync9(path, "utf-8")).version;
|
|
1701
2060
|
return typeof version === "string" ? version : void 0;
|
|
1702
2061
|
} catch {
|
|
1703
2062
|
return void 0;
|
|
@@ -1705,7 +2064,7 @@ function readOwnDevkitVersion() {
|
|
|
1705
2064
|
}
|
|
1706
2065
|
function readInstalledNx(root) {
|
|
1707
2066
|
try {
|
|
1708
|
-
const version = JSON.parse(
|
|
2067
|
+
const version = JSON.parse(readFileSync9(join11(root, "node_modules", "nx", "package.json"), "utf-8")).version;
|
|
1709
2068
|
return typeof version === "string" ? version : void 0;
|
|
1710
2069
|
} catch {
|
|
1711
2070
|
return void 0;
|
|
@@ -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-CHZPA6OE.js";
|
|
7
|
+
import "../_chunks/chunk-R2VEJGNP.js";
|
|
8
|
+
import "../_chunks/chunk-W2BBF5MS.js";
|
|
8
9
|
import "../_chunks/chunk-YEMQFSL6.js";
|
|
9
10
|
import "../_chunks/chunk-TXAQ2GJC.js";
|
|
10
11
|
import "../_chunks/chunk-6ZTIUBB2.js";
|
|
@@ -13,7 +14,7 @@ import "../_chunks/chunk-JPS6XKYK.js";
|
|
|
13
14
|
import {
|
|
14
15
|
resolveDryRun
|
|
15
16
|
} from "../_chunks/chunk-TUN34LAQ.js";
|
|
16
|
-
import "../_chunks/chunk-
|
|
17
|
+
import "../_chunks/chunk-736LFDT4.js";
|
|
17
18
|
import "../_chunks/chunk-5Z7VZPES.js";
|
|
18
19
|
import "../_chunks/chunk-BDLK2IID.js";
|
|
19
20
|
|
|
@@ -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-CHZPA6OE.js";
|
|
7
|
+
import "../_chunks/chunk-R2VEJGNP.js";
|
|
8
|
+
import "../_chunks/chunk-W2BBF5MS.js";
|
|
8
9
|
import "../_chunks/chunk-YEMQFSL6.js";
|
|
9
10
|
import "../_chunks/chunk-TXAQ2GJC.js";
|
|
10
11
|
import "../_chunks/chunk-6ZTIUBB2.js";
|
|
@@ -13,7 +14,7 @@ import "../_chunks/chunk-JPS6XKYK.js";
|
|
|
13
14
|
import {
|
|
14
15
|
resolveDryRun
|
|
15
16
|
} from "../_chunks/chunk-TUN34LAQ.js";
|
|
16
|
-
import "../_chunks/chunk-
|
|
17
|
+
import "../_chunks/chunk-736LFDT4.js";
|
|
17
18
|
import "../_chunks/chunk-5Z7VZPES.js";
|
|
18
19
|
import "../_chunks/chunk-BDLK2IID.js";
|
|
19
20
|
|