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
package/dist/package.json
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rapidkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "Official CLI for RapidKit, an open-source workspace platform that standardizes how teams build, scale, and deploy backend services.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"rapidkit",
|
|
8
8
|
"cli",
|
|
9
9
|
"create",
|
|
10
10
|
"fastapi",
|
|
11
11
|
"nestjs",
|
|
12
|
+
"gofiber",
|
|
13
|
+
"gogin",
|
|
12
14
|
"backend",
|
|
13
15
|
"microservices",
|
|
14
16
|
"generator",
|
|
@@ -34,7 +36,7 @@
|
|
|
34
36
|
"build:watch": "tsup --watch",
|
|
35
37
|
"dev": "tsup --watch",
|
|
36
38
|
"dev:local": "npm run build && npm link",
|
|
37
|
-
"install:local": "npm unlink -g rapidkit
|
|
39
|
+
"install:local": "npm unlink -g rapidkit && npm run build && npm link",
|
|
38
40
|
"uninstall:local": "npm unlink -g rapidkit",
|
|
39
41
|
"prepare": "husky",
|
|
40
42
|
"test:e2e:first-install": "bash scripts/e2e-first-install.sh",
|
|
@@ -110,6 +112,9 @@
|
|
|
110
112
|
"vite-bundle-visualizer": "^1.2.1",
|
|
111
113
|
"vitest": "^4.0.15"
|
|
112
114
|
},
|
|
115
|
+
"optionalDependencies": {
|
|
116
|
+
"@rollup/rollup-win32-x64-msvc": "*"
|
|
117
|
+
},
|
|
113
118
|
"engines": {
|
|
114
119
|
"node": ">=20.19.6"
|
|
115
120
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{j as __test__,b as checkRapidkitCoreAvailable,h as getCachedCoreTopLevelCommands,g as getCoreTopLevelCommands,i as getModulesCatalog,c as resolveRapidkitPython,d as runCoreRapidkit,f as runCoreRapidkitCapture,e as runCoreRapidkitStreamed}from'./chunk-
|
|
1
|
+
export{j as __test__,b as checkRapidkitCoreAvailable,h as getCachedCoreTopLevelCommands,g as getCoreTopLevelCommands,i as getModulesCatalog,c as resolveRapidkitPython,d as runCoreRapidkit,f as runCoreRapidkitCapture,e as runCoreRapidkitStreamed}from'./chunk-UOGFCKQ5.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {c}from'./chunk-N64Z3XVF.js';import {promises}from'fs';import
|
|
2
|
-
\u2705 Synced ${m} project(s) to registry`)):
|
|
3
|
-
\u2705 All projects already registered (${
|
|
1
|
+
import {c}from'./chunk-N64Z3XVF.js';import {j}from'./chunk-Z5LKRG57.js';import {promises}from'fs';import d from'path';import r from'chalk';import w from'ora';import {execa}from'execa';function $(e){let t=d.resolve(e);return process.platform==="win32"?t.toLowerCase():t}function N(e){let t=$(e.path),i=Array.isArray(e.projects)?e.projects:[],a=[],o=new Set;for(let c of i){if(!c||typeof c.name!="string"||typeof c.path!="string")continue;let n=$(c.path);o.has(n)||(o.add(n),a.push({name:c.name,path:n}));}return {name:e.name,path:t,mode:e.mode,projects:a}}function v(e){let t=[],i=new Set;for(let a of e.workspaces||[]){if(!a||typeof a.name!="string"||typeof a.path!="string")continue;let o=N(a);i.has(o.path)||(i.add(o.path),t.push(o));}return {workspaces:t}}async function S(e,t){try{let i=$(e),a=j(),o=d.join(a,"workspaces.json");await promises.mkdir(a,{recursive:true});let c={workspaces:[]};try{let s=await promises.readFile(o,"utf8"),m=JSON.parse(s);m&&Array.isArray(m.workspaces)&&(c=v(m));}catch{}c.workspaces.some(s=>s.path===i)||(c.workspaces.push({name:t,path:i,mode:"full",projects:[]}),await promises.writeFile(o,JSON.stringify(c,null,2)));}catch{console.warn(r.gray("Note: Could not register workspace in shared registry"));}}async function z(e,t=false){try{let i=$(e),a=j(),o=d.join(a,"workspaces.json"),c={workspaces:[]};try{let p=await promises.readFile(o,"utf8"),g=JSON.parse(p);g&&Array.isArray(g.workspaces)&&(c=v(g));}catch{t||console.log("\u26A0\uFE0F Workspace registry not found");return}let n=c.workspaces.find(p=>p.path===i);if(!n){t||console.log("\u26A0\uFE0F Workspace not registered in registry");return}Array.isArray(n.projects)||(n.projects=[]);let s=await promises.readdir(e,{withFileTypes:true}),m=0,h=0;for(let p of s)if(p.isDirectory()&&!p.name.startsWith(".")){let g=$(d.join(e,p.name)),C=d.join(g,".rapidkit","context.json"),j=d.join(g,".rapidkit","project.json");try{let k=false;try{await promises.access(C),k=true;}catch{await promises.access(j),k=true;}k&&(n.projects.some(x=>x.path===g||x.name===p.name)?h++:(n.projects.push({name:p.name,path:g}),m++,t||console.log(`\u2714 Added: ${p.name}`)));}catch{}}m>0?(await promises.writeFile(o,JSON.stringify(c,null,2)),t||console.log(`
|
|
2
|
+
\u2705 Synced ${m} project(s) to registry`)):t||console.log(`
|
|
3
|
+
\u2705 All projects already registered (${h} found)`);}catch(i){t||console.error("\u274C Failed to sync projects:",i.message);}}async function J(e,t,i){try{let a=$(e),o=$(i),c=j(),n=d.join(c,"workspaces.json"),s={workspaces:[]};try{let p=await promises.readFile(n,"utf8"),g=JSON.parse(p);g&&Array.isArray(g.workspaces)&&(s=v(g));}catch{return}let m=s.workspaces.find(p=>p.path===a);if(!m)return;Array.isArray(m.projects)||(m.projects=[]),m.projects.some(p=>p.path===o||p.name===t)||(m.projects.push({name:t,path:o}),await promises.writeFile(n,JSON.stringify(s,null,2)));}catch{}}async function K(e,t){let i=w("Creating RapidKit workspace...").start();try{await promises.mkdir(e,{recursive:true}),await promises.mkdir(d.join(e,".rapidkit"),{recursive:true});let a={workspace_name:t.name,author:t.author,rapidkit_version:c(),created_at:new Date().toISOString(),type:"workspace"};await promises.writeFile(d.join(e,".rapidkit","config.json"),JSON.stringify(a,null,2));let o=E();await promises.writeFile(d.join(e,"rapidkit"),o),await promises.chmod(d.join(e,"rapidkit"),493);let c$1=A(t.name);if(await promises.writeFile(d.join(e,"README.md"),c$1),await promises.writeFile(d.join(e,".gitignore"),`# RapidKit workspace
|
|
4
4
|
.env
|
|
5
5
|
.env.*
|
|
6
6
|
!.env.example
|
|
@@ -15,37 +15,37 @@ Thumbs.db
|
|
|
15
15
|
|
|
16
16
|
# Logs
|
|
17
17
|
*.log
|
|
18
|
-
`),await promises.writeFile(
|
|
19
|
-
${
|
|
18
|
+
`),await promises.writeFile(d.join(e,".rapidkit-workspace"),JSON.stringify({signature:"RAPIDKIT_WORKSPACE",createdBy:"rapidkit-npm",version:c(),createdAt:new Date().toISOString(),name:t.name},null,2)),await D(e),i.succeed("Workspace created!"),!t.skipGit){let s=w("Initializing git repository...").start();try{await execa("git",["init"],{cwd:e}),await execa("git",["add","."],{cwd:e}),await execa("git",["commit","-m","Initial commit: RapidKit workspace"],{cwd:e}),s.succeed("Git repository initialized");}catch{s.warn("Could not initialize git repository");}}await S(e,t.name),console.log(`
|
|
19
|
+
${r.green("\u2728 RapidKit workspace created successfully!")}
|
|
20
20
|
|
|
21
|
-
${
|
|
22
|
-
${
|
|
21
|
+
${r.bold("\u{1F4C2} Workspace structure:")}
|
|
22
|
+
${e}/
|
|
23
23
|
\u251C\u2500\u2500 rapidkit # Local CLI wrapper
|
|
24
24
|
\u251C\u2500\u2500 .rapidkit/ # Workspace configuration
|
|
25
25
|
\u2502 \u251C\u2500\u2500 config.json # Workspace settings
|
|
26
26
|
\u2502 \u2514\u2500\u2500 templates/ # Project templates
|
|
27
27
|
\u2514\u2500\u2500 README.md
|
|
28
28
|
|
|
29
|
-
${
|
|
30
|
-
${
|
|
31
|
-
${
|
|
32
|
-
${
|
|
33
|
-
${
|
|
34
|
-
${
|
|
29
|
+
${r.bold("\u{1F680} Get started:")}
|
|
30
|
+
${r.cyan(`cd ${t.name}`)}
|
|
31
|
+
${r.cyan("npx rapidkit my-api --template fastapi")}
|
|
32
|
+
${r.cyan("cd my-api")}
|
|
33
|
+
${r.cyan("npx rapidkit init")}
|
|
34
|
+
${r.cyan("npx rapidkit dev")}
|
|
35
35
|
|
|
36
|
-
${
|
|
36
|
+
${r.bold("\u{1F4E6} Available templates:")}
|
|
37
37
|
fastapi - FastAPI + Python (default)
|
|
38
38
|
nestjs - NestJS + TypeScript
|
|
39
39
|
|
|
40
|
-
${
|
|
40
|
+
${r.bold("\u{1F4DA} Commands:")}
|
|
41
41
|
npx rapidkit <name> --template <type> Create a new project
|
|
42
42
|
npx rapidkit init Install dependencies
|
|
43
43
|
npx rapidkit dev Start dev server
|
|
44
44
|
npx rapidkit help Show all commands
|
|
45
45
|
|
|
46
|
-
${
|
|
47
|
-
${
|
|
48
|
-
`);}catch(a){throw
|
|
46
|
+
${r.gray("Alternative: ./rapidkit dev, make dev")}
|
|
47
|
+
${r.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
|
|
48
|
+
`);}catch(a){throw i.fail("Failed to create workspace"),a}}function E(){return `#!/usr/bin/env bash
|
|
49
49
|
#
|
|
50
50
|
# RapidKit CLI - Local workspace commands
|
|
51
51
|
# This script provides rapidkit commands within the workspace
|
|
@@ -393,7 +393,7 @@ main() {
|
|
|
393
393
|
}
|
|
394
394
|
|
|
395
395
|
main "$@"
|
|
396
|
-
`}function
|
|
396
|
+
`}function A(e){return `# ${e}
|
|
397
397
|
|
|
398
398
|
RapidKit workspace for building API projects.
|
|
399
399
|
|
|
@@ -441,7 +441,7 @@ npx rapidkit dev # Start dev server
|
|
|
441
441
|
|
|
442
442
|
- [RapidKit Documentation](https://rapidkit.dev)
|
|
443
443
|
- [GitHub Repository](https://github.com/Baziar/rapidkit)
|
|
444
|
-
`}async function
|
|
444
|
+
`}async function D(e){let{fileURLToPath:t}=await import('url'),i=t(import.meta.url),a=d.dirname(i),o=d.resolve(a,".."),c=d.join(o,"templates","kits"),n=d.join(e,".rapidkit","templates"),{default:s}=await import('fs-extra');await s.copy(c,n);let m=d.join(o,"templates","generator.js"),h=d.join(e,".rapidkit","generator.js");await s.copy(m,h);}async function G(e,t){let i=t.template==="fastapi",a=i?"FastAPI":"NestJS",o=w(`Creating ${a} project...`).start();try{let{fileURLToPath:c$1}=await import('url'),n=c$1(import.meta.url),s=d.dirname(n),m=d.resolve(s,".."),h=i?"fastapi-standard":"nestjs-standard",p=d.join(m,"templates","kits",h);await promises.mkdir(e,{recursive:true});let g={project_name:i?t.name.replace(/-/g,"_").toLowerCase():t.name.replace(/_/g,"-").toLowerCase(),author:t.author,description:t.description||`${a} application generated with RapidKit`,app_version:"0.1.0",license:"MIT",package_manager:t.package_manager||"npm",created_at:new Date().toISOString(),rapidkit_version:c()};await R(p,e,g);let C=i?`# Python
|
|
445
445
|
__pycache__/
|
|
446
446
|
*.py[cod]
|
|
447
447
|
*$py.class
|
|
@@ -509,11 +509,11 @@ Thumbs.db
|
|
|
509
509
|
|
|
510
510
|
# Coverage
|
|
511
511
|
coverage/
|
|
512
|
-
`;if(await promises.writeFile(
|
|
513
|
-
${
|
|
512
|
+
`;if(await promises.writeFile(d.join(e,".gitignore"),C),o.succeed(`${a} project created!`),!t.skipGit){let k=w("Initializing git repository...").start();try{await execa("git",["init"],{cwd:e}),await execa("git",["add","."],{cwd:e}),await execa("git",["commit","-m",`Initial commit: ${a} project via RapidKit`],{cwd:e}),k.succeed("Git repository initialized");}catch{k.warn("Could not initialize git repository");}}if(!t.skipInstall&&!i){let k=t.package_manager||"npm",_=w(`Installing dependencies with ${k}...`).start();try{await execa(k,["install"],{cwd:e}),_.succeed("Dependencies installed");}catch{_.warn(`Could not install dependencies. Run '${k} install' manually.`);}}let j=d.basename(e);console.log(i?`
|
|
513
|
+
${r.green("\u2728 FastAPI project created successfully!")}
|
|
514
514
|
|
|
515
|
-
${
|
|
516
|
-
${
|
|
515
|
+
${r.bold("\u{1F4C2} Project structure:")}
|
|
516
|
+
${e}/
|
|
517
517
|
\u251C\u2500\u2500 .rapidkit/ # RapidKit CLI module
|
|
518
518
|
\u251C\u2500\u2500 src/
|
|
519
519
|
\u2502 \u251C\u2500\u2500 main.py # FastAPI application
|
|
@@ -524,12 +524,12 @@ ${t}/
|
|
|
524
524
|
\u251C\u2500\u2500 pyproject.toml # Poetry configuration
|
|
525
525
|
\u2514\u2500\u2500 README.md
|
|
526
526
|
|
|
527
|
-
${
|
|
528
|
-
${
|
|
529
|
-
${
|
|
530
|
-
${
|
|
527
|
+
${r.bold("\u{1F680} Get started:")}
|
|
528
|
+
${r.cyan(`cd ${j}`)}
|
|
529
|
+
${r.cyan("npx rapidkit init")} ${r.gray("# Install dependencies")}
|
|
530
|
+
${r.cyan("npx rapidkit dev")} ${r.gray("# Start dev server")}
|
|
531
531
|
|
|
532
|
-
${
|
|
532
|
+
${r.bold("\u{1F4DA} Available commands:")}
|
|
533
533
|
npx rapidkit init # Install dependencies (poetry install)
|
|
534
534
|
npx rapidkit dev # Start dev server with hot reload
|
|
535
535
|
npx rapidkit start # Start production server
|
|
@@ -537,13 +537,13 @@ ${e.bold("\u{1F4DA} Available commands:")}
|
|
|
537
537
|
npx rapidkit lint # Lint code
|
|
538
538
|
npx rapidkit format # Format code
|
|
539
539
|
|
|
540
|
-
${
|
|
541
|
-
${
|
|
540
|
+
${r.gray("Alternative: make dev, ./rapidkit dev, poetry run dev")}
|
|
541
|
+
${r.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
|
|
542
542
|
`:`
|
|
543
|
-
${
|
|
543
|
+
${r.green("\u2728 NestJS project created successfully!")}
|
|
544
544
|
|
|
545
|
-
${
|
|
546
|
-
${
|
|
545
|
+
${r.bold("\u{1F4C2} Project structure:")}
|
|
546
|
+
${e}/
|
|
547
547
|
\u251C\u2500\u2500 .rapidkit/ # RapidKit CLI module
|
|
548
548
|
\u251C\u2500\u2500 src/
|
|
549
549
|
\u2502 \u251C\u2500\u2500 main.ts # Application entry point
|
|
@@ -554,13 +554,13 @@ ${t}/
|
|
|
554
554
|
\u251C\u2500\u2500 package.json # Dependencies
|
|
555
555
|
\u2514\u2500\u2500 README.md
|
|
556
556
|
|
|
557
|
-
${
|
|
558
|
-
${
|
|
559
|
-
${
|
|
560
|
-
`:""}${
|
|
561
|
-
${
|
|
557
|
+
${r.bold("\u{1F680} Get started:")}
|
|
558
|
+
${r.cyan(`cd ${j}`)}
|
|
559
|
+
${t.skipInstall?r.cyan("npx rapidkit init")+r.gray(" # npm install")+`
|
|
560
|
+
`:""}${r.cyan("cp .env.example .env")}
|
|
561
|
+
${r.cyan("npx rapidkit dev")} ${r.gray("# Start dev server")}
|
|
562
562
|
|
|
563
|
-
${
|
|
563
|
+
${r.bold("\u{1F4DA} Available commands:")}
|
|
564
564
|
npx rapidkit init # Install dependencies
|
|
565
565
|
npx rapidkit dev # Start dev server with hot reload
|
|
566
566
|
npx rapidkit start # Start production server
|
|
@@ -569,19 +569,22 @@ ${e.bold("\u{1F4DA} Available commands:")}
|
|
|
569
569
|
npx rapidkit lint # Lint code
|
|
570
570
|
npx rapidkit format # Format code
|
|
571
571
|
|
|
572
|
-
${
|
|
572
|
+
${r.bold("\u{1F310} API endpoints:")}
|
|
573
573
|
http://localhost:8000/health # Health check
|
|
574
574
|
http://localhost:8000/docs # Swagger docs
|
|
575
575
|
http://localhost:8000/examples/notes # Example API
|
|
576
576
|
|
|
577
|
-
${
|
|
578
|
-
`);}catch(
|
|
577
|
+
${r.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
|
|
578
|
+
`);}catch(c){throw o.fail(`Failed to create ${a} project`),c}}async function R(e,t,i){let a=await promises.readdir(e,{withFileTypes:true});for(let o of a){let c=d.join(e,o.name),n=o.name.replace(/\.j2$/,""),s=d.join(t,n);if(o.isDirectory())await promises.mkdir(s,{recursive:true}),await R(c,s,i);else {let m=await promises.readFile(c,"utf-8");o.name.endsWith(".j2")&&(m=b(m,i)),await promises.writeFile(s,m),(n==="rapidkit"||n==="activate"||n.endsWith(".py")&&s.includes(".rapidkit"))&&await promises.chmod(s,493);}}}function b(e,t){let i=e;for(let[a,o]of Object.entries(t)){let c=new RegExp(`\\{\\{\\s*${a}\\s*\\}\\}`,"g");i=i.replace(c,String(o));let n=new RegExp(`\\{\\{\\s*${a}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\}\\}`,"g");i=i.replace(n,(h,p,g)=>String(o).replace(new RegExp(p,"g"),g));let s=new RegExp(`\\{\\{\\s*${a}\\s*\\|\\s*lower\\s*\\}\\}`,"g");i=i.replace(s,String(o).toLowerCase());let m=new RegExp(`\\{\\{\\s*${a}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\|\\s*lower\\s*\\}\\}`,"g");i=i.replace(m,(h,p,g)=>String(o).replace(new RegExp(p,"g"),g).toLowerCase());}return i}async function Y(){let e=j(),t=d.join(e,"workspaces.json");if(!await promises.stat(t).catch(()=>null)){console.log(r.yellow(`
|
|
579
579
|
\u26A0\uFE0F No workspaces registered yet.
|
|
580
|
-
`)),console.log(
|
|
581
|
-
`));return}try{let
|
|
580
|
+
`)),console.log(r.gray(`Create a workspace with: npx rapidkit <workspace-name>
|
|
581
|
+
`));return}try{let i=await promises.readFile(t,"utf8"),a=JSON.parse(i);if(!a||typeof a!="object"||!Array.isArray(a.workspaces)){console.log(r.yellow(`
|
|
582
|
+
\u26A0\uFE0F Workspace registry is invalid; resetting to empty state.
|
|
583
|
+
`)),await promises.writeFile(t,JSON.stringify({workspaces:[]},null,2));return}let o=v(a),c=[],n=0;for(let p of o.workspaces)await promises.stat(p.path).catch(()=>null)?c.push(p):n+=1;let s={workspaces:c},m=JSON.stringify(a),h=JSON.stringify(s);if(m!==h&&await promises.writeFile(t,JSON.stringify(s,null,2)),!s.workspaces||s.workspaces.length===0){console.log(r.yellow(`
|
|
582
584
|
\u26A0\uFE0F No workspaces registered yet.
|
|
583
|
-
`))
|
|
585
|
+
`)),n>0&&console.log(r.gray(`Cleaned ${n} stale workspace entr${n===1?"y":"ies"}.
|
|
586
|
+
`));return}console.log(r.bold(`
|
|
584
587
|
\u{1F4E6} Registered RapidKit Workspaces:
|
|
585
|
-
`));for(let
|
|
586
|
-
`));}catch(
|
|
587
|
-
\u274C Failed to read workspace registry`)),console.error(
|
|
588
|
+
`));for(let p of s.workspaces)console.log(r.cyan(` ${p.name}`)),console.log(r.gray(` Path: ${p.path}`)),console.log(r.gray(` Projects: ${p.projects?.length||0}`)),console.log();n>0&&console.log(r.gray(`Cleaned ${n} stale workspace entr${n===1?"y":"ies"}.`)),console.log(r.gray(`Total: ${s.workspaces.length} workspace(s)
|
|
589
|
+
`));}catch(i){console.error(r.red(`
|
|
590
|
+
\u274C Failed to read workspace registry`)),console.error(r.gray(String(i)));}}export{G as createProject,K as createWorkspace,Y as listWorkspaces,J as registerProjectInWorkspace,S as registerWorkspace,z as syncWorkspaceProjects};
|
package/package.json
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rapidkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.1",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "Official CLI for RapidKit, an open-source workspace platform that standardizes how teams build, scale, and deploy backend services.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"rapidkit",
|
|
8
8
|
"cli",
|
|
9
9
|
"create",
|
|
10
10
|
"fastapi",
|
|
11
11
|
"nestjs",
|
|
12
|
+
"gofiber",
|
|
13
|
+
"gogin",
|
|
12
14
|
"backend",
|
|
13
15
|
"microservices",
|
|
14
16
|
"generator",
|
|
@@ -34,7 +36,7 @@
|
|
|
34
36
|
"build:watch": "tsup --watch",
|
|
35
37
|
"dev": "tsup --watch",
|
|
36
38
|
"dev:local": "npm run build && npm link",
|
|
37
|
-
"install:local": "npm unlink -g rapidkit
|
|
39
|
+
"install:local": "npm unlink -g rapidkit && npm run build && npm link",
|
|
38
40
|
"uninstall:local": "npm unlink -g rapidkit",
|
|
39
41
|
"prepare": "husky",
|
|
40
42
|
"test:e2e:first-install": "bash scripts/e2e-first-install.sh",
|
|
@@ -110,6 +112,9 @@
|
|
|
110
112
|
"vite-bundle-visualizer": "^1.2.1",
|
|
111
113
|
"vitest": "^4.0.15"
|
|
112
114
|
},
|
|
115
|
+
"optionalDependencies": {
|
|
116
|
+
"@rollup/rollup-win32-x64-msvc": "*"
|
|
117
|
+
},
|
|
113
118
|
"engines": {
|
|
114
119
|
"node": ">=20.19.6"
|
|
115
120
|
},
|
package/dist/chunk-5JB4MOC5.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
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};
|