@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.
- package/LICENSE +33 -0
- package/README.md +66 -0
- package/dist/commands/lint/checks/BE/001.d.ts +6 -0
- package/dist/commands/lint/checks/BE/001.js +95 -0
- package/dist/commands/lint/checks/BE/001.js.map +1 -0
- package/dist/commands/lint/checks/BE/002.d.ts +6 -0
- package/dist/commands/lint/checks/BE/002.js +30 -0
- package/dist/commands/lint/checks/BE/002.js.map +1 -0
- package/dist/commands/lint/checks/BE/003.d.ts +11 -0
- package/dist/commands/lint/checks/BE/003.js +46 -0
- package/dist/commands/lint/checks/BE/003.js.map +1 -0
- package/dist/commands/lint/checks/BE/004.d.ts +6 -0
- package/dist/commands/lint/checks/BE/004.js +27 -0
- package/dist/commands/lint/checks/BE/004.js.map +1 -0
- package/dist/commands/lint/checks/BE/005.d.ts +6 -0
- package/dist/commands/lint/checks/BE/005.js +107 -0
- package/dist/commands/lint/checks/BE/005.js.map +1 -0
- package/dist/commands/lint/checks/BE/006.d.ts +6 -0
- package/dist/commands/lint/checks/BE/006.js +27 -0
- package/dist/commands/lint/checks/BE/006.js.map +1 -0
- package/dist/commands/lint/checks/BE/007.d.ts +31 -0
- package/dist/commands/lint/checks/BE/007.js +109 -0
- package/dist/commands/lint/checks/BE/007.js.map +1 -0
- package/dist/commands/lint/checks/BE/008.d.ts +12 -0
- package/dist/commands/lint/checks/BE/008.js +57 -0
- package/dist/commands/lint/checks/BE/008.js.map +1 -0
- package/dist/commands/lint/checks/BE/009.d.ts +12 -0
- package/dist/commands/lint/checks/BE/009.js +104 -0
- package/dist/commands/lint/checks/BE/009.js.map +1 -0
- package/dist/commands/lint/checks/BE/010.d.ts +12 -0
- package/dist/commands/lint/checks/BE/010.js +54 -0
- package/dist/commands/lint/checks/BE/010.js.map +1 -0
- package/dist/commands/lint/checks/BE/011.d.ts +16 -0
- package/dist/commands/lint/checks/BE/011.js +46 -0
- package/dist/commands/lint/checks/BE/011.js.map +1 -0
- package/dist/commands/lint/checks/E2E/001.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/001.js +35 -0
- package/dist/commands/lint/checks/E2E/001.js.map +1 -0
- package/dist/commands/lint/checks/E2E/002.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/002.js +37 -0
- package/dist/commands/lint/checks/E2E/002.js.map +1 -0
- package/dist/commands/lint/checks/E2E/003.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/003.js +42 -0
- package/dist/commands/lint/checks/E2E/003.js.map +1 -0
- package/dist/commands/lint/checks/E2E/004.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/004.js +37 -0
- package/dist/commands/lint/checks/E2E/004.js.map +1 -0
- package/dist/commands/lint/checks/E2E/005.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/005.js +47 -0
- package/dist/commands/lint/checks/E2E/005.js.map +1 -0
- package/dist/commands/lint/checks/E2E/006.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/006.js +28 -0
- package/dist/commands/lint/checks/E2E/006.js.map +1 -0
- package/dist/commands/lint/checks/E2E/007.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/007.js +47 -0
- package/dist/commands/lint/checks/E2E/007.js.map +1 -0
- package/dist/commands/lint/checks/FE/001.d.ts +6 -0
- package/dist/commands/lint/checks/FE/001.js +56 -0
- package/dist/commands/lint/checks/FE/001.js.map +1 -0
- package/dist/commands/lint/checks/FE/002.d.ts +6 -0
- package/dist/commands/lint/checks/FE/002.js +80 -0
- package/dist/commands/lint/checks/FE/002.js.map +1 -0
- package/dist/commands/lint/checks/FE/003.d.ts +6 -0
- package/dist/commands/lint/checks/FE/003.js +65 -0
- package/dist/commands/lint/checks/FE/003.js.map +1 -0
- package/dist/commands/lint/checks/FE/004.d.ts +6 -0
- package/dist/commands/lint/checks/FE/004.js +72 -0
- package/dist/commands/lint/checks/FE/004.js.map +1 -0
- package/dist/commands/lint/checks/FE/005.d.ts +6 -0
- package/dist/commands/lint/checks/FE/005.js +103 -0
- package/dist/commands/lint/checks/FE/005.js.map +1 -0
- package/dist/commands/lint/checks/FE/006.d.ts +6 -0
- package/dist/commands/lint/checks/FE/006.js +102 -0
- package/dist/commands/lint/checks/FE/006.js.map +1 -0
- package/dist/commands/lint/checks/FE/007.d.ts +6 -0
- package/dist/commands/lint/checks/FE/007.js +60 -0
- package/dist/commands/lint/checks/FE/007.js.map +1 -0
- package/dist/commands/lint/checks/FE/008.d.ts +6 -0
- package/dist/commands/lint/checks/FE/008.js +115 -0
- package/dist/commands/lint/checks/FE/008.js.map +1 -0
- package/dist/commands/lint/checks/FE/009.d.ts +6 -0
- package/dist/commands/lint/checks/FE/009.js +83 -0
- package/dist/commands/lint/checks/FE/009.js.map +1 -0
- package/dist/commands/lint/checks/FE/010.d.ts +6 -0
- package/dist/commands/lint/checks/FE/010.js +105 -0
- package/dist/commands/lint/checks/FE/010.js.map +1 -0
- package/dist/commands/lint/checks/FE/011.d.ts +6 -0
- package/dist/commands/lint/checks/FE/011.js +43 -0
- package/dist/commands/lint/checks/FE/011.js.map +1 -0
- package/dist/commands/lint/checks/FE/012.d.ts +6 -0
- package/dist/commands/lint/checks/FE/012.js +150 -0
- package/dist/commands/lint/checks/FE/012.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +3491 -0
- package/dist/index.js.map +1 -0
- package/dude.stack.json +7 -0
- package/package.json +43 -0
- package/templates/aws-eks/backend/Dockerfile.prod.hbs +22 -0
- package/templates/aws-eks/docs/docs/deploy.md.hbs +159 -0
- package/templates/aws-eks/frontend/Dockerfile.prod +28 -0
- package/templates/aws-eks/frontend/nginx.conf +19 -0
- package/templates/aws-eks/iac/README.md.hbs +311 -0
- package/templates/aws-eks/iac/_gitignore +24 -0
- package/templates/aws-eks/iac/helm/app/.helmignore +7 -0
- package/templates/aws-eks/iac/helm/app/Chart.yaml.hbs +6 -0
- package/templates/aws-eks/iac/helm/app/templates/NOTES.txt +23 -0
- package/templates/aws-eks/iac/helm/app/templates/backend-deployment.yaml +44 -0
- package/templates/aws-eks/iac/helm/app/templates/backend-service.yaml +16 -0
- package/templates/aws-eks/iac/helm/app/templates/celery-beat-deployment.yaml +34 -0
- package/templates/aws-eks/iac/helm/app/templates/celery-worker-deployment.yaml +31 -0
- package/templates/aws-eks/iac/helm/app/templates/configmap.yaml +15 -0
- package/templates/aws-eks/iac/helm/app/templates/flower-deployment.yaml +28 -0
- package/templates/aws-eks/iac/helm/app/templates/flower-service.yaml +19 -0
- package/templates/aws-eks/iac/helm/app/templates/frontend-deployment.yaml +34 -0
- package/templates/aws-eks/iac/helm/app/templates/frontend-service.yaml +16 -0
- package/templates/aws-eks/iac/helm/app/templates/helpers.tpl +90 -0
- package/templates/aws-eks/iac/helm/app/templates/hpa.yaml +23 -0
- package/templates/aws-eks/iac/helm/app/templates/ingress.yaml +30 -0
- package/templates/aws-eks/iac/helm/app/templates/migration-job.yaml +38 -0
- package/templates/aws-eks/iac/helm/app/templates/redis-deployment.yaml +33 -0
- package/templates/aws-eks/iac/helm/app/templates/redis-service.yaml +18 -0
- package/templates/aws-eks/iac/helm/app/templates/secret.yaml +17 -0
- package/templates/aws-eks/iac/helm/app/templates/serviceaccount.yaml +12 -0
- package/templates/aws-eks/iac/helm/app/values-dev.yaml.hbs +35 -0
- package/templates/aws-eks/iac/helm/app/values.yaml.hbs +130 -0
- package/templates/aws-eks/iac/runner/Dockerfile +53 -0
- package/templates/aws-eks/iac/terraform/bootstrap/main.tf.hbs +101 -0
- package/templates/aws-eks/iac/terraform/bootstrap/outputs.tf +19 -0
- package/templates/aws-eks/iac/terraform/bootstrap/variables.tf.hbs +17 -0
- package/templates/aws-eks/iac/terraform/environments/dev/backend.hcl.hbs +12 -0
- package/templates/aws-eks/iac/terraform/environments/dev/terraform.tfvars.hbs +32 -0
- package/templates/aws-eks/iac/terraform/main.tf.hbs +305 -0
- package/templates/aws-eks/iac/terraform/outputs.tf.hbs +52 -0
- package/templates/aws-eks/iac/terraform/providers.tf +47 -0
- package/templates/aws-eks/iac/terraform/variables.tf.hbs +181 -0
- package/templates/aws-eks/iac/terraform/versions.tf +27 -0
- package/templates/base/.claude/agents/issue-fixer.md +190 -0
- package/templates/base/.claude/agents/security-fixer.md +250 -0
- package/templates/base/.claude/rules/BE/001.md +25 -0
- package/templates/base/.claude/rules/BE/002.md +15 -0
- package/templates/base/.claude/rules/BE/003.md +18 -0
- package/templates/base/.claude/rules/BE/004.md +14 -0
- package/templates/base/.claude/rules/BE/005.md +15 -0
- package/templates/base/.claude/rules/BE/006.md +17 -0
- package/templates/base/.claude/rules/BE/007.md +21 -0
- package/templates/base/.claude/rules/BE/008.md +19 -0
- package/templates/base/.claude/rules/BE/009.md +27 -0
- package/templates/base/.claude/rules/BE/010.md +16 -0
- package/templates/base/.claude/rules/BE/011.md +15 -0
- package/templates/base/.claude/rules/E2E/001.md +13 -0
- package/templates/base/.claude/rules/E2E/002.md +14 -0
- package/templates/base/.claude/rules/E2E/003.md +10 -0
- package/templates/base/.claude/rules/E2E/004.md +23 -0
- package/templates/base/.claude/rules/E2E/005.md +15 -0
- package/templates/base/.claude/rules/E2E/006.md +13 -0
- package/templates/base/.claude/rules/E2E/007.md +18 -0
- package/templates/base/.claude/rules/FE/001.md +22 -0
- package/templates/base/.claude/rules/FE/002.md +39 -0
- package/templates/base/.claude/rules/FE/003.md +19 -0
- package/templates/base/.claude/rules/FE/004.md +21 -0
- package/templates/base/.claude/rules/FE/005.md +33 -0
- package/templates/base/.claude/rules/FE/006.md +24 -0
- package/templates/base/.claude/rules/FE/007.md +19 -0
- package/templates/base/.claude/rules/FE/008.md +26 -0
- package/templates/base/.claude/rules/FE/009.md +30 -0
- package/templates/base/.claude/rules/FE/010.md +25 -0
- package/templates/base/.claude/rules/FE/011.md +22 -0
- package/templates/base/.claude/rules/FE/012.md +32 -0
- package/templates/base/.claude/settings.json +53 -0
- package/templates/base/.claude/skills/clean-branches/SKILL.md +100 -0
- package/templates/base/.claude/skills/create/SKILL.md +47 -0
- package/templates/base/.claude/skills/create-jira-issue/SKILL.md +174 -0
- package/templates/base/.claude/skills/create-page/SKILL.md +195 -0
- package/templates/base/.claude/skills/create-route/SKILL.md +199 -0
- package/templates/base/.claude/skills/draft-email/SKILL.md +104 -0
- package/templates/base/.claude/skills/fix-issues/SKILL.md +238 -0
- package/templates/base/.claude/skills/security-scan/SKILL.md +297 -0
- package/templates/base/.claude/skills/verify-security-fixes/SKILL.md +180 -0
- package/templates/base/.dude/commands/README.md +85 -0
- package/templates/base/.dude/commands/hello.ts +34 -0
- package/templates/base/.dude/lint/checks/PRJ/001.ts +26 -0
- package/templates/base/.dude/lint/checks/README.md +69 -0
- package/templates/base/.vscode/tasks.json +44 -0
- package/templates/base/.worktreeinclude +2 -0
- package/templates/base/CLAUDE.md.hbs +364 -0
- package/templates/base/README.md.hbs +187 -0
- package/templates/base/_env.example.hbs +29 -0
- package/templates/base/_env.hbs +25 -0
- package/templates/base/_gitignore +31 -0
- package/templates/base/_npmrc +2 -0
- package/templates/base/backend/Dockerfile.hbs +22 -0
- package/templates/base/backend/README.md.hbs +74 -0
- package/templates/base/backend/_dockerignore +11 -0
- package/templates/base/backend/app/__init__.py +1 -0
- package/templates/base/backend/app/core/__init__.py +0 -0
- package/templates/base/backend/app/core/config.py.hbs +23 -0
- package/templates/base/backend/app/fixtures/__init__.py +0 -0
- package/templates/base/backend/app/main.py.hbs +41 -0
- package/templates/base/backend/app/management/__init__.py +0 -0
- package/templates/base/backend/app/models/__init__.py +0 -0
- package/templates/base/backend/app/queries/__init__.py +0 -0
- package/templates/base/backend/app/routers/__init__.py +0 -0
- package/templates/base/backend/app/routers/health.py +13 -0
- package/templates/base/backend/app/schemas/__init__.py +0 -0
- package/templates/base/backend/app/schemas/health.py +7 -0
- package/templates/base/backend/app/tasks/__init__.py +1 -0
- package/templates/base/backend/app/tests/__init__.py +0 -0
- package/templates/base/backend/app/tests/conftest.py +13 -0
- package/templates/base/backend/app/tests/models/__init__.py +0 -0
- package/templates/base/backend/app/tests/queries/__init__.py +0 -0
- package/templates/base/backend/app/tests/routers/__init__.py +0 -0
- package/templates/base/backend/app/tests/routers/test_health.py +10 -0
- package/templates/base/backend/app/tests/tasks/__init__.py +1 -0
- package/templates/base/backend/app/tests/utils/__init__.py +0 -0
- package/templates/base/backend/app/utils/__init__.py +0 -0
- package/templates/base/backend/pyproject.toml.hbs +40 -0
- package/templates/base/docker-compose.yml.hbs +128 -0
- package/templates/base/docs/docs/api.md +21 -0
- package/templates/base/docs/docs/dude.md.hbs +316 -0
- package/templates/base/docs/docs/index.md.hbs +100 -0
- package/templates/base/docs/docs/mkdocs.md +238 -0
- package/templates/base/docs/mkdocs.yml.hbs +52 -0
- package/templates/base/e2e/.prettierrc.json +1 -0
- package/templates/base/e2e/_prettierignore +3 -0
- package/templates/base/e2e/cucumber.js +21 -0
- package/templates/base/e2e/eslint.config.mjs +14 -0
- package/templates/base/e2e/features/example.feature +13 -0
- package/templates/base/e2e/package.json.hbs +30 -0
- package/templates/base/e2e/pages/ExamplePage.ts +16 -0
- package/templates/base/e2e/playwright.config.ts +27 -0
- package/templates/base/e2e/steps/common.steps.ts +32 -0
- package/templates/base/e2e/steps/example.steps.ts +4 -0
- package/templates/base/e2e/support/hooks.ts +72 -0
- package/templates/base/e2e/support/world.ts +24 -0
- package/templates/base/e2e/tsconfig.json +22 -0
- package/templates/base/frontend/.prettierrc.json +6 -0
- package/templates/base/frontend/Dockerfile +10 -0
- package/templates/base/frontend/_dockerignore +4 -0
- package/templates/base/frontend/eslint.config.js +32 -0
- package/templates/base/frontend/index.html.hbs +13 -0
- package/templates/base/frontend/package.json.hbs +38 -0
- package/templates/base/frontend/public/favicon.svg +5 -0
- package/templates/base/frontend/src/$components/Layout/$assets/logo.svg +5 -0
- package/templates/base/frontend/src/$components/Layout/constants.tsx.hbs +10 -0
- package/templates/base/frontend/src/$components/Layout/index.tsx +80 -0
- package/templates/base/frontend/src/$components/Layout/types.tsx +9 -0
- package/templates/base/frontend/src/$components/index.tsx +1 -0
- package/templates/base/frontend/src/$hooks/index.tsx +2 -0
- package/templates/base/frontend/src/$hooks/useCounterStore/index.tsx +28 -0
- package/templates/base/frontend/src/$hooks/useCounterStore/types.tsx +7 -0
- package/templates/base/frontend/src/$hooks/usePageTitle/index.tsx +21 -0
- package/templates/base/frontend/src/$types/vite-env.d.ts +10 -0
- package/templates/base/frontend/src/App.tsx.hbs +40 -0
- package/templates/base/frontend/src/main.tsx +10 -0
- package/templates/base/frontend/src/openapi/utils/openapi.yaml.hbs +28 -0
- package/templates/base/frontend/src/pages/constants.tsx +31 -0
- package/templates/base/frontend/src/pages/index.tsx +192 -0
- package/templates/base/frontend/src/pages/types.tsx +6 -0
- package/templates/base/frontend/src/styles.module.css +7 -0
- package/templates/base/frontend/src/utils/constants.tsx +11 -0
- package/templates/base/frontend/src/utils/formatters/index.tsx +49 -0
- package/templates/base/frontend/src/utils/functions.tsx +70 -0
- package/templates/base/frontend/src/utils/index.tsx +3 -0
- package/templates/base/frontend/tsconfig.json +24 -0
- package/templates/base/frontend/vite.config.ts +20 -0
- package/templates/base/package.json.hbs +11 -0
- package/templates/base/security/baseline.json +4 -0
- package/templates/celery/backend/app/tasks/__init__.py +1 -0
- package/templates/celery/backend/app/tasks/example.py +21 -0
- package/templates/celery/backend/app/tests/tasks/test_example.py +7 -0
- package/templates/celery/backend/app/worker.py.hbs +33 -0
- package/templates/celerybeat/backend/app/tasks/scheduled.py +16 -0
- package/templates/celerybeat/backend/app/tests/tasks/test_scheduled.py +7 -0
- package/templates/postgres/.dude/commands/reset.ts +76 -0
- package/templates/postgres/backend/alembic/env.py +55 -0
- package/templates/postgres/backend/alembic/script.py.mako +27 -0
- package/templates/postgres/backend/alembic/versions/0001_create_user_table.py +38 -0
- package/templates/postgres/backend/alembic.ini +42 -0
- package/templates/postgres/backend/app/core/database.py +15 -0
- package/templates/postgres/backend/app/models/__init__.py +5 -0
- package/templates/postgres/backend/app/models/user.py +15 -0
- package/templates/postgres/backend/app/queries/__init__.py +5 -0
- package/templates/postgres/backend/app/queries/users.py +18 -0
- package/templates/postgres/backend/app/routers/users.py +19 -0
- package/templates/postgres/backend/app/routers/users__id.py +20 -0
- package/templates/postgres/backend/app/tests/conftest.py +33 -0
- package/templates/postgres/backend/app/tests/models/test_user.py +12 -0
- package/templates/postgres/backend/app/tests/queries/test_users.py +12 -0
- package/templates/postgres/backend/app/tests/routers/test_users.py +10 -0
- package/templates/postgres/backend/app/tests/routers/test_users__id.py +9 -0
- package/templates/postgres/backend/start.sh +32 -0
- package/templates/postgres/frontend/src/openapi/utils/openapi.yaml.hbs +138 -0
- package/templates/postgres/frontend/src/pages/users/[id]/index.tsx +51 -0
- package/templates/postgres/frontend/src/pages/users/index.tsx +54 -0
- package/templates/postgres/frontend/src/pages/users/types.tsx +4 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
Copyright © Cubocicloide. All rights reserved.
|
|
2
|
+
|
|
3
|
+
SOURCE-AVAILABLE, PROPRIETARY LICENSE
|
|
4
|
+
|
|
5
|
+
This source code is made publicly viewable for transparency, evaluation, and
|
|
6
|
+
reference purposes only. It is NOT open-source software.
|
|
7
|
+
|
|
8
|
+
1. Grant. You are permitted to view and read this source code, and to clone the
|
|
9
|
+
repository, solely to evaluate the software and to understand how it works.
|
|
10
|
+
|
|
11
|
+
2. Restrictions. Except as expressly permitted above, you may NOT, without the
|
|
12
|
+
prior written permission of Cubocicloide:
|
|
13
|
+
a. use the software, in whole or in part, for any purpose (including any
|
|
14
|
+
personal, internal, commercial, or production use);
|
|
15
|
+
b. copy, reproduce, or redistribute the software or any derivative of it;
|
|
16
|
+
c. modify, adapt, translate, or create derivative works based on it;
|
|
17
|
+
d. sublicense, sell, rent, lease, or otherwise commercially exploit it;
|
|
18
|
+
e. remove or alter this notice or any copyright, trademark, or attribution
|
|
19
|
+
notices contained in the software.
|
|
20
|
+
|
|
21
|
+
3. No trademark rights. This license does not grant any rights to use the
|
|
22
|
+
"Cubocicloide" name, logos, or other trademarks.
|
|
23
|
+
|
|
24
|
+
4. No warranty. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
25
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
26
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT.
|
|
27
|
+
|
|
28
|
+
5. Limitation of liability. IN NO EVENT SHALL CUBOCICLOIDE BE LIABLE FOR ANY
|
|
29
|
+
CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR
|
|
30
|
+
OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
|
31
|
+
OR OTHER DEALINGS IN THE SOFTWARE.
|
|
32
|
+
|
|
33
|
+
To request permissions beyond the scope of this license, contact Cubocicloide.
|
package/README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# @cubocicloide/stack-react-fastapi
|
|
2
|
+
|
|
3
|
+
React (Vite + TypeScript) frontend with a FastAPI backend, scaffolded by [`dude`](../../packages/dude).
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
dude init my-app --stack react-fastapi
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Scaffolded projects pin both the CLI version and the stack version so customers
|
|
12
|
+
can upgrade or roll back deliberately:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
dude upgrade
|
|
16
|
+
dude upgrade --cli --cli-version 0.6.1
|
|
17
|
+
dude upgrade --stack --stack-version 5.0.5
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The command updates version pins only. It does not migrate existing files.
|
|
21
|
+
|
|
22
|
+
## Variables
|
|
23
|
+
|
|
24
|
+
| Name | Type | Default | Description |
|
|
25
|
+
| ------------- | ------- | -------- | ---------------------------------------------------- |
|
|
26
|
+
| `projectName` | string | `my-app` | Project slug (kebab-case) |
|
|
27
|
+
| `database` | string | — | `postgres` to enable PostgreSQL + Alembic migrations |
|
|
28
|
+
| `celery` | boolean | `false` | Add Celery worker + Redis |
|
|
29
|
+
| `celeryBeat` | boolean | `false` | Add Celery Beat scheduler (implies `celery`) |
|
|
30
|
+
|
|
31
|
+
## Layout produced
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
<projectName>/
|
|
35
|
+
├── README.md
|
|
36
|
+
├── .gitignore
|
|
37
|
+
├── frontend/ # Vite + React + TypeScript
|
|
38
|
+
│ └── src/
|
|
39
|
+
│ └── openapi/ # Auto-generated typed API client — do not edit by hand
|
|
40
|
+
├── backend/ # FastAPI (Python ≥ 3.13, uv)
|
|
41
|
+
│ └── app/
|
|
42
|
+
│ ├── core/ # settings, database session, shared utilities
|
|
43
|
+
│ ├── models/ # SQLAlchemy ORM models
|
|
44
|
+
│ ├── queries/ # database query functions
|
|
45
|
+
│ ├── routers/ # APIRouter modules
|
|
46
|
+
│ ├── schemas/ # Pydantic schemas
|
|
47
|
+
│ ├── tasks/ # Celery task definitions
|
|
48
|
+
│ ├── tests/ # pytest suite (models / queries / routers / tasks / utils)
|
|
49
|
+
│ └── utils/ # pure helper functions
|
|
50
|
+
├── docs/ # MkDocs documentation site
|
|
51
|
+
├── e2e/ # Playwright + Cucumber end-to-end tests
|
|
52
|
+
└── docker-compose.yml
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Lint checks
|
|
56
|
+
|
|
57
|
+
`dude lint` enforces naming, layout, and test-coverage conventions defined in
|
|
58
|
+
`src/commands/lint/checks/`. Each check has a companion explanation in
|
|
59
|
+
`templates/base/.claude/rules/`.
|
|
60
|
+
|
|
61
|
+
| Check | What it enforces |
|
|
62
|
+
| ----------- | ----------------------------------------------- |
|
|
63
|
+
| BE001 | Required directories exist in `backend/app/` |
|
|
64
|
+
| BE002–BE011 | Naming, import, config, and test-coverage rules |
|
|
65
|
+
| FE001–… | Frontend naming and structure rules |
|
|
66
|
+
| E2E001–… | E2e feature/step naming rules |
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// src/commands/lint/checks/BE/001.ts
|
|
2
|
+
import { existsSync } from "fs";
|
|
3
|
+
import path from "pathe";
|
|
4
|
+
var REQUIRED_DIRS = [
|
|
5
|
+
"core",
|
|
6
|
+
"fixtures",
|
|
7
|
+
"management",
|
|
8
|
+
"models",
|
|
9
|
+
"queries",
|
|
10
|
+
"routers",
|
|
11
|
+
"schemas",
|
|
12
|
+
"tasks",
|
|
13
|
+
"tests",
|
|
14
|
+
"utils"
|
|
15
|
+
];
|
|
16
|
+
var REQUIRED_FILES = ["main.py", "__init__.py"];
|
|
17
|
+
var REQUIRED_TESTS_DIRS = ["models", "queries", "routers", "tasks", "utils"];
|
|
18
|
+
var REQUIRED_TESTS_FILES = ["__init__.py", "conftest.py"];
|
|
19
|
+
function check(root) {
|
|
20
|
+
const appDir = path.join(root, "backend", "app");
|
|
21
|
+
const appRel = path.join("backend", "app");
|
|
22
|
+
if (!existsSync(appDir)) {
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
file: appRel,
|
|
26
|
+
line: 1,
|
|
27
|
+
col: 1,
|
|
28
|
+
severity: "error",
|
|
29
|
+
message: "backend/app/ directory is missing"
|
|
30
|
+
}
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
const diagnostics = [];
|
|
34
|
+
for (const dir of REQUIRED_DIRS) {
|
|
35
|
+
if (!existsSync(path.join(appDir, dir))) {
|
|
36
|
+
diagnostics.push({
|
|
37
|
+
file: appRel,
|
|
38
|
+
line: 1,
|
|
39
|
+
col: 1,
|
|
40
|
+
severity: "error",
|
|
41
|
+
message: `backend/app/${dir}/ is missing`
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
for (const file of REQUIRED_FILES) {
|
|
46
|
+
if (!existsSync(path.join(appDir, file))) {
|
|
47
|
+
diagnostics.push({
|
|
48
|
+
file: appRel,
|
|
49
|
+
line: 1,
|
|
50
|
+
col: 1,
|
|
51
|
+
severity: "error",
|
|
52
|
+
message: `backend/app/${file} is missing`
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const testsDir = path.join(appDir, "tests");
|
|
57
|
+
if (existsSync(testsDir)) {
|
|
58
|
+
const testsRel = path.join("backend", "app", "tests");
|
|
59
|
+
for (const dir of REQUIRED_TESTS_DIRS) {
|
|
60
|
+
if (!existsSync(path.join(testsDir, dir))) {
|
|
61
|
+
diagnostics.push({
|
|
62
|
+
file: testsRel,
|
|
63
|
+
line: 1,
|
|
64
|
+
col: 1,
|
|
65
|
+
severity: "error",
|
|
66
|
+
message: `backend/app/tests/${dir}/ is missing`
|
|
67
|
+
});
|
|
68
|
+
} else if (!existsSync(path.join(testsDir, dir, "__init__.py"))) {
|
|
69
|
+
diagnostics.push({
|
|
70
|
+
file: path.join(testsRel, dir),
|
|
71
|
+
line: 1,
|
|
72
|
+
col: 1,
|
|
73
|
+
severity: "error",
|
|
74
|
+
message: `backend/app/tests/${dir}/__init__.py is missing`
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
for (const file of REQUIRED_TESTS_FILES) {
|
|
79
|
+
if (!existsSync(path.join(testsDir, file))) {
|
|
80
|
+
diagnostics.push({
|
|
81
|
+
file: testsRel,
|
|
82
|
+
line: 1,
|
|
83
|
+
col: 1,
|
|
84
|
+
severity: "error",
|
|
85
|
+
message: `backend/app/tests/${file} is missing`
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return diagnostics;
|
|
91
|
+
}
|
|
92
|
+
export {
|
|
93
|
+
check as default
|
|
94
|
+
};
|
|
95
|
+
//# sourceMappingURL=001.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/commands/lint/checks/BE/001.ts"],"sourcesContent":["import { existsSync } from 'node:fs'\nimport path from 'pathe'\nimport type { RawDiagnostic } from '@cubocicloide/dude'\n\nconst REQUIRED_DIRS = [\n 'core',\n 'fixtures',\n 'management',\n 'models',\n 'queries',\n 'routers',\n 'schemas',\n 'tasks',\n 'tests',\n 'utils',\n]\nconst REQUIRED_FILES = ['main.py', '__init__.py']\n\n/** Required layout inside tests/: subdirs and files that must exist. */\nconst REQUIRED_TESTS_DIRS = ['models', 'queries', 'routers', 'tasks', 'utils']\nconst REQUIRED_TESTS_FILES = ['__init__.py', 'conftest.py']\n\n/** BE001 — backend/app/ must contain the required directories, files, and tests/ sub-structure */\nexport default function check(root: string): RawDiagnostic[] {\n const appDir = path.join(root, 'backend', 'app')\n const appRel = path.join('backend', 'app')\n\n if (!existsSync(appDir)) {\n return [\n {\n file: appRel,\n line: 1,\n col: 1,\n severity: 'error',\n message: 'backend/app/ directory is missing',\n },\n ]\n }\n\n const diagnostics: RawDiagnostic[] = []\n\n for (const dir of REQUIRED_DIRS) {\n if (!existsSync(path.join(appDir, dir))) {\n diagnostics.push({\n file: appRel,\n line: 1,\n col: 1,\n severity: 'error',\n message: `backend/app/${dir}/ is missing`,\n })\n }\n }\n\n for (const file of REQUIRED_FILES) {\n if (!existsSync(path.join(appDir, file))) {\n diagnostics.push({\n file: appRel,\n line: 1,\n col: 1,\n severity: 'error',\n message: `backend/app/${file} is missing`,\n })\n }\n }\n\n // tests/ internal structure\n const testsDir = path.join(appDir, 'tests')\n if (existsSync(testsDir)) {\n const testsRel = path.join('backend', 'app', 'tests')\n for (const dir of REQUIRED_TESTS_DIRS) {\n if (!existsSync(path.join(testsDir, dir))) {\n diagnostics.push({\n file: testsRel,\n line: 1,\n col: 1,\n severity: 'error',\n message: `backend/app/tests/${dir}/ is missing`,\n })\n } else if (!existsSync(path.join(testsDir, dir, '__init__.py'))) {\n diagnostics.push({\n file: path.join(testsRel, dir),\n line: 1,\n col: 1,\n severity: 'error',\n message: `backend/app/tests/${dir}/__init__.py is missing`,\n })\n }\n }\n for (const file of REQUIRED_TESTS_FILES) {\n if (!existsSync(path.join(testsDir, file))) {\n diagnostics.push({\n file: testsRel,\n line: 1,\n col: 1,\n severity: 'error',\n message: `backend/app/tests/${file} is missing`,\n })\n }\n }\n }\n\n return diagnostics\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,OAAO,UAAU;AAGjB,IAAM,gBAAgB;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACA,IAAM,iBAAiB,CAAC,WAAW,aAAa;AAGhD,IAAM,sBAAsB,CAAC,UAAU,WAAW,WAAW,SAAS,OAAO;AAC7E,IAAM,uBAAuB,CAAC,eAAe,aAAa;AAG3C,SAAR,MAAuB,MAA+B;AAC3D,QAAM,SAAS,KAAK,KAAK,MAAM,WAAW,KAAK;AAC/C,QAAM,SAAS,KAAK,KAAK,WAAW,KAAK;AAEzC,MAAI,CAAC,WAAW,MAAM,GAAG;AACvB,WAAO;AAAA,MACL;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,KAAK;AAAA,QACL,UAAU;AAAA,QACV,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AAEA,QAAM,cAA+B,CAAC;AAEtC,aAAW,OAAO,eAAe;AAC/B,QAAI,CAAC,WAAW,KAAK,KAAK,QAAQ,GAAG,CAAC,GAAG;AACvC,kBAAY,KAAK;AAAA,QACf,MAAM;AAAA,QACN,MAAM;AAAA,QACN,KAAK;AAAA,QACL,UAAU;AAAA,QACV,SAAS,eAAe,GAAG;AAAA,MAC7B,CAAC;AAAA,IACH;AAAA,EACF;AAEA,aAAW,QAAQ,gBAAgB;AACjC,QAAI,CAAC,WAAW,KAAK,KAAK,QAAQ,IAAI,CAAC,GAAG;AACxC,kBAAY,KAAK;AAAA,QACf,MAAM;AAAA,QACN,MAAM;AAAA,QACN,KAAK;AAAA,QACL,UAAU;AAAA,QACV,SAAS,eAAe,IAAI;AAAA,MAC9B,CAAC;AAAA,IACH;AAAA,EACF;AAGA,QAAM,WAAW,KAAK,KAAK,QAAQ,OAAO;AAC1C,MAAI,WAAW,QAAQ,GAAG;AACxB,UAAM,WAAW,KAAK,KAAK,WAAW,OAAO,OAAO;AACpD,eAAW,OAAO,qBAAqB;AACrC,UAAI,CAAC,WAAW,KAAK,KAAK,UAAU,GAAG,CAAC,GAAG;AACzC,oBAAY,KAAK;AAAA,UACf,MAAM;AAAA,UACN,MAAM;AAAA,UACN,KAAK;AAAA,UACL,UAAU;AAAA,UACV,SAAS,qBAAqB,GAAG;AAAA,QACnC,CAAC;AAAA,MACH,WAAW,CAAC,WAAW,KAAK,KAAK,UAAU,KAAK,aAAa,CAAC,GAAG;AAC/D,oBAAY,KAAK;AAAA,UACf,MAAM,KAAK,KAAK,UAAU,GAAG;AAAA,UAC7B,MAAM;AAAA,UACN,KAAK;AAAA,UACL,UAAU;AAAA,UACV,SAAS,qBAAqB,GAAG;AAAA,QACnC,CAAC;AAAA,MACH;AAAA,IACF;AACA,eAAW,QAAQ,sBAAsB;AACvC,UAAI,CAAC,WAAW,KAAK,KAAK,UAAU,IAAI,CAAC,GAAG;AAC1C,oBAAY,KAAK;AAAA,UACf,MAAM;AAAA,UACN,MAAM;AAAA,UACN,KAAK;AAAA,UACL,UAAU;AAAA,UACV,SAAS,qBAAqB,IAAI;AAAA,QACpC,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// src/commands/lint/checks/BE/002.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
|
+
for (const entry of readdirSync(modelsDir, { withFileTypes: true })) {
|
|
12
|
+
if (!entry.isFile() || !entry.name.endsWith(".py") || entry.name === "__init__.py") continue;
|
|
13
|
+
const expectedClass = snakeToPascal(entry.name.replace(/\.py$/, ""));
|
|
14
|
+
const content = readFileSync(path.join(modelsDir, entry.name), "utf8");
|
|
15
|
+
if (!new RegExp(`class\\s+${expectedClass}\\b`).test(content)) {
|
|
16
|
+
diagnostics.push({
|
|
17
|
+
file: path.join("backend", "app", "models", entry.name),
|
|
18
|
+
line: 1,
|
|
19
|
+
col: 1,
|
|
20
|
+
severity: "error",
|
|
21
|
+
message: `models/${entry.name} must define \`class ${expectedClass}\``
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return diagnostics;
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
check as default
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=002.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/commands/lint/checks/BE/002.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/** BE002 — models/foo.py must define `class Foo` (snake_case → PascalCase) */\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 for (const entry of readdirSync(modelsDir, { withFileTypes: true })) {\n if (!entry.isFile() || !entry.name.endsWith('.py') || entry.name === '__init__.py') continue\n const expectedClass = snakeToPascal(entry.name.replace(/\\.py$/, ''))\n const content = readFileSync(path.join(modelsDir, entry.name), 'utf8')\n if (!new RegExp(`class\\\\s+${expectedClass}\\\\b`).test(content)) {\n diagnostics.push({\n file: path.join('backend', 'app', 'models', entry.name),\n line: 1,\n col: 1,\n severity: 'error',\n message: `models/${entry.name} must define \\`class ${expectedClass}\\``,\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;AAGe,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,aAAW,SAAS,YAAY,WAAW,EAAE,eAAe,KAAK,CAAC,GAAG;AACnE,QAAI,CAAC,MAAM,OAAO,KAAK,CAAC,MAAM,KAAK,SAAS,KAAK,KAAK,MAAM,SAAS,cAAe;AACpF,UAAM,gBAAgB,cAAc,MAAM,KAAK,QAAQ,SAAS,EAAE,CAAC;AACnE,UAAM,UAAU,aAAa,KAAK,KAAK,WAAW,MAAM,IAAI,GAAG,MAAM;AACrE,QAAI,CAAC,IAAI,OAAO,YAAY,aAAa,KAAK,EAAE,KAAK,OAAO,GAAG;AAC7D,kBAAY,KAAK;AAAA,QACf,MAAM,KAAK,KAAK,WAAW,OAAO,UAAU,MAAM,IAAI;AAAA,QACtD,MAAM;AAAA,QACN,KAAK;AAAA,QACL,UAAU;AAAA,QACV,SAAS,UAAU,MAAM,IAAI,wBAAwB,aAAa;AAAA,MACpE,CAAC;AAAA,IACH;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RawDiagnostic } from '@cubocicloide/dude';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* BE003 — every class in a schemas file must:
|
|
5
|
+
* 1. extend BaseModel or SQLModel (it must be a Pydantic/SQLModel schema)
|
|
6
|
+
* 2. be named with the PascalCase prefix derived from the filename
|
|
7
|
+
* (foo.py → Foo, todo_item.py → TodoItem)
|
|
8
|
+
*/
|
|
9
|
+
declare function check(root: string): RawDiagnostic[];
|
|
10
|
+
|
|
11
|
+
export { check as default };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// src/commands/lint/checks/BE/003.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 schemasDir = path.join(root, "backend", "app", "schemas");
|
|
9
|
+
if (!existsSync(schemasDir)) return [];
|
|
10
|
+
const diagnostics = [];
|
|
11
|
+
const classRe = /^class\s+(\w+)(?:\s*\(([^)]*)\))?/gm;
|
|
12
|
+
for (const entry of readdirSync(schemasDir, { withFileTypes: true })) {
|
|
13
|
+
if (!entry.isFile() || !entry.name.endsWith(".py") || entry.name === "__init__.py") continue;
|
|
14
|
+
const expectedPrefix = snakeToPascal(entry.name.replace(/\.py$/, ""));
|
|
15
|
+
const relPath = path.join("backend", "app", "schemas", entry.name);
|
|
16
|
+
const content = readFileSync(path.join(schemasDir, entry.name), "utf8");
|
|
17
|
+
for (const m of content.matchAll(classRe)) {
|
|
18
|
+
const className = m[1];
|
|
19
|
+
const bases = m[2] ?? "";
|
|
20
|
+
const isSchema = /BaseModel|SQLModel/.test(bases);
|
|
21
|
+
if (!isSchema) {
|
|
22
|
+
diagnostics.push({
|
|
23
|
+
file: relPath,
|
|
24
|
+
line: 1,
|
|
25
|
+
col: 1,
|
|
26
|
+
severity: "error",
|
|
27
|
+
message: `class \`${className}\` in ${entry.name} must extend BaseModel (or SQLModel) \u2014 only Pydantic schemas are allowed in schemas/`
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
if (!className.startsWith(expectedPrefix)) {
|
|
31
|
+
diagnostics.push({
|
|
32
|
+
file: relPath,
|
|
33
|
+
line: 1,
|
|
34
|
+
col: 1,
|
|
35
|
+
severity: "error",
|
|
36
|
+
message: `schema class \`${className}\` in ${entry.name} must start with \`${expectedPrefix}\``
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return diagnostics;
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
check as default
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=003.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/commands/lint/checks/BE/003.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 * BE003 — every class in a schemas file must:\n * 1. extend BaseModel or SQLModel (it must be a Pydantic/SQLModel schema)\n * 2. be named with the PascalCase prefix derived from the filename\n * (foo.py → Foo, todo_item.py → TodoItem)\n */\nexport default function check(root: string): RawDiagnostic[] {\n const schemasDir = path.join(root, 'backend', 'app', 'schemas')\n if (!existsSync(schemasDir)) return []\n\n const diagnostics: RawDiagnostic[] = []\n // Matches any class definition; captures name and optional base list\n const classRe = /^class\\s+(\\w+)(?:\\s*\\(([^)]*)\\))?/gm\n\n for (const entry of readdirSync(schemasDir, { withFileTypes: true })) {\n if (!entry.isFile() || !entry.name.endsWith('.py') || entry.name === '__init__.py') continue\n const expectedPrefix = snakeToPascal(entry.name.replace(/\\.py$/, ''))\n const relPath = path.join('backend', 'app', 'schemas', entry.name)\n const content = readFileSync(path.join(schemasDir, entry.name), 'utf8')\n\n for (const m of content.matchAll(classRe)) {\n const className = m[1]!\n const bases = m[2] ?? ''\n const isSchema = /BaseModel|SQLModel/.test(bases)\n\n if (!isSchema) {\n diagnostics.push({\n file: relPath,\n line: 1,\n col: 1,\n severity: 'error',\n message: `class \\`${className}\\` in ${entry.name} must extend BaseModel (or SQLModel) — only Pydantic schemas are allowed in schemas/`,\n })\n }\n\n if (!className.startsWith(expectedPrefix)) {\n diagnostics.push({\n file: relPath,\n line: 1,\n col: 1,\n severity: 'error',\n message: `schema class \\`${className}\\` in ${entry.name} must start with \\`${expectedPrefix}\\``,\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;AAQe,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;AAEtC,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;AACpF,UAAM,iBAAiB,cAAc,MAAM,KAAK,QAAQ,SAAS,EAAE,CAAC;AACpE,UAAM,UAAU,KAAK,KAAK,WAAW,OAAO,WAAW,MAAM,IAAI;AACjE,UAAM,UAAU,aAAa,KAAK,KAAK,YAAY,MAAM,IAAI,GAAG,MAAM;AAEtE,eAAW,KAAK,QAAQ,SAAS,OAAO,GAAG;AACzC,YAAM,YAAY,EAAE,CAAC;AACrB,YAAM,QAAQ,EAAE,CAAC,KAAK;AACtB,YAAM,WAAW,qBAAqB,KAAK,KAAK;AAEhD,UAAI,CAAC,UAAU;AACb,oBAAY,KAAK;AAAA,UACf,MAAM;AAAA,UACN,MAAM;AAAA,UACN,KAAK;AAAA,UACL,UAAU;AAAA,UACV,SAAS,WAAW,SAAS,SAAS,MAAM,IAAI;AAAA,QAClD,CAAC;AAAA,MACH;AAEA,UAAI,CAAC,UAAU,WAAW,cAAc,GAAG;AACzC,oBAAY,KAAK;AAAA,UACf,MAAM;AAAA,UACN,MAAM;AAAA,UACN,KAAK;AAAA,UACL,UAAU;AAAA,UACV,SAAS,kBAAkB,SAAS,SAAS,MAAM,IAAI,sBAAsB,cAAc;AAAA,QAC7F,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/commands/lint/checks/BE/004.ts
|
|
2
|
+
import { readdirSync, existsSync, readFileSync } from "fs";
|
|
3
|
+
import path from "pathe";
|
|
4
|
+
var ROUTER_RE = /router\s*=\s*APIRouter\s*\(/;
|
|
5
|
+
function check(root) {
|
|
6
|
+
const routersDir = path.join(root, "backend", "app", "routers");
|
|
7
|
+
if (!existsSync(routersDir)) return [];
|
|
8
|
+
const diagnostics = [];
|
|
9
|
+
for (const entry of readdirSync(routersDir, { withFileTypes: true })) {
|
|
10
|
+
if (!entry.isFile() || !entry.name.endsWith(".py") || entry.name === "__init__.py") continue;
|
|
11
|
+
const content = readFileSync(path.join(routersDir, entry.name), "utf8");
|
|
12
|
+
if (!ROUTER_RE.test(content)) {
|
|
13
|
+
diagnostics.push({
|
|
14
|
+
file: path.join("backend", "app", "routers", entry.name),
|
|
15
|
+
line: 1,
|
|
16
|
+
col: 1,
|
|
17
|
+
severity: "error",
|
|
18
|
+
message: `routers/${entry.name} must define \`router = APIRouter(...)\``
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return diagnostics;
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
check as default
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=004.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/commands/lint/checks/BE/004.ts"],"sourcesContent":["import { readdirSync, existsSync, readFileSync } from 'node:fs'\nimport path from 'pathe'\nimport type { RawDiagnostic } from '@cubocicloide/dude'\n\nconst ROUTER_RE = /router\\s*=\\s*APIRouter\\s*\\(/\n\n/** BE004 — routers/foo.py must define `router = APIRouter(...)` */\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 for (const entry of readdirSync(routersDir, { withFileTypes: true })) {\n if (!entry.isFile() || !entry.name.endsWith('.py') || entry.name === '__init__.py') continue\n const content = readFileSync(path.join(routersDir, entry.name), 'utf8')\n if (!ROUTER_RE.test(content)) {\n diagnostics.push({\n file: path.join('backend', 'app', 'routers', entry.name),\n line: 1,\n col: 1,\n severity: 'error',\n message: `routers/${entry.name} must define \\`router = APIRouter(...)\\``,\n })\n }\n }\n return diagnostics\n}\n"],"mappings":";AAAA,SAAS,aAAa,YAAY,oBAAoB;AACtD,OAAO,UAAU;AAGjB,IAAM,YAAY;AAGH,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,aAAW,SAAS,YAAY,YAAY,EAAE,eAAe,KAAK,CAAC,GAAG;AACpE,QAAI,CAAC,MAAM,OAAO,KAAK,CAAC,MAAM,KAAK,SAAS,KAAK,KAAK,MAAM,SAAS,cAAe;AACpF,UAAM,UAAU,aAAa,KAAK,KAAK,YAAY,MAAM,IAAI,GAAG,MAAM;AACtE,QAAI,CAAC,UAAU,KAAK,OAAO,GAAG;AAC5B,kBAAY,KAAK;AAAA,QACf,MAAM,KAAK,KAAK,WAAW,OAAO,WAAW,MAAM,IAAI;AAAA,QACvD,MAAM;AAAA,QACN,KAAK;AAAA,QACL,UAAU;AAAA,QACV,SAAS,WAAW,MAAM,IAAI;AAAA,MAChC,CAAC;AAAA,IACH;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// src/commands/lint/checks/BE/005.ts
|
|
2
|
+
import { readdirSync, existsSync, readFileSync } from "fs";
|
|
3
|
+
import path from "pathe";
|
|
4
|
+
function parseRouterImports(content) {
|
|
5
|
+
const names = /* @__PURE__ */ new Set();
|
|
6
|
+
const lines = content.split("\n");
|
|
7
|
+
let inBlock = false;
|
|
8
|
+
for (const line of lines) {
|
|
9
|
+
const trimmed = line.trim();
|
|
10
|
+
if (!inBlock) {
|
|
11
|
+
const singleLineMatch = trimmed.match(/^from\s+app\.routers\s+import\s+\(([^)]+)\)/);
|
|
12
|
+
if (singleLineMatch?.[1]) {
|
|
13
|
+
for (const n of singleLineMatch[1].split(",")) {
|
|
14
|
+
const name = n.trim();
|
|
15
|
+
if (name) names.add(name);
|
|
16
|
+
}
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (/^from\s+app\.routers\s+import\s+\(/.test(trimmed)) {
|
|
20
|
+
inBlock = true;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const inlineMatch = trimmed.match(/^from\s+app\.routers\s+import\s+(\w+)/);
|
|
24
|
+
if (inlineMatch?.[1]) names.add(inlineMatch[1]);
|
|
25
|
+
} else {
|
|
26
|
+
if (trimmed.includes(")")) {
|
|
27
|
+
inBlock = false;
|
|
28
|
+
const part = trimmed.slice(0, trimmed.indexOf(")"));
|
|
29
|
+
for (const n of part.split(",")) {
|
|
30
|
+
const name = n.trim();
|
|
31
|
+
if (name) names.add(name);
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
for (const n of trimmed.split(",")) {
|
|
35
|
+
const name = n.trim();
|
|
36
|
+
if (name) names.add(name);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return names;
|
|
42
|
+
}
|
|
43
|
+
function parseIncludedRouters(content) {
|
|
44
|
+
const names = /* @__PURE__ */ new Set();
|
|
45
|
+
const re = /\.include_router\(\s*(\w+)\.router[\s,)]/g;
|
|
46
|
+
let m;
|
|
47
|
+
while ((m = re.exec(content)) !== null) {
|
|
48
|
+
if (m[1]) names.add(m[1]);
|
|
49
|
+
}
|
|
50
|
+
return names;
|
|
51
|
+
}
|
|
52
|
+
function check(root) {
|
|
53
|
+
const routersDir = path.join(root, "backend", "app", "routers");
|
|
54
|
+
const mainPy = path.join(root, "backend", "app", "main.py");
|
|
55
|
+
if (!existsSync(routersDir) || !existsSync(mainPy)) return [];
|
|
56
|
+
const stems = new Set(
|
|
57
|
+
readdirSync(routersDir, { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(".py") && e.name !== "__init__.py").map((e) => e.name.slice(0, -3))
|
|
58
|
+
);
|
|
59
|
+
const content = readFileSync(mainPy, "utf8");
|
|
60
|
+
const mainRel = path.join("backend", "app", "main.py");
|
|
61
|
+
const imported = parseRouterImports(content);
|
|
62
|
+
const included = parseIncludedRouters(content);
|
|
63
|
+
const diagnostics = [];
|
|
64
|
+
for (const stem of stems) {
|
|
65
|
+
if (!imported.has(stem))
|
|
66
|
+
diagnostics.push({
|
|
67
|
+
file: mainRel,
|
|
68
|
+
line: 1,
|
|
69
|
+
col: 1,
|
|
70
|
+
severity: "warning",
|
|
71
|
+
message: `routers/${stem}.py exists but is not imported in main.py`
|
|
72
|
+
});
|
|
73
|
+
if (!included.has(stem))
|
|
74
|
+
diagnostics.push({
|
|
75
|
+
file: mainRel,
|
|
76
|
+
line: 1,
|
|
77
|
+
col: 1,
|
|
78
|
+
severity: "warning",
|
|
79
|
+
message: `routers/${stem}.router is not registered via include_router() in main.py`
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
for (const name of imported) {
|
|
83
|
+
if (!stems.has(name))
|
|
84
|
+
diagnostics.push({
|
|
85
|
+
file: mainRel,
|
|
86
|
+
line: 1,
|
|
87
|
+
col: 1,
|
|
88
|
+
severity: "error",
|
|
89
|
+
message: `main.py imports \`${name}\` from app.routers but routers/${name}.py does not exist`
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
for (const name of included) {
|
|
93
|
+
if (!stems.has(name))
|
|
94
|
+
diagnostics.push({
|
|
95
|
+
file: mainRel,
|
|
96
|
+
line: 1,
|
|
97
|
+
col: 1,
|
|
98
|
+
severity: "error",
|
|
99
|
+
message: `main.py calls include_router(${name}.router) but routers/${name}.py does not exist`
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return diagnostics;
|
|
103
|
+
}
|
|
104
|
+
export {
|
|
105
|
+
check as default
|
|
106
|
+
};
|
|
107
|
+
//# sourceMappingURL=005.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/commands/lint/checks/BE/005.ts"],"sourcesContent":["import { readdirSync, existsSync, readFileSync } from 'node:fs'\nimport path from 'pathe'\nimport type { RawDiagnostic } from '@cubocicloide/dude'\n\n/** Extract module names from `from app.routers import (name1, name2, ...)` */\nfunction parseRouterImports(content: string): Set<string> {\n const names = new Set<string>()\n const lines = content.split('\\n')\n let inBlock = false\n for (const line of lines) {\n const trimmed = line.trim()\n if (!inBlock) {\n const singleLineMatch = trimmed.match(/^from\\s+app\\.routers\\s+import\\s+\\(([^)]+)\\)/)\n if (singleLineMatch?.[1]) {\n for (const n of singleLineMatch[1].split(',')) {\n const name = n.trim()\n if (name) names.add(name)\n }\n continue\n }\n if (/^from\\s+app\\.routers\\s+import\\s+\\(/.test(trimmed)) {\n inBlock = true\n continue\n }\n const inlineMatch = trimmed.match(/^from\\s+app\\.routers\\s+import\\s+(\\w+)/)\n if (inlineMatch?.[1]) names.add(inlineMatch[1])\n } else {\n if (trimmed.includes(')')) {\n inBlock = false\n const part = trimmed.slice(0, trimmed.indexOf(')'))\n for (const n of part.split(',')) {\n const name = n.trim()\n if (name) names.add(name)\n }\n } else {\n for (const n of trimmed.split(',')) {\n const name = n.trim()\n if (name) names.add(name)\n }\n }\n }\n }\n return names\n}\n\n/** Extract module names from `.include_router(module.router)` calls */\nfunction parseIncludedRouters(content: string): Set<string> {\n const names = new Set<string>()\n const re = /\\.include_router\\(\\s*(\\w+)\\.router[\\s,)]/g\n let m: RegExpExecArray | null\n while ((m = re.exec(content)) !== null) {\n if (m[1]) names.add(m[1])\n }\n return names\n}\n\n/** BE005 — main.py must import and include_router every module in routers/, and only those */\nexport default function check(root: string): RawDiagnostic[] {\n const routersDir = path.join(root, 'backend', 'app', 'routers')\n const mainPy = path.join(root, 'backend', 'app', 'main.py')\n if (!existsSync(routersDir) || !existsSync(mainPy)) return []\n\n const stems = new Set(\n readdirSync(routersDir, { withFileTypes: true })\n .filter((e) => e.isFile() && e.name.endsWith('.py') && e.name !== '__init__.py')\n .map((e) => e.name.slice(0, -3)),\n )\n\n const content = readFileSync(mainPy, 'utf8')\n const mainRel = path.join('backend', 'app', 'main.py')\n const imported = parseRouterImports(content)\n const included = parseIncludedRouters(content)\n const diagnostics: RawDiagnostic[] = []\n\n for (const stem of stems) {\n if (!imported.has(stem))\n diagnostics.push({\n file: mainRel,\n line: 1,\n col: 1,\n severity: 'warning',\n message: `routers/${stem}.py exists but is not imported in main.py`,\n })\n if (!included.has(stem))\n diagnostics.push({\n file: mainRel,\n line: 1,\n col: 1,\n severity: 'warning',\n message: `routers/${stem}.router is not registered via include_router() in main.py`,\n })\n }\n for (const name of imported) {\n if (!stems.has(name))\n diagnostics.push({\n file: mainRel,\n line: 1,\n col: 1,\n severity: 'error',\n message: `main.py imports \\`${name}\\` from app.routers but routers/${name}.py does not exist`,\n })\n }\n for (const name of included) {\n if (!stems.has(name))\n diagnostics.push({\n file: mainRel,\n line: 1,\n col: 1,\n severity: 'error',\n message: `main.py calls include_router(${name}.router) but routers/${name}.py does not exist`,\n })\n }\n\n return diagnostics\n}\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/commands/lint/checks/BE/006.ts
|
|
2
|
+
import { readdirSync, existsSync } from "fs";
|
|
3
|
+
import path from "pathe";
|
|
4
|
+
var STEM_RE = /^[a-z][a-z0-9]*(_[a-z][a-z0-9]*|__[a-z][a-z0-9]*)*$/;
|
|
5
|
+
function check(root) {
|
|
6
|
+
const routersDir = path.join(root, "backend", "app", "routers");
|
|
7
|
+
if (!existsSync(routersDir)) return [];
|
|
8
|
+
const diagnostics = [];
|
|
9
|
+
for (const entry of readdirSync(routersDir, { withFileTypes: true })) {
|
|
10
|
+
if (!entry.isFile() || !entry.name.endsWith(".py") || entry.name === "__init__.py") continue;
|
|
11
|
+
const stem = entry.name.slice(0, -3);
|
|
12
|
+
if (!STEM_RE.test(stem)) {
|
|
13
|
+
diagnostics.push({
|
|
14
|
+
file: path.join("backend", "app", "routers", entry.name),
|
|
15
|
+
line: 1,
|
|
16
|
+
col: 1,
|
|
17
|
+
severity: "error",
|
|
18
|
+
message: `routers/${entry.name}: stem \`${stem}\` must be lowercase segments separated by _ (sub-resource) or __ (path param)`
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return diagnostics;
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
check as default
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=006.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/commands/lint/checks/BE/006.ts"],"sourcesContent":["import { readdirSync, existsSync } from 'node:fs'\nimport path from 'pathe'\nimport type { RawDiagnostic } from '@cubocicloide/dude'\n\n/**\n * Valid router stem: one or more lowercase-alphanumeric segments separated by\n * `_` (sub-resource, e.g. users_me) or `__` (path param, e.g. todos__id).\n * Examples: health, todos, todos__id, users_me, keycloak_token_refresh\n */\nconst STEM_RE = /^[a-z][a-z0-9]*(_[a-z][a-z0-9]*|__[a-z][a-z0-9]*)*$/\n\n/** BE006 — router filenames must follow {resource}[_sub|__param].py convention */\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 for (const entry of readdirSync(routersDir, { withFileTypes: true })) {\n if (!entry.isFile() || !entry.name.endsWith('.py') || entry.name === '__init__.py') continue\n const stem = entry.name.slice(0, -3)\n if (!STEM_RE.test(stem)) {\n diagnostics.push({\n file: path.join('backend', 'app', 'routers', entry.name),\n line: 1,\n col: 1,\n severity: 'error',\n message: `routers/${entry.name}: stem \\`${stem}\\` must be lowercase segments separated by _ (sub-resource) or __ (path param)`,\n })\n }\n }\n return diagnostics\n}\n"],"mappings":";AAAA,SAAS,aAAa,kBAAkB;AACxC,OAAO,UAAU;AAQjB,IAAM,UAAU;AAGD,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,aAAW,SAAS,YAAY,YAAY,EAAE,eAAe,KAAK,CAAC,GAAG;AACpE,QAAI,CAAC,MAAM,OAAO,KAAK,CAAC,MAAM,KAAK,SAAS,KAAK,KAAK,MAAM,SAAS,cAAe;AACpF,UAAM,OAAO,MAAM,KAAK,MAAM,GAAG,EAAE;AACnC,QAAI,CAAC,QAAQ,KAAK,IAAI,GAAG;AACvB,kBAAY,KAAK;AAAA,QACf,MAAM,KAAK,KAAK,WAAW,OAAO,WAAW,MAAM,IAAI;AAAA,QACvD,MAAM;AAAA,QACN,KAAK;AAAA,QACL,UAAU;AAAA,QACV,SAAS,WAAW,MAAM,IAAI,YAAY,IAAI;AAAA,MAChD,CAAC;AAAA,IACH;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { RawDiagnostic } from '@cubocicloide/dude';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Derive the expected URL path from a router filename stem.
|
|
5
|
+
*
|
|
6
|
+
* Rules:
|
|
7
|
+
* - `__param` (double underscore) → `/{param}` (path parameter)
|
|
8
|
+
* - `_segment` (single underscore) → `/segment` (literal path segment)
|
|
9
|
+
*
|
|
10
|
+
* Examples:
|
|
11
|
+
* health → /health
|
|
12
|
+
* todos → /todos
|
|
13
|
+
* todos__id → /todos/{id}
|
|
14
|
+
* users_me → /users/me
|
|
15
|
+
* keycloak_token → /keycloak/token
|
|
16
|
+
*/
|
|
17
|
+
declare function stemToExpectedPath(stem: string): string;
|
|
18
|
+
declare function allowedHandlerName(method: string, stem: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* BE007 — router files may only contain @router.METHOD-decorated functions,
|
|
21
|
+
* each named `{method}_{stem}` and mapped to the path derived from the filename.
|
|
22
|
+
*
|
|
23
|
+
* Examples for `todos__id.py` (stem=todos__id, expectedPath=/todos/{id}):
|
|
24
|
+
* ✓ @router.get("/todos/{id}") async def get_todos__id(...)
|
|
25
|
+
* ✗ def ciao() — not a route handler
|
|
26
|
+
* ✗ @router.get("/wrong") async def get_todos__id(...) — wrong path
|
|
27
|
+
* ✗ @router.get("/todos/{id}") async def fetch_item(...) — wrong name
|
|
28
|
+
*/
|
|
29
|
+
declare function check(root: string): RawDiagnostic[];
|
|
30
|
+
|
|
31
|
+
export { allowedHandlerName, check as default, stemToExpectedPath };
|