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
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rapidkit",
3
- "version": "0.14.0",
3
+ "version": "0.15.1",
4
4
  "type": "module",
5
5
  "description": "Create RapidKit projects with a single command - The official CLI for RapidKit framework",
6
6
  "keywords": [
@@ -24,18 +24,23 @@
24
24
  "rapidkit": "dist/index.js"
25
25
  },
26
26
  "files": [
27
- "dist",
28
- "templates"
27
+ "dist"
29
28
  ],
30
29
  "scripts": {
31
30
  "build": "tsup",
32
31
  "build:watch": "tsup --watch",
33
32
  "dev": "tsup --watch",
34
33
  "prepare": "husky",
34
+ "test:e2e:first-install": "bash scripts/e2e-first-install.sh",
35
+ "test:e2e:user-first-install": "bash scripts/e2e-user-first-install.sh",
35
36
  "test": "vitest run",
37
+ "test:drift": "RAPIDKIT_DRIFT_GUARD=1 vitest run src/__tests__/drift-guard.test.ts",
36
38
  "test:watch": "vitest",
37
39
  "test:coverage": "vitest run --coverage",
38
40
  "test:e2e": "vitest run src/__tests__/e2e.test.ts",
41
+ "test:scenarios": "bash scripts/scenario-matrix-local.sh",
42
+ "test:scenarios:full": "RAPIDKIT_SCENARIO_FULL_BOOTSTRAP=1 bash scripts/scenario-matrix-local.sh",
43
+ "test:scenarios:docker": "bash scripts/scenario-matrix.sh",
39
44
  "lint": "eslint src --ext .ts",
40
45
  "lint:fix": "eslint src --ext .ts --fix",
41
46
  "format": "prettier --write \"src/**/*.ts\"",
@@ -46,7 +51,8 @@
46
51
  "security:fix": "npm audit fix",
47
52
  "metrics": "npx tsx scripts/metrics.ts",
48
53
  "bundle-size": "npm run build && du -sh dist/ && ls -lh dist/",
49
- "quality": "npm run validate && npm run security && npm run metrics"
54
+ "quality": "npm run validate && npm run security && npm run metrics",
55
+ "act-matrix": "act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-22.04 -P macos-latest=ghcr.io/catthehacker/ubuntu:act-22.04 -P windows-latest=ghcr.io/catthehacker/ubuntu:act-22.04 --pull=false -j build-test-matrix"
50
56
  },
51
57
  "dependencies": {
52
58
  "chalk": "^5.3.0",
@@ -59,6 +65,7 @@
59
65
  "validate-npm-package-name": "^5.0.1"
60
66
  },
61
67
  "devDependencies": {
68
+ "@eslint/eslintrc": "^3.3.3",
62
69
  "@types/fs-extra": "^11.0.4",
63
70
  "@types/inquirer": "^9.0.7",
64
71
  "@types/node": "^20.14.0",
@@ -68,7 +75,8 @@
68
75
  "@typescript-eslint/parser": "^8.46.2",
69
76
  "@vitest/coverage-v8": "^4.0.15",
70
77
  "@vitest/ui": "^4.0.15",
71
- "eslint": "^8.57.1",
78
+ "c8": "^10.1.3",
79
+ "eslint": "^9.39.2",
72
80
  "husky": "^9.1.7",
73
81
  "lint-staged": "^15.5.2",
74
82
  "prettier": "^3.6.2",
@@ -86,4 +94,4 @@
86
94
  ]
87
95
  },
88
96
  "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
89
- }
97
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rapidkit",
3
- "version": "0.14.1",
3
+ "version": "0.15.1",
4
4
  "type": "module",
5
5
  "description": "Create RapidKit projects with a single command - The official CLI for RapidKit framework",
6
6
  "keywords": [
@@ -24,18 +24,23 @@
24
24
  "rapidkit": "dist/index.js"
25
25
  },
26
26
  "files": [
27
- "dist",
28
- "templates"
27
+ "dist"
29
28
  ],
