rapidkit 0.20.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +423 -1509
- package/dist/chunk-7LU4Z66R.js +4 -0
- package/dist/chunk-D2ZRDZOE.js +17 -0
- package/dist/chunk-RV6HBTFC.js +2 -0
- package/dist/index.js +194 -800
- package/dist/package.json +8 -2
- package/dist/pythonRapidkitExec-GFCAVUOY.js +1 -0
- package/dist/workspace-LZZGJRGV.js +587 -0
- package/dist/workspace-marker-IOPQ42A7.js +1 -0
- package/package.json +8 -2
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rapidkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Create RapidKit projects with a single command - The official CLI for RapidKit framework",
|
|
6
6
|
"keywords": [
|
|
@@ -58,7 +58,10 @@
|
|
|
58
58
|
"sync:contracts": "node scripts/sync-contracts.mjs",
|
|
59
59
|
"check:contracts": "node scripts/sync-contracts.mjs --check",
|
|
60
60
|
"bundle-size": "npm run build && du -sh dist/ && ls -lh dist/",
|
|
61
|
-
"
|
|
61
|
+
"analyze": "npm run build && npx vite-bundle-visualizer dist/index.js --open",
|
|
62
|
+
"size-check": "npm run build && size-limit",
|
|
63
|
+
"bench": "npx tsx scripts/benchmarks.ts",
|
|
64
|
+
"quality": "npm run typecheck && npm run lint && npm run format:check && npm test && npm run size-check",
|
|
62
65
|
"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"
|
|
63
66
|
},
|
|
64
67
|
"dependencies": {
|
|
@@ -75,6 +78,7 @@
|
|
|
75
78
|
},
|
|
76
79
|
"devDependencies": {
|
|
77
80
|
"@eslint/eslintrc": "^3.3.3",
|
|
81
|
+
"@size-limit/preset-big-lib": "^12.0.0",
|
|
78
82
|
"@types/cli-progress": "^3.11.6",
|
|
79
83
|
"@types/fs-extra": "^11.0.4",
|
|
80
84
|
"@types/inquirer": "^9.0.7",
|
|
@@ -90,8 +94,10 @@
|
|
|
90
94
|
"husky": "^9.1.7",
|
|
91
95
|
"lint-staged": "^15.5.2",
|
|
92
96
|
"prettier": "^3.6.2",
|
|
97
|
+
"size-limit": "^12.0.0",
|
|
93
98
|
"tsup": "^8.5.0",
|
|
94
99
|
"typescript": "^5.5.0",
|
|
100
|
+
"vite-bundle-visualizer": "^1.2.1",
|
|
95
101
|
"vitest": "^4.0.15"
|
|
96
102
|
},
|
|
97
103
|
"engines": {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{i as __test__,b as checkRapidkitCoreAvailable,g as getCachedCoreTopLevelCommands,f as getCoreTopLevelCommands,h as getModulesCatalog,c as resolveRapidkitPython,d as runCoreRapidkit,e as runCoreRapidkitCapture}from'./chunk-D2ZRDZOE.js';
|
|
@@ -0,0 +1,587 @@
|
|
|
1
|
+
import {c}from'./chunk-7LU4Z66R.js';import {promises}from'fs';import i from'path';import e from'chalk';import y from'ora';import {execa}from'execa';import k from'os';async function C(t,r){try{let o=process.env.XDG_CONFIG_HOME||process.env.APPDATA||i.join(k.homedir(),".config"),a=process.platform==="win32"?i.join(o,"rapidkit"):i.join(k.homedir(),".rapidkit"),n=i.join(a,"workspaces.json");await promises.mkdir(a,{recursive:true});let s={workspaces:[]};try{let c=await promises.readFile(n,"utf8"),m=JSON.parse(c);m&&Array.isArray(m.workspaces)&&(s=m);}catch{}s.workspaces.some(c=>c.path===t)||(s.workspaces.push({name:r,path:t,mode:"full",projects:[]}),await promises.writeFile(n,JSON.stringify(s,null,2)));}catch{console.warn(e.gray("Note: Could not register workspace in shared registry"));}}async function T(t,r=false){try{let o=process.env.XDG_CONFIG_HOME||process.env.APPDATA||i.join(k.homedir(),".config"),a=process.platform==="win32"?i.join(o,"rapidkit"):i.join(k.homedir(),".rapidkit"),n=i.join(a,"workspaces.json"),s={workspaces:[]};try{let l=await promises.readFile(n,"utf8"),h=JSON.parse(l);h&&Array.isArray(h.workspaces)&&(s=h);}catch{r||console.log("\u26A0\uFE0F Workspace registry not found");return}let d=s.workspaces.find(l=>l.path===t);if(!d){r||console.log("\u26A0\uFE0F Workspace not registered in registry");return}Array.isArray(d.projects)||(d.projects=[]);let c=await promises.readdir(t,{withFileTypes:true}),m=0,g=0;for(let l of c)if(l.isDirectory()&&!l.name.startsWith(".")){let h=i.join(t,l.name),j=i.join(h,".rapidkit","context.json"),w=i.join(h,".rapidkit","project.json");try{let $=false;try{await promises.access(j),$=true;}catch{await promises.access(w),$=true;}$&&(d.projects.some(_=>_.path===h||_.name===l.name)?g++:(d.projects.push({name:l.name,path:h}),m++,r||console.log(`\u2714 Added: ${l.name}`)));}catch{}}m>0?(await promises.writeFile(n,JSON.stringify(s,null,2)),r||console.log(`
|
|
2
|
+
\u2705 Synced ${m} project(s) to registry`)):r||console.log(`
|
|
3
|
+
\u2705 All projects already registered (${g} found)`);}catch(o){r||console.error("\u274C Failed to sync projects:",o.message);}}async function G(t,r,o){try{let a=process.env.XDG_CONFIG_HOME||process.env.APPDATA||i.join(k.homedir(),".config"),n=process.platform==="win32"?i.join(a,"rapidkit"):i.join(k.homedir(),".rapidkit"),s=i.join(n,"workspaces.json");console.log(`[REGISTRY DEBUG] Registry file: ${s}`);let d={workspaces:[]};try{let g=await promises.readFile(s,"utf8"),l=JSON.parse(g);l&&Array.isArray(l.workspaces)&&(d=l),console.log(`[REGISTRY DEBUG] Registry loaded, ${d.workspaces.length} workspaces`);}catch{console.log("[REGISTRY DEBUG] Registry doesn't exist, returning");return}let c=d.workspaces.find(g=>g.path===t);if(!c){console.log("[REGISTRY DEBUG] Workspace not found in registry, returning");return}console.log(`[REGISTRY DEBUG] Workspace found: ${c.name}`),Array.isArray(c.projects)||(c.projects=[]),c.projects.some(g=>g.path===o||g.name===r)?console.log("[REGISTRY DEBUG] Project already exists in registry"):(console.log("[REGISTRY DEBUG] Adding project to registry"),c.projects.push({name:r,path:o}),await promises.writeFile(s,JSON.stringify(d,null,2)),console.log("[REGISTRY DEBUG] Registry updated successfully"));}catch(a){console.log(`[REGISTRY DEBUG] Error: ${a}`);}}async function U(t,r){let o=y("Creating RapidKit workspace...").start();try{await promises.mkdir(t,{recursive:true}),await promises.mkdir(i.join(t,".rapidkit"),{recursive:true});let a={workspace_name:r.name,author:r.author,rapidkit_version:c(),created_at:new Date().toISOString(),type:"workspace"};await promises.writeFile(i.join(t,".rapidkit","config.json"),JSON.stringify(a,null,2));let n=x();await promises.writeFile(i.join(t,"rapidkit"),n),await promises.chmod(i.join(t,"rapidkit"),493);let s=E(r.name);if(await promises.writeFile(i.join(t,"README.md"),s),await promises.writeFile(i.join(t,".gitignore"),`# RapidKit workspace
|
|
4
|
+
.env
|
|
5
|
+
.env.*
|
|
6
|
+
!.env.example
|
|
7
|
+
|
|
8
|
+
# OS
|
|
9
|
+
.DS_Store
|
|
10
|
+
Thumbs.db
|
|
11
|
+
|
|
12
|
+
# IDEs
|
|
13
|
+
.vscode/
|
|
14
|
+
.idea/
|
|
15
|
+
|
|
16
|
+
# Logs
|
|
17
|
+
*.log
|
|
18
|
+
`),await promises.writeFile(i.join(t,".rapidkit-workspace"),JSON.stringify({signature:"RAPIDKIT_WORKSPACE",createdBy:"rapidkit-npm",version:c(),createdAt:new Date().toISOString(),name:r.name},null,2)),await N(t),o.succeed("Workspace created!"),!r.skipGit){let c=y("Initializing git repository...").start();try{await execa("git",["init"],{cwd:t}),await execa("git",["add","."],{cwd:t}),await execa("git",["commit","-m","Initial commit: RapidKit workspace"],{cwd:t}),c.succeed("Git repository initialized");}catch{c.warn("Could not initialize git repository");}}await C(t,r.name),console.log(`
|
|
19
|
+
${e.green("\u2728 RapidKit workspace created successfully!")}
|
|
20
|
+
|
|
21
|
+
${e.bold("\u{1F4C2} Workspace structure:")}
|
|
22
|
+
${t}/
|
|
23
|
+
\u251C\u2500\u2500 rapidkit # Local CLI wrapper
|
|
24
|
+
\u251C\u2500\u2500 .rapidkit/ # Workspace configuration
|
|
25
|
+
\u2502 \u251C\u2500\u2500 config.json # Workspace settings
|
|
26
|
+
\u2502 \u2514\u2500\u2500 templates/ # Project templates
|
|
27
|
+
\u2514\u2500\u2500 README.md
|
|
28
|
+
|
|
29
|
+
${e.bold("\u{1F680} Get started:")}
|
|
30
|
+
${e.cyan(`cd ${r.name}`)}
|
|
31
|
+
${e.cyan("npx rapidkit my-api --template fastapi")}
|
|
32
|
+
${e.cyan("cd my-api")}
|
|
33
|
+
${e.cyan("npx rapidkit init")}
|
|
34
|
+
${e.cyan("npx rapidkit dev")}
|
|
35
|
+
|
|
36
|
+
${e.bold("\u{1F4E6} Available templates:")}
|
|
37
|
+
fastapi - FastAPI + Python (default)
|
|
38
|
+
nestjs - NestJS + TypeScript
|
|
39
|
+
|
|
40
|
+
${e.bold("\u{1F4DA} Commands:")}
|
|
41
|
+
npx rapidkit <name> --template <type> Create a new project
|
|
42
|
+
npx rapidkit init Install dependencies
|
|
43
|
+
npx rapidkit dev Start dev server
|
|
44
|
+
npx rapidkit help Show all commands
|
|
45
|
+
|
|
46
|
+
${e.gray("Alternative: ./rapidkit dev, make dev")}
|
|
47
|
+
${e.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
|
|
48
|
+
`);}catch(a){throw o.fail("Failed to create workspace"),a}}function x(){return `#!/usr/bin/env bash
|
|
49
|
+
#
|
|
50
|
+
# RapidKit CLI - Local workspace commands
|
|
51
|
+
# This script provides rapidkit commands within the workspace
|
|
52
|
+
#
|
|
53
|
+
|
|
54
|
+
set -e
|
|
55
|
+
|
|
56
|
+
# Find workspace root (where this script lives)
|
|
57
|
+
SCRIPT_DIR="$(cd "$(dirname "\${BASH_SOURCE[0]}")" && pwd)"
|
|
58
|
+
|
|
59
|
+
# Check if we're in a project directory (has .rapidkit/project.json)
|
|
60
|
+
find_project_root() {
|
|
61
|
+
local dir="$PWD"
|
|
62
|
+
while [[ "$dir" != "/" ]]; do
|
|
63
|
+
if [[ -f "$dir/.rapidkit/project.json" ]]; then
|
|
64
|
+
echo "$dir"
|
|
65
|
+
return 0
|
|
66
|
+
fi
|
|
67
|
+
dir="$(dirname "$dir")"
|
|
68
|
+
done
|
|
69
|
+
return 1
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
# Check if we're in a workspace (has .rapidkit/config.json with type=workspace)
|
|
73
|
+
find_workspace_root() {
|
|
74
|
+
local dir="$PWD"
|
|
75
|
+
while [[ "$dir" != "/" ]]; do
|
|
76
|
+
if [[ -f "$dir/.rapidkit/config.json" ]]; then
|
|
77
|
+
if grep -q '"type": "workspace"' "$dir/.rapidkit/config.json" 2>/dev/null; then
|
|
78
|
+
echo "$dir"
|
|
79
|
+
return 0
|
|
80
|
+
fi
|
|
81
|
+
fi
|
|
82
|
+
dir="$(dirname "$dir")"
|
|
83
|
+
done
|
|
84
|
+
return 1
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
# Colors
|
|
88
|
+
RED='\\033[0;31m'
|
|
89
|
+
GREEN='\\033[0;32m'
|
|
90
|
+
YELLOW='\\033[0;33m'
|
|
91
|
+
BLUE='\\033[0;34m'
|
|
92
|
+
CYAN='\\033[0;36m'
|
|
93
|
+
NC='\\033[0m' # No Color
|
|
94
|
+
BOLD='\\033[1m'
|
|
95
|
+
|
|
96
|
+
print_banner() {
|
|
97
|
+
echo -e "\${BLUE}\${BOLD}\u{1F680} RapidKit CLI\${NC}"
|
|
98
|
+
echo ""
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
print_help() {
|
|
102
|
+
print_banner
|
|
103
|
+
echo -e "\${BOLD}Usage:\${NC} rapidkit <command> [options]"
|
|
104
|
+
echo ""
|
|
105
|
+
echo -e "\${BOLD}\u{1F3D7}\uFE0F Workspace Commands:\${NC}"
|
|
106
|
+
echo " create <name> Create a new project from template"
|
|
107
|
+
echo " create --help Show create command options"
|
|
108
|
+
echo ""
|
|
109
|
+
echo -e "\${BOLD}\u{1F680} Project Commands\${NC} (run inside a project):"
|
|
110
|
+
echo " init Install project dependencies"
|
|
111
|
+
echo " dev Start development server"
|
|
112
|
+
echo " start Start production server"
|
|
113
|
+
echo " build Build for production"
|
|
114
|
+
echo " test Run tests"
|
|
115
|
+
echo " lint Run linting"
|
|
116
|
+
echo " format Format code"
|
|
117
|
+
echo ""
|
|
118
|
+
echo -e "\${BOLD}\u{1F4DA} Other Commands:\${NC}"
|
|
119
|
+
echo " help Show this help message"
|
|
120
|
+
echo " version Show version"
|
|
121
|
+
echo ""
|
|
122
|
+
echo -e "\${BOLD}Examples:\${NC}"
|
|
123
|
+
echo -e " \${CYAN}rapidkit create my-api --template fastapi\${NC}"
|
|
124
|
+
echo -e " \${CYAN}rapidkit create my-app --template nestjs --yes\${NC}"
|
|
125
|
+
echo -e " \${CYAN}cd my-api && rapidkit dev\${NC}"
|
|
126
|
+
echo ""
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
print_create_help() {
|
|
130
|
+
print_banner
|
|
131
|
+
echo -e "\${BOLD}Usage:\${NC} rapidkit create <project-name> [options]"
|
|
132
|
+
echo ""
|
|
133
|
+
echo -e "\${BOLD}Options:\${NC}"
|
|
134
|
+
echo " -t, --template <name> Template to use (fastapi, nestjs)"
|
|
135
|
+
echo " -y, --yes Skip prompts, use defaults"
|
|
136
|
+
echo " --skip-git Skip git initialization"
|
|
137
|
+
echo " --skip-install Skip dependency installation"
|
|
138
|
+
echo ""
|
|
139
|
+
echo -e "\${BOLD}Templates:\${NC}"
|
|
140
|
+
echo " fastapi FastAPI + Python (default)"
|
|
141
|
+
echo " nestjs NestJS + TypeScript"
|
|
142
|
+
echo ""
|
|
143
|
+
echo -e "\${BOLD}Examples:\${NC}"
|
|
144
|
+
echo -e " \${CYAN}rapidkit create my-api\${NC}"
|
|
145
|
+
echo -e " \${CYAN}rapidkit create my-api --template fastapi\${NC}"
|
|
146
|
+
echo -e " \${CYAN}rapidkit create my-app --template nestjs --yes\${NC}"
|
|
147
|
+
echo ""
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
# Create project command
|
|
151
|
+
cmd_create() {
|
|
152
|
+
local project_name=""
|
|
153
|
+
local template="fastapi"
|
|
154
|
+
local yes_flag=""
|
|
155
|
+
local skip_git=""
|
|
156
|
+
local skip_install=""
|
|
157
|
+
|
|
158
|
+
# Parse arguments
|
|
159
|
+
while [[ $# -gt 0 ]]; do
|
|
160
|
+
case "$1" in
|
|
161
|
+
-h|--help)
|
|
162
|
+
print_create_help
|
|
163
|
+
exit 0
|
|
164
|
+
;;
|
|
165
|
+
-t|--template)
|
|
166
|
+
template="$2"
|
|
167
|
+
shift 2
|
|
168
|
+
;;
|
|
169
|
+
-y|--yes)
|
|
170
|
+
yes_flag="--yes"
|
|
171
|
+
shift
|
|
172
|
+
;;
|
|
173
|
+
--skip-git)
|
|
174
|
+
skip_git="--skip-git"
|
|
175
|
+
shift
|
|
176
|
+
;;
|
|
177
|
+
--skip-install)
|
|
178
|
+
skip_install="--skip-install"
|
|
179
|
+
shift
|
|
180
|
+
;;
|
|
181
|
+
-*)
|
|
182
|
+
echo -e "\${RED}\u274C Unknown option: $1\${NC}"
|
|
183
|
+
print_create_help
|
|
184
|
+
exit 1
|
|
185
|
+
;;
|
|
186
|
+
*)
|
|
187
|
+
if [[ -z "$project_name" ]]; then
|
|
188
|
+
project_name="$1"
|
|
189
|
+
fi
|
|
190
|
+
shift
|
|
191
|
+
;;
|
|
192
|
+
esac
|
|
193
|
+
done
|
|
194
|
+
|
|
195
|
+
# Validate template
|
|
196
|
+
if [[ "$template" != "fastapi" && "$template" != "nestjs" ]]; then
|
|
197
|
+
echo -e "\${RED}\u274C Invalid template: $template\${NC}"
|
|
198
|
+
echo -e "Available templates: fastapi, nestjs"
|
|
199
|
+
exit 1
|
|
200
|
+
fi
|
|
201
|
+
|
|
202
|
+
# If no project name, prompt for it or show help
|
|
203
|
+
if [[ -z "$project_name" ]]; then
|
|
204
|
+
if [[ -n "$yes_flag" ]]; then
|
|
205
|
+
project_name="my-\${template}-project"
|
|
206
|
+
else
|
|
207
|
+
echo -e "\${YELLOW}Project name required\${NC}"
|
|
208
|
+
echo ""
|
|
209
|
+
print_create_help
|
|
210
|
+
exit 1
|
|
211
|
+
fi
|
|
212
|
+
fi
|
|
213
|
+
|
|
214
|
+
# Find workspace root
|
|
215
|
+
local workspace_root
|
|
216
|
+
workspace_root=$(find_workspace_root) || {
|
|
217
|
+
echo -e "\${RED}\u274C Not in a RapidKit workspace\${NC}"
|
|
218
|
+
echo -e "Run this command from within a RapidKit workspace."
|
|
219
|
+
exit 1
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
local project_path="$PWD/$project_name"
|
|
223
|
+
|
|
224
|
+
# Check if project already exists
|
|
225
|
+
if [[ -d "$project_path" ]]; then
|
|
226
|
+
echo -e "\${RED}\u274C Directory '$project_name' already exists\${NC}"
|
|
227
|
+
exit 1
|
|
228
|
+
fi
|
|
229
|
+
|
|
230
|
+
echo -e "\${BLUE}\${BOLD}\u{1F680} Creating $template project: $project_name\${NC}"
|
|
231
|
+
echo ""
|
|
232
|
+
|
|
233
|
+
# Use Node.js generator script
|
|
234
|
+
local generator_script="$workspace_root/.rapidkit/generator.js"
|
|
235
|
+
|
|
236
|
+
if [[ -f "$generator_script" ]]; then
|
|
237
|
+
node "$generator_script" "$project_path" "$template" "$yes_flag" "$skip_git" "$skip_install"
|
|
238
|
+
else
|
|
239
|
+
echo -e "\${RED}\u274C Generator script not found\${NC}"
|
|
240
|
+
exit 1
|
|
241
|
+
fi
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
# Project commands (dev, build, test, etc.)
|
|
245
|
+
cmd_project() {
|
|
246
|
+
local cmd="$1"
|
|
247
|
+
shift
|
|
248
|
+
|
|
249
|
+
# Find project root
|
|
250
|
+
local project_root
|
|
251
|
+
project_root=$(find_project_root) || {
|
|
252
|
+
echo -e "\${RED}\u274C Not in a RapidKit project\${NC}"
|
|
253
|
+
echo -e "Run this command from within a project directory."
|
|
254
|
+
echo -e "Use \${CYAN}rapidkit create <name>\${NC} to create a new project."
|
|
255
|
+
exit 1
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
# Read project type from project.json
|
|
259
|
+
local project_json="$project_root/.rapidkit/project.json"
|
|
260
|
+
local kit_name
|
|
261
|
+
kit_name=$(grep -o '"kit_name": *"[^"]*"' "$project_json" | cut -d'"' -f4)
|
|
262
|
+
|
|
263
|
+
cd "$project_root"
|
|
264
|
+
|
|
265
|
+
case "$kit_name" in
|
|
266
|
+
fastapi.standard|fastapi.ddd|python)
|
|
267
|
+
# Python/FastAPI project
|
|
268
|
+
case "$cmd" in
|
|
269
|
+
init)
|
|
270
|
+
echo -e "\${BLUE}\u{1F4E6} Installing dependencies...\${NC}"
|
|
271
|
+
|
|
272
|
+
# Source activate script first to ensure Poetry is available
|
|
273
|
+
if [[ -f ".rapidkit/activate" ]]; then
|
|
274
|
+
source .rapidkit/activate
|
|
275
|
+
fi
|
|
276
|
+
|
|
277
|
+
poetry install
|
|
278
|
+
echo -e "\${GREEN}\u2705 Dependencies installed!\${NC}"
|
|
279
|
+
;;
|
|
280
|
+
dev)
|
|
281
|
+
echo -e "\${BLUE}\u{1F680} Starting development server...\${NC}"
|
|
282
|
+
poetry run dev "$@"
|
|
283
|
+
;;
|
|
284
|
+
start)
|
|
285
|
+
echo -e "\${BLUE}\u26A1 Starting production server...\${NC}"
|
|
286
|
+
poetry run start "$@"
|
|
287
|
+
;;
|
|
288
|
+
build)
|
|
289
|
+
echo -e "\${BLUE}\u{1F4E6} Building project...\${NC}"
|
|
290
|
+
poetry run build
|
|
291
|
+
;;
|
|
292
|
+
test)
|
|
293
|
+
echo -e "\${BLUE}\u{1F9EA} Running tests...\${NC}"
|
|
294
|
+
poetry run test
|
|
295
|
+
;;
|
|
296
|
+
lint)
|
|
297
|
+
echo -e "\${BLUE}\u{1F527} Running linter...\${NC}"
|
|
298
|
+
poetry run lint
|
|
299
|
+
;;
|
|
300
|
+
format)
|
|
301
|
+
echo -e "\${BLUE}\u2728 Formatting code...\${NC}"
|
|
302
|
+
poetry run format
|
|
303
|
+
;;
|
|
304
|
+
*)
|
|
305
|
+
echo -e "\${RED}\u274C Unknown command: $cmd\${NC}"
|
|
306
|
+
exit 1
|
|
307
|
+
;;
|
|
308
|
+
esac
|
|
309
|
+
;;
|
|
310
|
+
nestjs.standard|node)
|
|
311
|
+
# Node/NestJS project
|
|
312
|
+
local pm="npm"
|
|
313
|
+
if command -v pnpm &>/dev/null && [[ -f "pnpm-lock.yaml" ]]; then
|
|
314
|
+
pm="pnpm"
|
|
315
|
+
elif command -v yarn &>/dev/null && [[ -f "yarn.lock" ]]; then
|
|
316
|
+
pm="yarn"
|
|
317
|
+
fi
|
|
318
|
+
|
|
319
|
+
case "$cmd" in
|
|
320
|
+
init)
|
|
321
|
+
echo -e "\${BLUE}\u{1F4E6} Installing dependencies...\${NC}"
|
|
322
|
+
|
|
323
|
+
# Source activate script first to ensure environment is ready
|
|
324
|
+
if [[ -f ".rapidkit/activate" ]]; then
|
|
325
|
+
source .rapidkit/activate
|
|
326
|
+
fi
|
|
327
|
+
|
|
328
|
+
$pm install
|
|
329
|
+
echo -e "\${GREEN}\u2705 Dependencies installed!\${NC}"
|
|
330
|
+
;;
|
|
331
|
+
dev)
|
|
332
|
+
echo -e "\${BLUE}\u{1F680} Starting development server...\${NC}"
|
|
333
|
+
$pm run start:dev
|
|
334
|
+
;;
|
|
335
|
+
start)
|
|
336
|
+
echo -e "\${BLUE}\u26A1 Starting production server...\${NC}"
|
|
337
|
+
$pm run start:prod
|
|
338
|
+
;;
|
|
339
|
+
build)
|
|
340
|
+
echo -e "\${BLUE}\u{1F4E6} Building project...\${NC}"
|
|
341
|
+
$pm run build
|
|
342
|
+
;;
|
|
343
|
+
test)
|
|
344
|
+
echo -e "\${BLUE}\u{1F9EA} Running tests...\${NC}"
|
|
345
|
+
$pm test
|
|
346
|
+
;;
|
|
347
|
+
lint)
|
|
348
|
+
echo -e "\${BLUE}\u{1F527} Running linter...\${NC}"
|
|
349
|
+
$pm run lint
|
|
350
|
+
;;
|
|
351
|
+
format)
|
|
352
|
+
echo -e "\${BLUE}\u2728 Formatting code...\${NC}"
|
|
353
|
+
$pm run format
|
|
354
|
+
;;
|
|
355
|
+
*)
|
|
356
|
+
echo -e "\${RED}\u274C Unknown command: $cmd\${NC}"
|
|
357
|
+
exit 1
|
|
358
|
+
;;
|
|
359
|
+
esac
|
|
360
|
+
;;
|
|
361
|
+
*)
|
|
362
|
+
echo -e "\${RED}\u274C Unknown project type: $kit_name\${NC}"
|
|
363
|
+
exit 1
|
|
364
|
+
;;
|
|
365
|
+
esac
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
# Main command handler
|
|
369
|
+
main() {
|
|
370
|
+
local cmd="\${1:-help}"
|
|
371
|
+
shift || true
|
|
372
|
+
|
|
373
|
+
case "$cmd" in
|
|
374
|
+
create)
|
|
375
|
+
cmd_create "$@"
|
|
376
|
+
;;
|
|
377
|
+
init|dev|start|build|test|lint|format)
|
|
378
|
+
cmd_project "$cmd" "$@"
|
|
379
|
+
;;
|
|
380
|
+
help|-h|--help)
|
|
381
|
+
print_help
|
|
382
|
+
;;
|
|
383
|
+
version|-v|--version)
|
|
384
|
+
echo "RapidKit CLI (npm workspace) v${c()}"
|
|
385
|
+
;;
|
|
386
|
+
*)
|
|
387
|
+
echo -e "\${RED}\u274C Unknown command: $cmd\${NC}"
|
|
388
|
+
echo ""
|
|
389
|
+
print_help
|
|
390
|
+
exit 1
|
|
391
|
+
;;
|
|
392
|
+
esac
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
main "$@"
|
|
396
|
+
`}function E(t){return `# ${t}
|
|
397
|
+
|
|
398
|
+
RapidKit workspace for building API projects.
|
|
399
|
+
|
|
400
|
+
## Quick Start
|
|
401
|
+
|
|
402
|
+
\`\`\`bash
|
|
403
|
+
# Add rapidkit to PATH (or use ./rapidkit)
|
|
404
|
+
export PATH="$PWD:$PATH"
|
|
405
|
+
|
|
406
|
+
# Create a FastAPI project
|
|
407
|
+
npx rapidkit my-api --template fastapi
|
|
408
|
+
|
|
409
|
+
# Or create a NestJS project
|
|
410
|
+
npx rapidkit my-app --template nestjs
|
|
411
|
+
|
|
412
|
+
# Enter project and start development
|
|
413
|
+
cd my-api
|
|
414
|
+
npx rapidkit init # Install dependencies
|
|
415
|
+
npx rapidkit dev # Start dev server
|
|
416
|
+
\`\`\`
|
|
417
|
+
|
|
418
|
+
## Available Templates
|
|
419
|
+
|
|
420
|
+
| Template | Stack | Description |
|
|
421
|
+
|----------|-------|-------------|
|
|
422
|
+
| \`fastapi\` | Python + FastAPI | High-performance Python API |
|
|
423
|
+
| \`nestjs\` | TypeScript + NestJS | Enterprise Node.js framework |
|
|
424
|
+
|
|
425
|
+
## Commands
|
|
426
|
+
|
|
427
|
+
### Commands
|
|
428
|
+
|
|
429
|
+
| Command | Description |
|
|
430
|
+
|---------|-------------|
|
|
431
|
+
| \`npx rapidkit <name> --template <type>\` | Create a new project |
|
|
432
|
+
| \`npx rapidkit init\` | Install dependencies |
|
|
433
|
+
| \`npx rapidkit dev\` | Start development server |
|
|
434
|
+
| \`npx rapidkit start\` | Start production server |
|
|
435
|
+
| \`npx rapidkit build\` | Build for production |
|
|
436
|
+
| \`npx rapidkit test\` | Run tests |
|
|
437
|
+
| \`npx rapidkit lint\` | Run linting |
|
|
438
|
+
| \`npx rapidkit format\` | Format code |
|
|
439
|
+
|
|
440
|
+
## Learn More
|
|
441
|
+
|
|
442
|
+
- [RapidKit Documentation](https://rapidkit.dev)
|
|
443
|
+
- [GitHub Repository](https://github.com/Baziar/rapidkit)
|
|
444
|
+
`}async function N(t){let{fileURLToPath:r}=await import('url'),o=r(import.meta.url),a=i.dirname(o),n=i.resolve(a,".."),s=i.join(n,"templates","kits"),d=i.join(t,".rapidkit","templates"),{default:c}=await import('fs-extra');await c.copy(s,d);let m=i.join(n,"templates","generator.js"),g=i.join(t,".rapidkit","generator.js");await c.copy(m,g);}async function W(t,r){let o=r.template==="fastapi",a=o?"FastAPI":"NestJS",n=y(`Creating ${a} project...`).start();try{let{fileURLToPath:s}=await import('url'),d=s(import.meta.url),c$1=i.dirname(d),m=i.resolve(c$1,".."),g=o?"fastapi-standard":"nestjs-standard",l=i.join(m,"templates","kits",g);await promises.mkdir(t,{recursive:true});let h={project_name:o?r.name.replace(/-/g,"_").toLowerCase():r.name.replace(/_/g,"-").toLowerCase(),author:r.author,description:r.description||`${a} application generated with RapidKit`,app_version:"0.1.0",license:"MIT",package_manager:r.package_manager||"npm",created_at:new Date().toISOString(),rapidkit_version:c()};await R(l,t,h);let j=o?`# Python
|
|
445
|
+
__pycache__/
|
|
446
|
+
*.py[cod]
|
|
447
|
+
*$py.class
|
|
448
|
+
*.so
|
|
449
|
+
.Python
|
|
450
|
+
build/
|
|
451
|
+
develop-eggs/
|
|
452
|
+
dist/
|
|
453
|
+
downloads/
|
|
454
|
+
eggs/
|
|
455
|
+
.eggs/
|
|
456
|
+
lib/
|
|
457
|
+
lib64/
|
|
458
|
+
parts/
|
|
459
|
+
sdist/
|
|
460
|
+
var/
|
|
461
|
+
wheels/
|
|
462
|
+
*.egg-info/
|
|
463
|
+
.installed.cfg
|
|
464
|
+
*.egg
|
|
465
|
+
|
|
466
|
+
# Virtual environments
|
|
467
|
+
.venv/
|
|
468
|
+
venv/
|
|
469
|
+
ENV/
|
|
470
|
+
env/
|
|
471
|
+
|
|
472
|
+
# IDEs
|
|
473
|
+
.vscode/
|
|
474
|
+
.idea/
|
|
475
|
+
*.swp
|
|
476
|
+
*.swo
|
|
477
|
+
*~
|
|
478
|
+
|
|
479
|
+
# OS
|
|
480
|
+
.DS_Store
|
|
481
|
+
Thumbs.db
|
|
482
|
+
|
|
483
|
+
# Project specific
|
|
484
|
+
.env
|
|
485
|
+
.env.local
|
|
486
|
+
`:`# Node artifacts
|
|
487
|
+
node_modules/
|
|
488
|
+
dist/
|
|
489
|
+
.tmp/
|
|
490
|
+
.env
|
|
491
|
+
.env.*
|
|
492
|
+
!.env.example
|
|
493
|
+
|
|
494
|
+
# Logs
|
|
495
|
+
logs/
|
|
496
|
+
*.log
|
|
497
|
+
npm-debug.log*
|
|
498
|
+
yarn-debug.log*
|
|
499
|
+
yarn-error.log*
|
|
500
|
+
pnpm-debug.log*
|
|
501
|
+
|
|
502
|
+
# OS
|
|
503
|
+
.DS_Store
|
|
504
|
+
Thumbs.db
|
|
505
|
+
|
|
506
|
+
# IDEs
|
|
507
|
+
.idea/
|
|
508
|
+
.vscode/
|
|
509
|
+
|
|
510
|
+
# Coverage
|
|
511
|
+
coverage/
|
|
512
|
+
`;if(await promises.writeFile(i.join(t,".gitignore"),j),n.succeed(`${a} project created!`),!r.skipGit){let $=y("Initializing git repository...").start();try{await execa("git",["init"],{cwd:t}),await execa("git",["add","."],{cwd:t}),await execa("git",["commit","-m",`Initial commit: ${a} project via RapidKit`],{cwd:t}),$.succeed("Git repository initialized");}catch{$.warn("Could not initialize git repository");}}if(!r.skipInstall&&!o){let $=r.package_manager||"npm",v=y(`Installing dependencies with ${$}...`).start();try{await execa($,["install"],{cwd:t}),v.succeed("Dependencies installed");}catch{v.warn(`Could not install dependencies. Run '${$} install' manually.`);}}let w=i.basename(t);console.log(o?`
|
|
513
|
+
${e.green("\u2728 FastAPI project created successfully!")}
|
|
514
|
+
|
|
515
|
+
${e.bold("\u{1F4C2} Project structure:")}
|
|
516
|
+
${t}/
|
|
517
|
+
\u251C\u2500\u2500 .rapidkit/ # RapidKit CLI module
|
|
518
|
+
\u251C\u2500\u2500 src/
|
|
519
|
+
\u2502 \u251C\u2500\u2500 main.py # FastAPI application
|
|
520
|
+
\u2502 \u251C\u2500\u2500 cli.py # CLI commands
|
|
521
|
+
\u2502 \u251C\u2500\u2500 routing/ # API routes
|
|
522
|
+
\u2502 \u2514\u2500\u2500 modules/ # Module system
|
|
523
|
+
\u251C\u2500\u2500 tests/ # Test suite
|
|
524
|
+
\u251C\u2500\u2500 pyproject.toml # Poetry configuration
|
|
525
|
+
\u2514\u2500\u2500 README.md
|
|
526
|
+
|
|
527
|
+
${e.bold("\u{1F680} Get started:")}
|
|
528
|
+
${e.cyan(`cd ${w}`)}
|
|
529
|
+
${e.cyan("npx rapidkit init")} ${e.gray("# Install dependencies")}
|
|
530
|
+
${e.cyan("npx rapidkit dev")} ${e.gray("# Start dev server")}
|
|
531
|
+
|
|
532
|
+
${e.bold("\u{1F4DA} Available commands:")}
|
|
533
|
+
npx rapidkit init # Install dependencies (poetry install)
|
|
534
|
+
npx rapidkit dev # Start dev server with hot reload
|
|
535
|
+
npx rapidkit start # Start production server
|
|
536
|
+
npx rapidkit test # Run tests
|
|
537
|
+
npx rapidkit lint # Lint code
|
|
538
|
+
npx rapidkit format # Format code
|
|
539
|
+
|
|
540
|
+
${e.gray("Alternative: make dev, ./rapidkit dev, poetry run dev")}
|
|
541
|
+
${e.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
|
|
542
|
+
`:`
|
|
543
|
+
${e.green("\u2728 NestJS project created successfully!")}
|
|
544
|
+
|
|
545
|
+
${e.bold("\u{1F4C2} Project structure:")}
|
|
546
|
+
${t}/
|
|
547
|
+
\u251C\u2500\u2500 .rapidkit/ # RapidKit CLI module
|
|
548
|
+
\u251C\u2500\u2500 src/
|
|
549
|
+
\u2502 \u251C\u2500\u2500 main.ts # Application entry point
|
|
550
|
+
\u2502 \u251C\u2500\u2500 app.module.ts # Root module
|
|
551
|
+
\u2502 \u251C\u2500\u2500 config/ # Configuration
|
|
552
|
+
\u2502 \u2514\u2500\u2500 examples/ # Example module
|
|
553
|
+
\u251C\u2500\u2500 test/ # Test files
|
|
554
|
+
\u251C\u2500\u2500 package.json # Dependencies
|
|
555
|
+
\u2514\u2500\u2500 README.md
|
|
556
|
+
|
|
557
|
+
${e.bold("\u{1F680} Get started:")}
|
|
558
|
+
${e.cyan(`cd ${w}`)}
|
|
559
|
+
${r.skipInstall?e.cyan("npx rapidkit init")+e.gray(" # npm install")+`
|
|
560
|
+
`:""}${e.cyan("cp .env.example .env")}
|
|
561
|
+
${e.cyan("npx rapidkit dev")} ${e.gray("# Start dev server")}
|
|
562
|
+
|
|
563
|
+
${e.bold("\u{1F4DA} Available commands:")}
|
|
564
|
+
npx rapidkit init # Install dependencies
|
|
565
|
+
npx rapidkit dev # Start dev server with hot reload
|
|
566
|
+
npx rapidkit start # Start production server
|
|
567
|
+
npx rapidkit build # Build for production
|
|
568
|
+
npx rapidkit test # Run tests
|
|
569
|
+
npx rapidkit lint # Lint code
|
|
570
|
+
npx rapidkit format # Format code
|
|
571
|
+
|
|
572
|
+
${e.bold("\u{1F310} API endpoints:")}
|
|
573
|
+
http://localhost:8000/health # Health check
|
|
574
|
+
http://localhost:8000/docs # Swagger docs
|
|
575
|
+
http://localhost:8000/examples/notes # Example API
|
|
576
|
+
|
|
577
|
+
${e.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
|
|
578
|
+
`);}catch(s){throw n.fail(`Failed to create ${a} project`),s}}async function R(t,r,o){let a=await promises.readdir(t,{withFileTypes:true});for(let n of a){let s=i.join(t,n.name),d=n.name.replace(/\.j2$/,""),c=i.join(r,d);if(n.isDirectory())await promises.mkdir(c,{recursive:true}),await R(s,c,o);else {let m=await promises.readFile(s,"utf-8");n.name.endsWith(".j2")&&(m=S(m,o)),await promises.writeFile(c,m),(d==="rapidkit"||d==="activate"||d.endsWith(".py")&&c.includes(".rapidkit"))&&await promises.chmod(c,493);}}}function S(t,r){let o=t;for(let[a,n]of Object.entries(r)){let s=new RegExp(`\\{\\{\\s*${a}\\s*\\}\\}`,"g");o=o.replace(s,String(n));let d=new RegExp(`\\{\\{\\s*${a}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\}\\}`,"g");o=o.replace(d,(g,l,h)=>String(n).replace(new RegExp(l,"g"),h));let c=new RegExp(`\\{\\{\\s*${a}\\s*\\|\\s*lower\\s*\\}\\}`,"g");o=o.replace(c,String(n).toLowerCase());let m=new RegExp(`\\{\\{\\s*${a}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\|\\s*lower\\s*\\}\\}`,"g");o=o.replace(m,(g,l,h)=>String(n).replace(new RegExp(l,"g"),h).toLowerCase());}return o}async function K(){let t=process.env.XDG_CONFIG_HOME||process.env.APPDATA||i.join(k.homedir(),".config"),r=process.platform==="win32"?i.join(t,"rapidkit"):i.join(k.homedir(),".rapidkit"),o=i.join(r,"workspaces.json");if(!await promises.stat(o).catch(()=>null)){console.log(e.yellow(`
|
|
579
|
+
\u26A0\uFE0F No workspaces registered yet.
|
|
580
|
+
`)),console.log(e.gray(`Create a workspace with: npx rapidkit <workspace-name>
|
|
581
|
+
`));return}try{let a=await promises.readFile(o,"utf8"),n=JSON.parse(a);if(!n.workspaces||n.workspaces.length===0){console.log(e.yellow(`
|
|
582
|
+
\u26A0\uFE0F No workspaces registered yet.
|
|
583
|
+
`));return}console.log(e.bold(`
|
|
584
|
+
\u{1F4E6} Registered RapidKit Workspaces:
|
|
585
|
+
`));for(let s of n.workspaces)console.log(e.cyan(` ${s.name}`)),console.log(e.gray(` Path: ${s.path}`)),console.log(e.gray(` Projects: ${s.projects?.length||0}`)),await promises.stat(s.path).catch(()=>null)||console.log(e.red(" \u26A0\uFE0F Path not found")),console.log();console.log(e.gray(`Total: ${n.workspaces.length} workspace(s)
|
|
586
|
+
`));}catch(a){console.error(e.red(`
|
|
587
|
+
\u274C Failed to read workspace registry`)),console.error(e.gray(String(a)));}}export{W as createProject,U as createWorkspace,K as listWorkspaces,G as registerProjectInWorkspace,C as registerWorkspace,T as syncWorkspaceProjects};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{d as createNpmWorkspaceMarker,e as isValidWorkspaceMarker,a as readWorkspaceMarker,c as updateWorkspaceMetadata,b as writeWorkspaceMarker}from'./chunk-RV6HBTFC.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rapidkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Create RapidKit projects with a single command - The official CLI for RapidKit framework",
|
|
6
6
|
"keywords": [
|
|
@@ -58,7 +58,10 @@
|
|
|
58
58
|
"sync:contracts": "node scripts/sync-contracts.mjs",
|
|
59
59
|
"check:contracts": "node scripts/sync-contracts.mjs --check",
|
|
60
60
|
"bundle-size": "npm run build && du -sh dist/ && ls -lh dist/",
|
|
61
|
-
"
|
|
61
|
+
"analyze": "npm run build && npx vite-bundle-visualizer dist/index.js --open",
|
|
62
|
+
"size-check": "npm run build && size-limit",
|
|
63
|
+
"bench": "npx tsx scripts/benchmarks.ts",
|
|
64
|
+
"quality": "npm run typecheck && npm run lint && npm run format:check && npm test && npm run size-check",
|
|
62
65
|
"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"
|
|
63
66
|
},
|
|
64
67
|
"dependencies": {
|
|
@@ -75,6 +78,7 @@
|
|
|
75
78
|
},
|
|
76
79
|
"devDependencies": {
|
|
77
80
|
"@eslint/eslintrc": "^3.3.3",
|
|
81
|
+
"@size-limit/preset-big-lib": "^12.0.0",
|
|
78
82
|
"@types/cli-progress": "^3.11.6",
|
|
79
83
|
"@types/fs-extra": "^11.0.4",
|
|
80
84
|
"@types/inquirer": "^9.0.7",
|
|
@@ -90,8 +94,10 @@
|
|
|
90
94
|
"husky": "^9.1.7",
|
|
91
95
|
"lint-staged": "^15.5.2",
|
|
92
96
|
"prettier": "^3.6.2",
|
|
97
|
+
"size-limit": "^12.0.0",
|
|
93
98
|
"tsup": "^8.5.0",
|
|
94
99
|
"typescript": "^5.5.0",
|
|
100
|
+
"vite-bundle-visualizer": "^1.2.1",
|
|
95
101
|
"vitest": "^4.0.15"
|
|
96
102
|
},
|
|
97
103
|
"engines": {
|