rapidkit 0.25.6 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,38 @@
1
+ import {b,f,d,a as a$1,k,g,i as i$1}from'./chunk-Z5LKRG57.js';import {a}from'./chunk-VM2TOHNX.js';import i from'chalk';import {execa}from'execa';import r from'fs-extra';import n from'path';import X from'inquirer';function z(t){return [...new Set(t.filter(s=>s&&s.trim().length>0))]}function Y(){let t=k().map(c=>n.join(c,a$1()?"poetry.exe":"poetry")),s=a$1()?[n.join(process.env.APPDATA||"","Python","Scripts","poetry.exe"),n.join(process.env.USERPROFILE||"","AppData","Roaming","Python","Scripts","poetry.exe")]:[],e=a$1()?[]:["/usr/local/bin/poetry","/usr/bin/poetry"];return z([...t,...s,...e])}function Z(t){let s=k().map(a=>({location:"Global (user-local)",path:n.join(a,a$1()?"rapidkit.exe":"rapidkit")})),e=[{location:"Global (pipx)",path:n.join(t,".local","bin","rapidkit")},{location:"Global (pipx)",path:n.join(t,"AppData","Roaming","Python","Scripts","rapidkit.exe")},{location:"Global (pyenv)",path:n.join(t,".pyenv","shims","rapidkit")},{location:"Global (system)",path:"/usr/local/bin/rapidkit"},{location:"Global (system)",path:"/usr/bin/rapidkit"}],c=g(n.join(process.cwd(),".venv")),o=i$1(process.cwd()),l=[{location:"Workspace (.venv)",path:c},...o.map(a=>({location:"Workspace (launcher)",path:a}))],p=[...s,...e,...l],d=new Set;return p.filter(a=>d.has(a.path)?false:(d.add(a.path),true))}function tt(t){let s=new Map([["Workspace (.venv)",0],["Global (user-local)",1],["Global (pipx)",2],["Global (pyenv)",3],["Global (system)",4]]);return [...t].sort((e,c)=>{let o=s.get(e.location)??Number.MAX_SAFE_INTEGER,l=s.get(c.location)??Number.MAX_SAFE_INTEGER;return o!==l?o-l:e.path.localeCompare(c.path)})}function j(t,s){return a$1()?`cd "${t}"; ${s}`:`cd ${t} && ${s}`}function W(t){return a$1()?j(t,"Copy-Item .env.example .env"):j(t,"cp .env.example .env")}async function J(t){try{let s=await r.stat(t);return `${n.basename(t)}:${s.isDirectory()?"d":"f"}:${s.size}:${s.mtimeMs}`}catch{return `${n.basename(t)}:missing`}}async function et(t){try{let s=new Set([".git",".venv","node_modules",".rapidkit","dist","build","coverage","__pycache__"]),e=new Set;await N(t)&&e.add(t);let c=async(o,l)=>{if(l<0)return;let p=await Q(o);for(let d of p){if(U(d,s))continue;let a=n.join(o,d);if(await N(a)){e.add(a);continue}l>0&&await c(a,l-1);}};return await c(t,1),e.size===0&&(await pt(t,3,s)).forEach(l=>e.add(l)),Array.from(e).sort((o,l)=>o.localeCompare(l))}catch{return []}}async function st(t,s){let e=[n.join(t,".rapidkit-workspace"),n.join(t,".rapidkit","workspace.json"),n.join(t,".rapidkit","policies.yml"),n.join(t,".rapidkit","toolchain.lock"),n.join(t,".rapidkit","cache-config.yml")],c=[".rapidkit/project.json",".rapidkit/context.json",".rapidkit/file-hashes.json","package.json","pyproject.toml","go.mod","go.sum","requirements.txt","Dockerfile","Makefile",".env",".env.example","src","modules","tests","test",".venv","node_modules"],o=await Promise.all(e.map(J)),l=await Promise.all(s.map(async p=>{let d=await Promise.all(c.map(a=>J(n.join(p,a))));return `${p}::${d.join("|")}`}));return [...o,...l].join("||")}async function ot(t,s){try{if(!await r.pathExists(t))return null;let e=await r.readJSON(t);return !e||e.signature!==s||!Array.isArray(e.projects)?null:e}catch{return null}}async function it(t,s){try{await r.ensureDir(n.dirname(t)),await r.writeJSON(t,s,{spaces:2});}catch{}}async function nt(t,s,e){let c=n.join(t,".rapidkit","reports","doctor-last-run.json");try{return await r.ensureDir(n.dirname(c)),await r.writeJSON(c,{generatedAt:new Date().toISOString(),workspacePath:t,workspaceName:s.workspaceName,projectScanCached:s.projectScanCached??false,projectScanSignature:s.projectScanSignature,cachePath:e,healthScore:s.healthScore,system:{python:s.python,poetry:s.poetry,pipx:s.pipx,go:s.go,rapidkitCore:s.rapidkitCore,versions:{core:s.coreVersion,npm:s.npmVersion}},projects:s.projects,summary:{totalProjects:s.projects.length,totalIssues:s.projects.reduce((o,l)=>o+l.issues.length,0),hasSystemErrors:[s.python,s.rapidkitCore].some(o=>o.status==="error")}},{spaces:2}),c}catch{return}}async function B(){let[t,s,e,c,o]=await Promise.all([at(),rt(),ct(),lt(),dt()]);return {python:t,poetry:s,pipx:e,go:c,rapidkitCore:o}}async function at(){let t=d();for(let s of t)try{let{stdout:e}=await execa(s,["--version"],{timeout:3e3}),c=e.match(/Python (\d+\.\d+\.\d+)/);if(c){let o=c[1],[l,p]=o.split(".").map(Number);return l<3||l===3&&p<10?{status:"warn",message:`Python ${o} (requires 3.10+)`,details:`${s} found but version is below minimum requirement`}:{status:"ok",message:`Python ${o}`,details:`Using ${s}`}}}catch{continue}return {status:"error",message:"Python not found",details:"Install Python 3.10+ and ensure it's in PATH"}}async function rt(){try{let{stdout:t}=await execa("poetry",["--version"],{timeout:3e3}),s=t.match(/Poetry .*version ([\d.]+)/);return s?{status:"ok",message:`Poetry ${s[1]}`,details:"Available for dependency management"}:{status:"warn",message:"Poetry version unknown"}}catch{let t=d().map(s=>({cmd:s,args:s==="py"?["-3","-m","poetry","--version"]:["-m","poetry","--version"]}));for(let s of t)try{let{stdout:e}=await execa(s.cmd,s.args,{timeout:3e3,shell:b()}),c=e.match(/Poetry .*version ([\d.]+)/)||e.match(/([\d.]+)/);return {status:"ok",message:c?.[1]?`Poetry ${c[1]}`:"Poetry detected",details:`Available via ${s.cmd} ${s.args.join(" ")}`}}catch{continue}for(let s of Y())try{if(!await r.pathExists(s))continue;let{stdout:e}=await execa(s,["--version"],{timeout:3e3,shell:b()}),c=e.match(/Poetry .*version ([\d.]+)/)||e.match(/([\d.]+)/);return {status:"ok",message:c?.[1]?`Poetry ${c[1]}`:"Poetry detected",details:`Available at ${s}`}}catch{continue}return {status:"warn",message:"Poetry not installed",details:"Optional: Install for better dependency management"}}}async function ct(){try{let{stdout:t}=await execa("pipx",["--version"],{timeout:3e3});return {status:"ok",message:`pipx ${t.trim()}`,details:"Available for global tool installation"}}catch{let t=d();for(let s of t)try{let e=s==="py"?["-3","-m","pipx","--version"]:["-m","pipx","--version"],{stdout:c}=await execa(s,e,{timeout:3e3,shell:b()});return {status:"ok",message:`pipx ${c.trim()}`,details:`Available via ${s} ${e.join(" ")}`}}catch{continue}return {status:"warn",message:"pipx not installed",details:"Optional: Install for isolated Python tools"}}}async function lt(){try{let{stdout:t}=await execa("go",["version"],{timeout:3e3}),s=t.match(/go version go(\d+\.\d+(?:\.\d+)?)/);return s?{status:"ok",message:`Go ${s[1]}`,details:"Available for Go/Fiber and Go/Gin projects"}:{status:"ok",message:"Go (version unknown)",details:"go found in PATH"}}catch{return {status:"warn",message:"Go not installed",details:"Optional: Required only for gofiber.standard / gogin.standard projects \u2014 https://go.dev/dl/"}}}async function dt(){let t=process.env.HOME||process.env.USERPROFILE||"",s=[],e=Z(t);for(let{location:o,path:l}of e)try{if(await r.pathExists(l)){let{stdout:p,exitCode:d}=await execa(l,["--version"],{timeout:3e3,reject:false});if(d===0&&(p.includes("RapidKit Version")||p.includes("RapidKit"))){let a=p.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);a&&s.push({location:o,path:l,version:a[1]});}}}catch{continue}if(s.length>0){let o=s.filter(p=>p.location!=="Workspace (launcher)");if(o.length>0){let p=tt(o);return {status:"ok",message:`RapidKit Core ${p[0].version}`,paths:p.map(a=>({location:a.location,path:a.path,version:a.version}))}}return {status:"ok",message:`RapidKit Core ${s[0].version}`,details:"Detected via workspace launcher"}}try{let{stdout:o,exitCode:l}=await execa("rapidkit",["--version"],{timeout:3e3,reject:false});if(l===0&&(o.includes("RapidKit Version")||o.includes("RapidKit"))){let p=o.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(p)return {status:"ok",message:`RapidKit Core ${p[1]}`,details:"Available via PATH"}}}catch{}try{let{stdout:o,exitCode:l}=await execa("poetry",["run","rapidkit","--version"],{timeout:3e3,reject:false});if(l===0&&(o.includes("RapidKit Version")||o.includes("RapidKit"))){let p=o.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(p)return {status:"ok",message:`RapidKit Core ${p[1]}`,details:"Available via Poetry"}}}catch{}let c=d();for(let o of c)try{let{stdout:l,exitCode:p}=await execa(o,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:3e3,reject:false});if(p===0&&l&&!l.includes("Traceback")&&!l.includes("ModuleNotFoundError")){let d=l.trim();if(d)return {status:"ok",message:`RapidKit Core ${d}`,details:`Available in ${o} environment`}}}catch{continue}return {status:"error",message:"RapidKit Core not installed",details:"Install with: pipx install rapidkit-core"}}async function I(t,s){let e=n.join(t,"Dockerfile");s.hasDocker=await r.pathExists(e);let c=n.join(t,"tests"),o=n.join(t,"test"),l=n.join(t,"src","test"),p=await r.pathExists(c)||await r.pathExists(o)||await r.pathExists(l),d=false;if(s.framework==="Go/Fiber"||s.framework==="Go/Gin")try{let a=[{dir:t,depth:0}],u=4,m=new Set([".git",".venv","node_modules","dist","build","vendor"]);for(;a.length>0&&!d;){let h=a.shift();if(!h)break;let w=[];try{w=await r.readdir(h.dir);}catch{continue}for(let f of w){let g=n.join(h.dir,f),v;try{v=await r.stat(g);}catch{continue}if(v.isFile()&&f.endsWith("_test.go")){d=true;break}v.isDirectory()&&h.depth<u&&!m.has(f)&&!f.startsWith(".")&&a.push({dir:g,depth:h.depth+1});}}}catch{}if(s.hasTests=p||d,s.framework==="NestJS"){let a=n.join(t,".eslintrc.js"),u=n.join(t,".eslintrc.json");s.hasCodeQuality=await r.pathExists(a)||await r.pathExists(u);}else if(s.framework==="Go/Fiber"||s.framework==="Go/Gin"){let a=n.join(t,".golangci.yml"),u=n.join(t,".golangci.yaml"),m=n.join(t,"Makefile"),h=await r.pathExists(m)&&(await r.readFile(m,"utf8")).includes("golangci-lint");s.hasCodeQuality=await r.pathExists(a)||await r.pathExists(u)||h;}else if(s.framework==="FastAPI"){let a=n.join(t,"ruff.toml"),u=n.join(t,"pyproject.toml");if(await r.pathExists(u))try{let m=await r.readFile(u,"utf8");s.hasCodeQuality=m.includes("[tool.ruff]")||await r.pathExists(a);}catch{s.hasCodeQuality=await r.pathExists(a);}}else if(s.framework==="Spring Boot"){let a=n.join(t,"pom.xml");if(await r.pathExists(a))try{let u=await r.readFile(a,"utf8");s.hasCodeQuality=u.includes("spotless")||u.includes("checkstyle")||u.includes("pmd")||u.includes("maven-enforcer-plugin");}catch{s.hasCodeQuality=false;}}try{if(s.framework==="NestJS"){let{stdout:a}=await execa("npm",["audit","--json"],{cwd:t,reject:false});if(a)try{let m=JSON.parse(a).metadata?.vulnerabilities;m&&(s.vulnerabilities=(m.high||0)+(m.critical||0)+(m.moderate||0));}catch{}}else if(s.framework==="FastAPI"){let a=n.join(t,".venv"),u=f(a);if(await r.pathExists(u))try{let{stdout:m}=await execa(u,["-m","pip","list","--format=json"],{timeout:5e3,reject:false});if(m){JSON.parse(m);s.vulnerabilities=0;}}catch{}}}catch{}}async function ut(t){let e={name:n.basename(t),path:t,venvActive:false,depsInstalled:false,coreInstalled:false,issues:[],fixCommands:[]},c=n.join(t,".rapidkit");if(!await r.pathExists(c))return e.issues.push("Not a valid RapidKit project (missing .rapidkit directory)"),e;try{let f=n.join(t,"registry.json");if(await r.pathExists(f)){let g=await r.readJson(f);g.installed_modules&&(e.stats={modules:g.installed_modules.length});}}catch{}let o=null;try{let f=n.join(c,"project.json");if(await r.pathExists(f)){o=await r.readJson(f);let g=o?.kit_name||o?.kit;g&&(e.kit=g);}}catch{}try{let f=n.join(t,".git");if(await r.pathExists(f)){let{stdout:g}=await execa("git",["log","-1","--format=%cr"],{cwd:t,reject:false});g&&(e.lastModified=g.trim());}else {let g=await r.stat(t),x=Date.now()-g.mtime.getTime(),k=Math.floor(x/(1e3*60*60*24));e.lastModified=k===0?"today":`${k} day${k>1?"s":""} ago`;}}catch{}let l=n.join(t,"package.json"),p=n.join(t,"pyproject.toml"),d=n.join(t,"go.mod"),a=n.join(t,"pom.xml");if(await r.pathExists(d)||o?.runtime==="go"||typeof o?.kit_name=="string"&&(o.kit_name.startsWith("gofiber")||o.kit_name.startsWith("gogin"))){let f=o?.kit_name??"";e.framework=f.startsWith("gogin")?"Go/Gin":"Go/Fiber",e.isGoProject=true,e.venvActive=true,e.coreInstalled=false;try{await execa("go",["version"],{timeout:3e3});}catch{e.issues.push("Go toolchain not found \u2014 install from https://go.dev/dl/"),e.fixCommands?.push("https://go.dev/dl/");}let g=n.join(t,"go.sum");return await r.pathExists(g)?e.depsInstalled=true:(e.depsInstalled=false,e.issues.push("Go dependencies not downloaded (go.sum missing)"),e.fixCommands?.push(j(t,"go mod tidy"))),await I(t,e),e}if(await r.pathExists(a)||o?.runtime==="java"||typeof o?.kit_name=="string"&&o.kit_name.startsWith("springboot")){e.framework="Spring Boot",e.venvActive=true,e.coreInstalled=false;let f=await r.pathExists(a),g=await r.pathExists(n.join(t,"build.gradle"))||await r.pathExists(n.join(t,"build.gradle.kts")),v=await r.pathExists(n.join(t,"mvnw"))||await r.pathExists(n.join(t,"mvnw.cmd")),x=await r.pathExists(n.join(t,"gradlew"))||await r.pathExists(n.join(t,"gradlew.bat"));try{await execa("java",["-version"],{timeout:3e3,reject:false});}catch{e.issues.push("Java runtime not found \u2014 install JDK 21+ and ensure java is on PATH"),e.fixCommands?.push("https://adoptium.net/");}if(f){if(!v)try{await execa("mvn",["-version"],{timeout:3e3,reject:false});}catch{e.issues.push("Maven not found \u2014 install Maven 3.9+ or add Maven Wrapper"),e.fixCommands?.push("https://maven.apache.org/install.html");}}else if(g&&!x)try{await execa("gradle",["--version"],{timeout:3e3,reject:false});}catch{e.issues.push("Gradle not found \u2014 install Gradle 8+ or add Gradle Wrapper"),e.fixCommands?.push("https://gradle.org/install/");}let k=n.join(t,"target"),b=n.join(t,"build","libs"),G=n.join(t,".rapidkit","cache","java","m2"),F=n.join(t,".rapidkit","cache","java","gradle");e.depsInstalled=await r.pathExists(k)||await r.pathExists(b)||await r.pathExists(G)||await r.pathExists(F),e.depsInstalled||(e.issues.push("Java dependencies are not warmed or built yet"),e.fixCommands?.push(j(t,"rapidkit init")));let E=n.join(t,".env");if(e.hasEnvFile=await r.pathExists(E),!e.hasEnvFile){let S=n.join(t,".env.example");await r.pathExists(S)&&(e.issues.push("Environment file missing (found .env.example)"),e.fixCommands?.push(W(t)));}let A=n.join(t,"src","main","resources","application.yml");if(await r.pathExists(A))try{let S=await r.readFile(A,"utf-8");/include:\s*[^\n]*health/i.test(S)||/management:\s*[\s\S]*endpoint:\s*[\s\S]*health:/i.test(S)||(e.issues.push("Actuator health endpoint exposure is not clearly configured in application.yml"),e.fixCommands?.push(j(t,"Ensure management.endpoints.web.exposure.include contains health in src/main/resources/application.yml")));}catch{e.issues.push("Unable to read application.yml for Spring Actuator health checks");}return await I(t,e),e}let h=await r.pathExists(l),w=await r.pathExists(p);if(h){e.framework="NestJS",e.venvActive=true;let f=n.join(t,"node_modules");if(await r.pathExists(f))try{let k=(await r.readdir(f)).filter(b=>!b.startsWith(".")&&!b.startsWith("_"));e.depsInstalled=k.length>0;}catch{e.depsInstalled=false;}e.depsInstalled||(e.issues.push("Dependencies not installed (node_modules empty or missing)"),e.fixCommands?.push(j(t,"rapidkit init"))),e.coreInstalled=false;let g=n.join(t,".env");if(e.hasEnvFile=await r.pathExists(g),!e.hasEnvFile){let x=n.join(t,".env.example");await r.pathExists(x)&&(e.issues.push("Environment file missing (found .env.example)"),e.fixCommands?.push(W(t)));}let v=n.join(t,"src");if(e.modulesHealthy=true,e.missingModules=[],await r.pathExists(v))try{let x=await r.readdir(v);e.modulesHealthy=x.length>0;}catch{e.modulesHealthy=false;}return await I(t,e),e}if(w){e.framework="FastAPI";let f$1=n.join(t,".venv");if(await r.pathExists(f$1)){e.venvActive=true;let k=f(f$1);if(await r.pathExists(k)){try{let{stdout:b}=await execa(k,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:2e3});e.coreInstalled=true,e.coreVersion=b.trim();}catch{e.coreInstalled=false;}try{await execa(k,["-c","import fastapi"],{timeout:2e3}),e.depsInstalled=true;}catch{try{let b=n.join(f$1,"lib");if(await r.pathExists(b)){let F=(await r.readdir(b)).find(E=>E.startsWith("python"));if(F){let E=n.join(b,F,"site-packages");if(await r.pathExists(E)){let S=(await r.readdir(E)).filter(_=>!_.startsWith("_")&&!_.includes("dist-info")&&!["pip","setuptools","wheel","pkg_resources"].includes(_));e.depsInstalled=S.length>0;}}}e.depsInstalled||(e.issues.push("Dependencies not installed"),e.fixCommands?.push(j(t,"rapidkit init")));}catch{e.issues.push("Could not verify dependency installation");}}}else e.issues.push("Virtual environment exists but Python executable not found");}else e.issues.push("Virtual environment not created"),e.fixCommands?.push(j(t,"rapidkit init"));let g=n.join(t,".env");if(e.hasEnvFile=await r.pathExists(g),!e.hasEnvFile){let k=n.join(t,".env.example");await r.pathExists(k)&&(e.issues.push("Environment file missing (found .env.example)"),e.fixCommands?.push(W(t)));}let v=n.join(t,"src"),x=n.join(t,"modules");if(e.modulesHealthy=true,e.missingModules=[],await r.pathExists(v)){let k=n.join(v,"__init__.py");await r.pathExists(k)||(e.modulesHealthy=false,e.missingModules.push("src/__init__.py"));}if(await r.pathExists(x))try{let k=await Q(x);for(let b of k){let G=n.join(x,b,"__init__.py");await r.pathExists(G)||(e.modulesHealthy=false,e.missingModules.push(`modules/${b}/__init__.py`));}}catch{}return !e.modulesHealthy&&e.missingModules.length>0&&e.issues.push(`Missing module init files: ${e.missingModules.join(", ")}`),await I(t,e),e}return e.issues.push("Unknown project type (no package.json or pyproject.toml)"),await I(t,e),e}async function Q(t){try{return (await r.readdir(t,{withFileTypes:true})).filter(e=>e.isDirectory()).map(e=>e.name)}catch{try{let s=await r.readdir(t),e=[];for(let c of s)try{(await r.stat(n.join(t,c))).isDirectory()&&e.push(c);}catch{continue}return e}catch{return []}}}async function N(t){let s=n.join(t,".rapidkit");if(!await r.pathExists(s))return false;let e=["project.json","context.json","file-hashes.json"];for(let c of e)if(await r.pathExists(n.join(s,c)))return true;return false}function U(t,s){if(s.has(t))return true;let e=t.toLowerCase();return !!(e==="dist"||e.startsWith("dist-")||e.startsWith("dist_")||e==="build"||e.startsWith("build-")||e.startsWith("build_"))}async function pt(t,s,e){let c=new Set,o=[{dir:t,depth:0}];for(;o.length>0;){let l=o.shift();if(!l)break;try{let p=await r.readdir(l.dir);for(let d of p){if(U(d,e))continue;let a=n.join(l.dir,d),u;try{u=await r.stat(a);}catch{continue}if(u.isDirectory()){if(await N(a)){c.add(a);continue}l.depth<s&&o.push({dir:a,depth:l.depth+1});}}}catch{continue}}return Array.from(c)}async function K(t){let s=t,e=n.parse(s).root;for(;s!==e;){let c=[n.join(s,".rapidkit-workspace"),n.join(s,".rapidkit","workspace-marker.json"),n.join(s,".rapidkit","config.json")];for(let o of c)if(await r.pathExists(o))return s;s=n.dirname(s);}return null}function mt(t,s){let e=0,c=0,o=0;return t.forEach(p=>{p.status==="ok"?e++:p.status==="warn"?c++:p.status==="error"&&o++;}),s.forEach(p=>{(p.isGoProject?p.issues.length===0&&p.depsInstalled:p.issues.length===0&&p.venvActive&&p.depsInstalled)?e++:p.issues.length>0&&c++;}),{total:e+c+o,passed:e,warnings:c,errors:o}}async function O(t,s=true){let e=n.basename(t);try{let m=n.join(t,".rapidkit-workspace");await r.pathExists(m)&&(e=(await r.readJSON(m)).name||e);}catch{try{let m=n.join(t,".rapidkit","config.json");e=(await r.readJSON(m)).workspace_name||e;}catch{}}let[c,o]=await Promise.all([B(),et(t)]),l={workspacePath:t,workspaceName:e,python:c.python,poetry:c.poetry,pipx:c.pipx,go:c.go,rapidkitCore:c.rapidkitCore,projects:[]};a.debug(`Workspace scan found ${o.length} project(s)`);let p=await st(t,o),d=n.join(t,".rapidkit","reports","doctor-workspace-cache.json"),a$1=s?await ot(d,p):null;if(a$1)l.projects=a$1.projects,l.projectScanCached=true,a.debug(`Workspace project health cache hit: ${d}`);else try{let m=await Promise.all(o.map(h=>ut(h)));l.projects=m,l.projectScanCached=false,await it(d,{signature:p,generatedAt:new Date().toISOString(),projects:m}),a.debug(`Workspace project health cache refreshed: ${d}`);}catch(m){a.debug(`Failed to scan workspace projects: ${m}`);}l.projectScanSignature=p,l.projectScanCachePath=d;let u=[l.python,l.poetry,l.pipx,l.go,l.rapidkitCore];if(l.healthScore=mt(u,l.projects),l.rapidkitCore.status==="ok"){let m=l.rapidkitCore.message.match(/([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);m&&(l.coreVersion=m[1]);}return l.evidencePath=await nt(t,l,a$1?d:null),l}function C(t,s){let e=t.status==="ok"?"\u2705":t.status==="warn"?"\u26A0\uFE0F":"\u274C",c=t.status==="ok"?i.green:t.status==="warn"?i.yellow:i.red;console.log(`${e} ${i.bold(s)}: ${c(t.message)}`),t.paths&&t.paths.length>0?t.paths.forEach(o=>{let l=o.version?i.cyan(` -> ${o.version}`):"";console.log(` ${i.cyan("\u2022")} ${i.gray(o.location)}: ${i.dim(o.path)}${l}`);}):t.details&&console.log(` ${i.gray(t.details)}`);}function ht(t){let s=t.issues.length>0,e=s?"\u26A0\uFE0F":"\u2705",c=s?i.yellow:i.green;if(console.log(`
2
+ ${e} ${i.bold("Project")}: ${c(t.name)}`),t.framework){let u=t.framework==="FastAPI"?"\u{1F40D}":t.framework==="NestJS"?"\u{1F985}":t.framework==="Spring Boot"?"\u2615":t.framework==="Go/Fiber"||t.framework==="Go/Gin"?"\u{1F439}":"\u{1F4E6}";console.log(` ${u} Framework: ${i.cyan(t.framework)}${t.kit?i.gray(` (${t.kit})`):""}`);}console.log(` ${i.gray(`Path: ${t.path}`)}`);let o=t.framework==="Go/Fiber"||t.framework==="Go/Gin",l=t.framework==="Spring Boot",p=t.framework==="NestJS";if(!o&&!p&&!l&&(t.venvActive?console.log(` \u2705 Virtual environment: ${i.green("Active")}`):console.log(` \u274C Virtual environment: ${i.red("Not found")}`),t.coreInstalled?console.log(` ${i.dim("\u2139")} RapidKit Core: ${i.gray(t.coreVersion||"In venv")} ${i.dim("(optional)")}`):console.log(` ${i.dim("\u2139")} RapidKit Core: ${i.gray("Using global installation")} ${i.dim("(recommended)")}`)),t.depsInstalled?console.log(` \u2705 Dependencies: ${i.green("Installed")}`):console.log(` \u26A0\uFE0F Dependencies: ${i.yellow("Not installed")}`),t.hasEnvFile!==void 0&&(t.hasEnvFile?console.log(` \u2705 Environment: ${i.green(".env configured")}`):console.log(` \u26A0\uFE0F Environment: ${i.yellow(".env missing")}`)),t.modulesHealthy!==void 0&&(t.modulesHealthy?console.log(` \u2705 Modules: ${i.green("Healthy")}`):t.missingModules&&t.missingModules.length>0&&console.log(` \u26A0\uFE0F Modules: ${i.yellow(`Missing ${t.missingModules.length} init file(s)`)}`)),t.stats){let u=[];t.stats.modules!==void 0&&u.push(`${t.stats.modules} module${t.stats.modules!==1?"s":""}`),u.length>0&&console.log(` \u{1F4CA} Stats: ${i.cyan(u.join(" \u2022 "))}`);}t.lastModified&&console.log(` \u{1F552} Last Modified: ${i.gray(t.lastModified)}`);let a=[];if(t.hasTests!==void 0&&a.push(t.hasTests?"\u2705 Tests":i.dim("\u2298 No tests")),t.hasDocker!==void 0&&a.push(t.hasDocker?"\u2705 Docker":i.dim("\u2298 No Docker")),t.hasCodeQuality!==void 0){let u=t.framework==="NestJS"?"ESLint":t.framework==="Spring Boot"?"Static analysis":t.framework==="Go/Fiber"||t.framework==="Go/Gin"?"golangci-lint":"Ruff";a.push(t.hasCodeQuality?`\u2705 ${u}`:i.dim(`\u2298 No ${u}`));}a.length>0&&console.log(` ${a.join(" \u2022 ")}`),t.vulnerabilities!==void 0&&t.vulnerabilities>0&&console.log(` \u26A0\uFE0F Security: ${i.yellow(`${t.vulnerabilities} vulnerability(ies) found`)}`),t.issues.length>0&&(console.log(` ${i.bold("Issues:")}`),t.issues.forEach(u=>{console.log(` \u2022 ${i.yellow(u)}`);}),t.fixCommands&&t.fixCommands.length>0&&(console.log(`
3
+ ${i.bold.cyan("\u{1F527} Quick Fix:")}`),t.fixCommands.forEach(u=>{console.log(` ${i.cyan("$")} ${i.white(u)}`);})));}async function q(){try{return (await execa("go",["version"],{timeout:3e3,reject:false})).exitCode===0}catch{return false}}async function L(t,s=false){let e=t.filter(u=>u.fixCommands&&u.fixCommands.length>0),c=null;if(e.length===0){console.log(i.green(`
4
+ \u2705 No fixes needed - all projects are healthy!`));return}console.log(i.bold.cyan(`
5
+ \u{1F527} Available Fixes:
6
+ `));for(let u of e){let m=u.fixCommands??[];console.log(i.bold(`Project: ${i.yellow(u.name)}`)),m.forEach((h,w)=>{console.log(` ${w+1}. ${i.cyan(h)}`);}),console.log();}let o=0;for(let u of e){let m=u.fixCommands??[];for(let h of m){if(/^https?:\/\//i.test(h.trim()))continue;if(d(h,"cp\\s+\\.env\\.example\\s+\\.env")||d(h,"copy-item\\s+\\.env\\.example\\s+\\.env")||d(h,"rapidkit\\s+init")){o+=1;continue}if(d(h,"go\\s+mod\\s+tidy")){c===null&&(c=await q()),c&&(o+=1);continue}o+=1;}}if(o===0){console.log(i.gray("\u{1F4A1} No automatic fixes can be applied right now.")),c===false&&console.log(i.gray(" Install Go to enable go mod tidy fixes, then rerun `rapidkit doctor workspace --fix`."));return}if(!s){console.log(i.gray('\u{1F4A1} Run "npx rapidkit doctor workspace --fix" to apply fixes automatically'));return}let{confirm:l}=await X.prompt([{type:"confirm",name:"confirm",message:`Apply ${e.reduce((u,m)=>u+(m.fixCommands?.length??0),0)} fix(es)?`,default:false}]);if(!l){console.log(i.yellow(`
7
+ \u26A0\uFE0F Fixes cancelled by user`));return}console.log(i.bold.cyan(`
8
+ \u{1F680} Applying fixes...
9
+ `));let p=u=>/^https?:\/\//i.test(u.trim());function d(u,m){let h=[new RegExp(`^cd\\s+"([^"]+)"\\s*(?:&&|;)\\s*${m}\\s*$`,"i"),new RegExp(`^cd\\s+'([^']+)'\\s*(?:&&|;)\\s*${m}\\s*$`,"i"),new RegExp(`^cd\\s+(.+?)\\s*(?:&&|;)\\s*${m}\\s*$`,"i")];for(let w of h){let f=u.match(w);if(f?.[1])return {projectPath:f[1].trim()}}return null}function a(u){return d(u,"cp\\s+\\.env\\.example\\s+\\.env")||d(u,"copy-item\\s+\\.env\\.example\\s+\\.env")}for(let u of e){let m=u.fixCommands??[];console.log(i.bold(`Fixing ${i.cyan(u.name)}...`));for(let h of m)try{if(console.log(i.gray(` $ ${h}`)),p(h)){console.log(i.yellow(` \u2139 Manual action required: open ${h}`)),console.log(i.green(` \u2705 Recorded as guidance
10
+ `));continue}let w=a(h);if(w){let v=n.join(w.projectPath,".env.example"),x=n.join(w.projectPath,".env");if(!await r.pathExists(v))throw new Error(`.env.example not found at ${v}`);if(await r.pathExists(x)){console.log(i.green(` \u2705 .env already exists
11
+ `));continue}await r.copy(v,x,{overwrite:false,errorOnExist:false}),console.log(i.green(` \u2705 Success
12
+ `));continue}let f=d(h,"rapidkit\\s+init");if(f){await execa("rapidkit",["init"],{cwd:f.projectPath,shell:b(),stdio:"inherit"}),console.log(i.green(` \u2705 Success
13
+ `));continue}let g=d(h,"go\\s+mod\\s+tidy");if(g){if(c===null&&(c=await q()),!c){console.log(i.yellow(" \u26A0 Go toolchain is not installed \u2014 skipping go mod tidy; install Go to apply this fix.")),console.log(i.green(` \u2705 Recorded as guidance
14
+ `));continue}await execa("go",["mod","tidy"],{cwd:g.projectPath,shell:b(),stdio:"inherit"}),console.log(i.green(` \u2705 Success
15
+ `));continue}await execa(h,{shell:true,stdio:"inherit"}),console.log(i.green(` \u2705 Success
16
+ `));}catch(w){console.log(i.red(` \u274C Failed: ${w instanceof Error?w.message:String(w)}
17
+ `));}}console.log(i.bold.green(`
18
+ \u2705 Fix process completed!`));}async function jt(t={}){let s=!t.workspace&&t.fix?await K(process.cwd()):null,e=t.workspace||!!s;if(t.json||console.log(i.bold.cyan(`
19
+ \u{1FA7A} RapidKit Health Check
20
+ `)),e){let c=s??await K(process.cwd());c||(a.error("No RapidKit workspace found in current directory or parents"),a.info('Run this command from within a workspace, or use "rapidkit doctor" for system check'),process.exit(1)),t.json||(s&&console.log(i.gray("\u2139\uFE0F Detected workspace context; enabling workspace checks for --fix")),console.log(i.bold(`Workspace: ${i.cyan(n.basename(c))}`)),console.log(i.gray(`Path: ${c}`)));let o=await O(c);if(t.json||(o.projectScanCached&&console.log(i.gray(`\u2139\uFE0F Reused cached project scan${o.projectScanCachePath?` (${n.basename(o.projectScanCachePath)})`:""}`)),o.evidencePath&&console.log(i.gray(`\u2139\uFE0F Evidence saved: ${o.evidencePath}`))),t.json){let d={workspace:{name:n.basename(c),path:c},cache:{projectScan:o.projectScanCached??false,projectScanPath:o.projectScanCachePath,evidencePath:o.evidencePath},healthScore:o.healthScore,system:{python:o.python,poetry:o.poetry,pipx:o.pipx,rapidkitCore:o.rapidkitCore,versions:{core:o.coreVersion,npm:o.npmVersion}},projects:o.projects.map(a=>({name:a.name,path:a.path,venvActive:a.venvActive,depsInstalled:a.depsInstalled,coreInstalled:a.coreInstalled,coreVersion:a.coreVersion,issues:a.issues,fixCommands:a.fixCommands})),summary:{totalProjects:o.projects.length,totalIssues:o.projects.reduce((a,u)=>a+u.issues.length,0),hasSystemErrors:[o.python,o.rapidkitCore].some(a=>a.status==="error")}};console.log(JSON.stringify(d,null,2));return}if(o.healthScore){let d=o.healthScore,a=Math.round(d.passed/d.total*100),u=a>=80?i.green:a>=50?i.yellow:i.red,m="\u2588".repeat(Math.floor(a/5))+"\u2591".repeat(20-Math.floor(a/5));console.log(i.bold(`
21
+ \u{1F4CA} Health Score:`)),console.log(` ${u(`${a}%`)} ${i.gray(m)}`),console.log(` ${i.green(`\u2705 ${d.passed} passed`)} ${i.gray("|")} ${i.yellow(`\u26A0\uFE0F ${d.warnings} warnings`)} ${i.gray("|")} ${i.red(`\u274C ${d.errors} errors`)}`);}if(console.log(i.bold(`
22
+
23
+ System Tools:
24
+ `)),C(o.python,"Python"),C(o.poetry,"Poetry"),C(o.pipx,"pipx"),C(o.go,"Go"),C(o.rapidkitCore,"RapidKit Core"),o.coreVersion&&o.npmVersion){let d=o.coreVersion.split(".")[1],a=o.npmVersion.split(".")[1];d!==a&&(console.log(i.yellow(`
25
+ \u26A0\uFE0F Version mismatch: Core ${o.coreVersion} / CLI ${o.npmVersion}`)),console.log(i.gray(" Consider updating to matching versions for best compatibility")));}o.projects.length>0?(console.log(i.bold(`
26
+ \u{1F4E6} Projects (${o.projects.length}):`)),o.projects.forEach(d=>ht(d))):(console.log(i.bold(`
27
+ \u{1F4E6} Projects:`)),console.log(i.gray(" No RapidKit projects found in workspace")));let l=o.projects.reduce((d,a)=>d+a.issues.length,0),p=[o.python,o.rapidkitCore].some(d=>d.status==="error");if(p||l>0)if(console.log(i.bold.yellow(`
28
+ \u26A0\uFE0F Found ${l} project issue(s)`)),p&&console.log(i.bold.red("\u274C System requirements not met")),t.fix){if(await L(o.projects,true),!t.json){let d=await O(c,false),a=d.projects.reduce((m,h)=>m+h.issues.length,0),u=[d.python,d.rapidkitCore].some(m=>m.status==="error");u||a>0?(console.log(i.bold.yellow(`
29
+ \u26A0\uFE0F Post-fix verification found ${a} remaining issue(s)`)),u&&console.log(i.bold.red("\u274C System requirements still not met"))):console.log(i.bold.green(`
30
+ \u2705 Post-fix verification passed. Workspace is healthy.`)),d.projectScanCached&&console.log(i.gray(`\u2139\uFE0F Reused cached project scan${d.projectScanCachePath?` (${n.basename(d.projectScanCachePath)})`:""}`)),d.evidencePath&&console.log(i.gray(`\u2139\uFE0F Evidence refreshed: ${d.evidencePath}`));}}else l>0&&await L(o.projects,false);else console.log(i.bold.green(`
31
+ \u2705 All checks passed! Workspace is healthy.`));}else {console.log(i.bold(`System Tools:
32
+ `));let c=await B(),o=c.python,l=c.poetry,p=c.pipx,d=c.go,a=c.rapidkitCore;C(o,"Python"),C(l,"Poetry"),C(p,"pipx"),C(d,"Go"),C(a,"RapidKit Core"),[o,a].some(m=>m.status==="error")?(console.log(i.bold.red(`
33
+ \u274C Some required tools are missing`)),t.fix&&console.log(i.gray(`
34
+ Tip: Project auto-fix runs in workspace mode. Run from a workspace and use "rapidkit doctor workspace --fix"`)),console.log(i.gray(`
35
+ Tip: Run "rapidkit doctor workspace" for detailed project checks`))):(console.log(i.bold.green(`
36
+ \u2705 All required tools are installed!`)),t.fix&&console.log(i.gray(`
37
+ Tip: Project auto-fix runs in workspace mode. Run from a workspace and use "rapidkit doctor workspace --fix"`)),console.log(i.gray(`
38
+ Tip: Run "rapidkit doctor workspace" for detailed project checks`)));}console.log("");}export{jt as runDoctor};
@@ -1,4 +1,4 @@
1
- import {b as b$1}from'./chunk-Q7ULIFQA.js';import {promises}from'fs';import s from'path';import i from'chalk';import h from'ora';import {execa}from'execa';function c(e){return e.split(/[-_\s]+/).map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join("")}async function b(e,o){await promises.mkdir(s.dirname(e),{recursive:true}),await promises.writeFile(e,o,"utf8");}function v(e){return `package main
1
+ import {c,b as b$1,d as d$1,e,f,a}from'./chunk-U7XJZHU6.js';import {b}from'./chunk-Q7ULIFQA.js';import {promises}from'fs';import d from'path';import o from'chalk';import S from'ora';import {execa}from'execa';function _(e){return `package main
2
2
 
3
3
  import (
4
4
  "fmt"
@@ -52,7 +52,7 @@ func main() {
52
52
  }
53
53
  slog.Info("server stopped")
54
54
  }
55
- `}function R(e){return `module ${e.module_path}
55
+ `}function T(e){return `module ${e.module_path}
56
56
 
57
57
  go ${e.go_version}
58
58
 
@@ -61,32 +61,7 @@ require (
61
61
  github.com/swaggo/fiber-swagger v1.3.0
62
62
  github.com/swaggo/swag v1.16.3
63
63
  )
64
-
65
- require (
66
- github.com/KyleBanks/depth v1.2.1 // indirect
67
- github.com/andybalholm/brotli v1.1.0 // indirect
68
- github.com/ghodss/yaml v1.0.0 // indirect
69
- github.com/go-openapi/jsonpointer v0.21.0 // indirect
70
- github.com/go-openapi/jsonreference v0.21.0 // indirect
71
- github.com/go-openapi/spec v0.21.0 // indirect
72
- github.com/go-openapi/swag v0.23.0 // indirect
73
- github.com/josharian/intern v1.0.0 // indirect
74
- github.com/klauspost/compress v1.17.6 // indirect
75
- github.com/mailru/easyjson v0.7.7 // indirect
76
- github.com/mattn/go-colorable v0.1.13 // indirect
77
- github.com/mattn/go-isatty v0.0.20 // indirect
78
- github.com/mattn/go-runewidth v0.0.15 // indirect
79
- github.com/rivo/uniseg v0.2.0 // indirect
80
- github.com/swaggo/files v1.0.1 // indirect
81
- github.com/valyala/bytebufferpool v1.0.0 // indirect
82
- github.com/valyala/fasthttp v1.52.0 // indirect
83
- github.com/valyala/tcplisten v1.0.0 // indirect
84
- golang.org/x/net v0.25.0 // indirect
85
- golang.org/x/sys v0.16.0 // indirect
86
- golang.org/x/tools v0.21.0 // indirect
87
- gopkg.in/yaml.v2 v2.4.0 // indirect
88
- )
89
- `}function w(e){return `package config
64
+ `}function q(e){return `package config
90
65
 
91
66
  import (
92
67
  "log/slog"
@@ -139,7 +114,7 @@ func getEnv(key, fallback string) string {
139
114
  }
140
115
  return fallback
141
116
  }
142
- `}function S(e){return `package server
117
+ `}function O(e){return `package server
143
118
 
144
119
  import (
145
120
  "net/http"
@@ -205,7 +180,7 @@ func NewApp(cfg *config.Config) *fiber.App {
205
180
 
206
181
  return app
207
182
  }
208
- `}function _(){return `package handlers
183
+ `}function y(){return `package handlers
209
184
 
210
185
  import (
211
186
  "time"
@@ -243,7 +218,7 @@ func Readiness(c *fiber.Ctx) error {
243
218
  "time": time.Now().UTC().Format(time.RFC3339),
244
219
  })
245
220
  }
246
- `}function T(e){return `package handlers_test
221
+ `}function C(e){return `package handlers_test
247
222
 
248
223
  import (
249
224
  "encoding/json"
@@ -292,7 +267,7 @@ func TestReadiness(t *testing.T) {
292
267
  t.Fatalf("expected 200, got %d: %s", resp.StatusCode, resp.Status)
293
268
  }
294
269
  }
295
- `}function y(){return `# \u2500\u2500 Build stage \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
270
+ `}function N(){return `# \u2500\u2500 Build stage \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
296
271
  FROM golang:1.24-alpine AS builder
297
272
 
298
273
  # Build-time version injection
@@ -321,7 +296,7 @@ EXPOSE 3000
321
296
  HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \\
322
297
  CMD wget -qO- http://localhost:3000/api/v1/health/live || exit 1
323
298
  ENTRYPOINT ["/server"]
324
- `}function O(e){return `version: "3.9"
299
+ `}function E(e){return `version: "3.9"
325
300
 
326
301
  services:
327
302
  api:
@@ -336,53 +311,7 @@ services:
336
311
  CORS_ALLOW_ORIGINS: "*"
337
312
  RATE_LIMIT_RPS: "100"
338
313
  restart: unless-stopped
339
- `}function C(e){return `.PHONY: dev run build test cover lint fmt tidy docs docker-up docker-down
340
-
341
- # Build-time metadata
342
- VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
343
- COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "none")
344
- DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
345
- LDFLAGS = -ldflags "-s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)"
346
- # Go tool binaries are installed to GOPATH/bin; include it so \`air\` and \`swag\` are found.
347
- GOBIN ?= $(shell go env GOPATH)/bin
348
-
349
- # Hot reload \u2014 installs air on first use
350
- dev:
351
- @test -x "$(GOBIN)/air" || go install github.com/air-verse/air@latest
352
- $(GOBIN)/air
353
-
354
- run:
355
- go run $(LDFLAGS) ./cmd/server
356
-
357
- build:
358
- go build $(LDFLAGS) -o bin/${e.project_name} ./cmd/server
359
-
360
- test:
361
- go test ./... -v -race
362
-
363
- cover:
364
- go test ./... -race -coverprofile=coverage.out
365
- go tool cover -html=coverage.out -o coverage.html
366
- @echo "Coverage report: coverage.html"
367
-
368
- # Generate Swagger docs \u2014 installs swag on first use
369
- docs:
370
- @test -x "$(GOBIN)/swag" || go install github.com/swaggo/swag/cmd/swag@latest
371
- $(GOBIN)/swag init -g main.go -d cmd/server,internal/handlers,internal/apierr -o docs --parseDependency
372
- tidy:
373
- go mod tidy
374
-
375
- docker-up:
376
- go mod tidy
377
- docker compose up --build \\
378
- --build-arg VERSION=$(VERSION) \\
379
- --build-arg COMMIT=$(COMMIT) \\
380
- --build-arg DATE=$(DATE) \\
381
- -d
382
-
383
- docker-down:
384
- docker compose down
385
- `}function q(e){return `# Application
314
+ `}function L(e){return d$1({projectName:e.project_name,devCommand:"$(GOBIN)/air",runCommand:"go run $(LDFLAGS) ./cmd/server",testCommand:"go test ./... -v -race"})}function G(e){return `# Application
386
315
  PORT=${e.port}
387
316
  APP_ENV=development
388
317
  LOG_LEVEL=debug
@@ -392,7 +321,7 @@ CORS_ALLOW_ORIGINS=*
392
321
 
393
322
  # Rate limiting \u2014 max requests per IP per second
394
323
  RATE_LIMIT_RPS=100
395
- `}function E(){return `# Binaries
324
+ `}function A(){return `# Binaries
396
325
  bin/
397
326
  *.exe
398
327
  *.exe~
@@ -432,7 +361,7 @@ docs/docs.go
432
361
  # OS
433
362
  .DS_Store
434
363
  Thumbs.db
435
- `}function N(e){return `name: CI
364
+ `}function I(e){return `name: CI
436
365
 
437
366
  on:
438
367
  push:
@@ -486,7 +415,7 @@ jobs:
486
415
  uses: golangci/golangci-lint-action@v6
487
416
  with:
488
417
  version: latest
489
- `}function L(e){return `# ${c(e.project_name)}
418
+ `}function F(e){return `# ${b$1(e.project_name)}
490
419
 
491
420
  > ${e.description}
492
421
 
@@ -601,7 +530,7 @@ ${e.project_name}/
601
530
  ## License
602
531
 
603
532
  ${e.app_version} \xB7 ${e.author}
604
- `}function I(){return `package middleware
533
+ `}function x(){return `package middleware
605
534
 
606
535
  import (
607
536
  "crypto/rand"
@@ -707,7 +636,7 @@ func TestRequestID_IsReused(t *testing.T) {
707
636
  t.Fatalf("expected X-Request-ID to be reused, got %q", id)
708
637
  }
709
638
  }
710
- `}function A(){return `// Package apierr provides a consistent JSON error envelope for all API responses.
639
+ `}function P(){return `// Package apierr provides a consistent JSON error envelope for all API responses.
711
640
  //
712
641
  // Every error response looks like:
713
642
  //
@@ -771,7 +700,7 @@ func InternalError(c *fiber.Ctx, _ error) error {
771
700
  func TooManyRequests(c *fiber.Ctx, msg string) error {
772
701
  return reply(c, http.StatusTooManyRequests, msg, "TOO_MANY_REQUESTS")
773
702
  }
774
- `}function G(e){return `package apierr_test
703
+ `}function D(e){return `package apierr_test
775
704
 
776
705
  import (
777
706
  "encoding/json"
@@ -903,11 +832,11 @@ func TestTooManyRequests(t *testing.T) {
903
832
  t.Fatalf("expected TOO_MANY_REQUESTS, got %q", body.Code)
904
833
  }
905
834
  }
906
- `}function x(e){return `// Package docs provides the swaggo-generated OpenAPI specification.
835
+ `}function M(e){return `// Package docs provides the swaggo-generated OpenAPI specification.
907
836
  //
908
837
  // Run \`make docs\` to regenerate after changing handler annotations.
909
838
  //
910
- // @title ${c(e.project_name)} API
839
+ // @title ${b$1(e.project_name)} API
911
840
  // @version ${e.app_version}
912
841
  // @description ${e.description}
913
842
  // @host localhost:${e.port}
@@ -917,7 +846,7 @@ func TestTooManyRequests(t *testing.T) {
917
846
  // @contact.name ${e.author}
918
847
  // @license.name MIT
919
848
  package docs
920
- `}function F(e){return `package handlers
849
+ `}function B(e){return `package handlers
921
850
 
922
851
  import (
923
852
  "net/http"
@@ -959,7 +888,7 @@ func EchoParams(c *fiber.Ctx) error {
959
888
  RequestID: rid,
960
889
  })
961
890
  }
962
- `}function D(e){return `package handlers_test
891
+ `}function $(e){return `package handlers_test
963
892
 
964
893
  import (
965
894
  "encoding/json"
@@ -1027,7 +956,7 @@ func TestEchoParams_EmptyName(t *testing.T) {
1027
956
  t.Fatalf("expected code=BAD_REQUEST, got %v", body["code"])
1028
957
  }
1029
958
  }
1030
- `}function P(e){return `package config_test
959
+ `}function j(e){return `package config_test
1031
960
 
1032
961
  import (
1033
962
  "log/slog"
@@ -1095,7 +1024,7 @@ func TestLoad_Defaults(t *testing.T) {
1095
1024
  t.Errorf("expected default LogLevel=debug (development env), got %q", cfg.LogLevel)
1096
1025
  }
1097
1026
  }
1098
- `}function M(){return `package middleware
1027
+ `}function H(){return `package middleware
1099
1028
 
1100
1029
  import (
1101
1030
  "os"
@@ -1123,7 +1052,7 @@ func CORS() fiber.Handler {
1123
1052
  MaxAge: 600,
1124
1053
  })
1125
1054
  }
1126
- `}function $(e){return `package middleware_test
1055
+ `}function U(e){return `package middleware_test
1127
1056
 
1128
1057
  import (
1129
1058
  "net/http"
@@ -1195,7 +1124,7 @@ func TestCORS_Default_Origin(t *testing.T) {
1195
1124
  t.Fatal("expected CORS header when origins defaulting to *")
1196
1125
  }
1197
1126
  }
1198
- `}function B(e){return `package server_test
1127
+ `}function V(e){return `package server_test
1199
1128
 
1200
1129
  import (
1201
1130
  "encoding/json"
@@ -1284,7 +1213,7 @@ func TestServer_Docs_Redirect(t *testing.T) {
1284
1213
  t.Fatalf("expected Location=/docs/index.html, got %q", loc)
1285
1214
  }
1286
1215
  }
1287
- `}function j(e){return `package middleware
1216
+ `}function J(e){return `package middleware
1288
1217
 
1289
1218
  import (
1290
1219
  "os"
@@ -1317,7 +1246,7 @@ func RateLimit() fiber.Handler {
1317
1246
  },
1318
1247
  })
1319
1248
  }
1320
- `}function H(e){return `package middleware_test
1249
+ `}function W(e){return `package middleware_test
1321
1250
 
1322
1251
  import (
1323
1252
  "net/http"
@@ -1393,7 +1322,7 @@ func TestRateLimit_InvalidRPS(t *testing.T) {
1393
1322
  t.Fatalf("expected 200 with invalid RPS env, got %d", resp.StatusCode)
1394
1323
  }
1395
1324
  }
1396
- `}function U(e){return `# Air \u2014 live reload for Go projects
1325
+ `}function K(e){return `# Air \u2014 live reload for Go projects
1397
1326
  # https://github.com/air-verse/air
1398
1327
  root = "."
1399
1328
  tmp_dir = "tmp"
@@ -1417,7 +1346,7 @@ tmp_dir = "tmp"
1417
1346
 
1418
1347
  [log]
1419
1348
  time = false
1420
- `}function V(e){return `run:
1349
+ `}function X(e){return `run:
1421
1350
  timeout: 5m
1422
1351
 
1423
1352
  linters:
@@ -1463,110 +1392,6 @@ issues:
1463
1392
  linters:
1464
1393
  - errcheck
1465
1394
  - wrapcheck
1466
- `}function J(){return JSON.stringify({engine:"npm",runtime:"go"},null,2)}function W(e){return `#!/usr/bin/env sh
1467
- # RapidKit Go/Fiber project launcher \u2014 generated by RapidKit CLI
1468
- # https://getrapidkit.com
1469
-
1470
- SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
1471
- CMD="\${1:-}"
1472
- shift 2>/dev/null || true
1473
-
1474
- case "$CMD" in
1475
- init)
1476
- cd "$SCRIPT_DIR"
1477
- echo "\u{1F439} Initializing Go/Fiber project\u2026"
1478
- GOBIN="$(go env GOPATH)/bin"
1479
- echo " \u2192 installing air (hot reload)\u2026"
1480
- go install github.com/air-verse/air@latest 2>/dev/null && echo " \u2713 air" || echo " \u26A0 air install failed (run: go install github.com/air-verse/air@latest)"
1481
- echo " \u2192 installing swag (swagger)\u2026"
1482
- go install github.com/swaggo/swag/cmd/swag@latest 2>/dev/null && echo " \u2713 swag" || echo " \u26A0 swag install failed (run: go install github.com/swaggo/swag/cmd/swag@latest)"
1483
- if [ ! -f ".env" ] && [ -f ".env.example" ]; then
1484
- cp .env.example .env && echo " \u2713 .env created from .env.example"
1485
- fi
1486
- go mod tidy && echo " \u2713 go mod tidy"
1487
- echo " \u2192 generating swagger docs (first build)\u2026"
1488
- "$(go env GOPATH)/bin/swag" init -g main.go -d cmd/server,internal/handlers,internal/apierr -o docs --parseDependency 2>/dev/null && echo " \u2713 swagger docs generated" || echo " \u26A0 swagger docs skipped (run: rapidkit docs)"
1489
- echo "\u2705 Ready \u2014 run: rapidkit dev"
1490
- ;;
1491
- dev)
1492
- cd "$SCRIPT_DIR"
1493
- echo "\u{1F4D6} Syncing swagger docs\u2026"
1494
- "$(go env GOPATH)/bin/swag" init -g main.go -d cmd/server,internal/handlers,internal/apierr -o docs --parseDependency 2>/dev/null || true
1495
- if [ -f "$SCRIPT_DIR/Makefile" ]; then
1496
- exec make -C "$SCRIPT_DIR" dev "$@"
1497
- else
1498
- exec go run ./cmd/server "$@"
1499
- fi
1500
- ;;
1501
- start)
1502
- BIN="$SCRIPT_DIR/bin/${e.project_name}"
1503
- if [ ! -f "$BIN" ]; then
1504
- make -C "$SCRIPT_DIR" build
1505
- fi
1506
- exec "$BIN" "$@"
1507
- ;;
1508
- build)
1509
- exec make -C "$SCRIPT_DIR" build "$@"
1510
- ;;
1511
- test)
1512
- exec make -C "$SCRIPT_DIR" test "$@"
1513
- ;;
1514
- lint)
1515
- exec make -C "$SCRIPT_DIR" lint "$@"
1516
- ;;
1517
- format|fmt)
1518
- exec make -C "$SCRIPT_DIR" fmt "$@"
1519
- ;;
1520
- docs)
1521
- exec make -C "$SCRIPT_DIR" docs "$@"
1522
- ;;
1523
- help|--help|-h)
1524
- echo "RapidKit \u2014 Go/Fiber project: ${e.project_name}"
1525
- echo ""
1526
- echo "Usage: rapidkit <command>"
1527
- echo ""
1528
- echo " init Install tools + create .env (air, swag, go mod tidy)"
1529
- echo " dev Hot reload dev server (make dev \u2014 requires air)"
1530
- echo " start Run compiled binary (make build + bin)"
1531
- echo " build Build binary (make build)"
1532
- echo " docs Generate Swagger docs (make docs \u2014 requires swag)"
1533
- echo " test Run tests (make test)"
1534
- echo " lint Run linter (make lint)"
1535
- echo " format Format code (make fmt)"
1536
- ;;
1537
- *)
1538
- if [ -n "$CMD" ]; then
1539
- echo "rapidkit: unknown command: $CMD" >&2
1540
- fi
1541
- echo "Available: init, dev, start, build, docs, test, lint, format" >&2
1542
- exit 1
1543
- ;;
1544
- esac
1545
- `}function K(e){return `@echo off
1546
- rem RapidKit Go/Fiber project launcher \u2014 Windows
1547
- set CMD=%1
1548
- if "%CMD%"=="" goto usage
1549
- shift
1550
-
1551
- if "%CMD%"=="init" (
1552
- echo Initializing Go/Fiber project...
1553
- go install github.com/air-verse/air@latest
1554
- go install github.com/swaggo/swag/cmd/swag@latest
1555
- if not exist .env if exist .env.example copy .env.example .env
1556
- go mod tidy
1557
- exit /b %ERRORLEVEL%
1558
- )
1559
- if "%CMD%"=="dev" ( make dev %* & exit /b %ERRORLEVEL% )
1560
- if "%CMD%"=="build" ( make build %* & exit /b %ERRORLEVEL% )
1561
- if "%CMD%"=="test" ( make test %* & exit /b %ERRORLEVEL% )
1562
- if "%CMD%"=="lint" ( make lint %* & exit /b %ERRORLEVEL% )
1563
- if "%CMD%"=="format" ( make fmt %* & exit /b %ERRORLEVEL% )
1564
- if "%CMD%"=="docs" ( make docs %* & exit /b %ERRORLEVEL% )
1565
- if "%CMD%"=="start" ( bin\\${e.project_name}.exe %* & exit /b %ERRORLEVEL% )
1566
-
1567
- :usage
1568
- echo Available: init, dev, start, build, docs, test, lint, format
1569
- exit /b 1
1570
- `}function X(e,o){return JSON.stringify({kit_name:"gofiber.standard",runtime:"go",module_support:false,project_name:e.project_name,module_path:e.module_path,app_version:e.app_version,created_by:"rapidkit-npm",rapidkit_version:o,created_at:new Date().toISOString()},null,2)}async function ie(e,o){let r={project_name:o.project_name,module_path:o.module_path||o.project_name,author:o.author||"RapidKit User",description:o.description||`Go/Fiber REST API \u2014 ${o.project_name}`,go_version:o.go_version||"1.24",app_version:o.app_version||"0.1.0",port:o.port||"3000",skipGit:o.skipGit??false},p=b$1();try{await execa("go",["version"],{timeout:3e3});}catch{console.log(i.yellow("\n\u26A0 Go not found in PATH \u2014 project will be scaffolded, but `go mod tidy` requires Go 1.21+")),console.log(i.gray(` Install: https://go.dev/dl/
1571
- `));}let a=h(`Generating Go/Fiber project: ${r.project_name}\u2026`).start();try{let t=(f,m)=>b(s.join(e,f),m),u=s.join(e,"rapidkit"),g=s.join(e,"rapidkit.cmd");await Promise.all([t("cmd/server/main.go",v(r)),t("go.mod",R(r)),t("internal/config/config.go",w(r)),t("internal/server/server.go",S(r)),t("internal/middleware/requestid.go",I()),t("internal/middleware/requestid_test.go",k(r)),t("internal/apierr/apierr.go",A()),t("internal/apierr/apierr_test.go",G(r)),t("internal/handlers/health.go",_()),t("internal/handlers/health_test.go",T(r)),t("internal/handlers/example.go",F(r)),t("internal/handlers/example_test.go",D(r)),t("internal/config/config_test.go",P(r)),t("internal/middleware/cors.go",M()),t("internal/middleware/cors_test.go",$(r)),t("internal/middleware/ratelimit.go",j(r)),t("internal/middleware/ratelimit_test.go",H(r)),t("internal/server/server_test.go",B(r)),t("docs/doc.go",x(r)),t(".air.toml",U(r)),t("Dockerfile",y()),t("docker-compose.yml",O(r)),t("Makefile",C(r)),t(".golangci.yml",V(r.module_path)),t(".env.example",q(r)),t(".gitignore",E()),t(".github/workflows/ci.yml",N(r)),t("README.md",L(r)),t(".rapidkit/project.json",X(r,p)),t(".rapidkit/context.json",J()),t("rapidkit",W(r)),t("rapidkit.cmd",K(r))]),await promises.chmod(u,493),await promises.chmod(g,493),a.succeed(i.green(`Project created at ${e}`));try{a.start("Fetching Go dependencies\u2026"),await execa("go",["mod","tidy"],{cwd:e,timeout:12e4}),a.succeed(i.gray("\u2713 go mod tidy completed"));}catch{a.warn(i.yellow("\u26A0 go mod tidy failed \u2014 run manually: go mod tidy"));}if(!r.skipGit)try{await execa("git",["init"],{cwd:e}),await execa("git",["add","-A"],{cwd:e}),await execa("git",["commit","-m","chore: initial scaffold (rapidkit gofiber.standard)"],{cwd:e}),console.log(i.gray("\u2713 git repository initialized"));}catch{console.log(i.gray("\u26A0 git init skipped (git not found or error)"));}console.log(""),console.log(i.bold("\u2705 Go/Fiber project ready!")),console.log(""),console.log(i.cyan("Next steps:")),console.log(i.white(` cd ${r.project_name}`)),console.log(i.white(" make run # start dev server")),console.log(i.white(" make test # run tests")),console.log(""),console.log(i.gray("Server will listen on port "+r.port)),console.log(i.gray(" http://localhost:"+r.port+"/api/v1/health/live")),console.log(i.gray(" http://localhost:"+r.port+"/api/v1/health/ready")),console.log(""),console.log(i.yellow("\u2139 RapidKit modules are not available for Go projects (module system uses Python/pip).")),console.log("");}catch(t){throw a.fail(i.red("Failed to generate Go/Fiber project")),t}}
1572
- export{ie as generateGoFiberKit};
1395
+ `}function Q(){return JSON.stringify({engine:"npm",runtime:"go"},null,2)}function Y(e$1){return e({runtimeLabel:"Go/Fiber",projectName:e$1.project_name,fallbackDevCommand:'exec go run ./cmd/server "$@"'})}function z(e){return f({runtimeLabel:"Go/Fiber",projectName:e.project_name})}function Z(e,i){return JSON.stringify({kit_name:"gofiber.standard",runtime:"go",module_support:false,project_name:e.project_name,module_path:e.module_path,app_version:e.app_version,created_by:"rapidkit-npm",rapidkit_version:i,created_at:new Date().toISOString()},null,2)}async function pe(e,i){let r={project_name:i.project_name,module_path:i.module_path||i.project_name,author:i.author||"RapidKit User",description:i.description||`Go/Fiber REST API \u2014 ${i.project_name}`,go_version:i.go_version||a,app_version:i.app_version||"0.1.0",port:i.port||"3000",skipGit:i.skipGit??false},h=b();try{await execa("go",["version"],{timeout:3e3});}catch{console.log(o.yellow("\n\u26A0 Go not found in PATH \u2014 project will be scaffolded, but `go mod tidy` requires Go 1.21+")),console.log(o.gray(` Install: https://go.dev/dl/
1396
+ `));}let n=S(`Generating Go/Fiber project: ${r.project_name}\u2026`).start();try{let t=(R,w)=>c(d.join(e,R),w),b=d.join(e,"rapidkit"),v=d.join(e,"rapidkit.cmd");await Promise.all([t("cmd/server/main.go",_(r)),t("go.mod",T(r)),t("internal/config/config.go",q(r)),t("internal/server/server.go",O(r)),t("internal/middleware/requestid.go",x()),t("internal/middleware/requestid_test.go",k(r)),t("internal/apierr/apierr.go",P()),t("internal/apierr/apierr_test.go",D(r)),t("internal/handlers/health.go",y()),t("internal/handlers/health_test.go",C(r)),t("internal/handlers/example.go",B(r)),t("internal/handlers/example_test.go",$(r)),t("internal/config/config_test.go",j(r)),t("internal/middleware/cors.go",H()),t("internal/middleware/cors_test.go",U(r)),t("internal/middleware/ratelimit.go",J(r)),t("internal/middleware/ratelimit_test.go",W(r)),t("internal/server/server_test.go",V(r)),t("docs/doc.go",M(r)),t(".air.toml",K(r)),t("Dockerfile",N()),t("docker-compose.yml",E(r)),t("Makefile",L(r)),t(".golangci.yml",X(r.module_path)),t(".env.example",G(r)),t(".gitignore",A()),t(".github/workflows/ci.yml",I(r)),t("README.md",F(r)),t(".rapidkit/project.json",Z(r,h)),t(".rapidkit/context.json",Q()),t("rapidkit",Y(r)),t("rapidkit.cmd",z(r))]),await promises.chmod(b,493),await promises.chmod(v,493),n.succeed(o.green(`Project created at ${e}`));try{n.start("Fetching Go dependencies\u2026"),await execa("go",["mod","tidy"],{cwd:e,timeout:12e4}),n.succeed(o.gray("\u2713 go mod tidy completed"));}catch{n.warn(o.yellow("\u26A0 go mod tidy failed \u2014 run manually: go mod tidy"));}if(!r.skipGit)try{await execa("git",["init"],{cwd:e}),await execa("git",["add","-A"],{cwd:e}),await execa("git",["commit","-m","chore: initial scaffold (rapidkit gofiber.standard)"],{cwd:e}),console.log(o.gray("\u2713 git repository initialized"));}catch{console.log(o.gray("\u26A0 git init skipped (git not found or error)"));}console.log(""),console.log(o.bold("\u2705 Go/Fiber project ready!")),console.log(""),console.log(o.cyan("Next steps:")),console.log(o.white(` cd ${r.project_name}`)),console.log(o.white(" make run # start dev server")),console.log(o.white(" make test # run tests")),console.log(""),console.log(o.gray("Server will listen on port "+r.port)),console.log(o.gray(" http://localhost:"+r.port+"/api/v1/health/live")),console.log(o.gray(" http://localhost:"+r.port+"/api/v1/health/ready")),console.log(""),console.log(o.yellow("\u2139 RapidKit modules are not available for Go projects (module system uses Python/pip).")),console.log("");}catch(t){throw n.fail(o.red("Failed to generate Go/Fiber project")),t}}
1397
+ export{pe as generateGoFiberKit};