rapidkit 0.16.4 → 0.16.5
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 +68 -33
- package/dist/index.js +171 -188
- package/dist/package.json +3 -1
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -536,68 +536,103 @@ The registry stores workspace and project metadata:
|
|
|
536
536
|
|
|
537
537
|
## 📁 Project Structure
|
|
538
538
|
|
|
539
|
+
### Workspace
|
|
540
|
+
|
|
541
|
+
```
|
|
542
|
+
my-workspace/
|
|
543
|
+
├── my-api/ # FastAPI project
|
|
544
|
+
│ ├── .rapidkit/ # Project config
|
|
545
|
+
│ ├── src/ # Source code
|
|
546
|
+
│ ├── config/ # Configuration
|
|
547
|
+
│ ├── tests/ # Test suite
|
|
548
|
+
│ ├── pyproject.toml # Poetry config
|
|
549
|
+
│ └── Dockerfile # Docker setup
|
|
550
|
+
├── my-service/ # NestJS project
|
|
551
|
+
│ ├── .rapidkit/ # Project config
|
|
552
|
+
│ ├── src/ # Source code
|
|
553
|
+
│ ├── test/ # Test suite
|
|
554
|
+
│ ├── package.json # npm config
|
|
555
|
+
│ └── Dockerfile # Docker setup
|
|
556
|
+
├── .venv/ # Workspace Python environment
|
|
557
|
+
├── .rapidkit-workspace # Workspace metadata
|
|
558
|
+
├── poetry.lock # Locked Python dependencies
|
|
559
|
+
├── pyproject.toml # Workspace Python config
|
|
560
|
+
├── rapidkit # CLI script (bash)
|
|
561
|
+
├── rapidkit.cmd # CLI script (Windows)
|
|
562
|
+
├── README.md
|
|
563
|
+
└── Makefile
|
|
564
|
+
```
|
|
565
|
+
|
|
539
566
|
### FastAPI Project
|
|
540
567
|
|
|
541
568
|
```
|
|
542
569
|
my-api/
|
|
543
|
-
├── .rapidkit/
|
|
544
|
-
│ ├──
|
|
545
|
-
│ ├──
|
|
546
|
-
│ ├──
|
|
547
|
-
│ └──
|
|
548
|
-
├──
|
|
549
|
-
├──
|
|
550
|
-
│ ├──
|
|
551
|
-
│ ├── cli.py # CLI commands
|
|
552
|
-
│ ├── routing/ # API routes
|
|
570
|
+
├── .rapidkit/ # RapidKit config
|
|
571
|
+
│ ├── project.json # Project metadata
|
|
572
|
+
│ ├── context.json # Project context
|
|
573
|
+
│ ├── cli.py # Local CLI module
|
|
574
|
+
│ └── activate # Environment activation
|
|
575
|
+
├── src/ # Source code
|
|
576
|
+
│ ├── main.py # FastAPI entry point
|
|
577
|
+
│ ├── routing/ # API routes
|
|
553
578
|
│ │ ├── __init__.py
|
|
554
579
|
│ │ ├── health.py
|
|
555
580
|
│ │ └── examples.py
|
|
556
|
-
│ └── modules/
|
|
581
|
+
│ └── modules/ # Feature modules
|
|
557
582
|
│ └── __init__.py
|
|
558
|
-
├──
|
|
583
|
+
├── config/ # Configuration
|
|
584
|
+
├── tests/ # Test suite
|
|
559
585
|
│ ├── __init__.py
|
|
560
586
|
│ ├── test_health.py
|
|
561
587
|
│ └── test_examples.py
|
|
562
|
-
├──
|
|
563
|
-
├──
|
|
564
|
-
├── Dockerfile # Docker configuration
|
|
565
|
-
├── docker-compose.yml # Docker Compose
|
|
566
|
-
├── .env.example # Environment template
|
|
588
|
+
├── .github/ # GitHub workflows
|
|
589
|
+
├── .env.example # Environment template
|
|
567
590
|
├── .gitignore
|
|
591
|
+
├── bootstrap.sh # Setup script
|
|
592
|
+
├── docker-compose.yml # Docker Compose
|
|
593
|
+
├── Dockerfile # Docker configuration
|
|
594
|
+
├── Makefile # Make commands
|
|
595
|
+
├── poetry.lock # Locked dependencies
|
|
596
|
+
├── pyproject.toml # Poetry configuration
|
|
597
|
+
├── LICENSE
|
|
568
598
|
└── README.md
|
|
569
599
|
```
|
|
570
600
|
|
|
571
601
|
### NestJS Project
|
|
572
602
|
|
|
573
603
|
```
|
|
574
|
-
my-
|
|
575
|
-
├── .rapidkit/
|
|
576
|
-
│ ├──
|
|
577
|
-
│ ├──
|
|
578
|
-
│ └──
|
|
579
|
-
├──
|
|
580
|
-
├──
|
|
581
|
-
│ ├── main.ts # Application entry point
|
|
604
|
+
my-app/
|
|
605
|
+
├── .rapidkit/ # RapidKit config
|
|
606
|
+
│ ├── project.json # Project metadata
|
|
607
|
+
│ ├── context.json # Project context
|
|
608
|
+
│ └── cli.js # Local CLI module (optional)
|
|
609
|
+
├── src/ # Source code
|
|
610
|
+
│ ├── main.ts # NestJS entry point
|
|
582
611
|
│ ├── app.module.ts # Root module
|
|
583
612
|
│ ├── app.controller.ts # Root controller
|
|
584
613
|
│ ├── app.service.ts # Root service
|
|
585
|
-
│ ├── config/ # Configuration
|
|
614
|
+
│ ├── config/ # Configuration module
|
|
586
615
|
│ │ ├── configuration.ts
|
|
587
616
|
│ │ └── validation.ts
|
|
588
|
-
│ └── examples/ # Example module
|
|
617
|
+
│ └── examples/ # Example CRUD module
|
|
589
618
|
│ ├── examples.module.ts
|
|
590
619
|
│ ├── examples.controller.ts
|
|
591
620
|
│ └── examples.service.ts
|
|
592
|
-
├── test/ # Test
|
|
621
|
+
├── test/ # Test suite
|
|
593
622
|
│ ├── app.e2e-spec.ts
|
|
594
623
|
│ └── jest-e2e.json
|
|
595
|
-
├──
|
|
596
|
-
├── tsconfig.json # TypeScript config
|
|
597
|
-
├── nest-cli.json # NestJS CLI config
|
|
598
|
-
├── Dockerfile # Docker configuration
|
|
599
|
-
├── docker-compose.yml # Docker Compose
|
|
624
|
+
├── .github/ # GitHub workflows
|
|
600
625
|
├── .env.example # Environment template
|
|
626
|
+
├── .gitignore
|
|
627
|
+
├── bootstrap.sh # Setup script
|
|
628
|
+
├── docker-compose.yml # Docker Compose
|
|
629
|
+
├── Dockerfile # Docker configuration
|
|
630
|
+
├── eslint.config.cjs # ESLint configuration
|
|
631
|
+
├── jest.config.ts # Jest configuration
|
|
632
|
+
├── nest-cli.json # NestJS CLI config
|
|
633
|
+
├── package.json # npm dependencies
|
|
634
|
+
├── tsconfig.json # TypeScript config
|
|
635
|
+
├── LICENSE
|
|
601
636
|
└── README.md
|
|
602
637
|
```
|
|
603
638
|
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import v from'path';import {fileURLToPath}from'url';import
|
|
3
|
-
[${e}/${i}]`),
|
|
4
|
-
\u26A0\uFE0F Update available: ${
|
|
5
|
-
`))):
|
|
6
|
-
`);};try{i("probing interpreter-specific rapidkit script");let
|
|
7
|
-
`);};for(let i of ["python3","python","python3.10","python3.11","python3.12"])try{e(`Method 1: trying ${i} import`);let
|
|
8
|
-
`).filter(
|
|
9
|
-
`),l
|
|
10
|
-
${
|
|
2
|
+
import v from'path';import {fileURLToPath,pathToFileURL}from'url';import g from'chalk';import {execa}from'execa';import {createRequire}from'module';import*as z from'os';import z__default from'os';import*as I from'fs-extra';import T,{promises}from'fs';import wt from'ora';import {Command,Option}from'commander';import Jt from'inquirer';import {spawn}from'child_process';import ze from'validate-npm-package-name';import Ri from'nunjucks';import Ci from'crypto';var Me=Object.defineProperty;var at=(t,e)=>()=>(t&&(e=t(t=0)),e);var Nt=(t,e)=>{for(var i in e)Me(t,i,{get:e[i],enumerable:true});};var $=at(()=>{});var Dt,u,st=at(()=>{$();Dt=class{debugEnabled=false;setDebug(e){this.debugEnabled=e;}debug(e,...i){this.debugEnabled&&console.log(g.gray(`[DEBUG] ${e}`),...i);}info(e,...i){console.log(g.blue(e),...i);}success(e,...i){console.log(g.green(e),...i);}warn(e,...i){console.log(g.yellow(e),...i);}error(e,...i){console.error(g.red(e),...i);}step(e,i,o){console.log(g.cyan(`
|
|
3
|
+
[${e}/${i}]`),g.white(o));}},u=new Dt;});async function te(){try{u.debug("Checking for updates...");let{stdout:t}=await execa("npm",["view",Ge,"version"],{timeout:3e3}),e=t.trim();e&&e!==Tt?(console.log(g.yellow(`
|
|
4
|
+
\u26A0\uFE0F Update available: ${Tt} \u2192 ${e}`)),console.log(g.cyan(`Run: npm install -g rapidkit@latest
|
|
5
|
+
`))):u.debug("You are using the latest version");}catch{u.debug("Could not check for updates");}}function U(){return Tt}var Ge,Ve,Ue,Tt,gt=at(()=>{$();st();Ge="rapidkit",Ve=createRequire(import.meta.url),Ue=Ve("../package.json"),Tt=Ue?.version??"0.0.0";});var Gt={};Nt(Gt,{__test__:()=>ai,checkRapidkitCoreAvailable:()=>me,getCachedCoreTopLevelCommands:()=>Lt,getCoreTopLevelCommands:()=>ni,resolveRapidkitPython:()=>dt,runCoreRapidkit:()=>B,runCoreRapidkitCapture:()=>Wt});function Mt(t){return t instanceof lt?t.code==="PYTHON_NOT_FOUND"?"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.":`RapidKit (npm) bridge error: ${t.message}`:`RapidKit (npm) failed to run the Python core engine: ${t instanceof Error?t.message:String(t)}`}function ti(){let t=process.env.RAPIDKIT_CORE_PYTHON_PACKAGE;return t&&t.trim()?t.trim():"rapidkit-core"}function pe(){let t=process.env.XDG_CACHE_HOME;return t&&t.trim()?t:v.join(z__default.homedir(),".cache")}function Ot(){return v.join(pe(),"rapidkit","npm-bridge","venv")}function ae(t){return process.platform==="win32"?v.join(t,"Scripts","python.exe"):v.join(t,"bin","python")}function se(t){return process.platform==="win32"?v.join(t,"Scripts","rapidkit.exe"):v.join(t,"bin","rapidkit")}function le(){return v.join(pe(),"rapidkit","npm-bridge","core-commands.json")}async function de(t){let e=!!process.env.RAPIDKIT_DEBUG,i=o=>{e&&process.stderr.write(`[DEBUG] tryRapidkit(${t}): ${o}
|
|
6
|
+
`);};try{i("probing interpreter-specific rapidkit script");let r=((await execa(t,["-c","import sysconfig, os; print(os.path.join(sysconfig.get_path('scripts'), 'rapidkit'))"],{reject:!1,stdio:"pipe",timeout:2e3})).stdout??"").toString().trim();if(i(`script path: ${r}`),r)try{if(await I.pathExists(r)){i(`found script at ${r}; invoking --version --json`);let n=await execa(r,["--version","--json"],{reject:!1,stdio:"pipe",timeout:4e3});if(i(`script exitCode=${n.exitCode}`),n.exitCode===0){let a=(n.stdout??"").toString().trim();try{let s=JSON.parse(a),c=!!s&&typeof s=="object"&&s!==null&&"version"in s;if(i(`script JSON parse ok=${c}`),c)return !0}catch{i("script output not valid JSON");}}}}catch(n){i(`interpreter-specific script probe failed: ${String(n)}`);}}catch(o){i(`interpreter-specific script probe error: ${String(o)}`);}try{i('probing importlib.find_spec("rapidkit")');let o=await execa(t,["-c","import importlib.util; print(1 if importlib.util.find_spec('rapidkit') else 0)"],{reject:!1,stdio:"pipe",timeout:2e3});if(i(`import probe exitCode=${o.exitCode} stdout=${(o.stdout??"").toString().trim()}`),o.exitCode===0&&(o.stdout??"").toString().trim()==="1")return !0}catch(o){i(`import probe error: ${String(o)}`);}try{i("probing python -m rapidkit");let o=await execa(t,["-m","rapidkit","--version","--json"],{reject:!1,stdio:"pipe",timeout:8e3});if(i(`-m probe exitCode=${o.exitCode}`),o.exitCode===0)return !0}catch(o){i(`-m probe error: ${String(o)}`);}try{i("probing PATH for rapidkit executables");let o=(process.env.PATH??"").split(v.delimiter).filter(Boolean);for(let r of o){let n=v.join(r,process.platform==="win32"?"rapidkit.exe":"rapidkit");try{if(await I.pathExists(n)){i(`found candidate on PATH: ${n}; invoking --version --json`);let a=await execa(n,["--version","--json"],{reject:!1,stdio:"pipe",timeout:4e3});if(i(`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 !0}catch{i("candidate output not valid JSON, skipping");}}}}catch(a){i(`error probing candidate ${n}: ${String(a)}`);}}return i("no valid rapidkit found on PATH"),!1}catch(o){return i(`PATH probe error: ${String(o)}`),false}}async function Ft(t){let e=(t??"").toString().trim();if(!e)return false;try{let i=JSON.parse(e);return !!i&&typeof i=="object"&&i!==null&&"version"in i}catch{return false}}async function ei(t){let e=process.platform==="win32",i=e?v.join(".venv","Scripts","rapidkit.exe"):v.join(".venv","bin","rapidkit"),o=e?v.join(".venv","Scripts","python.exe"):v.join(".venv","bin","python"),r=t;for(let n=0;n<25;n+=1){let a=v.join(r,i);if(await I.pathExists(a)){let p=await execa(a,["--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:r});if(p.exitCode===0&&await Ft(p.stdout))return {cmd:a,baseArgs:[]}}let s=v.join(r,o);if(await I.pathExists(s)){let p=await execa(s,["-m","rapidkit","--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:r});if(p.exitCode===0&&await Ft(p.stdout))return {cmd:s,baseArgs:["-m","rapidkit"]}}let c=v.dirname(r);if(c===r)break;r=c;}return null}async function ii(t){try{let e=v.join(t,".python-version");if(await I.pathExists(e)){let o=(await I.readFile(e,"utf-8")).trim();if(o)return o}}catch{}try{let e=v.join(t,".rapidkit-workspace");if(await I.pathExists(e)){let i=await I.readFile(e,"utf-8"),o=JSON.parse(i);if(o.pythonVersion)return o.pythonVersion}}catch{}return null}async function ue(t){if(t&&t.trim())try{let n=await ei(t);if(n){let a=v.dirname(n.cmd).includes(".venv")?v.dirname(v.dirname(v.dirname(n.cmd))):v.dirname(n.cmd),s=await ii(a);return s&&(process.env.PYENV_VERSION=s),n}}catch{}let e=await dt();if(e.kind==="venv"){let n=Ot(),a=se(n);return await I.pathExists(a)?{cmd:a,baseArgs:[]}:{cmd:e.pythonPath,baseArgs:["-m","rapidkit"]}}try{if((await execa(e.cmd,["-m","rapidkit","--version","--json"],{reject:!1,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:!1,stdio:"pipe",timeout:2e3})).stdout??"").toString().trim();if(a&&await I.pathExists(a))try{let s=await execa(a,["--version","--json"],{reject:!1,stdio:"pipe",timeout:4e3});if(s.exitCode===0&&await Ft(s.stdout))return {cmd:a,baseArgs:[]}}catch{}}catch{}let i=Ot(),o=await bt(e.cmd),r=se(i);return await I.pathExists(r)?{cmd:r,baseArgs:[]}:{cmd:o,baseArgs:["-m","rapidkit"]}}async function Kt(){for(let t of ["python3","python"])try{return await execa(t,["--version"],{reject:!1,stdio:"pipe",timeout:2e3}),t}catch{}return null}async function me(){let t=!!process.env.RAPIDKIT_DEBUG,e=i=>{t&&process.stderr.write(`[DEBUG] checkRapidkitCore: ${i}
|
|
7
|
+
`);};for(let i of ["python3","python","python3.10","python3.11","python3.12"])try{e(`Method 1: trying ${i} import`);let o=await execa(i,["-c","import rapidkit_core; print(1)"],{reject:!1,stdio:"pipe",timeout:3e3});if(o.exitCode===0&&o.stdout?.trim()==="1")return e(`\u2713 Found via ${i} import`),!0}catch{continue}for(let i of ["python3","python"])try{e(`Method 2: trying ${i} -m pip show`);let o=await execa(i,["-m","pip","show","rapidkit-core"],{reject:!1,stdio:"pipe",timeout:3e3});if(o.exitCode===0&&o.stdout?.includes("Name: rapidkit-core"))return e(`\u2713 Found via ${i} -m pip show`),!0}catch{continue}for(let i of ["pip","pip3"])try{e(`Method 3: trying ${i} show`);let o=await execa(i,["show","rapidkit-core"],{reject:!1,stdio:"pipe",timeout:3e3});if(o.exitCode===0&&o.stdout?.includes("Name: rapidkit-core"))return e(`\u2713 Found via ${i} show`),!0}catch{continue}try{e("Method 4: checking pyenv versions");let i=await execa("pyenv",["versions","--bare"],{reject:!1,stdio:"pipe",timeout:3e3});if(i.exitCode===0&&i.stdout){let o=i.stdout.split(`
|
|
8
|
+
`).filter(r=>r.trim());e(`Found pyenv versions: ${o.join(", ")}`);for(let r of o){let n=process.env.PYENV_ROOT||v.join(z__default.homedir(),".pyenv"),a=v.join(n,"versions",r.trim(),"bin","pip");try{let s=await execa(a,["show","rapidkit-core"],{reject:!1,stdio:"pipe",timeout:3e3});if(s.exitCode===0&&s.stdout?.includes("Name: rapidkit-core"))return e(`\u2713 Found in pyenv ${r}`),!0}catch{try{let s=await execa("bash",["-c",`PYENV_VERSION=${r.trim()} pyenv exec pip show rapidkit-core`],{reject:!1,stdio:"pipe",timeout:3e3});if(s.exitCode===0&&s.stdout?.includes("Name: rapidkit-core"))return e(`\u2713 Found in pyenv ${r} via PYENV_VERSION`),!0}catch{continue}}}}}catch{e("pyenv not available");}for(let i of ["python3","python"])try{e(`Method 5: checking ${i} user site`);let o=await execa(i,["-m","site","--user-site"],{reject:!1,stdio:"pipe",timeout:3e3});if(o.exitCode===0&&o.stdout){let r=o.stdout.trim(),n=v.join(r,"rapidkit_core");if(await I.pathExists(n))return e("\u2713 Found in user site-packages"),!0}}catch{continue}try{e("Method 6: checking pipx");let i=await execa("pipx",["list"],{reject:!1,stdio:"pipe",timeout:3e3});if(i.exitCode===0&&i.stdout?.includes("rapidkit-core"))return e("\u2713 Found via pipx"),!0}catch{e("pipx not available");}try{if(e("Method 7: checking poetry"),(await execa("poetry",["show","rapidkit-core"],{reject:!1,stdio:"pipe",timeout:3e3})).exitCode===0)return e("\u2713 Found via poetry"),!0}catch{e("poetry check failed");}try{e("Method 8: checking conda");let i=await execa("conda",["list","rapidkit-core"],{reject:!1,stdio:"pipe",timeout:3e3});if(i.exitCode===0&&i.stdout?.includes("rapidkit-core"))return e("\u2713 Found via conda"),!0}catch{e("conda not available");}return e("\u2717 Not found in any environment"),false}async function bt(t){let e=Ot(),i=ae(e);if(await I.pathExists(i))try{let n=await execa(i,["-c","import importlib.util; print(1 if importlib.util.find_spec('rapidkit') else 0)"],{reject:!1,stdio:"pipe",timeout:2e3});if(n.exitCode===0&&(n.stdout??"").toString().trim()==="1")return i;await I.remove(e);}catch{await I.remove(e);}let o={...process.env,PIP_DISABLE_PIP_VERSION_CHECK:"1",PIP_NO_PYTHON_VERSION_WARNING:"1"},r=async(n,a)=>{let s=await execa(n,a,{reject:false,stdio:["ignore","pipe","inherit"],env:o});if(s.exitCode===0)return;let c=(s.stdout??"").toString(),p=(s.stderr??"").toString(),l=[c,p].filter(Boolean).join(`
|
|
9
|
+
`),d=l?`${n} ${a.join(" ")}
|
|
10
|
+
${l}`:`${n} ${a.join(" ")}`;throw new Error(d)};try{await I.ensureDir(v.dirname(e)),await r(t,["-m","venv",e]);let n=ae(e);if((await execa(n,["-m","pip","--version"],{reject:!1,stdio:"pipe",timeout:2e3})).exitCode!==0&&(await execa(n,["-m","ensurepip","--default-pip"],{reject:!1,stdio:["ignore","pipe","inherit"],env:o})).exitCode!==0)throw new Error(`Failed to install pip in virtual environment.
|
|
11
11
|
Your Python installation may be missing the ensurepip module.
|
|
12
|
-
On Debian/Ubuntu, install: sudo apt install python3-venv python3-pip`);return process.env.RAPIDKIT_BRIDGE_UPGRADE_PIP==="1"&&await n
|
|
13
|
-
`),1}}async function
|
|
14
|
-
`}}}function
|
|
15
|
-
`),
|
|
16
|
-
`,"utf-8");}async function
|
|
12
|
+
On Debian/Ubuntu, install: sudo apt install python3-venv python3-pip`);return process.env.RAPIDKIT_BRIDGE_UPGRADE_PIP==="1"&&await r(n,["-m","pip","install","-U","pip"]),await r(n,["-m","pip","install","-U",ti()]),n}catch(n){throw new lt("BRIDGE_VENV_BOOTSTRAP_FAILED",Mt(n))}}async function dt(){if(process.env.RAPIDKIT_BRIDGE_FORCE_VENV==="1"){let i=await Kt();if(!i)throw new lt("PYTHON_NOT_FOUND","No Python interpreter found (python3/python).");return {kind:"venv",pythonPath:await bt(i)}}for(let i of ["python3","python"])if(await de(i))return {kind:"system",cmd:i};let t=await Kt();if(!t)throw new lt("PYTHON_NOT_FOUND","No Python interpreter found (python3/python).");return {kind:"venv",pythonPath:await bt(t)}}async function B(t,e){try{let i=await ue(e?.cwd),o=i.cmd,r=[...i.baseArgs,...t],n=await execa(o,r,{cwd:e?.cwd,env:{...process.env,...e?.env},reject:!1,stdio:"inherit"});return typeof n.exitCode=="number"?n.exitCode:1}catch(i){return process.stderr.write(`${Mt(i)}
|
|
13
|
+
`),1}}async function Wt(t,e){try{let i=await ue(e?.cwd),o=i.cmd,r=[...i.baseArgs,...t],n=await execa(o,r,{cwd:e?.cwd,env:{...process.env,...e?.env},reject:!1,stdio:"pipe"});return {exitCode:typeof n.exitCode=="number"?n.exitCode:1,stdout:(n.stdout??"").toString(),stderr:(n.stderr??"").toString()}}catch(i){return {exitCode:1,stdout:"",stderr:`${Mt(i)}
|
|
14
|
+
`}}}function ge(t){let e=new Set,i=t.split(`
|
|
15
|
+
`),o=false;for(let r of i){let n=r.replace(/\r$/,"");if(!o){/^\s*Commands:\s*$/i.test(n)&&(o=true);let c=n.match(/^\s*rapidkit\s+([a-z0-9_-]+)\b/i);if(c){let p=c[1].trim();p&&!p.startsWith("-")&&e.add(p);}continue}if(!n.trim())break;if(/^\s*(Options|Arguments|Usage|Commands)\s*:/i.test(n))continue;let a=n.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 fe(){let t=le();if(!await I.pathExists(t))return null;try{let e=await I.readJson(t);if(e&&e.schema_version===1&&Array.isArray(e.commands))return e}catch{}return null}async function oi(t){let e=le();await I.ensureDir(v.dirname(e)),await I.writeJson(e,t,{spaces:2});}async function ri(){let t=await Wt(["version","--json"],{cwd:process.cwd()});if(t.exitCode===0)try{let i=JSON.parse(t.stdout)?.version;return typeof i=="string"?i:void 0}catch{return}}async function ni(){let e=Date.now(),i=await fe(),o=await ri(),r=!!i?.commands?.length;if(r&&e-i.fetched_at<864e5&&(!o||!i.rapidkit_version||i.rapidkit_version===o))return new Set(i.commands);let n=await Wt(["--help"],{cwd:process.cwd()});if(n.exitCode!==0)return r&&i?.commands?new Set(i.commands):new Set;let a=ge(n.stdout);if(a.size===0)return new Set;let s=Array.from(a).sort();return await oi({schema_version:1,fetched_at:e,rapidkit_version:o,commands:s}),a}async function Lt(){let e=Date.now(),i=await fe();return !i||e-i.fetched_at>=864e5||!i.commands?.length?null:new Set(i.commands)}var lt,ai,$t=at(()=>{$();lt=class extends Error{code;constructor(e,i){super(i),this.code=e;}};ai={pickSystemPython:Kt,ensureBridgeVenv:bt,parseCoreCommandsFromHelp:ge,tryRapidkit:de,checkRapidkitCoreAvailable:me};});var we={};Nt(we,{createNpmWorkspaceMarker:()=>Ut,isValidWorkspaceMarker:()=>pi,readWorkspaceMarker:()=>Vt,updateWorkspaceMetadata:()=>ci,writeWorkspaceMarker:()=>Pt});async function Vt(t){let e=v.join(t,".rapidkit-workspace");try{if(await I.pathExists(e))return await I.readJson(e)}catch{return null}return null}async function Pt(t,e){let i=v.join(t,".rapidkit-workspace"),o=await Vt(t);o?.metadata&&(e.metadata={...o.metadata,...e.metadata}),await I.outputFile(i,JSON.stringify(e,null,2)+`
|
|
16
|
+
`,"utf-8");}async function ci(t,e){let i=await Vt(t);return i?(i.metadata={...i.metadata,...e,vscode:e.vscode?{...i.metadata?.vscode,...e.vscode}:i.metadata?.vscode,npm:e.npm?{...i.metadata?.npm,...e.npm}:i.metadata?.npm,python:e.python?{...i.metadata?.python,...e.python}:i.metadata?.python},await Pt(t,i),true):false}function Ut(t,e,i){return {signature:"RAPIDKIT_WORKSPACE",createdBy:"rapidkit-npm",version:e,createdAt:new Date().toISOString(),name:t,metadata:{npm:{packageVersion:e,installMethod:i,lastUsedAt:new Date().toISOString()}}}}function pi(t){if(!t||typeof t!="object")return false;let e=t;return e.signature==="RAPIDKIT_WORKSPACE"&&typeof e.createdBy=="string"&&typeof e.version=="string"&&typeof e.createdAt=="string"&&typeof e.name=="string"}var Bt=at(()=>{$();});var q={};Nt(q,{createProject:()=>hi,createWorkspace:()=>ui,listWorkspaces:()=>wi,registerProjectInWorkspace:()=>di,registerWorkspace:()=>ke,syncWorkspaceProjects:()=>li});async function ke(t,e){try{let i=process.env.XDG_CONFIG_HOME||process.env.APPDATA||v.join(z__default.homedir(),".config"),o=process.platform==="win32"?v.join(i,"rapidkit"):v.join(z__default.homedir(),".rapidkit"),r=v.join(o,"workspaces.json");await promises.mkdir(o,{recursive:!0});let n={workspaces:[]};try{let s=await promises.readFile(r,"utf8"),c=JSON.parse(s);c&&Array.isArray(c.workspaces)&&(n=c);}catch{}n.workspaces.some(s=>s.path===t)||(n.workspaces.push({name:e,path:t,mode:"full",projects:[]}),await promises.writeFile(r,JSON.stringify(n,null,2)));}catch{console.warn(g.gray("Note: Could not register workspace in shared registry"));}}async function li(t,e=false){try{let i=process.env.XDG_CONFIG_HOME||process.env.APPDATA||v.join(z__default.homedir(),".config"),o=process.platform==="win32"?v.join(i,"rapidkit"):v.join(z__default.homedir(),".rapidkit"),r=v.join(o,"workspaces.json"),n={workspaces:[]};try{let l=await promises.readFile(r,"utf8"),d=JSON.parse(l);d&&Array.isArray(d.workspaces)&&(n=d);}catch{e||console.log("\u26A0\uFE0F Workspace registry not found");return}let a=n.workspaces.find(l=>l.path===t);if(!a){e||console.log("\u26A0\uFE0F Workspace not registered in registry");return}Array.isArray(a.projects)||(a.projects=[]);let s=await promises.readdir(t,{withFileTypes:!0}),c=0,p=0;for(let l of s)if(l.isDirectory()&&!l.name.startsWith(".")){let d=v.join(t,l.name),m=v.join(d,".rapidkit","context.json"),y=v.join(d,".rapidkit","project.json");try{let f=!1;try{await promises.access(m),f=!0;}catch{await promises.access(y),f=!0;}f&&(a.projects.some(A=>A.path===d||A.name===l.name)?p++:(a.projects.push({name:l.name,path:d}),c++,e||console.log(`\u2714 Added: ${l.name}`)));}catch{}}c>0?(await promises.writeFile(r,JSON.stringify(n,null,2)),e||console.log(`
|
|
17
17
|
\u2705 Synced ${c} project(s) to registry`)):e||console.log(`
|
|
18
|
-
\u2705 All projects already registered (${
|
|
18
|
+
\u2705 All projects already registered (${p} found)`);}catch(i){e||console.error("\u274C Failed to sync projects:",i.message);}}async function di(t,e,i){try{let o=process.env.XDG_CONFIG_HOME||process.env.APPDATA||v.join(z__default.homedir(),".config"),r=process.platform==="win32"?v.join(o,"rapidkit"):v.join(z__default.homedir(),".rapidkit"),n=v.join(r,"workspaces.json");console.log(`[REGISTRY DEBUG] Registry file: ${n}`);let a={workspaces:[]};try{let p=await promises.readFile(n,"utf8"),l=JSON.parse(p);l&&Array.isArray(l.workspaces)&&(a=l),console.log(`[REGISTRY DEBUG] Registry loaded, ${a.workspaces.length} workspaces`);}catch{console.log("[REGISTRY DEBUG] Registry doesn't exist, returning");return}let s=a.workspaces.find(p=>p.path===t);if(!s){console.log("[REGISTRY DEBUG] Workspace not found in registry, returning");return}console.log(`[REGISTRY DEBUG] Workspace found: ${s.name}`),Array.isArray(s.projects)||(s.projects=[]),s.projects.some(p=>p.path===i||p.name===e)?console.log("[REGISTRY DEBUG] Project already exists in registry"):(console.log("[REGISTRY DEBUG] Adding project to registry"),s.projects.push({name:e,path:i}),await promises.writeFile(n,JSON.stringify(a,null,2)),console.log("[REGISTRY DEBUG] Registry updated successfully"));}catch(o){console.log(`[REGISTRY DEBUG] Error: ${o}`);}}async function ui(t,e){let i=wt("Creating RapidKit workspace...").start();try{await promises.mkdir(t,{recursive:!0}),await promises.mkdir(v.join(t,".rapidkit"),{recursive:!0});let o={workspace_name:e.name,author:e.author,rapidkit_version:U(),created_at:new Date().toISOString(),type:"workspace"};await promises.writeFile(v.join(t,".rapidkit","config.json"),JSON.stringify(o,null,2));let r=mi();await promises.writeFile(v.join(t,"rapidkit"),r),await promises.chmod(v.join(t,"rapidkit"),493);let n=gi(e.name);if(await promises.writeFile(v.join(t,"README.md"),n),await promises.writeFile(v.join(t,".gitignore"),`# RapidKit workspace
|
|
19
19
|
.env
|
|
20
20
|
.env.*
|
|
21
21
|
!.env.example
|
|
@@ -30,10 +30,10 @@ Thumbs.db
|
|
|
30
30
|
|
|
31
31
|
# Logs
|
|
32
32
|
*.log
|
|
33
|
-
`),await promises.writeFile(v.join(t,".rapidkit-workspace"),JSON.stringify({signature:"RAPIDKIT_WORKSPACE",createdBy:"rapidkit-npm",version:
|
|
34
|
-
${
|
|
33
|
+
`),await promises.writeFile(v.join(t,".rapidkit-workspace"),JSON.stringify({signature:"RAPIDKIT_WORKSPACE",createdBy:"rapidkit-npm",version:U(),createdAt:new Date().toISOString(),name:e.name},null,2)),await fi(t),i.succeed("Workspace created!"),!e.skipGit){let s=wt("Initializing git repository...").start();try{await execa("git",["init"],{cwd:t}),await execa("git",["add","."],{cwd:t}),await execa("git",["commit","-m","Initial commit: RapidKit workspace"],{cwd:t}),s.succeed("Git repository initialized");}catch{s.warn("Could not initialize git repository");}}await ke(t,e.name),console.log(`
|
|
34
|
+
${g.green("\u2728 RapidKit workspace created successfully!")}
|
|
35
35
|
|
|
36
|
-
${
|
|
36
|
+
${g.bold("\u{1F4C2} Workspace structure:")}
|
|
37
37
|
${t}/
|
|
38
38
|
\u251C\u2500\u2500 rapidkit # Local CLI wrapper
|
|
39
39
|
\u251C\u2500\u2500 .rapidkit/ # Workspace configuration
|
|
@@ -41,26 +41,26 @@ ${t}/
|
|
|
41
41
|
\u2502 \u2514\u2500\u2500 templates/ # Project templates
|
|
42
42
|
\u2514\u2500\u2500 README.md
|
|
43
43
|
|
|
44
|
-
${
|
|
45
|
-
${
|
|
46
|
-
${
|
|
47
|
-
${
|
|
48
|
-
${
|
|
49
|
-
${
|
|
44
|
+
${g.bold("\u{1F680} Get started:")}
|
|
45
|
+
${g.cyan(`cd ${e.name}`)}
|
|
46
|
+
${g.cyan("npx rapidkit my-api --template fastapi")}
|
|
47
|
+
${g.cyan("cd my-api")}
|
|
48
|
+
${g.cyan("npx rapidkit init")}
|
|
49
|
+
${g.cyan("npx rapidkit dev")}
|
|
50
50
|
|
|
51
|
-
${
|
|
51
|
+
${g.bold("\u{1F4E6} Available templates:")}
|
|
52
52
|
fastapi - FastAPI + Python (default)
|
|
53
53
|
nestjs - NestJS + TypeScript
|
|
54
54
|
|
|
55
|
-
${
|
|
55
|
+
${g.bold("\u{1F4DA} Commands:")}
|
|
56
56
|
npx rapidkit <name> --template <type> Create a new project
|
|
57
57
|
npx rapidkit init Install dependencies
|
|
58
58
|
npx rapidkit dev Start dev server
|
|
59
59
|
npx rapidkit help Show all commands
|
|
60
60
|
|
|
61
|
-
${
|
|
62
|
-
${
|
|
63
|
-
`);}catch(
|
|
61
|
+
${g.gray("Alternative: ./rapidkit dev, make dev")}
|
|
62
|
+
${g.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
|
|
63
|
+
`);}catch(o){throw i.fail("Failed to create workspace"),o}}function mi(){return `#!/usr/bin/env bash
|
|
64
64
|
#
|
|
65
65
|
# RapidKit CLI - Local workspace commands
|
|
66
66
|
# This script provides rapidkit commands within the workspace
|
|
@@ -396,7 +396,7 @@ main() {
|
|
|
396
396
|
print_help
|
|
397
397
|
;;
|
|
398
398
|
version|-v|--version)
|
|
399
|
-
echo "RapidKit CLI (npm workspace) v${
|
|
399
|
+
echo "RapidKit CLI (npm workspace) v${U()}"
|
|
400
400
|
;;
|
|
401
401
|
*)
|
|
402
402
|
echo -e "\${RED}\u274C Unknown command: $cmd\${NC}"
|
|
@@ -408,7 +408,7 @@ main() {
|
|
|
408
408
|
}
|
|
409
409
|
|
|
410
410
|
main "$@"
|
|
411
|
-
`}function
|
|
411
|
+
`}function gi(t){return `# ${t}
|
|
412
412
|
|
|
413
413
|
RapidKit workspace for building API projects.
|
|
414
414
|
|
|
@@ -456,7 +456,7 @@ npx rapidkit dev # Start dev server
|
|
|
456
456
|
|
|
457
457
|
- [RapidKit Documentation](https://rapidkit.dev)
|
|
458
458
|
- [GitHub Repository](https://github.com/Baziar/rapidkit)
|
|
459
|
-
`}async function
|
|
459
|
+
`}async function fi(t){let{fileURLToPath:e}=await import('url'),i=e(import.meta.url),o=v.dirname(i),r=v.resolve(o,".."),n=v.join(r,"templates","kits"),a=v.join(t,".rapidkit","templates"),{default:s}=await import('fs-extra');await s.copy(n,a);let c=v.join(r,"templates","generator.js"),p=v.join(t,".rapidkit","generator.js");await s.copy(c,p);}async function hi(t,e){let i=e.template==="fastapi",o=i?"FastAPI":"NestJS",r=wt(`Creating ${o} project...`).start();try{let{fileURLToPath:n}=await import('url'),a=n(import.meta.url),s=v.dirname(a),c=v.resolve(s,".."),p=i?"fastapi-standard":"nestjs-standard",l=v.join(c,"templates","kits",p);await promises.mkdir(t,{recursive:!0});let d={project_name:i?e.name.replace(/-/g,"_").toLowerCase():e.name.replace(/_/g,"-").toLowerCase(),author:e.author,description:e.description||`${o} application generated with RapidKit`,app_version:"0.1.0",license:"MIT",package_manager:e.package_manager||"npm",created_at:new Date().toISOString(),rapidkit_version:U()};await ve(l,t,d);let m=i?`# Python
|
|
460
460
|
__pycache__/
|
|
461
461
|
*.py[cod]
|
|
462
462
|
*$py.class
|
|
@@ -524,10 +524,10 @@ Thumbs.db
|
|
|
524
524
|
|
|
525
525
|
# Coverage
|
|
526
526
|
coverage/
|
|
527
|
-
`;if(await promises.writeFile(v.join(t,".gitignore"),
|
|
528
|
-
${
|
|
527
|
+
`;if(await promises.writeFile(v.join(t,".gitignore"),m),r.succeed(`${o} project created!`),!e.skipGit){let f=wt("Initializing git repository...").start();try{await execa("git",["init"],{cwd:t}),await execa("git",["add","."],{cwd:t}),await execa("git",["commit","-m",`Initial commit: ${o} project via RapidKit`],{cwd:t}),f.succeed("Git repository initialized");}catch{f.warn("Could not initialize git repository");}}if(!e.skipInstall&&!i){let f=e.package_manager||"npm",w=wt(`Installing dependencies with ${f}...`).start();try{await execa(f,["install"],{cwd:t}),w.succeed("Dependencies installed");}catch{w.warn(`Could not install dependencies. Run '${f} install' manually.`);}}let y=v.basename(t);console.log(i?`
|
|
528
|
+
${g.green("\u2728 FastAPI project created successfully!")}
|
|
529
529
|
|
|
530
|
-
${
|
|
530
|
+
${g.bold("\u{1F4C2} Project structure:")}
|
|
531
531
|
${t}/
|
|
532
532
|
\u251C\u2500\u2500 .rapidkit/ # RapidKit CLI module
|
|
533
533
|
\u251C\u2500\u2500 src/
|
|
@@ -539,12 +539,12 @@ ${t}/
|
|
|
539
539
|
\u251C\u2500\u2500 pyproject.toml # Poetry configuration
|
|
540
540
|
\u2514\u2500\u2500 README.md
|
|
541
541
|
|
|
542
|
-
${
|
|
543
|
-
${
|
|
544
|
-
${
|
|
545
|
-
${
|
|
542
|
+
${g.bold("\u{1F680} Get started:")}
|
|
543
|
+
${g.cyan(`cd ${y}`)}
|
|
544
|
+
${g.cyan("npx rapidkit init")} ${g.gray("# Install dependencies")}
|
|
545
|
+
${g.cyan("npx rapidkit dev")} ${g.gray("# Start dev server")}
|
|
546
546
|
|
|
547
|
-
${
|
|
547
|
+
${g.bold("\u{1F4DA} Available commands:")}
|
|
548
548
|
npx rapidkit init # Install dependencies (poetry install)
|
|
549
549
|
npx rapidkit dev # Start dev server with hot reload
|
|
550
550
|
npx rapidkit start # Start production server
|
|
@@ -552,12 +552,12 @@ ${m.bold("\u{1F4DA} Available commands:")}
|
|
|
552
552
|
npx rapidkit lint # Lint code
|
|
553
553
|
npx rapidkit format # Format code
|
|
554
554
|
|
|
555
|
-
${
|
|
556
|
-
${
|
|
555
|
+
${g.gray("Alternative: make dev, ./rapidkit dev, poetry run dev")}
|
|
556
|
+
${g.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
|
|
557
557
|
`:`
|
|
558
|
-
${
|
|
558
|
+
${g.green("\u2728 NestJS project created successfully!")}
|
|
559
559
|
|
|
560
|
-
${
|
|
560
|
+
${g.bold("\u{1F4C2} Project structure:")}
|
|
561
561
|
${t}/
|
|
562
562
|
\u251C\u2500\u2500 .rapidkit/ # RapidKit CLI module
|
|
563
563
|
\u251C\u2500\u2500 src/
|
|
@@ -569,13 +569,13 @@ ${t}/
|
|
|
569
569
|
\u251C\u2500\u2500 package.json # Dependencies
|
|
570
570
|
\u2514\u2500\u2500 README.md
|
|
571
571
|
|
|
572
|
-
${
|
|
573
|
-
${
|
|
574
|
-
${e.skipInstall?
|
|
575
|
-
`:""}${
|
|
576
|
-
${
|
|
572
|
+
${g.bold("\u{1F680} Get started:")}
|
|
573
|
+
${g.cyan(`cd ${y}`)}
|
|
574
|
+
${e.skipInstall?g.cyan("npx rapidkit init")+g.gray(" # npm install")+`
|
|
575
|
+
`:""}${g.cyan("cp .env.example .env")}
|
|
576
|
+
${g.cyan("npx rapidkit dev")} ${g.gray("# Start dev server")}
|
|
577
577
|
|
|
578
|
-
${
|
|
578
|
+
${g.bold("\u{1F4DA} Available commands:")}
|
|
579
579
|
npx rapidkit init # Install dependencies
|
|
580
580
|
npx rapidkit dev # Start dev server with hot reload
|
|
581
581
|
npx rapidkit start # Start production server
|
|
@@ -584,43 +584,43 @@ ${m.bold("\u{1F4DA} Available commands:")}
|
|
|
584
584
|
npx rapidkit lint # Lint code
|
|
585
585
|
npx rapidkit format # Format code
|
|
586
586
|
|
|
587
|
-
${
|
|
587
|
+
${g.bold("\u{1F310} API endpoints:")}
|
|
588
588
|
http://localhost:8000/health # Health check
|
|
589
589
|
http://localhost:8000/docs # Swagger docs
|
|
590
590
|
http://localhost:8000/examples/notes # Example API
|
|
591
591
|
|
|
592
|
-
${
|
|
593
|
-
`);}catch(
|
|
592
|
+
${g.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
|
|
593
|
+
`);}catch(n){throw r.fail(`Failed to create ${o} project`),n}}async function ve(t,e,i){let o=await promises.readdir(t,{withFileTypes:true});for(let r of o){let n=v.join(t,r.name),a=r.name.replace(/\.j2$/,""),s=v.join(e,a);if(r.isDirectory())await promises.mkdir(s,{recursive:true}),await ve(n,s,i);else {let c=await promises.readFile(n,"utf-8");r.name.endsWith(".j2")&&(c=yi(c,i)),await promises.writeFile(s,c),(a==="rapidkit"||a==="activate"||a.endsWith(".py")&&s.includes(".rapidkit"))&&await promises.chmod(s,493);}}}function yi(t,e){let i=t;for(let[o,r]of Object.entries(e)){let n=new RegExp(`\\{\\{\\s*${o}\\s*\\}\\}`,"g");i=i.replace(n,String(r));let a=new RegExp(`\\{\\{\\s*${o}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\}\\}`,"g");i=i.replace(a,(p,l,d)=>String(r).replace(new RegExp(l,"g"),d));let s=new RegExp(`\\{\\{\\s*${o}\\s*\\|\\s*lower\\s*\\}\\}`,"g");i=i.replace(s,String(r).toLowerCase());let c=new RegExp(`\\{\\{\\s*${o}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\|\\s*lower\\s*\\}\\}`,"g");i=i.replace(c,(p,l,d)=>String(r).replace(new RegExp(l,"g"),d).toLowerCase());}return i}async function wi(){let t=process.env.XDG_CONFIG_HOME||process.env.APPDATA||v.join(z__default.homedir(),".config"),e=process.platform==="win32"?v.join(t,"rapidkit"):v.join(z__default.homedir(),".rapidkit"),i=v.join(e,"workspaces.json");if(!await promises.stat(i).catch(()=>null)){console.log(g.yellow(`
|
|
594
594
|
\u26A0\uFE0F No workspaces registered yet.
|
|
595
|
-
`)),console.log(
|
|
596
|
-
`));return}try{let
|
|
595
|
+
`)),console.log(g.gray(`Create a workspace with: npx rapidkit <workspace-name>
|
|
596
|
+
`));return}try{let o=await promises.readFile(i,"utf8"),r=JSON.parse(o);if(!r.workspaces||r.workspaces.length===0){console.log(g.yellow(`
|
|
597
597
|
\u26A0\uFE0F No workspaces registered yet.
|
|
598
|
-
`));return}console.log(
|
|
598
|
+
`));return}console.log(g.bold(`
|
|
599
599
|
\u{1F4E6} Registered RapidKit Workspaces:
|
|
600
|
-
`));for(let
|
|
601
|
-
`));}catch(
|
|
602
|
-
\u274C Failed to read workspace registry`)),console.error(
|
|
600
|
+
`));for(let n of r.workspaces)console.log(g.cyan(` ${n.name}`)),console.log(g.gray(` Path: ${n.path}`)),console.log(g.gray(` Projects: ${n.projects?.length||0}`)),await promises.stat(n.path).catch(()=>null)||console.log(g.red(" \u26A0\uFE0F Path not found")),console.log();console.log(g.gray(`Total: ${r.workspaces.length} workspace(s)
|
|
601
|
+
`));}catch(o){console.error(g.red(`
|
|
602
|
+
\u274C Failed to read workspace registry`)),console.error(g.gray(String(o)));}}var X=at(()=>{$();gt();});$();st();gt();$();st();var Je=".rapidkitrc.json",Ye=["rapidkit.config.js","rapidkit.config.mjs","rapidkit.config.cjs"];async function ft(){let t=v.join(z__default.homedir(),Je);try{let e=await promises.readFile(t,"utf-8"),i=JSON.parse(e);return u.debug(`Loaded config from ${t}`),i}catch{return u.debug("No user config found, using defaults"),{}}}async function ie(t=process.cwd()){let e=t,i=v.parse(e).root;for(;e!==i;){for(let o of Ye){let r=v.join(e,o);try{await promises.access(r),u.debug(`Found config file: ${r}`);let a=await import(pathToFileURL(r).href),s=a.default||a;return u.debug(`Loaded RapidKit config from ${o}`),s}catch{continue}}e=v.dirname(e);}return u.debug("No RapidKit config file found, using defaults"),{}}function oe(t,e,i){return {author:i.author||e.workspace?.defaultAuthor||t.author,pythonVersion:e.workspace?.pythonVersion||t.pythonVersion,defaultInstallMethod:i.defaultInstallMethod||e.workspace?.installMethod||t.defaultInstallMethod,defaultKit:i.defaultKit||e.projects?.defaultKit||t.defaultKit,skipGit:i.skipGit??e.projects?.skipGit??t.skipGit,license:i.license||t.license,testRapidKitPath:i.testRapidKitPath||t.testRapidKitPath}}function xt(t){return process.env.RAPIDKIT_DEV_PATH||t.testRapidKitPath||void 0}$();$();var G=class extends Error{constructor(i,o,r){super(i);this.code=o;this.details=r;this.name="RapidKitError",Error.captureStackTrace(this,this.constructor);}},ct=class extends G{constructor(e,i){let o=i?`Python ${e}+ required, found ${i}`:`Python ${e}+ not found`;super(o,"PYTHON_NOT_FOUND","Please install Python from https://www.python.org/downloads/");}},ht=class extends G{constructor(){super("Poetry is not installed","POETRY_NOT_FOUND","Install Poetry from https://python-poetry.org/docs/#installation");}},yt=class extends G{constructor(){super("pipx is not installed","PIPX_NOT_FOUND","Install pipx from https://pypa.github.io/pipx/installation/");}},jt=class extends G{constructor(e){super(`Directory "${e}" already exists`,"DIRECTORY_EXISTS","Please choose a different name or remove the existing directory");}},Y=class extends G{constructor(e,i){super(`Invalid project name: "${e}"`,"INVALID_PROJECT_NAME",i);}},F=class extends G{constructor(e,i){let o=`Installation failed at: ${e}`,r=`${i.message}
|
|
603
603
|
|
|
604
604
|
Troubleshooting:
|
|
605
605
|
- Check your internet connection
|
|
606
606
|
- Verify Python/Poetry installation
|
|
607
|
-
- Try running with --debug flag for more details`;super(
|
|
607
|
+
- Try running with --debug flag for more details`;super(o,"INSTALLATION_ERROR",r);}},pt=class extends G{constructor(){super("RapidKit Python package is not yet available on PyPI","RAPIDKIT_NOT_AVAILABLE",`Available options:
|
|
608
608
|
1. Install Python 3.10+ and retry the same command
|
|
609
609
|
2. Use the core workflow: npx rapidkit create workspace <name>
|
|
610
610
|
3. Offline fallback (limited): npx rapidkit create project fastapi.standard <name> --output .
|
|
611
611
|
|
|
612
|
-
Legacy: set RAPIDKIT_SHOW_LEGACY=1 to reveal template-mode flags in help.`);}};function
|
|
612
|
+
Legacy: set RAPIDKIT_SHOW_LEGACY=1 to reveal template-mode flags in help.`);}};function re(t){let e=ze(t);if(!e.validForNewPackages){let o=e.errors||[],r=e.warnings||[],n=[...o,...r];throw new Y(t,`NPM validation failed: ${n.join(", ")}`)}if(!/^[a-z][a-z0-9_-]*$/.test(t))throw new Y(t,"Must start with a lowercase letter and contain only lowercase letters, numbers, hyphens, and underscores");if(["test","tests","src","dist","build","lib","python","pip","poetry","node","npm","rapidkit","rapidkit"].includes(t.toLowerCase()))throw new Y(t,`"${t}" is a reserved name. Please choose a different name.`);if(t.length<2)throw new Y(t,"Name must be at least 2 characters long");if(t.length>214)throw new Y(t,"Name must be less than 214 characters");return true}$();function Xe(t){return typeof t=="object"&&t!==null}async function Qe(t,e,i,o=8e3){try{let r=await execa(t,e,{cwd:i,timeout:o,reject:!1,stdio:"pipe"});return {ok:r.exitCode===0,exitCode:r.exitCode,stdout:r.stdout,stderr:r.stderr}}catch(r){return {ok:false,exitCode:void 0,stdout:"",stderr:r instanceof Error?r.message:String(r)}}}async function Ze(t,e){let i=["-m","rapidkit",...t],o=["python3","python"];for(let r of o){let n=await Qe(r,i,e?.cwd,e?.timeoutMs);if(!n.ok)continue;let a=(n.stdout??"").trim();try{let s=JSON.parse(a);return Xe(s)?{ok:!0,command:r,exitCode:n.exitCode,stdout:n.stdout,stderr:n.stderr,data:s}:{ok:!1,command:r,exitCode:n.exitCode,stdout:n.stdout,stderr:n.stderr}}catch{return {ok:false,command:r,exitCode:n.exitCode,stdout:n.stdout,stderr:n.stderr}}}return {ok:false}}async function ne(t,e){let i=await Ze(["project","detect","--path",t,"--json"],e);return !i.ok||!i.data||i.data.schema_version!==1?{ok:false,command:i.command,exitCode:i.exitCode,stdout:i.stdout,stderr:i.stderr}:i}$t();$();var si=["version","project","create","init","dev","start","build","test","lint","format","add","list","info","upgrade","diff","doctor","license","reconcile","rollback","uninstall","checkpoint","optimize","snapshot","frameworks","modules","merge"],he=new Set(si);$();st();gt();$();function Rt(){return process.platform==="win32"?"python":"python3"}Bt();async function be(t,e,i,o){let r=Ut(e,U(),i);o&&(r.metadata||(r.metadata={}),r.metadata.python={version:o}),await Pt(t,r);}async function $e(t){await I.outputFile(v.join(t,".gitignore"),`.venv/
|
|
613
613
|
__pycache__/
|
|
614
614
|
*.pyc
|
|
615
615
|
.env
|
|
616
616
|
.rapidkit-workspace/
|
|
617
617
|
|
|
618
|
-
`,"utf-8");}async function
|
|
619
|
-
`,"utf-8"),
|
|
618
|
+
`,"utf-8");}async function xe(t){try{let{stdout:e}=await execa(t,["--version"],{timeout:3e3}),i=e.match(/Python (\d+\.\d+\.\d+)/);if(i)return i[1]}catch{}return null}async function ki(t,e){try{await promises.writeFile(v.join(t,".python-version"),`${e}
|
|
619
|
+
`,"utf-8"),u.debug(`Created .python-version with ${e}`);}catch(i){u.warn(`Failed to create .python-version: ${i}`);}}function kt(){let t=v.join(z.homedir(),".local","bin"),i=(process.env.PATH||"").split(v.delimiter).filter(Boolean);i.includes(t)||(process.env.PATH=[t,...i].join(v.delimiter));}async function Ct(t,e){kt(),t.start("Checking pipx installation");try{return await execa("pipx",["--version"]),t.succeed("pipx found"),{kind:"binary"}}catch{}let i=Rt();try{return await execa(i,["-m","pipx","--version"]),t.succeed("pipx found"),{kind:"python-module",pythonCmd:i}}catch{}if(e)throw new yt;let{installPipx:o}=await Jt.prompt([{type:"confirm",name:"installPipx",message:"pipx is not installed. Install it now (user install via python -m pip)?",default:true}]);if(!o)throw new yt;t.start("Installing pipx (user install)");try{try{await execa(i,["-m","pip","install","--user","--upgrade","pip"]);}catch{}await execa(i,["-m","pip","install","--user","--upgrade","pipx"]);}catch(r){let n=r,a=String(n?.stderr||n?.shortMessage||n?.message||"");throw new F("Install pipx with python -m pip",r instanceof Error?r:new Error(a))}t.succeed("pipx installed"),kt();try{return await execa(i,["-m","pipx","--version"]),{kind:"python-module",pythonCmd:i}}catch(r){let n=r,a=String(n?.stderr||n?.shortMessage||n?.message||"pipx not runnable after install");throw new F("Verify pipx after install",new Error(`${a}
|
|
620
620
|
|
|
621
|
-
Try reopening your terminal or run: python3 -m pipx ensurepath`))}}async function
|
|
621
|
+
Try reopening your terminal or run: python3 -m pipx ensurepath`))}}async function mt(t,e){return t.kind==="binary"?execa("pipx",e):execa(t.pythonCmd,["-m","pipx",...e])}async function vi(t,e){kt(),t.start("Checking Poetry installation");try{await execa("poetry",["--version"]),t.succeed("Poetry found");return}catch{}if(e)throw new ht;let{installPoetry:i}=await Jt.prompt([{type:"confirm",name:"installPoetry",message:"Poetry is not installed. Install it now using pipx?",default:true}]);if(!i)throw new ht;let o=await Ct(t,e);t.start("Installing Poetry with pipx");try{await mt(o,["install","poetry"]);}catch(r){let n=r,a=String(n?.stderr||n?.shortMessage||n?.message||"");if(/already\s+installed|already\s+seems\s+to\s+be\s+installed|exists/i.test(a))try{await mt(o,["upgrade","poetry"]);}catch{}else throw new F("Install Poetry with pipx",r instanceof Error?r:new Error(a))}t.succeed("Poetry installed"),kt();try{await execa("poetry",["--version"]);}catch(r){let n=r,a=String(n?.stderr||n?.shortMessage||n?.message||"Poetry not found on PATH");throw new F("Verify Poetry after pipx install",new Error(`${a}
|
|
622
622
|
|
|
623
|
-
Poetry may be installed but not on PATH yet. Try reopening your terminal or run: pipx ensurepath`))}}function
|
|
623
|
+
Poetry may be installed but not on PATH yet. Try reopening your terminal or run: pipx ensurepath`))}}function xi(t){let e=t==="poetry";return `#!/usr/bin/env sh
|
|
624
624
|
set -eu
|
|
625
625
|
|
|
626
626
|
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
@@ -639,7 +639,7 @@ echo "- If you used venv: ensure .venv exists (or re-run the installer)." 1>&2
|
|
|
639
639
|
${e?`echo "- If you used Poetry: run 'poetry install' and retry, or activate the env." 1>&2
|
|
640
640
|
`:""}echo "Tip: you can also run: ./.venv/bin/rapidkit --help" 1>&2
|
|
641
641
|
exit 1
|
|
642
|
-
`}function
|
|
642
|
+
`}function ji(t){return `@echo off
|
|
643
643
|
setlocal
|
|
644
644
|
|
|
645
645
|
set "SCRIPT_DIR=%~dp0"
|
|
@@ -658,42 +658,42 @@ if %ERRORLEVEL%==0 if exist "%SCRIPT_DIR%\\pyproject.toml" (
|
|
|
658
658
|
`:""}echo RapidKit launcher could not find a local Python CLI. 1>&2
|
|
659
659
|
echo Tip: run .venv\\Scripts\\rapidkit.exe --help 1>&2
|
|
660
660
|
exit /b 1
|
|
661
|
-
`}async function
|
|
661
|
+
`}async function Re(t,e){await I.outputFile(v.join(t,"rapidkit"),xi(e),{encoding:"utf-8",mode:493}),await I.outputFile(v.join(t,"rapidkit.cmd"),ji(e),"utf-8");}async function Pe(t,e){let{skipGit:i=false,testMode:o=false,demoMode:r=false,dryRun:n=false,yes:a=false,userConfig:s={},installMethod:c}=e,p=t||"rapidkit",l=v.resolve(process.cwd(),p);if(await I.pathExists(l))throw new jt(p);if(n){await $i(l,p,r,s);return}if(r){await bi(l,p,i);return}let d=a?{pythonVersion:s.pythonVersion||"3.10",installMethod:c||s.defaultInstallMethod||"poetry"}:await Jt.prompt([{type:"list",name:"pythonVersion",message:"Select Python version for RapidKit:",choices:["3.10","3.11","3.12"],default:s.pythonVersion||"3.10"},{type:"list",name:"installMethod",message:"How would you like to install RapidKit?",choices:[{name:"\u{1F3AF} Poetry (Recommended - includes virtual env)",value:"poetry"},{name:"\u{1F4E6} pip with venv (Standard)",value:"venv"},{name:"\u{1F527} pipx (Global isolated install)",value:"pipx"}],default:s.defaultInstallMethod||"poetry"}]);u.step(1,3,"Setting up RapidKit environment");let m=wt("Creating directory").start();try{await I.ensureDir(l),m.succeed("Directory created"),m.start("Detecting Python version");let y=null,f=await Ce(d.pythonVersion);if(f)y=await xe(f),y?(u.info(`Detected Python ${y}`),m.succeed(`Python ${y} detected`)):m.warn("Could not detect exact Python version");else {let w=Rt();y=await xe(w),y?m.succeed(`Python ${y} detected`):m.warn("Could not detect Python version, proceeding with defaults");}if(await be(l,p,d.installMethod,y||void 0),y&&await ki(l,y),await $e(l),d.installMethod==="poetry")try{await _e(l,d.pythonVersion,m,o,s,a);}catch(w){let A=w?.details||w?.message||String(w);if(A.includes("pyenv")||A.includes("exit status 127")||A.includes("returned non-zero exit status 127")){m.warn("Poetry encountered Python discovery issues, trying venv method"),u.debug(`Poetry error (attempting venv fallback): ${A}`);try{await Ht(l,d.pythonVersion,m,o,s),d.installMethod="venv";}catch(K){throw K}}else throw w}else d.installMethod==="venv"?await Ht(l,d.pythonVersion,m,o,s):await Ee(l,m,o,s,a);if(await Re(l,d.installMethod),await Ie(l,d.installMethod),m.succeed("RapidKit environment ready!"),!e.skipGit){m.start("Initializing git repository");try{await execa("git",["init"],{cwd:l}),await execa("git",["add","."],{cwd:l}),await execa("git",["commit","-m","Initial commit: RapidKit environment"],{cwd:l}),m.succeed("Git repository initialized");}catch{m.warn("Could not initialize git repository");}}try{let{registerWorkspace:w}=await Promise.resolve().then(()=>(X(),q));await w(l,p);}catch{console.warn(g.gray("Note: Could not register workspace in shared registry"));}if(console.log(g.green(`
|
|
662
662
|
\u2728 RapidKit environment created successfully!
|
|
663
|
-
`)),console.log(
|
|
664
|
-
`)),console.log(
|
|
665
|
-
\u{1F4A1} For more information, check the README.md file.`)),console.log(
|
|
666
|
-
\u{1F4DA} RapidKit commands:`)),console.log(
|
|
667
|
-
`));}catch(
|
|
668
|
-
\u274C Error:`),
|
|
669
|
-
package-mode = false`):
|
|
663
|
+
`)),console.log(g.cyan("\u{1F4C2} Location:"),g.white(l)),console.log(g.cyan(`\u{1F680} Get started:
|
|
664
|
+
`)),console.log(g.white(` cd ${p}`)),d.installMethod==="poetry"){let w="source $(poetry env info --path)/bin/activate";try{kt();let{stdout:A}=await execa("poetry",["--version"]),D=A.match(/Poetry.*?(\d+)\.(\d+)/);D&&(parseInt(D[1])>=2?w="source $(poetry env info --path)/bin/activate":w="poetry shell");}catch{}console.log(g.white(` ${w} # Or: poetry run rapidkit`)),console.log(g.white(" rapidkit create # Interactive mode")),console.log(g.white(" cd <project-name> && rapidkit init && rapidkit dev"));}else d.installMethod==="venv"?(console.log(g.white(" source .venv/bin/activate # On Windows: .venv\\Scripts\\activate")),console.log(g.white(" rapidkit create # Interactive mode")),console.log(g.white(" cd <project-name> && rapidkit init && rapidkit dev"))):(console.log(g.white(" rapidkit create # Interactive mode")),console.log(g.white(" cd <project-name> && rapidkit init && rapidkit dev")));console.log(g.white(`
|
|
665
|
+
\u{1F4A1} For more information, check the README.md file.`)),console.log(g.cyan(`
|
|
666
|
+
\u{1F4DA} RapidKit commands:`)),console.log(g.white(" rapidkit create - Create a new project (interactive)")),console.log(g.white(" rapidkit dev - Run development server")),console.log(g.white(" rapidkit add module <name> - Add a module (e.g., settings)")),console.log(g.white(" rapidkit list - List available kits")),console.log(g.white(" rapidkit modules - List available modules")),console.log(g.white(` rapidkit --help - Show all commands
|
|
667
|
+
`));}catch(y){m.fail("Failed to create RapidKit environment"),console.error(g.red(`
|
|
668
|
+
\u274C Error:`),y);try{await I.remove(l);}catch{}throw y}}async function Ce(t){let e=[];try{let{stdout:i}=await execa("pyenv",["root"]),o=i.trim();e.push(v.join(o,"versions",`${t}.*`,"bin","python"));let[r,n]=t.split(".");e.push(v.join(o,"versions",`${r}.${n}.*`,"bin","python"));}catch{}e.push(`python${t}`,`python3.${t.split(".")[1]}`,"python3","python"),e.push(`/usr/bin/python${t}`,"/usr/bin/python3",`/usr/local/bin/python${t}`,"/usr/local/bin/python3");for(let i of e)try{let o=i;if(i.includes("*")){if(o=(await execa("sh",["-c",`ls -d ${i} 2>/dev/null | head -1`])).stdout.trim(),!o)continue;o=v.join(o.split("/").slice(0,-1).join("/"),"../bin/python");}let{stdout:r}=await execa(o,["--version"],{timeout:2e3}),n=r.match(/Python (\d+\.\d+)/)?.[1];if(n&&parseFloat(n)>=parseFloat(t))return await execa(o,["-c","import sys; sys.exit(0)"],{timeout:2e3}),o}catch{continue}return null}async function _e(t,e,i,o,r,n=false){await vi(i,n),i.start("Finding Python interpreter");let a=await Ce(e);a?(u.debug(`Found working Python: ${a}`),i.succeed("Python found")):i.warn("Could not verify Python path, proceeding with default"),i.start("Initializing Poetry project"),await execa("poetry",["init","--no-interaction","--python",`^${e}`],{cwd:t}),i.succeed("Poetry project initialized");let s=v.join(t,"pyproject.toml"),p=await promises.readFile(s,"utf-8");p.includes("[tool.poetry]")?p=p.replace("[tool.poetry]",`[tool.poetry]
|
|
669
|
+
package-mode = false`):p.includes("[project]")&&(p.includes("[build-system]")?p=p.replace("[build-system]",`
|
|
670
670
|
[tool.poetry]
|
|
671
671
|
package-mode = false
|
|
672
672
|
|
|
673
|
-
[build-system]`):
|
|
673
|
+
[build-system]`):p+=`
|
|
674
674
|
|
|
675
675
|
[tool.poetry]
|
|
676
676
|
package-mode = false
|
|
677
|
-
`),await promises.writeFile(s,
|
|
678
|
-
Error: ${
|
|
677
|
+
`),await promises.writeFile(s,p,"utf-8"),i.start("Configuring Poetry");try{if(await execa("poetry",["config","virtualenvs.in-project","true","--local"],{cwd:t}),a)try{await execa("poetry",["env","use",a],{cwd:t}),u.debug(`Poetry configured to use: ${a}`);}catch(l){u.debug(`Could not set Poetry env to ${a}: ${l}`);}i.succeed("Poetry configured");}catch{i.warn("Could not configure Poetry virtualenvs.in-project");}i.start("Creating virtualenv");try{await execa("poetry",["install","--no-root"],{cwd:t,timeout:3e4}),i.succeed("Virtualenv created");}catch(l){u.debug(`Failed to create virtualenv: ${l}`),i.warn("Could not create virtualenv, proceeding with add command");}if(i.start("Installing RapidKit"),o){let l=xt(r||{});if(!l)throw new F("Test mode installation",new Error("No local RapidKit path configured. Set RAPIDKIT_DEV_PATH environment variable."));u.debug(`Installing from local path: ${l}`),i.text="Installing RapidKit from local path (test mode)",await execa("poetry",["add",l],{cwd:t});}else {i.text="Installing RapidKit from PyPI";let l=false,d=null;for(let m=1;m<=3;m++)try{await execa("poetry",["add","rapidkit-core"],{cwd:t,timeout:6e4*m}),l=!0;break}catch(y){d=y,u.debug(`Poetry add attempt ${m} failed: ${y}`),m<3&&(i.text=`Retrying installation (attempt ${m+1}/3)`,await new Promise(f=>setTimeout(f,2e3)));}if(!l){let m=d?.stderr||d?.message||"Unknown error";throw u.debug(`All Poetry install attempts failed. Last error: ${m}`),m.includes("Could not find")||m.includes("No matching distribution")?new pt:new F("Install rapidkit-core with Poetry",new Error(`Failed to install rapidkit-core after 3 attempts.
|
|
678
|
+
Error: ${m}
|
|
679
679
|
|
|
680
680
|
Possible solutions:
|
|
681
681
|
1. Check your internet connection
|
|
682
682
|
2. Try installing manually: cd ${v.basename(t)} && poetry add rapidkit-core
|
|
683
|
-
3. Use venv method instead: npx rapidkit ${v.basename(t)} --install-method=venv`))}}i.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:
|
|
683
|
+
3. Use venv method instead: npx rapidkit ${v.basename(t)} --install-method=venv`))}}i.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:l}=await Promise.resolve().then(()=>($t(),Gt));if(!await l()&&!o){i.start("Installing RapidKit globally with pipx for CLI access");let m=await Ct(i,n);try{await mt(m,["install","rapidkit-core"]),i.succeed("RapidKit installed globally");}catch(y){i.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),u.debug(`pipx install failed: ${y}`);}}}catch(l){u.debug(`Global install check skipped: ${l}`);}}async function Ht(t,e,i,o,r,n=false){i.start(`Checking Python ${e}`);let a=Rt();try{let{stdout:c}=await execa(a,["--version"]),p=c.match(/Python (\d+\.\d+)/)?.[1];if(p&&parseFloat(p)<parseFloat(e))throw new ct(e,p);i.succeed(`Python ${p} found`);}catch(c){throw c instanceof ct?c:new ct(e)}i.start("Creating virtual environment");try{await execa(a,["-m","venv",".venv"],{cwd:t}),i.succeed("Virtual environment created");}catch(c){if(i.fail("Failed to create virtual environment"),(l=>typeof l=="object"&&l!==null&&"stdout"in l&&typeof l.stdout=="string")(c)&&c.stdout.includes("ensurepip is not")){let l=c.stdout.match(/apt install (python[\d.]+-venv)/),d=l?l[1]:"python3-venv";throw new F("Python venv module not available",new Error(`Virtual environment creation failed.
|
|
684
684
|
|
|
685
685
|
On Debian/Ubuntu systems, install the venv package:
|
|
686
|
-
sudo apt install ${
|
|
686
|
+
sudo apt install ${d}
|
|
687
687
|
|
|
688
688
|
Or use Poetry instead (recommended):
|
|
689
|
-
npx rapidkit ${v.basename(t)} --yes`))}throw new
|
|
690
|
-
Error: ${
|
|
689
|
+
npx rapidkit ${v.basename(t)} --yes`))}throw new F("Virtual environment creation",c instanceof Error?c:new Error(String(c)))}i.start("Installing RapidKit");let s=v.join(t,".venv",process.platform==="win32"?"Scripts":"bin",process.platform==="win32"?"python.exe":"python");if(await execa(s,["-m","pip","install","--upgrade","pip"],{cwd:t}),o){let c=xt(r||{});if(!c)throw new F("Test mode installation",new Error("No local RapidKit path configured. Set RAPIDKIT_DEV_PATH environment variable."));u.debug(`Installing from local path: ${c}`),i.text="Installing RapidKit from local path (test mode)",await execa(s,["-m","pip","install","-e",c],{cwd:t});}else {i.text="Installing RapidKit from PyPI";let c=false,p=null;for(let l=1;l<=3;l++)try{await execa(s,["-m","pip","install","rapidkit-core"],{cwd:t,timeout:6e4*l}),c=!0;break}catch(d){p=d,u.debug(`pip install attempt ${l} failed: ${d}`),l<3&&(i.text=`Retrying installation (attempt ${l+1}/3)`,await new Promise(m=>setTimeout(m,2e3)));}if(!c){let l=p?.stderr||p?.message||"Unknown error";throw u.debug(`All pip install attempts failed. Last error: ${l}`),l.includes("Could not find")||l.includes("No matching distribution")?new pt:new F("Install rapidkit-core with pip",new Error(`Failed to install rapidkit-core after 3 attempts.
|
|
690
|
+
Error: ${l}
|
|
691
691
|
|
|
692
692
|
Possible solutions:
|
|
693
693
|
1. Check your internet connection
|
|
694
694
|
2. Try installing manually: cd ${v.basename(t)} && .venv/bin/python -m pip install rapidkit-core
|
|
695
|
-
3. Use Poetry instead: npx rapidkit ${v.basename(t)} --install-method=poetry`))}}i.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:c}=await Promise.resolve().then(()=>(
|
|
696
|
-
`,"utf-8");}async function
|
|
695
|
+
3. Use Poetry instead: npx rapidkit ${v.basename(t)} --install-method=poetry`))}}i.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:c}=await Promise.resolve().then(()=>($t(),Gt));if(!await c()&&!o){i.start("Installing RapidKit globally with pipx for CLI access");let l=await Ct(i,n);try{await mt(l,["install","rapidkit-core"]),i.succeed("RapidKit installed globally");}catch(d){i.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),u.debug(`pipx install failed: ${d}`);}}}catch(c){u.debug(`Global install check skipped: ${c}`);}}async function Ee(t,e,i,o,r=false){let n=await Ct(e,r);if(e.start("Installing RapidKit globally with pipx"),i){let a=xt(o||{});if(!a)throw new F("Test mode installation",new Error("No local RapidKit path configured. Set RAPIDKIT_DEV_PATH environment variable."));u.debug(`Installing from local path: ${a}`),e.text="Installing RapidKit from local path (test mode)",await mt(n,["install","-e",a]);}else {e.text="Installing RapidKit from PyPI";try{await mt(n,["install","rapidkit-core"]);}catch{throw new pt}}e.succeed("RapidKit installed globally"),await I.outputFile(v.join(t,".rapidkit-global"),`RapidKit installed globally with pipx
|
|
696
|
+
`,"utf-8");}async function rt(t,e){let{skipGit:i=false,testMode:o=false,userConfig:r={},yes:n=false,installMethod:a,pythonVersion:s="3.10"}=e||{},c=a||r.defaultInstallMethod||"poetry";await be(t,v.basename(t),c),await $e(t);let p=wt("Registering workspace").start();try{c==="poetry"?await _e(t,s,p,o,r,n):c==="venv"?await Ht(t,s,p,o,r):await Ee(t,p,o,r,n),await Re(t,c),await Ie(t,c),p.succeed("Workspace registered");try{let{registerWorkspace:l}=await Promise.resolve().then(()=>(X(),q));await l(t,v.basename(t));}catch{}if(!i){p.start("Initializing git repository");try{await execa("git",["init"],{cwd:t}),await execa("git",["add","."],{cwd:t}),await execa("git",["commit","-m","Initial commit: RapidKit workspace"],{cwd:t}),p.succeed("Git repository initialized");}catch{p.warn("Could not initialize git repository");}}}catch(l){throw p.fail("Failed to register workspace"),l}}async function Ie(t,e){let r=`# RapidKit Workspace
|
|
697
697
|
|
|
698
698
|
This directory contains a RapidKit development environment.
|
|
699
699
|
|
|
@@ -804,7 +804,7 @@ If you encounter issues:
|
|
|
804
804
|
2. Check RapidKit installation: \`rapidkit --version\`
|
|
805
805
|
3. Run diagnostics: \`rapidkit doctor\`
|
|
806
806
|
4. Visit RapidKit documentation or GitHub issues
|
|
807
|
-
`;await promises.writeFile(v.join(t,"README.md"),
|
|
807
|
+
`;await promises.writeFile(v.join(t,"README.md"),r,"utf-8");}async function bi(t,e,i){let o=wt("Creating demo workspace").start();try{await I.ensureDir(t),o.succeed("Directory created"),o.start("Setting up demo kit generator");let r=JSON.stringify({name:`${e}-workspace`,version:"1.0.0",private:!0,description:"RapidKit demo workspace",scripts:{generate:"node generate-demo.js"}},null,2);await promises.writeFile(v.join(t,"package.json"),r,"utf-8"),await promises.writeFile(v.join(t,"generate-demo.js"),`#!/usr/bin/env node
|
|
808
808
|
/**
|
|
809
809
|
* Demo Kit Generator - Create FastAPI demo projects
|
|
810
810
|
*
|
|
@@ -1287,7 +1287,7 @@ ${e}/
|
|
|
1287
1287
|
---
|
|
1288
1288
|
|
|
1289
1289
|
**Generated with RapidKit** | [GitHub](https://github.com/getrapidkit/rapidkit-npm)
|
|
1290
|
-
`;if(await promises.writeFile(v.join(t,"README.md"),a,"utf-8"),
|
|
1290
|
+
`;if(await promises.writeFile(v.join(t,"README.md"),a,"utf-8"),o.succeed("Demo workspace setup complete"),!i){o.start("Initializing git repository");try{await execa("git",["init"],{cwd:t}),await I.outputFile(v.join(t,".gitignore"),`# Dependencies
|
|
1291
1291
|
node_modules/
|
|
1292
1292
|
|
|
1293
1293
|
# Generated projects
|
|
@@ -1300,19 +1300,19 @@ __pycache__/
|
|
|
1300
1300
|
*.pyc
|
|
1301
1301
|
.venv/
|
|
1302
1302
|
.env
|
|
1303
|
-
`,"utf-8"),await execa("git",["add","."],{cwd:t}),await execa("git",["commit","-m","Initial commit: Demo workspace"],{cwd:t}),
|
|
1303
|
+
`,"utf-8"),await execa("git",["add","."],{cwd:t}),await execa("git",["commit","-m","Initial commit: Demo workspace"],{cwd:t}),o.succeed("Git repository initialized");}catch{o.warn("Could not initialize git repository");}}console.log(g.green(`
|
|
1304
1304
|
\u2728 Demo workspace created successfully!
|
|
1305
|
-
`)),console.log(
|
|
1306
|
-
`)),console.log(
|
|
1305
|
+
`)),console.log(g.cyan("\u{1F4C2} Location:"),g.white(t)),console.log(g.cyan(`\u{1F680} Get started:
|
|
1306
|
+
`)),console.log(g.white(` cd ${e}`)),console.log(g.white(" node generate-demo.js my-api")),console.log(g.white(" cd my-api")),console.log(g.white(" rapidkit init")),console.log(g.white(" rapidkit dev")),console.log(),console.log(g.yellow("\u{1F4A1} Note:"),"This is a demo workspace. For full RapidKit features:"),console.log(g.cyan(" pipx install rapidkit")),console.log();}catch(r){throw o.fail("Failed to create demo workspace"),r}}async function $i(t,e,i,o){console.log(g.cyan(`
|
|
1307
1307
|
\u{1F50D} Dry-run mode - showing what would be created:
|
|
1308
|
-
`)),console.log(
|
|
1309
|
-
\u{1F4DD} Files to create:`)),console.log(
|
|
1310
|
-
\u{1F3AF} Capabilities:`)),console.log(
|
|
1311
|
-
\u2699\uFE0F Configuration:`)),console.log(
|
|
1312
|
-
\u{1F4DD} Files to create:`)),console.log(
|
|
1313
|
-
\u{1F3AF} Next steps after creation:`)),console.log(
|
|
1308
|
+
`)),console.log(g.white("\u{1F4C2} Project path:"),t),console.log(g.white("\u{1F4E6} Project type:"),i?"Demo workspace":"Full RapidKit environment"),i?(console.log(g.white(`
|
|
1309
|
+
\u{1F4DD} Files to create:`)),console.log(g.gray(" - package.json")),console.log(g.gray(" - generate-demo.js (project generator)")),console.log(g.gray(" - README.md")),console.log(g.gray(" - .gitignore")),console.log(g.white(`
|
|
1310
|
+
\u{1F3AF} Capabilities:`)),console.log(g.gray(" - Generate multiple FastAPI demo projects")),console.log(g.gray(" - No Python RapidKit installation required")),console.log(g.gray(" - Bundled templates included"))):(console.log(g.white(`
|
|
1311
|
+
\u2699\uFE0F Configuration:`)),console.log(g.gray(` - Python version: ${o.pythonVersion||"3.10"}`)),console.log(g.gray(` - Install method: ${o.defaultInstallMethod||"poetry"}`)),console.log(g.gray(` - Git initialization: ${o.skipGit?"No":"Yes"}`)),console.log(g.white(`
|
|
1312
|
+
\u{1F4DD} Files to create:`)),console.log(g.gray(" - pyproject.toml (Poetry) or .venv/ (venv)")),console.log(g.gray(" - README.md")),console.log(g.gray(" - .gitignore")),console.log(g.white(`
|
|
1313
|
+
\u{1F3AF} Next steps after creation:`)),console.log(g.gray(" 1. Install RapidKit Python package")),console.log(g.gray(" 2. Create projects with rapidkit CLI")),console.log(g.gray(" 3. Add modules and customize"))),console.log(g.white(`
|
|
1314
1314
|
\u{1F4A1} To proceed with actual creation, run without --dry-run flag
|
|
1315
|
-
`));}$();
|
|
1315
|
+
`));}$();gt();var _i=fileURLToPath(import.meta.url),Ei=v.dirname(_i);function Ii(t=32){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=Ci.randomBytes(t),o="";for(let r=0;r<t;r++)o+=e[i[r]%e.length];return o}async function Se(t,e){let o=(e.template||"fastapi")==="fastapi",r=o?"FastAPI":"NestJS",n=wt(`Generating ${r} project...`).start();try{let a=v.resolve(Ei,".."),s=o?"fastapi-standard":"nestjs-standard",c=v.join(a,"templates","kits",s),p=Ri.configure(c,{autoescape:!1,trimBlocks:!0,lstripBlocks:!0});p.addFilter("generate_secret",function(f,w=32){return Ii(w)});let l={project_name:e.project_name,author:e.author||"RapidKit User",description:e.description||(o?"FastAPI service generated with RapidKit":"NestJS application generated with RapidKit"),app_version:e.app_version||"0.1.0",license:e.license||"MIT",package_manager:e.package_manager||"npm",created_at:new Date().toISOString(),rapidkit_version:U()},d;o?d=["src/main.py.j2","src/__init__.py.j2","src/cli.py.j2","src/routing/__init__.py.j2","src/routing/health.py.j2","src/modules/__init__.py.j2","tests/__init__.py.j2","README.md.j2","pyproject.toml.j2","Makefile.j2",".rapidkit/__init__.py.j2",".rapidkit/project.json.j2",".rapidkit/cli.py.j2",".rapidkit/rapidkit.j2",".rapidkit/activate.j2","rapidkit.j2","rapidkit.cmd.j2"]:d=["src/main.ts.j2","src/app.module.ts.j2","src/app.controller.ts.j2","src/app.service.ts.j2","src/config/configuration.ts.j2","src/config/validation.ts.j2","src/config/index.ts.j2","src/modules/index.ts.j2","src/examples/examples.module.ts.j2","src/examples/examples.controller.ts.j2","src/examples/examples.service.ts.j2","src/examples/dto/create-note.dto.ts.j2","test/app.controller.spec.ts.j2","test/examples.controller.spec.ts.j2","test/app.e2e-spec.ts.j2","test/jest-e2e.json.j2","package.json.j2","tsconfig.json.j2","tsconfig.build.json.j2","nest-cli.json.j2","jest.config.ts.j2","eslint.config.cjs.j2",".env.example.j2","docker-compose.yml.j2","Dockerfile.j2","README.md.j2",".rapidkit/project.json.j2",".rapidkit/rapidkit.j2",".rapidkit/rapidkit.cmd.j2",".rapidkit/activate.j2","rapidkit.j2","rapidkit.cmd.j2"];for(let f of d){let w=v.join(c,f);try{await promises.access(w);}catch{continue}let A=await promises.readFile(w,"utf-8"),D=p.renderString(A,l),K=f.replace(/\.j2$/,""),At=v.join(t,K);await promises.mkdir(v.dirname(At),{recursive:!0}),await promises.writeFile(At,D),(K.endsWith(".rapidkit/rapidkit")||K.endsWith(".rapidkit/cli.py")||K.endsWith(".rapidkit/activate")||K==="rapidkit")&&await promises.chmod(At,493);}if(o){let f=v.join(c,".rapidkit","context.json"),w=v.join(t,".rapidkit","context.json");try{await promises.mkdir(v.join(t,".rapidkit"),{recursive:!0}),await promises.copyFile(f,w);}catch{await promises.mkdir(v.join(t,".rapidkit"),{recursive:!0});let D=e.engine||"pip";await promises.writeFile(w,JSON.stringify({engine:D,created_by:"rapidkit-npm-fallback"},null,2));}}let m=o?`# Python
|
|
1316
1316
|
__pycache__/
|
|
1317
1317
|
*.py[cod]
|
|
1318
1318
|
*$py.class
|
|
@@ -1380,15 +1380,15 @@ Thumbs.db
|
|
|
1380
1380
|
|
|
1381
1381
|
# Coverage
|
|
1382
1382
|
coverage/
|
|
1383
|
-
`;if(await promises.writeFile(v.join(t,".gitignore"),
|
|
1384
|
-
${
|
|
1385
|
-
${
|
|
1386
|
-
${
|
|
1387
|
-
${
|
|
1388
|
-
`),console.log(
|
|
1389
|
-
${
|
|
1390
|
-
|
|
1391
|
-
${
|
|
1383
|
+
`;if(await promises.writeFile(v.join(t,".gitignore"),m),n.succeed(`${r} project generated!`),!e.skipGit){let f=wt("Initializing git repository...").start();try{await execa("git",["init"],{cwd:t}),await execa("git",["add","."],{cwd:t}),await execa("git",["commit","-m",`Initial commit: ${r} project via RapidKit`],{cwd:t}),f.succeed("Git repository initialized");}catch{f.warn("Could not initialize git repository");}}if(!o&&!e.skipInstall){let f=e.package_manager||"npm",w=wt(`Installing dependencies with ${f}...`).start();try{await execa(f,f==="yarn"?["install"]:f==="pnpm"?["install"]:["install"],{cwd:t}),w.succeed("Dependencies installed");}catch{w.warn(`Could not install dependencies. Run '${f} install' manually.`);}}let y=v.basename(t);console.log(`
|
|
1384
|
+
${g.yellow("\u26A0\uFE0F Limited offline mode:")} This project was created using basic templates.
|
|
1385
|
+
${g.gray("For full kit features, install Python 3.10+ and rapidkit-core:")}
|
|
1386
|
+
${g.cyan(" sudo apt install python3 python3-pip python3-venv")}
|
|
1387
|
+
${g.cyan(" pip install rapidkit-core")}
|
|
1388
|
+
`),console.log(o?`
|
|
1389
|
+
${g.green("\u2728 FastAPI project created successfully!")}
|
|
1390
|
+
|
|
1391
|
+
${g.bold("\u{1F4C2} Project structure:")}
|
|
1392
1392
|
${t}/
|
|
1393
1393
|
\u251C\u2500\u2500 .rapidkit/ # RapidKit CLI module
|
|
1394
1394
|
\u251C\u2500\u2500 src/
|
|
@@ -1400,12 +1400,12 @@ ${t}/
|
|
|
1400
1400
|
\u251C\u2500\u2500 pyproject.toml # Poetry configuration
|
|
1401
1401
|
\u2514\u2500\u2500 README.md
|
|
1402
1402
|
|
|
1403
|
-
${
|
|
1404
|
-
${
|
|
1405
|
-
${
|
|
1406
|
-
${
|
|
1403
|
+
${g.bold("\u{1F680} Get started:")}
|
|
1404
|
+
${g.cyan(`cd ${y}`)}
|
|
1405
|
+
${g.cyan("npx rapidkit init")} ${g.gray("# Install dependencies")}
|
|
1406
|
+
${g.cyan("npx rapidkit dev")} ${g.gray("# Start dev server")}
|
|
1407
1407
|
|
|
1408
|
-
${
|
|
1408
|
+
${g.bold("\u{1F4DA} Available commands:")}
|
|
1409
1409
|
npx rapidkit init # Install dependencies (poetry install)
|
|
1410
1410
|
npx rapidkit dev # Start dev server with hot reload
|
|
1411
1411
|
npx rapidkit start # Start production server
|
|
@@ -1413,12 +1413,12 @@ ${m.bold("\u{1F4DA} Available commands:")}
|
|
|
1413
1413
|
npx rapidkit lint # Lint code
|
|
1414
1414
|
npx rapidkit format # Format code
|
|
1415
1415
|
|
|
1416
|
-
${
|
|
1417
|
-
${
|
|
1416
|
+
${g.gray("Alternative: make dev, ./rapidkit dev, poetry run dev")}
|
|
1417
|
+
${g.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
|
|
1418
1418
|
`:`
|
|
1419
|
-
${
|
|
1419
|
+
${g.green("\u2728 NestJS project created successfully!")}
|
|
1420
1420
|
|
|
1421
|
-
${
|
|
1421
|
+
${g.bold("\u{1F4C2} Project structure:")}
|
|
1422
1422
|
${t}/
|
|
1423
1423
|
\u251C\u2500\u2500 .rapidkit/ # RapidKit CLI module
|
|
1424
1424
|
\u251C\u2500\u2500 src/
|
|
@@ -1430,13 +1430,13 @@ ${t}/
|
|
|
1430
1430
|
\u251C\u2500\u2500 package.json # Dependencies
|
|
1431
1431
|
\u2514\u2500\u2500 README.md
|
|
1432
1432
|
|
|
1433
|
-
${
|
|
1434
|
-
${
|
|
1435
|
-
${
|
|
1436
|
-
${
|
|
1437
|
-
${
|
|
1433
|
+
${g.bold("\u{1F680} Get started:")}
|
|
1434
|
+
${g.cyan(`cd ${y}`)}
|
|
1435
|
+
${g.cyan("npx rapidkit init")} ${g.gray("# Install dependencies")}
|
|
1436
|
+
${g.cyan("cp .env.example .env")}
|
|
1437
|
+
${g.cyan("npx rapidkit dev")} ${g.gray("# Start dev server")}
|
|
1438
1438
|
|
|
1439
|
-
${
|
|
1439
|
+
${g.bold("\u{1F4DA} Available commands:")}
|
|
1440
1440
|
npx rapidkit init # Install dependencies
|
|
1441
1441
|
npx rapidkit dev # Start dev server with hot reload
|
|
1442
1442
|
npx rapidkit start # Start production server
|
|
@@ -1445,30 +1445,44 @@ ${m.bold("\u{1F4DA} Available commands:")}
|
|
|
1445
1445
|
npx rapidkit lint # Lint code
|
|
1446
1446
|
npx rapidkit format # Format code
|
|
1447
1447
|
|
|
1448
|
-
${
|
|
1448
|
+
${g.bold("\u{1F310} API endpoints:")}
|
|
1449
1449
|
http://localhost:8000/health # Health check
|
|
1450
1450
|
http://localhost:8000/docs # Swagger docs
|
|
1451
1451
|
http://localhost:8000/examples/notes # Example API
|
|
1452
1452
|
|
|
1453
|
-
${
|
|
1454
|
-
${
|
|
1455
|
-
`);}catch(a){throw
|
|
1453
|
+
${g.gray("Alternative: npm run start:dev, ./rapidkit dev")}
|
|
1454
|
+
${g.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
|
|
1455
|
+
`);}catch(a){throw n.fail(`Failed to generate ${r} project`),a}}$();st();async function Ae(){let t=process.platform==="win32"?["python","python3"]:["python3","python"];for(let e of t)try{let{stdout:i}=await execa(e,["--version"],{timeout:3e3}),o=i.match(/Python (\d+\.\d+\.\d+)/);if(o){let r=o[1],[n,a]=r.split(".").map(Number);return n<3||n===3&&a<10?{status:"warn",message:`Python ${r} (requires 3.10+)`,details:`${e} found but version is below minimum requirement`}:{status:"ok",message:`Python ${r}`,details:`Using ${e}`}}}catch{continue}return {status:"error",message:"Python not found",details:"Install Python 3.10+ and ensure it's in PATH"}}async function Ne(){try{let{stdout:t}=await execa("poetry",["--version"],{timeout:3e3}),e=t.match(/Poetry .*version ([\d.]+)/);return e?{status:"ok",message:`Poetry ${e[1]}`,details:"Available for dependency management"}:{status:"warn",message:"Poetry version unknown"}}catch{return {status:"warn",message:"Poetry not installed",details:"Optional: Install for better dependency management"}}}async function De(){try{let{stdout:t}=await execa("pipx",["--version"],{timeout:3e3});return {status:"ok",message:`pipx ${t.trim()}`,details:"Available for global tool installation"}}catch{return {status:"warn",message:"pipx not installed",details:"Optional: Install for isolated Python tools"}}}async function Te(){let t=process.platform==="win32"?["python","python3"]:["python3","python"],e=process.env.HOME||process.env.USERPROFILE||"",i=[v.join(e,".local","bin","rapidkit"),v.join(e,"AppData","Roaming","Python","Scripts","rapidkit.exe"),v.join(e,".pyenv","shims","rapidkit"),"/usr/local/bin/rapidkit","/usr/bin/rapidkit"];try{let{stdout:o,exitCode:r}=await execa("rapidkit",["--version"],{timeout:3e3,reject:!1});if(r===0&&(o.includes("RapidKit Version")||o.includes("RapidKit"))){let n=o.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(n)return {status:"ok",message:`RapidKit Core ${n[1]}`,details:"Available via PATH"}}}catch{}for(let o of i)try{if(await I.pathExists(o)){let{stdout:r,exitCode:n}=await execa(o,["--version"],{timeout:3e3,reject:!1});if(n===0&&(r.includes("RapidKit Version")||r.includes("RapidKit"))){let a=r.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(a)return {status:"ok",message:`RapidKit Core ${a[1]}`,details:`Installed at ${o}`}}}}catch{continue}try{let o=v.join(process.cwd(),".venv","bin","rapidkit");if(await I.pathExists(o)){let{stdout:r,exitCode:n}=await execa(o,["--version"],{timeout:3e3,reject:!1});if(n===0&&(r.includes("RapidKit Version")||r.includes("RapidKit"))){let a=r.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(a)return {status:"ok",message:`RapidKit Core ${a[1]}`,details:"Installed in workspace virtualenv"}}}}catch{}try{let{stdout:o,exitCode:r}=await execa("poetry",["run","rapidkit","--version"],{timeout:3e3,reject:!1});if(r===0&&(o.includes("RapidKit Version")||o.includes("RapidKit"))){let n=o.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(n)return {status:"ok",message:`RapidKit Core ${n[1]}`,details:"Available via Poetry"}}}catch{}for(let o of t)try{let{stdout:r,exitCode:n}=await execa(o,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:3e3,reject:!1});if(n===0&&r&&!r.includes("Traceback")&&!r.includes("ModuleNotFoundError")){let a=r.trim();if(a)return {status:"ok",message:`RapidKit Core ${a}`,details:`Available in ${o} environment`}}}catch{continue}return {status:"error",message:"RapidKit Core not installed",details:"Install with: pipx install rapidkit-core"}}async function Si(t){let i={name:v.basename(t),path:t,venvActive:false,depsInstalled:false,coreInstalled:false,issues:[]},o=v.join(t,".rapidkit");if(!await I.pathExists(o))return i.issues.push("Not a valid RapidKit project (missing .rapidkit directory)"),i;let r=v.join(t,".venv");if(await I.pathExists(r)){i.venvActive=true;let n=process.platform==="win32"?v.join(r,"Scripts","python.exe"):v.join(r,"bin","python");if(await I.pathExists(n)){try{let{stdout:s}=await execa(n,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:2e3});i.coreInstalled=!0,i.coreVersion=s.trim();}catch{i.issues.push("RapidKit Core not installed in virtual environment");}let a=process.platform==="win32"?v.join(r,"Lib","site-packages"):v.join(r,"lib","python*","site-packages");try{let s=await I.pathExists(v.dirname(a));i.depsInstalled=s,s||i.issues.push("Dependencies not installed (run: rapidkit init)");}catch{i.issues.push("Could not verify dependency installation");}}else i.issues.push("Virtual environment exists but Python executable not found");}else i.issues.push("Virtual environment not created (run: rapidkit init)");return i}async function Ai(t){let e=t,i=v.parse(e).root;for(;e!==i;){let o=[v.join(e,".rapidkit-workspace"),v.join(e,".rapidkit","workspace-marker.json"),v.join(e,".rapidkit","config.json")];for(let r of o)if(await I.pathExists(r))return e;e=v.dirname(e);}return null}async function Ni(t){let e=v.basename(t);try{let o=v.join(t,".rapidkit-workspace");await I.pathExists(o)&&(e=(await I.readJSON(o)).name||e);}catch{try{let o=v.join(t,".rapidkit","config.json");e=(await I.readJSON(o)).workspace_name||e;}catch{}}let i={workspacePath:t,workspaceName:e,python:await Ae(),poetry:await Ne(),pipx:await De(),rapidkitCore:await Te(),projects:[]};try{let o=await I.readdir(t,{withFileTypes:!0});for(let r of o)if(r.isDirectory()&&!r.name.startsWith(".")){let n=v.join(t,r.name),a=v.join(n,".rapidkit");if(await I.pathExists(a)){let s=await Si(n);i.projects.push(s);}}}catch(o){u.debug(`Failed to scan workspace projects: ${o}`);}return i}function Q(t,e){let i=t.status==="ok"?"\u2705":t.status==="warn"?"\u26A0\uFE0F":"\u274C",o=t.status==="ok"?g.green:t.status==="warn"?g.yellow:g.red;console.log(`${i} ${g.bold(e)}: ${o(t.message)}`),t.details&&console.log(` ${g.gray(t.details)}`);}function Di(t){let e=t.issues.length>0,i=e?"\u26A0\uFE0F":"\u2705",o=e?g.yellow:g.green;console.log(`
|
|
1456
|
+
${i} ${g.bold("Project")}: ${o(t.name)}`),console.log(` ${g.gray(`Path: ${t.path}`)}`),t.venvActive?console.log(` \u2705 Virtual environment: ${g.green("Active")}`):console.log(` \u274C Virtual environment: ${g.red("Not found")}`),t.coreInstalled?console.log(` \u2705 RapidKit Core: ${g.green(t.coreVersion||"Installed")}`):console.log(` \u274C RapidKit Core: ${g.red("Not installed")}`),t.depsInstalled?console.log(` \u2705 Dependencies: ${g.green("Installed")}`):console.log(` \u26A0\uFE0F Dependencies: ${g.yellow("Not verified")}`),t.issues.length>0&&(console.log(` ${g.bold("Issues:")}`),t.issues.forEach(r=>{console.log(` \u2022 ${g.yellow(r)}`);}));}async function Oe(t={}){if(console.log(g.bold.cyan(`
|
|
1457
|
+
\u{1FA7A} RapidKit Health Check
|
|
1458
|
+
`)),t.workspace){let e=await Ai(process.cwd());e||(u.error("No RapidKit workspace found in current directory or parents"),u.info('Run this command from within a workspace, or use "rapidkit doctor" for system check'),process.exit(1)),console.log(g.bold(`Workspace: ${g.cyan(v.basename(e))}`)),console.log(g.gray(`Path: ${e}
|
|
1459
|
+
`));let i=await Ni(e);console.log(g.bold(`System Tools:
|
|
1460
|
+
`)),Q(i.python,"Python"),Q(i.poetry,"Poetry"),Q(i.pipx,"pipx"),Q(i.rapidkitCore,"RapidKit Core"),i.projects.length>0?(console.log(g.bold(`
|
|
1461
|
+
\u{1F4E6} Projects (${i.projects.length}):`)),i.projects.forEach(n=>Di(n))):(console.log(g.bold(`
|
|
1462
|
+
\u{1F4E6} Projects:`)),console.log(g.gray(" No RapidKit projects found in workspace")));let o=i.projects.reduce((n,a)=>n+a.issues.length,0),r=[i.python,i.rapidkitCore].some(n=>n.status==="error");r||o>0?(console.log(g.bold.yellow(`
|
|
1463
|
+
\u26A0\uFE0F Found ${o} project issue(s)`)),r&&console.log(g.bold.red("\u274C System requirements not met"))):console.log(g.bold.green(`
|
|
1464
|
+
\u2705 All checks passed! Workspace is healthy.`));}else {console.log(g.bold(`System Tools:
|
|
1465
|
+
`));let e=await Ae(),i=await Ne(),o=await De(),r=await Te();Q(e,"Python"),Q(i,"Poetry"),Q(o,"pipx"),Q(r,"RapidKit Core"),[e,r].some(a=>a.status==="error")?(console.log(g.bold.red(`
|
|
1466
|
+
\u274C Some required tools are missing`)),console.log(g.gray(`
|
|
1467
|
+
Tip: Run "rapidkit doctor --workspace" from within a workspace for detailed project checks`))):(console.log(g.bold.green(`
|
|
1468
|
+
\u2705 All required tools are installed!`)),console.log(g.gray(`
|
|
1469
|
+
Tip: Run "rapidkit doctor --workspace" from within a workspace for detailed project checks`)));}console.log("");}function qt(t){if(!t||typeof t!="object")return null;let e=t.code;return e==="PYTHON_NOT_FOUND"||e==="BRIDGE_VENV_BOOTSTRAP_FAILED"?e:null}function Oi(t){let e=t.trim().toLowerCase();return e?e.startsWith("fastapi")?"fastapi":e.startsWith("nestjs")?"nestjs":null:null}function Fi(t,e){let i=t.indexOf(e);if(i>=0&&i+1<t.length)return t[i+1];let o=t.find(r=>r.startsWith(`${e}=`));if(o)return o.slice(e.length+1)}async function Xt(t,e){if(t.includes("--json"))return process.stderr.write("RapidKit (npm) offline fallback does not support --json for `create` commands.\nInstall Python 3.10+ and retry the same command.\n"),1;if(t[0]!=="create")return 1;if(t[1]!=="project")return process.stderr.write(`RapidKit (npm) could not run the Python core engine for \`create\`.
|
|
1456
1470
|
Reason: ${e}.
|
|
1457
1471
|
Install Python 3.10+ to use the interactive wizard and full kit catalog.
|
|
1458
|
-
`),1;let
|
|
1472
|
+
`),1;let r=t[2],n=t[3];if(!r||!n)return process.stderr.write(`Usage: rapidkit create project <kit> <name> [--output <dir>]
|
|
1459
1473
|
Tip: offline fallback supports only fastapi* and nestjs* kits.
|
|
1460
|
-
`),1;let a=
|
|
1474
|
+
`),1;let a=Oi(r);if(!a)return process.stderr.write(`RapidKit (npm) could not run the Python core engine to create this kit.
|
|
1461
1475
|
Reason: ${e}.
|
|
1462
|
-
Requested kit: ${
|
|
1476
|
+
Requested kit: ${r}
|
|
1463
1477
|
Offline fallback only supports: fastapi.standard, nestjs.standard (and their shorthands).
|
|
1464
1478
|
Install Python 3.10+ to access all kits.
|
|
1465
|
-
`),1;let s=
|
|
1466
|
-
`),1;let
|
|
1467
|
-
`),1}}async function
|
|
1468
|
-
`),
|
|
1469
|
-
`),1)}}if(t[0]==="create"&&t[1]!=="project")try{await
|
|
1470
|
-
`),1)}return await
|
|
1471
|
-
`),1)}}var
|
|
1479
|
+
`),1;let s=Fi(t,"--output")||process.cwd(),c=v.resolve(s,n),p=t.includes("--skip-git")||t.includes("--no-git"),l=t.includes("--skip-install");try{if(await I.ensureDir(v.dirname(c)),await I.pathExists(c))return process.stderr.write(`\u274C Directory "${c}" already exists
|
|
1480
|
+
`),1;let d="pip",m=It(process.cwd());if(m)try{let{readWorkspaceMarker:y}=await Promise.resolve().then(()=>(Bt(),we)),f=await y(m);f?.metadata?.npm?.installMethod&&(d=f.metadata.npm.installMethod,console.log(`[DEBUG] Detected workspace engine: ${d}`));}catch(y){console.log("[DEBUG] Failed to read workspace marker:",y);}else console.log("[DEBUG] No workspace found, using default engine: pip");if(await I.ensureDir(c),await Se(c,{project_name:n,template:a,skipGit:p,skipInstall:l,engine:d}),m){let{syncWorkspaceProjects:y}=await Promise.resolve().then(()=>(X(),q));await y(m,!0);}return 0}catch(d){return process.stderr.write(`RapidKit (npm) offline fallback failed: ${d?.message??d}
|
|
1481
|
+
`),1}}async function Ki(t){let e=new Set(["--yes","-y","--skip-git","--skip-install","--debug","--dry-run","--no-update-check","--create-workspace","--no-workspace"]);try{if(t[0]==="create"&&t[1]==="project"){let i=t.includes("--create-workspace"),o=t.includes("--no-workspace"),r=t.includes("--yes")||t.includes("-y"),n=t.includes("--skip-git")||t.includes("--no-git");if(!!!Et(process.cwd())){if(i)await rt(process.cwd(),{skipGit:n,yes:r,userConfig:await ft()});else if(!o)if(r)await rt(process.cwd(),{skipGit:n,yes:!0,userConfig:await ft()});else {let{createWs:c}=await Jt.prompt([{type:"confirm",name:"createWs",message:"This project will be created outside a RapidKit workspace. Create and register a workspace here?",default:!0}]);c&&await rt(process.cwd(),{skipGit:n,yes:!1,userConfig:await ft()});}}let s=t.filter(c=>{let p=c.split("=")[0];return !e.has(c)&&!e.has(p)});try{await dt();let c=await B(s,{cwd:process.cwd()});if(c===0){let p=It(process.cwd());if(p){try{let d=t[3];if(d){let m=t.indexOf("--output"),y=m>=0?t[m+1]:".",f=v.resolve(process.cwd(),y,d),w=v.join(p,".python-version"),A=v.join(f,".python-version");if(T.existsSync(w)&&T.existsSync(f)){let D=T.readFileSync(w,"utf-8");T.writeFileSync(A,D.trim()+`
|
|
1482
|
+
`),u.debug(`Synced Python version ${D.trim()} from workspace to ${d}`);}}}catch(d){u.debug("Could not sync Python version from workspace:",d);}let{syncWorkspaceProjects:l}=await Promise.resolve().then(()=>(X(),q));await l(p,!0);}}return c}catch(c){let p=qt(c);return p?await Xt(s,p):(process.stderr.write(`RapidKit (npm) failed to run the Python core engine: ${c?.message??c}
|
|
1483
|
+
`),1)}}if(t[0]==="create"&&t[1]!=="project")try{await dt();let i=await B(t,{cwd:process.cwd()});if(i===0){let o=It(process.cwd());if(o){let{syncWorkspaceProjects:r}=await Promise.resolve().then(()=>(X(),q));await r(o,!0);}}return i}catch(i){let o=qt(i);return o?await Xt(t,o):(process.stderr.write(`RapidKit (npm) failed to run the Python core engine: ${i?.message??i}
|
|
1484
|
+
`),1)}return await dt(),await B(t,{cwd:process.cwd()})}catch(i){let o=qt(i);return o?await Xt(t,o):(process.stderr.write(`RapidKit (npm) failed to run the Python core engine: ${i?.message??i}
|
|
1485
|
+
`),1)}}var Ke=["init","dev","start","build","test","lint","format","create","help","--help","-h"];function Mi(t){let e=t;for(;;){let i=v.join(e,".rapidkit","context.json");if(T.existsSync(i))return i;let o=v.dirname(e);if(o===e)break;e=o;}return null}function Et(t){let e=t;for(;;){let i=v.join(e,".rapidkit-workspace");if(T.existsSync(i))return i;let o=v.dirname(e);if(o===e)break;e=o;}return null}function It(t){let e=t;for(;;){let i=v.join(e,".rapidkit-workspace");if(T.existsSync(i))return e;let o=v.dirname(e);if(o===e)break;e=o;}return null}async function Wi(){let t=process.cwd(),e=process.argv.slice(2);if(e[0]==="create")return false;try{let c=e[0],p=!c||c==="--help"||c==="-h"||c==="help";if(Et(t)&&p){let d=await B(c?["--help"]:[],{cwd:t});process.exit(d);}}catch{}try{let c=e[0],p=c==="shell"&&e[1]==="activate",l=c==="create",d=await ne(t,{cwd:t,timeoutMs:1200});if(d.ok&&d.data?.isRapidkitProject&&d.data.engine==="python"&&!p&&!l){let m=await B(process.argv.slice(2),{cwd:t});process.exit(m);}}catch{}let i=Mi(t),o=process.platform==="win32",r=o?[v.join(t,"rapidkit.cmd"),v.join(t,"rapidkit"),v.join(t,".rapidkit","rapidkit.cmd"),v.join(t,".rapidkit","rapidkit")]:[v.join(t,"rapidkit"),v.join(t,".rapidkit","rapidkit")],n=null;for(let c of r)if(await I.pathExists(c)){n=c;break}let a=e[0],s=a==="create";if(n&&a&&Ke.includes(a)&&!s){u.debug(`Delegating to local CLI: ${n} ${e.join(" ")}`);let c=spawn(n,e,{stdio:"inherit",cwd:t,shell:o});return c.on("close",p=>{process.exit(p??0);}),c.on("error",p=>{u.error(`Failed to run local rapidkit: ${p.message}`),process.exit(1);}),true}if(i&&await I.pathExists(i))try{if((await I.readJson(i)).engine==="pip"){let p=e[0],d=process.platform==="win32"?[v.join(t,"rapidkit.cmd"),v.join(t,"rapidkit"),v.join(t,".rapidkit","rapidkit.cmd"),v.join(t,".rapidkit","rapidkit")]:[v.join(t,"rapidkit"),v.join(t,".rapidkit","rapidkit")],m=null;for(let f of d)if(await I.pathExists(f)){m=f;break}if(m&&p&&Ke.includes(p)){u.debug(`Delegating to local CLI (early detection): ${m} ${e.join(" ")}`);let f=spawn(m,e,{stdio:"inherit",cwd:t});return f.on("close",w=>process.exit(w??0)),f.on("error",w=>{u.error(`Failed to run local rapidkit: ${w.message}`),process.exit(1);}),!0}if(p==="shell"&&e[1]==="activate"){let f=`# RapidKit: activation snippet - eval "$(rapidkit shell activate)"
|
|
1472
1486
|
VENV='.venv'
|
|
1473
1487
|
if [ -f "$VENV/bin/activate" ]; then
|
|
1474
1488
|
. "$VENV/bin/activate"
|
|
@@ -1477,11 +1491,11 @@ elif [ -f "$VENV/bin/activate.fish" ]; then
|
|
|
1477
1491
|
fi
|
|
1478
1492
|
export RAPIDKIT_PROJECT_ROOT="$(pwd)"
|
|
1479
1493
|
export PATH="$(pwd)/.rapidkit:$(pwd):$PATH"
|
|
1480
|
-
`;console.log(
|
|
1494
|
+
`;console.log(g.green.bold(`
|
|
1481
1495
|
\u2705 Activation snippet \u2014 run the following to activate this project in your current shell:
|
|
1482
|
-
`)),console.log(f),console.log(
|
|
1496
|
+
`)),console.log(f),console.log(g.gray(`
|
|
1483
1497
|
\u{1F4A1} After activation you can run: rapidkit dev
|
|
1484
|
-
`)),process.exit(0);}let
|
|
1498
|
+
`)),process.exit(0);}let y=await B(e,{cwd:t});process.exit(y);}}catch{}return false}var Z=null,St=false,tt=new Command;async function Gi(t){if(t.length===0)return false;let e=t[0],i=t[1];if(e==="shell"&&i==="activate"||e==="workspace"||e==="doctor")return false;if(t.includes("--tui"))return true;if(e==="--help"||e==="-h"||e==="help"||e==="--version"||e==="-V"||t.includes("--template")||t.includes("-t"))return false;let o=new Set(["--yes","-y","--skip-git","--skip-install","--debug","--dry-run","--no-update-check","--create-workspace","--no-workspace"]);if(t.some(n=>o.has(n)))return false;let r=await Lt();return r?r.has(e):!!(he.has(e)||t.length>1)}tt.name("rapidkit").description("Create RapidKit workspaces and projects").version(U());tt.addHelpText("beforeAll",`RapidKit
|
|
1485
1499
|
|
|
1486
1500
|
Global CLI
|
|
1487
1501
|
Create RapidKit workspaces and projects
|
|
@@ -1495,58 +1509,27 @@ Project Commands
|
|
|
1495
1509
|
rapidkit dev
|
|
1496
1510
|
|
|
1497
1511
|
Use "rapidkit help <command>" for more information.
|
|
1498
|
-
`);tt.argument("[name]","Name of the workspace or project directory").addOption(new Option("-t, --template <template>","Legacy: create a project with template (fastapi, nestjs) instead of a workspace").hideHelp()).option("-y, --yes","Skip prompts and use defaults").addOption(new Option("--skip-git","Skip git initialization").hideHelp()).addOption(new Option("--skip-install","Legacy: skip installing dependencies (template mode)").hideHelp()).option("--debug","Enable debug logging").addOption(new Option("--dry-run","Show what would be created without creating it").hideHelp()).addOption(new Option("--install-method <method>","Installation method: poetry, venv, or pipx").choices(["poetry","venv","pipx"]).hideHelp()).addOption(new Option("--create-workspace","When creating a project outside a workspace: create and register a workspace in the current directory").hideHelp()).addOption(new Option("--no-workspace","When creating a project outside a workspace: do not create a workspace").hideHelp()).option("--no-update-check","Skip checking for updates").action(async(t,e)=>{try{e.debug&&(
|
|
1512
|
+
`);tt.argument("[name]","Name of the workspace or project directory").addOption(new Option("-t, --template <template>","Legacy: create a project with template (fastapi, nestjs) instead of a workspace").hideHelp()).option("-y, --yes","Skip prompts and use defaults").addOption(new Option("--skip-git","Skip git initialization").hideHelp()).addOption(new Option("--skip-install","Legacy: skip installing dependencies (template mode)").hideHelp()).option("--debug","Enable debug logging").addOption(new Option("--dry-run","Show what would be created without creating it").hideHelp()).addOption(new Option("--install-method <method>","Installation method: poetry, venv, or pipx").choices(["poetry","venv","pipx"]).hideHelp()).addOption(new Option("--create-workspace","When creating a project outside a workspace: create and register a workspace in the current directory").hideHelp()).addOption(new Option("--no-workspace","When creating a project outside a workspace: do not create a workspace").hideHelp()).option("--no-update-check","Skip checking for updates").action(async(t,e)=>{try{e.debug&&(u.setDebug(!0),u.debug("Debug mode enabled"));let i=await ft();u.debug("User config loaded",i);let o=await ie();u.debug("RapidKit config loaded",o);let r=oe(i,o,{author:e.author,pythonVersion:void 0,skipGit:e.skipGit});u.debug("Merged config",r),e.updateCheck!==!1&&await te(),console.log(g.blue.bold(`
|
|
1499
1513
|
\u{1F680} Welcome to RapidKit!
|
|
1500
|
-
`)),t||(
|
|
1501
|
-
\u274C ${
|
|
1502
|
-
`),process.exit(1)),
|
|
1503
|
-
\u274C Directory "${t}" already exists`),console.log(
|
|
1514
|
+
`)),t||(Vi(),process.exit(0));try{re(t);}catch(s){throw s instanceof G&&(u.error(`
|
|
1515
|
+
\u274C ${s.message}`),s.details&&u.warn(`\u{1F4A1} ${s.details}
|
|
1516
|
+
`),process.exit(1)),s}let n=v.resolve(process.cwd(),t);Z=n,await I.pathExists(n)&&(u.error(`
|
|
1517
|
+
\u274C Directory "${t}" already exists`),console.log(g.cyan(`
|
|
1504
1518
|
\u{1F4A1} Choose a different name or delete the existing directory.
|
|
1505
|
-
`)),process.exit(1));let
|
|
1519
|
+
`)),process.exit(1));let a=!!e.template;if(e.dryRun){console.log(g.cyan(`
|
|
1506
1520
|
\u{1F50D} Dry-run mode - showing what would be created:
|
|
1507
|
-
`)),console.log(
|
|
1508
|
-
`)),
|
|
1509
|
-
`),
|
|
1510
|
-
`),
|
|
1511
|
-
\u274C ${i.message}`),i.details&&
|
|
1512
|
-
\u274C An unexpected error occurred:`),console.error(i)),process.exit(1);}finally{
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
. "
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
\u2705 Activation snippet \u2014 run the following to activate this project in your current shell:
|
|
1523
|
-
`)),console.log(a),console.log(m.gray(`
|
|
1524
|
-
\u{1F4A1} After activation you can run: rapidkit dev
|
|
1525
|
-
`)),process.exit(0);}try{(await E.readJson(r)).engine!=="pip"&&(console.log(m.yellow("This project is not a pip-based RapidKit project.")),process.exit(1)),console.log(`# RapidKit: activation snippet - eval "$(rapidkit shell activate)"
|
|
1526
|
-
VENV='.venv'
|
|
1527
|
-
if [ -f "$VENV/bin/activate" ]; then
|
|
1528
|
-
. "$VENV/bin/activate"
|
|
1529
|
-
elif [ -f "$VENV/bin/activate.fish" ]; then
|
|
1530
|
-
source "$VENV/bin/activate.fish"
|
|
1531
|
-
fi
|
|
1532
|
-
export RAPIDKIT_PROJECT_ROOT="$(pwd)"
|
|
1533
|
-
export PATH="$(pwd)/.rapidkit:$(pwd):$PATH"
|
|
1534
|
-
`),process.exit(0);}catch{console.log(m.yellow("Could not read project context but found a venv or activation file \u2014 printing activation snippet")),console.log(`# RapidKit: activation snippet - eval "$(rapidkit shell activate)"
|
|
1535
|
-
VENV='.venv'
|
|
1536
|
-
if [ -f "$VENV/bin/activate" ]; then
|
|
1537
|
-
. "$VENV/bin/activate"
|
|
1538
|
-
elif [ -f "$VENV/bin/activate.fish" ]; then
|
|
1539
|
-
source "$VENV/bin/activate.fish"
|
|
1540
|
-
fi
|
|
1541
|
-
export RAPIDKIT_PROJECT_ROOT="$(pwd)"
|
|
1542
|
-
export PATH="$(pwd):$PATH"
|
|
1543
|
-
`),process.exit(0);}});tt.command("workspace <action>").description("Manage RapidKit workspaces (list, sync)").action(async t=>{if(t==="list"){let{listWorkspaces:e}=await Promise.resolve().then(()=>(J(),H));await e();}else if(t==="sync"){let e=bt(process.cwd());e||(console.log(m.red("\u274C Not inside a RapidKit workspace")),console.log(m.gray("\u{1F4A1} Run this command from within a workspace directory")),process.exit(1));let{syncWorkspaceProjects:i}=await Promise.resolve().then(()=>(J(),H));console.log(m.cyan(`\u{1F4C2} Scanning workspace: ${v.basename(e)}`)),await i(e);}else console.log(m.red(`Unknown workspace action: ${t}`)),console.log(m.gray("Available: list, sync")),process.exit(1);});function Ri(){console.log(m.white(`Usage:
|
|
1544
|
-
`)),console.log(m.cyan(" npx rapidkit <workspace-name> [options]")),console.log(m.cyan(` npx rapidkit create <...>
|
|
1545
|
-
`)),console.log(m.bold("Recommended workflow:")),console.log(m.cyan(" npx rapidkit my-workspace")),console.log(m.cyan(" cd my-workspace")),console.log(m.cyan(" npx rapidkit create project fastapi.standard my-api --output .")),console.log(m.cyan(" cd my-api")),console.log(m.cyan(` npx rapidkit init && npx rapidkit dev
|
|
1546
|
-
`)),console.log(m.bold("Options (workspace creation):")),console.log(m.gray(" -y, --yes Skip prompts and use defaults")),console.log(m.gray(" --skip-git Skip git initialization")),console.log(m.gray(" --debug Enable debug logging")),console.log(m.gray(" --dry-run Show what would be created")),console.log(m.gray(" --create-workspace When creating a project outside a workspace: create and register a workspace in the current directory")),console.log(m.gray(" --no-workspace When creating a project outside a workspace: do not create a workspace")),console.log(m.gray(` --no-update-check Skip checking for updates
|
|
1547
|
-
`)),console.log(m.gray(`Tip: set RAPIDKIT_SHOW_LEGACY=1 to show legacy template flags in help.
|
|
1548
|
-
`));}process.on("SIGINT",async()=>{if(!Rt){if(Rt=true,console.log(m.yellow(`
|
|
1549
|
-
|
|
1550
|
-
\u26A0\uFE0F Interrupted by user`)),Y&&await E.pathExists(Y)){console.log(m.gray("Cleaning up partial installation..."));try{await E.remove(Y),console.log(m.green("\u2713 Cleanup complete"));}catch(t){g.debug("Cleanup failed:",t);}}process.exit(130);}});process.on("SIGTERM",async()=>{if(!Rt){if(Rt=true,g.debug("Received SIGTERM"),Y&&await E.pathExists(Y))try{await E.remove(Y);}catch(t){g.debug("Cleanup failed:",t);}process.exit(143);}});ji().then(async t=>{if(!t){let e=process.argv.slice(2);if(process.env.RAPIDKIT_NPM_DEBUG_ARGS==="1"&&process.stderr.write(`[rapidkit-npm] argv=${JSON.stringify(e)}
|
|
1551
|
-
`),e[0]==="create"){let r=await vi(e);process.exit(r);}let i=await bi(e);if(process.env.RAPIDKIT_NPM_DEBUG_ARGS==="1"&&process.stderr.write(`[rapidkit-npm] shouldForwardToCore=${i}
|
|
1552
|
-
`),i){let r=await V(e,{cwd:process.cwd()});process.exit(r);}tt.parse();}});export{vi as handleCreateOrFallback};
|
|
1521
|
+
`)),console.log(g.white("\u{1F4C2} Path:"),n),console.log(g.white("\u{1F4E6} Type:"),a?`Project (${e.template})`:"Workspace"),console.log();return}if(!e.yes&&!a?await Jt.prompt([{type:"input",name:"author",message:"Author name:",default:process.env.USER||"RapidKit User"}]):e.yes&&console.log(g.gray(`Using default values (--yes flag)
|
|
1522
|
+
`)),a){let s=String(e.template||"").trim(),c=s.toLowerCase(),p=c==="fastapi"?"fastapi.standard":c==="nestjs"?"nestjs.standard":s;if(!!!Et(process.cwd())){if(e.createWorkspace)await rt(process.cwd(),{skipGit:e.skipGit,yes:e.yes,userConfig:i});else if(!e.noWorkspace)if(e.yes)await rt(process.cwd(),{skipGit:e.skipGit,yes:!0,userConfig:i});else {let{createWs:f}=await Jt.prompt([{type:"confirm",name:"createWs",message:"This project will be created outside a RapidKit workspace. Create and register a workspace here?",default:!0}]);f&&await rt(process.cwd(),{skipGit:e.skipGit,yes:!1,userConfig:i});}}let d=["create","project",p,t,"--output",process.cwd(),"--install-essentials"],m=await B(d,{cwd:process.cwd()});m!==0&&process.exit(m);let y=Et(process.cwd());if(y){let f=v.dirname(y),w=v.join(f,".python-version"),A=v.join(n,".python-version");try{if(await I.pathExists(w)){let D=T.readFileSync(w,"utf-8");T.writeFileSync(A,D.trim()+`
|
|
1523
|
+
`),u.debug(`Synced Python version ${D.trim()} from workspace to project`);}}catch(D){u.debug("Could not sync Python version from workspace:",D);}}if(!e.skipInstall){let f=await B(["init",n],{cwd:process.cwd()});if(f!==0&&process.exit(f),y){let w=v.dirname(y),A=v.join(w,".python-version"),D=v.join(n,".python-version");try{if(await I.pathExists(A)){let K=T.readFileSync(A,"utf-8");T.writeFileSync(D,K.trim()+`
|
|
1524
|
+
`),u.debug(`Re-synced Python version ${K.trim()} after init`);}}catch(K){u.debug("Could not re-sync Python version after init:",K);}}}}else await Pe(t,{skipGit:e.skipGit,dryRun:e.dryRun,yes:e.yes,userConfig:r,installMethod:e.installMethod});}catch(i){i instanceof G?(u.error(`
|
|
1525
|
+
\u274C ${i.message}`),i.details&&u.warn(`\u{1F4A1} ${i.details}`),u.debug("Error code:",i.code)):(u.error(`
|
|
1526
|
+
\u274C An unexpected error occurred:`),console.error(i)),process.exit(1);}finally{Z=null;}});tt.command("shell <action>").description("Shell helpers (activate virtualenv in current shell)").action(async t=>{t!=="activate"&&(console.log(g.red(`Unknown shell command: ${t}`)),process.exit(1));let e=process.cwd();function i(c){let p=c;for(;;){let l=v.join(p,".rapidkit","context.json");if(T.existsSync(l))return l;let d=v.dirname(p);if(d===p)break;p=d;}return null}let o=i(e);function r(c){let p=c;for(;;){let l=v.join(p,".venv"),d=v.join(p,".rapidkit","activate");if(T.existsSync(d)||T.existsSync(l))return {venv:l,activateFile:d};let m=v.dirname(p);if(m===p)break;p=m;}return null}let n=r(e);!o&&!n&&(console.log(g.yellow("No RapidKit project found in this directory")),process.exit(1));let a;n&&T.existsSync(n.activateFile)?a=n.activateFile:n&&T.existsSync(n.venv)?a=process.platform==="win32"?v.join(n.venv,"Scripts","activate"):v.join(n.venv,"bin","activate"):(console.log(g.yellow("No virtual environment found")),process.exit(1));let s=process.platform==="win32";console.log(s?`call "${a}"`:`. "${a}"`);});tt.command("doctor").description("\u{1FA7A} Check RapidKit environment health").option("--workspace","Check entire workspace (including all projects)").action(async t=>{await Oe(t);});tt.command("workspace <action>").description("Manage RapidKit workspaces (list, sync)").action(async t=>{if(t==="list"){let{listWorkspaces:e}=await Promise.resolve().then(()=>(X(),q));await e();}else if(t==="sync"){let e=It(process.cwd());e||(console.log(g.red("\u274C Not inside a RapidKit workspace")),console.log(g.gray("\u{1F4A1} Run this command from within a workspace directory")),process.exit(1));let{syncWorkspaceProjects:i}=await Promise.resolve().then(()=>(X(),q));console.log(g.cyan(`\u{1F4C2} Scanning workspace: ${v.basename(e)}`)),await i(e);}else console.log(g.red(`Unknown workspace action: ${t}`)),console.log(g.gray("Available: list, sync")),process.exit(1);});function Vi(){console.log(g.white(`Usage:
|
|
1527
|
+
`)),console.log(g.cyan(" npx rapidkit <workspace-name> [options]")),console.log(g.cyan(` npx rapidkit create <...>
|
|
1528
|
+
`)),console.log(g.bold("Recommended workflow:")),console.log(g.cyan(" npx rapidkit my-workspace")),console.log(g.cyan(" cd my-workspace")),console.log(g.cyan(" npx rapidkit create project fastapi.standard my-api --output .")),console.log(g.cyan(" cd my-api")),console.log(g.cyan(` npx rapidkit init && npx rapidkit dev
|
|
1529
|
+
`)),console.log(g.bold("Options (workspace creation):")),console.log(g.gray(" -y, --yes Skip prompts and use defaults")),console.log(g.gray(" --skip-git Skip git initialization")),console.log(g.gray(" --debug Enable debug logging")),console.log(g.gray(" --dry-run Show what would be created")),console.log(g.gray(" --create-workspace When creating a project outside a workspace: create and register a workspace in the current directory")),console.log(g.gray(" --no-workspace When creating a project outside a workspace: do not create a workspace")),console.log(g.gray(` --no-update-check Skip checking for updates
|
|
1530
|
+
`)),console.log(g.gray(`Tip: set RAPIDKIT_SHOW_LEGACY=1 to show legacy template flags in help.
|
|
1531
|
+
`));}process.on("SIGINT",async()=>{if(!St){if(St=true,console.log(g.yellow(`
|
|
1532
|
+
|
|
1533
|
+
\u26A0\uFE0F Interrupted by user`)),Z&&await I.pathExists(Z)){console.log(g.gray("Cleaning up partial installation..."));try{await I.remove(Z),console.log(g.green("\u2713 Cleanup complete"));}catch(t){u.debug("Cleanup failed:",t);}}process.exit(130);}});process.on("SIGTERM",async()=>{if(!St){if(St=true,u.debug("Received SIGTERM"),Z&&await I.pathExists(Z))try{await I.remove(Z);}catch(t){u.debug("Cleanup failed:",t);}process.exit(143);}});Wi().then(async t=>{if(!t){let e=process.argv.slice(2);if(process.env.RAPIDKIT_NPM_DEBUG_ARGS==="1"&&process.stderr.write(`[rapidkit-npm] argv=${JSON.stringify(e)}
|
|
1534
|
+
`),e[0]==="create"){let o=await Ki(e);process.exit(o);}let i=await Gi(e);if(process.env.RAPIDKIT_NPM_DEBUG_ARGS==="1"&&process.stderr.write(`[rapidkit-npm] shouldForwardToCore=${i}
|
|
1535
|
+
`),i){let o=await B(e,{cwd:process.cwd()});process.exit(o);}tt.parse();}});export{Ki as handleCreateOrFallback};
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rapidkit",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Create RapidKit projects with a single command - The official CLI for RapidKit framework",
|
|
6
6
|
"keywords": [
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"chalk": "^5.3.0",
|
|
63
|
+
"cli-progress": "^3.12.0",
|
|
63
64
|
"commander": "^12.1.0",
|
|
64
65
|
"execa": "^9.3.1",
|
|
65
66
|
"fs-extra": "^11.2.0",
|
|
@@ -70,6 +71,7 @@
|
|
|
70
71
|
},
|
|
71
72
|
"devDependencies": {
|
|
72
73
|
"@eslint/eslintrc": "^3.3.3",
|
|
74
|
+
"@types/cli-progress": "^3.11.6",
|
|
73
75
|
"@types/fs-extra": "^11.0.4",
|
|
74
76
|
"@types/inquirer": "^9.0.7",
|
|
75
77
|
"@types/node": "^20.14.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rapidkit",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Create RapidKit projects with a single command - The official CLI for RapidKit framework",
|
|
6
6
|
"keywords": [
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"chalk": "^5.3.0",
|
|
63
|
+
"cli-progress": "^3.12.0",
|
|
63
64
|
"commander": "^12.1.0",
|
|
64
65
|
"execa": "^9.3.1",
|
|
65
66
|
"fs-extra": "^11.2.0",
|
|
@@ -70,6 +71,7 @@
|
|
|
70
71
|
},
|
|
71
72
|
"devDependencies": {
|
|
72
73
|
"@eslint/eslintrc": "^3.3.3",
|
|
74
|
+
"@types/cli-progress": "^3.11.6",
|
|
73
75
|
"@types/fs-extra": "^11.0.4",
|
|
74
76
|
"@types/inquirer": "^9.0.7",
|
|
75
77
|
"@types/node": "^20.14.0",
|