30
29
  "scripts": {
31
30
  "build": "tsup",
32
31
  "build:watch": "tsup --watch",
33
32
  "dev": "tsup --watch",
34
33
  "prepare": "husky",
34
+ "test:e2e:first-install": "bash scripts/e2e-first-install.sh",
35
+ "test:e2e:user-first-install": "bash scripts/e2e-user-first-install.sh",
35
36
  "test": "vitest run",
37
+ "test:drift": "RAPIDKIT_DRIFT_GUARD=1 vitest run src/__tests__/drift-guard.test.ts",
36
38
  "test:watch": "vitest",
37
39
  "test:coverage": "vitest run --coverage",
38
40
  "test:e2e": "vitest run src/__tests__/e2e.test.ts",
41
+ "test:scenarios": "bash scripts/scenario-matrix-local.sh",
42
+ "test:scenarios:full": "RAPIDKIT_SCENARIO_FULL_BOOTSTRAP=1 bash scripts/scenario-matrix-local.sh",
43
+ "test:scenarios:docker": "bash scripts/scenario-matrix.sh",
39
44
  "lint": "eslint src --ext .ts",
40
45
  "lint:fix": "eslint src --ext .ts --fix",
41
46
  "format": "prettier --write \"src/**/*.ts\"",
@@ -46,7 +51,8 @@
46
51
  "security:fix": "npm audit fix",
47
52
  "metrics": "npx tsx scripts/metrics.ts",
48
53
  "bundle-size": "npm run build && du -sh dist/ && ls -lh dist/",
49
- "quality": "npm run validate && npm run security && npm run metrics"
54
+ "quality": "npm run validate && npm run security && npm run metrics",
55
+ "act-matrix": "act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-22.04 -P macos-latest=ghcr.io/catthehacker/ubuntu:act-22.04 -P windows-latest=ghcr.io/catthehacker/ubuntu:act-22.04 --pull=false -j build-test-matrix"
50
56
  },
51
57
  "dependencies": {
52
58
  "chalk": "^5.3.0",
@@ -59,6 +65,7 @@
59
65
  "validate-npm-package-name": "^5.0.1"
60
66
  },
61
67
  "devDependencies": {
68
+ "@eslint/eslintrc": "^3.3.3",
62
69
  "@types/fs-extra": "^11.0.4",
63
70
  "@types/inquirer": "^9.0.7",
64
71
  "@types/node": "^20.14.0",
@@ -68,7 +75,8 @@
68
75
  "@typescript-eslint/parser": "^8.46.2",
69
76
  "@vitest/coverage-v8": "^4.0.15",
70
77
  "@vitest/ui": "^4.0.15",
71
- "eslint": "^8.57.1",
78
+ "c8": "^10.1.3",
79
+ "eslint": "^9.39.2",
72
80
  "husky": "^9.1.7",
73
81
  "lint-staged": "^15.5.2",
74
82
  "prettier": "^3.6.2",
@@ -86,4 +94,4 @@
86
94
  ]
87
95
  },
88
96
  "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
