rapidkit 0.23.1 → 0.24.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,33 @@
1
+ import Q from'crypto';import G from'os';import c from'path';import*as p from'fs-extra';import {execa}from'execa';var q=["version","project","create","init","dev","start","build","test","lint","format","add","list","info","upgrade","diff","doctor","license","commands","reconcile","rollback","uninstall","checkpoint","optimize","snapshot","frameworks","modules","merge"],S=new Set(q);function V(){return process.platform==="win32"?["python","py","python3"]:["python3","python"]}function w(t,n){return t==="py"?["-3",...n]:n}function N(t){if(!t)return t;let n=["Installed Poetry version does not support '--no-update'. Falling back to 'poetry lock'."];return t.split(/\r?\n/).filter(s=>!n.some(i=>s.includes(i))).join(`
2
+ `)}var g=class extends Error{code;constructor(n,e){super(e),this.code=n;}};function x(t){if(t instanceof g)switch(t.code){case "PYTHON_NOT_FOUND":return `RapidKit (npm) could not find Python (python3/python/py) on your PATH.
3
+ Install Python 3.10+ and ensure \`${process.platform==="win32"?"python":"python3"}\` is available, then retry.
4
+ Tip: if you are inside a RapidKit project, use the local ./rapidkit launcher.`;case "BRIDGE_VENV_CREATE_FAILED":return `RapidKit (npm) failed to create its bridge virtual environment.
5
+ `+(process.platform==="win32"?`Ensure Python is installed with venv support.
6
+ `:`Ensure Python venv support is installed (e.g., python3-venv).
7
+ `)+`Details: ${t.message}`;case "BRIDGE_PIP_BOOTSTRAP_FAILED":return `RapidKit (npm) could not bootstrap pip inside the bridge virtual environment.
8
+ `+(process.platform==="win32"?`Ensure pip is available for your Python installation and retry.
9
+ `:`Install python3-venv/python3-pip and retry.
10
+ `)+`Details: ${t.message}`;case "BRIDGE_PIP_UPGRADE_FAILED":return `RapidKit (npm) could not upgrade pip in the bridge virtual environment.
11
+ Check your network/proxy or disable RAPIDKIT_BRIDGE_UPGRADE_PIP.
12
+ Details: ${t.message}`;case "BRIDGE_PIP_INSTALL_FAILED":return `RapidKit (npm) could not install rapidkit-core in the bridge virtual environment.
13
+ Check your network/proxy, or install manually with: pipx install rapidkit-core.
14
+ Details: ${t.message}`;default:return `RapidKit (npm) bridge error: ${t.message}`}return `RapidKit (npm) failed to run the Python core engine: ${t instanceof Error?t.message:String(t)}`}function I(){let t=process.env.RAPIDKIT_CORE_PYTHON_PACKAGE;return t&&t.trim()?t.trim():"rapidkit-core"}function Z(){let t=I(),n=process.env.RAPIDKIT_CORE_PYTHON_PACKAGE_ID,e=n&&n.trim()?`${t}|${n.trim()}`:t;return Q.createHash("sha256").update(e).digest("hex").slice(0,12)}function R(){let t=process.env.XDG_CACHE_HOME;return t&&t.trim()?t:c.join(G.homedir(),".cache")}function tt(){return c.join(R(),"rapidkit","npm-bridge","venv")}function K(){let t=Z();return c.join(R(),"rapidkit","npm-bridge",`venv-${t}`)}function T(t){return process.platform==="win32"?c.join(t,"Scripts","python.exe"):c.join(t,"bin","python")}function $(t){return process.platform==="win32"?c.join(t,"Scripts","rapidkit.exe"):c.join(t,"bin","rapidkit")}function et(t){return /[<>=!~]=|@|\.whl$|\.tar\.gz$|\.zip$|git\+|https?:\/\//.test(t)}function nt(t){return c.dirname(c.dirname(t))}function L(){return c.join(R(),"rapidkit","npm-bridge","core-commands.json")}async function J(t){let n=!!process.env.RAPIDKIT_DEBUG,e=r=>{n&&process.stderr.write(`[DEBUG] tryRapidkit(${t}): ${r}
15
+ `);};try{e("probing interpreter-specific rapidkit script");let s=((await execa(t,w(t,["-c","import sysconfig, os; print(os.path.join(sysconfig.get_path('scripts'), 'rapidkit'))"]),{reject:false,stdio:"pipe",timeout:2e3})).stdout??"").toString().trim();if(e(`script path: ${s}`),s)try{if(await p.pathExists(s)){e(`found script at ${s}; invoking --version --json`);let i=await execa(s,["--version","--json"],{reject:false,stdio:"pipe",timeout:4e3});if(e(`script exitCode=${i.exitCode}`),i.exitCode===0){let a=(i.stdout??"").toString().trim();try{let o=JSON.parse(a),d=!!o&&typeof o=="object"&&o!==null&&"version"in o;if(e(`script JSON parse ok=${d}`),d)return true}catch{e("script output not valid JSON");}}}}catch(i){e(`interpreter-specific script probe failed: ${String(i)}`);}}catch(r){e(`interpreter-specific script probe error: ${String(r)}`);}try{e('probing importlib.find_spec("rapidkit")');let r=await execa(t,w(t,["-c","import importlib.util; print(1 if importlib.util.find_spec('rapidkit') else 0)"]),{reject:false,stdio:"pipe",timeout:2e3});if(e(`import probe exitCode=${r.exitCode} stdout=${(r.stdout??"").toString().trim()}`),r.exitCode===0&&(r.stdout??"").toString().trim()==="1")return true}catch(r){e(`import probe error: ${String(r)}`);}try{e("probing python -m rapidkit");let r=await execa(t,w(t,["-m","rapidkit","--version","--json"]),{reject:false,stdio:"pipe",timeout:8e3});if(e(`-m probe exitCode=${r.exitCode}`),r.exitCode===0)return true}catch(r){e(`-m probe error: ${String(r)}`);}try{e("probing PATH for rapidkit executables");let r=(process.env.PATH??"").split(c.delimiter).filter(Boolean);for(let s of r){let i=c.join(s,process.platform==="win32"?"rapidkit.exe":"rapidkit");try{if(await p.pathExists(i)){e(`found candidate on PATH: ${i}; invoking --version --json`);let a=await execa(i,["--version","--json"],{reject:false,stdio:"pipe",timeout:4e3});if(e(`candidate exitCode=${a.exitCode}`),a.exitCode===0){let o=(a.stdout??"").toString().trim();try{let d=JSON.parse(o);if(d&&typeof d=="object"&&d!==null&&"version"in d)return true}catch{e("candidate output not valid JSON, skipping");}}}}catch(a){e(`error probing candidate ${i}: ${String(a)}`);}}return e("no valid rapidkit found on PATH"),false}catch(r){return e(`PATH probe error: ${String(r)}`),false}}async function D(t){let n=(t??"").toString().trim();if(!n)return false;try{let e=JSON.parse(n);return !!e&&typeof e=="object"&&e!==null&&"version"in e}catch{return false}}async function rt(t){let n=process.platform==="win32",e=n?c.join(".venv","Scripts","rapidkit.exe"):c.join(".venv","bin","rapidkit"),r=n?c.join(".venv","Scripts","python.exe"):c.join(".venv","bin","python"),s=t;for(let i=0;i<25;i+=1){let a=c.join(s,e);if(await p.pathExists(a)){let m=await execa(a,["--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:s});if(m.exitCode===0&&await D(m.stdout))return {cmd:a,baseArgs:[]}}let o=c.join(s,r);if(await p.pathExists(o)){let m=await execa(o,["-m","rapidkit","--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:s});if(m.exitCode===0&&await D(m.stdout))return {cmd:o,baseArgs:["-m","rapidkit"]}}let d=c.dirname(s);if(d===s)break;s=d;}return null}async function it(t){try{let n=c.join(t,".python-version");if(await p.pathExists(n)){let r=(await p.readFile(n,"utf-8")).trim();if(r)return r}}catch{}try{let n=c.join(t,".rapidkit-workspace");if(await p.pathExists(n)){let e=await p.readFile(n,"utf-8"),r=JSON.parse(e);if(r.pythonVersion)return r.pythonVersion}}catch{}return null}async function O(t){if(t&&t.trim())try{let i=await rt(t);if(i){let a=c.dirname(i.cmd).includes(".venv")?c.dirname(c.dirname(c.dirname(i.cmd))):c.dirname(i.cmd),o=await it(a);return o&&(process.env.PYENV_VERSION=o),i}}catch{}let n=await st();if(n.kind==="venv"){let i=nt(n.pythonPath),a=$(i);return await p.pathExists(a)?{cmd:a,baseArgs:[]}:{cmd:n.pythonPath,baseArgs:["-m","rapidkit"]}}try{if((await execa(n.cmd,["-m","rapidkit","--version","--json"],{reject:false,stdio:"pipe",timeout:4e3})).exitCode===0)return {cmd:n.cmd,baseArgs:["-m","rapidkit"]}}catch{}try{let a=((await execa(n.cmd,["-c","import sysconfig, os; print(os.path.join(sysconfig.get_path('scripts'), 'rapidkit'))"],{reject:false,stdio:"pipe",timeout:2e3})).stdout??"").toString().trim();if(a&&await p.pathExists(a))try{let o=await execa(a,["--version","--json"],{reject:false,stdio:"pipe",timeout:4e3});if(o.exitCode===0&&await D(o.stdout))return {cmd:a,baseArgs:[]}}catch{}}catch{}let e=K(),r=await k(n.cmd),s=$(e);return await p.pathExists(s)?{cmd:s,baseArgs:[]}:{cmd:r,baseArgs:["-m","rapidkit"]}}async function j(){for(let t of V())try{return await execa(t,w(t,["--version"]),{reject:false,stdio:"pipe",timeout:2e3}),t}catch{}return null}async function ot(){let t=!!process.env.RAPIDKIT_DEBUG,n=e=>{t&&process.stderr.write(`[DEBUG] checkRapidkitCore: ${e}
16
+ `);};for(let e of ["python3","python","py","python3.10","python3.11","python3.12"])try{n(`Method 1: trying ${e} import`);let r=await execa(e,w(e,["-c","import rapidkit_core; print(1)"]),{reject:false,stdio:"pipe",timeout:3e3});if(r.exitCode===0&&r.stdout?.trim()==="1")return n(`\u2713 Found via ${e} import`),true}catch{continue}for(let e of ["python3","python","py"])try{n(`Method 2: trying ${e} -m pip show`);let r=await execa(e,w(e,["-m","pip","show","rapidkit-core"]),{reject:false,stdio:"pipe",timeout:3e3});if(r.exitCode===0&&r.stdout?.includes("Name: rapidkit-core"))return n(`\u2713 Found via ${e} -m pip show`),true}catch{continue}for(let e of ["pip","pip3"])try{n(`Method 3: trying ${e} show`);let r=await execa(e,["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:3e3});if(r.exitCode===0&&r.stdout?.includes("Name: rapidkit-core"))return n(`\u2713 Found via ${e} show`),true}catch{continue}try{n("Method 4: checking pyenv versions");let e=await execa("pyenv",["versions","--bare"],{reject:false,stdio:"pipe",timeout:3e3});if(e.exitCode===0&&e.stdout){let r=e.stdout.split(`
17
+ `).filter(s=>s.trim());n(`Found pyenv versions: ${r.join(", ")}`);for(let s of r){let i=process.env.PYENV_ROOT||c.join(G.homedir(),".pyenv"),a=c.join(i,"versions",s.trim(),"bin","pip");try{let o=await execa(a,["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:3e3});if(o.exitCode===0&&o.stdout?.includes("Name: rapidkit-core"))return n(`\u2713 Found in pyenv ${s}`),true}catch{try{let o=await execa("bash",["-c",`PYENV_VERSION=${s.trim()} pyenv exec pip show rapidkit-core`],{reject:false,stdio:"pipe",timeout:3e3});if(o.exitCode===0&&o.stdout?.includes("Name: rapidkit-core"))return n(`\u2713 Found in pyenv ${s} via PYENV_VERSION`),true}catch{continue}}}}}catch{n("pyenv not available");}for(let e of ["python3","python","py"])try{n(`Method 5: checking ${e} user site`);let r=await execa(e,w(e,["-m","site","--user-site"]),{reject:false,stdio:"pipe",timeout:3e3});if(r.exitCode===0&&r.stdout){let s=r.stdout.trim(),i=c.join(s,"rapidkit_core");if(await p.pathExists(i))return n("\u2713 Found in user site-packages"),true}}catch{continue}try{n("Method 6: checking pipx");let e=await execa("pipx",["list"],{reject:false,stdio:"pipe",timeout:3e3});if(e.exitCode===0&&e.stdout?.includes("rapidkit-core"))return n("\u2713 Found via pipx"),true}catch{n("pipx not available");}try{if(n("Method 7: checking poetry"),(await execa("poetry",["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:3e3})).exitCode===0)return n("\u2713 Found via poetry"),true}catch{n("poetry check failed");}try{n("Method 8: checking conda");let e=await execa("conda",["list","rapidkit-core"],{reject:false,stdio:"pipe",timeout:3e3});if(e.exitCode===0&&e.stdout?.includes("rapidkit-core"))return n("\u2713 Found via conda"),true}catch{n("conda not available");}return n("\u2717 Not found in any environment"),false}async function k(t){let n=K(),e=tt(),r=I(),s=[n];!et(r)&&!await p.pathExists(n)&&await p.pathExists(e)&&s.push(e);for(let l of s){let h=T(l);if(await p.pathExists(h))try{let f=await execa(h,["-c","import importlib.util; print(1 if importlib.util.find_spec('rapidkit') else 0)"],{reject:false,stdio:"pipe",timeout:2e3});if(f.exitCode===0&&(f.stdout??"").toString().trim()==="1")return h;await p.remove(l);}catch{await p.remove(l);}}let i=n,a={...process.env,PIP_DISABLE_PIP_VERSION_CHECK:"1",PIP_NO_PYTHON_VERSION_WARNING:"1"},o=Math.max(0,Number(process.env.RAPIDKIT_BRIDGE_PIP_RETRY??"2")),d=Math.max(200,Number(process.env.RAPIDKIT_BRIDGE_PIP_RETRY_DELAY_MS??"800")),m=Math.max(1e4,Number(process.env.RAPIDKIT_BRIDGE_PIP_TIMEOUT_MS??"120000")),v=l=>new Promise(h=>setTimeout(h,l)),E=async(l,h,f)=>{let y=await execa(l,h,{reject:false,stdio:["ignore","pipe","inherit"],env:a,timeout:f});if(y.exitCode===0)return;let b=(y.stdout??"").toString(),A=(y.stderr??"").toString(),C=[b,A].filter(Boolean).join(`
18
+ `),W=C?`${l} ${h.join(" ")}
19
+ ${C}`:`${l} ${h.join(" ")}`;throw new Error(W)},P=async(l,h,f)=>{let y=0;for(;;)try{await E(l,h,f);return}catch(b){if(y>=o)throw b;let A=Math.floor(Math.random()*200),C=d*Math.pow(2,y)+A;y+=1,await v(C);}};try{await p.ensureDir(c.dirname(i));try{await E(t,w(t,["-m","venv",i]),6e4);}catch(f){let y=f instanceof Error?f.message:String(f);throw new g("BRIDGE_VENV_CREATE_FAILED",y)}let l=T(i);if((await execa(l,["-m","pip","--version"],{reject:false,stdio:"pipe",timeout:2e3})).exitCode!==0&&(await execa(l,["-m","ensurepip","--default-pip"],{reject:false,stdio:["ignore","pipe","inherit"],env:a,timeout:6e4})).exitCode!==0)throw new g("BRIDGE_PIP_BOOTSTRAP_FAILED","ensurepip failed; install python3-venv/python3-pip and retry.");if(process.env.RAPIDKIT_BRIDGE_UPGRADE_PIP==="1")try{await P(l,["-m","pip","install","-U","pip"],m);}catch(f){let y=f instanceof Error?f.message:String(f);throw new g("BRIDGE_PIP_UPGRADE_FAILED",y)}try{await P(l,["-m","pip","install","-U",I()],m);}catch(f){let y=f instanceof Error?f.message:String(f);throw new g("BRIDGE_PIP_INSTALL_FAILED",y)}return l}catch(l){if(l instanceof g)throw l;let h=l instanceof Error?l.message:String(l);throw new g("BRIDGE_VENV_BOOTSTRAP_FAILED",h)}}async function st(){if(process.env.RAPIDKIT_BRIDGE_FORCE_VENV==="1"){let e=await j();if(!e)throw new g("PYTHON_NOT_FOUND","No Python interpreter found (python3/python/py).");return {kind:"venv",pythonPath:await k(e)}}for(let e of V())if(await J(e))return {kind:"system",cmd:e};let t=await j();if(!t)throw new g("PYTHON_NOT_FOUND","No Python interpreter found (python3/python/py).");return {kind:"venv",pythonPath:await k(t)}}async function wt(t,n){try{let e=await O(n?.cwd),r=e.cmd,s=[...e.baseArgs,...t];if(t[0]==="init"){let o=await execa(r,s,{cwd:n?.cwd,env:{...process.env,...n?.env},reject:false,stdio:"pipe"}),d=N((o.stdout??"").toString()),m=N((o.stderr??"").toString());return d&&process.stdout.write(d.endsWith(`
20
+ `)?d:`${d}
21
+ `),m&&process.stderr.write(m.endsWith(`
22
+ `)?m:`${m}
23
+ `),typeof o.exitCode=="number"?o.exitCode:1}let a=await execa(r,s,{cwd:n?.cwd,env:{...process.env,...n?.env},reject:false,stdio:"inherit"});return typeof a.exitCode=="number"?a.exitCode:1}catch(e){return process.stderr.write(`${x(e)}
24
+ `),1}}var at=[{pattern:/RapidKitError:\s*Directory '([^']+)' exists and force is not set/,message:t=>`\u274C Directory "${c.basename(t[1])}" already exists.
25
+ \u{1F4A1} Choose a different name, or remove the existing directory first:
26
+ rm -rf ${t[1]}`},{pattern:/RapidKitError:\s*Project name '([^']+)' is (invalid|not allowed)/i,message:t=>`\u274C Invalid project name: "${t[1]}"
27
+ \u{1F4A1} Use lowercase letters, numbers, and hyphens only (e.g. my-api).`},{pattern:/RapidKitError:\s*Kit '([^']+)' not found/i,message:t=>`\u274C Unknown kit: "${t[1]}"
28
+ \u{1F4A1} Run "npx rapidkit list" to see available kits.`},{pattern:/RapidKitError:\s*(.+)/,message:t=>`\u274C ${t[1].trim()}`}];async function vt(t,n){let{spawn:e}=await import('child_process');try{let r=await O(n?.cwd),s=r.cmd,i=[...r.baseArgs,...t];return await new Promise(a=>{let o=e(s,i,{cwd:n?.cwd,env:{...process.env,...n?.env},stdio:["inherit","inherit","pipe"]}),d=[];o.stderr?.on("data",m=>{d.push(m);}),o.on("close",m=>{let v=m??1;if(v!==0&&d.length>0){let E=Buffer.concat(d).toString("utf8");for(let{pattern:P,message:l}of at){let h=E.match(P);if(h){process.stderr.write(l(h)+`
29
+ `),a(v);return}}process.stderr.write(E);}a(v);}),o.on("error",m=>{process.stderr.write(`${x(m)}
30
+ `),a(1);});})}catch(r){return process.stderr.write(`${x(r)}
31
+ `),1}}async function _(t,n){try{let e=await O(n?.cwd),r=e.cmd,s=[...e.baseArgs,...t],i=await execa(r,s,{cwd:n?.cwd,env:{...process.env,...n?.env},reject:false,stdio:"pipe"});return {exitCode:typeof i.exitCode=="number"?i.exitCode:1,stdout:(i.stdout??"").toString(),stderr:(i.stderr??"").toString()}}catch(e){return {exitCode:1,stdout:"",stderr:`${x(e)}
32
+ `}}}function H(t){let n=new Set,e=t.split(`
33
+ `),r=false;for(let s of e){let i=s.replace(/\r$/,"");if(!r){/^\s*Commands:\s*$/i.test(i)&&(r=true);let d=i.match(/^\s*rapidkit\s+([a-z0-9_-]+)\b/i);if(d){let m=d[1].trim();m&&!m.startsWith("-")&&n.add(m);}continue}if(!i.trim())break;if(/^\s*(Options|Arguments|Usage|Commands)\s*:/i.test(i))continue;let a=i.match(/^\s*([a-z0-9][a-z0-9_-]*)\b/i);if(!a)continue;let o=a[1].trim();o&&!o.startsWith("-")&&n.add(o);}return n}async function U(){let t=L();if(!await p.pathExists(t))return null;try{let n=await p.readJson(t);if(n&&n.schema_version===1&&Array.isArray(n.commands))return n}catch{}return null}async function M(t){let n=L();await p.ensureDir(c.dirname(n)),await p.writeJson(n,t,{spaces:2});}async function ct(){let t=await _(["version","--json"],{cwd:process.cwd()});if(t.exitCode===0)try{let e=JSON.parse(t.stdout)?.version;return typeof e=="string"?e:void 0}catch{return}}async function dt(){let t=await _(["commands","--json"],{cwd:process.cwd()});if(t.exitCode!==0)return null;try{let n=JSON.parse(t.stdout);if(n?.schema_version!==1||!Array.isArray(n.commands))return null;let e=n.commands.filter(r=>typeof r=="string");return e.length?e:null}catch{return null}}async function Et(){let n=Date.now(),e=await U(),r=await ct(),s=!!e?.commands?.length;if(s&&n-e.fetched_at<864e5&&(!r||!e.rapidkit_version||e.rapidkit_version===r))return new Set(e.commands);let i=await dt();if(i?.length){let m=Array.from(new Set(i)).sort();return await M({schema_version:1,fetched_at:n,rapidkit_version:r,commands:m}),new Set(m)}let a=await _(["--help"],{cwd:process.cwd()});if(a.exitCode!==0)return s&&e?.commands?new Set(e.commands):new Set(S);let o=H(a.stdout);if(o.size===0)return new Set(S);let d=Array.from(o).sort();return await M({schema_version:1,fetched_at:n,rapidkit_version:r,commands:d}),o}async function _t(){let n=Date.now(),e=await U();return !e||n-e.fetched_at>=864e5||!e.commands?.length?null:new Set(e.commands)}function Y(){return c.join(R(),"rapidkit","npm-bridge","modules-catalog.json")}async function pt(){let t=Y();if(!await p.pathExists(t))return null;try{let n=await p.readJson(t);if(n&&n.schema_version===1&&Array.isArray(n.modules))return n}catch{}return null}async function B(t){let n=Y();await p.ensureDir(c.dirname(n)),await p.writeJson(n,t,{spaces:2});}function F(t){try{return JSON.parse(t)}catch{return null}}async function Pt(t={}){let n=typeof t.ttlMs=="number"?t.ttlMs:18e5,e=Date.now(),r=await pt();if(r?.fetched_at&&e-r.fetched_at<n)return r;let s=["modules","list","--json-schema","1"];t.category&&s.push("--category",t.category),t.tag&&s.push("--tag",t.tag),t.detailed&&s.push("--detailed");let i=await _(s,{cwd:t.cwd,env:t.env});if(i.exitCode===0){let o=F(i.stdout);if(o&&o.schema_version===1&&Array.isArray(o.modules)){let d={...o,fetched_at:e};return await B(d),d}}let a=await _(["modules","list","--json"],{cwd:t.cwd,env:t.env});if(a.exitCode===0){let o=F(a.stdout);if(Array.isArray(o)){let d={schema_version:1,generated_at:new Date().toISOString(),filters:{category:t.category??null,tag:t.tag??null,detailed:!!t.detailed},stats:{total:o.length,returned:o.length,invalid:0},modules:o,source:"legacy-json",fetched_at:e};return await B(d),d}}return r||null}var Ct={pickSystemPython:j,ensureBridgeVenv:k,parseCoreCommandsFromHelp:H,tryRapidkit:J,checkRapidkitCoreAvailable:ot};export{S as a,ot as b,st as c,wt as d,vt as e,_ as f,Et as g,_t as h,Pt as i,Ct as j};
@@ -1,4 +1,4 @@
1
1
  import o from'chalk';import {execa}from'execa';import {createRequire}from'module';var c=class{debugEnabled=false;setDebug(r){this.debugEnabled=r;}debug(r,...e){this.debugEnabled&&console.log(o.gray(`[DEBUG] ${r}`),...e);}info(r,...e){console.log(o.blue(r),...e);}success(r,...e){console.log(o.green(r),...e);}warn(r,...e){console.log(o.yellow(r),...e);}error(r,...e){console.error(o.red(r),...e);}step(r,e,n){console.log(o.cyan(`
2
- [${r}/${e}]`),o.white(n));}},l=new c;var y="rapidkit",N=createRequire(import.meta.url),v=N("../package.json"),m=v?.version??"0.0.0";function d(t){let e=t.trim().match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/);if(!e)return null;let n=e[4]?e[4].split(".").map(i=>i.match(/^\d+$/)?Number(i):i):[];return {major:Number(e[1]),minor:Number(e[2]),patch:Number(e[3]),prerelease:n}}function E(t,r){let e=d(t),n=d(r);if(!e||!n)return 0;if(e.major!==n.major)return e.major>n.major?1:-1;if(e.minor!==n.minor)return e.minor>n.minor?1:-1;if(e.patch!==n.patch)return e.patch>n.patch?1:-1;if(e.prerelease.length===0&&n.prerelease.length===0)return 0;if(e.prerelease.length===0)return 1;if(n.prerelease.length===0)return -1;let i=Math.max(e.prerelease.length,n.prerelease.length);for(let u=0;u<i;u+=1){let s=e.prerelease[u],a=n.prerelease[u];if(s===void 0)return -1;if(a===void 0)return 1;if(s===a)continue;let g=typeof s=="number",p=typeof a=="number";return g&&p?s>a?1:-1:g?-1:p||String(s)>String(a)?1:-1}return 0}async function P(){try{l.debug("Checking for updates...");let{stdout:t}=await execa("npm",["view",y,"version"],{timeout:3e3}),r=t.trim();r&&E(r,m)>0?(console.log(o.yellow(`
2
+ [${r}/${e}]`),o.white(n));}},l=new c;var y="rapidkit",N=createRequire(import.meta.url),v=N("../package.json"),m=v?.version??"0.0.0";function d(t){let e=t.trim().match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/);if(!e)return null;let n=e[4]?e[4].split(".").map(s=>s.match(/^\d+$/)?Number(s):s):[];return {major:Number(e[1]),minor:Number(e[2]),patch:Number(e[3]),prerelease:n}}function E(t,r){let e=d(t),n=d(r);if(!e||!n)return 0;if(e.major!==n.major)return e.major>n.major?1:-1;if(e.minor!==n.minor)return e.minor>n.minor?1:-1;if(e.patch!==n.patch)return e.patch>n.patch?1:-1;if(e.prerelease.length===0&&n.prerelease.length===0)return 0;if(e.prerelease.length===0)return 1;if(n.prerelease.length===0)return -1;let s=Math.max(e.prerelease.length,n.prerelease.length);for(let u=0;u<s;u+=1){let i=e.prerelease[u],a=n.prerelease[u];if(i===void 0)return -1;if(a===void 0)return 1;if(i===a)continue;let g=typeof i=="number",p=typeof a=="number";return g&&p?i>a?1:-1:g?-1:p||String(i)>String(a)?1:-1}return 0}async function C(){try{l.debug("Checking for updates...");let{stdout:t}=await execa("npm",["view",y,"version"],{timeout:3e3}),r=t.trim();r&&E(r,m)>0?(console.log(o.yellow(`
3
3
  \u26A0\uFE0F Update available: ${m} \u2192 ${r}`)),console.log(o.cyan(`Run: npm install -g rapidkit@latest
4
- `))):l.debug("You are using the latest version");}catch{l.debug("Could not check for updates");}}function U(){return m}export{l as a,P as b,U as c};
4
+ `))):l.debug("You are using the latest version");}catch{l.debug("Could not check for updates");}}function P(){return m}export{l as a,C as b,P as c};