rapidkit 0.24.2 → 0.25.1
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 +61 -23
- package/dist/chunk-3MJ2BD56.js +786 -0
- package/dist/chunk-UOGFCKQ5.js +33 -0
- package/dist/chunk-Z5LKRG57.js +1 -0
- package/dist/{create-3OT5GA5W.js → create-PELQEDCF.js} +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +223 -195
- package/dist/package.json +8 -3
- package/dist/{pythonRapidkitExec-EXCX5QGH.js → pythonRapidkitExec-K2SFGAYJ.js} +1 -1
- package/dist/{workspace-6SADFTND.js → workspace-PIBFBNRA.js} +52 -49
- package/package.json +8 -3
- package/dist/chunk-5JB4MOC5.js +0 -33
- package/dist/chunk-XP4GTL4L.js +0 -776
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {a,d as d$1,e,f,c,g}from'./chunk-Z5LKRG57.js';import it from'crypto';import U from'os';import u from'path';import*as d from'fs-extra';import {execa}from'execa';var rt=["version","project","create","add","list","info","upgrade","diff","doctor","license","commands","reconcile","rollback","uninstall","checkpoint","optimize","snapshot","frameworks","modules","merge"],j=new Set(rt);function Y(){return d$1()}function w(t,e){return t==="py"?["-3",...e]:e}function V(t){if(!t)return t;let e=["Installed Poetry version does not support '--no-update'. Falling back to 'poetry lock'."];return t.split(/\r?\n/).filter(o=>!e.some(i=>o.includes(i))).join(`
|
|
2
|
+
`)}var y=class extends Error{code;constructor(e,r){super(r),this.code=e;}};function k(t){if(t instanceof y)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 \`${c()}\` 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
|
+
`+(a()?`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
|
+
`+(a()?`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 N(){let t=process.env.RAPIDKIT_CORE_PYTHON_PACKAGE;return t&&t.trim()?t.trim():"rapidkit-core"}function ot(){let t=N(),e=process.env.RAPIDKIT_CORE_PYTHON_PACKAGE_ID,r=e&&e.trim()?`${t}|${e.trim()}`:t;return it.createHash("sha256").update(r).digest("hex").slice(0,12)}function b(){let t=process.env.XDG_CACHE_HOME;return t&&t.trim()?t:u.join(U.homedir(),".cache")}function st(){return u.join(b(),"rapidkit","npm-bridge","venv")}function W(){let t=ot();return u.join(b(),"rapidkit","npm-bridge",`venv-${t}`)}function G(t){return f(t)}function K(t){return g(t)}function at(t){return /[<>=!~]=|@|\.whl$|\.tar\.gz$|\.zip$|git\+|https?:\/\//.test(t)}function ct(t){return u.dirname(u.dirname(t))}function z(){return u.join(b(),"rapidkit","npm-bridge","core-commands.json")}async function X(t){let e=!!process.env.RAPIDKIT_DEBUG,r=n=>{e&&process.stderr.write(`[DEBUG] tryRapidkit(${t}): ${n}
|
|
15
|
+
`);};try{r("probing interpreter-specific rapidkit script");let o=((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(r(`script path: ${o}`),o)try{if(await d.pathExists(o)){r(`found script at ${o}; invoking --version --json`);let i=await execa(o,["--version","--json"],{reject:false,stdio:"pipe",timeout:4e3});if(r(`script exitCode=${i.exitCode}`),i.exitCode===0){let a=(i.stdout??"").toString().trim();try{let s=JSON.parse(a),c=!!s&&typeof s=="object"&&s!==null&&"version"in s;if(r(`script JSON parse ok=${c}`),c)return true}catch{r("script output not valid JSON");}}}}catch(i){r(`interpreter-specific script probe failed: ${String(i)}`);}}catch(n){r(`interpreter-specific script probe error: ${String(n)}`);}try{r('probing importlib.find_spec("rapidkit")');let n=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(r(`import probe exitCode=${n.exitCode} stdout=${(n.stdout??"").toString().trim()}`),n.exitCode===0&&(n.stdout??"").toString().trim()==="1")return true}catch(n){r(`import probe error: ${String(n)}`);}try{r("probing python -m rapidkit");let n=await execa(t,w(t,["-m","rapidkit","--version","--json"]),{reject:false,stdio:"pipe",timeout:8e3});if(r(`-m probe exitCode=${n.exitCode}`),n.exitCode===0)return true}catch(n){r(`-m probe error: ${String(n)}`);}try{r("probing PATH for rapidkit executables");let n=(process.env.PATH??"").split(u.delimiter).filter(Boolean);for(let o of n){let i=u.join(o,a()?"rapidkit.exe":"rapidkit");try{if(await d.pathExists(i)){r(`found candidate on PATH: ${i}; invoking --version --json`);let a=await execa(i,["--version","--json"],{reject:false,stdio:"pipe",timeout:4e3});if(r(`candidate exitCode=${a.exitCode}`),a.exitCode===0){let s=(a.stdout??"").toString().trim();try{let c=JSON.parse(s);if(c&&typeof c=="object"&&c!==null&&"version"in c)return true}catch{r("candidate output not valid JSON, skipping");}}}}catch(a){r(`error probing candidate ${i}: ${String(a)}`);}}return r("no valid rapidkit found on PATH"),false}catch(n){return r(`PATH probe error: ${String(n)}`),false}}async function T(t){let e=(t??"").toString().trim();if(!e)return false;try{let r=JSON.parse(e);return !!r&&typeof r=="object"&&r!==null&&"version"in r}catch{return false}}async function dt(t){let e=u.relative(".",g(".venv")),r=u.relative(".",f(".venv")),n=t;for(let o=0;o<25;o+=1){let i=u.join(n,e);if(await d.pathExists(i)){let c=await execa(i,["--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:n});if(c.exitCode===0&&await T(c.stdout))return {cmd:i,baseArgs:[]}}let a=u.join(n,r);if(await d.pathExists(a)){let c=await execa(a,["-m","rapidkit","--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:n});if(c.exitCode===0&&await T(c.stdout))return {cmd:a,baseArgs:["-m","rapidkit"]}}let s=u.dirname(n);if(s===n)break;n=s;}return null}async function pt(t){try{let e=u.join(t,".python-version");if(await d.pathExists(e)){let n=(await d.readFile(e,"utf-8")).trim();if(n)return n}}catch{}try{let e=u.join(t,".rapidkit-workspace");if(await d.pathExists(e)){let r=await d.readFile(e,"utf-8"),n=JSON.parse(r);if(n.pythonVersion)return n.pythonVersion}}catch{}return null}async function M(t){if(t&&t.trim())try{let i=await dt(t);if(i){let a=u.dirname(i.cmd).includes(".venv")?u.dirname(u.dirname(u.dirname(i.cmd))):u.dirname(i.cmd),s=await pt(a);return s&&(process.env.PYENV_VERSION=s),i}}catch{}let e=await mt();if(e.kind==="venv"){let i=ct(e.pythonPath),a=K(i);return await d.pathExists(a)?{cmd:a,baseArgs:[]}:{cmd:e.pythonPath,baseArgs:["-m","rapidkit"]}}try{if((await execa(e.cmd,["-m","rapidkit","--version","--json"],{reject:false,stdio:"pipe",timeout:4e3})).exitCode===0)return {cmd:e.cmd,baseArgs:["-m","rapidkit"]}}catch{}try{let a=((await execa(e.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 d.pathExists(a))try{let s=await execa(a,["--version","--json"],{reject:false,stdio:"pipe",timeout:4e3});if(s.exitCode===0&&await T(s.stdout))return {cmd:a,baseArgs:[]}}catch{}}catch{}let r=W(),n=await R(e.cmd),o=K(r);return await d.pathExists(o)?{cmd:o,baseArgs:[]}:{cmd:n,baseArgs:["-m","rapidkit"]}}async function $(){for(let t of Y())try{return await execa(t,w(t,["--version"]),{reject:false,stdio:"pipe",timeout:2e3}),t}catch{}return null}async function ut(){let t=!!process.env.RAPIDKIT_DEBUG,e$1=n=>{t&&process.stderr.write(`[DEBUG] checkRapidkitCore: ${n}
|
|
16
|
+
`);},r=Array.from(new Set([...d$1(),...e(14,10).map(n=>n.command)]));for(let n of r)try{e$1(`Method 1: trying ${n} import`);let o=await execa(n,w(n,["-c","import rapidkit_core; print(1)"]),{reject:false,stdio:"pipe",timeout:3e3});if(o.exitCode===0&&o.stdout?.trim()==="1")return e$1(`\u2713 Found via ${n} import`),true}catch{continue}for(let n of r)try{e$1(`Method 2: trying ${n} -m pip show`);let o=await execa(n,w(n,["-m","pip","show","rapidkit-core"]),{reject:false,stdio:"pipe",timeout:3e3});if(o.exitCode===0&&o.stdout?.includes("Name: rapidkit-core"))return e$1(`\u2713 Found via ${n} -m pip show`),true}catch{continue}for(let n of ["pip","pip3"])try{e$1(`Method 3: trying ${n} show`);let o=await execa(n,["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:3e3});if(o.exitCode===0&&o.stdout?.includes("Name: rapidkit-core"))return e$1(`\u2713 Found via ${n} show`),true}catch{continue}try{e$1("Method 4: checking pyenv versions");let n=await execa("pyenv",["versions","--bare"],{reject:false,stdio:"pipe",timeout:3e3});if(n.exitCode===0&&n.stdout){let o=n.stdout.split(`
|
|
17
|
+
`).filter(i=>i.trim());e$1(`Found pyenv versions: ${o.join(", ")}`);for(let i of o){let a=process.env.PYENV_ROOT||u.join(U.homedir(),".pyenv"),s=u.join(a,"versions",i.trim(),"bin","pip");try{let c=await execa(s,["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:3e3});if(c.exitCode===0&&c.stdout?.includes("Name: rapidkit-core"))return e$1(`\u2713 Found in pyenv ${i}`),true}catch{try{let c=await execa("pyenv",["exec","pip","show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:3e3,env:{...process.env,PYENV_VERSION:i.trim()}});if(c.exitCode===0&&c.stdout?.includes("Name: rapidkit-core"))return e$1(`\u2713 Found in pyenv ${i} via PYENV_VERSION`),true}catch{continue}}}}}catch{e$1("pyenv not available");}for(let n of r)try{e$1(`Method 5: checking ${n} user site`);let o=await execa(n,w(n,["-m","site","--user-site"]),{reject:false,stdio:"pipe",timeout:3e3});if(o.exitCode===0&&o.stdout){let i=o.stdout.trim(),a=u.join(i,"rapidkit_core");if(await d.pathExists(a))return e$1("\u2713 Found in user site-packages"),true}}catch{continue}try{e$1("Method 6: checking pipx");let n=await execa("pipx",["list"],{reject:false,stdio:"pipe",timeout:3e3});if(n.exitCode===0&&n.stdout?.includes("rapidkit-core"))return e$1("\u2713 Found via pipx"),true}catch{e$1("pipx not available");}for(let n of r)try{e$1(`Method 6: checking ${n} -m pipx list`);let o=await execa(n,w(n,["-m","pipx","list"]),{reject:false,stdio:"pipe",timeout:3e3});if(o.exitCode===0&&o.stdout?.includes("rapidkit-core"))return e$1(`\u2713 Found via ${n} -m pipx list`),true}catch{continue}try{if(e$1("Method 7: checking poetry"),(await execa("poetry",["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:3e3})).exitCode===0)return e$1("\u2713 Found via poetry"),true}catch{e$1("poetry check failed");}for(let n of r)try{if(e$1(`Method 7: checking ${n} -m poetry show rapidkit-core`),(await execa(n,w(n,["-m","poetry","show","rapidkit-core"]),{reject:false,stdio:"pipe",timeout:3e3})).exitCode===0)return e$1(`\u2713 Found via ${n} -m poetry`),true}catch{continue}try{e$1("Method 8: checking conda");let n=await execa("conda",["list","rapidkit-core"],{reject:false,stdio:"pipe",timeout:3e3});if(n.exitCode===0&&n.stdout?.includes("rapidkit-core"))return e$1("\u2713 Found via conda"),true}catch{e$1("conda not available");}return e$1("\u2717 Not found in any environment"),false}async function R(t){let e=W(),r=st(),n=N(),o=[e];!at(n)&&!await d.pathExists(e)&&await d.pathExists(r)&&o.push(r);for(let m of o){let h=G(m);if(await d.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 d.remove(m);}catch{await d.remove(m);}}let i=e,a={...process.env,PIP_DISABLE_PIP_VERSION_CHECK:"1",PIP_NO_PYTHON_VERSION_WARNING:"1"},s=Math.max(0,Number(process.env.RAPIDKIT_BRIDGE_PIP_RETRY??"2")),c=Math.max(200,Number(process.env.RAPIDKIT_BRIDGE_PIP_RETRY_DELAY_MS??"800")),l=Math.max(1e4,Number(process.env.RAPIDKIT_BRIDGE_PIP_TIMEOUT_MS??"120000")),v=m=>new Promise(h=>setTimeout(h,m)),P=async(m,h,f)=>{let g=await execa(m,h,{reject:false,stdio:["ignore","pipe","inherit"],env:a,timeout:f});if(g.exitCode===0)return;let A=(g.stdout??"").toString(),I=(g.stderr??"").toString(),C=[A,I].filter(Boolean).join(`
|
|
18
|
+
`),tt=C?`${m} ${h.join(" ")}
|
|
19
|
+
${C}`:`${m} ${h.join(" ")}`;throw new Error(tt)},_=async(m,h,f)=>{let g=0;for(;;)try{await P(m,h,f);return}catch(A){if(g>=s)throw A;let I=Math.floor(Math.random()*200),C=c*Math.pow(2,g)+I;g+=1,await v(C);}};try{await d.ensureDir(u.dirname(i));try{await P(t,w(t,["-m","venv",i]),6e4);}catch(f){let g=f instanceof Error?f.message:String(f);throw new y("BRIDGE_VENV_CREATE_FAILED",g)}let m=G(i);if((await execa(m,["-m","pip","--version"],{reject:false,stdio:"pipe",timeout:2e3})).exitCode!==0&&(await execa(m,["-m","ensurepip","--default-pip"],{reject:false,stdio:["ignore","pipe","inherit"],env:a,timeout:6e4})).exitCode!==0)throw new y("BRIDGE_PIP_BOOTSTRAP_FAILED","ensurepip failed; install python3-venv/python3-pip and retry.");if(process.env.RAPIDKIT_BRIDGE_UPGRADE_PIP==="1")try{await _(m,["-m","pip","install","-U","pip"],l);}catch(f){let g=f instanceof Error?f.message:String(f);throw new y("BRIDGE_PIP_UPGRADE_FAILED",g)}try{await _(m,["-m","pip","install","-U",N()],l);}catch(f){let g=f instanceof Error?f.message:String(f);throw new y("BRIDGE_PIP_INSTALL_FAILED",g)}return m}catch(m){if(m instanceof y)throw m;let h=m instanceof Error?m.message:String(m);throw new y("BRIDGE_VENV_BOOTSTRAP_FAILED",h)}}async function mt(){if(process.env.RAPIDKIT_BRIDGE_FORCE_VENV==="1"){let r=await $();if(!r)throw new y("PYTHON_NOT_FOUND","No Python interpreter found (python3/python/py).");return {kind:"venv",pythonPath:await R(r)}}for(let r of Y())if(await X(r))return {kind:"system",cmd:r};let t=await $();if(!t)throw new y("PYTHON_NOT_FOUND","No Python interpreter found (python3/python/py).");return {kind:"venv",pythonPath:await R(t)}}async function kt(t,e){try{let r=await M(e?.cwd),n=r.cmd,o=[...r.baseArgs,...t];if(t[0]==="init"){let s=await execa(n,o,{cwd:e?.cwd,env:{...process.env,...e?.env},reject:false,stdio:"pipe"}),c=V((s.stdout??"").toString()),l=V((s.stderr??"").toString());return c&&process.stdout.write(c.endsWith(`
|
|
20
|
+
`)?c:`${c}
|
|
21
|
+
`),l&&process.stderr.write(l.endsWith(`
|
|
22
|
+
`)?l:`${l}
|
|
23
|
+
`),typeof s.exitCode=="number"?s.exitCode:1}let a=await execa(n,o,{cwd:e?.cwd,env:{...process.env,...e?.env},reject:false,stdio:"inherit"});return typeof a.exitCode=="number"?a.exitCode:1}catch(r){return process.stderr.write(`${k(r)}
|
|
24
|
+
`),1}}var lt=[{pattern:/RapidKitError:\s*Directory '([^']+)' exists and force is not set/,message:t=>`\u274C Directory "${u.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 Rt(t,e){let{spawn:r}=await import('child_process');try{let n=await M(e?.cwd),o=n.cmd,i=[...n.baseArgs,...t];return await new Promise(a=>{let s=r(o,i,{cwd:e?.cwd,env:{...process.env,...e?.env},stdio:["inherit","inherit","pipe"]}),c=[];s.stderr?.on("data",l=>{c.push(l);}),s.on("close",l=>{let v=l??1;if(v!==0&&c.length>0){let P=Buffer.concat(c).toString("utf8");for(let{pattern:_,message:m}of lt){let h=P.match(_);if(h){process.stderr.write(m(h)+`
|
|
29
|
+
`),a(v);return}}process.stderr.write(P);}a(v);}),s.on("error",l=>{process.stderr.write(`${k(l)}
|
|
30
|
+
`),a(1);});})}catch(n){return process.stderr.write(`${k(n)}
|
|
31
|
+
`),1}}async function E(t,e){try{let r=await M(e?.cwd),n=r.cmd,o=[...r.baseArgs,...t],i=await execa(n,o,{cwd:e?.cwd,env:{...process.env,...e?.env},reject:false,stdio:"pipe"});return {exitCode:typeof i.exitCode=="number"?i.exitCode:1,stdout:(i.stdout??"").toString(),stderr:(i.stderr??"").toString()}}catch(r){return {exitCode:1,stdout:"",stderr:`${k(r)}
|
|
32
|
+
`}}}function q(t){let e=new Set,r=t.split(`
|
|
33
|
+
`),n=false;for(let o of r){let i=o.replace(/\r$/,"");if(!n){/^\s*Commands:\s*$/i.test(i)&&(n=true);let c=i.match(/^\s*rapidkit\s+([a-z0-9_-]+)\b/i);if(c){let l=c[1].trim();l&&!l.startsWith("-")&&e.add(l);}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 s=a[1].trim();s&&!s.startsWith("-")&&e.add(s);}return e}async function Q(){let t=z();if(!await d.pathExists(t))return null;try{let e=await d.readJson(t);if(e&&e.schema_version===1&&Array.isArray(e.commands))return e}catch{}return null}async function L(t){let e=z();await d.ensureDir(u.dirname(e)),await d.writeJson(e,t,{spaces:2});}async function ft(){let t=await E(["version","--json"],{cwd:process.cwd()});if(t.exitCode===0)try{let r=JSON.parse(t.stdout)?.version;return typeof r=="string"?r:void 0}catch{return}}async function ht(){let t=await E(["commands","--json"],{cwd:process.cwd()});if(t.exitCode!==0)return null;try{let e=JSON.parse(t.stdout);if(e?.schema_version!==1||!Array.isArray(e.commands))return null;let r=e.commands.filter(n=>typeof n=="string");return r.length?r:null}catch{return null}}async function bt(){let e=Date.now(),r=await Q(),n=await ft(),o=!!r?.commands?.length;if(o&&e-r.fetched_at<864e5&&(!n||!r.rapidkit_version||r.rapidkit_version===n))return new Set(r.commands);let i=await ht();if(i?.length){let l=Array.from(new Set(i)).sort();return await L({schema_version:1,fetched_at:e,rapidkit_version:n,commands:l}),new Set(l)}let a=await E(["--help"],{cwd:process.cwd()});if(a.exitCode!==0)return o&&r?.commands?new Set(r.commands):new Set(j);let s=q(a.stdout);if(s.size===0)return new Set(j);let c=Array.from(s).sort();return await L({schema_version:1,fetched_at:e,rapidkit_version:n,commands:c}),s}async function At(){let e=Date.now(),r=await Q();return !r||e-r.fetched_at>=864e5||!r.commands?.length?null:new Set(r.commands)}function Z(){return u.join(b(),"rapidkit","npm-bridge","modules-catalog.json")}async function gt(){let t=Z();if(!await d.pathExists(t))return null;try{let e=await d.readJson(t);if(e&&e.schema_version===1&&Array.isArray(e.modules))return e}catch{}return null}async function J(t){let e=Z();await d.ensureDir(u.dirname(e)),await d.writeJson(e,t,{spaces:2});}function H(t){try{return JSON.parse(t)}catch{return null}}async function It(t={}){let e=typeof t.ttlMs=="number"?t.ttlMs:18e5,r=Date.now(),n=await gt();if(n?.fetched_at&&r-n.fetched_at<e)return n;let o=["modules","list","--json-schema","1"];t.category&&o.push("--category",t.category),t.tag&&o.push("--tag",t.tag),t.detailed&&o.push("--detailed");let i=await E(o,{cwd:t.cwd,env:t.env});if(i.exitCode===0){let s=H(i.stdout);if(s&&s.schema_version===1&&Array.isArray(s.modules)){let c={...s,fetched_at:r};return await J(c),c}}let a=await E(["modules","list","--json"],{cwd:t.cwd,env:t.env});if(a.exitCode===0){let s=H(a.stdout);if(Array.isArray(s)){let c={schema_version:1,generated_at:new Date().toISOString(),filters:{category:t.category??null,tag:t.tag??null,detailed:!!t.detailed},stats:{total:s.length,returned:s.length,invalid:0},modules:s,source:"legacy-json",fetched_at:r};return await J(c),c}}return n||null}var Dt={pickSystemPython:$,ensureBridgeVenv:R,parseCoreCommandsFromHelp:q,tryRapidkit:X,checkRapidkitCoreAvailable:ut};export{j as a,ut as b,mt as c,kt as d,Rt as e,E as f,bt as g,At as h,It as i,Dt as j};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import p from'os';import r from'path';function a(o=process.platform){return o==="win32"?"windows":o==="linux"?"linux":o==="darwin"?"macos":"other"}function n(o=process.platform){return a(o)==="windows"}function l(o=process.platform){return n(o)}function u(o=process.platform){return n(o)?"python":"python3"}function P(o=process.platform){return n(o)?["python","py","python3"]:["python3","python"]}function g(o=14,t=10,i=process.platform){let e=[];if(n(i)){for(let s=o;s>=t;s-=1)e.push({command:"py",args:[`-3.${s}`,"--version"]});return e.push({command:"py",args:["-3","--version"]}),e.push({command:"python",args:["--version"]}),e}for(let s=o;s>=t;s-=1)e.push({command:`python3.${s}`,args:["--version"]});return e.push({command:"python3",args:["--version"]}),e.push({command:"python",args:["--version"]}),e}function h(o,t=process.platform){return n(t)?r.join(o,"Scripts","python.exe"):r.join(o,"bin","python")}function y(o,t=process.platform){return n(t)?r.join(o,"Scripts","rapidkit.exe"):r.join(o,"bin","rapidkit")}function S(o,t=process.platform){return n(t)?r.join(o,"Scripts","activate"):r.join(o,"bin","activate")}function x(o,t=process.platform){return n(t)?[r.join(o,"rapidkit.cmd"),r.join(o,".rapidkit","rapidkit.cmd")]:[r.join(o,"rapidkit"),r.join(o,".rapidkit","rapidkit")]}function j(o=process.env,t=process.platform){let i=o.XDG_CONFIG_HOME||o.APPDATA||r.join(p.homedir(),".config");return n(t)?r.join(i,"rapidkit"):r.join(p.homedir(),".rapidkit")}function A(o=process.env,t=process.platform){let i=[];return n(t)?(o.USERPROFILE&&i.push(r.join(o.USERPROFILE,".local","bin")),o.APPDATA&&i.push(r.join(o.APPDATA,"Python","Scripts")),o.LOCALAPPDATA&&i.push(r.join(o.LOCALAPPDATA,"Programs","Python","Scripts"))):i.push(r.join(p.homedir(),".local","bin")),[...new Set(i.filter(Boolean))]}export{n as a,l as b,u as c,P as d,g as e,h as f,y as g,S as h,x as i,j,A as k};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{h as createProject,i as registerWorkspaceAtPath,f as syncWorkspaceFoundationFiles,g as writeWorkspaceLauncher}from'./chunk-
|
|
1
|
+
export{h as createProject,i as registerWorkspaceAtPath,f as syncWorkspaceFoundationFiles,g as writeWorkspaceLauncher}from'./chunk-3MJ2BD56.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
declare function handleCreateOrFallback(args: string[]): Promise<number>;
|
|
3
|
+
declare const NPM_ONLY_TOP_LEVEL_COMMANDS: readonly ["doctor", "workspace", "bootstrap", "setup", "cache", "mirror", "ai", "config", "shell"];
|
|
3
4
|
declare function handleBootstrapCommand(args: string[], initRunner?: (nextArgs: string[]) => Promise<number>): Promise<number>;
|
|
4
5
|
declare function handleSetupCommand(args: string[]): Promise<number>;
|
|
5
6
|
declare function handleCacheCommand(args: string[]): Promise<number>;
|
|
@@ -7,4 +8,4 @@ declare function handleMirrorCommand(args: string[]): Promise<number>;
|
|
|
7
8
|
declare function handleInitCommand(args: string[]): Promise<number>;
|
|
8
9
|
declare function shouldForwardToCore(args: string[]): Promise<boolean>;
|
|
9
10
|
|
|
10
|
-
export { handleBootstrapCommand, handleCacheCommand, handleCreateOrFallback, handleInitCommand, handleMirrorCommand, handleSetupCommand, shouldForwardToCore };
|
|
11
|
+
export { NPM_ONLY_TOP_LEVEL_COMMANDS, handleBootstrapCommand, handleCacheCommand, handleCreateOrFallback, handleInitCommand, handleMirrorCommand, handleSetupCommand, shouldForwardToCore };
|