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