rapidkit 0.25.4 → 0.25.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,776 @@
1
+ import {i,d as d$2,l,k,f as f$1,g,h}from'./chunk-ZAZJEYYT.js';import {a as a$2,e,d as d$1,f,c,k as k$1}from'./chunk-Z5LKRG57.js';import {a,d,b as b$1}from'./chunk-RV6HBTFC.js';import {b}from'./chunk-Q7ULIFQA.js';import {a as a$1}from'./chunk-VM2TOHNX.js';import {promises}from'fs';import*as v from'fs-extra';import m from'path';import U from'inquirer';import o from'chalk';import z from'ora';import {execa}from'execa';function C(){return c()}async function et(t,n,e,r){let s=d(n,b(),e);r&&(s.metadata||(s.metadata={}),s.metadata.python={version:r}),await b$1(t,s);}async function H(t){await v.outputFile(m.join(t,".gitignore"),`.venv/
2
+ __pycache__/
3
+ *.pyc
4
+ .env
5
+ .rapidkit-workspace/
6
+
7
+ `,"utf-8");}async function ot(t,n){let e=n.replace(/[^a-z0-9-]/gi,"-").toLowerCase();await v.outputFile(m.join(t,"poetry.toml"),`[virtualenvs]
8
+ in-project = true
9
+ `,"utf-8"),await v.outputFile(m.join(t,"pyproject.toml"),`[tool.poetry]
10
+ name = "${e}"
11
+ version = "0.1.0"
12
+ description = "RapidKit workspace"
13
+ authors = []
14
+ package-mode = false
15
+
16
+ [tool.poetry.dependencies]
17
+ python = "^3.10"
18
+ rapidkit-core = "*"
19
+
20
+ [build-system]
21
+ requires = ["poetry-core"]
22
+ build-backend = "poetry.core.masonry.api"
23
+ `,"utf-8");}function mt(t,n,e,r){return JSON.stringify({schema_version:"1.0",workspace_name:t,rapidkit_version:b(),created_at:new Date().toISOString(),created_by:"rapidkit-npm",profile:r||"minimal",engine:{install_method:n,python_version:e||null}},null,2)}function yt(t,n,e,r){return JSON.stringify({schema_version:"1.0",generated_by:"rapidkit-npm",generated_at:new Date().toISOString(),runtime:{python:{version:n||null,install_method:t},node:{version:e||process.version},go:{version:r||null}}},null,2)}function gt(){return `version: "1.0"
24
+ mode: warn # "warn" or "strict"
25
+ dependency_sharing_mode: isolated # "isolated" or "shared-runtime-caches" or "shared-node-deps"
26
+ # change profile (recommended): npx rapidkit bootstrap --profile polyglot
27
+ # change mode/dependency manually: edit this file and rerun npx rapidkit init
28
+ rules:
29
+ enforce_workspace_marker: true
30
+ enforce_toolchain_lock: false
31
+ disallow_untrusted_tool_sources: false
32
+ `}function ht(){return `version: "1.0"
33
+ cache:
34
+ strategy: shared # "shared" or "on-demand"
35
+ prune_on_bootstrap: false
36
+ self_heal: true
37
+ verify_integrity: false
38
+ `}async function nt(t,n,e,r,s){let d;try{let{stdout:u}=await execa("go",["version"],{timeout:3e3,stdio:"pipe"}),g=u.match(/go(\d+\.\d+(?:\.\d+)?)/i);d=g?g[1]:void 0;}catch{}await v.outputFile(m.join(t,".rapidkit","workspace.json"),mt(n,e,r,s),"utf-8"),await v.outputFile(m.join(t,".rapidkit","toolchain.lock"),yt(e,r,process.version,d),"utf-8"),await v.outputFile(m.join(t,".rapidkit","policies.yml"),gt(),"utf-8"),await v.outputFile(m.join(t,".rapidkit","cache-config.yml"),ht(),"utf-8");}async function ee(t,n){let{workspaceName:e=m.basename(t),installMethod:r="venv",pythonVersion:s,profile:d$1,writeMarker:u=true,writeGitignore:g=true,onlyIfMissing:y=true}=n||{},h=[],c;try{let{stdout:a}=await execa("go",["version"],{timeout:3e3,stdio:"pipe"}),p=a.match(/go(\d+\.\d+(?:\.\d+)?)/i);c=p?p[1]:void 0;}catch{}let i=[{relPath:m.join(".rapidkit","workspace.json"),content:mt(e,r,s,d$1)},{relPath:m.join(".rapidkit","toolchain.lock"),content:yt(r,s,process.version,c)},{relPath:m.join(".rapidkit","policies.yml"),content:gt()},{relPath:m.join(".rapidkit","cache-config.yml"),content:ht()}];for(let a of i){let p=m.join(t,a.relPath);y&&await v.pathExists(p)||(await v.outputFile(p,a.content,"utf-8"),h.push(a.relPath));}if(u&&(!!!await a(t)||!y)){let p=d(e,b(),r);s&&(p.metadata||(p.metadata={}),p.metadata.python={version:s}),await b$1(t,p),h.push(".rapidkit-workspace");}if(g){let a=m.join(t,".gitignore");(!y||!await v.pathExists(a))&&(await H(t),h.push(".gitignore"));}return h}var A="3.10",ft=["3.10","3.11","3.12"];async function pt(t){try{let{stdout:n}=await execa(t,["--version"],{timeout:3e3}),e=n.match(/Python (\d+\.\d+\.\d+)/);if(e)return e[1]}catch{}return null}async function jt(t,n){try{await promises.writeFile(m.join(t,".python-version"),`${n}
39
+ `,"utf-8"),a$1.debug(`Created .python-version with ${n}`);}catch(e){a$1.warn(`Failed to create .python-version: ${e}`);}}function D(){let e=[...(process.env.PATH||"").split(m.delimiter).filter(Boolean)];for(let r of k$1())e.includes(r)||e.unshift(r);process.env.PATH=e.join(m.delimiter);}async function q(t,n){D(),t.start("Checking pipx installation");try{return await execa("pipx",["--version"]),t.succeed("pipx found"),{kind:"binary"}}catch{}let e=C();try{return await execa(e,["-m","pipx","--version"]),t.succeed("pipx found"),{kind:"python-module",pythonCmd:e}}catch{}if(n)throw new h;t.stop?.();let{installPipx:r}=await U.prompt([{type:"confirm",name:"installPipx",message:"pipx is not installed. Install it now (user install via python -m pip)?",default:true}]);if(!r)throw new h;t.start("Installing pipx (user install)");try{try{await execa(e,["-m","pip","install","--user","--upgrade","pip"]);}catch{}await execa(e,["-m","pip","install","--user","--upgrade","pipx"]);}catch(s){let d=s,u=String(d?.stderr||d?.shortMessage||d?.message||"");throw new k("Install pipx with python -m pip",s instanceof Error?s:new Error(u))}t.succeed("pipx installed"),D();try{return await execa(e,["-m","pipx","--version"]),{kind:"python-module",pythonCmd:e}}catch(s){let d=s,u=String(d?.stderr||d?.shortMessage||d?.message||"pipx not runnable after install");throw new k("Verify pipx after install",new Error(`${u}
40
+
41
+ Try reopening your terminal or run: ${e} -m pipx ensurepath`))}}async function F(t,n){return t.kind==="binary"?execa("pipx",n):execa(t.pythonCmd,["-m","pipx",...n])}function Et(t){let n=t.match(/^(\d+)\.(\d+)/);return n?`${n[1]}.${n[2]}`:null}function ut(t){if(!t)return null;let n=t.match(/Python\s+(\d+)\.(\d+)(?:\.\d+)?/i);return n?`${n[1]}.${n[2]}`:null}function it(t,n){let[e,r]=t.split(".").map(u=>Number(u)),[s,d]=n.split(".").map(u=>Number(u));return e!==s?e-s:r-d}function K(t,n){return it(t,n)>=0}async function Ct(t){let n=new Set,e$1=e(14,10);for(let i of e$1)try{let a=await execa(i.command,i.args,{timeout:2500}),p=ut(`${a.stdout||""}
42
+ ${a.stderr||""}`);p&&K(p,A)&&n.add(p);}catch{}let r=null;try{let i=await execa(C(),["--version"],{timeout:2500}),a=ut(`${i.stdout||""}
43
+ ${i.stderr||""}`);a&&K(a,A)&&(r=a,n.add(a));}catch{}let s=ft.filter(i=>K(i,A)),d=new Set([...s,...n]),u=Array.from(d).sort((i,a)=>it(a,i)),g=t?Et(t):null,y=g&&K(g,A)?g:r||u[0]||A;return d.has(y)||d.add(y),{choices:Array.from(d).sort((i,a)=>it(a,i)).map(i=>{let a=[];return i===r&&a.push("current system"),i===A&&a.push("minimum supported"),n.has(i)&&i!==r&&a.push("detected"),{name:a.length>0?`${i} (${a.join(", ")})`:i,value:i}}),defaultValue:y}}async function $t(){D();let t=false,n=false;try{await execa("poetry",["--version"],{timeout:2500}),t=true;}catch{t=false;}try{await execa("pipx",["--version"],{timeout:2500}),n=true;}catch{let e=c();try{await execa(e,["-m","pipx","--version"],{timeout:2500}),n=true;}catch{n=false;}}return {poetry:t,pipx:n}}async function wt(){D();try{return await execa("poetry",["--version"],{timeout:2500}),true}catch{return false}}function Mt(t,n){return t==="poetry"&&n.poetry?"poetry":t==="pipx"&&n.pipx?"pipx":t==="venv"?"venv":n.poetry?"poetry":"venv"}async function St(t,n){D(),t.start("Checking Poetry installation");try{await execa("poetry",["--version"]),t.succeed("Poetry found");return}catch{}if(n)throw new g;let{installPoetry:e}=await U.prompt([{type:"confirm",name:"installPoetry",message:"Poetry is not installed. Install it now using pipx?",default:true}]);if(!e)throw new g;let r=await q(t,n);t.start("Installing Poetry with pipx");try{await F(r,["install","poetry"]);}catch(s){let d=s,u=String(d?.stderr||d?.shortMessage||d?.message||"");if(/already\s+installed|already\s+seems\s+to\s+be\s+installed|exists/i.test(u))try{await F(r,["upgrade","poetry"]);}catch{}else throw new k("Install Poetry with pipx",s instanceof Error?s:new Error(u))}t.succeed("Poetry installed"),D();try{await execa("poetry",["--version"]);}catch(s){let d=s,u=String(d?.stderr||d?.shortMessage||d?.message||"Poetry not found on PATH");throw new k("Verify Poetry after pipx install",new Error(`${u}
44
+
45
+ Poetry may be installed but not on PATH yet. Try reopening your terminal or run: pipx ensurepath`))}}function At(t){let n=t==="poetry";return `#!/usr/bin/env sh
46
+ set -eu
47
+
48
+ SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
49
+
50
+ VENV_RAPIDKIT="$SCRIPT_DIR/.venv/bin/rapidkit"
51
+ if [ -x "$VENV_RAPIDKIT" ]; then
52
+ exec "$VENV_RAPIDKIT" "$@"
53
+ fi
54
+
55
+ ${n?`if command -v poetry >/dev/null 2>&1 && [ -f "$SCRIPT_DIR/pyproject.toml" ]; then
56
+ exec poetry run rapidkit "$@"
57
+ fi
58
+
59
+ `:""}echo "RapidKit launcher could not find a local Python CLI." 1>&2
60
+ echo "- If you used venv: ensure .venv exists (or re-run the installer)." 1>&2
61
+ ${n?`echo "- If you used Poetry: run 'poetry install' and retry, or activate the env." 1>&2
62
+ `:""}echo "Tip: you can also run: ./.venv/bin/rapidkit --help" 1>&2
63
+ exit 1
64
+ `}function Dt(t){return `@echo off
65
+ setlocal
66
+
67
+ set "SCRIPT_DIR=%~dp0"
68
+
69
+ if exist "%SCRIPT_DIR%\\.venv\\Scripts\\rapidkit.exe" (
70
+ "%SCRIPT_DIR%\\.venv\\Scripts\\rapidkit.exe" %*
71
+ exit /b %ERRORLEVEL%
72
+ )
73
+
74
+ ${t==="poetry"?`where poetry >nul 2>nul
75
+ if %ERRORLEVEL%==0 if exist "%SCRIPT_DIR%\\pyproject.toml" (
76
+ poetry run rapidkit %*
77
+ exit /b %ERRORLEVEL%
78
+ )
79
+
80
+ `:""}echo RapidKit launcher could not find a local Python CLI. 1>&2
81
+ echo Tip: run .venv\\Scripts\\rapidkit.exe --help 1>&2
82
+ exit /b 1
83
+ `}async function vt(t,n){await v.outputFile(m.join(t,"rapidkit"),At(n),{encoding:"utf-8",mode:493}),await v.outputFile(m.join(t,"rapidkit.cmd"),Dt(n),"utf-8");}async function oe(t,n){let{skipGit:e=false,testMode:r=false,demoMode:s=false,dryRun:d=false,yes:u=false,userConfig:g={},installMethod:y,profile:h}=n,c=t||"rapidkit",i$1=m.resolve(process.cwd(),c);if(await v.pathExists(i$1))throw new i(c);if(d){await Ft(i$1,c,s,g);return}if(s){await Kt(i$1,c,e);return}let a=new Set(["python-only","polyglot","enterprise"]),p=h||"";if(!u&&!h){let{selectedProfile:f}=await U.prompt([{type:"rawlist",name:"selectedProfile",message:"Select workspace profile:",choices:[{name:"minimal \u2014 Foundation files only (fastest bootstrap, mixed projects)",value:"minimal"},{name:"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}]);p=f;}else p||(p="minimal");let b=!u&&a.has(p),E=typeof g.pythonVersion=="string"&&g.pythonVersion.trim().length>0?g.pythonVersion.trim():void 0,M=y||g.defaultInstallMethod||"poetry",I=b?await $t():{poetry:true,pipx:true},T=b?await Ct(E):{choices:ft.map(f=>({name:f,value:f})),defaultValue:A},Y=Mt(M,I),It=[{name:I.poetry?"\u{1F3AF} Poetry (Recommended - includes virtual env)":"\u{1F3AF} Poetry (Recommended - includes virtual env) \u2014 not detected (we can install it)",value:"poetry"},{name:"\u{1F4E6} pip with venv (Standard, zero extra tools)",value:"venv"},{name:I.pipx?"\u{1F527} pipx (Global isolated install)":"\u{1F527} pipx (Global isolated install) \u2014 not detected (we can install it)",value:"pipx"}],x=b?await U.prompt([{type:"rawlist",name:"pythonVersion",message:"Select Python version for RapidKit:",choices:T.choices,default:T.defaultValue},{type:"rawlist",name:"installMethod",message:"How would you like to manage the workspace environment?",choices:It,default:Y}]):await(async()=>{let f=y||g.defaultInstallMethod||await(async()=>{try{return await execa("poetry",["--version"],{timeout:3e3}),"poetry"}catch{return a$1.warn("Poetry not found \u2014 auto-selecting venv. Pass --install-method poetry to override."),"venv"}})();return {pythonVersion:g.pythonVersion||"3.10",installMethod:f}})();if(new Set(["go-only","node-only","minimal"]).has(p)){let f=z("Creating workspace").start();try{await v.ensureDir(i$1),f.succeed("Directory created"),await et(i$1,c,"venv",void 0),await nt(i$1,c,"venv",void 0,p),await H(i$1),await ot(i$1,c);let R={"go-only":"Go-only","node-only":"Node.js-only",minimal:"Minimal"};if(await v.outputFile(m.join(i$1,"README.md"),`# ${c}
84
+
85
+ RapidKit **${R[p]}** workspace.
86
+
87
+ ## Quick start
88
+
89
+ \`\`\`bash
90
+ `+(p==="go-only"?`npx rapidkit create project gofiber.standard my-api
91
+ cd my-api
92
+ npx rapidkit init
93
+ npx rapidkit dev
94
+ `:p==="node-only"?`npx rapidkit create project nestjs.standard my-app
95
+ cd my-app
96
+ npx rapidkit init
97
+ npx rapidkit dev
98
+ `:`npx rapidkit create project
99
+ cd <project-name>
100
+ npx rapidkit init
101
+ npx rapidkit dev
102
+ `)+"```\n","utf-8"),!e){f.start("Initializing git repository");try{await execa("git",["init"],{cwd:i$1}),await execa("git",["add","."],{cwd:i$1}),await execa("git",["commit","-m","Initial commit: RapidKit workspace"],{cwd:i$1}),f.succeed("Git repository initialized");}catch{f.warn("Could not initialize git repository");}}try{let{registerWorkspace:k}=await import('./workspace-VXNLNKCM.js');await k(i$1,c);}catch{}if(console.log(o.green(`
103
+ \u2728 Workspace created!
104
+ `)),console.log(o.cyan("\u{1F4C2} Location:"),o.white(i$1)),console.log(o.cyan(`
105
+ \u{1F680} Get started:
106
+ `)),console.log(o.white(` cd ${c}`)),p==="go-only"){console.log(o.white(" npx rapidkit create project gofiber.standard my-api")),console.log(o.white(" cd my-api")),console.log(o.white(" npx rapidkit init")),console.log(o.white(` npx rapidkit dev
107
+ `)),console.log(o.gray("\u{1F4A1} No Python required \u2014 Go kits run entirely through the npm package."));try{let{stdout:k}=await execa("go",["version"],{timeout:3e3}),_=k.match(/go version go(\d+\.\d+(?:\.\d+)?)/),S=_?_[1]:"unknown";console.log(o.gray(`\u{1F439} Go ${S} detected \u2014 ready for gofiber.standard / gogin.standard projects`));}catch{console.log(o.yellow(`
108
+ \u26A0\uFE0F Go is not installed \u2014 install it from https://go.dev/dl/`));}}else p==="node-only"?(console.log(o.white(" npx rapidkit create project nestjs.standard my-app")),console.log(o.white(" cd my-app")),console.log(o.white(" npx rapidkit init")),console.log(o.white(` npx rapidkit dev
109
+ `)),console.log(o.gray("\u{1F4A1} Python engine will be installed automatically on first `create project nestjs.standard`."))):(console.log(o.white(" npx rapidkit create project")),console.log(o.white(" cd <project-name>")),console.log(o.white(" npx rapidkit init")),console.log(o.white(` npx rapidkit dev
110
+ `)),console.log(o.gray("\u{1F4A1} Bootstrap a specific runtime any time: rapidkit bootstrap --profile python-only|node-only|go-only")));console.log("");}catch(R){throw f.fail("Failed to create workspace"),console.error(o.red(`
111
+ \u274C Error:`),R),R}return}{let f=C(),R=false;try{await execa(f,["--version"],{timeout:5e3}),R=true;}catch{try{await execa("python",["--version"],{timeout:5e3}),R=true;}catch{R=false;}}R||(console.log(o.red(`
112
+ \u274C Python 3.10+ is required for the "${p}" profile.
113
+ `)),console.log(o.cyan(`\u{1F4A1} How to install Python:
114
+ `)),console.log(o.white(" Ubuntu / Debian: sudo apt install python3.10")),console.log(o.white(" macOS (Homebrew): brew install python@3.10")),console.log(o.white(` Windows: https://python.org/downloads
115
+ `)),console.log(o.gray(` After installing Python, run: npx rapidkit ${c}
116
+ `)),process.exit(1));}a$1.step(1,3,"Setting up RapidKit environment");let P=z("Creating directory").start();try{await v.ensureDir(i$1),P.succeed("Directory created"),P.start("Detecting Python version");let f=null,R=await kt(x.pythonVersion);if(R)f=await pt(R),f?(a$1.info(` Detected Python ${f}`),P.succeed(`Python ${f} detected`)):P.warn("Could not detect exact Python version");else {let k=C();f=await pt(k),f?P.succeed(`Python ${f} detected`):P.warn("Could not detect Python version, proceeding with defaults");}if(x.installMethod==="poetry"&&!await wt()&&(P.warn("Poetry not found \u2014 auto-fallback to pip + venv"),x.installMethod="venv"),await et(i$1,c,x.installMethod,f||void 0),f&&await jt(i$1,f),await nt(i$1,c,x.installMethod,f||x.pythonVersion,p||h),await H(i$1),await ot(i$1,c),x.installMethod==="poetry")try{await bt(i$1,x.pythonVersion,P,r,g,u);}catch(k){let _=k?.details||k?.message||String(k);if(_.includes("pyenv")||_.includes("exit status 127")||_.includes("returned non-zero exit status 127")){P.warn("Poetry encountered Python discovery issues, trying venv method"),a$1.debug(`Poetry error (attempting venv fallback): ${_}`);try{await rt(i$1,x.pythonVersion,P,r,g),x.installMethod="venv";}catch(at){throw at}}else throw k}else x.installMethod==="venv"?await rt(i$1,x.pythonVersion,P,r,g):await Pt(i$1,P,r,g,u);if(await vt(i$1,x.installMethod),await xt(i$1,x.installMethod),P.succeed("RapidKit environment ready!"),!n.skipGit){P.start("Initializing git repository");try{await execa("git",["init"],{cwd:i$1}),await execa("git",["add","."],{cwd:i$1}),await execa("git",["commit","-m","Initial commit: RapidKit environment"],{cwd:i$1}),P.succeed("Git repository initialized");}catch{P.warn("Could not initialize git repository");}}try{let{registerWorkspace:k}=await import('./workspace-VXNLNKCM.js');await k(i$1,c);}catch{console.warn(o.gray("Note: Could not register workspace in shared registry"));}if(console.log(o.green(`
117
+ \u2728 RapidKit environment created successfully!
118
+ `)),console.log(o.cyan("\u{1F4C2} Location:"),o.white(i$1)),console.log(o.cyan(`\u{1F680} Get started:
119
+ `)),console.log(o.white(` cd ${c}`)),x.installMethod==="poetry"){let k="source $(poetry env info --path)/bin/activate";try{D();let{stdout:_}=await execa("poetry",["--version"]),S=_.match(/Poetry.*?(\d+)\.(\d+)/);S&&(parseInt(S[1])>=2?k="source $(poetry env info --path)/bin/activate":k="poetry shell");}catch{}console.log(o.white(` ${k} # Or: poetry run rapidkit`)),console.log(o.white(" rapidkit create # Interactive mode")),console.log(o.white(" cd <project-name>")),console.log(o.white(" rapidkit init")),console.log(o.white(" rapidkit dev"));}else x.installMethod==="venv"?(console.log(o.white(" source .venv/bin/activate # On Windows: .venv\\Scripts\\activate")),console.log(o.white(" rapidkit create # Interactive mode")),console.log(o.white(" cd <project-name>")),console.log(o.white(" rapidkit init")),console.log(o.white(" rapidkit dev"))):(console.log(o.white(" rapidkit create # Interactive mode")),console.log(o.white(" cd <project-name>")),console.log(o.white(" rapidkit init")),console.log(o.white(" rapidkit dev")));console.log(o.white(`
120
+ \u{1F4A1} For more information, check the README.md file.`)),console.log(o.cyan(`
121
+ \u{1F4DA} RapidKit commands:`)),console.log(o.white(" rapidkit create - Create a new project (interactive)")),console.log(o.white(" rapidkit dev - Run development server")),console.log(o.white(" rapidkit add module <name> - Add a module (e.g., settings)")),console.log(o.white(" rapidkit list - List available kits")),console.log(o.white(" rapidkit modules - List available modules")),console.log(o.white(` rapidkit --help - Show all commands
122
+ `));try{let{stdout:k}=await execa("go",["version"],{timeout:3e3}),_=k.match(/go version go(\d+\.\d+(?:\.\d+)?)/),S=_?_[1]:"unknown";console.log(o.gray(`\u{1F439} Go toolchain: Go ${S} detected \u2014 ready for gofiber.standard projects`));}catch{console.log(o.yellow("\u26A0\uFE0F Go toolchain not installed \u2014 needed for gofiber.standard projects")),console.log(o.gray(" Install: https://go.dev/dl/"));}console.log("");}catch(f){P.fail("Failed to create RapidKit environment"),console.error(o.red(`
123
+ \u274C Error:`),f);try{await v.remove(i$1);}catch{}throw f}}async function kt(t){let n=[];if(!a$2())try{let{stdout:d}=await execa("pyenv",["which","python"]),u=d.trim();u&&n.push(u);}catch{}let e$1=Number(t.split(".")[1]),r=e(e$1,10).map(d=>d.command).filter(Boolean);n.push(`python${t}`,...r,...d$1());let s=[...new Set(n)];for(let d of s)try{let u=d==="py"?["-3","--version"]:["--version"],g=d==="py"?["-3","-c","import sys; sys.exit(0)"]:["-c","import sys; sys.exit(0)"],{stdout:y}=await execa(d,u,{timeout:2e3}),h=y.match(/Python (\d+\.\d+)/)?.[1];if(h&&K(h,t))return await execa(d,g,{timeout:2e3}),d}catch{continue}return null}async function bt(t,n,e,r,s,d=false){await St(e,d),e.start("Finding Python interpreter");let u=await kt(n);u?(a$1.debug(`Found working Python: ${u}`),e.succeed("Python found")):e.warn("Could not verify Python path, proceeding with default"),e.start("Initializing Poetry project");let g=m.join(t,"pyproject.toml"),h=(await v.pathExists(g)?await promises.readFile(g,"utf-8"):"").includes("rapidkit-core");if(h)e.succeed("Poetry project initialized");else {await execa("poetry",["init","--no-interaction","--python",`^${n}`],{cwd:t}),e.succeed("Poetry project initialized");let p=await promises.readFile(g,"utf-8");p.includes("[tool.poetry]")?p=p.replace("[tool.poetry]",`[tool.poetry]
124
+ package-mode = false`):p.includes("[project]")&&(p.includes("[build-system]")?p=p.replace("[build-system]",`
125
+ [tool.poetry]
126
+ package-mode = false
127
+
128
+ [build-system]`):p+=`
129
+
130
+ [tool.poetry]
131
+ package-mode = false
132
+ `),await promises.writeFile(g,p,"utf-8");}e.start("Configuring Poetry");try{await execa("poetry",["config","virtualenvs.in-project","true","--local"],{cwd:t}),e.succeed("Poetry configured");}catch{e.warn("Could not configure Poetry virtualenvs.in-project");}e.start("Creating virtualenv");let c=u||C(),i=f(m.join(t,".venv"));try{await execa(c,["-m","venv",".venv"],{cwd:t,timeout:6e4}),e.succeed("Virtualenv created");}catch(a){a$1.debug(`python -m venv failed: ${a}`),e.warn("Could not pre-create virtualenv, Poetry will try"),i=u||C();}try{await execa("poetry",["env","use",i||C()],{cwd:t}),a$1.debug(`Poetry env set to: ${i}`);}catch(a){a$1.debug(`Could not set Poetry env: ${a}`);}if(e.start("Installing RapidKit"),h&&!r){let a=d$2(s||{}),p=a?await v.pathExists(a):false,b=p&&a?a:"rapidkit-core";a&&!p&&a$1.warn(`RAPIDKIT_DEV_PATH is set but path does not exist: ${a}. Falling back to PyPI.`),e.text=p?"Installing RapidKit from local path":"Installing RapidKit from PyPI";let E=false,M=null;for(let I=1;I<=3;I++)try{await execa(i,["-m","pip","install",b,"--quiet"],{cwd:t,timeout:18e4}),E=true;break}catch(T){M=T,a$1.debug(`pip install rapidkit-core attempt ${I} failed: ${T}`),I<3&&(e.text=`Retrying installation (attempt ${I+1}/3)`,await new Promise(Y=>setTimeout(Y,2e3)));}if(!E){let I=M?.stderr||M?.message||"Unknown error";throw a$1.debug(`All pip install attempts failed. Last error: ${I}`),I.includes("Could not find")||I.includes("No matching distribution")?new l:new k("Install rapidkit-core with pip",new Error(`Failed to install rapidkit-core after 3 attempts.
133
+ Error: ${I}
134
+
135
+ Possible solutions:
136
+ 1. Check your internet connection
137
+ 2. Try installing manually: cd ${m.basename(t)} && poetry add rapidkit-core
138
+ 3. Use venv method instead: npx rapidkit ${m.basename(t)} --install-method=venv`))}}else {e.text="Syncing Poetry environment";try{await execa("poetry",["install","--no-root"],{cwd:t,timeout:12e4}),e.succeed("Poetry environment synced");}catch(a){a$1.debug(`poetry install --no-root failed: ${a}`),e.warn("Could not sync Poetry environment, proceeding with add command");}if(e.start("Installing RapidKit"),r){let a=d$2(s||{});if(!a)throw new k("Test mode installation",new Error("No local RapidKit path configured. Set RAPIDKIT_DEV_PATH environment variable."));a$1.debug(`Installing from local path: ${a}`),e.text="Installing RapidKit from local path (test mode)",await execa("poetry",["add",a],{cwd:t});}else {e.text="Installing RapidKit from PyPI";let a=false,p=null;for(let b=1;b<=3;b++)try{await execa("poetry",["add","rapidkit-core"],{cwd:t,timeout:6e4*b}),a=true;break}catch(E){p=E,a$1.debug(`Poetry add attempt ${b} failed: ${E}`),b<3&&(e.text=`Retrying installation (attempt ${b+1}/3)`,await new Promise(M=>setTimeout(M,2e3)));}if(!a){let b=p?.stderr||p?.message||"Unknown error";throw a$1.debug(`All Poetry install attempts failed. Last error: ${b}`),b.includes("Could not find")||b.includes("No matching distribution")?new l:new k("Install rapidkit-core with Poetry",new Error(`Failed to install rapidkit-core after 3 attempts.
139
+ Error: ${b}
140
+
141
+ Possible solutions:
142
+ 1. Check your internet connection
143
+ 2. Try installing manually: cd ${m.basename(t)} && poetry add rapidkit-core
144
+ 3. Use venv method instead: npx rapidkit ${m.basename(t)} --install-method=venv`))}}}e.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:a}=await import('./pythonRapidkitExec-K2SFGAYJ.js');if(!await a()&&!r){e.start("Checking optional global pipx installation");let b=await q(e,true);try{e.start("Installing RapidKit globally with pipx for CLI access"),await F(b,["install","rapidkit-core"]),e.succeed("RapidKit installed globally");}catch(E){e.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),a$1.debug(`pipx install failed: ${E}`);}}}catch(a){e.succeed("Skipped optional global pipx installation"),a$1.debug(`Global install check skipped: ${a}`);}}async function rt(t,n,e,r,s,d=false){e.start(`Checking Python ${n}`);let u=C();try{let{stdout:y}=await execa(u,["--version"]),h=y.match(/Python (\d+\.\d+)/)?.[1];if(h&&!K(h,n))throw new f$1(n,h);e.succeed(`Python ${h} found`);}catch(y){throw y instanceof f$1?y:new f$1(n)}e.start("Creating virtual environment");try{await execa(u,["-m","venv",".venv"],{cwd:t}),e.succeed("Virtual environment created");}catch(y){if(e.fail("Failed to create virtual environment"),(c=>typeof c=="object"&&c!==null&&"stdout"in c&&typeof c.stdout=="string")(y)&&y.stdout.includes("ensurepip is not")){let c=y.stdout.match(/apt install (python[\d.]+-venv)/),i=c?c[1]:"python3-venv";throw new k("Python venv module not available",new Error(`Virtual environment creation failed.
145
+
146
+ On Debian/Ubuntu systems, install the venv package:
147
+ sudo apt install ${i}
148
+
149
+ Or use Poetry instead (recommended):
150
+ npx rapidkit ${m.basename(t)} --yes`))}throw new k("Virtual environment creation",y instanceof Error?y:new Error(String(y)))}e.start("Installing RapidKit");let g=f(m.join(t,".venv"));if(await execa(g,["-m","pip","install","--upgrade","pip"],{cwd:t}),r){let y=d$2(s||{});if(!y)throw new k("Test mode installation",new Error("No local RapidKit path configured. Set RAPIDKIT_DEV_PATH environment variable."));a$1.debug(`Installing from local path: ${y}`),e.text="Installing RapidKit from local path (test mode)",await execa(g,["-m","pip","install","-e",y],{cwd:t});}else {e.text="Installing RapidKit from PyPI";let y=false,h=null;for(let c=1;c<=3;c++)try{await execa(g,["-m","pip","install","rapidkit-core"],{cwd:t,timeout:6e4*c}),y=true;break}catch(i){h=i,a$1.debug(`pip install attempt ${c} failed: ${i}`),c<3&&(e.text=`Retrying installation (attempt ${c+1}/3)`,await new Promise(a=>setTimeout(a,2e3)));}if(!y){let c=h?.stderr||h?.message||"Unknown error";throw a$1.debug(`All pip install attempts failed. Last error: ${c}`),c.includes("Could not find")||c.includes("No matching distribution")?new l:new k("Install rapidkit-core with pip",new Error(`Failed to install rapidkit-core after 3 attempts.
151
+ Error: ${c}
152
+
153
+ Possible solutions:
154
+ 1. Check your internet connection
155
+ 2. Try installing manually: cd ${m.basename(t)} && ${f(".venv")} -m pip install rapidkit-core
156
+ 3. Use Poetry instead: npx rapidkit ${m.basename(t)} --install-method=poetry`))}}e.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:y}=await import('./pythonRapidkitExec-K2SFGAYJ.js');if(!await y()&&!r){e.start("Checking optional global pipx installation");let c=await q(e,true);try{e.start("Installing RapidKit globally with pipx for CLI access"),await F(c,["install","rapidkit-core"]),e.succeed("RapidKit installed globally");}catch(i){e.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),a$1.debug(`pipx install failed: ${i}`);}}}catch(y){e.succeed("Skipped optional global pipx installation"),a$1.debug(`Global install check skipped: ${y}`);}}async function Pt(t,n,e,r,s=false){let d=await q(n,s);if(n.start("Installing RapidKit globally with pipx"),e){let u=d$2(r||{});if(!u)throw new k("Test mode installation",new Error("No local RapidKit path configured. Set RAPIDKIT_DEV_PATH environment variable."));a$1.debug(`Installing from local path: ${u}`),n.text="Installing RapidKit from local path (test mode)",await F(d,["install","-e",u]);}else {n.text="Installing RapidKit from PyPI";try{await F(d,["install","rapidkit-core"]);}catch{throw new l}}n.succeed("RapidKit installed globally"),await v.outputFile(m.join(t,".rapidkit-global"),`RapidKit installed globally with pipx
157
+ `,"utf-8");}async function ne(t,n){let{skipGit:e=false,testMode:r=false,userConfig:s={},yes:d=false,installMethod:u,pythonVersion:g="3.10"}=n||{},y=u||s.defaultInstallMethod||await(async()=>{try{return await execa("poetry",["--version"],{timeout:3e3}),"poetry"}catch{return a$1.warn("Poetry not found \u2014 auto-selecting venv. Pass --install-method poetry to override."),"venv"}})(),h=y==="poetry"&&!await wt()?"venv":y;await et(t,m.basename(t),h),await H(t),await nt(t,m.basename(t),h,g,n?.profile);let c=z("Registering workspace").start();try{h==="poetry"?(await ot(t,m.basename(t)),await bt(t,g,c,r,s,d)):h==="venv"?await rt(t,g,c,r,s):await Pt(t,c,r,s,d),await vt(t,h),await xt(t,h),c.succeed("Workspace registered");try{let{registerWorkspace:i}=await import('./workspace-VXNLNKCM.js');await i(t,m.basename(t));}catch{}if(!e){c.start("Initializing git repository");try{await execa("git",["init"],{cwd:t}),await execa("git",["add","."],{cwd:t}),await execa("git",["commit","-m","Initial commit: RapidKit workspace"],{cwd:t}),c.succeed("Git repository initialized");}catch{c.warn("Could not initialize git repository");}}}catch(i){throw c.fail("Failed to register workspace"),i}}async function xt(t,n){let e=n==="poetry"?`source $(poetry env info --path)/bin/activate
158
+ # Or simply use: poetry run rapidkit <command>`:n==="venv"?"source .venv/bin/activate # On Windows: .venv\\Scripts\\activate":"N/A (globally installed)",r=n==="poetry"?`# No activation needed (recommended):
159
+ ./rapidkit --help
160
+ # or:
161
+ poetry run rapidkit --help`:n==="venv"?`# No activation needed (recommended):
162
+ ./rapidkit --help
163
+ # or direct:
164
+ ./.venv/bin/rapidkit --help`:`# Optional: use the local launcher
165
+ ./rapidkit --help
166
+ # (pipx installs may require Poetry/venv to be present in this folder)`,s=a$2()?"python --version (or: py -3 --version)":"python3 --version (or: python --version)",d=`# RapidKit Workspace
167
+
168
+ This directory contains a RapidKit development environment.
169
+
170
+ ## Installation Method
171
+
172
+ **${n==="poetry"?"Poetry":n==="venv"?"Python venv + pip":"pipx (global)"}**
173
+
174
+ ## Getting Started
175
+
176
+ ### 0. Run Without Activation (Recommended)
177
+
178
+ This workspace includes a local launcher script so you can run the Python Core CLI without activating the environment:
179
+
180
+ \`\`\`bash
181
+ ${r}
182
+ \`\`\`
183
+
184
+ ### 1. Activate Environment
185
+
186
+ \`\`\`bash
187
+ ${e}
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
+ ${n==="venv"?".venv/ # Python virtual environment":""}
255
+ ${n==="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: \`${s}\`
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(m.join(t,"README.md"),d,"utf-8");}async function Kt(t,n,e){let r=z("Creating demo workspace").start();try{await v.ensureDir(t),r.succeed("Directory created"),r.start("Setting up demo kit generator");let s=JSON.stringify({name:`${n}-workspace`,version:"1.0.0",private:true,description:"RapidKit demo workspace",scripts:{generate:"node generate-demo.js"}},null,2);await promises.writeFile(m.join(t,"package.json"),s,"utf-8"),await promises.writeFile(m.join(t,"generate-demo.js"),`#!/usr/bin/env node
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",m.join(t,"generate-demo.js")]);}catch{}let u=`# 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
+ ${n}/
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(m.join(t,"README.md"),u,"utf-8"),r.succeed("Demo workspace setup complete"),!e){r.start("Initializing git repository");try{await execa("git",["init"],{cwd:t}),await v.outputFile(m.join(t,".gitignore"),`# Dependencies
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}),r.succeed("Git repository initialized");}catch{r.warn("Could not initialize git repository");}}console.log(o.green(`
765
+ \u2728 Demo workspace created successfully!
766
+ `)),console.log(o.cyan("\u{1F4C2} Location:"),o.white(t)),console.log(o.cyan(`\u{1F680} Get started:
767
+ `)),console.log(o.white(` cd ${n}`)),console.log(o.white(" node generate-demo.js my-api")),console.log(o.white(" cd my-api")),console.log(o.white(" rapidkit init")),console.log(o.white(" rapidkit dev")),console.log(),console.log(o.yellow("\u{1F4A1} Note:"),"This is a demo workspace. For full RapidKit features:"),console.log(o.cyan(" pipx install rapidkit")),console.log();}catch(s){throw r.fail("Failed to create demo workspace"),s}}async function Ft(t,n,e,r){console.log(o.cyan(`
768
+ \u{1F50D} Dry-run mode - showing what would be created:
769
+ `)),console.log(o.white("\u{1F4C2} Project path:"),t),console.log(o.white("\u{1F4E6} Project type:"),e?"Demo workspace":"Full RapidKit environment"),e?(console.log(o.white(`
770
+ \u{1F4DD} Files to create:`)),console.log(o.gray(" - package.json")),console.log(o.gray(" - generate-demo.js (project generator)")),console.log(o.gray(" - README.md")),console.log(o.gray(" - .gitignore")),console.log(o.white(`
771
+ \u{1F3AF} Capabilities:`)),console.log(o.gray(" - Generate multiple FastAPI demo projects")),console.log(o.gray(" - No Python RapidKit installation required")),console.log(o.gray(" - Bundled templates included"))):(console.log(o.white(`
772
+ \u2699\uFE0F Configuration:`)),console.log(o.gray(` - Python version: ${r.pythonVersion||"3.10"}`)),console.log(o.gray(` - Install method: ${r.defaultInstallMethod||"poetry"}`)),console.log(o.gray(` - Git initialization: ${r.skipGit?"No":"Yes"}`)),console.log(o.white(`
773
+ \u{1F4DD} Files to create:`)),console.log(o.gray(" - pyproject.toml (Poetry) or .venv/ (venv)")),console.log(o.gray(" - README.md")),console.log(o.gray(" - .gitignore")),console.log(o.white(`
774
+ \u{1F3AF} Next steps after creation:`)),console.log(o.gray(" 1. Install RapidKit Python package")),console.log(o.gray(" 2. Create projects with rapidkit CLI")),console.log(o.gray(" 3. Add modules and customize"))),console.log(o.white(`
775
+ \u{1F4A1} To proceed with actual creation, run without --dry-run flag
776
+ `));}export{oe as createProject,ne as registerWorkspaceAtPath,ee as syncWorkspaceFoundationFiles,vt as writeWorkspaceLauncher};