rapidkit 0.23.1 → 0.25.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.
- package/LICENSE +1 -1
- package/README.md +123 -721
- package/dist/chunk-D46IWAXH.js +33 -0
- package/dist/chunk-FXRDNZGB.js +1 -0
- package/dist/{chunk-7LU4Z66R.js → chunk-N64Z3XVF.js} +2 -2
- package/dist/chunk-T62GANVU.js +786 -0
- package/dist/create-EFY5NQWP.js +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +317 -974
- package/dist/package.json +16 -4
- package/dist/{pythonRapidkitExec-YIFUZLND.js → pythonRapidkitExec-7LPE3JUQ.js} +1 -1
- package/dist/{workspace-LZZGJRGV.js → workspace-J5UUDMHW.js} +52 -49
- package/package.json +13 -3
- package/dist/chunk-74G6C57B.js +0 -24
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rapidkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Create RapidKit projects with a single command - The official CLI for RapidKit framework",
|
|
6
6
|
"keywords": [
|
|
@@ -9,6 +9,8 @@
|
|
|
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",
|
|
@@ -57,6 +59,11 @@
|
|
|
57
59
|
"security": "npm audit --audit-level=moderate",
|
|
58
60
|
"security:fix": "npm audit fix",
|
|
59
61
|
"metrics": "npx tsx scripts/metrics.ts",
|
|
62
|
+
"validate:docs-examples": "node scripts/validate-doc-examples.mjs",
|
|
63
|
+
"check:markdown-links": "node scripts/check-markdown-links.mjs",
|
|
64
|
+
"check:docs-drift": "node scripts/docs-drift-guard.mjs",
|
|
65
|
+
"smoke:readme": "node scripts/smoke-readme-commands.mjs",
|
|
66
|
+
"validate:docs": "npm run check:markdown-links && npm run check:docs-drift && npm run validate:docs-examples && npm run smoke:readme",
|
|
60
67
|
"sync:contracts": "node scripts/sync-contracts.mjs",
|
|
61
68
|
"check:contracts": "node scripts/sync-contracts.mjs --check",
|
|
62
69
|
"bundle-size": "npm run build && du -sh dist/ && ls -lh dist/",
|
|
@@ -78,7 +85,7 @@
|
|
|
78
85
|
"fs-extra": "^11.2.0",
|
|
79
86
|
"inquirer": "^13.2.2",
|
|
80
87
|
"nunjucks": "^3.2.4",
|
|
81
|
-
"openai": "^
|
|
88
|
+
"openai": "^6.22.0",
|
|
82
89
|
"ora": "^8.0.1",
|
|
83
90
|
"validate-npm-package-name": "^5.0.1"
|
|
84
91
|
},
|
|
@@ -95,7 +102,6 @@
|
|
|
95
102
|
"@typescript-eslint/parser": "^8.46.2",
|
|
96
103
|
"@vitest/coverage-v8": "^4.0.15",
|
|
97
104
|
"@vitest/ui": "^4.0.15",
|
|
98
|
-
"c8": "^10.1.3",
|
|
99
105
|
"eslint": "^9.39.2",
|
|
100
106
|
"husky": "^9.1.7",
|
|
101
107
|
"lint-staged": "^15.5.2",
|
|
@@ -106,6 +112,9 @@
|
|
|
106
112
|
"vite-bundle-visualizer": "^1.2.1",
|
|
107
113
|
"vitest": "^4.0.15"
|
|
108
114
|
},
|
|
115
|
+
"optionalDependencies": {
|
|
116
|
+
"@rollup/rollup-win32-x64-msvc": "*"
|
|
117
|
+
},
|
|
109
118
|
"engines": {
|
|
110
119
|
"node": ">=20.19.6"
|
|
111
120
|
},
|
|
@@ -115,5 +124,8 @@
|
|
|
115
124
|
"prettier --write"
|
|
116
125
|
]
|
|
117
126
|
},
|
|
127
|
+
"overrides": {
|
|
128
|
+
"minimatch": "^10.2.1"
|
|
129
|
+
},
|
|
118
130
|
"packageManager": "npm@10.8.2"
|
|
119
131
|
}
|
|
@@ -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-D46IWAXH.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {c}from'./chunk-
|
|
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-FXRDNZGB.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.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",
|
|
@@ -57,6 +59,11 @@
|
|
|
57
59
|
"security": "npm audit --audit-level=moderate",
|
|
58
60
|
"security:fix": "npm audit fix",
|
|
59
61
|
"metrics": "npx tsx scripts/metrics.ts",
|
|
62
|
+
"validate:docs-examples": "node scripts/validate-doc-examples.mjs",
|
|
63
|
+
"check:markdown-links": "node scripts/check-markdown-links.mjs",
|
|
64
|
+
"check:docs-drift": "node scripts/docs-drift-guard.mjs",
|
|
65
|
+
"smoke:readme": "node scripts/smoke-readme-commands.mjs",
|
|
66
|
+
"validate:docs": "npm run check:markdown-links && npm run check:docs-drift && npm run validate:docs-examples && npm run smoke:readme",
|
|
60
67
|
"sync:contracts": "node scripts/sync-contracts.mjs",
|
|
61
68
|
"check:contracts": "node scripts/sync-contracts.mjs --check",
|
|
62
69
|
"bundle-size": "npm run build && du -sh dist/ && ls -lh dist/",
|
|
@@ -105,6 +112,9 @@
|
|
|
105
112
|
"vite-bundle-visualizer": "^1.2.1",
|
|
106
113
|
"vitest": "^4.0.15"
|
|
107
114
|
},
|
|
115
|
+
"optionalDependencies": {
|
|
116
|
+
"@rollup/rollup-win32-x64-msvc": "*"
|
|
117
|
+
},
|
|
108
118
|
"engines": {
|
|
109
119
|
"node": ">=20.19.6"
|
|
110
120
|
},
|
package/dist/chunk-74G6C57B.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import z from'crypto';import B from'os';import c from'path';import*as d from'fs-extra';import {execa}from'execa';var W=["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"],A=new Set(W);var y=class extends Error{code;constructor(n,e){super(e),this.code=n;}};function C(t){if(t instanceof y)switch(t.code){case "PYTHON_NOT_FOUND":return "RapidKit (npm) could not find Python (python3/python) on your PATH.\nInstall Python 3.10+ and ensure `python3` is available, then retry.\nTip: 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.
|
|
2
|
-
Ensure Python venv support is installed (e.g., python3-venv).
|
|
3
|
-
Details: ${t.message}`;case "BRIDGE_PIP_BOOTSTRAP_FAILED":return `RapidKit (npm) could not bootstrap pip inside the bridge virtual environment.
|
|
4
|
-
Install python3-venv/python3-pip and retry.
|
|
5
|
-
Details: ${t.message}`;case "BRIDGE_PIP_UPGRADE_FAILED":return `RapidKit (npm) could not upgrade pip in the bridge virtual environment.
|
|
6
|
-
Check your network/proxy or disable RAPIDKIT_BRIDGE_UPGRADE_PIP.
|
|
7
|
-
Details: ${t.message}`;case "BRIDGE_PIP_INSTALL_FAILED":return `RapidKit (npm) could not install rapidkit-core in the bridge virtual environment.
|
|
8
|
-
Check your network/proxy, or install manually with: pipx install rapidkit-core.
|
|
9
|
-
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 S(){let t=process.env.RAPIDKIT_CORE_PYTHON_PACKAGE;return t&&t.trim()?t.trim():"rapidkit-core"}function X(){let t=S(),n=process.env.RAPIDKIT_CORE_PYTHON_PACKAGE_ID,e=n&&n.trim()?`${t}|${n.trim()}`:t;return z.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(B.homedir(),".cache")}function q(){return c.join(R(),"rapidkit","npm-bridge","venv")}function F(){let t=X();return c.join(R(),"rapidkit","npm-bridge",`venv-${t}`)}function O(t){return process.platform==="win32"?c.join(t,"Scripts","python.exe"):c.join(t,"bin","python")}function N(t){return process.platform==="win32"?c.join(t,"Scripts","rapidkit.exe"):c.join(t,"bin","rapidkit")}function Q(t){return /[<>=!~]=|@|\.whl$|\.tar\.gz$|\.zip$|git\+|https?:\/\//.test(t)}function Z(t){return c.dirname(c.dirname(t))}function G(){return c.join(R(),"rapidkit","npm-bridge","core-commands.json")}async function V(t){let n=!!process.env.RAPIDKIT_DEBUG,e=r=>{n&&process.stderr.write(`[DEBUG] tryRapidkit(${t}): ${r}
|
|
10
|
-
`);};try{e("probing interpreter-specific rapidkit script");let s=((await execa(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 d.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),p=!!o&&typeof o=="object"&&o!==null&&"version"in o;if(e(`script JSON parse ok=${p}`),p)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,["-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,["-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 d.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 p=JSON.parse(o);if(p&&typeof p=="object"&&p!==null&&"version"in p)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 tt(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 d.pathExists(a)){let l=await execa(a,["--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:s});if(l.exitCode===0&&await D(l.stdout))return {cmd:a,baseArgs:[]}}let o=c.join(s,r);if(await d.pathExists(o)){let l=await execa(o,["-m","rapidkit","--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:s});if(l.exitCode===0&&await D(l.stdout))return {cmd:o,baseArgs:["-m","rapidkit"]}}let p=c.dirname(s);if(p===s)break;s=p;}return null}async function et(t){try{let n=c.join(t,".python-version");if(await d.pathExists(n)){let r=(await d.readFile(n,"utf-8")).trim();if(r)return r}}catch{}try{let n=c.join(t,".rapidkit-workspace");if(await d.pathExists(n)){let e=await d.readFile(n,"utf-8"),r=JSON.parse(e);if(r.pythonVersion)return r.pythonVersion}}catch{}return null}async function j(t){if(t&&t.trim())try{let i=await tt(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 et(a);return o&&(process.env.PYENV_VERSION=o),i}}catch{}let n=await rt();if(n.kind==="venv"){let i=Z(n.pythonPath),a=N(i);return await d.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 d.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=F(),r=await x(n.cmd),s=N(e);return await d.pathExists(s)?{cmd:s,baseArgs:[]}:{cmd:r,baseArgs:["-m","rapidkit"]}}async function I(){for(let t of ["python3","python"])try{return await execa(t,["--version"],{reject:false,stdio:"pipe",timeout:2e3}),t}catch{}return null}async function nt(){let t=!!process.env.RAPIDKIT_DEBUG,n=e=>{t&&process.stderr.write(`[DEBUG] checkRapidkitCore: ${e}
|
|
11
|
-
`);};for(let e of ["python3","python","python3.10","python3.11","python3.12"])try{n(`Method 1: trying ${e} import`);let r=await execa(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"])try{n(`Method 2: trying ${e} -m pip show`);let r=await execa(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(`
|
|
12
|
-
`).filter(s=>s.trim());n(`Found pyenv versions: ${r.join(", ")}`);for(let s of r){let i=process.env.PYENV_ROOT||c.join(B.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"])try{n(`Method 5: checking ${e} user site`);let r=await execa(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 d.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 x(t){let n=F(),e=q(),r=S(),s=[n];!Q(r)&&!await d.pathExists(n)&&await d.pathExists(e)&&s.push(e);for(let m of s){let h=O(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=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")),p=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")),w=m=>new Promise(h=>setTimeout(h,m)),v=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 k=(g.stdout??"").toString(),b=(g.stderr??"").toString(),P=[k,b].filter(Boolean).join(`
|
|
13
|
-
`),H=P?`${m} ${h.join(" ")}
|
|
14
|
-
${P}`:`${m} ${h.join(" ")}`;throw new Error(H)},E=async(m,h,f)=>{let g=0;for(;;)try{await v(m,h,f);return}catch(k){if(g>=o)throw k;let b=Math.floor(Math.random()*200),P=p*Math.pow(2,g)+b;g+=1,await w(P);}};try{await d.ensureDir(c.dirname(i));try{await v(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=O(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 E(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 E(m,["-m","pip","install","-U",S()],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 rt(){if(process.env.RAPIDKIT_BRIDGE_FORCE_VENV==="1"){let e=await I();if(!e)throw new y("PYTHON_NOT_FOUND","No Python interpreter found (python3/python).");return {kind:"venv",pythonPath:await x(e)}}for(let e of ["python3","python"])if(await V(e))return {kind:"system",cmd:e};let t=await I();if(!t)throw new y("PYTHON_NOT_FOUND","No Python interpreter found (python3/python).");return {kind:"venv",pythonPath:await x(t)}}async function ht(t,n){try{let e=await j(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:"inherit"});return typeof i.exitCode=="number"?i.exitCode:1}catch(e){return process.stderr.write(`${C(e)}
|
|
15
|
-
`),1}}var it=[{pattern:/RapidKitError:\s*Directory '([^']+)' exists and force is not set/,message:t=>`\u274C Directory "${c.basename(t[1])}" already exists.
|
|
16
|
-
\u{1F4A1} Choose a different name, or remove the existing directory first:
|
|
17
|
-
rm -rf ${t[1]}`},{pattern:/RapidKitError:\s*Project name '([^']+)' is (invalid|not allowed)/i,message:t=>`\u274C Invalid project name: "${t[1]}"
|
|
18
|
-
\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]}"
|
|
19
|
-
\u{1F4A1} Run "npx rapidkit list" to see available kits.`},{pattern:/RapidKitError:\s*(.+)/,message:t=>`\u274C ${t[1].trim()}`}];async function gt(t,n){let{spawn:e}=await import('child_process');try{let r=await j(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"]}),p=[];o.stderr?.on("data",l=>{p.push(l);}),o.on("close",l=>{let w=l??1;if(w!==0&&p.length>0){let v=Buffer.concat(p).toString("utf8");for(let{pattern:E,message:m}of it){let h=v.match(E);if(h){process.stderr.write(m(h)+`
|
|
20
|
-
`),a(w);return}}process.stderr.write(v);}a(w);}),o.on("error",l=>{process.stderr.write(`${C(l)}
|
|
21
|
-
`),a(1);});})}catch(r){return process.stderr.write(`${C(r)}
|
|
22
|
-
`),1}}async function _(t,n){try{let e=await j(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:`${C(e)}
|
|
23
|
-
`}}}function K(t){let n=new Set,e=t.split(`
|
|
24
|
-
`),r=false;for(let s of e){let i=s.replace(/\r$/,"");if(!r){/^\s*Commands:\s*$/i.test(i)&&(r=true);let p=i.match(/^\s*rapidkit\s+([a-z0-9_-]+)\b/i);if(p){let l=p[1].trim();l&&!l.startsWith("-")&&n.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 o=a[1].trim();o&&!o.startsWith("-")&&n.add(o);}return n}async function L(){let t=G();if(!await d.pathExists(t))return null;try{let n=await d.readJson(t);if(n&&n.schema_version===1&&Array.isArray(n.commands))return n}catch{}return null}async function T(t){let n=G();await d.ensureDir(c.dirname(n)),await d.writeJson(n,t,{spaces:2});}async function ot(){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 st(){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 yt(){let n=Date.now(),e=await L(),r=await ot(),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 st();if(i?.length){let l=Array.from(new Set(i)).sort();return await T({schema_version:1,fetched_at:n,rapidkit_version:r,commands:l}),new Set(l)}let a=await _(["--help"],{cwd:process.cwd()});if(a.exitCode!==0)return s&&e?.commands?new Set(e.commands):new Set(A);let o=K(a.stdout);if(o.size===0)return new Set(A);let p=Array.from(o).sort();return await T({schema_version:1,fetched_at:n,rapidkit_version:r,commands:p}),o}async function wt(){let n=Date.now(),e=await L();return !e||n-e.fetched_at>=864e5||!e.commands?.length?null:new Set(e.commands)}function J(){return c.join(R(),"rapidkit","npm-bridge","modules-catalog.json")}async function at(){let t=J();if(!await d.pathExists(t))return null;try{let n=await d.readJson(t);if(n&&n.schema_version===1&&Array.isArray(n.modules))return n}catch{}return null}async function $(t){let n=J();await d.ensureDir(c.dirname(n)),await d.writeJson(n,t,{spaces:2});}function M(t){try{return JSON.parse(t)}catch{return null}}async function vt(t={}){let n=typeof t.ttlMs=="number"?t.ttlMs:18e5,e=Date.now(),r=await at();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=M(i.stdout);if(o&&o.schema_version===1&&Array.isArray(o.modules)){let p={...o,fetched_at:e};return await $(p),p}}let a=await _(["modules","list","--json"],{cwd:t.cwd,env:t.env});if(a.exitCode===0){let o=M(a.stdout);if(Array.isArray(o)){let p={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 $(p),p}}return r||null}var _t={pickSystemPython:I,ensureBridgeVenv:x,parseCoreCommandsFromHelp:K,tryRapidkit:V,checkRapidkitCoreAvailable:nt};export{A as a,nt as b,rt as c,ht as d,gt as e,_ as f,yt as g,wt as h,vt as i,_t as j};
|