@cubocicloide/stack-react-fastapi 13.0.6

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.
Files changed (295) hide show
  1. package/LICENSE +33 -0
  2. package/README.md +66 -0
  3. package/dist/commands/lint/checks/BE/001.d.ts +6 -0
  4. package/dist/commands/lint/checks/BE/001.js +95 -0
  5. package/dist/commands/lint/checks/BE/001.js.map +1 -0
  6. package/dist/commands/lint/checks/BE/002.d.ts +6 -0
  7. package/dist/commands/lint/checks/BE/002.js +30 -0
  8. package/dist/commands/lint/checks/BE/002.js.map +1 -0
  9. package/dist/commands/lint/checks/BE/003.d.ts +11 -0
  10. package/dist/commands/lint/checks/BE/003.js +46 -0
  11. package/dist/commands/lint/checks/BE/003.js.map +1 -0
  12. package/dist/commands/lint/checks/BE/004.d.ts +6 -0
  13. package/dist/commands/lint/checks/BE/004.js +27 -0
  14. package/dist/commands/lint/checks/BE/004.js.map +1 -0
  15. package/dist/commands/lint/checks/BE/005.d.ts +6 -0
  16. package/dist/commands/lint/checks/BE/005.js +107 -0
  17. package/dist/commands/lint/checks/BE/005.js.map +1 -0
  18. package/dist/commands/lint/checks/BE/006.d.ts +6 -0
  19. package/dist/commands/lint/checks/BE/006.js +27 -0
  20. package/dist/commands/lint/checks/BE/006.js.map +1 -0
  21. package/dist/commands/lint/checks/BE/007.d.ts +31 -0
  22. package/dist/commands/lint/checks/BE/007.js +109 -0
  23. package/dist/commands/lint/checks/BE/007.js.map +1 -0
  24. package/dist/commands/lint/checks/BE/008.d.ts +12 -0
  25. package/dist/commands/lint/checks/BE/008.js +57 -0
  26. package/dist/commands/lint/checks/BE/008.js.map +1 -0
  27. package/dist/commands/lint/checks/BE/009.d.ts +12 -0
  28. package/dist/commands/lint/checks/BE/009.js +104 -0
  29. package/dist/commands/lint/checks/BE/009.js.map +1 -0
  30. package/dist/commands/lint/checks/BE/010.d.ts +12 -0
  31. package/dist/commands/lint/checks/BE/010.js +54 -0
  32. package/dist/commands/lint/checks/BE/010.js.map +1 -0
  33. package/dist/commands/lint/checks/BE/011.d.ts +16 -0
  34. package/dist/commands/lint/checks/BE/011.js +46 -0
  35. package/dist/commands/lint/checks/BE/011.js.map +1 -0
  36. package/dist/commands/lint/checks/E2E/001.d.ts +6 -0
  37. package/dist/commands/lint/checks/E2E/001.js +35 -0
  38. package/dist/commands/lint/checks/E2E/001.js.map +1 -0
  39. package/dist/commands/lint/checks/E2E/002.d.ts +6 -0
  40. package/dist/commands/lint/checks/E2E/002.js +37 -0
  41. package/dist/commands/lint/checks/E2E/002.js.map +1 -0
  42. package/dist/commands/lint/checks/E2E/003.d.ts +6 -0
  43. package/dist/commands/lint/checks/E2E/003.js +42 -0
  44. package/dist/commands/lint/checks/E2E/003.js.map +1 -0
  45. package/dist/commands/lint/checks/E2E/004.d.ts +6 -0
  46. package/dist/commands/lint/checks/E2E/004.js +37 -0
  47. package/dist/commands/lint/checks/E2E/004.js.map +1 -0
  48. package/dist/commands/lint/checks/E2E/005.d.ts +6 -0
  49. package/dist/commands/lint/checks/E2E/005.js +47 -0
  50. package/dist/commands/lint/checks/E2E/005.js.map +1 -0
  51. package/dist/commands/lint/checks/E2E/006.d.ts +6 -0
  52. package/dist/commands/lint/checks/E2E/006.js +28 -0
  53. package/dist/commands/lint/checks/E2E/006.js.map +1 -0
  54. package/dist/commands/lint/checks/E2E/007.d.ts +6 -0
  55. package/dist/commands/lint/checks/E2E/007.js +47 -0
  56. package/dist/commands/lint/checks/E2E/007.js.map +1 -0
  57. package/dist/commands/lint/checks/FE/001.d.ts +6 -0
  58. package/dist/commands/lint/checks/FE/001.js +56 -0
  59. package/dist/commands/lint/checks/FE/001.js.map +1 -0
  60. package/dist/commands/lint/checks/FE/002.d.ts +6 -0
  61. package/dist/commands/lint/checks/FE/002.js +80 -0
  62. package/dist/commands/lint/checks/FE/002.js.map +1 -0
  63. package/dist/commands/lint/checks/FE/003.d.ts +6 -0
  64. package/dist/commands/lint/checks/FE/003.js +65 -0
  65. package/dist/commands/lint/checks/FE/003.js.map +1 -0
  66. package/dist/commands/lint/checks/FE/004.d.ts +6 -0
  67. package/dist/commands/lint/checks/FE/004.js +72 -0
  68. package/dist/commands/lint/checks/FE/004.js.map +1 -0
  69. package/dist/commands/lint/checks/FE/005.d.ts +6 -0
  70. package/dist/commands/lint/checks/FE/005.js +103 -0
  71. package/dist/commands/lint/checks/FE/005.js.map +1 -0
  72. package/dist/commands/lint/checks/FE/006.d.ts +6 -0
  73. package/dist/commands/lint/checks/FE/006.js +102 -0
  74. package/dist/commands/lint/checks/FE/006.js.map +1 -0
  75. package/dist/commands/lint/checks/FE/007.d.ts +6 -0
  76. package/dist/commands/lint/checks/FE/007.js +60 -0
  77. package/dist/commands/lint/checks/FE/007.js.map +1 -0
  78. package/dist/commands/lint/checks/FE/008.d.ts +6 -0
  79. package/dist/commands/lint/checks/FE/008.js +115 -0
  80. package/dist/commands/lint/checks/FE/008.js.map +1 -0
  81. package/dist/commands/lint/checks/FE/009.d.ts +6 -0
  82. package/dist/commands/lint/checks/FE/009.js +83 -0
  83. package/dist/commands/lint/checks/FE/009.js.map +1 -0
  84. package/dist/commands/lint/checks/FE/010.d.ts +6 -0
  85. package/dist/commands/lint/checks/FE/010.js +105 -0
  86. package/dist/commands/lint/checks/FE/010.js.map +1 -0
  87. package/dist/commands/lint/checks/FE/011.d.ts +6 -0
  88. package/dist/commands/lint/checks/FE/011.js +43 -0
  89. package/dist/commands/lint/checks/FE/011.js.map +1 -0
  90. package/dist/commands/lint/checks/FE/012.d.ts +6 -0
  91. package/dist/commands/lint/checks/FE/012.js +150 -0
  92. package/dist/commands/lint/checks/FE/012.js.map +1 -0
  93. package/dist/index.d.ts +5 -0
  94. package/dist/index.js +3491 -0
  95. package/dist/index.js.map +1 -0
  96. package/dude.stack.json +7 -0
  97. package/package.json +43 -0
  98. package/templates/aws-eks/backend/Dockerfile.prod.hbs +22 -0
  99. package/templates/aws-eks/docs/docs/deploy.md.hbs +159 -0
  100. package/templates/aws-eks/frontend/Dockerfile.prod +28 -0
  101. package/templates/aws-eks/frontend/nginx.conf +19 -0
  102. package/templates/aws-eks/iac/README.md.hbs +311 -0
  103. package/templates/aws-eks/iac/_gitignore +24 -0
  104. package/templates/aws-eks/iac/helm/app/.helmignore +7 -0
  105. package/templates/aws-eks/iac/helm/app/Chart.yaml.hbs +6 -0
  106. package/templates/aws-eks/iac/helm/app/templates/NOTES.txt +23 -0
  107. package/templates/aws-eks/iac/helm/app/templates/backend-deployment.yaml +44 -0
  108. package/templates/aws-eks/iac/helm/app/templates/backend-service.yaml +16 -0
  109. package/templates/aws-eks/iac/helm/app/templates/celery-beat-deployment.yaml +34 -0
  110. package/templates/aws-eks/iac/helm/app/templates/celery-worker-deployment.yaml +31 -0
  111. package/templates/aws-eks/iac/helm/app/templates/configmap.yaml +15 -0
  112. package/templates/aws-eks/iac/helm/app/templates/flower-deployment.yaml +28 -0
  113. package/templates/aws-eks/iac/helm/app/templates/flower-service.yaml +19 -0
  114. package/templates/aws-eks/iac/helm/app/templates/frontend-deployment.yaml +34 -0
  115. package/templates/aws-eks/iac/helm/app/templates/frontend-service.yaml +16 -0
  116. package/templates/aws-eks/iac/helm/app/templates/helpers.tpl +90 -0
  117. package/templates/aws-eks/iac/helm/app/templates/hpa.yaml +23 -0
  118. package/templates/aws-eks/iac/helm/app/templates/ingress.yaml +30 -0
  119. package/templates/aws-eks/iac/helm/app/templates/migration-job.yaml +38 -0
  120. package/templates/aws-eks/iac/helm/app/templates/redis-deployment.yaml +33 -0
  121. package/templates/aws-eks/iac/helm/app/templates/redis-service.yaml +18 -0
  122. package/templates/aws-eks/iac/helm/app/templates/secret.yaml +17 -0
  123. package/templates/aws-eks/iac/helm/app/templates/serviceaccount.yaml +12 -0
  124. package/templates/aws-eks/iac/helm/app/values-dev.yaml.hbs +35 -0
  125. package/templates/aws-eks/iac/helm/app/values.yaml.hbs +130 -0
  126. package/templates/aws-eks/iac/runner/Dockerfile +53 -0
  127. package/templates/aws-eks/iac/terraform/bootstrap/main.tf.hbs +101 -0
  128. package/templates/aws-eks/iac/terraform/bootstrap/outputs.tf +19 -0
  129. package/templates/aws-eks/iac/terraform/bootstrap/variables.tf.hbs +17 -0
  130. package/templates/aws-eks/iac/terraform/environments/dev/backend.hcl.hbs +12 -0
  131. package/templates/aws-eks/iac/terraform/environments/dev/terraform.tfvars.hbs +32 -0
  132. package/templates/aws-eks/iac/terraform/main.tf.hbs +305 -0
  133. package/templates/aws-eks/iac/terraform/outputs.tf.hbs +52 -0
  134. package/templates/aws-eks/iac/terraform/providers.tf +47 -0
  135. package/templates/aws-eks/iac/terraform/variables.tf.hbs +181 -0
  136. package/templates/aws-eks/iac/terraform/versions.tf +27 -0
  137. package/templates/base/.claude/agents/issue-fixer.md +190 -0
  138. package/templates/base/.claude/agents/security-fixer.md +250 -0
  139. package/templates/base/.claude/rules/BE/001.md +25 -0
  140. package/templates/base/.claude/rules/BE/002.md +15 -0
  141. package/templates/base/.claude/rules/BE/003.md +18 -0
  142. package/templates/base/.claude/rules/BE/004.md +14 -0
  143. package/templates/base/.claude/rules/BE/005.md +15 -0
  144. package/templates/base/.claude/rules/BE/006.md +17 -0
  145. package/templates/base/.claude/rules/BE/007.md +21 -0
  146. package/templates/base/.claude/rules/BE/008.md +19 -0
  147. package/templates/base/.claude/rules/BE/009.md +27 -0
  148. package/templates/base/.claude/rules/BE/010.md +16 -0
  149. package/templates/base/.claude/rules/BE/011.md +15 -0
  150. package/templates/base/.claude/rules/E2E/001.md +13 -0
  151. package/templates/base/.claude/rules/E2E/002.md +14 -0
  152. package/templates/base/.claude/rules/E2E/003.md +10 -0
  153. package/templates/base/.claude/rules/E2E/004.md +23 -0
  154. package/templates/base/.claude/rules/E2E/005.md +15 -0
  155. package/templates/base/.claude/rules/E2E/006.md +13 -0
  156. package/templates/base/.claude/rules/E2E/007.md +18 -0
  157. package/templates/base/.claude/rules/FE/001.md +22 -0
  158. package/templates/base/.claude/rules/FE/002.md +39 -0
  159. package/templates/base/.claude/rules/FE/003.md +19 -0
  160. package/templates/base/.claude/rules/FE/004.md +21 -0
  161. package/templates/base/.claude/rules/FE/005.md +33 -0
  162. package/templates/base/.claude/rules/FE/006.md +24 -0
  163. package/templates/base/.claude/rules/FE/007.md +19 -0
  164. package/templates/base/.claude/rules/FE/008.md +26 -0
  165. package/templates/base/.claude/rules/FE/009.md +30 -0
  166. package/templates/base/.claude/rules/FE/010.md +25 -0
  167. package/templates/base/.claude/rules/FE/011.md +22 -0
  168. package/templates/base/.claude/rules/FE/012.md +32 -0
  169. package/templates/base/.claude/settings.json +53 -0
  170. package/templates/base/.claude/skills/clean-branches/SKILL.md +100 -0
  171. package/templates/base/.claude/skills/create/SKILL.md +47 -0
  172. package/templates/base/.claude/skills/create-jira-issue/SKILL.md +174 -0
  173. package/templates/base/.claude/skills/create-page/SKILL.md +195 -0
  174. package/templates/base/.claude/skills/create-route/SKILL.md +199 -0
  175. package/templates/base/.claude/skills/draft-email/SKILL.md +104 -0
  176. package/templates/base/.claude/skills/fix-issues/SKILL.md +238 -0
  177. package/templates/base/.claude/skills/security-scan/SKILL.md +297 -0
  178. package/templates/base/.claude/skills/verify-security-fixes/SKILL.md +180 -0
  179. package/templates/base/.dude/commands/README.md +85 -0
  180. package/templates/base/.dude/commands/hello.ts +34 -0
  181. package/templates/base/.dude/lint/checks/PRJ/001.ts +26 -0
  182. package/templates/base/.dude/lint/checks/README.md +69 -0
  183. package/templates/base/.vscode/tasks.json +44 -0
  184. package/templates/base/.worktreeinclude +2 -0
  185. package/templates/base/CLAUDE.md.hbs +364 -0
  186. package/templates/base/README.md.hbs +187 -0
  187. package/templates/base/_env.example.hbs +29 -0
  188. package/templates/base/_env.hbs +25 -0
  189. package/templates/base/_gitignore +31 -0
  190. package/templates/base/_npmrc +2 -0
  191. package/templates/base/backend/Dockerfile.hbs +22 -0
  192. package/templates/base/backend/README.md.hbs +74 -0
  193. package/templates/base/backend/_dockerignore +11 -0
  194. package/templates/base/backend/app/__init__.py +1 -0
  195. package/templates/base/backend/app/core/__init__.py +0 -0
  196. package/templates/base/backend/app/core/config.py.hbs +23 -0
  197. package/templates/base/backend/app/fixtures/__init__.py +0 -0
  198. package/templates/base/backend/app/main.py.hbs +41 -0
  199. package/templates/base/backend/app/management/__init__.py +0 -0
  200. package/templates/base/backend/app/models/__init__.py +0 -0
  201. package/templates/base/backend/app/queries/__init__.py +0 -0
  202. package/templates/base/backend/app/routers/__init__.py +0 -0
  203. package/templates/base/backend/app/routers/health.py +13 -0
  204. package/templates/base/backend/app/schemas/__init__.py +0 -0
  205. package/templates/base/backend/app/schemas/health.py +7 -0
  206. package/templates/base/backend/app/tasks/__init__.py +1 -0
  207. package/templates/base/backend/app/tests/__init__.py +0 -0
  208. package/templates/base/backend/app/tests/conftest.py +13 -0
  209. package/templates/base/backend/app/tests/models/__init__.py +0 -0
  210. package/templates/base/backend/app/tests/queries/__init__.py +0 -0
  211. package/templates/base/backend/app/tests/routers/__init__.py +0 -0
  212. package/templates/base/backend/app/tests/routers/test_health.py +10 -0
  213. package/templates/base/backend/app/tests/tasks/__init__.py +1 -0
  214. package/templates/base/backend/app/tests/utils/__init__.py +0 -0
  215. package/templates/base/backend/app/utils/__init__.py +0 -0
  216. package/templates/base/backend/pyproject.toml.hbs +40 -0
  217. package/templates/base/docker-compose.yml.hbs +128 -0
  218. package/templates/base/docs/docs/api.md +21 -0
  219. package/templates/base/docs/docs/dude.md.hbs +316 -0
  220. package/templates/base/docs/docs/index.md.hbs +100 -0
  221. package/templates/base/docs/docs/mkdocs.md +238 -0
  222. package/templates/base/docs/mkdocs.yml.hbs +52 -0
  223. package/templates/base/e2e/.prettierrc.json +1 -0
  224. package/templates/base/e2e/_prettierignore +3 -0
  225. package/templates/base/e2e/cucumber.js +21 -0
  226. package/templates/base/e2e/eslint.config.mjs +14 -0
  227. package/templates/base/e2e/features/example.feature +13 -0
  228. package/templates/base/e2e/package.json.hbs +30 -0
  229. package/templates/base/e2e/pages/ExamplePage.ts +16 -0
  230. package/templates/base/e2e/playwright.config.ts +27 -0
  231. package/templates/base/e2e/steps/common.steps.ts +32 -0
  232. package/templates/base/e2e/steps/example.steps.ts +4 -0
  233. package/templates/base/e2e/support/hooks.ts +72 -0
  234. package/templates/base/e2e/support/world.ts +24 -0
  235. package/templates/base/e2e/tsconfig.json +22 -0
  236. package/templates/base/frontend/.prettierrc.json +6 -0
  237. package/templates/base/frontend/Dockerfile +10 -0
  238. package/templates/base/frontend/_dockerignore +4 -0
  239. package/templates/base/frontend/eslint.config.js +32 -0
  240. package/templates/base/frontend/index.html.hbs +13 -0
  241. package/templates/base/frontend/package.json.hbs +38 -0
  242. package/templates/base/frontend/public/favicon.svg +5 -0
  243. package/templates/base/frontend/src/$components/Layout/$assets/logo.svg +5 -0
  244. package/templates/base/frontend/src/$components/Layout/constants.tsx.hbs +10 -0
  245. package/templates/base/frontend/src/$components/Layout/index.tsx +80 -0
  246. package/templates/base/frontend/src/$components/Layout/types.tsx +9 -0
  247. package/templates/base/frontend/src/$components/index.tsx +1 -0
  248. package/templates/base/frontend/src/$hooks/index.tsx +2 -0
  249. package/templates/base/frontend/src/$hooks/useCounterStore/index.tsx +28 -0
  250. package/templates/base/frontend/src/$hooks/useCounterStore/types.tsx +7 -0
  251. package/templates/base/frontend/src/$hooks/usePageTitle/index.tsx +21 -0
  252. package/templates/base/frontend/src/$types/vite-env.d.ts +10 -0
  253. package/templates/base/frontend/src/App.tsx.hbs +40 -0
  254. package/templates/base/frontend/src/main.tsx +10 -0
  255. package/templates/base/frontend/src/openapi/utils/openapi.yaml.hbs +28 -0
  256. package/templates/base/frontend/src/pages/constants.tsx +31 -0
  257. package/templates/base/frontend/src/pages/index.tsx +192 -0
  258. package/templates/base/frontend/src/pages/types.tsx +6 -0
  259. package/templates/base/frontend/src/styles.module.css +7 -0
  260. package/templates/base/frontend/src/utils/constants.tsx +11 -0
  261. package/templates/base/frontend/src/utils/formatters/index.tsx +49 -0
  262. package/templates/base/frontend/src/utils/functions.tsx +70 -0
  263. package/templates/base/frontend/src/utils/index.tsx +3 -0
  264. package/templates/base/frontend/tsconfig.json +24 -0
  265. package/templates/base/frontend/vite.config.ts +20 -0
  266. package/templates/base/package.json.hbs +11 -0
  267. package/templates/base/security/baseline.json +4 -0
  268. package/templates/celery/backend/app/tasks/__init__.py +1 -0
  269. package/templates/celery/backend/app/tasks/example.py +21 -0
  270. package/templates/celery/backend/app/tests/tasks/test_example.py +7 -0
  271. package/templates/celery/backend/app/worker.py.hbs +33 -0
  272. package/templates/celerybeat/backend/app/tasks/scheduled.py +16 -0
  273. package/templates/celerybeat/backend/app/tests/tasks/test_scheduled.py +7 -0
  274. package/templates/postgres/.dude/commands/reset.ts +76 -0
  275. package/templates/postgres/backend/alembic/env.py +55 -0
  276. package/templates/postgres/backend/alembic/script.py.mako +27 -0
  277. package/templates/postgres/backend/alembic/versions/0001_create_user_table.py +38 -0
  278. package/templates/postgres/backend/alembic.ini +42 -0
  279. package/templates/postgres/backend/app/core/database.py +15 -0
  280. package/templates/postgres/backend/app/models/__init__.py +5 -0
  281. package/templates/postgres/backend/app/models/user.py +15 -0
  282. package/templates/postgres/backend/app/queries/__init__.py +5 -0
  283. package/templates/postgres/backend/app/queries/users.py +18 -0
  284. package/templates/postgres/backend/app/routers/users.py +19 -0
  285. package/templates/postgres/backend/app/routers/users__id.py +20 -0
  286. package/templates/postgres/backend/app/tests/conftest.py +33 -0
  287. package/templates/postgres/backend/app/tests/models/test_user.py +12 -0
  288. package/templates/postgres/backend/app/tests/queries/test_users.py +12 -0
  289. package/templates/postgres/backend/app/tests/routers/test_users.py +10 -0
  290. package/templates/postgres/backend/app/tests/routers/test_users__id.py +9 -0
  291. package/templates/postgres/backend/start.sh +32 -0
  292. package/templates/postgres/frontend/src/openapi/utils/openapi.yaml.hbs +138 -0
  293. package/templates/postgres/frontend/src/pages/users/[id]/index.tsx +51 -0
  294. package/templates/postgres/frontend/src/pages/users/index.tsx +54 -0
  295. package/templates/postgres/frontend/src/pages/users/types.tsx +4 -0
