rapidkit 0.23.1 → 0.24.2

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