rapidkit 0.27.4 → 0.27.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.
@@ -1,781 +0,0 @@
1
- import {i,d as d$2,l,k,f as f$1,g,h}from'./chunk-ZAZJEYYT.js';import {a,d,b as b$1}from'./chunk-RV6HBTFC.js';import {a as a$2,e,d as d$1,f,c,k as k$1}from'./chunk-Z5LKRG57.js';import {b}from'./chunk-Q7ULIFQA.js';import {a as a$1}from'./chunk-VM2TOHNX.js';import {promises}from'fs';import*as v from'fs-extra';import m from'path';import U from'inquirer';import o from'chalk';import z from'ora';import {execa}from'execa';function C(){return c()}async function et(t,n,e,r){let s=d(n,b(),e);r&&(s.metadata||(s.metadata={}),s.metadata.python={version:r}),await b$1(t,s);}async function H(t){await v.outputFile(m.join(t,".gitignore"),`.venv/
2
- __pycache__/
3
- *.pyc
4
- .env
5
- .rapidkit-workspace/
6
-
7
- `,"utf-8");}async function ot(t,n){let e=n.replace(/[^a-z0-9-]/gi,"-").toLowerCase();await v.outputFile(m.join(t,"poetry.toml"),`[virtualenvs]
8
- in-project = true
9
- `,"utf-8"),await v.outputFile(m.join(t,"pyproject.toml"),`[tool.poetry]
10
- name = "${e}"
11
- version = "0.1.0"
12
- description = "RapidKit workspace"
13
- authors = []
14
- package-mode = false
15
-
16
- [tool.poetry.dependencies]
17
- python = "^3.10"
18
- rapidkit-core = "*"
19
-
20
- [build-system]
21
- requires = ["poetry-core"]
22
- build-backend = "poetry.core.masonry.api"
23
- `,"utf-8");}function mt(t,n,e,r){return JSON.stringify({schema_version:"1.0",workspace_name:t,rapidkit_version:b(),created_at:new Date().toISOString(),created_by:"rapidkit-npm",profile:r||"minimal",engine:{install_method:n,python_version:e||null}},null,2)}function yt(t,n,e,r){return JSON.stringify({schema_version:"1.0",generated_by:"rapidkit-npm",generated_at:new Date().toISOString(),runtime:{python:{version:n||null,install_method:t},node:{version:e||process.version},go:{version:r||null},java:{version:null,build_tool:null,build_tool_version:null}}},null,2)}function gt(){return `version: "1.0"
24
- mode: warn # "warn" or "strict"
25
- dependency_sharing_mode: isolated # "isolated" or "shared-runtime-caches" or "shared-node-deps"
26
- # change profile (recommended): npx rapidkit bootstrap --profile polyglot
27
- # change mode/dependency manually: edit this file and rerun npx rapidkit init
28
- rules:
29
- enforce_workspace_marker: true
30
- enforce_toolchain_lock: false
31
- disallow_untrusted_tool_sources: false
32
- `}function ht(){return `version: "1.0"
33
- cache:
34
- strategy: shared # "shared" or "on-demand"
35
- prune_on_bootstrap: false
36
- self_heal: true
37
- verify_integrity: false
38
- `}async function nt(t,n,e,r,s){let d;try{let{stdout:u}=await execa("go",["version"],{timeout:3e3,stdio:"pipe"}),g=u.match(/go(\d+\.\d+(?:\.\d+)?)/i);d=g?g[1]:void 0;}catch{}await v.outputFile(m.join(t,".rapidkit","workspace.json"),mt(n,e,r,s),"utf-8"),await v.outputFile(m.join(t,".rapidkit","toolchain.lock"),yt(e,r,process.version,d),"utf-8"),await v.outputFile(m.join(t,".rapidkit","policies.yml"),gt(),"utf-8"),await v.outputFile(m.join(t,".rapidkit","cache-config.yml"),ht(),"utf-8");}async function ee(t,n){let{workspaceName:e=m.basename(t),installMethod:r="venv",pythonVersion:s,profile:d$1,writeMarker:u=true,writeGitignore:g=true,onlyIfMissing:y=true}=n||{},h=[],c;try{let{stdout:a}=await execa("go",["version"],{timeout:3e3,stdio:"pipe"}),p=a.match(/go(\d+\.\d+(?:\.\d+)?)/i);c=p?p[1]:void 0;}catch{}let i=[{relPath:m.join(".rapidkit","workspace.json"),content:mt(e,r,s,d$1)},{relPath:m.join(".rapidkit","toolchain.lock"),content:yt(r,s,process.version,c)},{relPath:m.join(".rapidkit","policies.yml"),content:gt()},{relPath:m.join(".rapidkit","cache-config.yml"),content:ht()}];for(let a of i){let p=m.join(t,a.relPath);y&&await v.pathExists(p)||(await v.outputFile(p,a.content,"utf-8"),h.push(a.relPath));}if(u&&(!!!await a(t)||!y)){let p=d(e,b(),r);s&&(p.metadata||(p.metadata={}),p.metadata.python={version:s}),await b$1(t,p),h.push(".rapidkit-workspace");}if(g){let a=m.join(t,".gitignore");(!y||!await v.pathExists(a))&&(await H(t),h.push(".gitignore"));}return h}var A="3.10",ft=["3.10","3.11","3.12"];async function pt(t){try{let{stdout:n}=await execa(t,["--version"],{timeout:3e3}),e=n.match(/Python (\d+\.\d+\.\d+)/);if(e)return e[1]}catch{}return null}async function jt(t,n){try{await promises.writeFile(m.join(t,".python-version"),`${n}
39
- `,"utf-8"),a$1.debug(`Created .python-version with ${n}`);}catch(e){a$1.warn(`Failed to create .python-version: ${e}`);}}function D(){let e=[...(process.env.PATH||"").split(m.delimiter).filter(Boolean)];for(let r of k$1())e.includes(r)||e.unshift(r);process.env.PATH=e.join(m.delimiter);}async function q(t,n){D(),t.start("Checking pipx installation");try{return await execa("pipx",["--version"]),t.succeed("pipx found"),{kind:"binary"}}catch{}let e=C();try{return await execa(e,["-m","pipx","--version"]),t.succeed("pipx found"),{kind:"python-module",pythonCmd:e}}catch{}if(n)throw new h;t.stop?.();let{installPipx:r}=await U.prompt([{type:"confirm",name:"installPipx",message:"pipx is not installed. Install it now (user install via python -m pip)?",default:true}]);if(!r)throw new h;t.start("Installing pipx (user install)");try{try{await execa(e,["-m","pip","install","--user","--upgrade","pip"]);}catch{}await execa(e,["-m","pip","install","--user","--upgrade","pipx"]);}catch(s){let d=s,u=String(d?.stderr||d?.shortMessage||d?.message||"");throw new k("Install pipx with python -m pip",s instanceof Error?s:new Error(u))}t.succeed("pipx installed"),D();try{return await execa(e,["-m","pipx","--version"]),{kind:"python-module",pythonCmd:e}}catch(s){let d=s,u=String(d?.stderr||d?.shortMessage||d?.message||"pipx not runnable after install");throw new k("Verify pipx after install",new Error(`${u}
40
-
41
- Try reopening your terminal or run: ${e} -m pipx ensurepath`))}}async function F(t,n){return t.kind==="binary"?execa("pipx",n):execa(t.pythonCmd,["-m","pipx",...n])}function Et(t){let n=t.match(/^(\d+)\.(\d+)/);return n?`${n[1]}.${n[2]}`:null}function ut(t){if(!t)return null;let n=t.match(/Python\s+(\d+)\.(\d+)(?:\.\d+)?/i);return n?`${n[1]}.${n[2]}`:null}function it(t,n){let[e,r]=t.split(".").map(u=>Number(u)),[s,d]=n.split(".").map(u=>Number(u));return e!==s?e-s:r-d}function K(t,n){return it(t,n)>=0}async function Ct(t){let n=new Set,e$1=e(14,10);for(let i of e$1)try{let a=await execa(i.command,i.args,{timeout:2500}),p=ut(`${a.stdout||""}
42
- ${a.stderr||""}`);p&&K(p,A)&&n.add(p);}catch{}let r=null;try{let i=await execa(C(),["--version"],{timeout:2500}),a=ut(`${i.stdout||""}
43
- ${i.stderr||""}`);a&&K(a,A)&&(r=a,n.add(a));}catch{}let s=ft.filter(i=>K(i,A)),d=new Set([...s,...n]),u=Array.from(d).sort((i,a)=>it(a,i)),g=t?Et(t):null,y=g&&K(g,A)?g:r||u[0]||A;return d.has(y)||d.add(y),{choices:Array.from(d).sort((i,a)=>it(a,i)).map(i=>{let a=[];return i===r&&a.push("current system"),i===A&&a.push("minimum supported"),n.has(i)&&i!==r&&a.push("detected"),{name:a.length>0?`${i} (${a.join(", ")})`:i,value:i}}),defaultValue:y}}async function $t(){D();let t=false,n=false;try{await execa("poetry",["--version"],{timeout:2500}),t=true;}catch{t=false;}try{await execa("pipx",["--version"],{timeout:2500}),n=true;}catch{let e=c();try{await execa(e,["-m","pipx","--version"],{timeout:2500}),n=true;}catch{n=false;}}return {poetry:t,pipx:n}}async function wt(){D();try{return await execa("poetry",["--version"],{timeout:2500}),true}catch{return false}}function St(t,n){return t==="poetry"&&n.poetry?"poetry":t==="pipx"&&n.pipx?"pipx":t==="venv"?"venv":n.poetry?"poetry":"venv"}async function Mt(t,n){D(),t.start("Checking Poetry installation");try{await execa("poetry",["--version"]),t.succeed("Poetry found");return}catch{}if(n)throw new g;let{installPoetry:e}=await U.prompt([{type:"confirm",name:"installPoetry",message:"Poetry is not installed. Install it now using pipx?",default:true}]);if(!e)throw new g;let r=await q(t,n);t.start("Installing Poetry with pipx");try{await F(r,["install","poetry"]);}catch(s){let d=s,u=String(d?.stderr||d?.shortMessage||d?.message||"");if(/already\s+installed|already\s+seems\s+to\s+be\s+installed|exists/i.test(u))try{await F(r,["upgrade","poetry"]);}catch{}else throw new k("Install Poetry with pipx",s instanceof Error?s:new Error(u))}t.succeed("Poetry installed"),D();try{await execa("poetry",["--version"]);}catch(s){let d=s,u=String(d?.stderr||d?.shortMessage||d?.message||"Poetry not found on PATH");throw new k("Verify Poetry after pipx install",new Error(`${u}
44
-
45
- Poetry may be installed but not on PATH yet. Try reopening your terminal or run: pipx ensurepath`))}}function At(t){let n=t==="poetry";return `#!/usr/bin/env sh
46
- set -eu
47
-
48
- SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
49
-
50
- VENV_RAPIDKIT="$SCRIPT_DIR/.venv/bin/rapidkit"
51
- if [ -x "$VENV_RAPIDKIT" ]; then
52
- exec "$VENV_RAPIDKIT" "$@"
53
- fi
54
-
55
- ${n?`if command -v poetry >/dev/null 2>&1 && [ -f "$SCRIPT_DIR/pyproject.toml" ]; then
56
- exec poetry run rapidkit "$@"
57
- fi
58
-
59
- `:""}echo "RapidKit launcher could not find a local Python CLI." 1>&2
60
- echo "- If you used venv: ensure .venv exists (or re-run the installer)." 1>&2
61
- ${n?`echo "- If you used Poetry: run 'poetry install' and retry, or activate the env." 1>&2
62
- `:""}echo "Tip: you can also run: ./.venv/bin/rapidkit --help" 1>&2
63
- exit 1
64
- `}function Dt(t){return `@echo off
65
- setlocal
66
-
67
- set "SCRIPT_DIR=%~dp0"
68
-
69
- if exist "%SCRIPT_DIR%\\.venv\\Scripts\\rapidkit.exe" (
70
- "%SCRIPT_DIR%\\.venv\\Scripts\\rapidkit.exe" %*
71
- exit /b %ERRORLEVEL%
72
- )
73
-
74
- ${t==="poetry"?`where poetry >nul 2>nul
75
- if %ERRORLEVEL%==0 if exist "%SCRIPT_DIR%\\pyproject.toml" (
76
- poetry run rapidkit %*
77
- exit /b %ERRORLEVEL%
78
- )
79
-
80
- `:""}echo RapidKit launcher could not find a local Python CLI. 1>&2
81
- echo Tip: run .venv\\Scripts\\rapidkit.exe --help 1>&2
82
- exit /b 1
83
- `}async function vt(t,n){await v.outputFile(m.join(t,"rapidkit"),At(n),{encoding:"utf-8",mode:493}),await v.outputFile(m.join(t,"rapidkit.cmd"),Dt(n),"utf-8");}async function oe(t,n){let{skipGit:e=false,testMode:r=false,demoMode:s=false,dryRun:d=false,yes:u=false,userConfig:g={},installMethod:y,profile:h}=n,c=t||"rapidkit",i$1=m.resolve(process.cwd(),c);if(await v.pathExists(i$1))throw new i(c);if(d){await Ft(i$1,c,s,g);return}if(s){await Kt(i$1,c,e);return}let a=new Set(["python-only","polyglot","enterprise"]),p=h||"";if(!u&&!h){let{selectedProfile:f}=await U.prompt([{type:"rawlist",name:"selectedProfile",message:"Select workspace profile:",choices:[{name:"minimal \u2014 Foundation files only (fastest bootstrap, mixed projects)",value:"minimal"},{name:"java-only \u2014 Java runtime (Spring Boot services)",value:"java-only"},{name:"python-only \u2014 Python + Poetry (FastAPI, Django, ML pipelines)",value:"python-only"},{name:"node-only \u2014 Node.js runtime (NestJS, Express, Next.js)",value:"node-only"},{name:"go-only \u2014 Go runtime (Fiber, Gin, gRPC, microservices)",value:"go-only"},{name:"polyglot \u2014 Python + Node.js + Go + Java multi-runtime workspace",value:"polyglot"},{name:"enterprise \u2014 Polyglot + governance + Sigstore verification",value:"enterprise"}],default:1}]);p=f;}else p||(p="minimal");let b=!u&&a.has(p),E=typeof g.pythonVersion=="string"&&g.pythonVersion.trim().length>0?g.pythonVersion.trim():void 0,S=y||g.defaultInstallMethod||"poetry",I=b?await $t():{poetry:true,pipx:true},T=b?await Ct(E):{choices:ft.map(f=>({name:f,value:f})),defaultValue:A},Y=St(S,I),It=[{name:I.poetry?"\u{1F3AF} Poetry (Recommended - includes virtual env)":"\u{1F3AF} Poetry (Recommended - includes virtual env) \u2014 not detected (we can install it)",value:"poetry"},{name:"\u{1F4E6} pip with venv (Standard, zero extra tools)",value:"venv"},{name:I.pipx?"\u{1F527} pipx (Global isolated install)":"\u{1F527} pipx (Global isolated install) \u2014 not detected (we can install it)",value:"pipx"}],x=b?await U.prompt([{type:"rawlist",name:"pythonVersion",message:"Select Python version for RapidKit:",choices:T.choices,default:T.defaultValue},{type:"rawlist",name:"installMethod",message:"How would you like to manage the workspace environment?",choices:It,default:Y}]):await(async()=>{let f=y||g.defaultInstallMethod||await(async()=>{try{return await execa("poetry",["--version"],{timeout:3e3}),"poetry"}catch{return a$1.warn("Poetry not found \u2014 auto-selecting venv. Pass --install-method poetry to override."),"venv"}})();return {pythonVersion:g.pythonVersion||"3.10",installMethod:f}})();if(new Set(["go-only","java-only","node-only","minimal"]).has(p)){let f=z("Creating workspace").start();try{await v.ensureDir(i$1),f.succeed("Directory created"),await et(i$1,c,"venv",void 0),await nt(i$1,c,"venv",void 0,p),await H(i$1),await ot(i$1,c);let R={"go-only":"Go-only","java-only":"Java-only","node-only":"Node.js-only",minimal:"Minimal"};if(await v.outputFile(m.join(i$1,"README.md"),`# ${c}
84
-
85
- RapidKit **${R[p]}** workspace.
86
-
87
- ## Quick start
88
-
89
- \`\`\`bash
90
- `+(p==="go-only"?`npx rapidkit create project gofiber.standard my-api
91
- cd my-api
92
- npx rapidkit init
93
- npx rapidkit dev
94
- `:p==="java-only"?`npx rapidkit create project springboot.standard my-service
95
- cd my-service
96
- npx rapidkit init
97
- npx rapidkit dev
98
- `:p==="node-only"?`npx rapidkit create project nestjs.standard my-app
99
- cd my-app
100
- npx rapidkit init
101
- npx rapidkit dev
102
- `:`npx rapidkit create project
103
- cd <project-name>
104
- npx rapidkit init
105
- npx rapidkit dev
106
- `)+"```\n","utf-8"),!e){f.start("Initializing git repository");try{await execa("git",["init"],{cwd:i$1}),await execa("git",["add","."],{cwd:i$1}),await execa("git",["commit","-m","Initial commit: RapidKit workspace"],{cwd:i$1}),f.succeed("Git repository initialized");}catch{f.warn("Could not initialize git repository");}}try{let{registerWorkspace:k}=await import('./workspace-HEHMJ3QC.js');await k(i$1,c);}catch{}if(console.log(o.green(`
107
- \u2728 Workspace created!
108
- `)),console.log(o.cyan("\u{1F4C2} Location:"),o.white(i$1)),console.log(o.cyan(`
109
- \u{1F680} Get started:
110
- `)),console.log(o.white(` cd ${c}`)),p==="go-only"){console.log(o.white(" npx rapidkit create project gofiber.standard my-api")),console.log(o.white(" cd my-api")),console.log(o.white(" npx rapidkit init")),console.log(o.white(` npx rapidkit dev
111
- `)),console.log(o.gray("\u{1F4A1} No Python required \u2014 Go kits run entirely through the npm package."));try{let{stdout:k}=await execa("go",["version"],{timeout:3e3}),_=k.match(/go version go(\d+\.\d+(?:\.\d+)?)/),M=_?_[1]:"unknown";console.log(o.gray(`\u{1F439} Go ${M} detected \u2014 ready for gofiber.standard / gogin.standard projects`));}catch{console.log(o.yellow(`
112
- \u26A0\uFE0F Go is not installed \u2014 install it from https://go.dev/dl/`));}}else p==="java-only"?(console.log(o.white(" npx rapidkit create project springboot.standard my-service")),console.log(o.white(" cd my-service")),console.log(o.white(" npx rapidkit init")),console.log(o.white(` npx rapidkit dev
113
- `)),console.log(o.gray("\u{1F4A1} No Python required \u2014 Spring Boot kit runs through the npm package with Java tooling."))):p==="node-only"?(console.log(o.white(" npx rapidkit create project nestjs.standard my-app")),console.log(o.white(" cd my-app")),console.log(o.white(" npx rapidkit init")),console.log(o.white(` npx rapidkit dev
114
- `)),console.log(o.gray("\u{1F4A1} Python engine will be installed automatically on first `create project nestjs.standard`."))):(console.log(o.white(" npx rapidkit create project")),console.log(o.white(" cd <project-name>")),console.log(o.white(" npx rapidkit init")),console.log(o.white(` npx rapidkit dev
115
- `)),console.log(o.gray("\u{1F4A1} Bootstrap a specific runtime any time: rapidkit bootstrap --profile java-only|python-only|node-only|go-only")));console.log("");}catch(R){throw f.fail("Failed to create workspace"),console.error(o.red(`
116
- \u274C Error:`),R),R}return}{let f=C(),R=false;try{await execa(f,["--version"],{timeout:5e3}),R=true;}catch{try{await execa("python",["--version"],{timeout:5e3}),R=true;}catch{R=false;}}R||(console.log(o.red(`
117
- \u274C Python 3.10+ is required for the "${p}" profile.
118
- `)),console.log(o.cyan(`\u{1F4A1} How to install Python:
119
- `)),console.log(o.white(" Ubuntu / Debian: sudo apt install python3.10")),console.log(o.white(" macOS (Homebrew): brew install python@3.10")),console.log(o.white(` Windows: https://python.org/downloads
120
- `)),console.log(o.gray(` After installing Python, run: npx rapidkit ${c}
121
- `)),process.exit(1));}a$1.step(1,3,"Setting up RapidKit environment");let P=z("Creating directory").start();try{await v.ensureDir(i$1),P.succeed("Directory created"),P.start("Detecting Python version");let f=null,R=await kt(x.pythonVersion);if(R)f=await pt(R),f?(a$1.info(` Detected Python ${f}`),P.succeed(`Python ${f} detected`)):P.warn("Could not detect exact Python version");else {let k=C();f=await pt(k),f?P.succeed(`Python ${f} detected`):P.warn("Could not detect Python version, proceeding with defaults");}if(x.installMethod==="poetry"&&!await wt()&&(P.warn("Poetry not found \u2014 auto-fallback to pip + venv"),x.installMethod="venv"),await et(i$1,c,x.installMethod,f||void 0),f&&await jt(i$1,f),await nt(i$1,c,x.installMethod,f||x.pythonVersion,p||h),await H(i$1),await ot(i$1,c),x.installMethod==="poetry")try{await bt(i$1,x.pythonVersion,P,r,g,u);}catch(k){let _=k?.details||k?.message||String(k);if(_.includes("pyenv")||_.includes("exit status 127")||_.includes("returned non-zero exit status 127")){P.warn("Poetry encountered Python discovery issues, trying venv method"),a$1.debug(`Poetry error (attempting venv fallback): ${_}`);try{await rt(i$1,x.pythonVersion,P,r,g),x.installMethod="venv";}catch(at){throw at}}else throw k}else x.installMethod==="venv"?await rt(i$1,x.pythonVersion,P,r,g):await Pt(i$1,P,r,g,u);if(await vt(i$1,x.installMethod),await xt(i$1,x.installMethod),P.succeed("RapidKit environment ready!"),!n.skipGit){P.start("Initializing git repository");try{await execa("git",["init"],{cwd:i$1}),await execa("git",["add","."],{cwd:i$1}),await execa("git",["commit","-m","Initial commit: RapidKit environment"],{cwd:i$1}),P.succeed("Git repository initialized");}catch{P.warn("Could not initialize git repository");}}try{let{registerWorkspace:k}=await import('./workspace-HEHMJ3QC.js');await k(i$1,c);}catch{console.warn(o.gray("Note: Could not register workspace in shared registry"));}if(console.log(o.green(`
122
- \u2728 RapidKit environment created successfully!
123
- `)),console.log(o.cyan("\u{1F4C2} Location:"),o.white(i$1)),console.log(o.cyan(`\u{1F680} Get started:
124
- `)),console.log(o.white(` cd ${c}`)),x.installMethod==="poetry"){let k="source $(poetry env info --path)/bin/activate";try{D();let{stdout:_}=await execa("poetry",["--version"]),M=_.match(/Poetry.*?(\d+)\.(\d+)/);M&&(parseInt(M[1])>=2?k="source $(poetry env info --path)/bin/activate":k="poetry shell");}catch{}console.log(o.white(` ${k} # Or: poetry run rapidkit`)),console.log(o.white(" rapidkit create # Interactive mode")),console.log(o.white(" cd <project-name>")),console.log(o.white(" rapidkit init")),console.log(o.white(" rapidkit dev"));}else x.installMethod==="venv"?(console.log(o.white(" source .venv/bin/activate # On Windows: .venv\\Scripts\\activate")),console.log(o.white(" rapidkit create # Interactive mode")),console.log(o.white(" cd <project-name>")),console.log(o.white(" rapidkit init")),console.log(o.white(" rapidkit dev"))):(console.log(o.white(" rapidkit create # Interactive mode")),console.log(o.white(" cd <project-name>")),console.log(o.white(" rapidkit init")),console.log(o.white(" rapidkit dev")));console.log(o.white(`
125
- \u{1F4A1} For more information, check the README.md file.`)),console.log(o.cyan(`
126
- \u{1F4DA} RapidKit commands:`)),console.log(o.white(" rapidkit create - Create a new project (interactive)")),console.log(o.white(" rapidkit dev - Run development server")),console.log(o.white(" rapidkit add module <name> - Add a module (e.g., settings)")),console.log(o.white(" rapidkit list - List available kits")),console.log(o.white(" rapidkit modules - List available modules")),console.log(o.white(` rapidkit --help - Show all commands
127
- `));try{let{stdout:k}=await execa("go",["version"],{timeout:3e3}),_=k.match(/go version go(\d+\.\d+(?:\.\d+)?)/),M=_?_[1]:"unknown";console.log(o.gray(`\u{1F439} Go toolchain: Go ${M} detected \u2014 ready for gofiber.standard projects`));}catch{console.log(o.yellow("\u26A0\uFE0F Go toolchain not installed \u2014 needed for gofiber.standard projects")),console.log(o.gray(" Install: https://go.dev/dl/"));}console.log("");}catch(f){P.fail("Failed to create RapidKit environment"),console.error(o.red(`
128
- \u274C Error:`),f);try{await v.remove(i$1);}catch{}throw f}}async function kt(t){let n=[];if(!a$2())try{let{stdout:d}=await execa("pyenv",["which","python"]),u=d.trim();u&&n.push(u);}catch{}let e$1=Number(t.split(".")[1]),r=e(e$1,10).map(d=>d.command).filter(Boolean);n.push(`python${t}`,...r,...d$1());let s=[...new Set(n)];for(let d of s)try{let u=d==="py"?["-3","--version"]:["--version"],g=d==="py"?["-3","-c","import sys; sys.exit(0)"]:["-c","import sys; sys.exit(0)"],{stdout:y}=await execa(d,u,{timeout:2e3}),h=y.match(/Python (\d+\.\d+)/)?.[1];if(h&&K(h,t))return await execa(d,g,{timeout:2e3}),d}catch{continue}return null}async function bt(t,n,e,r,s,d=false){await Mt(e,d),e.start("Finding Python interpreter");let u=await kt(n);u?(a$1.debug(`Found working Python: ${u}`),e.succeed("Python found")):e.warn("Could not verify Python path, proceeding with default"),e.start("Initializing Poetry project");let g=m.join(t,"pyproject.toml"),h=(await v.pathExists(g)?await promises.readFile(g,"utf-8"):"").includes("rapidkit-core");if(h)e.succeed("Poetry project initialized");else {await execa("poetry",["init","--no-interaction","--python",`^${n}`],{cwd:t}),e.succeed("Poetry project initialized");let p=await promises.readFile(g,"utf-8");p.includes("[tool.poetry]")?p=p.replace("[tool.poetry]",`[tool.poetry]
129
- package-mode = false`):p.includes("[project]")&&(p.includes("[build-system]")?p=p.replace("[build-system]",`
130
- [tool.poetry]
131
- package-mode = false
132
-
133
- [build-system]`):p+=`
134
-
135
- [tool.poetry]
136
- package-mode = false
137
- `),await promises.writeFile(g,p,"utf-8");}e.start("Configuring Poetry");try{await execa("poetry",["config","virtualenvs.in-project","true","--local"],{cwd:t}),e.succeed("Poetry configured");}catch{e.warn("Could not configure Poetry virtualenvs.in-project");}e.start("Creating virtualenv");let c=u||C(),i=f(m.join(t,".venv"));try{await execa(c,["-m","venv",".venv"],{cwd:t,timeout:6e4}),e.succeed("Virtualenv created");}catch(a){a$1.debug(`python -m venv failed: ${a}`),e.warn("Could not pre-create virtualenv, Poetry will try"),i=u||C();}try{await execa("poetry",["env","use",i||C()],{cwd:t}),a$1.debug(`Poetry env set to: ${i}`);}catch(a){a$1.debug(`Could not set Poetry env: ${a}`);}if(e.start("Installing RapidKit"),h&&!r){let a=d$2(s||{}),p=a?await v.pathExists(a):false,b=p&&a?a:"rapidkit-core";a&&!p&&a$1.warn(`RAPIDKIT_DEV_PATH is set but path does not exist: ${a}. Falling back to PyPI.`),e.text=p?"Installing RapidKit from local path":"Installing RapidKit from PyPI";let E=false,S=null;for(let I=1;I<=3;I++)try{await execa(i,["-m","pip","install",b,"--quiet"],{cwd:t,timeout:18e4}),E=true;break}catch(T){S=T,a$1.debug(`pip install rapidkit-core attempt ${I} failed: ${T}`),I<3&&(e.text=`Retrying installation (attempt ${I+1}/3)`,await new Promise(Y=>setTimeout(Y,2e3)));}if(!E){let I=S?.stderr||S?.message||"Unknown error";throw a$1.debug(`All pip install attempts failed. Last error: ${I}`),I.includes("Could not find")||I.includes("No matching distribution")?new l:new k("Install rapidkit-core with pip",new Error(`Failed to install rapidkit-core after 3 attempts.
138
- Error: ${I}
139
-
140
- Possible solutions:
141
- 1. Check your internet connection
142
- 2. Try installing manually: cd ${m.basename(t)} && poetry add rapidkit-core
143
- 3. Use venv method instead: npx rapidkit ${m.basename(t)} --install-method=venv`))}}else {e.text="Syncing Poetry environment";try{await execa("poetry",["install","--no-root"],{cwd:t,timeout:12e4}),e.succeed("Poetry environment synced");}catch(a){a$1.debug(`poetry install --no-root failed: ${a}`),e.warn("Could not sync Poetry environment, proceeding with add command");}if(e.start("Installing RapidKit"),r){let a=d$2(s||{});if(!a)throw new k("Test mode installation",new Error("No local RapidKit path configured. Set RAPIDKIT_DEV_PATH environment variable."));a$1.debug(`Installing from local path: ${a}`),e.text="Installing RapidKit from local path (test mode)",await execa("poetry",["add",a],{cwd:t});}else {e.text="Installing RapidKit from PyPI";let a=false,p=null;for(let b=1;b<=3;b++)try{await execa("poetry",["add","rapidkit-core"],{cwd:t,timeout:6e4*b}),a=true;break}catch(E){p=E,a$1.debug(`Poetry add attempt ${b} failed: ${E}`),b<3&&(e.text=`Retrying installation (attempt ${b+1}/3)`,await new Promise(S=>setTimeout(S,2e3)));}if(!a){let b=p?.stderr||p?.message||"Unknown error";throw a$1.debug(`All Poetry install attempts failed. Last error: ${b}`),b.includes("Could not find")||b.includes("No matching distribution")?new l:new k("Install rapidkit-core with Poetry",new Error(`Failed to install rapidkit-core after 3 attempts.
144
- Error: ${b}
145
-
146
- Possible solutions:
147
- 1. Check your internet connection
148
- 2. Try installing manually: cd ${m.basename(t)} && poetry add rapidkit-core
149
- 3. Use venv method instead: npx rapidkit ${m.basename(t)} --install-method=venv`))}}}e.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:a}=await import('./pythonRapidkitExec-K2SFGAYJ.js');if(!await a()&&!r){e.start("Checking optional global pipx installation");let b=await q(e,true);try{e.start("Installing RapidKit globally with pipx for CLI access"),await F(b,["install","rapidkit-core"]),e.succeed("RapidKit installed globally");}catch(E){e.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),a$1.debug(`pipx install failed: ${E}`);}}}catch(a){e.succeed("Skipped optional global pipx installation"),a$1.debug(`Global install check skipped: ${a}`);}}async function rt(t,n,e,r,s,d=false){e.start(`Checking Python ${n}`);let u=C();try{let{stdout:y}=await execa(u,["--version"]),h=y.match(/Python (\d+\.\d+)/)?.[1];if(h&&!K(h,n))throw new f$1(n,h);e.succeed(`Python ${h} found`);}catch(y){throw y instanceof f$1?y:new f$1(n)}e.start("Creating virtual environment");try{await execa(u,["-m","venv",".venv"],{cwd:t}),e.succeed("Virtual environment created");}catch(y){if(e.fail("Failed to create virtual environment"),(c=>typeof c=="object"&&c!==null&&"stdout"in c&&typeof c.stdout=="string")(y)&&y.stdout.includes("ensurepip is not")){let c=y.stdout.match(/apt install (python[\d.]+-venv)/),i=c?c[1]:"python3-venv";throw new k("Python venv module not available",new Error(`Virtual environment creation failed.
150
-
151
- On Debian/Ubuntu systems, install the venv package:
152
- sudo apt install ${i}
153
-
154
- Or use Poetry instead (recommended):
155
- npx rapidkit ${m.basename(t)} --yes`))}throw new k("Virtual environment creation",y instanceof Error?y:new Error(String(y)))}e.start("Installing RapidKit");let g=f(m.join(t,".venv"));if(await execa(g,["-m","pip","install","--upgrade","pip"],{cwd:t}),r){let y=d$2(s||{});if(!y)throw new k("Test mode installation",new Error("No local RapidKit path configured. Set RAPIDKIT_DEV_PATH environment variable."));a$1.debug(`Installing from local path: ${y}`),e.text="Installing RapidKit from local path (test mode)",await execa(g,["-m","pip","install","-e",y],{cwd:t});}else {e.text="Installing RapidKit from PyPI";let y=false,h=null;for(let c=1;c<=3;c++)try{await execa(g,["-m","pip","install","rapidkit-core"],{cwd:t,timeout:6e4*c}),y=true;break}catch(i){h=i,a$1.debug(`pip install attempt ${c} failed: ${i}`),c<3&&(e.text=`Retrying installation (attempt ${c+1}/3)`,await new Promise(a=>setTimeout(a,2e3)));}if(!y){let c=h?.stderr||h?.message||"Unknown error";throw a$1.debug(`All pip install attempts failed. Last error: ${c}`),c.includes("Could not find")||c.includes("No matching distribution")?new l:new k("Install rapidkit-core with pip",new Error(`Failed to install rapidkit-core after 3 attempts.
156
- Error: ${c}
157
-
158
- Possible solutions:
159
- 1. Check your internet connection
160
- 2. Try installing manually: cd ${m.basename(t)} && ${f(".venv")} -m pip install rapidkit-core
161
- 3. Use Poetry instead: npx rapidkit ${m.basename(t)} --install-method=poetry`))}}e.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:y}=await import('./pythonRapidkitExec-K2SFGAYJ.js');if(!await y()&&!r){e.start("Checking optional global pipx installation");let c=await q(e,true);try{e.start("Installing RapidKit globally with pipx for CLI access"),await F(c,["install","rapidkit-core"]),e.succeed("RapidKit installed globally");}catch(i){e.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),a$1.debug(`pipx install failed: ${i}`);}}}catch(y){e.succeed("Skipped optional global pipx installation"),a$1.debug(`Global install check skipped: ${y}`);}}async function Pt(t,n,e,r,s=false){let d=await q(n,s);if(n.start("Installing RapidKit globally with pipx"),e){let u=d$2(r||{});if(!u)throw new k("Test mode installation",new Error("No local RapidKit path configured. Set RAPIDKIT_DEV_PATH environment variable."));a$1.debug(`Installing from local path: ${u}`),n.text="Installing RapidKit from local path (test mode)",await F(d,["install","-e",u]);}else {n.text="Installing RapidKit from PyPI";try{await F(d,["install","rapidkit-core"]);}catch{throw new l}}n.succeed("RapidKit installed globally"),await v.outputFile(m.join(t,".rapidkit-global"),`RapidKit installed globally with pipx
162
- `,"utf-8");}async function ne(t,n){let{skipGit:e=false,testMode:r=false,userConfig:s={},yes:d=false,installMethod:u,pythonVersion:g="3.10"}=n||{},y=u||s.defaultInstallMethod||await(async()=>{try{return await execa("poetry",["--version"],{timeout:3e3}),"poetry"}catch{return a$1.warn("Poetry not found \u2014 auto-selecting venv. Pass --install-method poetry to override."),"venv"}})(),h=y==="poetry"&&!await wt()?"venv":y;await et(t,m.basename(t),h),await H(t),await nt(t,m.basename(t),h,g,n?.profile);let c=z("Registering workspace").start();try{h==="poetry"?(await ot(t,m.basename(t)),await bt(t,g,c,r,s,d)):h==="venv"?await rt(t,g,c,r,s):await Pt(t,c,r,s,d),await vt(t,h),await xt(t,h),c.succeed("Workspace registered");try{let{registerWorkspace:i}=await import('./workspace-HEHMJ3QC.js');await i(t,m.basename(t));}catch{}if(!e){c.start("Initializing git repository");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");}}}catch(i){throw c.fail("Failed to register workspace"),i}}async function xt(t,n){let e=n==="poetry"?`source $(poetry env info --path)/bin/activate
163
- # Or simply use: poetry run rapidkit <command>`:n==="venv"?"source .venv/bin/activate # On Windows: .venv\\Scripts\\activate":"N/A (globally installed)",r=n==="poetry"?`# No activation needed (recommended):
164
- ./rapidkit --help
165
- # or:
166
- poetry run rapidkit --help`:n==="venv"?`# No activation needed (recommended):
167
- ./rapidkit --help
168
- # or direct:
169
- ./.venv/bin/rapidkit --help`:`# Optional: use the local launcher
170
- ./rapidkit --help
171
- # (pipx installs may require Poetry/venv to be present in this folder)`,s=a$2()?"python --version (or: py -3 --version)":"python3 --version (or: python --version)",d=`# RapidKit Workspace
172
-
173
- This directory contains a RapidKit development environment.
174
-
175
- ## Installation Method
176
-
177
- **${n==="poetry"?"Poetry":n==="venv"?"Python venv + pip":"pipx (global)"}**
178
-
179
- ## Getting Started
180
-
181
- ### 0. Run Without Activation (Recommended)
182
-
183
- This workspace includes a local launcher script so you can run the Python Core CLI without activating the environment:
184
-
185
- \`\`\`bash
186
- ${r}
187
- \`\`\`
188
-
189
- ### 1. Activate Environment
190
-
191
- \`\`\`bash
192
- ${e}
193
- \`\`\`
194
-
195
- ### 2. Create Your First Project
196
-
197
- \`\`\`bash
198
- # Interactive mode (recommended):
199
- rapidkit create
200
- # Follow the prompts to choose kit and project name
201
-
202
- # Or specify directly:
203
- rapidkit create project fastapi.standard my-project
204
-
205
- # With poetry run (no activation needed):
206
- poetry run rapidkit create
207
- \`\`\`
208
-
209
- Interactive mode will guide you through selecting a kit and configuring your project.
210
-
211
- ### 3. Navigate and Run
212
-
213
- \`\`\`bash
214
- cd my-project
215
- # Install dependencies (preferred):
216
- rapidkit init
217
-
218
- # Run the server (project-aware):
219
- rapidkit dev
220
-
221
- # Or with poetry run (manual / advanced):
222
- poetry run rapidkit dev
223
-
224
- # Or manually:
225
- uvicorn src.main:app --reload
226
- \`\`\`
227
-
228
- ### 4. Add Modules (Optional)
229
-
230
- \`\`\`bash
231
- # Add common modules to your project:
232
- rapidkit add module settings
233
- rapidkit add module logging
234
- rapidkit add module database
235
-
236
- # List available modules:
237
- rapidkit modules list
238
- \`\`\`
239
-
240
- ## Available Commands
241
-
242
- - \`rapidkit create\` - Create a new project (interactive)
243
- - \`rapidkit create project <kit> <name>\` - Create project with specific kit
244
- - \`rapidkit dev\` - Run development server
245
- - \`rapidkit add module <name>\` - Add a module (e.g., \`rapidkit add module settings\`)
246
- - \`rapidkit list\` - List available kits
247
- - \`rapidkit modules\` - List available modules
248
- - \`rapidkit upgrade\` - Upgrade RapidKit
249
- - \`rapidkit doctor\` - Check system requirements
250
- - \`rapidkit --help\` - Show all commands
251
-
252
- ## RapidKit Documentation
253
-
254
- For full documentation, visit: [RapidKit Docs](https://getrapidkit.com) *(or appropriate URL)*
255
-
256
- ## Workspace Structure
257
-
258
- \`\`\`
259
- ${n==="venv"?".venv/ # Python virtual environment":""}
260
- ${n==="poetry"?"pyproject.toml # Poetry configuration":""}
261
- my-project/ # Your RapidKit projects go here
262
- README.md # This file
263
- \`\`\`
264
-
265
- ## Troubleshooting
266
-
267
- If you encounter issues:
268
-
269
- 1. Ensure Python 3.10+ is installed: \`${s}\`
270
- 2. Check RapidKit installation: \`rapidkit --version\`
271
- 3. Run diagnostics: \`rapidkit doctor\`
272
- 4. Visit RapidKit documentation or GitHub issues
273
- `;await promises.writeFile(m.join(t,"README.md"),d,"utf-8");}async function Kt(t,n,e){let r=z("Creating demo workspace").start();try{await v.ensureDir(t),r.succeed("Directory created"),r.start("Setting up demo kit generator");let s=JSON.stringify({name:`${n}-workspace`,version:"1.0.0",private:true,description:"RapidKit demo workspace",scripts:{generate:"node generate-demo.js"}},null,2);await promises.writeFile(m.join(t,"package.json"),s,"utf-8"),await promises.writeFile(m.join(t,"generate-demo.js"),`#!/usr/bin/env node
274
- /**
275
- * Demo Kit Generator - Create FastAPI demo projects
276
- *
277
- * This workspace contains bundled RapidKit templates that you can use
278
- * to generate demo projects without installing Python RapidKit.
279
- *
280
- * Usage:
281
- * npm run generate <project-name>
282
- * node generate-demo.js <project-name>
283
- *
284
- * Example:
285
- * npm run generate my-api
286
- */
287
-
288
- const fs = require('fs');
289
- const path = require('path');
290
- const readline = require('readline');
291
-
292
- const projectName = process.argv[2];
293
-
294
- if (!projectName) {
295
- console.error('\\n\u274C Please provide a project name');
296
- console.log('\\nUsage: npm run generate <project-name>\\n');
297
- console.log('Example: npm run generate my-api\\n');
298
- process.exit(1);
299
- }
300
-
301
- const rl = readline.createInterface({
302
- input: process.stdin,
303
- output: process.stdout
304
- });
305
-
306
- function ask(question, defaultValue) {
307
- return new Promise((resolve) => {
308
- rl.question(\`\${question} (\${defaultValue}): \`, (answer) => {
309
- resolve(answer || defaultValue);
310
- });
311
- });
312
- }
313
-
314
- async function main() {
315
- const targetPath = path.join(process.cwd(), projectName);
316
-
317
- if (fs.existsSync(targetPath)) {
318
- console.error(\`\\n\u274C Directory "\${projectName}" already exists\\n\`);
319
- process.exit(1);
320
- }
321
-
322
- console.log(\`\\n\u{1F680} Creating FastAPI project: \${projectName}\\n\`);
323
-
324
- const snakeName = projectName.replace(/-/g, '_').toLowerCase();
325
- const project_name = await ask('Project name (snake_case)', snakeName);
326
- const author = await ask('Author name', process.env.USER || 'RapidKit User');
327
- const description = await ask('Description', 'FastAPI service generated with RapidKit');
328
-
329
- rl.close();
330
-
331
- // Create project structure
332
- const dirs = [
333
- '',
334
- 'src',
335
- 'src/routing',
336
- 'src/modules',
337
- 'tests',
338
- '.rapidkit'
339
- ];
340
-
341
- for (const dir of dirs) {
342
- fs.mkdirSync(path.join(targetPath, dir), { recursive: true });
343
- }
344
-
345
- // Template files with content
346
- const files = {
347
- 'src/__init__.py': '"""' + project_name + ' package."""\\n',
348
- 'src/modules/__init__.py': '"""Modules package."""\\n',
349
- 'tests/__init__.py': '"""Tests package."""\\n',
350
- 'src/main.py': \`"""\${project_name} application entrypoint."""
351
-
352
- from __future__ import annotations
353
-
354
- from contextlib import asynccontextmanager
355
- from typing import AsyncIterator
356
-
357
- from fastapi import FastAPI
358
- from fastapi.middleware.cors import CORSMiddleware
359
-
360
- from .routing import api_router
361
-
362
-
363
- @asynccontextmanager
364
- async def lifespan(app: FastAPI) -> AsyncIterator[None]:
365
- """Application lifespan context manager for startup/shutdown events."""
366
- yield
367
-
368
-
369
- app = FastAPI(
370
- title="\${project_name}",
371
- description="\${description}",
372
- version="0.1.0",
373
- docs_url="/docs",
374
- redoc_url="/redoc",
375
- lifespan=lifespan,
376
- )
377
-
378
- app.add_middleware(
379
- CORSMiddleware,
380
- allow_origins=["*"],
381
- allow_credentials=True,
382
- allow_methods=["*"],
383
- allow_headers=["*"],
384
- )
385
-
386
- app.include_router(api_router, prefix="/api")
387
-
388
-
389
- if __name__ == "__main__":
390
- import uvicorn
391
- uvicorn.run("src.main:app", host="0.0.0.0", port=8001, reload=True)
392
- \`,
393
- 'src/routing/__init__.py': \`"""API routing configuration."""
394
-
395
- from fastapi import APIRouter
396
-
397
- from .health import router as health_router
398
-
399
- api_router = APIRouter()
400
-
401
- api_router.include_router(health_router)
402
- \`,
403
- 'src/routing/health.py': \`"""Health check endpoints."""
404
-
405
- from __future__ import annotations
406
-
407
- from fastapi import APIRouter
408
-
409
- router = APIRouter(prefix="/health", tags=["health"])
410
-
411
-
412
- @router.get("/", summary="Health check")
413
- async def heartbeat() -> dict[str, str]:
414
- """Return basic service heartbeat."""
415
- return {"status": "ok"}
416
- \`,
417
- 'src/cli.py': \`"""CLI commands for \${project_name}."""
418
-
419
- import subprocess
420
- import sys
421
- from pathlib import Path
422
-
423
-
424
- def dev():
425
- """Start development server with hot reload."""
426
- print("\u{1F680} Starting development server...")
427
- subprocess.run([
428
- sys.executable, "-m", "uvicorn",
429
- "src.main:app", "--reload",
430
- "--host", "0.0.0.0", "--port", "8000"
431
- ])
432
-
433
-
434
- def start():
435
- """Start production server."""
436
- print("\u26A1 Starting production server...")
437
- subprocess.run([
438
- sys.executable, "-m", "uvicorn",
439
- "src.main:app",
440
- "--host", "0.0.0.0", "--port", "8000"
441
- ])
442
-
443
-
444
- def test():
445
- """Run tests."""
446
- print("\u{1F9EA} Running tests...")
447
- subprocess.run([sys.executable, "-m", "pytest", "-q"])
448
-
449
-
450
- if __name__ == "__main__":
451
- if len(sys.argv) < 2:
452
- print("Usage: python -m src.cli <command>")
453
- print("Commands: dev, start, test")
454
- sys.exit(1)
455
-
456
- cmd = sys.argv[1]
457
- if cmd == "dev":
458
- dev()
459
- elif cmd == "start":
460
- start()
461
- elif cmd == "test":
462
- test()
463
- else:
464
- print(f"Unknown command: {cmd}")
465
- sys.exit(1)
466
- \`,
467
- 'pyproject.toml': \`[tool.poetry]
468
- name = "\${project_name}"
469
- version = "0.1.0"
470
- description = "\${description}"
471
- authors = ["\${author}"]
472
- license = "MIT"
473
- readme = "README.md"
474
- package-mode = false
475
-
476
- [tool.poetry.dependencies]
477
- python = "^3.10"
478
- fastapi = "^0.128.0"
479
- uvicorn = {extras = ["standard"], version = "^0.40.0"}
480
- pydantic = "^2.12.5"
481
- pydantic-settings = "^2.12.0"
482
-
483
- [tool.poetry.group.dev.dependencies]
484
- pytest = "^9.0.2"
485
- pytest-asyncio = "^1.3.0"
486
- pytest-cov = "^7.0.0"
487
- httpx = "^0.28.1"
488
- black = "^25.12.0"
489
- ruff = "^0.14.10"
490
- mypy = "^1.19.1"
491
-
492
- [tool.poetry.scripts]
493
- dev = "src.cli:dev"
494
- start = "src.cli:start"
495
- test = "src.cli:test"
496
-
497
- [build-system]
498
- requires = ["poetry-core"]
499
- build-backend = "poetry.core.masonry.api"
500
-
501
- [tool.pytest.ini_options]
502
- asyncio_mode = "auto"
503
- testpaths = ["tests"]
504
-
505
- [tool.ruff]
506
- line-length = 100
507
- target-version = "py311"
508
-
509
- [tool.black]
510
- line-length = 100
511
- target-version = ["py311"]
512
- \`,
513
- 'README.md': \`# \${project_name}
514
-
515
- \${description}
516
-
517
- ## Quick start
518
-
519
- \\\`\\\`\\\`bash
520
- npx rapidkit init # Install dependencies
521
- npx rapidkit dev # Start dev server
522
- \\\`\\\`\\\`
523
-
524
- ## Available commands
525
-
526
- \\\`\\\`\\\`bash
527
- npx rapidkit init # \u{1F527} Install dependencies
528
- npx rapidkit dev # \u{1F680} Start development server with hot reload
529
- npx rapidkit start # \u26A1 Start production server
530
- npx rapidkit test # \u{1F9EA} Run tests
531
- npx rapidkit help # \u{1F4DA} Show available commands
532
- \\\`\\\`\\\`
533
-
534
- ## Project layout
535
-
536
- \\\`\\\`\\\`
537
- \${project_name}/
538
- \u251C\u2500\u2500 src/
539
- \u2502 \u251C\u2500\u2500 main.py # FastAPI application
540
- \u2502 \u251C\u2500\u2500 cli.py # CLI commands
541
- \u2502 \u251C\u2500\u2500 routing/ # API routes
542
- \u2502 \u2514\u2500\u2500 modules/ # Module system
543
- \u251C\u2500\u2500 tests/ # Test suite
544
- \u251C\u2500\u2500 pyproject.toml # Poetry configuration
545
- \u2514\u2500\u2500 README.md
546
- \\\`\\\`\\\`
547
- \`,
548
- '.rapidkit/project.json': JSON.stringify({
549
- kit_name: "fastapi.standard",
550
- profile: "fastapi/standard",
551
- created_at: new Date().toISOString(),
552
- rapidkit_version: "npm-demo"
553
- }, null, 2),
554
- '.rapidkit/cli.py': \`#!/usr/bin/env python3
555
- """RapidKit CLI wrapper for demo projects."""
556
-
557
- import subprocess
558
- import sys
559
- from pathlib import Path
560
-
561
-
562
- def dev(port=8000, host="0.0.0.0"):
563
- """Start development server."""
564
- print("\u{1F680} Starting development server with hot reload...")
565
- subprocess.run([
566
- sys.executable, "-m", "uvicorn",
567
- "src.main:app", "--reload",
568
- "--host", host, "--port", str(port)
569
- ])
570
-
571
-
572
- def start(port=8000, host="0.0.0.0"):
573
- """Start production server."""
574
- print("\u26A1 Starting production server...")
575
- subprocess.run([
576
- sys.executable, "-m", "uvicorn",
577
- "src.main:app",
578
- "--host", host, "--port", str(port)
579
- ])
580
-
581
-
582
- def init():
583
- """Install dependencies."""
584
- print("\u{1F4E6} Installing dependencies...")
585
- subprocess.run(["poetry", "install"])
586
-
587
-
588
- def test():
589
- """Run tests."""
590
- print("\u{1F9EA} Running tests...")
591
- subprocess.run([sys.executable, "-m", "pytest", "-q"])
592
-
593
-
594
- def help_cmd():
595
- """Show help."""
596
- print("\u{1F4DA} Available commands:")
597
- print(" init - Install dependencies")
598
- print(" dev - Start dev server")
599
- print(" start - Start production server")
600
- print(" test - Run tests")
601
-
602
-
603
- if __name__ == "__main__":
604
- cmd = sys.argv[1] if len(sys.argv) > 1 else "help"
605
- cmds = {"dev": dev, "start": start, "init": init, "test": test, "help": help_cmd}
606
- cmds.get(cmd, help_cmd)()
607
- \`,
608
- '.rapidkit/rapidkit': '#!/usr/bin/env bash\\n# Local RapidKit launcher for demo projects\\nset -euo pipefail\\nSCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"\\nROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"\\ncd "$ROOT_DIR"\\n\\nif [ -f "pyproject.toml" ]; then\\n if command -v poetry >/dev/null 2>&1; then\\n exec poetry run python "$SCRIPT_DIR/cli.py" "$@"\\n fi\\nfi\\n\\necho "Poetry not found. Install with: pip install poetry"\\nexit 1\\n',
609
- '.gitignore': \`# Python
610
- __pycache__/
611
- *.py[cod]
612
- *.so
613
- .Python
614
- build/
615
- dist/
616
- *.egg-info/
617
-
618
- # Virtual environments
619
- .venv/
620
- venv/
621
-
622
- # IDEs
623
- .vscode/
624
- .idea/
625
-
626
- # OS
627
- .DS_Store
628
-
629
- # Project
630
- .env
631
- .env.local
632
- \`
633
- };
634
-
635
- for (const [filePath, content] of Object.entries(files)) {
636
- fs.writeFileSync(path.join(targetPath, filePath), content);
637
- }
638
-
639
- // Make scripts executable
640
- try {
641
- fs.chmodSync(path.join(targetPath, '.rapidkit/cli.py'), 0o755);
642
- fs.chmodSync(path.join(targetPath, '.rapidkit/rapidkit'), 0o755);
643
- } catch (e) {
644
- // Ignore on Windows
645
- }
646
-
647
- console.log(\`
648
- \u2728 Demo project created successfully!
649
-
650
- \u{1F4C2} Project: \${targetPath}
651
-
652
- \u{1F680} Get started:
653
- cd \${projectName}
654
- npx rapidkit init # Install dependencies
655
- npx rapidkit dev # Start dev server
656
-
657
- \u{1F4DA} Available commands:
658
- npx rapidkit init # \u{1F527} Install dependencies
659
- npx rapidkit dev # \u{1F680} Start dev server with hot reload
660
- npx rapidkit start # \u26A1 Start production server
661
- npx rapidkit test # \u{1F9EA} Run tests
662
- npx rapidkit help # \u{1F4DA} Show help
663
-
664
- \u{1F4A1} For full RapidKit features: pipx install rapidkit
665
- \`);
666
- }
667
-
668
- main().catch(console.error);
669
- `,"utf-8");try{await execa("chmod",["+x",m.join(t,"generate-demo.js")]);}catch{}let u=`# RapidKit Demo Workspace
670
-
671
- Welcome to your RapidKit demo workspace! This environment lets you generate FastAPI demo projects using bundled RapidKit templates, without needing to install Python RapidKit.
672
-
673
- ## \u{1F680} Quick Start
674
-
675
- ### Generate Your First Demo Project
676
-
677
- \`\`\`bash
678
- # Generate a demo project:
679
- node generate-demo.js my-api
680
-
681
- # Navigate to the project:
682
- cd my-api
683
-
684
- # Install dependencies:
685
- rapidkit init
686
-
687
- # Run the development server:
688
- rapidkit dev
689
- \`\`\`
690
-
691
- Your API will be available at \`http://localhost:8000\`
692
-
693
- ## \u{1F4E6} Generate Multiple Projects
694
-
695
- You can create multiple demo projects in this workspace:
696
-
697
- \`\`\`bash
698
- node generate-demo.js api-service
699
- node generate-demo.js auth-service
700
- node generate-demo.js data-service
701
- \`\`\`
702
-
703
- Each project is independent and has its own dependencies.
704
-
705
- ## \u{1F3AF} What's Included
706
-
707
- Each generated demo project contains:
708
-
709
- - **FastAPI Application** - Modern async web framework
710
- - **Routing System** - Organized API routes
711
- - **Module System** - Extensible module architecture
712
- - **CLI Commands** - Built-in command system
713
- - **Testing Setup** - pytest configuration
714
- - **Poetry Configuration** - Dependency management
715
-
716
- ## \u{1F4DA} Next Steps
717
-
718
- 1. **Explore the Generated Code** - Check out \`src/main.py\` and \`src/routing/\`
719
- 2. **Add Routes** - Create new endpoints in \`src/routing/\`
720
- 3. **Install Full RapidKit** - For advanced features: \`pipx install rapidkit\`
721
- 4. **Read the Documentation** - Visit [RapidKit Docs](https://getrapidkit.com)
722
-
723
- ## \u26A0\uFE0F Demo Mode Limitations
724
-
725
- This is a demo workspace with:
726
- - \u2705 Pre-built FastAPI templates
727
- - \u2705 Project generation without Python RapidKit
728
- - \u274C No RapidKit CLI commands (\`rapidkit create\`, \`rapidkit add module\`)
729
- - \u274C No interactive module system
730
-
731
- For full RapidKit features, install the Python package:
732
-
733
- \`\`\`bash
734
- pipx install rapidkit
735
- \`\`\`
736
-
737
- ## \u{1F6E0}\uFE0F Workspace Structure
738
-
739
- \`\`\`
740
- ${n}/
741
- \u251C\u2500\u2500 generate-demo.js # Demo project generator
742
- \u251C\u2500\u2500 README.md # This file
743
- \u2514\u2500\u2500 my-api/ # Your generated projects go here
744
- \`\`\`
745
-
746
- ## \u{1F4A1} Tips
747
-
748
- - Run \`node generate-demo.js --help\` for more options (coming soon)
749
- - Each project can have different configurations
750
- - Demo projects are production-ready FastAPI applications
751
- - You can copy and modify templates as needed
752
-
753
- ---
754
-
755
- **Generated with RapidKit** | [GitHub](https://github.com/getrapidkit/rapidkit-npm)
756
- `;if(await promises.writeFile(m.join(t,"README.md"),u,"utf-8"),r.succeed("Demo workspace setup complete"),!e){r.start("Initializing git repository");try{await execa("git",["init"],{cwd:t}),await v.outputFile(m.join(t,".gitignore"),`# Dependencies
757
- node_modules/
758
-
759
- # Generated projects
760
- */
761
- !generate-demo.js
762
- !README.md
763
-
764
- # Python
765
- __pycache__/
766
- *.pyc
767
- .venv/
768
- .env
769
- `,"utf-8"),await execa("git",["add","."],{cwd:t}),await execa("git",["commit","-m","Initial commit: Demo workspace"],{cwd:t}),r.succeed("Git repository initialized");}catch{r.warn("Could not initialize git repository");}}console.log(o.green(`
770
- \u2728 Demo workspace created successfully!
771
- `)),console.log(o.cyan("\u{1F4C2} Location:"),o.white(t)),console.log(o.cyan(`\u{1F680} Get started:
772
- `)),console.log(o.white(` cd ${n}`)),console.log(o.white(" node generate-demo.js my-api")),console.log(o.white(" cd my-api")),console.log(o.white(" rapidkit init")),console.log(o.white(" rapidkit dev")),console.log(),console.log(o.yellow("\u{1F4A1} Note:"),"This is a demo workspace. For full RapidKit features:"),console.log(o.cyan(" pipx install rapidkit")),console.log();}catch(s){throw r.fail("Failed to create demo workspace"),s}}async function Ft(t,n,e,r){console.log(o.cyan(`
773
- \u{1F50D} Dry-run mode - showing what would be created:
774
- `)),console.log(o.white("\u{1F4C2} Project path:"),t),console.log(o.white("\u{1F4E6} Project type:"),e?"Demo workspace":"Full RapidKit environment"),e?(console.log(o.white(`
775
- \u{1F4DD} Files to create:`)),console.log(o.gray(" - package.json")),console.log(o.gray(" - generate-demo.js (project generator)")),console.log(o.gray(" - README.md")),console.log(o.gray(" - .gitignore")),console.log(o.white(`
776
- \u{1F3AF} Capabilities:`)),console.log(o.gray(" - Generate multiple FastAPI demo projects")),console.log(o.gray(" - No Python RapidKit installation required")),console.log(o.gray(" - Bundled templates included"))):(console.log(o.white(`
777
- \u2699\uFE0F Configuration:`)),console.log(o.gray(` - Python version: ${r.pythonVersion||"3.10"}`)),console.log(o.gray(` - Install method: ${r.defaultInstallMethod||"poetry"}`)),console.log(o.gray(` - Git initialization: ${r.skipGit?"No":"Yes"}`)),console.log(o.white(`
778
- \u{1F4DD} Files to create:`)),console.log(o.gray(" - pyproject.toml (Poetry) or .venv/ (venv)")),console.log(o.gray(" - README.md")),console.log(o.gray(" - .gitignore")),console.log(o.white(`
779
- \u{1F3AF} Next steps after creation:`)),console.log(o.gray(" 1. Install RapidKit Python package")),console.log(o.gray(" 2. Create projects with rapidkit CLI")),console.log(o.gray(" 3. Add modules and customize"))),console.log(o.white(`
780
- \u{1F4A1} To proceed with actual creation, run without --dry-run flag
781
- `));}export{oe as createProject,ne as registerWorkspaceAtPath,ee as syncWorkspaceFoundationFiles,vt as writeWorkspaceLauncher};