rapidkit 0.14.1 → 0.15.1

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 (61) hide show
  1. package/README.md +199 -38
  2. package/dist/index.d.ts +3 -0
  3. package/dist/index.js +746 -494
  4. package/dist/package.json +14 -6
  5. package/package.json +14 -6
  6. package/templates/generator.js +0 -175
  7. package/templates/kits/fastapi-standard/.rapidkit/__init__.py.j2 +0 -1
  8. package/templates/kits/fastapi-standard/.rapidkit/activate.j2 +0 -24
  9. package/templates/kits/fastapi-standard/.rapidkit/cli.py.j2 +0 -289
  10. package/templates/kits/fastapi-standard/.rapidkit/context.json +0 -3
  11. package/templates/kits/fastapi-standard/.rapidkit/project.json.j2 +0 -7
  12. package/templates/kits/fastapi-standard/.rapidkit/rapidkit.j2 +0 -107
  13. package/templates/kits/fastapi-standard/Makefile.j2 +0 -41
  14. package/templates/kits/fastapi-standard/README.md.j2 +0 -38
  15. package/templates/kits/fastapi-standard/kit.json +0 -70
  16. package/templates/kits/fastapi-standard/kit.yaml +0 -120
  17. package/templates/kits/fastapi-standard/pyproject.toml.j2 +0 -42
  18. package/templates/kits/fastapi-standard/rapidkit.cmd.j2 +0 -72
  19. package/templates/kits/fastapi-standard/rapidkit.j2 +0 -50
  20. package/templates/kits/fastapi-standard/src/__init__.py.j2 +0 -3
  21. package/templates/kits/fastapi-standard/src/cli.py.j2 +0 -335
  22. package/templates/kits/fastapi-standard/src/main.py.j2 +0 -44
  23. package/templates/kits/fastapi-standard/src/modules/__init__.py.j2 +0 -3
  24. package/templates/kits/fastapi-standard/src/routing/__init__.py.j2 +0 -13
  25. package/templates/kits/fastapi-standard/src/routing/health.py.j2 +0 -32
  26. package/templates/kits/fastapi-standard/tests/__init__.py.j2 +0 -1
  27. package/templates/kits/nestjs-standard/.env.example.j2 +0 -16
  28. package/templates/kits/nestjs-standard/.eslintrc.js.j2 +0 -25
  29. package/templates/kits/nestjs-standard/.gitignore.j2 +0 -26
  30. package/templates/kits/nestjs-standard/.node-version.j2 +0 -1
  31. package/templates/kits/nestjs-standard/.nvmrc.j2 +0 -1
  32. package/templates/kits/nestjs-standard/.prettierrc.j2 +0 -7
  33. package/templates/kits/nestjs-standard/.rapidkit/activate.j2 +0 -25
  34. package/templates/kits/nestjs-standard/.rapidkit/context.json +0 -3
  35. package/templates/kits/nestjs-standard/.rapidkit/project.json.j2 +0 -7
  36. package/templates/kits/nestjs-standard/.rapidkit/rapidkit.cmd.j2 +0 -166
  37. package/templates/kits/nestjs-standard/.rapidkit/rapidkit.j2 +0 -227
  38. package/templates/kits/nestjs-standard/README.md.j2 +0 -110
  39. package/templates/kits/nestjs-standard/jest.config.ts.j2 +0 -21
  40. package/templates/kits/nestjs-standard/nest-cli.json.j2 +0 -10
  41. package/templates/kits/nestjs-standard/package.json.j2 +0 -75
  42. package/templates/kits/nestjs-standard/rapidkit.cmd.j2 +0 -5
  43. package/templates/kits/nestjs-standard/rapidkit.j2 +0 -5
  44. package/templates/kits/nestjs-standard/src/app.controller.ts.j2 +0 -12
  45. package/templates/kits/nestjs-standard/src/app.module.ts.j2 +0 -23
  46. package/templates/kits/nestjs-standard/src/app.service.ts.j2 +0 -11
  47. package/templates/kits/nestjs-standard/src/config/configuration.ts.j2 +0 -9
  48. package/templates/kits/nestjs-standard/src/config/index.ts.j2 +0 -2
  49. package/templates/kits/nestjs-standard/src/config/validation.ts.j2 +0 -11
  50. package/templates/kits/nestjs-standard/src/examples/dto/create-note.dto.ts.j2 +0 -11
  51. package/templates/kits/nestjs-standard/src/examples/examples.controller.ts.j2 +0 -24
  52. package/templates/kits/nestjs-standard/src/examples/examples.module.ts.j2 +0 -10
  53. package/templates/kits/nestjs-standard/src/examples/examples.service.ts.j2 +0 -33
  54. package/templates/kits/nestjs-standard/src/main.ts.j2 +0 -51
  55. package/templates/kits/nestjs-standard/src/modules/index.ts.j2 +0 -3
  56. package/templates/kits/nestjs-standard/test/app.controller.spec.ts.j2 +0 -22
  57. package/templates/kits/nestjs-standard/test/app.e2e-spec.ts.j2 +0 -48
  58. package/templates/kits/nestjs-standard/test/examples.controller.spec.ts.j2 +0 -28
  59. package/templates/kits/nestjs-standard/test/jest-e2e.json.j2 +0 -15
  60. package/templates/kits/nestjs-standard/tsconfig.build.json.j2 +0 -12
  61. package/templates/kits/nestjs-standard/tsconfig.json.j2 +0 -26