89
- }
97
+ }
@@ -1,175 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * RapidKit Project Generator
4
- * This script is called by the rapidkit CLI to generate projects
5
- */
6
-
7
- const fs = require('fs').promises;
8
- const path = require('path');
9
- const { execSync } = require('child_process');
10
-
11
- const TEMPLATES_DIR = path.join(__dirname, 'templates');
12
-
13
- async function generateProject(projectPath, template, useDefaults, skipGit, skipInstall) {
14
- const projectName = path.basename(projectPath);
15
- const templateDir = template === 'nestjs' ? 'nestjs-standard' : 'fastapi-standard';
16
- const templatePath = path.join(TEMPLATES_DIR, templateDir);
17
-
18
- // Check template exists
19
- try {
20
- await fs.access(templatePath);
21
- } catch {
22
- console.error('❌ Template not found:', templateDir);
23
- process.exit(1);
24
- }
25
-
26
- // Create project directory
27
- await fs.mkdir(projectPath, { recursive: true });
28
-
29
- // Build context
30
- const context = {
31
- project_name: template === 'nestjs'
32
- ? projectName.replace(/_/g, '-').toLowerCase()
33
- : projectName.replace(/-/g, '_').toLowerCase(),
34
- author: process.env.USER || 'RapidKit User',
35
- description: template === 'nestjs'
36
- ? 'NestJS application generated with RapidKit'
37
- : 'FastAPI service generated with RapidKit',
38
- app_version: '0.1.0',
39
- license: 'MIT',
40
- package_manager: 'npm',
41
- created_at: new Date().toISOString(),
42
- rapidkit_version: require('./config.json').rapidkit_version || '0.12.0',
43
- };
44
-
45
- // Copy and render template files
46
- await copyTemplateDir(templatePath, projectPath, context);
47
-
48
- console.log('✅ Project files created!');
49
-
50
- // Git initialization
51
- if (!skipGit) {
52
- try {
53
- execSync('git init', { cwd: projectPath, stdio: 'pipe' });
54
- execSync('git add .', { cwd: projectPath, stdio: 'pipe' });
55
- const commitMsg = 'Initial commit: ' + (template === 'nestjs' ? 'NestJS' : 'FastAPI') + ' project via RapidKit';
56
- execSync(`git commit -m "${commitMsg}"`, { cwd: projectPath, stdio: 'pipe' });
57
- console.log('✅ Git repository initialized');
58
- } catch (e) {
59
- console.log('⚠️ Could not initialize git');
60
- }
61
- }
62
-
63
- // Install dependencies
64
- if (!skipInstall) {
65
- if (template === 'nestjs') {
66
- console.log('📦 Installing dependencies...');
67
- try {
68
- execSync('npm install', { cwd: projectPath, stdio: 'inherit' });
69
- console.log('✅ Dependencies installed');
70
- } catch {
71
- console.log('⚠️ Could not install dependencies. Run npm install manually.');
72
- }
73
- }
74
- }
75
-
76
- // Success message
77
- const templateName = template === 'nestjs' ? 'NestJS' : 'FastAPI';
78
- console.log('');
79
- console.log('✨ ' + templateName + ' project created successfully!');
80
- console.log('');
81
- console.log('🚀 Get started:');
82
- console.log(' cd ' + projectName);
83
- if (template === 'fastapi') {
84
- console.log(' rapidkit init # poetry install');
85
- console.log(' rapidkit dev # Start dev server');
86
- } else {
87
- if (skipInstall) {
88
- console.log(' rapidkit init # npm install');
89
- }
90
- console.log(' cp .env.example .env');
91
- console.log(' rapidkit dev # Start dev server');
92
- }
93
- console.log('');
94
- }
95
-
96
- function renderTemplate(content, context) {
97
- let result = content;
98
-
99
- for (const [key, value] of Object.entries(context)) {
100
- // Simple variable replacement: {{ key }}
101
- const simpleRegex = new RegExp(`\\{\\{\\s*${key}\\s*\\}\\}`, 'g');
102
- result = result.replace(simpleRegex, String(value));
103
-
104
- // With replace filter: {{ key | replace('a', 'b') }}
105
- const replaceRegex = new RegExp(
106
- `\\{\\{\\s*${key}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\}\\}`,
107
- 'g'
108
- );
109
- result = result.replace(replaceRegex, (match, from, to) => {
110
- return String(value).replace(new RegExp(from, 'g'), to);
111
- });
112
-
113
- // With lower filter: {{ key | lower }}
114
- const lowerRegex = new RegExp(`\\{\\{\\s*${key}\\s*\\|\\s*lower\\s*\\}\\}`, 'g');
115
- result = result.replace(lowerRegex, String(value).toLowerCase());
116
-
117
- // Combined: {{ key | replace('a', 'b') | lower }}
118
- const combinedRegex = new RegExp(
119
- `\\{\\{\\s*${key}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\|\\s*lower\\s*\\}\\}`,
120
- 'g'
121
- );
122
- result = result.replace(combinedRegex, (match, from, to) => {
123
- return String(value).replace(new RegExp(from, 'g'), to).toLowerCase();
124
- });
125
- }
126
-
127
- return result;
128
- }
129
-
130
- async function copyTemplateDir(src, dest, context) {
131
- const entries = await fs.readdir(src, { withFileTypes: true });
132
-
133
- for (const entry of entries) {
134
- const srcPath = path.join(src, entry.name);
135
- const destName = entry.name.replace(/\.j2$/, '');
136
- const destPath = path.join(dest, destName);
137
-
138
- if (entry.isDirectory()) {
139
- await fs.mkdir(destPath, { recursive: true });
140
- await copyTemplateDir(srcPath, destPath, context);
141
- } else {
142
- let content = await fs.readFile(srcPath, 'utf-8');
143
-
144
- // Render template if it's a .j2 file
145
- if (entry.name.endsWith('.j2')) {
146
- content = renderTemplate(content, context);
147
- }
148
-
149
- await fs.writeFile(destPath, content);
150
-
151
- // Make scripts executable
152
- if (destName === 'rapidkit' || (destName.endsWith('.py') && destPath.includes('.rapidkit'))) {
153
- await fs.chmod(destPath, 0o755);
154
- }
155
- }
156
- }
157
- }
158
-
159
- // Main
160
- const args = process.argv.slice(2);
161
- const projectPath = args[0];
162
- const template = args[1] || 'fastapi';
163
- const useDefaults = args.includes('--yes');
164
- const skipGit = args.includes('--skip-git');
165
- const skipInstall = args.includes('--skip-install');
166
-
167
- if (!projectPath) {
168
- console.error('Usage: node generator.js <project-path> <template> [--yes] [--skip-git] [--skip-install]');
169
- process.exit(1);
170
- }
171
-
172
- generateProject(projectPath, template, useDefaults, skipGit, skipInstall).catch(err => {
173
- console.error('Error:', err);
174
- process.exit(1);
175
- });
@@ -1 +0,0 @@
1
- # RapidKit local CLI module
@@ -1,24 +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 test - Run tests"
23
- echo " rapidkit --help - Show all commands"
24
- echo ""
@@ -1,289 +0,0 @@
1
- #!/usr/bin/env python3
2
- """RapidKit CLI wrapper (npm demo template)
3
-
4
- This file provides local project commands for demo projects generated
5
- via npx rapidkit --demo. It mimics the behavior of the full RapidKit
6
- engine for dev, start, test, lint, and format commands.
7
- """
8
-
9
- import subprocess
10
- import shutil
11
- import sys
12
- from pathlib import Path
13
- import socket
14
- from typing import Any
15
-
16
-
17
- def _print_banner(emoji: str, message: str) -> None:
18
- print(f"{emoji} {message}")
19
-
20
-
21
- def _run(*cmd: Any, cwd: Path | str | None = None, env: dict | None = None) -> int:
22
- try:
23
- run_env = None
24
- if env is not None:
25
- import os as _os
26
- run_env = _os.environ.copy()
27
- run_env.update(env)
28
-
29
- proc = subprocess.run([str(c) for c in cmd], cwd=str(cwd) if cwd else None, env=run_env)
30
- return proc.returncode
31
- except KeyboardInterrupt:
32
- print("\n🛑 Command interrupted by user")
33
- return 130
34
- except Exception as exc:
35
- print(f"❌ Error running command: {exc}")
36
- return 1
37
-
38
-
39
- def _project_type(root: Path) -> str:
40
- if (root / "pyproject.toml").exists():
41
- return "python"
42
- if (root / "package.json").exists():
43
- return "node"
44
- return "unknown"
45
-
46
-
47
- def _python_module(module: str, *module_args: str) -> int:
48
- return _run(sys.executable, "-m", module, *module_args)
49
-
50
-
51
- def _python_code_targets(root: Path) -> list[str]:
52
- targets: list[str] = []
53
- for name in ("src", "tests"):
54
- if (root / name).exists():
55
- targets.append(name)
56
- return targets or ["src"]
57
-
58
-
59
- def _get_poetry_venv() -> Path | None:
60
- """Get Poetry virtualenv path if it exists"""
61
- try:
62
- result = subprocess.run(
63
- ["poetry", "env", "info", "--path"],
64
- capture_output=True,
65
- text=True,
66
- check=False
67
- )
68
- if result.returncode == 0 and result.stdout.strip():
69
- venv_path = Path(result.stdout.strip())
70
- if venv_path.exists():
71
- return venv_path
72
- except Exception:
73
- pass
74
- return None
75
-
76
-
77
- def _venv_has_uvicorn(venv_path: Path) -> bool:
78
- if (venv_path / "bin" / "uvicorn").exists():
79
- return True
80
- for p in venv_path.rglob("site-packages/*"):
81
- name = p.name.lower()
82
- if "uvicorn" in name or "fastapi" in name:
83
- return True
84
- return False
85
-
86
-
87
- def dev(port: int = 8000, host: str = "0.0.0.0", allow_global_runtime: bool = False) -> None:
88
- """Start development server with reload"""
89
- _print_banner("🚀", "Starting development server with hot reload...")
90
- root = Path.cwd()
91
- ptype = _project_type(root)
92
-
93
- if ptype == "python":
94
- venv_dir = root / ".venv"
95
- _print_banner("📁", f"Working directory: {root}")
96
- _print_banner("🌐", f"Server will be available at: http://{host}:{port}")
97
-
98
- # Check for .venv or Poetry virtualenv
99
- if not venv_dir.exists():
100
- poetry_venv = _get_poetry_venv()
101
- if poetry_venv:
102
- venv_dir = poetry_venv
103
- _print_banner("🐍", f"Using Poetry virtualenv: {venv_dir}")
104
-
105
- if venv_dir.exists():
106
- if not _venv_has_uvicorn(venv_dir):
107
- print("❌ Project virtualenv was found but uvicorn/fastapi doesn't appear installed.")
108
- print("💡 Run 'rapidkit init' to install dependencies.")
109
- sys.exit(1)
110
- else:
111
- if not allow_global_runtime:
112
- print("❌ Project environment not bootstrapped (no .venv found).")
113
- print("")
114
- print("💡 Initialize and install dependencies with:")
115
- print("")
116
- print(" rapidkit init")
117
- print("")
118
- print("If you intentionally want to use the system Python, run:")
119
- print("")
120
- print(" rapidkit dev --allow-global-runtime")
121
- print("")
122
- sys.exit(1)
123
-
124
- if shutil.which("uvicorn") is None:
125
- print("❌ No uvicorn executable found on PATH and no .venv present.")
126
- print("")
127
- print("💡 Install dependencies with: rapidkit init")
128
- print("")
129
- sys.exit(1)
130
- print("⚠️ Running with system/global Python runtime.")
131
-
132
- rc = _run(sys.executable, "-m", "uvicorn", "src.main:app", "--reload", "--reload-dir", "src", "--host", host, "--port", str(port))
133
- if rc != 0:
134
- sys.exit(rc)
135
- else:
136
- print("❌ Unknown project type. Ensure pyproject.toml exists.")
137
- sys.exit(1)
138
-
139
-
140
- def init() -> None:
141
- """Bootstrap project: install dependencies"""
142
- _print_banner("🚀", "Bootstrapping project (installing dependencies)")
143
- root = Path.cwd()
144
- ptype = _project_type(root)
145
-
146
- if ptype == "python":
147
- if shutil.which("poetry"):
148
- rc = _run("poetry", "install")
149
- if rc != 0:
150
- print("❌ Failed to install dependencies via poetry.")
151
- sys.exit(rc)
152
- print("✅ Dependencies installed successfully!")
153
- else:
154
- print("❌ Poetry not found. Install it with: pip install poetry")
155
- sys.exit(1)
156
- else:
157
- print("❌ Unknown project type. Ensure pyproject.toml exists.")
158
- sys.exit(1)
159
-
160
-
161
- def start(port: int = 8000, host: str = "0.0.0.0", allow_global_runtime: bool = False) -> None:
162
- """Start production server"""
163
- _print_banner("⚡", "Starting production server...")
164
- root = Path.cwd()
165
- ptype = _project_type(root)
166
-
167
- if ptype == "python":
168
- venv_dir = root / ".venv"
169
-
170
- # Check for .venv or Poetry virtualenv
171
- if not venv_dir.exists():
172
- poetry_venv = _get_poetry_venv()
173
- if poetry_venv:
174
- venv_dir = poetry_venv
175
-
176
- if venv_dir.exists():
177
- if not _venv_has_uvicorn(venv_dir):
178
- print("❌ Project virtualenv was found but uvicorn/fastapi doesn't appear installed.")
179
- print("💡 Run 'poetry install' to install dependencies.")
180
- sys.exit(1)
181
- else:
182
- if not allow_global_runtime:
183
- print("❌ Project environment not bootstrapped (no .venv found).")
184
- print("💡 Run 'poetry install' to install dependencies.")
185
- sys.exit(1)
186
-
187
- rc = _run(sys.executable, "-m", "uvicorn", "src.main:app", "--host", host, "--port", str(port))
188
- if rc != 0:
189
- sys.exit(rc)
190
- else:
191
- print("❌ Unknown project type.")
192
- sys.exit(1)
193
-
194
-
195
- def build() -> None:
196
- """Build project"""
197
- _print_banner("📦", "Building project")
198
- rc = _python_module("build")
199
- if rc != 0:
200
- sys.exit(rc)
201
-
202
-
203
- def test() -> None:
204
- """Run tests"""
205
- _print_banner("🧪", "Running tests")
206
- rc = _python_module("pytest", "-q")
207
- if rc != 0:
208
- sys.exit(rc)
209
-
210
-
211
- def lint() -> None:
212
- """Run linting"""
213
- _print_banner("🔧", "Running lint")
214
- root = Path.cwd()
215
- targets = _python_code_targets(root)
216
- rc = _python_module("ruff", "check", *targets)
217
- if rc == 0:
218
- rc = _python_module("black", "--check", *targets)
219
- if rc != 0:
220
- sys.exit(rc)
221
-
222
-
223
- def format_code() -> None:
224
- """Format code"""
225
- _print_banner("✨", "Formatting")
226
- root = Path.cwd()
227
- targets = _python_code_targets(root)
228
- rc = _python_module("ruff", "check", *targets, "--fix")
229
- if rc == 0:
230
- rc = _python_module("black", *targets)
231
- if rc != 0:
232
- sys.exit(rc)
233
-
234
-
235
- def help_cmd() -> None:
236
- """Show help"""
237
- _print_banner("📚", "Project Commands")
238
- print("Usage: rapidkit <command> [args...]\n")
239
- print(" init 📦 Initialize project (install deps)")
240
- print(" dev 🚀 Start development server")
241
- print(" start ⚡ Start production server")
242
- print(" build 📦 Build for production")
243
- print(" test 🧪 Run tests")
244
- print(" lint 🔧 Lint code")
245
- print(" format ✨ Format code")
246
- print(" help 📚 Show help")
247
- print("")
248
- print("💡 Note: This is a demo project. For full RapidKit features:")
249
- print(" pipx install rapidkit")
250
-
251
-
252
- def main():
253
- if len(sys.argv) < 2 or sys.argv[1] in ("-h", "--help", "help"):
254
- help_cmd()
255
- return
256
-
257
- command = sys.argv[1]
258
- args = sys.argv[2:]
259
-
260
- commands = {
261
- "init": init,
262
- "dev": dev,
263
- "start": start,
264
- "build": build,
265
- "test": test,
266
- "lint": lint,
267
- "format": format_code,
268
- "help": help_cmd,
269
- }
270
-
271
- if command not in commands:
272
- print(f"❌ Unknown command: {command}")
273
- help_cmd()
274
- sys.exit(1)
275
-
276
- if command in ("dev", "start"):
277
- import argparse as _arg
278
- _parser = _arg.ArgumentParser(prog=f"rapidkit {command}")
279
- _parser.add_argument("-p", "--port", dest="port", type=int, default=8000)
280
- _parser.add_argument("--host", dest="host", default="0.0.0.0")
281
- _parser.add_argument("--allow-global-runtime", action="store_true", dest="allow_global_runtime")
282
- _ns, _extra = _parser.parse_known_args(args)
283
- commands[command](port=_ns.port, host=_ns.host, allow_global_runtime=_ns.allow_global_runtime)
284
- else:
285
- commands[command]()
286
-
287
-
288
- if __name__ == "__main__":
289
- main()
@@ -1,3 +0,0 @@
1
- {
2
- "engine": "npm"
3
- }
@@ -1,7 +0,0 @@
1
- {
2
- "kit_name": "fastapi.standard",
3
- "profile": "fastapi/standard",
4
- "project_name": "{{ project_name }}",
5
- "created_at": "{{ created_at }}",
6
- "rapidkit_version": "npm-{{ rapidkit_version }}"
7
- }