@@ -0,0 +1,109 @@
1
+ // src/commands/lint/checks/BE/007.ts
2
+ import { readdirSync, existsSync, readFileSync } from "fs";
3
+ import path from "pathe";
4
+ var ROUTER_DECORATOR_RE = /^@router\.(get|post|put|patch|delete)\s*\(/;
5
+ var STRING_LITERAL_RE = /["']([^"']+)["']/;
6
+ var DEF_RE = /^(?:async\s+)?def\s+(\w+)/;
7
+ function stemToExpectedPath(stem) {
8
+ const parts = stem.split("__");
9
+ const base = "/" + (parts[0] ?? "").replace(/_/g, "/");
10
+ const params = parts.slice(1).map((p) => `/{${p}}`);
11
+ return base + params.join("");
12
+ }
13
+ function extractDecoratorPath(lines, lineIdx) {
14
+ for (let i = lineIdx; i < Math.min(lineIdx + 8, lines.length); i++) {
15
+ const line = lines[i] ?? "";
16
+ const m = STRING_LITERAL_RE.exec(line);
17
+ if (m?.[1]) return m[1];
18
+ if (i > lineIdx && /^\)/.test(line.trim())) break;
19
+ }
20
+ return null;
21
+ }
22
+ function parseRoutes(content) {
23
+ const lines = content.split("\n");
24
+ const results = [];
25
+ let pendingMethod = null;
26
+ let pendingPath = null;
27
+ for (let i = 0; i < lines.length; i++) {
28
+ const raw = lines[i] ?? "";
29
+ if (raw.length > 0 && /^\s/.test(raw)) continue;
30
+ const line = raw.trim();
31
+ if (!line || line.startsWith("#")) continue;
32
+ const decMatch = ROUTER_DECORATOR_RE.exec(line);
33
+ if (decMatch?.[1]) {
34
+ pendingMethod = decMatch[1];
35
+ pendingPath = extractDecoratorPath(lines, i);
36
+ continue;
37
+ }
38
+ const defMatch = DEF_RE.exec(line);
39
+ if (defMatch?.[1]) {
40
+ results.push({
41
+ method: pendingMethod,
42
+ fnName: defMatch[1],
43
+ declaredPath: pendingPath,
44
+ line: i + 1
45
+ });
46
+ pendingMethod = null;
47
+ pendingPath = null;
48
+ continue;
49
+ }
50
+ if (!line.startsWith("@") && !line.startsWith(")")) {
51
+ pendingMethod = null;
52
+ pendingPath = null;
53
+ }
54
+ }
55
+ return results;
56
+ }
57
+ function allowedHandlerName(method, stem) {
58
+ return `${method}_${stem}`;
59
+ }
60
+ function check(root) {
61
+ const routersDir = path.join(root, "backend", "app", "routers");
62
+ if (!existsSync(routersDir)) return [];
63
+ const diagnostics = [];
64
+ for (const entry of readdirSync(routersDir, { withFileTypes: true })) {
65
+ if (!entry.isFile() || !entry.name.endsWith(".py") || entry.name === "__init__.py") continue;
66
+ const stem = entry.name.slice(0, -3);
67
+ const relPath = path.join("backend", "app", "routers", entry.name);
68
+ const content = readFileSync(path.join(routersDir, entry.name), "utf8");
69
+ const expectedPath = stemToExpectedPath(stem);
70
+ for (const route of parseRoutes(content)) {
71
+ if (route.method === null) {
72
+ diagnostics.push({
73
+ file: relPath,
74
+ line: route.line,
75
+ col: 1,
76
+ severity: "error",
77
+ message: `\`${route.fnName}\` is not a route handler \u2014 only @router.METHOD-decorated functions are allowed in router files`
78
+ });
79
+ continue;
80
+ }
81
+ const expected = allowedHandlerName(route.method, stem);
82
+ if (route.fnName !== expected) {
83
+ diagnostics.push({
84
+ file: relPath,
85
+ line: route.line,
86
+ col: 1,
87
+ severity: "error",
88
+ message: `route handler \`${route.fnName}\` should be named \`${expected}\``
89
+ });
90
+ }
91
+ if (route.declaredPath !== null && route.declaredPath !== expectedPath) {
92
+ diagnostics.push({
93
+ file: relPath,
94
+ line: route.line,
95
+ col: 1,
96
+ severity: "error",
97
+ message: `route path \`${route.declaredPath}\` does not match expected \`${expectedPath}\` (derived from \`${entry.name}\`)`
98
+ });
99
+ }
100
+ }
101
+ }
102
+ return diagnostics;
103
+ }
104
+ export {
105
+ allowedHandlerName,
106
+ check as default,
107
+ stemToExpectedPath
108
+ };
109
+ //# sourceMappingURL=007.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/commands/lint/checks/BE/007.ts"],"sourcesContent":["import { readdirSync, existsSync, readFileSync } from 'node:fs'\nimport path from 'pathe'\nimport type { RawDiagnostic } from '@cubocicloide/dude'\n\nconst ROUTER_DECORATOR_RE = /^@router\\.(get|post|put|patch|delete)\\s*\\(/\nconst STRING_LITERAL_RE = /[\"']([^\"']+)[\"']/\nconst DEF_RE = /^(?:async\\s+)?def\\s+(\\w+)/\n\ninterface RouteInfo {\n /** null = undecorated function (not a route handler) */\n method: string | null\n fnName: string\n /** null if method is null or path could not be extracted */\n declaredPath: string | null\n line: number\n}\n\n/**\n * Derive the expected URL path from a router filename stem.\n *\n * Rules:\n * - `__param` (double underscore) → `/{param}` (path parameter)\n * - `_segment` (single underscore) → `/segment` (literal path segment)\n *\n * Examples:\n * health → /health\n * todos → /todos\n * todos__id → /todos/{id}\n * users_me → /users/me\n * keycloak_token → /keycloak/token\n */\nexport function stemToExpectedPath(stem: string): string {\n const parts = stem.split('__')\n const base = '/' + (parts[0] ?? '').replace(/_/g, '/')\n const params = parts.slice(1).map((p) => `/{${p}}`)\n return base + params.join('')\n}\n\n/**\n * Try to find the first string literal (= the path argument) in the decorator\n * call starting at `lineIdx`, scanning forward across multi-line decorators.\n */\nfunction extractDecoratorPath(lines: string[], lineIdx: number): string | null {\n for (let i = lineIdx; i < Math.min(lineIdx + 8, lines.length); i++) {\n const line = lines[i] ?? ''\n const m = STRING_LITERAL_RE.exec(line)\n if (m?.[1]) return m[1]\n // Stop at closing paren of the decorator if no string found yet\n if (i > lineIdx && /^\\)/.test(line.trim())) break\n }\n return null\n}\n\n/**\n * Scan a router file line-by-line (module-level lines only).\n * Returns one RouteInfo per top-level function definition.\n */\nfunction parseRoutes(content: string): RouteInfo[] {\n const lines = content.split('\\n')\n const results: RouteInfo[] = []\n let pendingMethod: string | null = null\n let pendingPath: string | null = null\n\n for (let i = 0; i < lines.length; i++) {\n const raw = lines[i] ?? ''\n\n // Only analyse module-level lines (no leading whitespace)\n if (raw.length > 0 && /^\\s/.test(raw)) continue\n\n const line = raw.trim()\n if (!line || line.startsWith('#')) continue\n\n // @router.METHOD decorator\n const decMatch = ROUTER_DECORATOR_RE.exec(line)\n if (decMatch?.[1]) {\n pendingMethod = decMatch[1]\n pendingPath = extractDecoratorPath(lines, i)\n continue\n }\n\n // def / async def\n const defMatch = DEF_RE.exec(line)\n if (defMatch?.[1]) {\n results.push({\n method: pendingMethod,\n fnName: defMatch[1],\n declaredPath: pendingPath,\n line: i + 1,\n })\n pendingMethod = null\n pendingPath = null\n continue\n }\n\n // Any other module-level statement (import, class, assignment, closing paren\n // of multi-line decorator) — only reset if it's clearly not part of a decorator\n if (!line.startsWith('@') && !line.startsWith(')')) {\n pendingMethod = null\n pendingPath = null\n }\n }\n return results\n}\n\nexport function allowedHandlerName(method: string, stem: string): string {\n return `${method}_${stem}`\n}\n\n/**\n * BE007 — router files may only contain @router.METHOD-decorated functions,\n * each named `{method}_{stem}` and mapped to the path derived from the filename.\n *\n * Examples for `todos__id.py` (stem=todos__id, expectedPath=/todos/{id}):\n * ✓ @router.get(\"/todos/{id}\") async def get_todos__id(...)\n * ✗ def ciao() — not a route handler\n * ✗ @router.get(\"/wrong\") async def get_todos__id(...) — wrong path\n * ✗ @router.get(\"/todos/{id}\") async def fetch_item(...) — wrong name\n */\nexport default function check(root: string): RawDiagnostic[] {\n const routersDir = path.join(root, 'backend', 'app', 'routers')\n if (!existsSync(routersDir)) return []\n\n const diagnostics: RawDiagnostic[] = []\n\n for (const entry of readdirSync(routersDir, { withFileTypes: true })) {\n if (!entry.isFile() || !entry.name.endsWith('.py') || entry.name === '__init__.py') continue\n\n const stem = entry.name.slice(0, -3)\n const relPath = path.join('backend', 'app', 'routers', entry.name)\n const content = readFileSync(path.join(routersDir, entry.name), 'utf8')\n const expectedPath = stemToExpectedPath(stem)\n\n for (const route of parseRoutes(content)) {\n // Non-route function\n if (route.method === null) {\n diagnostics.push({\n file: relPath,\n line: route.line,\n col: 1,\n severity: 'error',\n message: `\\`${route.fnName}\\` is not a route handler — only @router.METHOD-decorated functions are allowed in router files`,\n })\n continue\n }\n\n // Wrong function name\n const expected = allowedHandlerName(route.method, stem)\n if (route.fnName !== expected) {\n diagnostics.push({\n file: relPath,\n line: route.line,\n col: 1,\n severity: 'error',\n message: `route handler \\`${route.fnName}\\` should be named \\`${expected}\\``,\n })\n }\n\n // Wrong path\n if (route.declaredPath !== null && route.declaredPath !== expectedPath) {\n diagnostics.push({\n file: relPath,\n line: route.line,\n col: 1,\n severity: 'error',\n message: `route path \\`${route.declaredPath}\\` does not match expected \\`${expectedPath}\\` (derived from \\`${entry.name}\\`)`,\n })\n }\n }\n }\n\n return diagnostics\n}\n"],"mappings":";AAAA,SAAS,aAAa,YAAY,oBAAoB;AACtD,OAAO,UAAU;AAGjB,IAAM,sBAAsB;AAC5B,IAAM,oBAAoB;AAC1B,IAAM,SAAS;AAyBR,SAAS,mBAAmB,MAAsB;AACvD,QAAM,QAAQ,KAAK,MAAM,IAAI;AAC7B,QAAM,OAAO,OAAO,MAAM,CAAC,KAAK,IAAI,QAAQ,MAAM,GAAG;AACrD,QAAM,SAAS,MAAM,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,KAAK,CAAC,GAAG;AAClD,SAAO,OAAO,OAAO,KAAK,EAAE;AAC9B;AAMA,SAAS,qBAAqB,OAAiB,SAAgC;AAC7E,WAAS,IAAI,SAAS,IAAI,KAAK,IAAI,UAAU,GAAG,MAAM,MAAM,GAAG,KAAK;AAClE,UAAM,OAAO,MAAM,CAAC,KAAK;AACzB,UAAM,IAAI,kBAAkB,KAAK,IAAI;AACrC,QAAI,IAAI,CAAC,EAAG,QAAO,EAAE,CAAC;AAEtB,QAAI,IAAI,WAAW,MAAM,KAAK,KAAK,KAAK,CAAC,EAAG;AAAA,EAC9C;AACA,SAAO;AACT;AAMA,SAAS,YAAY,SAA8B;AACjD,QAAM,QAAQ,QAAQ,MAAM,IAAI;AAChC,QAAM,UAAuB,CAAC;AAC9B,MAAI,gBAA+B;AACnC,MAAI,cAA6B;AAEjC,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,UAAM,MAAM,MAAM,CAA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tE,UAAM,eAAe,mBAAmB,IAAI;AAE5C,eAAW,SAAS,YAAY,OAAO,GAAG;AAExC,UAAI,MAAM,WAAW,MAAM;AACzB,oBAAY,KAAK;AAAA,UACf,MAAM;AAAA,UACN,MAAM,MAAM;AAAA,UACZ,KAAK;AAAA,UACL,UAAU;AAAA,UACV,SAAS,KAAK,MAAM,MAAM;AAAA,QAC5B,CAAC;AACD;AAAA,MACF;AAGA,YAAM,WAAW,mBAAmB,MAAM,QAAQ,IAAI;AACtD,UAAI,MAAM,WAAW,UAAU;AAC7B,oBAAY,KAAK;AAAA,UACf,MAAM;AAAA,UACN,MAAM,MAAM;AAAA,UACZ,KAAK;AAAA,UACL,UAAU;AAAA,UACV,SAAS,mBAAmB,MAAM,MAAM,wBAAwB,QAAQ;AAAA,QAC1E,CAAC;AAAA,MACH;AAGA,UAAI,MAAM,iBAAiB,QAAQ,MAAM,iBAAiB,cAAc;AACtE,oBAAY,KAAK;AAAA,UACf,MAAM;AAAA,UACN,MAAM,MAAM;AAAA,UACZ,KAAK;AAAA,UACL,UAAU;AAAA,UACV,SAAS,gBAAgB,MAAM,YAAY,gCAAgC,YAAY,sBAAsB,MAAM,IAAI;AAAA,QACzH,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,12 @@
1
+ import { RawDiagnostic } from '@cubocicloide/dude';
2
+
3
+ /**
4
+ * BE008 — every source file in models/queries/routers/tasks/utils must have a
5
+ * corresponding test file in tests/{group}/test_{stem}.py, and vice-versa.
6
+ *
7
+ * Warning: source file exists but test is missing → add the test.
8
+ * Error: test file exists but source is missing → orphaned test.
9
+ */
10
+ declare function check(root: string): RawDiagnostic[];
11
+
12
+ export { check as default };
@@ -0,0 +1,57 @@
1
+ // src/commands/lint/checks/BE/008.ts
2
+ import { readdirSync, existsSync } from "fs";
3
+ import path from "pathe";
4
+ var GROUPS = ["models", "queries", "routers", "tasks", "utils"];
5
+ function check(root) {
6
+ const appDir = path.join(root, "backend", "app");
7
+ const testsDir = path.join(appDir, "tests");
8
+ if (!existsSync(appDir) || !existsSync(testsDir)) return [];
9
+ const diagnostics = [];
10
+ for (const group of GROUPS) {
11
+ const srcDir = path.join(appDir, group);
12
+ const testDir = path.join(testsDir, group);
13
+ const srcStems = /* @__PURE__ */ new Set();
14
+ if (existsSync(srcDir)) {
15
+ for (const e of readdirSync(srcDir, { withFileTypes: true })) {
16
+ if (e.isFile() && e.name.endsWith(".py") && e.name !== "__init__.py") {
17
+ srcStems.add(e.name.slice(0, -3));
18
+ }
19
+ }
20
+ }
21
+ const testStems = /* @__PURE__ */ new Set();
22
+ if (existsSync(testDir)) {
23
+ for (const e of readdirSync(testDir, { withFileTypes: true })) {
24
+ if (e.isFile() && e.name.startsWith("test_") && e.name.endsWith(".py")) {
25
+ testStems.add(e.name.slice("test_".length, -3));
26
+ }
27
+ }
28
+ }
29
+ for (const stem of srcStems) {
30
+ if (!testStems.has(stem)) {
31
+ diagnostics.push({
32
+ file: path.join("backend", "app", group, `${stem}.py`),
33
+ line: 1,
34
+ col: 1,
35
+ severity: "warning",
36
+ message: `tests/${group}/test_${stem}.py is missing \u2014 no tests for \`${group}/${stem}.py\``
37
+ });
38
+ }
39
+ }
40
+ for (const stem of testStems) {
41
+ if (!srcStems.has(stem)) {
42
+ diagnostics.push({
43
+ file: path.join("backend", "app", "tests", group, `test_${stem}.py`),
44
+ line: 1,
45
+ col: 1,
46
+ severity: "error",
47
+ message: `\`test_${stem}.py\` has no corresponding \`${group}/${stem}.py\` \u2014 remove this test or create the source file`
48
+ });
49
+ }
50
+ }
51
+ }
52
+ return diagnostics;
53
+ }
54
+ export {
55
+ check as default
56
+ };
57
+ //# sourceMappingURL=008.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/commands/lint/checks/BE/008.ts"],"sourcesContent":["import { readdirSync, existsSync } from 'node:fs'\nimport path from 'pathe'\nimport type { RawDiagnostic } from '@cubocicloide/dude'\n\n/** Groups that must have 1-to-1 source ↔ test file coverage. */\nconst GROUPS = ['models', 'queries', 'routers', 'tasks', 'utils'] as const\n\n/**\n * BE008 — every source file in models/queries/routers/tasks/utils must have a\n * corresponding test file in tests/{group}/test_{stem}.py, and vice-versa.\n *\n * Warning: source file exists but test is missing → add the test.\n * Error: test file exists but source is missing → orphaned test.\n */\nexport default function check(root: string): RawDiagnostic[] {\n const appDir = path.join(root, 'backend', 'app')\n const testsDir = path.join(appDir, 'tests')\n if (!existsSync(appDir) || !existsSync(testsDir)) return []\n\n const diagnostics: RawDiagnostic[] = []\n\n for (const group of GROUPS) {\n const srcDir = path.join(appDir, group)\n const testDir = path.join(testsDir, group)\n\n // Collect source stems (exclude __init__.py)\n const srcStems = new Set<string>()\n if (existsSync(srcDir)) {\n for (const e of readdirSync(srcDir, { withFileTypes: true })) {\n if (e.isFile() && e.name.endsWith('.py') && e.name !== '__init__.py') {\n srcStems.add(e.name.slice(0, -3))\n }\n }\n }\n\n // Collect test stems from test_*.py files (exclude __init__.py)\n const testStems = new Set<string>()\n if (existsSync(testDir)) {\n for (const e of readdirSync(testDir, { withFileTypes: true })) {\n if (e.isFile() && e.name.startsWith('test_') && e.name.endsWith('.py')) {\n testStems.add(e.name.slice('test_'.length, -3))\n }\n }\n }\n\n // Warning: source exists, test missing\n for (const stem of srcStems) {\n if (!testStems.has(stem)) {\n diagnostics.push({\n file: path.join('backend', 'app', group, `${stem}.py`),\n line: 1,\n col: 1,\n severity: 'warning',\n message: `tests/${group}/test_${stem}.py is missing — no tests for \\`${group}/${stem}.py\\``,\n })\n }\n }\n\n // Error: test exists, source missing\n for (const stem of testStems) {\n if (!srcStems.has(stem)) {\n diagnostics.push({\n file: path.join('backend', 'app', 'tests', group, `test_${stem}.py`),\n line: 1,\n col: 1,\n severity: 'error',\n message: `\\`test_${stem}.py\\` has no corresponding \\`${group}/${stem}.py\\` — remove this test or create the source file`,\n })\n }\n }\n }\n\n return diagnostics\n}\n"],"mappings":";AAAA,SA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AU;AAAA,UACV,SAAS,SAAS,KAAK,SAAS,IAAI,wCAAmC,KAAK,IAAI,IAAI;AAAA,QACtF,CAAC;AAAA,MACH;AAAA,IACF;AAGA,eAAW,QAAQ,WAAW;AAC5B,UAAI,CAAC,SAAS,IAAI,IAAI,GAAG;AACvB,oBAAY,KAAK;AAAA,UACf,MAAM,KAAK,KAAK,WAAW,OAAO,SAAS,OAAO,QAAQ,IAAI,KAAK;AAAA,UACnE,MAAM;AAAA,UACN,KAAK;AAAA,UACL,UAAU;AAAA,UACV,SAAS,UAAU,IAAI,gCAAgC,KAAK,IAAI,IAAI;AAAA,QACtE,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,12 @@
1
+ import { RawDiagnostic } from '@cubocicloide/dude';
2
+
3
+ /**
4
+ * BE009 — environment variables must be centralised in core/config.py.
5
+ *
6
+ * Warning: core/config.py is missing.
7
+ * Error: os.getenv / os.environ used outside backend/app/core/.
8
+ * Warning: Settings fields in core/config.py are not in alphabetical order.
9
+ */
10
+ declare function check(root: string): RawDiagnostic[];
11
+
12
+ export { check as default };
@@ -0,0 +1,104 @@
1
+ // src/commands/lint/checks/BE/009.ts
2
+ import { readdirSync, existsSync, readFileSync } from "fs";
3
+ import path from "pathe";
4
+ var OS_ENV_RE = /\bos\.(getenv|environ)\b/;
5
+ function extractSettingsFields(content) {
6
+ const lines = content.split("\n");
7
+ let inClass = false;
8
+ let classIndent = 0;
9
+ const fields = [];
10
+ for (const raw of lines) {
11
+ if (!inClass) {
12
+ if (/^class\s+\w+\s*\(.*BaseSettings.*\)\s*:/.test(raw)) {
13
+ inClass = true;
14
+ classIndent = 0;
15
+ }
16
+ continue;
17
+ }
18
+ if (raw.length > 0 && !/^\s/.test(raw)) break;
19
+ const stripped = raw.trimStart();
20
+ const indent = raw.length - stripped.length;
21
+ if (/^class\s+/.test(stripped)) {
22
+ classIndent = indent;
23
+ continue;
24
+ }
25
+ if (classIndent > 0 && indent > classIndent) continue;
26
+ classIndent = 0;
27
+ const m = /^([A-Za-z_]\w*)\s*[:=]/.exec(stripped);
28
+ if (m?.[1] && !m[1].startsWith("__") && m[1] !== "class" && m[1] !== "model_config") {
29
+ fields.push(m[1]);
30
+ }
31
+ }
32
+ return fields;
33
+ }
34
+ function walkPyFiles(dir, skipDir, callback, relBase = "") {
35
+ for (const e of readdirSync(dir, { withFileTypes: true })) {
36
+ const abs = path.join(dir, e.name);
37
+ const rel = relBase ? `${relBase}/${e.name}` : e.name;
38
+ if (e.isDirectory()) {
39
+ if (!skipDir(e.name)) walkPyFiles(abs, skipDir, callback, rel);
40
+ } else if (e.isFile() && e.name.endsWith(".py")) {
41
+ callback(abs, rel);
42
+ }
43
+ }
44
+ }
45
+ function check(root) {
46
+ const appDir = path.join(root, "backend", "app");
47
+ if (!existsSync(appDir)) return [];
48
+ const configPath = path.join(appDir, "core", "config.py");
49
+ const appRel = path.join("backend", "app");
50
+ const diagnostics = [];
51
+ if (!existsSync(configPath)) {
52
+ diagnostics.push({
53
+ file: path.join(appRel, "core"),
54
+ line: 1,
55
+ col: 1,
56
+ severity: "warning",
57
+ message: "backend/app/core/config.py is missing \u2014 create a Pydantic BaseSettings class to centralise env vars"
58
+ });
59
+ }
60
+ const coreDir = path.join(appDir, "core");
61
+ walkPyFiles(
62
+ appDir,
63
+ // Skip the core/ subtree entirely — that's the allowed place
64
+ (name) => name === "core" || name === "__pycache__",
65
+ (absPath, relPath) => {
66
+ const content = readFileSync(absPath, "utf8");
67
+ const lines = content.split("\n");
68
+ lines.forEach((line, idx) => {
69
+ if (OS_ENV_RE.test(line) && !line.trimStart().startsWith("#")) {
70
+ diagnostics.push({
71
+ file: path.join(appRel, relPath),
72
+ line: idx + 1,
73
+ col: 1,
74
+ severity: "error",
75
+ message: `\`os.environ\`/\`os.getenv\` must not be used here \u2014 read env vars from \`app.core.config\``
76
+ });
77
+ }
78
+ });
79
+ }
80
+ );
81
+ if (existsSync(configPath)) {
82
+ const content = readFileSync(configPath, "utf8");
83
+ const fields = extractSettingsFields(content);
84
+ const sorted = [...fields].sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
85
+ const firstMismatch = fields.findIndex((f, i) => f.toLowerCase() !== sorted[i]?.toLowerCase());
86
+ if (firstMismatch !== -1) {
87
+ const actual = fields[firstMismatch];
88
+ const expected = sorted[firstMismatch];
89
+ const hint = firstMismatch === 0 ? `first field \`${actual}\` should be \`${expected}\`` : `\`${actual}\` should come after \`${fields[firstMismatch - 1]}\``;
90
+ diagnostics.push({
91
+ file: path.join(appRel, "core", "config.py"),
92
+ line: 1,
93
+ col: 1,
94
+ severity: "warning",
95
+ message: `Settings fields are not in alphabetical order \u2014 ${hint}`
96
+ });
97
+ }
98
+ }
99
+ return diagnostics;
100
+ }
101
+ export {
102
+ check as default
103
+ };
104
+ //# sourceMappingURL=009.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/commands/lint/checks/BE/009.ts"],"sourcesContent":["import { readdirSync, existsSync, readFileSync } from 'node:fs'\nimport path from 'pathe'\nimport type { RawDiagnostic } from '@cubocicloide/dude'\n\n/** Matches any direct env-var access that should only live in core/config.py */\nconst OS_ENV_RE = /\\bos\\.(getenv|environ)\\b/\n\n/**\n * Extract field names from the first `class … (BaseSettings)` block.\n * Only captures simple `FIELD_NAME: …` or `FIELD_NAME = …` lines at one\n * level of indentation (body of the class, not nested).\n */\nfunction extractSettingsFields(content: string): string[] {\n const lines = content.split('\\n')\n let inClass = false\n let classIndent = 0\n const fields: string[] = []\n\n for (const raw of lines) {\n if (!inClass) {\n if (/^class\\s+\\w+\\s*\\(.*BaseSettings.*\\)\\s*:/.test(raw)) {\n inClass = true\n classIndent = 0\n }\n continue\n }\n // End of class body: non-indented non-blank line\n if (raw.length > 0 && !/^\\s/.test(raw)) break\n const stripped = raw.trimStart()\n const indent = raw.length - stripped.length\n // Stop descending into nested classes (e.g. class Config:)\n if (/^class\\s+/.test(stripped)) {\n classIndent = indent\n continue\n }\n // Skip lines that belong to a nested class body\n if (classIndent > 0 && indent > classIndent) continue\n classIndent = 0\n // Field: ` FIELD_NAME: Type` or ` FIELD_NAME = …`\n // Exclude `model_config` — it is Pydantic's class-level metadata, not a settings field.\n const m = /^([A-Za-z_]\\w*)\\s*[:=]/.exec(stripped)\n if (m?.[1] && !m[1].startsWith('__') && m[1] !== 'class' && m[1] !== 'model_config') {\n fields.push(m[1])\n }\n }\n return fields\n}\n\nfunction walkPyFiles(\n dir: string,\n skipDir: (name: string) => boolean,\n callback: (filePath: string, relPath: string) => void,\n relBase = '',\n): void {\n for (const e of readdirSync(dir, { withFileTypes: true })) {\n const abs = path.join(dir, e.name)\n const rel = relBase ? `${relBase}/${e.name}` : e.name\n if (e.isDirectory()) {\n if (!skipDir(e.name)) walkPyFiles(abs, skipDir, callback, rel)\n } else if (e.isFile() && e.name.endsWith('.py')) {\n callback(abs, rel)\n }\n }\n}\n\n/**\n * BE009 — environment variables must be centralised in core/config.py.\n *\n * Warning: core/config.py is missing.\n * Error: os.getenv / os.environ used outside backend/app/core/.\n * Warning: Settings fields in core/config.py are not in alphabetical order.\n */\nexport default function check(root: string): RawDiagnostic[] {\n const appDir = path.join(root, 'backend', 'app')\n if (!existsSync(appDir)) return []\n\n const configPath = path.join(appDir, 'core', 'config.py')\n const appRel = path.join('backend', 'app')\n const diagnostics: RawDiagnostic[] = []\n\n // 1. Warning if core/config.py is missing\n if (!existsSync(configPath)) {\n diagnostics.push({\n file: path.join(appRel, 'core'),\n line: 1,\n col: 1,\n severity: 'warning',\n message:\n 'backend/app/core/config.py is missing — create a Pydantic BaseSettings class to centralise env vars',\n })\n }\n\n // 2. Error: os.getenv / os.environ used outside core/\n const coreDir = path.join(appDir, 'core')\n walkPyFiles(\n appDir,\n // Skip the core/ subtree entirely — that's the allowed place\n (name) => name === 'core' || name === '__pycache__',\n (absPath, relPath) => {\n const content = readFileSync(absPath, 'utf8')\n const lines = content.split('\\n')\n lines.forEach((line, idx) => {\n if (OS_ENV_RE.test(line) && !line.trimStart().startsWith('#')) {\n diagnostics.push({\n file: path.join(appRel, relPath),\n line: idx + 1,\n col: 1,\n severity: 'error',\n message: `\\`os.environ\\`/\\`os.getenv\\` must not be used here — read env vars from \\`app.core.config\\``,\n })\n }\n })\n },\n )\n\n // 3. Warning: Settings fields not in alphabetical order\n if (existsSync(configPath)) {\n const content = readFileSync(configPath, 'utf8')\n const fields = extractSettingsFields(content)\n const sorted = [...fields].sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))\n const firstMismatch = fields.findIndex((f, i) => f.toLowerCase() !== sorted[i]?.toLowerCase())\n if (firstMismatch !== -1) {\n const actual = fields[firstMismatch]!\n const expected = sorted[firstMismatch]!\n const hint =\n firstMismatch === 0\n ? `first field \\`${actual}\\` should be \\`${expected}\\``\n : `\\`${actual}\\` should come after \\`${fields[firstMismatch - 1]}\\``\n diagnostics.push({\n file: path.join(appRel, 'core', 'config.py'),\n line: 1,\n col: 1,\n severity: 'warning',\n message: `Settings fields are not in alphabetical order — ${hint}`,\n })\n }\n }\n\n return diagnostics\n}\n"],"mappings":";AAAA,SAAS,aAAa,YAAY,oBAAoB;AACtD,OAAO,UAAU;AAIjB,IAAM,YAAY;AAOlB,SAAS,sBAAsB,SAA2B;AACxD,QAAM,QAAQ,QAAQ,MAAM,IAAI;AAChC,MAAI,UAAU;AACd,MAAI,cAAc;AAClB,QAAM,SAAmB,CAAC;AAE1B,aAAW,OAAO,OAAO;AACvB,QAAI,CAAC,SAAS;AACZ,UAAI,0CAA0C,KAAK,GAAG,GAAG;AACvD,kBAAU;AACV,sBAAc;AAAA,MAChB;AACA;AAAA,IACF;AAEA,QAAI,IAAI,SAAS,KAAK,CAAC,MAAM,KAAK,GAAG,EAAG;AACxC,UAAM,WAAW,IAAI,UAAU;AAC/B,UAAM,SAAS,IAAI,SAAS,SAAS;AAErC,QAAI,YAAY,KAAK,QAAQ,GAAG;AAC9B,oBAAc;AACd;AAAA,IAC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
+ import { RawDiagnostic } from '@cubocicloide/dude';
2
+
3
+ /**
4
+ * BE010 — every file in `models/` must define exactly one class, and that
5
+ * class must be named after the file.
6
+ *
7
+ * models/group.py → exactly one class named `Group`
8
+ * models/user_profile.py → exactly one class named `UserProfile`
9
+ */
10
+ declare function check(root: string): RawDiagnostic[];
11
+
12
+ export { check as default };
@@ -0,0 +1,54 @@
1
+ // src/commands/lint/checks/BE/010.ts
2
+ import { readdirSync, existsSync, readFileSync } from "fs";
3
+ import path from "pathe";
4
+ function snakeToPascal(name) {
5
+ return name.replace(/(^|_)([a-z])/g, (_, _sep, c) => c.toUpperCase());
6
+ }
7
+ function check(root) {
8
+ const modelsDir = path.join(root, "backend", "app", "models");
9
+ if (!existsSync(modelsDir)) return [];
10
+ const diagnostics = [];
11
+ const classRe = /^class\s+(\w+)/gm;
12
+ for (const entry of readdirSync(modelsDir, { withFileTypes: true })) {
13
+ if (!entry.isFile() || !entry.name.endsWith(".py") || entry.name === "__init__.py") continue;
14
+ const stem = entry.name.replace(/\.py$/, "");
15
+ const expectedName = snakeToPascal(stem);
16
+ const relPath = path.join("backend", "app", "models", entry.name);
17
+ const content = readFileSync(path.join(modelsDir, entry.name), "utf8");
18
+ const classes = [...content.matchAll(classRe)].map((m) => m[1]);
19
+ if (classes.length === 0) {
20
+ diagnostics.push({
21
+ file: relPath,
22
+ line: 1,
23
+ col: 1,
24
+ severity: "error",
25
+ message: `models/${entry.name} defines no class \u2014 expected exactly one class named \`${expectedName}\``
26
+ });
27
+ continue;
28
+ }
29
+ if (classes.length > 1) {
30
+ diagnostics.push({
31
+ file: relPath,
32
+ line: 1,
33
+ col: 1,
34
+ severity: "error",
35
+ message: `models/${entry.name} defines ${classes.length} classes (${classes.join(", ")}) \u2014 each model file must contain exactly one class named \`${expectedName}\``
36
+ });
37
+ continue;
38
+ }
39
+ if (classes[0] !== expectedName) {
40
+ diagnostics.push({
41
+ file: relPath,
42
+ line: 1,
43
+ col: 1,
44
+ severity: "error",
45
+ message: `class \`${classes[0]}\` in models/${entry.name} must be named \`${expectedName}\` to match the file name`
46
+ });
47
+ }
48
+ }
49
+ return diagnostics;
50
+ }
51
+ export {
52
+ check as default
53
+ };
54
+ //# sourceMappingURL=010.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/commands/lint/checks/BE/010.ts"],"sourcesContent":["import { readdirSync, existsSync, readFileSync } from 'node:fs'\nimport path from 'pathe'\nimport type { RawDiagnostic } from '@cubocicloide/dude'\n\nfunction snakeToPascal(name: string): string {\n return name.replace(/(^|_)([a-z])/g, (_, _sep, c: string) => c.toUpperCase())\n}\n\n/**\n * BE010 — every file in `models/` must define exactly one class, and that\n * class must be named after the file.\n *\n * models/group.py → exactly one class named `Group`\n * models/user_profile.py → exactly one class named `UserProfile`\n */\nexport default function check(root: string): RawDiagnostic[] {\n const modelsDir = path.join(root, 'backend', 'app', 'models')\n if (!existsSync(modelsDir)) return []\n\n const diagnostics: RawDiagnostic[] = []\n const classRe = /^class\\s+(\\w+)/gm\n\n for (const entry of readdirSync(modelsDir, { withFileTypes: true })) {\n if (!entry.isFile() || !entry.name.endsWith('.py') || entry.name === '__init__.py') continue\n\n const stem = entry.name.replace(/\\.py$/, '')\n const expectedName = snakeToPascal(stem)\n const relPath = path.join('backend', 'app', 'models', entry.name)\n const content = readFileSync(path.join(modelsDir, entry.name), 'utf8')\n\n const classes = [...content.matchAll(classRe)].map((m) => m[1]!)\n\n if (classes.length === 0) {\n diagnostics.push({\n file: relPath,\n line: 1,\n col: 1,\n severity: 'error',\n message: `models/${entry.name} defines no class — expected exactly one class named \\`${expectedName}\\``,\n })\n continue\n }\n\n if (classes.length > 1) {\n diagnostics.push({\n file: relPath,\n line: 1,\n col: 1,\n severity: 'error',\n message: `models/${entry.name} defines ${classes.length} classes (${classes.join(', ')}) — each model file must contain exactly one class named \\`${expectedName}\\``,\n })\n continue\n }\n\n if (classes[0] !== expectedName) {\n diagnostics.push({\n file: relPath,\n line: 1,\n col: 1,\n severity: 'error',\n message: `class \\`${classes[0]}\\` in models/${entry.name} must be named \\`${expectedName}\\` to match the file name`,\n })\n }\n }\n\n return diagnostics\n}\n"],"mappings":";AAAA,SAAS,aAAa,YAAY,oBAAoB;AACtD,OAAO,UAAU;AAGjB,SAAS,cAAc,MAAsB;AAC3C,SAAO,KAAK,QAAQ,iBAAiB,CAAC,GAAG,MAAM,MAAc,EAAE,YAAY,CAAC;AAC9E;AASe,SAAR,MAAuB,MAA+B;AAC3D,QAAM,YAAY,KAAK,KAAK,MAAM,WAAW,OAAO,QAAQ;AAC5D,MAAI,CAAC,WAAW,SAAS,EAAG,QAAO,CAAC;AAEpC,QAAM,cAA+B,CAAC;AACtC,QAAM,UAAU;AAEhB,aAAW,SAAS,YAAY,WAAW,EAAE,eAAe,KAAK,CAAC,GAAG;AACnE,QAAI,CAAC,MAAM,OAAO,KAAK,CAAC,MAAM,KAAK,SAAS,KAAK,KAAK,MAAM,SAAS,cAAe;AAEpF,UAAM,OAAO,MAAM,KAAK,QAAQ,SAAS,EAAE;AAC3C,UAAM,eAAe,cAAc,IAAI;AACvC,UAAM,UAAU,KAAK,KAAK,WAAW,OAAO,UAAU,MAAM,IAAI;AAChE,UAAM,UAAU,aAAa,KAAK,KAAK,WAAW,MAAM,IAAI,GAAG,MAAM;AAErE,UAAM,UAAU,CAAC,GAAG,QAAQ,SAAS,OAAO,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAE;AAE/D,QAAI,QAAQ,WAAW,GAAG;AACxB,kBAAY,KAAK;AAAA,QACf,MAAM;AAAA,QACN,MAAM;AAAA,QACN,KAAK;AAAA,QACL,UAAU;AAAA,QACV,SAAS,UAAU,MAAM,IAAI,+DAA0D,YAAY;AAAA,MACrG,CAAC;AACD;AAAA,IACF;AAEA,QAAI,QAAQ,SAAS,GAAG;AACtB,kBAAY,KAAK;AAAA,QACf,MAAM;AAAA,QACN,MAAM;AAAA,QACN,KAAK;AAAA,QACL,UAAU;AAAA,QACV,SAAS,UAAU,MAAM,IAAI,YAAY,QAAQ,MAAM,aAAa,QAAQ,KAAK,IAAI,CAAC,mEAA8D,YAAY;AAAA,MAClK,CAAC;AACD;AAAA,IACF;AAEA,QAAI,QAAQ,CAAC,MAAM,cAAc;AAC/B,kBAAY,KAAK;AAAA,QACf,MAAM;AAAA,QACN,MAAM;AAAA,QACN,KAAK;AAAA,QACL,UAAU;AAAA,QACV,SAAS,WAAW,QAAQ,CAAC,CAAC,gBAAgB,MAAM,IAAI,oBAAoB,YAAY;AAAA,MAC1F,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,16 @@
1
+ import { RawDiagnostic } from '@cubocicloide/dude';
2
+
3
+ /**
4
+ * BE011 — every class in a `queries/` file must be named with the PascalCase
5
+ * prefix derived from the filename. Multiple classes are allowed.
6
+ *
7
+ * queries/todos.py → Todos, TodosList, TodosDelete, … are all valid
8
+ * queries/users.py → Users, UsersCreate, UsersById, …
9
+ *
10
+ * Rules:
11
+ * - Error if the file defines no classes at all
12
+ * - Error for each class whose name does not start with the expected prefix
13
+ */
14
+ declare function check(root: string): RawDiagnostic[];
15
+
16
+ export { check as default };
@@ -0,0 +1,46 @@
1
+ // src/commands/lint/checks/BE/011.ts
2
+ import { readdirSync, existsSync, readFileSync } from "fs";
3
+ import path from "pathe";
4
+ function snakeToPascal(name) {
5
+ return name.replace(/(^|_)([a-z])/g, (_, _sep, c) => c.toUpperCase());
6
+ }
7
+ function check(root) {
8
+ const queriesDir = path.join(root, "backend", "app", "queries");
9
+ if (!existsSync(queriesDir)) return [];
10
+ const diagnostics = [];
11
+ const classRe = /^class\s+(\w+)/gm;
12
+ for (const entry of readdirSync(queriesDir, { withFileTypes: true })) {
13
+ if (!entry.isFile() || !entry.name.endsWith(".py") || entry.name === "__init__.py") continue;
14
+ const stem = entry.name.replace(/\.py$/, "");
15
+ const expectedPrefix = snakeToPascal(stem);
16
+ const relPath = path.join("backend", "app", "queries", entry.name);
17
+ const content = readFileSync(path.join(queriesDir, entry.name), "utf8");
18
+ const classes = [...content.matchAll(classRe)].map((m) => m[1]);
19
+ if (classes.length === 0) {
20
+ diagnostics.push({
21
+ file: relPath,
22
+ line: 1,
23
+ col: 1,
24
+ severity: "error",
25
+ message: `queries/${entry.name} defines no classes \u2014 expected at least one class starting with \`${expectedPrefix}\``
26
+ });
27
+ continue;
28
+ }
29
+ for (const cls of classes) {
30
+ if (!cls.startsWith(expectedPrefix)) {
31
+ diagnostics.push({
32
+ file: relPath,
33
+ line: 1,
34
+ col: 1,
35
+ severity: "error",
36
+ message: `class \`${cls}\` in queries/${entry.name} must start with \`${expectedPrefix}\` (e.g. \`${expectedPrefix}\`, \`${expectedPrefix}List\`, \`${expectedPrefix}Delete\`)`
37
+ });
38
+ }
39
+ }
40
+ }
41
+ return diagnostics;
42
+ }
43
+ export {
44
+ check as default
45
+ };
46
+ //# sourceMappingURL=011.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/commands/lint/checks/BE/011.ts"],"sourcesContent":["import { readdirSync, existsSync, readFileSync } from 'node:fs'\nimport path from 'pathe'\nimport type { RawDiagnostic } from '@cubocicloide/dude'\n\nfunction snakeToPascal(name: string): string {\n return name.replace(/(^|_)([a-z])/g, (_, _sep, c: string) => c.toUpperCase())\n}\n\n/**\n * BE011 — every class in a `queries/` file must be named with the PascalCase\n * prefix derived from the filename. Multiple classes are allowed.\n *\n * queries/todos.py → Todos, TodosList, TodosDelete, … are all valid\n * queries/users.py → Users, UsersCreate, UsersById, …\n *\n * Rules:\n * - Error if the file defines no classes at all\n * - Error for each class whose name does not start with the expected prefix\n */\nexport default function check(root: string): RawDiagnostic[] {\n const queriesDir = path.join(root, 'backend', 'app', 'queries')\n if (!existsSync(queriesDir)) return []\n\n const diagnostics: RawDiagnostic[] = []\n const classRe = /^class\\s+(\\w+)/gm\n\n for (const entry of readdirSync(queriesDir, { withFileTypes: true })) {\n if (!entry.isFile() || !entry.name.endsWith('.py') || entry.name === '__init__.py') continue\n\n const stem = entry.name.replace(/\\.py$/, '')\n const expectedPrefix = snakeToPascal(stem)\n const relPath = path.join('backend', 'app', 'queries', entry.name)\n const content = readFileSync(path.join(queriesDir, entry.name), 'utf8')\n\n const classes = [...content.matchAll(classRe)].map((m) => m[1]!)\n\n if (classes.length === 0) {\n diagnostics.push({\n file: relPath,\n line: 1,\n col: 1,\n severity: 'error',\n message: `queries/${entry.name} defines no classes — expected at least one class starting with \\`${expectedPrefix}\\``,\n })\n continue\n }\n\n for (const cls of classes) {\n if (!cls.startsWith(expectedPrefix)) {\n diagnostics.push({\n file: relPath,\n line: 1,\n col: 1,\n severity: 'error',\n message: `class \\`${cls}\\` in queries/${entry.name} must start with \\`${expectedPrefix}\\` (e.g. \\`${expectedPrefix}\\`, \\`${expectedPrefix}List\\`, \\`${expectedPrefix}Delete\\`)`,\n })\n }\n }\n }\n\n return diagnostics\n}\n"],"mappings":";AAAA,SAAS,aAAa,YAAY,oBAAoB;AACtD,OAAO,UAAU;AAGjB,SAAS,cAAc,MAAsB;AAC3C,SAAO,KAAK,QAAQ,iBAAiB,CAAC,GAAG,MAAM,MAAc,EAAE,YAAY,CAAC;AAC9E;AAae,SAAR,MAAuB,MAA+B;AAC3D,QAAM,aAAa,KAAK,KAAK,MAAM,WAAW,OAAO,SAAS;AAC9D,MAAI,CAAC,WAAW,UAAU,EAAG,QAAO,CAAC;AAErC,QAAM,cAA+B,CAAC;AACtC,QAAM,UAAU;AAEhB,aAAW,SAAS,YAAY,YAAY,EAAE,eAAe,KAAK,CAAC,GAAG;AACpE,QAAI,CAAC,MAAM,OAAO,KAAK,CAAC,MAAM,KAAK,SAAS,KAAK,KAAK,MAAM,SAAS,cAAe;AAEpF,UAAM,OAAO,MAAM,KAAK,QAAQ,SAAS,EAAE;AAC3C,UAAM,iBAAiB,cAAc,IAAI;AACzC,UAAM,UAAU,KAAK,KAAK,WAAW,OAAO,WAAW,MAAM,IAAI;AACjE,UAAM,UAAU,aAAa,KAAK,KAAK,YAAY,MAAM,IAAI,GAAG,MAAM;AAEtE,UAAM,UAAU,CAAC,GAAG,QAAQ,SAAS,OAAO,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAE;AAE/D,QAAI,QAAQ,WAAW,GAAG;AACxB,kBAAY,KAAK;AAAA,QACf,MAAM;AAAA,QACN,MAAM;AAAA,QACN,KAAK;AAAA,QACL,UAAU;AAAA,QACV,SAAS,WAAW,MAAM,IAAI,0EAAqE,cAAc;AAAA,MACnH,CAAC;AACD;AAAA,IACF;AAEA,eAAW,OAAO,SAAS;AACzB,UAAI,CAAC,IAAI,WAAW,cAAc,GAAG;AACnC,oBAAY,KAAK;AAAA,UACf,MAAM;AAAA,UACN,MAAM;AAAA,UACN,KAAK;AAAA,UACL,UAAU;AAAA,UACV,SAAS,WAAW,GAAG,iBAAiB,MAAM,IAAI,sBAAsB,cAAc,cAAc,cAAc,SAAS,cAAc,aAAa,cAAc;AAAA,QACtK,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,6 @@
1
+ import { RawDiagnostic } from '@cubocicloide/dude';
2
+
3
+ /** ET001 — feature file names must be snake_case */
4
+ declare function check(root: string): RawDiagnostic[];
5
+
6
+ export { check as default };
@@ -0,0 +1,35 @@
1
+ // src/commands/lint/checks/E2E/001.ts
2
+ import { readdirSync, existsSync } from "fs";
3
+ import path from "pathe";
4
+ var SNAKE_CASE = /^[a-z][a-z0-9_]*$/;
5
+ function collectFiles(dir, ext) {
6
+ if (!existsSync(dir)) return [];
7
+ const results = [];
8
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
9
+ const full = path.join(dir, entry.name);
10
+ if (entry.isDirectory()) results.push(...collectFiles(full, ext));
11
+ else if (entry.name.endsWith(ext)) results.push(full);
12
+ }
13
+ return results;
14
+ }
15
+ function check(root) {
16
+ const featuresDir = path.join(root, "e2e", "features");
17
+ const diagnostics = [];
18
+ for (const file of collectFiles(featuresDir, ".feature")) {
19
+ const stem = path.basename(file).replace(/\.feature$/, "");
20
+ if (!SNAKE_CASE.test(stem)) {
21
+ diagnostics.push({
22
+ file: path.relative(root, file),
23
+ line: 1,
24
+ col: 1,
25
+ severity: "error",
26
+ message: `Feature file "${path.basename(file)}" must use snake_case (got "${stem}").`
27
+ });
28
+ }
29
+ }
30
+ return diagnostics;
31
+ }
32
+ export {
33
+ check as default
34
+ };
35
+ //# sourceMappingURL=001.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/commands/lint/checks/E2E/001.ts"],"sourcesContent":["import { readdirSync, existsSync } from 'node:fs'\nimport path from 'pathe'\nimport type { RawDiagnostic } from '@cubocicloide/dude'\n\nconst SNAKE_CASE = /^[a-z][a-z0-9_]*$/\n\nfunction collectFiles(dir: string, ext: string): string[] {\n if (!existsSync(dir)) return []\n const results: string[] = []\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n const full = path.join(dir, entry.name)\n if (entry.isDirectory()) results.push(...collectFiles(full, ext))\n else if (entry.name.endsWith(ext)) results.push(full)\n }\n return results\n}\n\n/** ET001 — feature file names must be snake_case */\nexport default function check(root: string): RawDiagnostic[] {\n const featuresDir = path.join(root, 'e2e', 'features')\n const diagnostics: RawDiagnostic[] = []\n\n for (const file of collectFiles(featuresDir, '.feature')) {\n const stem = path.basename(file).replace(/\\.feature$/, '')\n if (!SNAKE_CASE.test(stem)) {\n diagnostics.push({\n file: path.relative(root, file),\n line: 1,\n col: 1,\n severity: 'error',\n message: `Feature file \"${path.basename(file)}\" must use snake_case (got \"${stem}\").`,\n })\n }\n }\n\n return diagnostics\n}\n"],"mappings":";AAAA,SAAS,aAAa,kBAAkB;AACxC,OAAO,UAAU;AAGjB,IAAM,aAAa;AAEnB,SAAS,aAAa,KAAa,KAAuB;AACxD,MAAI,CAAC,WAAW,GAAG,EAAG,QAAO,CAAC;AAC9B,QAAM,UAAoB,CAAC;AAC3B,aAAW,SAAS,YAAY,KAAK,EAAE,eAAe,KAAK,CAAC,GAAG;AAC7D,UAAM,OAAO,KAAK,KAAK,KAAK,MAAM,IAAI;AACtC,QAAI,MAAM,YAAY,EAAG,SAAQ,KAAK,GAAG,aAAa,MAAM,GAAG,CAAC;AAAA,aACvD,MAAM,KAAK,SAAS,GAAG,EAAG,SAAQ,KAAK,IAAI;AAAA,EACtD;AACA,SAAO;AACT;AAGe,SAAR,MAAuB,MAA+B;AAC3D,QAAM,cAAc,KAAK,KAAK,MAAM,OAAO,UAAU;AACrD,QAAM,cAA+B,CAAC;AAEtC,aAAW,QAAQ,aAAa,aAAa,UAAU,GAAG;AACxD,UAAM,OAAO,KAAK,SAAS,IAAI,EAAE,QAAQ,cAAc,EAAE;AACzD,QAAI,CAAC,WAAW,KAAK,IAAI,GAAG;AAC1B,kBAAY,KAAK;AAAA,QACf,MAAM,KAAK,SAAS,MAAM,IAAI;AAAA,QAC9B,MAAM;AAAA,QACN,KAAK;AAAA,QACL,UAAU;AAAA,QACV,SAAS,iBAAiB,KAAK,SAAS,IAAI,CAAC,+BAA+B,IAAI;AAAA,MAClF,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,6 @@
1
+ import { RawDiagnostic } from '@cubocicloide/dude';
2
+
3
+ /** ET002 — each feature file must have a matching step-definitions file */
4
+ declare function check(root: string): RawDiagnostic[];
5
+
6
+ export { check as default };
@@ -0,0 +1,37 @@
1
+ // src/commands/lint/checks/E2E/002.ts
2
+ import { readdirSync, existsSync } from "fs";
3
+ import path from "pathe";
4
+ function collectFiles(dir, ext) {
5
+ if (!existsSync(dir)) return [];
6
+ const results = [];
7
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
8
+ const full = path.join(dir, entry.name);
9
+ if (entry.isDirectory()) results.push(...collectFiles(full, ext));
10
+ else if (entry.name.endsWith(ext)) results.push(full);
11
+ }
12
+ return results;
13
+ }
14
+ function check(root) {
15
+ const featuresDir = path.join(root, "e2e", "features");
16
+ const stepsDir = path.join(root, "e2e", "steps");
17
+ if (!existsSync(featuresDir) || !existsSync(stepsDir)) return [];
18
+ const diagnostics = [];
19
+ for (const file of collectFiles(featuresDir, ".feature")) {
20
+ const stem = path.basename(file).replace(/\.feature$/, "");
21
+ const expected = path.join(stepsDir, `${stem}.steps.ts`);
22
+ if (!existsSync(expected)) {
23
+ diagnostics.push({
24
+ file: path.relative(root, file),
25
+ line: 1,
26
+ col: 1,
27
+ severity: "error",
28
+ message: `No step definitions for "${path.basename(file)}". Expected: e2e/steps/${stem}.steps.ts`
29
+ });
30
+ }
31
+ }
32
+ return diagnostics;
33
+ }
34
+ export {
35
+ check as default
36
+ };
37
+ //# sourceMappingURL=002.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/commands/lint/checks/E2E/002.ts"],"sourcesContent":["import { readdirSync, existsSync } from 'node:fs'\nimport path from 'pathe'\nimport type { RawDiagnostic } from '@cubocicloide/dude'\n\nfunction collectFiles(dir: string, ext: string): string[] {\n if (!existsSync(dir)) return []\n const results: string[] = []\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n const full = path.join(dir, entry.name)\n if (entry.isDirectory()) results.push(...collectFiles(full, ext))\n else if (entry.name.endsWith(ext)) results.push(full)\n }\n return results\n}\n\n/** ET002 — each feature file must have a matching step-definitions file */\nexport default function check(root: string): RawDiagnostic[] {\n const featuresDir = path.join(root, 'e2e', 'features')\n const stepsDir = path.join(root, 'e2e', 'steps')\n\n if (!existsSync(featuresDir) || !existsSync(stepsDir)) return []\n\n const diagnostics: RawDiagnostic[] = []\n\n for (const file of collectFiles(featuresDir, '.feature')) {\n const stem = path.basename(file).replace(/\\.feature$/, '')\n const expected = path.join(stepsDir, `${stem}.steps.ts`)\n if (!existsSync(expected)) {\n diagnostics.push({\n file: path.relative(root, file),\n line: 1,\n col: 1,\n severity: 'error',\n message: `No step definitions for \"${path.basename(file)}\". Expected: e2e/steps/${stem}.steps.ts`,\n })\n }\n }\n\n return diagnostics\n}\n"],"mappings":";AAAA,SAAS,aAAa,kBAAkB;AACxC,OAAO,UAAU;AAGjB,SAAS,aAAa,KAAa,KAAuB;AACxD,MAAI,CAAC,WAAW,GAAG,EAAG,QAAO,CAAC;AAC9B,QAAM,UAAoB,CAAC;AAC3B,aAAW,SAAS,YAAY,KAAK,EAAE,eAAe,KAAK,CAAC,GAAG;AAC7D,UAAM,OAAO,KAAK,KAAK,KAAK,MAAM,IAAI;AACtC,QAAI,MAAM,YAAY,EAAG,SAAQ,KAAK,GAAG,aAAa,MAAM,GAAG,CAAC;AAAA,aACvD,MAAM,KAAK,SAAS,GAAG,EAAG,SAAQ,KAAK,IAAI;AAAA,EACtD;AACA,SAAO;AACT;AAGe,SAAR,MAAuB,MAA+B;AAC3D,QAAM,cAAc,KAAK,KAAK,MAAM,OAAO,UAAU;AACrD,QAAM,WAAW,KAAK,KAAK,MAAM,OAAO,OAAO;AAE/C,MAAI,CAAC,WAAW,WAAW,KAAK,CAAC,WAAW,QAAQ,EAAG,QAAO,CAAC;AAE/D,QAAM,cAA+B,CAAC;AAEtC,aAAW,QAAQ,aAAa,aAAa,UAAU,GAAG;AACxD,UAAM,OAAO,KAAK,SAAS,IAAI,EAAE,QAAQ,cAAc,EAAE;AACzD,UAAM,WAAW,KAAK,KAAK,UAAU,GAAG,IAAI,WAAW;AACvD,QAAI,CAAC,WAAW,QAAQ,GAAG;AACzB,kBAAY,KAAK;AAAA,QACf,MAAM,KAAK,SAAS,MAAM,IAAI;AAAA,QAC9B,MAAM;AAAA,QACN,KAAK;AAAA,QACL,UAAU;AAAA,QACV,SAAS,4BAA4B,KAAK,SAAS,IAAI,CAAC,0BAA0B,IAAI;AAAA,MACxF,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,6 @@
1
+ import { RawDiagnostic } from '@cubocicloide/dude';
2
+
3
+ /** ET003 — step-definitions files must have a matching feature file (no orphans) */
4
+ declare function check(root: string): RawDiagnostic[];
5
+
6
+ export { check as default };