@@ -1,335 +0,0 @@
1
- #!/usr/bin/env python3
2
- """Professional CLI commands for {{ project_name }} - Poetry Scripts Integration
3
-
4
- A modern CLI inspired by Next.js developer experience for FastAPI projects.
5
- """
6
-
7
- import os
8
- import subprocess
9
- import sys
10
- from pathlib import Path
11
- from typing import Any, Dict
12
-
13
-
14
- def _print_banner(emoji: str, message: str, color_code: str = "36") -> None:
15
- """Print colored banner message."""
16
- print(f"\033[{color_code}m{emoji} {message}\033[0m")
17
-
18
-
19
- def _print_error(message: str) -> None:
20
- """Print error message in red."""
21
- print(f"\033[91m❌ {message}\033[0m")
22
-
23
-
24
- def _print_success(message: str) -> None:
25
- """Print success message in green."""
26
- print(f"\033[92m✅ {message}\033[0m")
27
-
28
-
29
- def _get_env_var(key: str, default: str) -> str:
30
- """Get environment variable with default."""
31
- return os.getenv(key, default)
32
-
33
-
34
- def _parse_args() -> dict:
35
- """Parse command line arguments."""
36
- args = {"port": "8000", "host": "0.0.0.0", "workers": "1", "env": "development"}
37
-
38
- i = 0
39
- while i < len(sys.argv):
40
- if sys.argv[i] in ["--port", "-p"] and i + 1 < len(sys.argv):
41
- args["port"] = sys.argv[i + 1]
42
- i += 2
43
- elif sys.argv[i] in ["--host", "-h"] and i + 1 < len(sys.argv):
44
- args["host"] = sys.argv[i + 1]
45
- i += 2
46
- elif sys.argv[i] in ["--workers", "-w"] and i + 1 < len(sys.argv):
47
- args["workers"] = sys.argv[i + 1]
48
- i += 2
49
- elif sys.argv[i] in ["--env", "-e"] and i + 1 < len(sys.argv):
50
- args["env"] = sys.argv[i + 1]
51
- i += 2
52
- else:
53
- i += 1
54
-
55
- return args
56
-
57
- def _run_uvicorn(module: str, reload: bool = False, **kwargs: Any) -> None:
58
- """Run uvicorn server with proper error handling."""
59
- args: Dict[str, Any] = _parse_args()
60
-
61
- cmd: list[str] = [
62
- sys.executable, "-m", "uvicorn",
63
- module,
64
- "--host", str(args.get("host", "0.0.0.0")),
65
- "--port", str(args.get("port", 8000))
66
- ]
67
-
68
- if reload:
69
- cmd.append("--reload")
70
- cmd.extend(["--reload-dir", "src"])
71
-
72
- env: str = args.get("env", "development")
73
- if env == "production" and "workers" in args:
74
- cmd.extend(["--workers", str(args["workers"])])
75
- cmd.append("--no-access-log")
76
-
77
- extra_args: list[str] = kwargs.get("extra_args", [])
78
- cmd.extend(extra_args)
79
-
80
- env_vars: Dict[str, str] = os.environ.copy()
81
- env_vars.update({
82
- "PYTHONPATH": str(Path.cwd()),
83
- "ENVIRONMENT": env
84
- })
85
-
86
- try:
87
- subprocess.run(cmd, check=False, env=env_vars)
88
- except KeyboardInterrupt:
89
- _print_banner("🛑", "Server stopped by user")
90
- except Exception as e:
91
- _print_error(f"Failed to start server: {e}")
92
- sys.exit(1)
93
-
94
- def dev() -> None:
95
- """🚀 Start development server with hot reload
96
-
97
- Usage:
98
- rapidkit dev [options] # preferred (project-aware)
99
- # or: poetry run dev [options]
100
-
101
- Options:
102
- --port, -p PORT Server port (default: 8000)
103
- --host, -h HOST Server host (default: 0.0.0.0)
104
- --env, -e ENV Environment (default: development)
105
-
106
- Examples:
107
- rapidkit dev
108
- rapidkit dev --port 3000
109
- rapidkit dev --host 127.0.0.1 --port 8080
110
- # or: poetry run dev --port 3000
111
- """
112
- _print_banner("🚀", "Starting development server with hot reload...")
113
- _print_banner("📁", f"Working directory: {Path.cwd()}")
114
-
115
- args = _parse_args()
116
- _print_banner("🌐", f"Server will be available at: http://{args['host']}:{args['port']}")
117
-
118
- _run_uvicorn("src.main:app", reload=True)
119
-
120
-
121
- def start() -> None:
122
- """⚡ Start production server
123
-
124
- Usage:
125
- poetry run start [options]
126
-
127
- Options:
128
- --port, -p PORT Server port (default: 8000)
129
- --host, -h HOST Server host (default: 0.0.0.0)
130
- --workers, -w NUM Number of workers (default: 1)
131
-
132
- Examples:
133
- poetry run start
134
- poetry run start --workers 4 --port 80
135
- """
136
- _print_banner("⚡", "Starting production server...")
137
-
138
- args = _parse_args()
139
- _print_banner("👥", f"Workers: {args['workers']}")
140
- _print_banner("🌐", f"Server will be available at: http://{args['host']}:{args['port']}")
141
-
142
- _run_uvicorn("src.main:app", reload=False, env="production")
143
-
144
-
145
- def build() -> None:
146
- """📦 Build project for production
147
-
148
- This command prepares the project for production deployment:
149
- - Validates dependencies
150
- - Runs type checking
151
- - Builds distribution packages
152
- """
153
- _print_banner("📦", "Building project for production...")
154
-
155
- try:
156
- # Type checking
157
- _print_banner("🔍", "Running type checks...")
158
- result = subprocess.run([
159
- sys.executable, "-m", "mypy", "src", "--ignore-missing-imports"
160
- ], capture_output=True, text=True)
161
-
162
- if result.returncode != 0:
163
- _print_error("Type checking failed!")
164
- print(result.stdout)
165
- print(result.stderr)
166
- else:
167
- _print_success("Type checking passed!")
168
-
169
- # Build wheel
170
- _print_banner("🏗️", "Building distribution packages...")
171
- subprocess.run([sys.executable, "-m", "build"], check=True)
172
-
173
- _print_success("Build completed successfully!")
174
- _print_banner("📁", "Distribution files created in 'dist/' directory")
175
-
176
- except subprocess.CalledProcessError as e:
177
- _print_error(f"Build failed: {e}")
178
- sys.exit(1)
179
- except FileNotFoundError:
180
- _print_error("Build tools not found. Install with: rapidkit init (or: poetry install --group dev)")
181
- sys.exit(1)
182
-
183
-
184
- def test() -> None:
185
- """🧪 Run tests with coverage
186
-
187
- Usage:
188
- poetry run test [pytest-options]
189
-
190
- Examples:
191
- poetry run test
192
- poetry run test -v
193
- poetry run test tests/test_api.py
194
- poetry run test --cov-report=html
195
- """
196
- _print_banner("🧪", "Running tests with coverage...")
197
-
198
- # Get additional pytest args
199
- pytest_args = [arg for arg in sys.argv[2:] if not arg.startswith("-")]
200
-
201
- cmd = [
202
- sys.executable, "-m", "pytest",
203
- "--cov=src",
204
- "--cov-report=term-missing",
205
- "--cov-report=xml",
206
- "-v"
207
- ] + pytest_args
208
-
209
- try:
210
- result = subprocess.run(cmd, check=False)
211
-
212
- if result.returncode == 0:
213
- _print_success("All tests passed!")
214
- else:
215
- _print_error("Some tests failed!")
216
- sys.exit(result.returncode)
217
-
218
- except FileNotFoundError:
219
- _print_error("pytest not found. Install with: rapidkit init (or: poetry install --group dev)")
220
- sys.exit(1)
221
-
222
-
223
- def lint() -> None:
224
- """� Run code linting and formatting
225
-
226
- This command runs:
227
- - ruff for linting
228
- - black for formatting
229
- - isort for import sorting
230
- """
231
- _print_banner("�", "Running linting and formatting...")
232
-
233
- try:
234
- # Ruff linting
235
- _print_banner("📋", "Running ruff linter...")
236
- subprocess.run([sys.executable, "-m", "ruff", "check", "src"], check=True)
237
-
238
- # Black formatting
239
- _print_banner("🎨", "Running black formatter...")
240
- subprocess.run([sys.executable, "-m", "black", "src", "--check"], check=True)
241
-
242
- # isort import sorting
243
- _print_banner("📦", "Checking import sorting...")
244
- subprocess.run([sys.executable, "-m", "isort", "src", "--check-only"], check=True)
245
-
246
- _print_success("All linting checks passed!")
247
-
248
- except subprocess.CalledProcessError:
249
- _print_error("Linting failed! Run 'poetry run format' to fix issues.")
250
- sys.exit(1)
251
- except FileNotFoundError:
252
- _print_error("Linting tools not found. Install with: rapidkit init (or: poetry install --group dev)")
253
- sys.exit(1)
254
-
255
-
256
- def format() -> None:
257
- """✨ Format code automatically
258
-
259
- This command auto-fixes:
260
- - Code formatting with black
261
- - Import sorting with isort
262
- - Auto-fixable linting issues with ruff
263
- """
264
- _print_banner("✨", "Formatting code...")
265
-
266
- try:
267
- # Ruff auto-fix
268
- _print_banner("🔧", "Auto-fixing with ruff...")
269
- subprocess.run([sys.executable, "-m", "ruff", "check", "src", "--fix"], check=True)
270
-
271
- # Black formatting
272
- _print_banner("🎨", "Formatting with black...")
273
- subprocess.run([sys.executable, "-m", "black", "src"], check=True)
274
-
275
- # isort import sorting
276
- _print_banner("📦", "Sorting imports with isort...")
277
- subprocess.run([sys.executable, "-m", "isort", "src"], check=True)
278
-
279
- _print_success("Code formatting completed!")
280
-
281
- except subprocess.CalledProcessError as e:
282
- _print_error(f"Formatting failed: {e}")
283
- sys.exit(1)
284
- except FileNotFoundError:
285
- _print_error("Formatting tools not found. Install with: rapidkit init (or: poetry install --group dev)")
286
- sys.exit(1)
287
-
288
-
289
- def help_cmd() -> None:
290
- """📚 Show detailed help information"""
291
- _print_banner("📚", "{{ project_name }} - Available Commands")
292
-
293
- commands = {
294
- "dev": "🚀 Start development server with hot reload",
295
- "start": "⚡ Start production server",
296
- "build": "📦 Build project for production",
297
- "test": "🧪 Run tests with coverage",
298
- "lint": "🔧 Run code linting and formatting checks",
299
- "format": "✨ Format code automatically",
300
- "help": "📚 Show this help message"
301
- }
302
-
303
- print("\nCommands:")
304
- for cmd, desc in commands.items():
305
- print(f" poetry run {cmd:<10} {desc}")
306
-
307
- print("\nFor detailed command help:")
308
- print(" poetry run <command> --help")
309
-
310
- print("\nProject: {{ project_name }}")
311
- print("Framework: FastAPI + RapidKit")
312
-
313
-
314
- if __name__ == "__main__":
315
- if len(sys.argv) < 2:
316
- help_cmd()
317
- sys.exit(0)
318
-
319
- command = sys.argv[1]
320
- commands = {
321
- "dev": dev,
322
- "start": start,
323
- "build": build,
324
- "test": test,
325
- "lint": lint,
326
- "format": format,
327
- "help": help_cmd,
328
- }
329
-
330
- if command in commands:
331
- commands[command]()
332
- else:
333
- _print_error(f"Unknown command: {command}")
334
- print("\nRun 'poetry run help' to see available commands.")
335
- sys.exit(1)
@@ -1,44 +0,0 @@
1
- """{{ project_name }} application entrypoint."""
2
-
3
- from __future__ import annotations
4
-
5
- from contextlib import asynccontextmanager
6
- from typing import AsyncIterator
7
-
8
- from fastapi import FastAPI
9
- from fastapi.middleware.cors import CORSMiddleware
10
-
11
- # <<<inject:imports>>>
12
-
13
- from .routing import api_router
14
-
15
-
16
- @asynccontextmanager
17
- async def lifespan(app: FastAPI) -> AsyncIterator[None]:
18
- """Application lifespan context manager for startup/shutdown events."""
19
- # Startup
20
- # <<<inject:startup>>>
21
- yield
22
- # Shutdown
23
- # <<<inject:shutdown>>>
24
-
25
-
26
- app = FastAPI(
27
- title="{{ project_name }}",
28
- description="{{ description }}",
29
- version="{{ app_version }}",
30
- docs_url="/docs",
31
- redoc_url="/redoc",
32
- lifespan=lifespan,
33
- )
34
-
35
- app.add_middleware(
36
- CORSMiddleware,
37
- allow_origins=["*"],
38
- allow_credentials=True,
39
- allow_methods=["*"],
40
- allow_headers=["*"],
41
- )
42
-
43
- app.include_router(api_router, prefix="/api")
44
- # <<<inject:routes>>>
@@ -1,3 +0,0 @@
1
- """Module bootstrap namespace."""
2
-
3
- # <<<inject:module-init>>>
@@ -1,13 +0,0 @@
1
- """API router assembly."""
2
-
3
- from __future__ import annotations
4
-
5
- from fastapi import APIRouter
6
-
7
- from .health import router as health_router
8
- # <<<inject:router-imports>>>
9
-
10
- api_router = APIRouter()
11
-
12
- api_router.include_router(health_router)
13
- # <<<inject:router-mount>>>
@@ -1,32 +0,0 @@
1
- """Health endpoints."""
2
-
3
- from __future__ import annotations
4
-
5
- from fastapi import APIRouter
6
-
7
- try:
8
- from src.health.registry import (
9
- list_registered_health_routes as _list_registered_health_routes,
10
- )
11
- except ImportError: # pragma: no cover - registry not generated yet
12
- def _list_registered_health_routes(
13
- prefix: str = "/api/health",
14
- ) -> list[dict[str, str]]:
15
- return []
16
-
17
-
18
- router = APIRouter(prefix="/health", tags=["health"])
19
-
20
-
21
- @router.get("/", summary="Health check")
22
- async def heartbeat() -> dict[str, str]:
23
- """Return basic service heartbeat."""
24
-
25
- return {"status": "ok"}
26
-
27
-
28
- @router.get("/modules", summary="Registered module health endpoints")
29
- async def module_health_catalog() -> dict[str, list[dict[str, str]]]:
30
- """Expose metadata for module-provided health routers."""
31
-
32
- return {"routes": _list_registered_health_routes()}
@@ -1 +0,0 @@
1
- """Test package placeholder."""
@@ -1,16 +0,0 @@
1
- # Application
2
- APP_NAME={{ project_name | upper | replace('-', '_') }}
3
- PORT=8000
4
- HOST=0.0.0.0
5
- NODE_ENV=development
6
-
7
- # Security
8
- JWT_SECRET=your-super-secret-jwt-key-change-in-production
9
- JWT_EXPIRATION=1h
10
-
11
- # Database (optional)
12
- # DATABASE_URL=postgresql://user:password@localhost:5432/{{ project_name | replace('-', '_') }}
13
-
14
- # Redis (optional)
15
- # REDIS_HOST=localhost
16
- # REDIS_PORT=6379
@@ -1,25 +0,0 @@
1
- module.exports = {
2
- parser: '@typescript-eslint/parser',
3
- parserOptions: {
4
- project: ['tsconfig.json'],
5
- tsconfigRootDir: __dirname,
6
- sourceType: 'module',
7
- },
8
- plugins: ['@typescript-eslint/eslint-plugin'],
9
- extends: [
10
- 'plugin:@typescript-eslint/recommended',
11
- 'plugin:prettier/recommended',
12
- ],
13
- root: true,
14
- env: {
15
- node: true,
16
- jest: true,
17
- },
18
- ignorePatterns: ['.eslintrc.js'],
19
- rules: {
20
- '@typescript-eslint/interface-name-prefix': 'off',
21
- '@typescript-eslint/explicit-function-return-type': 'off',
22
- '@typescript-eslint/explicit-module-boundary-types': 'off',
23
- '@typescript-eslint/no-explicit-any': 'warn',
24
- },
25
- };
@@ -1,26 +0,0 @@
1
- # Node artifacts
2
- node_modules/
3
- dist/
4
- .tmp/
5
- .env
6
- .env.*
7
- !.env.example
8
-
9
- # Logs
10
- logs/
11
- *.log
12
- npm-debug.log*
13
- yarn-debug.log*
14
- yarn-error.log*
15
- pnpm-debug.log*
16
-
17
- # OS
18
- .DS_Store
19
- Thumbs.db
20
-
21
- # IDEs
22
- .idea/
23
- .vscode/
24
-
25
- # Coverage
26
- coverage/
@@ -1 +0,0 @@
1
- 20
@@ -1,7 +0,0 @@
1
- {
2
- "singleQuote": true,
3
- "trailingComma": "all",
4
- "printWidth": 100,
5
- "tabWidth": 2,
6
- "semi": true
7
- }
@@ -1,25 +0,0 @@
1
- #!/bin/bash
2
- # RapidKit Environment Activation
3
- # Usage: source .rapidkit/activate
4
-
5
- # Get the directory where this script is located
6
- RAPIDKIT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7
- PROJECT_ROOT="$(dirname "$RAPIDKIT_DIR")"
8
-
9
- # Add project root to PATH (where rapidkit script lives)
10
- if [[ ":$PATH:" != *":$PROJECT_ROOT:"* ]]; then
11
- export PATH="$PROJECT_ROOT:$PATH"
12
- echo "✅ RapidKit activated! You can now use 'rapidkit' commands directly."
13
- else
14
- echo "ℹ️ RapidKit already activated."
15
- fi
16
-
17
- # Show available commands
18
- echo ""
19
- echo "📚 Available commands:"
20
- echo " rapidkit dev - Start development server"
21
- echo " rapidkit init - Install dependencies"
22
- echo " rapidkit build - Build for production"
23
- echo " rapidkit test - Run tests"
24
- echo " rapidkit --help - Show all commands"
25
- echo ""
@@ -1,3 +0,0 @@
1
- {
2
- "engine": "npm"
3
- }
@@ -1,7 +0,0 @@
1
- {
2
- "kit_name": "nestjs.standard",
3
- "profile": "nestjs/standard",
4
- "project_name": "{{ project_name }}",
5
- "created_at": "{{ created_at }}",
6
- "rapidkit_version": "npm-{{ rapidkit_version }}"
7
- }