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