rapidkit 0.16.4 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +107 -33
- package/dist/index.js +131 -135
- package/dist/package.json +3 -1
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -313,6 +313,9 @@ npx rapidkit info module <name> # Module details
|
|
|
313
313
|
|
|
314
314
|
# System
|
|
315
315
|
npx rapidkit doctor # Diagnose environment
|
|
316
|
+
npx rapidkit doctor --workspace # Check entire workspace
|
|
317
|
+
npx rapidkit doctor --workspace --json # JSON output (CI/CD)
|
|
318
|
+
npx rapidkit doctor --workspace --fix # Auto-fix issues
|
|
316
319
|
npx rapidkit --version # Show version
|
|
317
320
|
npx rapidkit --tui # Launch interactive TUI
|
|
318
321
|
|
|
@@ -321,6 +324,42 @@ npx rapidkit workspace list # List workspaces
|
|
|
321
324
|
npx rapidkit workspace sync # Sync projects
|
|
322
325
|
```
|
|
323
326
|
|
|
327
|
+
### Doctor Command (Health Check)
|
|
328
|
+
|
|
329
|
+
The enhanced `doctor` command provides comprehensive health monitoring:
|
|
330
|
+
|
|
331
|
+
```bash
|
|
332
|
+
# System check (basic)
|
|
333
|
+
rapidkit doctor
|
|
334
|
+
|
|
335
|
+
# Workspace check (detailed)
|
|
336
|
+
rapidkit doctor --workspace
|
|
337
|
+
# ✅ Health score with visual progress bar
|
|
338
|
+
# ✅ System tools validation (Python, Poetry, pipx, Core)
|
|
339
|
+
# ✅ Project-level checks (venv, dependencies, modules)
|
|
340
|
+
# ✅ Environment file validation (.env)
|
|
341
|
+
# ✅ Module structure integrity
|
|
342
|
+
# ✅ Version compatibility warnings
|
|
343
|
+
# ✅ Actionable fix commands
|
|
344
|
+
|
|
345
|
+
# JSON output for CI/CD pipelines
|
|
346
|
+
rapidkit doctor --workspace --json
|
|
347
|
+
|
|
348
|
+
# Auto-fix common issues
|
|
349
|
+
rapidkit doctor --workspace --fix
|
|
350
|
+
# Interactive confirmation before applying fixes
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
**Features:**
|
|
354
|
+
- **Health Score**: Visual percentage with pass/warn/error breakdown
|
|
355
|
+
- **Fix Commands**: Project-specific commands to resolve issues
|
|
356
|
+
- **JSON Mode**: Machine-readable output for automation
|
|
357
|
+
- **Auto-Fix**: Apply fixes automatically with confirmation
|
|
358
|
+
- **Module Checks**: Validates `__init__.py` files
|
|
359
|
+
- **Environment Checks**: Detects missing `.env` files
|
|
360
|
+
- **Version Compatibility**: Warns about Core/CLI mismatches
|
|
361
|
+
```
|
|
362
|
+
|
|
324
363
|
### Workspace Commands
|
|
325
364
|
|
|
326
365
|
```bash
|
|
@@ -536,68 +575,103 @@ The registry stores workspace and project metadata:
|
|
|
536
575
|
|
|
537
576
|
## 📁 Project Structure
|
|
538
577
|
|
|
578
|
+
### Workspace
|
|
579
|
+
|
|
580
|
+
```
|
|
581
|
+
my-workspace/
|
|
582
|
+
├── my-api/ # FastAPI project
|
|
583
|
+
│ ├── .rapidkit/ # Project config
|
|
584
|
+
│ ├── src/ # Source code
|
|
585
|
+
│ ├── config/ # Configuration
|
|
586
|
+
│ ├── tests/ # Test suite
|
|
587
|
+
│ ├── pyproject.toml # Poetry config
|
|
588
|
+
│ └── Dockerfile # Docker setup
|
|
589
|
+
├── my-service/ # NestJS project
|
|
590
|
+
│ ├── .rapidkit/ # Project config
|
|
591
|
+
│ ├── src/ # Source code
|
|
592
|
+
│ ├── test/ # Test suite
|
|
593
|
+
│ ├── package.json # npm config
|
|
594
|
+
│ └── Dockerfile # Docker setup
|
|
595
|
+
├── .venv/ # Workspace Python environment
|
|
596
|
+
├── .rapidkit-workspace # Workspace metadata
|
|
597
|
+
├── poetry.lock # Locked Python dependencies
|
|
598
|
+
├── pyproject.toml # Workspace Python config
|
|
599
|
+
├── rapidkit # CLI script (bash)
|
|
600
|
+
├── rapidkit.cmd # CLI script (Windows)
|
|
601
|
+
├── README.md
|
|
602
|
+
└── Makefile
|
|
603
|
+
```
|
|
604
|
+
|
|
539
605
|
### FastAPI Project
|
|
540
606
|
|
|
541
607
|
```
|
|
542
608
|
my-api/
|
|
543
|
-
├── .rapidkit/
|
|
544
|
-
│ ├──
|
|
545
|
-
│ ├──
|
|
546
|
-
│ ├──
|
|
547
|
-
│ └──
|
|
548
|
-
├──
|
|
549
|
-
├──
|
|
550
|
-
│ ├──
|
|
551
|
-
│ ├── cli.py # CLI commands
|
|
552
|
-
│ ├── routing/ # API routes
|
|
609
|
+
├── .rapidkit/ # RapidKit config
|
|
610
|
+
│ ├── project.json # Project metadata
|
|
611
|
+
│ ├── context.json # Project context
|
|
612
|
+
│ ├── cli.py # Local CLI module
|
|
613
|
+
│ └── activate # Environment activation
|
|
614
|
+
├── src/ # Source code
|
|
615
|
+
│ ├── main.py # FastAPI entry point
|
|
616
|
+
│ ├── routing/ # API routes
|
|
553
617
|
│ │ ├── __init__.py
|
|
554
618
|
│ │ ├── health.py
|
|
555
619
|
│ │ └── examples.py
|
|
556
|
-
│ └── modules/
|
|
620
|
+
│ └── modules/ # Feature modules
|
|
557
621
|
│ └── __init__.py
|
|
558
|
-
├──
|
|
622
|
+
├── config/ # Configuration
|
|
623
|
+
├── tests/ # Test suite
|
|
559
624
|
│ ├── __init__.py
|
|
560
625
|
│ ├── test_health.py
|
|
561
626
|
│ └── test_examples.py
|
|
562
|
-
├──
|
|
563
|
-
├──
|
|
564
|
-
├── Dockerfile # Docker configuration
|
|
565
|
-
├── docker-compose.yml # Docker Compose
|
|
566
|
-
├── .env.example # Environment template
|
|
627
|
+
├── .github/ # GitHub workflows
|
|
628
|
+
├── .env.example # Environment template
|
|
567
629
|
├── .gitignore
|
|
630
|
+
├── bootstrap.sh # Setup script
|
|
631
|
+
├── docker-compose.yml # Docker Compose
|
|
632
|
+
├── Dockerfile # Docker configuration
|
|
633
|
+
├── Makefile # Make commands
|
|
634
|
+
├── poetry.lock # Locked dependencies
|
|
635
|
+
├── pyproject.toml # Poetry configuration
|
|
636
|
+
├── LICENSE
|
|
568
637
|
└── README.md
|
|
569
638
|
```
|
|
570
639
|
|
|
571
640
|
### NestJS Project
|
|
572
641
|
|
|
573
642
|
```
|
|
574
|
-
my-
|
|
575
|
-
├── .rapidkit/
|
|
576
|
-
│ ├──
|
|
577
|
-
│ ├──
|
|
578
|
-
│ └──
|
|
579
|
-
├──
|
|
580
|
-
├──
|
|
581
|
-
│ ├── main.ts # Application entry point
|
|
643
|
+
my-app/
|
|
644
|
+
├── .rapidkit/ # RapidKit config
|
|
645
|
+
│ ├── project.json # Project metadata
|
|
646
|
+
│ ├── context.json # Project context
|
|
647
|
+
│ └── cli.js # Local CLI module (optional)
|
|
648
|
+
├── src/ # Source code
|
|
649
|
+
│ ├── main.ts # NestJS entry point
|
|
582
650
|
│ ├── app.module.ts # Root module
|
|
583
651
|
│ ├── app.controller.ts # Root controller
|
|
584
652
|
│ ├── app.service.ts # Root service
|
|
585
|
-
│ ├── config/ # Configuration
|
|
653
|
+
│ ├── config/ # Configuration module
|
|
586
654
|
│ │ ├── configuration.ts
|
|
587
655
|
│ │ └── validation.ts
|
|
588
|
-
│ └── examples/ # Example module
|
|
656
|
+
│ └── examples/ # Example CRUD module
|
|
589
657
|
│ ├── examples.module.ts
|
|
590
658
|
│ ├── examples.controller.ts
|
|
591
659
|
│ └── examples.service.ts
|
|
592
|
-
├── test/ # Test
|
|
660
|
+
├── test/ # Test suite
|
|
593
661
|
│ ├── app.e2e-spec.ts
|
|
594
662
|
│ └── 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
|
|
663
|
+
├── .github/ # GitHub workflows
|
|
600
664
|
├── .env.example # Environment template
|
|
665
|
+
├── .gitignore
|
|
666
|
+
├── bootstrap.sh # Setup script
|
|
667
|
+
├── docker-compose.yml # Docker Compose
|
|
668
|
+
├── Dockerfile # Docker configuration
|
|
669
|
+
├── eslint.config.cjs # ESLint configuration
|
|
670
|
+
├── jest.config.ts # Jest configuration
|
|
671
|
+
├── nest-cli.json # NestJS CLI config
|
|
672
|
+
├── package.json # npm dependencies
|
|
673
|
+
├── tsconfig.json # TypeScript config
|
|
674
|
+
├── LICENSE
|
|
601
675
|
└── README.md
|
|
602
676
|
```
|
|
603
677
|
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
[${
|
|
4
|
-
\u26A0\uFE0F Update available: ${
|
|
5
|
-
`))):
|
|
6
|
-
`);};try{
|
|
7
|
-
`);};for(let
|
|
8
|
-
`).filter(
|
|
9
|
-
`),
|
|
10
|
-
${p}`:`${
|
|
2
|
+
import w from'path';import {fileURLToPath,pathToFileURL}from'url';import m from'chalk';import {execa}from'execa';import {createRequire}from'module';import*as z from'os';import z__default from'os';import*as k from'fs-extra';import k__default from'fs-extra';import F,{promises}from'fs';import kt from'ora';import {Command,Option}from'commander';import Jt from'inquirer';import {spawn}from'child_process';import Xe from'validate-npm-package-name';import _i from'nunjucks';import Ii from'crypto';var Le=Object.defineProperty;var st=(t,i)=>()=>(t&&(i=t(t=0)),i);var Nt=(t,i)=>{for(var e in i)Le(t,e,{get:i[e],enumerable:true});};var R=st(()=>{});var Dt,f,ct=st(()=>{R();Dt=class{debugEnabled=false;setDebug(i){this.debugEnabled=i;}debug(i,...e){this.debugEnabled&&console.log(m.gray(`[DEBUG] ${i}`),...e);}info(i,...e){console.log(m.blue(i),...e);}success(i,...e){console.log(m.green(i),...e);}warn(i,...e){console.log(m.yellow(i),...e);}error(i,...e){console.error(m.red(i),...e);}step(i,e,o){console.log(m.cyan(`
|
|
3
|
+
[${i}/${e}]`),m.white(o));}},f=new Dt;});async function ee(){try{f.debug("Checking for updates...");let{stdout:t}=await execa("npm",["view",He,"version"],{timeout:3e3}),i=t.trim();i&&i!==Tt?(console.log(m.yellow(`
|
|
4
|
+
\u26A0\uFE0F Update available: ${Tt} \u2192 ${i}`)),console.log(m.cyan(`Run: npm install -g rapidkit@latest
|
|
5
|
+
`))):f.debug("You are using the latest version");}catch{f.debug("Could not check for updates");}}function H(){return Tt}var He,Be,Je,Tt,gt=st(()=>{R();ct();He="rapidkit",Be=createRequire(import.meta.url),Je=Be("../package.json"),Tt=Je?.version??"0.0.0";});var Lt={};Nt(Lt,{__test__:()=>li,checkRapidkitCoreAvailable:()=>fe,getCachedCoreTopLevelCommands:()=>Vt,getCoreTopLevelCommands:()=>ci,resolveRapidkitPython:()=>ut,runCoreRapidkit:()=>B,runCoreRapidkitCapture:()=>Wt});function Kt(t){return t instanceof dt?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 oi(){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:w.join(z__default.homedir(),".cache")}function Ft(){return w.join(pe(),"rapidkit","npm-bridge","venv")}function se(t){return process.platform==="win32"?w.join(t,"Scripts","python.exe"):w.join(t,"bin","python")}function ce(t){return process.platform==="win32"?w.join(t,"Scripts","rapidkit.exe"):w.join(t,"bin","rapidkit")}function de(){return w.join(pe(),"rapidkit","npm-bridge","core-commands.json")}async function ue(t){let i=!!process.env.RAPIDKIT_DEBUG,e=o=>{i&&process.stderr.write(`[DEBUG] tryRapidkit(${t}): ${o}
|
|
6
|
+
`);};try{e("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(e(`script path: ${r}`),r)try{if(await k.pathExists(r)){e(`found script at ${r}; invoking --version --json`);let n=await execa(r,["--version","--json"],{reject:!1,stdio:"pipe",timeout:4e3});if(e(`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(e(`script JSON parse ok=${c}`),c)return !0}catch{e("script output not valid JSON");}}}}catch(n){e(`interpreter-specific script probe failed: ${String(n)}`);}}catch(o){e(`interpreter-specific script probe error: ${String(o)}`);}try{e('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(e(`import probe exitCode=${o.exitCode} stdout=${(o.stdout??"").toString().trim()}`),o.exitCode===0&&(o.stdout??"").toString().trim()==="1")return !0}catch(o){e(`import probe error: ${String(o)}`);}try{e("probing python -m rapidkit");let o=await execa(t,["-m","rapidkit","--version","--json"],{reject:!1,stdio:"pipe",timeout:8e3});if(e(`-m probe exitCode=${o.exitCode}`),o.exitCode===0)return !0}catch(o){e(`-m probe error: ${String(o)}`);}try{e("probing PATH for rapidkit executables");let o=(process.env.PATH??"").split(w.delimiter).filter(Boolean);for(let r of o){let n=w.join(r,process.platform==="win32"?"rapidkit.exe":"rapidkit");try{if(await k.pathExists(n)){e(`found candidate on PATH: ${n}; invoking --version --json`);let a=await execa(n,["--version","--json"],{reject:!1,stdio:"pipe",timeout:4e3});if(e(`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{e("candidate output not valid JSON, skipping");}}}}catch(a){e(`error probing candidate ${n}: ${String(a)}`);}}return e("no valid rapidkit found on PATH"),!1}catch(o){return e(`PATH probe error: ${String(o)}`),false}}async function Ot(t){let i=(t??"").toString().trim();if(!i)return false;try{let e=JSON.parse(i);return !!e&&typeof e=="object"&&e!==null&&"version"in e}catch{return false}}async function ni(t){let i=process.platform==="win32",e=i?w.join(".venv","Scripts","rapidkit.exe"):w.join(".venv","bin","rapidkit"),o=i?w.join(".venv","Scripts","python.exe"):w.join(".venv","bin","python"),r=t;for(let n=0;n<25;n+=1){let a=w.join(r,e);if(await k.pathExists(a)){let l=await execa(a,["--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:r});if(l.exitCode===0&&await Ot(l.stdout))return {cmd:a,baseArgs:[]}}let s=w.join(r,o);if(await k.pathExists(s)){let l=await execa(s,["-m","rapidkit","--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:r});if(l.exitCode===0&&await Ot(l.stdout))return {cmd:s,baseArgs:["-m","rapidkit"]}}let c=w.dirname(r);if(c===r)break;r=c;}return null}async function ri(t){try{let i=w.join(t,".python-version");if(await k.pathExists(i)){let o=(await k.readFile(i,"utf-8")).trim();if(o)return o}}catch{}try{let i=w.join(t,".rapidkit-workspace");if(await k.pathExists(i)){let e=await k.readFile(i,"utf-8"),o=JSON.parse(e);if(o.pythonVersion)return o.pythonVersion}}catch{}return null}async function me(t){if(t&&t.trim())try{let n=await ni(t);if(n){let a=w.dirname(n.cmd).includes(".venv")?w.dirname(w.dirname(w.dirname(n.cmd))):w.dirname(n.cmd),s=await ri(a);return s&&(process.env.PYENV_VERSION=s),n}}catch{}let i=await ut();if(i.kind==="venv"){let n=Ft(),a=ce(n);return await k.pathExists(a)?{cmd:a,baseArgs:[]}:{cmd:i.pythonPath,baseArgs:["-m","rapidkit"]}}try{if((await execa(i.cmd,["-m","rapidkit","--version","--json"],{reject:!1,stdio:"pipe",timeout:4e3})).exitCode===0)return {cmd:i.cmd,baseArgs:["-m","rapidkit"]}}catch{}try{let a=((await execa(i.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 k.pathExists(a))try{let s=await execa(a,["--version","--json"],{reject:!1,stdio:"pipe",timeout:4e3});if(s.exitCode===0&&await Ot(s.stdout))return {cmd:a,baseArgs:[]}}catch{}}catch{}let e=Ft(),o=await $t(i.cmd),r=ce(e);return await k.pathExists(r)?{cmd:r,baseArgs:[]}:{cmd:o,baseArgs:["-m","rapidkit"]}}async function Mt(){for(let t of ["python3","python"])try{return await execa(t,["--version"],{reject:!1,stdio:"pipe",timeout:2e3}),t}catch{}return null}async function fe(){let t=!!process.env.RAPIDKIT_DEBUG,i=e=>{t&&process.stderr.write(`[DEBUG] checkRapidkitCore: ${e}
|
|
7
|
+
`);};for(let e of ["python3","python","python3.10","python3.11","python3.12"])try{i(`Method 1: trying ${e} import`);let o=await execa(e,["-c","import rapidkit_core; print(1)"],{reject:!1,stdio:"pipe",timeout:3e3});if(o.exitCode===0&&o.stdout?.trim()==="1")return i(`\u2713 Found via ${e} import`),!0}catch{continue}for(let e of ["python3","python"])try{i(`Method 2: trying ${e} -m pip show`);let o=await execa(e,["-m","pip","show","rapidkit-core"],{reject:!1,stdio:"pipe",timeout:3e3});if(o.exitCode===0&&o.stdout?.includes("Name: rapidkit-core"))return i(`\u2713 Found via ${e} -m pip show`),!0}catch{continue}for(let e of ["pip","pip3"])try{i(`Method 3: trying ${e} show`);let o=await execa(e,["show","rapidkit-core"],{reject:!1,stdio:"pipe",timeout:3e3});if(o.exitCode===0&&o.stdout?.includes("Name: rapidkit-core"))return i(`\u2713 Found via ${e} show`),!0}catch{continue}try{i("Method 4: checking pyenv versions");let e=await execa("pyenv",["versions","--bare"],{reject:!1,stdio:"pipe",timeout:3e3});if(e.exitCode===0&&e.stdout){let o=e.stdout.split(`
|
|
8
|
+
`).filter(r=>r.trim());i(`Found pyenv versions: ${o.join(", ")}`);for(let r of o){let n=process.env.PYENV_ROOT||w.join(z__default.homedir(),".pyenv"),a=w.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 i(`\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 i(`\u2713 Found in pyenv ${r} via PYENV_VERSION`),!0}catch{continue}}}}}catch{i("pyenv not available");}for(let e of ["python3","python"])try{i(`Method 5: checking ${e} user site`);let o=await execa(e,["-m","site","--user-site"],{reject:!1,stdio:"pipe",timeout:3e3});if(o.exitCode===0&&o.stdout){let r=o.stdout.trim(),n=w.join(r,"rapidkit_core");if(await k.pathExists(n))return i("\u2713 Found in user site-packages"),!0}}catch{continue}try{i("Method 6: checking pipx");let e=await execa("pipx",["list"],{reject:!1,stdio:"pipe",timeout:3e3});if(e.exitCode===0&&e.stdout?.includes("rapidkit-core"))return i("\u2713 Found via pipx"),!0}catch{i("pipx not available");}try{if(i("Method 7: checking poetry"),(await execa("poetry",["show","rapidkit-core"],{reject:!1,stdio:"pipe",timeout:3e3})).exitCode===0)return i("\u2713 Found via poetry"),!0}catch{i("poetry check failed");}try{i("Method 8: checking conda");let e=await execa("conda",["list","rapidkit-core"],{reject:!1,stdio:"pipe",timeout:3e3});if(e.exitCode===0&&e.stdout?.includes("rapidkit-core"))return i("\u2713 Found via conda"),!0}catch{i("conda not available");}return i("\u2717 Not found in any environment"),false}async function $t(t){let i=Ft(),e=se(i);if(await k.pathExists(e))try{let n=await execa(e,["-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 e;await k.remove(i);}catch{await k.remove(i);}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(),l=(s.stderr??"").toString(),p=[c,l].filter(Boolean).join(`
|
|
9
|
+
`),d=p?`${n} ${a.join(" ")}
|
|
10
|
+
${p}`:`${n} ${a.join(" ")}`;throw new Error(d)};try{await k.ensureDir(w.dirname(i)),await r(t,["-m","venv",i]);let n=se(i);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
|
|
17
|
-
\u2705 Synced ${c} project(s) to registry`)):
|
|
18
|
-
\u2705 All projects already registered (${
|
|
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",oi()]),n}catch(n){throw new dt("BRIDGE_VENV_BOOTSTRAP_FAILED",Kt(n))}}async function ut(){if(process.env.RAPIDKIT_BRIDGE_FORCE_VENV==="1"){let e=await Mt();if(!e)throw new dt("PYTHON_NOT_FOUND","No Python interpreter found (python3/python).");return {kind:"venv",pythonPath:await $t(e)}}for(let e of ["python3","python"])if(await ue(e))return {kind:"system",cmd:e};let t=await Mt();if(!t)throw new dt("PYTHON_NOT_FOUND","No Python interpreter found (python3/python).");return {kind:"venv",pythonPath:await $t(t)}}async function B(t,i){try{let e=await me(i?.cwd),o=e.cmd,r=[...e.baseArgs,...t],n=await execa(o,r,{cwd:i?.cwd,env:{...process.env,...i?.env},reject:!1,stdio:"inherit"});return typeof n.exitCode=="number"?n.exitCode:1}catch(e){return process.stderr.write(`${Kt(e)}
|
|
13
|
+
`),1}}async function Wt(t,i){try{let e=await me(i?.cwd),o=e.cmd,r=[...e.baseArgs,...t],n=await execa(o,r,{cwd:i?.cwd,env:{...process.env,...i?.env},reject:!1,stdio:"pipe"});return {exitCode:typeof n.exitCode=="number"?n.exitCode:1,stdout:(n.stdout??"").toString(),stderr:(n.stderr??"").toString()}}catch(e){return {exitCode:1,stdout:"",stderr:`${Kt(e)}
|
|
14
|
+
`}}}function ge(t){let i=new Set,e=t.split(`
|
|
15
|
+
`),o=false;for(let r of e){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 l=c[1].trim();l&&!l.startsWith("-")&&i.add(l);}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("-")&&i.add(s);}return i}async function he(){let t=de();if(!await k.pathExists(t))return null;try{let i=await k.readJson(t);if(i&&i.schema_version===1&&Array.isArray(i.commands))return i}catch{}return null}async function ai(t){let i=de();await k.ensureDir(w.dirname(i)),await k.writeJson(i,t,{spaces:2});}async function si(){let t=await Wt(["version","--json"],{cwd:process.cwd()});if(t.exitCode===0)try{let e=JSON.parse(t.stdout)?.version;return typeof e=="string"?e:void 0}catch{return}}async function ci(){let i=Date.now(),e=await he(),o=await si(),r=!!e?.commands?.length;if(r&&i-e.fetched_at<864e5&&(!o||!e.rapidkit_version||e.rapidkit_version===o))return new Set(e.commands);let n=await Wt(["--help"],{cwd:process.cwd()});if(n.exitCode!==0)return r&&e?.commands?new Set(e.commands):new Set;let a=ge(n.stdout);if(a.size===0)return new Set;let s=Array.from(a).sort();return await ai({schema_version:1,fetched_at:i,rapidkit_version:o,commands:s}),a}async function Vt(){let i=Date.now(),e=await he();return !e||i-e.fetched_at>=864e5||!e.commands?.length?null:new Set(e.commands)}var dt,li,Pt=st(()=>{R();dt=class extends Error{code;constructor(i,e){super(e),this.code=i;}};li={pickSystemPython:Mt,ensureBridgeVenv:$t,parseCoreCommandsFromHelp:ge,tryRapidkit:ue,checkRapidkitCoreAvailable:fe};});var ke={};Nt(ke,{createNpmWorkspaceMarker:()=>Ut,isValidWorkspaceMarker:()=>ui,readWorkspaceMarker:()=>Gt,updateWorkspaceMetadata:()=>di,writeWorkspaceMarker:()=>Ct});async function Gt(t){let i=w.join(t,".rapidkit-workspace");try{if(await k.pathExists(i))return await k.readJson(i)}catch{return null}return null}async function Ct(t,i){let e=w.join(t,".rapidkit-workspace"),o=await Gt(t);o?.metadata&&(i.metadata={...o.metadata,...i.metadata}),await k.outputFile(e,JSON.stringify(i,null,2)+`
|
|
16
|
+
`,"utf-8");}async function di(t,i){let e=await Gt(t);return e?(e.metadata={...e.metadata,...i,vscode:i.vscode?{...e.metadata?.vscode,...i.vscode}:e.metadata?.vscode,npm:i.npm?{...e.metadata?.npm,...i.npm}:e.metadata?.npm,python:i.python?{...e.metadata?.python,...i.python}:e.metadata?.python},await Ct(t,e),true):false}function Ut(t,i,e){return {signature:"RAPIDKIT_WORKSPACE",createdBy:"rapidkit-npm",version:i,createdAt:new Date().toISOString(),name:t,metadata:{npm:{packageVersion:i,installMethod:e,lastUsedAt:new Date().toISOString()}}}}function ui(t){if(!t||typeof t!="object")return false;let i=t;return i.signature==="RAPIDKIT_WORKSPACE"&&typeof i.createdBy=="string"&&typeof i.version=="string"&&typeof i.createdAt=="string"&&typeof i.name=="string"}var Ht=st(()=>{R();});var q={};Nt(q,{createProject:()=>ki,createWorkspace:()=>gi,listWorkspaces:()=>xi,registerProjectInWorkspace:()=>fi,registerWorkspace:()=>ve,syncWorkspaceProjects:()=>mi});async function ve(t,i){try{let e=process.env.XDG_CONFIG_HOME||process.env.APPDATA||w.join(z__default.homedir(),".config"),o=process.platform==="win32"?w.join(e,"rapidkit"):w.join(z__default.homedir(),".rapidkit"),r=w.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:i,path:t,mode:"full",projects:[]}),await promises.writeFile(r,JSON.stringify(n,null,2)));}catch{console.warn(m.gray("Note: Could not register workspace in shared registry"));}}async function mi(t,i=false){try{let e=process.env.XDG_CONFIG_HOME||process.env.APPDATA||w.join(z__default.homedir(),".config"),o=process.platform==="win32"?w.join(e,"rapidkit"):w.join(z__default.homedir(),".rapidkit"),r=w.join(o,"workspaces.json"),n={workspaces:[]};try{let p=await promises.readFile(r,"utf8"),d=JSON.parse(p);d&&Array.isArray(d.workspaces)&&(n=d);}catch{i||console.log("\u26A0\uFE0F Workspace registry not found");return}let a=n.workspaces.find(p=>p.path===t);if(!a){i||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,l=0;for(let p of s)if(p.isDirectory()&&!p.name.startsWith(".")){let d=w.join(t,p.name),u=w.join(d,".rapidkit","context.json"),h=w.join(d,".rapidkit","project.json");try{let y=!1;try{await promises.access(u),y=!0;}catch{await promises.access(h),y=!0;}y&&(a.projects.some(A=>A.path===d||A.name===p.name)?l++:(a.projects.push({name:p.name,path:d}),c++,i||console.log(`\u2714 Added: ${p.name}`)));}catch{}}c>0?(await promises.writeFile(r,JSON.stringify(n,null,2)),i||console.log(`
|
|
17
|
+
\u2705 Synced ${c} project(s) to registry`)):i||console.log(`
|
|
18
|
+
\u2705 All projects already registered (${l} found)`);}catch(e){i||console.error("\u274C Failed to sync projects:",e.message);}}async function fi(t,i,e){try{let o=process.env.XDG_CONFIG_HOME||process.env.APPDATA||w.join(z__default.homedir(),".config"),r=process.platform==="win32"?w.join(o,"rapidkit"):w.join(z__default.homedir(),".rapidkit"),n=w.join(r,"workspaces.json");console.log(`[REGISTRY DEBUG] Registry file: ${n}`);let a={workspaces:[]};try{let l=await promises.readFile(n,"utf8"),p=JSON.parse(l);p&&Array.isArray(p.workspaces)&&(a=p),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(l=>l.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(l=>l.path===e||l.name===i)?console.log("[REGISTRY DEBUG] Project already exists in registry"):(console.log("[REGISTRY DEBUG] Adding project to registry"),s.projects.push({name:i,path:e}),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 gi(t,i){let e=kt("Creating RapidKit workspace...").start();try{await promises.mkdir(t,{recursive:!0}),await promises.mkdir(w.join(t,".rapidkit"),{recursive:!0});let o={workspace_name:i.name,author:i.author,rapidkit_version:H(),created_at:new Date().toISOString(),type:"workspace"};await promises.writeFile(w.join(t,".rapidkit","config.json"),JSON.stringify(o,null,2));let r=hi();await promises.writeFile(w.join(t,"rapidkit"),r),await promises.chmod(w.join(t,"rapidkit"),493);let n=yi(i.name);if(await promises.writeFile(w.join(t,"README.md"),n),await promises.writeFile(w.join(t,".gitignore"),`# RapidKit workspace
|
|
19
19
|
.env
|
|
20
20
|
.env.*
|
|
21
21
|
!.env.example
|
|
@@ -30,7 +30,7 @@ Thumbs.db
|
|
|
30
30
|
|
|
31
31
|
# Logs
|
|
32
32
|
*.log
|
|
33
|
-
`),await promises.writeFile(
|
|
33
|
+
`),await promises.writeFile(w.join(t,".rapidkit-workspace"),JSON.stringify({signature:"RAPIDKIT_WORKSPACE",createdBy:"rapidkit-npm",version:H(),createdAt:new Date().toISOString(),name:i.name},null,2)),await wi(t),e.succeed("Workspace created!"),!i.skipGit){let s=kt("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 ve(t,i.name),console.log(`
|
|
34
34
|
${m.green("\u2728 RapidKit workspace created successfully!")}
|
|
35
35
|
|
|
36
36
|
${m.bold("\u{1F4C2} Workspace structure:")}
|
|
@@ -42,7 +42,7 @@ ${t}/
|
|
|
42
42
|
\u2514\u2500\u2500 README.md
|
|
43
43
|
|
|
44
44
|
${m.bold("\u{1F680} Get started:")}
|
|
45
|
-
${m.cyan(`cd ${
|
|
45
|
+
${m.cyan(`cd ${i.name}`)}
|
|
46
46
|
${m.cyan("npx rapidkit my-api --template fastapi")}
|
|
47
47
|
${m.cyan("cd my-api")}
|
|
48
48
|
${m.cyan("npx rapidkit init")}
|
|
@@ -60,7 +60,7 @@ ${m.bold("\u{1F4DA} Commands:")}
|
|
|
60
60
|
|
|
61
61
|
${m.gray("Alternative: ./rapidkit dev, make dev")}
|
|
62
62
|
${m.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
|
|
63
|
-
`);}catch(
|
|
63
|
+
`);}catch(o){throw e.fail("Failed to create workspace"),o}}function hi(){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${H()}"
|
|
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 yi(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 wi(t){let{fileURLToPath:i}=await import('url'),e=i(import.meta.url),o=w.dirname(e),r=w.resolve(o,".."),n=w.join(r,"templates","kits"),a=w.join(t,".rapidkit","templates"),{default:s}=await import('fs-extra');await s.copy(n,a);let c=w.join(r,"templates","generator.js"),l=w.join(t,".rapidkit","generator.js");await s.copy(c,l);}async function ki(t,i){let e=i.template==="fastapi",o=e?"FastAPI":"NestJS",r=kt(`Creating ${o} project...`).start();try{let{fileURLToPath:n}=await import('url'),a=n(import.meta.url),s=w.dirname(a),c=w.resolve(s,".."),l=e?"fastapi-standard":"nestjs-standard",p=w.join(c,"templates","kits",l);await promises.mkdir(t,{recursive:!0});let d={project_name:e?i.name.replace(/-/g,"_").toLowerCase():i.name.replace(/_/g,"-").toLowerCase(),author:i.author,description:i.description||`${o} application generated with RapidKit`,app_version:"0.1.0",license:"MIT",package_manager:i.package_manager||"npm",created_at:new Date().toISOString(),rapidkit_version:H()};await xe(p,t,d);let u=e?`# Python
|
|
460
460
|
__pycache__/
|
|
461
461
|
*.py[cod]
|
|
462
462
|
*$py.class
|
|
@@ -524,7 +524,7 @@ Thumbs.db
|
|
|
524
524
|
|
|
525
525
|
# Coverage
|
|
526
526
|
coverage/
|
|
527
|
-
`;if(await promises.writeFile(
|
|
527
|
+
`;if(await promises.writeFile(w.join(t,".gitignore"),u),r.succeed(`${o} project created!`),!i.skipGit){let y=kt("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}),y.succeed("Git repository initialized");}catch{y.warn("Could not initialize git repository");}}if(!i.skipInstall&&!e){let y=i.package_manager||"npm",x=kt(`Installing dependencies with ${y}...`).start();try{await execa(y,["install"],{cwd:t}),x.succeed("Dependencies installed");}catch{x.warn(`Could not install dependencies. Run '${y} install' manually.`);}}let h=w.basename(t);console.log(e?`
|
|
528
528
|
${m.green("\u2728 FastAPI project created successfully!")}
|
|
529
529
|
|
|
530
530
|
${m.bold("\u{1F4C2} Project structure:")}
|
|
@@ -540,7 +540,7 @@ ${t}/
|
|
|
540
540
|
\u2514\u2500\u2500 README.md
|
|
541
541
|
|
|
542
542
|
${m.bold("\u{1F680} Get started:")}
|
|
543
|
-
${m.cyan(`cd ${
|
|
543
|
+
${m.cyan(`cd ${h}`)}
|
|
544
544
|
${m.cyan("npx rapidkit init")} ${m.gray("# Install dependencies")}
|
|
545
545
|
${m.cyan("npx rapidkit dev")} ${m.gray("# Start dev server")}
|
|
546
546
|
|
|
@@ -570,8 +570,8 @@ ${t}/
|
|
|
570
570
|
\u2514\u2500\u2500 README.md
|
|
571
571
|
|
|
572
572
|
${m.bold("\u{1F680} Get started:")}
|
|
573
|
-
${m.cyan(`cd ${
|
|
574
|
-
${
|
|
573
|
+
${m.cyan(`cd ${h}`)}
|
|
574
|
+
${i.skipInstall?m.cyan("npx rapidkit init")+m.gray(" # npm install")+`
|
|
575
575
|
`:""}${m.cyan("cp .env.example .env")}
|
|
576
576
|
${m.cyan("npx rapidkit dev")} ${m.gray("# Start dev server")}
|
|
577
577
|
|
|
@@ -590,37 +590,37 @@ ${m.bold("\u{1F310} API endpoints:")}
|
|
|
590
590
|
http://localhost:8000/examples/notes # Example API
|
|
591
591
|
|
|
592
592
|
${m.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
|
|
593
|
-
`);}catch(
|
|
593
|
+
`);}catch(n){throw r.fail(`Failed to create ${o} project`),n}}async function xe(t,i,e){let o=await promises.readdir(t,{withFileTypes:true});for(let r of o){let n=w.join(t,r.name),a=r.name.replace(/\.j2$/,""),s=w.join(i,a);if(r.isDirectory())await promises.mkdir(s,{recursive:true}),await xe(n,s,e);else {let c=await promises.readFile(n,"utf-8");r.name.endsWith(".j2")&&(c=vi(c,e)),await promises.writeFile(s,c),(a==="rapidkit"||a==="activate"||a.endsWith(".py")&&s.includes(".rapidkit"))&&await promises.chmod(s,493);}}}function vi(t,i){let e=t;for(let[o,r]of Object.entries(i)){let n=new RegExp(`\\{\\{\\s*${o}\\s*\\}\\}`,"g");e=e.replace(n,String(r));let a=new RegExp(`\\{\\{\\s*${o}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\}\\}`,"g");e=e.replace(a,(l,p,d)=>String(r).replace(new RegExp(p,"g"),d));let s=new RegExp(`\\{\\{\\s*${o}\\s*\\|\\s*lower\\s*\\}\\}`,"g");e=e.replace(s,String(r).toLowerCase());let c=new RegExp(`\\{\\{\\s*${o}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\|\\s*lower\\s*\\}\\}`,"g");e=e.replace(c,(l,p,d)=>String(r).replace(new RegExp(p,"g"),d).toLowerCase());}return e}async function xi(){let t=process.env.XDG_CONFIG_HOME||process.env.APPDATA||w.join(z__default.homedir(),".config"),i=process.platform==="win32"?w.join(t,"rapidkit"):w.join(z__default.homedir(),".rapidkit"),e=w.join(i,"workspaces.json");if(!await promises.stat(e).catch(()=>null)){console.log(m.yellow(`
|
|
594
594
|
\u26A0\uFE0F No workspaces registered yet.
|
|
595
595
|
`)),console.log(m.gray(`Create a workspace with: npx rapidkit <workspace-name>
|
|
596
|
-
`));return}try{let
|
|
596
|
+
`));return}try{let o=await promises.readFile(e,"utf8"),r=JSON.parse(o);if(!r.workspaces||r.workspaces.length===0){console.log(m.yellow(`
|
|
597
597
|
\u26A0\uFE0F No workspaces registered yet.
|
|
598
598
|
`));return}console.log(m.bold(`
|
|
599
599
|
\u{1F4E6} Registered RapidKit Workspaces:
|
|
600
|
-
`));for(let
|
|
601
|
-
`));}catch(
|
|
602
|
-
\u274C Failed to read workspace registry`)),console.error(m.gray(String(
|
|
600
|
+
`));for(let n of r.workspaces)console.log(m.cyan(` ${n.name}`)),console.log(m.gray(` Path: ${n.path}`)),console.log(m.gray(` Projects: ${n.projects?.length||0}`)),await promises.stat(n.path).catch(()=>null)||console.log(m.red(" \u26A0\uFE0F Path not found")),console.log();console.log(m.gray(`Total: ${r.workspaces.length} workspace(s)
|
|
601
|
+
`));}catch(o){console.error(m.red(`
|
|
602
|
+
\u274C Failed to read workspace registry`)),console.error(m.gray(String(o)));}}var Q=st(()=>{R();gt();});R();ct();gt();R();ct();var qe=".rapidkitrc.json",Qe=["rapidkit.config.js","rapidkit.config.mjs","rapidkit.config.cjs"];async function ht(){let t=w.join(z__default.homedir(),qe);try{let i=await promises.readFile(t,"utf-8"),e=JSON.parse(i);return f.debug(`Loaded config from ${t}`),e}catch{return f.debug("No user config found, using defaults"),{}}}async function oe(t=process.cwd()){let i=t,e=w.parse(i).root;for(;i!==e;){for(let o of Qe){let r=w.join(i,o);try{await promises.access(r),f.debug(`Found config file: ${r}`);let a=await import(pathToFileURL(r).href),s=a.default||a;return f.debug(`Loaded RapidKit config from ${o}`),s}catch{continue}}i=w.dirname(i);}return f.debug("No RapidKit config file found, using defaults"),{}}function ne(t,i,e){return {author:e.author||i.workspace?.defaultAuthor||t.author,pythonVersion:i.workspace?.pythonVersion||t.pythonVersion,defaultInstallMethod:e.defaultInstallMethod||i.workspace?.installMethod||t.defaultInstallMethod,defaultKit:e.defaultKit||i.projects?.defaultKit||t.defaultKit,skipGit:e.skipGit??i.projects?.skipGit??t.skipGit,license:e.license||t.license,testRapidKitPath:e.testRapidKitPath||t.testRapidKitPath}}function jt(t){return process.env.RAPIDKIT_DEV_PATH||t.testRapidKitPath||void 0}R();R();var G=class extends Error{constructor(e,o,r){super(e);this.code=o;this.details=r;this.name="RapidKitError",Error.captureStackTrace(this,this.constructor);}},lt=class extends G{constructor(i,e){let o=e?`Python ${i}+ required, found ${e}`:`Python ${i}+ not found`;super(o,"PYTHON_NOT_FOUND","Please install Python from https://www.python.org/downloads/");}},yt=class extends G{constructor(){super("Poetry is not installed","POETRY_NOT_FOUND","Install Poetry from https://python-poetry.org/docs/#installation");}},wt=class extends G{constructor(){super("pipx is not installed","PIPX_NOT_FOUND","Install pipx from https://pypa.github.io/pipx/installation/");}},bt=class extends G{constructor(i){super(`Directory "${i}" already exists`,"DIRECTORY_EXISTS","Please choose a different name or remove the existing directory");}},Y=class extends G{constructor(i,e){super(`Invalid project name: "${i}"`,"INVALID_PROJECT_NAME",e);}},M=class extends G{constructor(i,e){let o=`Installation failed at: ${i}`,r=`${e.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 i=Xe(t);if(!i.validForNewPackages){let o=i.errors||[],r=i.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}R();function ti(t){return typeof t=="object"&&t!==null}async function ei(t,i,e,o=8e3){try{let r=await execa(t,i,{cwd:e,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 ii(t,i){let e=["-m","rapidkit",...t],o=["python3","python"];for(let r of o){let n=await ei(r,e,i?.cwd,i?.timeoutMs);if(!n.ok)continue;let a=(n.stdout??"").trim();try{let s=JSON.parse(a);return ti(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 ae(t,i){let e=await ii(["project","detect","--path",t,"--json"],i);return !e.ok||!e.data||e.data.schema_version!==1?{ok:false,command:e.command,exitCode:e.exitCode,stdout:e.stdout,stderr:e.stderr}:e}Pt();R();var pi=["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"],ye=new Set(pi);R();ct();gt();R();function Rt(){return process.platform==="win32"?"python":"python3"}Ht();async function $e(t,i,e,o){let r=Ut(i,H(),e);o&&(r.metadata||(r.metadata={}),r.metadata.python={version:o}),await Ct(t,r);}async function Pe(t){await k.outputFile(w.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 je(t){try{let{stdout:i}=await execa(t,["--version"],{timeout:3e3}),e=i.match(/Python (\d+\.\d+\.\d+)/);if(e)return e[1]}catch{}return null}async function ji(t,i){try{await promises.writeFile(w.join(t,".python-version"),`${i}
|
|
619
|
+
`,"utf-8"),f.debug(`Created .python-version with ${i}`);}catch(e){f.warn(`Failed to create .python-version: ${e}`);}}function vt(){let t=w.join(z.homedir(),".local","bin"),e=(process.env.PATH||"").split(w.delimiter).filter(Boolean);e.includes(t)||(process.env.PATH=[t,...e].join(w.delimiter));}async function _t(t,i){vt(),t.start("Checking pipx installation");try{return await execa("pipx",["--version"]),t.succeed("pipx found"),{kind:"binary"}}catch{}let e=Rt();try{return await execa(e,["-m","pipx","--version"]),t.succeed("pipx found"),{kind:"python-module",pythonCmd:e}}catch{}if(i)throw new wt;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 wt;t.start("Installing pipx (user install)");try{try{await execa(e,["-m","pip","install","--user","--upgrade","pip"]);}catch{}await execa(e,["-m","pip","install","--user","--upgrade","pipx"]);}catch(r){let n=r,a=String(n?.stderr||n?.shortMessage||n?.message||"");throw new M("Install pipx with python -m pip",r instanceof Error?r:new Error(a))}t.succeed("pipx installed"),vt();try{return await execa(e,["-m","pipx","--version"]),{kind:"python-module",pythonCmd:e}}catch(r){let n=r,a=String(n?.stderr||n?.shortMessage||n?.message||"pipx not runnable after install");throw new M("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 ft(t,i){return t.kind==="binary"?execa("pipx",i):execa(t.pythonCmd,["-m","pipx",...i])}async function bi(t,i){vt(),t.start("Checking Poetry installation");try{await execa("poetry",["--version"]),t.succeed("Poetry found");return}catch{}if(i)throw new yt;let{installPoetry:e}=await Jt.prompt([{type:"confirm",name:"installPoetry",message:"Poetry is not installed. Install it now using pipx?",default:true}]);if(!e)throw new yt;let o=await _t(t,i);t.start("Installing Poetry with pipx");try{await ft(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 ft(o,["upgrade","poetry"]);}catch{}else throw new M("Install Poetry with pipx",r instanceof Error?r:new Error(a))}t.succeed("Poetry installed"),vt();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 M("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 $i(t){let i=t==="poetry";return `#!/usr/bin/env sh
|
|
624
624
|
set -eu
|
|
625
625
|
|
|
626
626
|
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
@@ -630,16 +630,16 @@ if [ -x "$VENV_RAPIDKIT" ]; then
|
|
|
630
630
|
exec "$VENV_RAPIDKIT" "$@"
|
|
631
631
|
fi
|
|
632
632
|
|
|
633
|
-
${
|
|
633
|
+
${i?`if command -v poetry >/dev/null 2>&1 && [ -f "$SCRIPT_DIR/pyproject.toml" ]; then
|
|
634
634
|
exec poetry run rapidkit "$@"
|
|
635
635
|
fi
|
|
636
636
|
|
|
637
637
|
`:""}echo "RapidKit launcher could not find a local Python CLI." 1>&2
|
|
638
638
|
echo "- If you used venv: ensure .venv exists (or re-run the installer)." 1>&2
|
|
639
|
-
${
|
|
639
|
+
${i?`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 Pi(t){return `@echo off
|
|
643
643
|
setlocal
|
|
644
644
|
|
|
645
645
|
set "SCRIPT_DIR=%~dp0"
|
|
@@ -658,48 +658,48 @@ 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,i){await k.outputFile(w.join(t,"rapidkit"),$i(i),{encoding:"utf-8",mode:493}),await k.outputFile(w.join(t,"rapidkit.cmd"),Pi(i),"utf-8");}async function Ce(t,i){let{skipGit:e=false,testMode:o=false,demoMode:r=false,dryRun:n=false,yes:a=false,userConfig:s={},installMethod:c}=i,l=t||"rapidkit",p=w.resolve(process.cwd(),l);if(await k.pathExists(p))throw new bt(l);if(n){await Ci(p,l,r,s);return}if(r){await Ri(p,l,e);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"}]);f.step(1,3,"Setting up RapidKit environment");let u=kt("Creating directory").start();try{await k.ensureDir(p),u.succeed("Directory created"),u.start("Detecting Python version");let h=null,y=await _e(d.pythonVersion);if(y)h=await je(y),h?(f.info(`Detected Python ${h}`),u.succeed(`Python ${h} detected`)):u.warn("Could not detect exact Python version");else {let x=Rt();h=await je(x),h?u.succeed(`Python ${h} detected`):u.warn("Could not detect Python version, proceeding with defaults");}if(await $e(p,l,d.installMethod,h||void 0),h&&await ji(p,h),await Pe(p),d.installMethod==="poetry")try{await Ee(p,d.pythonVersion,u,o,s,a);}catch(x){let A=x?.details||x?.message||String(x);if(A.includes("pyenv")||A.includes("exit status 127")||A.includes("returned non-zero exit status 127")){u.warn("Poetry encountered Python discovery issues, trying venv method"),f.debug(`Poetry error (attempting venv fallback): ${A}`);try{await Bt(p,d.pythonVersion,u,o,s),d.installMethod="venv";}catch(O){throw O}}else throw x}else d.installMethod==="venv"?await Bt(p,d.pythonVersion,u,o,s):await Ie(p,u,o,s,a);if(await Re(p,d.installMethod),await Se(p,d.installMethod),u.succeed("RapidKit environment ready!"),!i.skipGit){u.start("Initializing git repository");try{await execa("git",["init"],{cwd:p}),await execa("git",["add","."],{cwd:p}),await execa("git",["commit","-m","Initial commit: RapidKit environment"],{cwd:p}),u.succeed("Git repository initialized");}catch{u.warn("Could not initialize git repository");}}try{let{registerWorkspace:x}=await Promise.resolve().then(()=>(Q(),q));await x(p,l);}catch{console.warn(m.gray("Note: Could not register workspace in shared registry"));}if(console.log(m.green(`
|
|
662
662
|
\u2728 RapidKit environment created successfully!
|
|
663
663
|
`)),console.log(m.cyan("\u{1F4C2} Location:"),m.white(p)),console.log(m.cyan(`\u{1F680} Get started:
|
|
664
|
-
`)),console.log(m.white(` cd ${
|
|
664
|
+
`)),console.log(m.white(` cd ${l}`)),d.installMethod==="poetry"){let x="source $(poetry env info --path)/bin/activate";try{vt();let{stdout:A}=await execa("poetry",["--version"]),D=A.match(/Poetry.*?(\d+)\.(\d+)/);D&&(parseInt(D[1])>=2?x="source $(poetry env info --path)/bin/activate":x="poetry shell");}catch{}console.log(m.white(` ${x} # Or: poetry run rapidkit`)),console.log(m.white(" rapidkit create # Interactive mode")),console.log(m.white(" cd <project-name> && rapidkit init && rapidkit dev"));}else d.installMethod==="venv"?(console.log(m.white(" source .venv/bin/activate # On Windows: .venv\\Scripts\\activate")),console.log(m.white(" rapidkit create # Interactive mode")),console.log(m.white(" cd <project-name> && rapidkit init && rapidkit dev"))):(console.log(m.white(" rapidkit create # Interactive mode")),console.log(m.white(" cd <project-name> && rapidkit init && rapidkit dev")));console.log(m.white(`
|
|
665
665
|
\u{1F4A1} For more information, check the README.md file.`)),console.log(m.cyan(`
|
|
666
666
|
\u{1F4DA} RapidKit commands:`)),console.log(m.white(" rapidkit create - Create a new project (interactive)")),console.log(m.white(" rapidkit dev - Run development server")),console.log(m.white(" rapidkit add module <name> - Add a module (e.g., settings)")),console.log(m.white(" rapidkit list - List available kits")),console.log(m.white(" rapidkit modules - List available modules")),console.log(m.white(` rapidkit --help - Show all commands
|
|
667
|
-
`));}catch(
|
|
668
|
-
\u274C Error:`),
|
|
669
|
-
package-mode = false`):
|
|
667
|
+
`));}catch(h){u.fail("Failed to create RapidKit environment"),console.error(m.red(`
|
|
668
|
+
\u274C Error:`),h);try{await k.remove(p);}catch{}throw h}}async function _e(t){let i=[];try{let{stdout:e}=await execa("pyenv",["root"]),o=e.trim();i.push(w.join(o,"versions",`${t}.*`,"bin","python"));let[r,n]=t.split(".");i.push(w.join(o,"versions",`${r}.${n}.*`,"bin","python"));}catch{}i.push(`python${t}`,`python3.${t.split(".")[1]}`,"python3","python"),i.push(`/usr/bin/python${t}`,"/usr/bin/python3",`/usr/local/bin/python${t}`,"/usr/local/bin/python3");for(let e of i)try{let o=e;if(e.includes("*")){if(o=(await execa("sh",["-c",`ls -d ${e} 2>/dev/null | head -1`])).stdout.trim(),!o)continue;o=w.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 Ee(t,i,e,o,r,n=false){await bi(e,n),e.start("Finding Python interpreter");let a=await _e(i);a?(f.debug(`Found working Python: ${a}`),e.succeed("Python found")):e.warn("Could not verify Python path, proceeding with default"),e.start("Initializing Poetry project"),await execa("poetry",["init","--no-interaction","--python",`^${i}`],{cwd:t}),e.succeed("Poetry project initialized");let s=w.join(t,"pyproject.toml"),l=await promises.readFile(s,"utf-8");l.includes("[tool.poetry]")?l=l.replace("[tool.poetry]",`[tool.poetry]
|
|
669
|
+
package-mode = false`):l.includes("[project]")&&(l.includes("[build-system]")?l=l.replace("[build-system]",`
|
|
670
670
|
[tool.poetry]
|
|
671
671
|
package-mode = false
|
|
672
672
|
|
|
673
|
-
[build-system]`):
|
|
673
|
+
[build-system]`):l+=`
|
|
674
674
|
|
|
675
675
|
[tool.poetry]
|
|
676
676
|
package-mode = false
|
|
677
|
-
`),await promises.writeFile(s,
|
|
677
|
+
`),await promises.writeFile(s,l,"utf-8"),e.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}),f.debug(`Poetry configured to use: ${a}`);}catch(p){f.debug(`Could not set Poetry env to ${a}: ${p}`);}e.succeed("Poetry configured");}catch{e.warn("Could not configure Poetry virtualenvs.in-project");}e.start("Creating virtualenv");try{await execa("poetry",["install","--no-root"],{cwd:t,timeout:3e4}),e.succeed("Virtualenv created");}catch(p){f.debug(`Failed to create virtualenv: ${p}`),e.warn("Could not create virtualenv, proceeding with add command");}if(e.start("Installing RapidKit"),o){let p=jt(r||{});if(!p)throw new M("Test mode installation",new Error("No local RapidKit path configured. Set RAPIDKIT_DEV_PATH environment variable."));f.debug(`Installing from local path: ${p}`),e.text="Installing RapidKit from local path (test mode)",await execa("poetry",["add",p],{cwd:t});}else {e.text="Installing RapidKit from PyPI";let p=false,d=null;for(let u=1;u<=3;u++)try{await execa("poetry",["add","rapidkit-core"],{cwd:t,timeout:6e4*u}),p=!0;break}catch(h){d=h,f.debug(`Poetry add attempt ${u} failed: ${h}`),u<3&&(e.text=`Retrying installation (attempt ${u+1}/3)`,await new Promise(y=>setTimeout(y,2e3)));}if(!p){let u=d?.stderr||d?.message||"Unknown error";throw f.debug(`All Poetry install attempts failed. Last error: ${u}`),u.includes("Could not find")||u.includes("No matching distribution")?new pt:new M("Install rapidkit-core with Poetry",new Error(`Failed to install rapidkit-core after 3 attempts.
|
|
678
678
|
Error: ${u}
|
|
679
679
|
|
|
680
680
|
Possible solutions:
|
|
681
681
|
1. Check your internet connection
|
|
682
|
-
2. Try installing manually: cd ${
|
|
683
|
-
3. Use venv method instead: npx rapidkit ${
|
|
682
|
+
2. Try installing manually: cd ${w.basename(t)} && poetry add rapidkit-core
|
|
683
|
+
3. Use venv method instead: npx rapidkit ${w.basename(t)} --install-method=venv`))}}e.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:p}=await Promise.resolve().then(()=>(Pt(),Lt));if(!await p()&&!o){e.start("Installing RapidKit globally with pipx for CLI access");let u=await _t(e,n);try{await ft(u,["install","rapidkit-core"]),e.succeed("RapidKit installed globally");}catch(h){e.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),f.debug(`pipx install failed: ${h}`);}}}catch(p){f.debug(`Global install check skipped: ${p}`);}}async function Bt(t,i,e,o,r,n=false){e.start(`Checking Python ${i}`);let a=Rt();try{let{stdout:c}=await execa(a,["--version"]),l=c.match(/Python (\d+\.\d+)/)?.[1];if(l&&parseFloat(l)<parseFloat(i))throw new lt(i,l);e.succeed(`Python ${l} found`);}catch(c){throw c instanceof lt?c:new lt(i)}e.start("Creating virtual environment");try{await execa(a,["-m","venv",".venv"],{cwd:t}),e.succeed("Virtual environment created");}catch(c){if(e.fail("Failed to create virtual environment"),(p=>typeof p=="object"&&p!==null&&"stdout"in p&&typeof p.stdout=="string")(c)&&c.stdout.includes("ensurepip is not")){let p=c.stdout.match(/apt install (python[\d.]+-venv)/),d=p?p[1]:"python3-venv";throw new M("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 ${
|
|
689
|
+
npx rapidkit ${w.basename(t)} --yes`))}throw new M("Virtual environment creation",c instanceof Error?c:new Error(String(c)))}e.start("Installing RapidKit");let s=w.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=jt(r||{});if(!c)throw new M("Test mode installation",new Error("No local RapidKit path configured. Set RAPIDKIT_DEV_PATH environment variable."));f.debug(`Installing from local path: ${c}`),e.text="Installing RapidKit from local path (test mode)",await execa(s,["-m","pip","install","-e",c],{cwd:t});}else {e.text="Installing RapidKit from PyPI";let c=false,l=null;for(let p=1;p<=3;p++)try{await execa(s,["-m","pip","install","rapidkit-core"],{cwd:t,timeout:6e4*p}),c=!0;break}catch(d){l=d,f.debug(`pip install attempt ${p} failed: ${d}`),p<3&&(e.text=`Retrying installation (attempt ${p+1}/3)`,await new Promise(u=>setTimeout(u,2e3)));}if(!c){let p=l?.stderr||l?.message||"Unknown error";throw f.debug(`All pip install attempts failed. Last error: ${p}`),p.includes("Could not find")||p.includes("No matching distribution")?new pt:new M("Install rapidkit-core with pip",new Error(`Failed to install rapidkit-core after 3 attempts.
|
|
690
690
|
Error: ${p}
|
|
691
691
|
|
|
692
692
|
Possible solutions:
|
|
693
693
|
1. Check your internet connection
|
|
694
|
-
2. Try installing manually: cd ${
|
|
695
|
-
3. Use Poetry instead: npx rapidkit ${
|
|
696
|
-
`,"utf-8");}async function
|
|
694
|
+
2. Try installing manually: cd ${w.basename(t)} && .venv/bin/python -m pip install rapidkit-core
|
|
695
|
+
3. Use Poetry instead: npx rapidkit ${w.basename(t)} --install-method=poetry`))}}e.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:c}=await Promise.resolve().then(()=>(Pt(),Lt));if(!await c()&&!o){e.start("Installing RapidKit globally with pipx for CLI access");let p=await _t(e,n);try{await ft(p,["install","rapidkit-core"]),e.succeed("RapidKit installed globally");}catch(d){e.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),f.debug(`pipx install failed: ${d}`);}}}catch(c){f.debug(`Global install check skipped: ${c}`);}}async function Ie(t,i,e,o,r=false){let n=await _t(i,r);if(i.start("Installing RapidKit globally with pipx"),e){let a=jt(o||{});if(!a)throw new M("Test mode installation",new Error("No local RapidKit path configured. Set RAPIDKIT_DEV_PATH environment variable."));f.debug(`Installing from local path: ${a}`),i.text="Installing RapidKit from local path (test mode)",await ft(n,["install","-e",a]);}else {i.text="Installing RapidKit from PyPI";try{await ft(n,["install","rapidkit-core"]);}catch{throw new pt}}i.succeed("RapidKit installed globally"),await k.outputFile(w.join(t,".rapidkit-global"),`RapidKit installed globally with pipx
|
|
696
|
+
`,"utf-8");}async function rt(t,i){let{skipGit:e=false,testMode:o=false,userConfig:r={},yes:n=false,installMethod:a,pythonVersion:s="3.10"}=i||{},c=a||r.defaultInstallMethod||"poetry";await $e(t,w.basename(t),c),await Pe(t);let l=kt("Registering workspace").start();try{c==="poetry"?await Ee(t,s,l,o,r,n):c==="venv"?await Bt(t,s,l,o,r):await Ie(t,l,o,r,n),await Re(t,c),await Se(t,c),l.succeed("Workspace registered");try{let{registerWorkspace:p}=await Promise.resolve().then(()=>(Q(),q));await p(t,w.basename(t));}catch{}if(!e){l.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}),l.succeed("Git repository initialized");}catch{l.warn("Could not initialize git repository");}}}catch(p){throw l.fail("Failed to register workspace"),p}}async function Se(t,i){let r=`# RapidKit Workspace
|
|
697
697
|
|
|
698
698
|
This directory contains a RapidKit development environment.
|
|
699
699
|
|
|
700
700
|
## Installation Method
|
|
701
701
|
|
|
702
|
-
**${
|
|
702
|
+
**${i==="poetry"?"Poetry":i==="venv"?"Python venv + pip":"pipx (global)"}**
|
|
703
703
|
|
|
704
704
|
## Getting Started
|
|
705
705
|
|
|
@@ -708,10 +708,10 @@ This directory contains a RapidKit development environment.
|
|
|
708
708
|
This workspace includes a local launcher script so you can run the Python Core CLI without activating the environment:
|
|
709
709
|
|
|
710
710
|
\`\`\`bash
|
|
711
|
-
${
|
|
711
|
+
${i==="poetry"?`# No activation needed (recommended):
|
|
712
712
|
./rapidkit --help
|
|
713
713
|
# or:
|
|
714
|
-
poetry run rapidkit --help`:
|
|
714
|
+
poetry run rapidkit --help`:i==="venv"?`# No activation needed (recommended):
|
|
715
715
|
./rapidkit --help
|
|
716
716
|
# or direct:
|
|
717
717
|
./.venv/bin/rapidkit --help`:`# Optional: use the local launcher
|
|
@@ -722,8 +722,8 @@ poetry run rapidkit --help`:e==="venv"?`# No activation needed (recommended):
|
|
|
722
722
|
### 1. Activate Environment
|
|
723
723
|
|
|
724
724
|
\`\`\`bash
|
|
725
|
-
${
|
|
726
|
-
# Or simply use: poetry run rapidkit <command>`:
|
|
725
|
+
${i==="poetry"?`source $(poetry env info --path)/bin/activate
|
|
726
|
+
# Or simply use: poetry run rapidkit <command>`:i==="venv"?"source .venv/bin/activate # On Windows: .venv\\Scripts\\activate":"N/A (globally installed)"}
|
|
727
727
|
\`\`\`
|
|
728
728
|
|
|
729
729
|
### 2. Create Your First Project
|
|
@@ -790,8 +790,8 @@ For full documentation, visit: [RapidKit Docs](https://getrapidkit.com) *(or app
|
|
|
790
790
|
## Workspace Structure
|
|
791
791
|
|
|
792
792
|
\`\`\`
|
|
793
|
-
${
|
|
794
|
-
${
|
|
793
|
+
${i==="venv"?".venv/ # Python virtual environment":""}
|
|
794
|
+
${i==="poetry"?"pyproject.toml # Poetry configuration":""}
|
|
795
795
|
my-project/ # Your RapidKit projects go here
|
|
796
796
|
README.md # This file
|
|
797
797
|
\`\`\`
|
|
@@ -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(
|
|
807
|
+
`;await promises.writeFile(w.join(t,"README.md"),r,"utf-8");}async function Ri(t,i,e){let o=kt("Creating demo workspace").start();try{await k.ensureDir(t),o.succeed("Directory created"),o.start("Setting up demo kit generator");let r=JSON.stringify({name:`${i}-workspace`,version:"1.0.0",private:!0,description:"RapidKit demo workspace",scripts:{generate:"node generate-demo.js"}},null,2);await promises.writeFile(w.join(t,"package.json"),r,"utf-8"),await promises.writeFile(w.join(t,"generate-demo.js"),`#!/usr/bin/env node
|
|
808
808
|
/**
|
|
809
809
|
* Demo Kit Generator - Create FastAPI demo projects
|
|
810
810
|
*
|
|
@@ -1200,7 +1200,7 @@ venv/
|
|
|
1200
1200
|
}
|
|
1201
1201
|
|
|
1202
1202
|
main().catch(console.error);
|
|
1203
|
-
`,"utf-8");try{await execa("chmod",["+x",
|
|
1203
|
+
`,"utf-8");try{await execa("chmod",["+x",w.join(t,"generate-demo.js")]);}catch{}let a=`# RapidKit Demo Workspace
|
|
1204
1204
|
|
|
1205
1205
|
Welcome to your RapidKit demo workspace! This environment lets you generate FastAPI demo projects using bundled RapidKit templates, without needing to install Python RapidKit.
|
|
1206
1206
|
|
|
@@ -1271,7 +1271,7 @@ pipx install rapidkit
|
|
|
1271
1271
|
## \u{1F6E0}\uFE0F Workspace Structure
|
|
1272
1272
|
|
|
1273
1273
|
\`\`\`
|
|
1274
|
-
${
|
|
1274
|
+
${i}/
|
|
1275
1275
|
\u251C\u2500\u2500 generate-demo.js # Demo project generator
|
|
1276
1276
|
\u251C\u2500\u2500 README.md # This file
|
|
1277
1277
|
\u2514\u2500\u2500 my-api/ # Your generated projects go here
|
|
@@ -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(
|
|
1290
|
+
`;if(await promises.writeFile(w.join(t,"README.md"),a,"utf-8"),o.succeed("Demo workspace setup complete"),!e){o.start("Initializing git repository");try{await execa("git",["init"],{cwd:t}),await k.outputFile(w.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(m.green(`
|
|
1304
1304
|
\u2728 Demo workspace created successfully!
|
|
1305
1305
|
`)),console.log(m.cyan("\u{1F4C2} Location:"),m.white(t)),console.log(m.cyan(`\u{1F680} Get started:
|
|
1306
|
-
`)),console.log(m.white(` cd ${
|
|
1306
|
+
`)),console.log(m.white(` cd ${i}`)),console.log(m.white(" node generate-demo.js my-api")),console.log(m.white(" cd my-api")),console.log(m.white(" rapidkit init")),console.log(m.white(" rapidkit dev")),console.log(),console.log(m.yellow("\u{1F4A1} Note:"),"This is a demo workspace. For full RapidKit features:"),console.log(m.cyan(" pipx install rapidkit")),console.log();}catch(r){throw o.fail("Failed to create demo workspace"),r}}async function Ci(t,i,e,o){console.log(m.cyan(`
|
|
1307
1307
|
\u{1F50D} Dry-run mode - showing what would be created:
|
|
1308
|
-
`)),console.log(m.white("\u{1F4C2} Project path:"),t),console.log(m.white("\u{1F4E6} Project type:"),
|
|
1308
|
+
`)),console.log(m.white("\u{1F4C2} Project path:"),t),console.log(m.white("\u{1F4E6} Project type:"),e?"Demo workspace":"Full RapidKit environment"),e?(console.log(m.white(`
|
|
1309
1309
|
\u{1F4DD} Files to create:`)),console.log(m.gray(" - package.json")),console.log(m.gray(" - generate-demo.js (project generator)")),console.log(m.gray(" - README.md")),console.log(m.gray(" - .gitignore")),console.log(m.white(`
|
|
1310
1310
|
\u{1F3AF} Capabilities:`)),console.log(m.gray(" - Generate multiple FastAPI demo projects")),console.log(m.gray(" - No Python RapidKit installation required")),console.log(m.gray(" - Bundled templates included"))):(console.log(m.white(`
|
|
1311
|
-
\u2699\uFE0F Configuration:`)),console.log(m.gray(` - Python version: ${
|
|
1311
|
+
\u2699\uFE0F Configuration:`)),console.log(m.gray(` - Python version: ${o.pythonVersion||"3.10"}`)),console.log(m.gray(` - Install method: ${o.defaultInstallMethod||"poetry"}`)),console.log(m.gray(` - Git initialization: ${o.skipGit?"No":"Yes"}`)),console.log(m.white(`
|
|
1312
1312
|
\u{1F4DD} Files to create:`)),console.log(m.gray(" - pyproject.toml (Poetry) or .venv/ (venv)")),console.log(m.gray(" - README.md")),console.log(m.gray(" - .gitignore")),console.log(m.white(`
|
|
1313
1313
|
\u{1F3AF} Next steps after creation:`)),console.log(m.gray(" 1. Install RapidKit Python package")),console.log(m.gray(" 2. Create projects with rapidkit CLI")),console.log(m.gray(" 3. Add modules and customize"))),console.log(m.white(`
|
|
1314
1314
|
\u{1F4A1} To proceed with actual creation, run without --dry-run flag
|
|
1315
|
-
`));}
|
|
1315
|
+
`));}R();gt();var Si=fileURLToPath(import.meta.url),Ai=w.dirname(Si);function Ni(t=32){let i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=Ii.randomBytes(t),o="";for(let r=0;r<t;r++)o+=i[e[r]%i.length];return o}async function Ae(t,i){let o=(i.template||"fastapi")==="fastapi",r=o?"FastAPI":"NestJS",n=kt(`Generating ${r} project...`).start();try{let a=w.resolve(Ai,".."),s=o?"fastapi-standard":"nestjs-standard",c=w.join(a,"templates","kits",s),l=_i.configure(c,{autoescape:!1,trimBlocks:!0,lstripBlocks:!0});l.addFilter("generate_secret",function(y,x=32){return Ni(x)});let p={project_name:i.project_name,author:i.author||"RapidKit User",description:i.description||(o?"FastAPI service generated with RapidKit":"NestJS application generated with RapidKit"),app_version:i.app_version||"0.1.0",license:i.license||"MIT",package_manager:i.package_manager||"npm",created_at:new Date().toISOString(),rapidkit_version:H()},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 y of d){let x=w.join(c,y);try{await promises.access(x);}catch{continue}let A=await promises.readFile(x,"utf-8"),D=l.renderString(A,p),O=y.replace(/\.j2$/,""),et=w.join(t,O);await promises.mkdir(w.dirname(et),{recursive:!0}),await promises.writeFile(et,D),(O.endsWith(".rapidkit/rapidkit")||O.endsWith(".rapidkit/cli.py")||O.endsWith(".rapidkit/activate")||O==="rapidkit")&&await promises.chmod(et,493);}if(o){let y=w.join(c,".rapidkit","context.json"),x=w.join(t,".rapidkit","context.json");try{await promises.mkdir(w.join(t,".rapidkit"),{recursive:!0}),await promises.copyFile(y,x);}catch{await promises.mkdir(w.join(t,".rapidkit"),{recursive:!0});let D=i.engine||"pip";await promises.writeFile(x,JSON.stringify({engine:D,created_by:"rapidkit-npm-fallback"},null,2));}}let u=o?`# Python
|
|
1316
1316
|
__pycache__/
|
|
1317
1317
|
*.py[cod]
|
|
1318
1318
|
*$py.class
|
|
@@ -1380,12 +1380,12 @@ Thumbs.db
|
|
|
1380
1380
|
|
|
1381
1381
|
# Coverage
|
|
1382
1382
|
coverage/
|
|
1383
|
-
`;if(await promises.writeFile(
|
|
1383
|
+
`;if(await promises.writeFile(w.join(t,".gitignore"),u),n.succeed(`${r} project generated!`),!i.skipGit){let y=kt("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}),y.succeed("Git repository initialized");}catch{y.warn("Could not initialize git repository");}}if(!o&&!i.skipInstall){let y=i.package_manager||"npm",x=kt(`Installing dependencies with ${y}...`).start();try{await execa(y,y==="yarn"?["install"]:y==="pnpm"?["install"]:["install"],{cwd:t}),x.succeed("Dependencies installed");}catch{x.warn(`Could not install dependencies. Run '${y} install' manually.`);}}let h=w.basename(t);console.log(`
|
|
1384
1384
|
${m.yellow("\u26A0\uFE0F Limited offline mode:")} This project was created using basic templates.
|
|
1385
1385
|
${m.gray("For full kit features, install Python 3.10+ and rapidkit-core:")}
|
|
1386
1386
|
${m.cyan(" sudo apt install python3 python3-pip python3-venv")}
|
|
1387
1387
|
${m.cyan(" pip install rapidkit-core")}
|
|
1388
|
-
`),console.log(
|
|
1388
|
+
`),console.log(o?`
|
|
1389
1389
|
${m.green("\u2728 FastAPI project created successfully!")}
|
|
1390
1390
|
|
|
1391
1391
|
${m.bold("\u{1F4C2} Project structure:")}
|
|
@@ -1401,7 +1401,7 @@ ${t}/
|
|
|
1401
1401
|
\u2514\u2500\u2500 README.md
|
|
1402
1402
|
|
|
1403
1403
|
${m.bold("\u{1F680} Get started:")}
|
|
1404
|
-
${m.cyan(`cd ${
|
|
1404
|
+
${m.cyan(`cd ${h}`)}
|
|
1405
1405
|
${m.cyan("npx rapidkit init")} ${m.gray("# Install dependencies")}
|
|
1406
1406
|
${m.cyan("npx rapidkit dev")} ${m.gray("# Start dev server")}
|
|
1407
1407
|
|
|
@@ -1431,7 +1431,7 @@ ${t}/
|
|
|
1431
1431
|
\u2514\u2500\u2500 README.md
|
|
1432
1432
|
|
|
1433
1433
|
${m.bold("\u{1F680} Get started:")}
|
|
1434
|
-
${m.cyan(`cd ${
|
|
1434
|
+
${m.cyan(`cd ${h}`)}
|
|
1435
1435
|
${m.cyan("npx rapidkit init")} ${m.gray("# Install dependencies")}
|
|
1436
1436
|
${m.cyan("cp .env.example .env")}
|
|
1437
1437
|
${m.cyan("npx rapidkit dev")} ${m.gray("# Start dev server")}
|
|
@@ -1452,23 +1452,50 @@ ${m.bold("\u{1F310} API endpoints:")}
|
|
|
1452
1452
|
|
|
1453
1453
|
${m.gray("Alternative: npm run start:dev, ./rapidkit dev")}
|
|
1454
1454
|
${m.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
|
|
1455
|
-
`);}catch(a){throw o.fail(`Failed to generate ${n} project`),a}}function Ut(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 wi(t){let e=t.trim().toLowerCase();return e?e.startsWith("fastapi")?"fastapi":e.startsWith("nestjs")?"nestjs":null:null}function ki(t,e){let i=t.indexOf(e);if(i>=0&&i+1<t.length)return t[i+1];let r=t.find(n=>n.startsWith(`${e}=`));if(r)return r.slice(e.length+1)}async function Bt(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
|
-
|
|
1455
|
+
`);}catch(a){throw n.fail(`Failed to generate ${r} project`),a}}R();ct();async function De(){let t=process.platform==="win32"?["python","python3"]:["python3","python"];for(let i of t)try{let{stdout:e}=await execa(i,["--version"],{timeout:3e3}),o=e.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:`${i} found but version is below minimum requirement`}:{status:"ok",message:`Python ${r}`,details:`Using ${i}`}}}catch{continue}return {status:"error",message:"Python not found",details:"Install Python 3.10+ and ensure it's in PATH"}}async function Te(){try{let{stdout:t}=await execa("poetry",["--version"],{timeout:3e3}),i=t.match(/Poetry .*version ([\d.]+)/);return i?{status:"ok",message:`Poetry ${i[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 Fe(){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 Oe(){let t=process.platform==="win32"?["python","python3"]:["python3","python"],i=process.env.HOME||process.env.USERPROFILE||"",e=[w.join(i,".local","bin","rapidkit"),w.join(i,"AppData","Roaming","Python","Scripts","rapidkit.exe"),w.join(i,".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 e)try{if(await k__default.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=w.join(process.cwd(),".venv","bin","rapidkit");if(await k__default.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 qt(t,i){let e=w.join(t,"Dockerfile");i.hasDocker=await k__default.pathExists(e);let o=w.join(t,"tests"),r=w.join(t,"test");if(i.hasTests=await k__default.pathExists(o)||await k__default.pathExists(r),i.framework==="NestJS"){let n=w.join(t,".eslintrc.js"),a=w.join(t,".eslintrc.json");i.hasCodeQuality=await k__default.pathExists(n)||await k__default.pathExists(a);}else if(i.framework==="FastAPI"){let n=w.join(t,"ruff.toml"),a=w.join(t,"pyproject.toml");if(await k__default.pathExists(a))try{let s=await k__default.readFile(a,"utf8");i.hasCodeQuality=s.includes("[tool.ruff]")||await k__default.pathExists(n);}catch{i.hasCodeQuality=await k__default.pathExists(n);}}try{if(i.framework==="NestJS"){let{stdout:n}=await execa("npm",["audit","--json"],{cwd:t,reject:!1});if(n)try{let s=JSON.parse(n).metadata?.vulnerabilities;s&&(i.vulnerabilities=(s.high||0)+(s.critical||0)+(s.moderate||0));}catch{}}else if(i.framework==="FastAPI"){let n=w.join(t,".venv"),a=process.platform==="win32"?w.join(n,"Scripts","python.exe"):w.join(n,"bin","python");if(await k__default.pathExists(a))try{let{stdout:s}=await execa(a,["-m","pip","list","--format=json"],{timeout:5e3,reject:!1});if(s){let c=JSON.parse(s);i.vulnerabilities=0;}}catch{}}}catch{}}async function Ti(t){let e={name:w.basename(t),path:t,venvActive:false,depsInstalled:false,coreInstalled:false,issues:[],fixCommands:[]},o=w.join(t,".rapidkit");if(!await k__default.pathExists(o))return e.issues.push("Not a valid RapidKit project (missing .rapidkit directory)"),e;try{let c=w.join(t,"registry.json");if(await k__default.pathExists(c)){let l=await k__default.readJson(c);l.installed_modules&&(e.stats={modules:l.installed_modules.length});}}catch{}try{let c=w.join(o,"project.json");if(await k__default.pathExists(c)){let l=await k__default.readJson(c);l.kit&&(e.kit=l.kit);}}catch{}try{let c=w.join(t,".git");if(await k__default.pathExists(c)){let{stdout:l}=await execa("git",["log","-1","--format=%cr"],{cwd:t,reject:!1});l&&(e.lastModified=l.trim());}else {let l=await k__default.stat(t),d=Date.now()-l.mtime.getTime(),u=Math.floor(d/(1e3*60*60*24));e.lastModified=u===0?"today":`${u} day${u>1?"s":""} ago`;}}catch{}let r=w.join(t,"package.json"),n=w.join(t,"pyproject.toml"),a=await k__default.pathExists(r),s=await k__default.pathExists(n);if(a){e.framework="NestJS",e.venvActive=true;let c=w.join(t,"node_modules");if(await k__default.pathExists(c))try{let u=(await k__default.readdir(c)).filter(h=>!h.startsWith(".")&&!h.startsWith("_"));e.depsInstalled=u.length>0;}catch{e.depsInstalled=false;}e.depsInstalled||(e.issues.push("Dependencies not installed (node_modules empty or missing)"),e.fixCommands?.push(`cd ${t} && rapidkit init`)),e.coreInstalled=false;let l=w.join(t,".env");if(e.hasEnvFile=await k__default.pathExists(l),!e.hasEnvFile){let d=w.join(t,".env.example");await k__default.pathExists(d)&&(e.issues.push("Environment file missing (found .env.example)"),e.fixCommands?.push(`cd ${t} && cp .env.example .env`));}let p=w.join(t,"src");if(e.modulesHealthy=true,e.missingModules=[],await k__default.pathExists(p))try{let d=await k__default.readdir(p);e.modulesHealthy=d.length>0;}catch{e.modulesHealthy=false;}return await qt(t,e),e}if(s){e.framework="FastAPI";let c=w.join(t,".venv");if(await k__default.pathExists(c)){e.venvActive=true;let u=process.platform==="win32"?w.join(c,"Scripts","python.exe"):w.join(c,"bin","python");if(await k__default.pathExists(u)){try{let{stdout:h}=await execa(u,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:2e3});e.coreInstalled=!0,e.coreVersion=h.trim();}catch{e.coreInstalled=false;}try{await execa(u,["-c","import fastapi"],{timeout:2e3}),e.depsInstalled=!0;}catch{try{let h=w.join(c,"lib");if(await k__default.pathExists(h)){let x=(await k__default.readdir(h)).find(A=>A.startsWith("python"));if(x){let A=w.join(h,x,"site-packages");if(await k__default.pathExists(A)){let O=(await k__default.readdir(A)).filter(et=>!et.startsWith("_")&&!et.includes("dist-info")&&!["pip","setuptools","wheel","pkg_resources"].includes(et));e.depsInstalled=O.length>0;}}}e.depsInstalled||(e.issues.push("Dependencies not installed"),e.fixCommands?.push(`cd ${t} && rapidkit init`));}catch{e.issues.push("Could not verify dependency installation");}}}else e.issues.push("Virtual environment exists but Python executable not found");}else e.issues.push("Virtual environment not created"),e.fixCommands?.push(`cd ${t} && rapidkit init`);let l=w.join(t,".env");if(e.hasEnvFile=await k__default.pathExists(l),!e.hasEnvFile){let u=w.join(t,".env.example");await k__default.pathExists(u)&&(e.issues.push("Environment file missing (found .env.example)"),e.fixCommands?.push(`cd ${t} && cp .env.example .env`));}let p=w.join(t,"src"),d=w.join(t,"modules");if(e.modulesHealthy=true,e.missingModules=[],await k__default.pathExists(p)){let u=w.join(p,"__init__.py");await k__default.pathExists(u)||(e.modulesHealthy=false,e.missingModules.push("src/__init__.py"));}if(await k__default.pathExists(d))try{let u=await Me(d);for(let h of u){let y=w.join(d,h,"__init__.py");await k__default.pathExists(y)||(e.modulesHealthy=!1,e.missingModules.push(`modules/${h}/__init__.py`));}}catch{}return !e.modulesHealthy&&e.missingModules.length>0&&e.issues.push(`Missing module init files: ${e.missingModules.join(", ")}`),await qt(t,e),e}return e.issues.push("Unknown project type (no package.json or pyproject.toml)"),await qt(t,e),e}async function Me(t){try{return (await k__default.readdir(t,{withFileTypes:!0})).filter(e=>e.isDirectory()).map(e=>e.name)}catch{try{let i=await k__default.readdir(t),e=[];for(let o of i)try{(await k__default.stat(w.join(t,o))).isDirectory()&&e.push(o);}catch{continue}return e}catch{return []}}}async function Fi(t,i,e){let o=new Set,r=[{dir:t,depth:0}];for(;r.length>0;){let n=r.shift();if(!n)break;try{let a=await k__default.readdir(n.dir);for(let s of a){if(e.has(s))continue;let c=w.join(n.dir,s),l;try{l=await k__default.stat(c);}catch{continue}if(!l.isDirectory())continue;let p=w.join(c,".rapidkit");if(await k__default.pathExists(p)){o.add(c);continue}n.depth<i&&r.push({dir:c,depth:n.depth+1});}}catch{continue}}return Array.from(o)}async function Oi(t){let i=t,e=w.parse(i).root;for(;i!==e;){let o=[w.join(i,".rapidkit-workspace"),w.join(i,".rapidkit","workspace-marker.json"),w.join(i,".rapidkit","config.json")];for(let r of o)if(await k__default.pathExists(r))return i;i=w.dirname(i);}return null}function Mi(t,i){let e=0,o=0,r=0;return t.forEach(a=>{a.status==="ok"?e++:a.status==="warn"?o++:a.status==="error"&&r++;}),i.forEach(a=>{a.issues.length===0&&a.venvActive&&a.depsInstalled?e++:a.issues.length>0&&o++;}),{total:e+o+r,passed:e,warnings:o,errors:r}}async function Ki(t){let i=w.basename(t);try{let r=w.join(t,".rapidkit-workspace");await k__default.pathExists(r)&&(i=(await k__default.readJSON(r)).name||i);}catch{try{let r=w.join(t,".rapidkit","config.json");i=(await k__default.readJSON(r)).workspace_name||i;}catch{}}let e={workspacePath:t,workspaceName:i,python:await De(),poetry:await Te(),pipx:await Fe(),rapidkitCore:await Oe(),projects:[]};try{let r=new Set([".git",".venv","node_modules",".rapidkit","dist","build","coverage","__pycache__"]),n=new Set,a=w.join(t,".rapidkit");await k__default.pathExists(a)&&n.add(t);let s=async(c,l)=>{if(l<0)return;let p=await Me(c);for(let d of p){if(r.has(d))continue;let u=w.join(c,d),h=w.join(u,".rapidkit");if(await k__default.pathExists(h)){n.add(u);continue}l>0&&await s(u,l-1);}};if(await s(t,1),f.debug(`Workspace scan (shallow) found ${n.size} project(s)`),n.size===0){let c=await Fi(t,3,r);c.forEach(l=>n.add(l)),f.debug(`Workspace scan (deep fallback) found ${c.length} project(s)`);}n.size>0&&f.debug(`Workspace projects detected: ${Array.from(n).join(", ")}`);for(let c of n){let l=await Ti(c);e.projects.push(l);}}catch(r){f.debug(`Failed to scan workspace projects: ${r}`);}let o=[e.python,e.poetry,e.pipx,e.rapidkitCore];if(e.healthScore=Mi(o,e.projects),e.rapidkitCore.status==="ok"){let r=e.rapidkitCore.message.match(/([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);r&&(e.coreVersion=r[1]);}return e}function X(t,i){let e=t.status==="ok"?"\u2705":t.status==="warn"?"\u26A0\uFE0F":"\u274C",o=t.status==="ok"?m.green:t.status==="warn"?m.yellow:m.red;console.log(`${e} ${m.bold(i)}: ${o(t.message)}`),t.details&&console.log(` ${m.gray(t.details)}`);}function Wi(t){let i=t.issues.length>0,e=i?"\u26A0\uFE0F":"\u2705",o=i?m.yellow:m.green;if(console.log(`
|
|
1456
|
+
${e} ${m.bold("Project")}: ${o(t.name)}`),t.framework){let s=t.framework==="FastAPI"?"\u{1F40D}":t.framework==="NestJS"?"\u{1F985}":"\u{1F4E6}";console.log(` ${s} Framework: ${m.cyan(t.framework)}${t.kit?m.gray(` (${t.kit})`):""}`);}if(console.log(` ${m.gray(`Path: ${t.path}`)}`),!(t.venvActive&&!t.coreInstalled)&&(t.venvActive?console.log(` \u2705 Virtual environment: ${m.green("Active")}`):console.log(` \u274C Virtual environment: ${m.red("Not found")}`),t.coreInstalled?console.log(` ${m.dim("\u2139")} RapidKit Core: ${m.gray(t.coreVersion||"In venv")} ${m.dim("(optional)")}`):console.log(` ${m.dim("\u2139")} RapidKit Core: ${m.gray("Using global installation")} ${m.dim("(recommended)")}`)),t.depsInstalled?console.log(` \u2705 Dependencies: ${m.green("Installed")}`):console.log(` \u26A0\uFE0F Dependencies: ${m.yellow("Not installed")}`),t.hasEnvFile!==void 0&&(t.hasEnvFile?console.log(` \u2705 Environment: ${m.green(".env configured")}`):console.log(` \u26A0\uFE0F Environment: ${m.yellow(".env missing")}`)),t.modulesHealthy!==void 0&&(t.modulesHealthy?console.log(` \u2705 Modules: ${m.green("Healthy")}`):t.missingModules&&t.missingModules.length>0&&console.log(` \u26A0\uFE0F Modules: ${m.yellow(`Missing ${t.missingModules.length} init file(s)`)}`)),t.stats){let s=[];t.stats.modules!==void 0&&s.push(`${t.stats.modules} module${t.stats.modules!==1?"s":""}`),s.length>0&&console.log(` \u{1F4CA} Stats: ${m.cyan(s.join(" \u2022 "))}`);}t.lastModified&&console.log(` \u{1F552} Last Modified: ${m.gray(t.lastModified)}`);let a=[];if(t.hasTests!==void 0&&a.push(t.hasTests?"\u2705 Tests":m.dim("\u2298 No tests")),t.hasDocker!==void 0&&a.push(t.hasDocker?"\u2705 Docker":m.dim("\u2298 No Docker")),t.hasCodeQuality!==void 0){let s=t.framework==="NestJS"?"ESLint":"Ruff";a.push(t.hasCodeQuality?`\u2705 ${s}`:m.dim(`\u2298 No ${s}`));}a.length>0&&console.log(` ${a.join(" \u2022 ")}`),t.vulnerabilities!==void 0&&t.vulnerabilities>0&&console.log(` \u26A0\uFE0F Security: ${m.yellow(`${t.vulnerabilities} vulnerability(ies) found`)}`),t.issues.length>0&&(console.log(` ${m.bold("Issues:")}`),t.issues.forEach(s=>{console.log(` \u2022 ${m.yellow(s)}`);}),t.fixCommands&&t.fixCommands.length>0&&(console.log(`
|
|
1457
|
+
${m.bold.cyan("\u{1F527} Quick Fix:")}`),t.fixCommands.forEach(s=>{console.log(` ${m.cyan("$")} ${m.white(s)}`);})));}async function Ne(t,i=false){let e=t.filter(r=>r.fixCommands&&r.fixCommands.length>0);if(e.length===0){console.log(m.green(`
|
|
1458
|
+
\u2705 No fixes needed - all projects are healthy!`));return}console.log(m.bold.cyan(`
|
|
1459
|
+
\u{1F527} Available Fixes:
|
|
1460
|
+
`));for(let r of e)console.log(m.bold(`Project: ${m.yellow(r.name)}`)),r.fixCommands.forEach((n,a)=>{console.log(` ${a+1}. ${m.cyan(n)}`);}),console.log();if(!i){console.log(m.gray("\u{1F4A1} Run with --fix flag to apply fixes automatically"));return}let{confirm:o}=await Jt.prompt([{type:"confirm",name:"confirm",message:`Apply ${e.reduce((r,n)=>r+n.fixCommands.length,0)} fix(es)?`,default:false}]);if(!o){console.log(m.yellow(`
|
|
1461
|
+
\u26A0\uFE0F Fixes cancelled by user`));return}console.log(m.bold.cyan(`
|
|
1462
|
+
\u{1F680} Applying fixes...
|
|
1463
|
+
`));for(let r of e){console.log(m.bold(`Fixing ${m.cyan(r.name)}...`));for(let n of r.fixCommands)try{console.log(m.gray(` $ ${n}`)),await execa(n,{shell:!0,stdio:"inherit"}),console.log(m.green(` \u2705 Success
|
|
1464
|
+
`));}catch(a){console.log(m.red(` \u274C Failed: ${a instanceof Error?a.message:String(a)}
|
|
1465
|
+
`));}}console.log(m.bold.green(`
|
|
1466
|
+
\u2705 Fix process completed!`));}async function Ke(t={}){if(t.json||console.log(m.bold.cyan(`
|
|
1467
|
+
\u{1FA7A} RapidKit Health Check
|
|
1468
|
+
`)),t.workspace){let i=await Oi(process.cwd());i||(f.error("No RapidKit workspace found in current directory or parents"),f.info('Run this command from within a workspace, or use "rapidkit doctor" for system check'),process.exit(1)),t.json||(console.log(m.bold(`Workspace: ${m.cyan(w.basename(i))}`)),console.log(m.gray(`Path: ${i}`)));let e=await Ki(i);if(t.json){let n={workspace:{name:w.basename(i),path:i},healthScore:e.healthScore,system:{python:e.python,poetry:e.poetry,pipx:e.pipx,rapidkitCore:e.rapidkitCore,versions:{core:e.coreVersion,npm:e.npmVersion}},projects:e.projects.map(a=>({name:a.name,path:a.path,venvActive:a.venvActive,depsInstalled:a.depsInstalled,coreInstalled:a.coreInstalled,coreVersion:a.coreVersion,issues:a.issues,fixCommands:a.fixCommands})),summary:{totalProjects:e.projects.length,totalIssues:e.projects.reduce((a,s)=>a+s.issues.length,0),hasSystemErrors:[e.python,e.rapidkitCore].some(a=>a.status==="error")}};console.log(JSON.stringify(n,null,2));return}if(e.healthScore){let n=e.healthScore,a=Math.round(n.passed/n.total*100),s=a>=80?m.green:a>=50?m.yellow:m.red,c="\u2588".repeat(Math.floor(a/5))+"\u2591".repeat(20-Math.floor(a/5));console.log(m.bold(`
|
|
1469
|
+
\u{1F4CA} Health Score:`)),console.log(` ${s(`${a}%`)} ${m.gray(c)}`),console.log(` ${m.green(`\u2705 ${n.passed} passed`)} ${m.gray("|")} ${m.yellow(`\u26A0\uFE0F ${n.warnings} warnings`)} ${m.gray("|")} ${m.red(`\u274C ${n.errors} errors`)}`);}if(console.log(m.bold(`
|
|
1470
|
+
|
|
1471
|
+
System Tools:
|
|
1472
|
+
`)),X(e.python,"Python"),X(e.poetry,"Poetry"),X(e.pipx,"pipx"),X(e.rapidkitCore,"RapidKit Core"),e.coreVersion&&e.npmVersion){let n=e.coreVersion.split(".")[1],a=e.npmVersion.split(".")[1];n!==a&&(console.log(m.yellow(`
|
|
1473
|
+
\u26A0\uFE0F Version mismatch: Core ${e.coreVersion} / CLI ${e.npmVersion}`)),console.log(m.gray(" Consider updating to matching versions for best compatibility")));}e.projects.length>0?(console.log(m.bold(`
|
|
1474
|
+
\u{1F4E6} Projects (${e.projects.length}):`)),e.projects.forEach(n=>Wi(n))):(console.log(m.bold(`
|
|
1475
|
+
\u{1F4E6} Projects:`)),console.log(m.gray(" No RapidKit projects found in workspace")));let o=e.projects.reduce((n,a)=>n+a.issues.length,0),r=[e.python,e.rapidkitCore].some(n=>n.status==="error");r||o>0?(console.log(m.bold.yellow(`
|
|
1476
|
+
\u26A0\uFE0F Found ${o} project issue(s)`)),r&&console.log(m.bold.red("\u274C System requirements not met")),t.fix?await Ne(e.projects,true):o>0&&await Ne(e.projects,false)):console.log(m.bold.green(`
|
|
1477
|
+
\u2705 All checks passed! Workspace is healthy.`));}else {console.log(m.bold(`System Tools:
|
|
1478
|
+
`));let i=await De(),e=await Te(),o=await Fe(),r=await Oe();X(i,"Python"),X(e,"Poetry"),X(o,"pipx"),X(r,"RapidKit Core"),[i,r].some(a=>a.status==="error")?(console.log(m.bold.red(`
|
|
1479
|
+
\u274C Some required tools are missing`)),console.log(m.gray(`
|
|
1480
|
+
Tip: Run "rapidkit doctor --workspace" from within a workspace for detailed project checks`))):(console.log(m.bold.green(`
|
|
1481
|
+
\u2705 All required tools are installed!`)),console.log(m.gray(`
|
|
1482
|
+
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 i=t.code;return i==="PYTHON_NOT_FOUND"||i==="BRIDGE_VENV_BOOTSTRAP_FAILED"?i:null}function Li(t){let i=t.trim().toLowerCase();return i?i.startsWith("fastapi")?"fastapi":i.startsWith("nestjs")?"nestjs":null:null}function Gi(t,i){let e=t.indexOf(i);if(e>=0&&e+1<t.length)return t[e+1];let o=t.find(r=>r.startsWith(`${i}=`));if(o)return o.slice(i.length+1)}async function Xt(t,i){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\`.
|
|
1483
|
+
Reason: ${i}.
|
|
1457
1484
|
Install Python 3.10+ to use the interactive wizard and full kit catalog.
|
|
1458
|
-
`),1;let
|
|
1485
|
+
`),1;let r=t[2],n=t[3];if(!r||!n)return process.stderr.write(`Usage: rapidkit create project <kit> <name> [--output <dir>]
|
|
1459
1486
|
Tip: offline fallback supports only fastapi* and nestjs* kits.
|
|
1460
|
-
`),1;let a=
|
|
1461
|
-
Reason: ${
|
|
1462
|
-
Requested kit: ${
|
|
1487
|
+
`),1;let a=Li(r);if(!a)return process.stderr.write(`RapidKit (npm) could not run the Python core engine to create this kit.
|
|
1488
|
+
Reason: ${i}.
|
|
1489
|
+
Requested kit: ${r}
|
|
1463
1490
|
Offline fallback only supports: fastapi.standard, nestjs.standard (and their shorthands).
|
|
1464
1491
|
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
|
|
1492
|
+
`),1;let s=Gi(t,"--output")||process.cwd(),c=w.resolve(s,n),l=t.includes("--skip-git")||t.includes("--no-git"),p=t.includes("--skip-install");try{if(await k.ensureDir(w.dirname(c)),await k.pathExists(c))return process.stderr.write(`\u274C Directory "${c}" already exists
|
|
1493
|
+
`),1;let d="pip",u=St(process.cwd());if(u)try{let{readWorkspaceMarker:h}=await Promise.resolve().then(()=>(Ht(),ke)),y=await h(u);y?.metadata?.npm?.installMethod&&(d=y.metadata.npm.installMethod,console.log(`[DEBUG] Detected workspace engine: ${d}`));}catch(h){console.log("[DEBUG] Failed to read workspace marker:",h);}else console.log("[DEBUG] No workspace found, using default engine: pip");if(await k.ensureDir(c),await Ae(c,{project_name:n,template:a,skipGit:l,skipInstall:p,engine:d}),u){let{syncWorkspaceProjects:h}=await Promise.resolve().then(()=>(Q(),q));await h(u,!0);}return 0}catch(d){return process.stderr.write(`RapidKit (npm) offline fallback failed: ${d?.message??d}
|
|
1494
|
+
`),1}}async function Ui(t){let i=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 e=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(!!!It(process.cwd())){if(e)await rt(process.cwd(),{skipGit:n,yes:r,userConfig:await ht()});else if(!o)if(r)await rt(process.cwd(),{skipGit:n,yes:!0,userConfig:await ht()});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 ht()});}}let s=t.filter(c=>{let l=c.split("=")[0];return !i.has(c)&&!i.has(l)});try{await ut();let c=await B(s,{cwd:process.cwd()});if(c===0){let l=St(process.cwd());if(l){try{let d=t[3];if(d){let u=t.indexOf("--output"),h=u>=0?t[u+1]:".",y=w.resolve(process.cwd(),h,d),x=w.join(l,".python-version"),A=w.join(y,".python-version");if(F.existsSync(x)&&F.existsSync(y)){let D=F.readFileSync(x,"utf-8");F.writeFileSync(A,D.trim()+`
|
|
1495
|
+
`),f.debug(`Synced Python version ${D.trim()} from workspace to ${d}`);}}}catch(d){f.debug("Could not sync Python version from workspace:",d);}let{syncWorkspaceProjects:p}=await Promise.resolve().then(()=>(Q(),q));await p(l,!0);}}return c}catch(c){let l=Qt(c);return l?await Xt(s,l):(process.stderr.write(`RapidKit (npm) failed to run the Python core engine: ${c?.message??c}
|
|
1496
|
+
`),1)}}if(t[0]==="create"&&t[1]!=="project")try{await ut();let e=await B(t,{cwd:process.cwd()});if(e===0){let o=St(process.cwd());if(o){let{syncWorkspaceProjects:r}=await Promise.resolve().then(()=>(Q(),q));await r(o,!0);}}return e}catch(e){let o=Qt(e);return o?await Xt(t,o):(process.stderr.write(`RapidKit (npm) failed to run the Python core engine: ${e?.message??e}
|
|
1497
|
+
`),1)}return await ut(),await B(t,{cwd:process.cwd()})}catch(e){let o=Qt(e);return o?await Xt(t,o):(process.stderr.write(`RapidKit (npm) failed to run the Python core engine: ${e?.message??e}
|
|
1498
|
+
`),1)}}var Ve=["init","dev","start","build","test","lint","format","create","help","--help","-h"];function Hi(t){let i=t;for(;;){let e=w.join(i,".rapidkit","context.json");if(F.existsSync(e))return e;let o=w.dirname(i);if(o===i)break;i=o;}return null}function It(t){let i=t;for(;;){let e=w.join(i,".rapidkit-workspace");if(F.existsSync(e))return e;let o=w.dirname(i);if(o===i)break;i=o;}return null}function St(t){let i=t;for(;;){let e=w.join(i,".rapidkit-workspace");if(F.existsSync(e))return i;let o=w.dirname(i);if(o===i)break;i=o;}return null}async function Bi(){let t=process.cwd(),i=process.argv.slice(2);if(i[0]==="create")return false;try{let c=i[0],l=!c||c==="--help"||c==="-h"||c==="help";if(It(t)&&l){let d=await B(c?["--help"]:[],{cwd:t});process.exit(d);}}catch{}try{let c=i[0],l=c==="shell"&&i[1]==="activate",p=c==="create",d=await ae(t,{cwd:t,timeoutMs:1200});if(d.ok&&d.data?.isRapidkitProject&&d.data.engine==="python"&&!l&&!p){let u=await B(process.argv.slice(2),{cwd:t});process.exit(u);}}catch{}let e=Hi(t),o=process.platform==="win32",r=o?[w.join(t,"rapidkit.cmd"),w.join(t,"rapidkit"),w.join(t,".rapidkit","rapidkit.cmd"),w.join(t,".rapidkit","rapidkit")]:[w.join(t,"rapidkit"),w.join(t,".rapidkit","rapidkit")],n=null;for(let c of r)if(await k.pathExists(c)){n=c;break}let a=i[0],s=a==="create";if(n&&a&&Ve.includes(a)&&!s){f.debug(`Delegating to local CLI: ${n} ${i.join(" ")}`);let c=spawn(n,i,{stdio:"inherit",cwd:t,shell:o});return c.on("close",l=>{process.exit(l??0);}),c.on("error",l=>{f.error(`Failed to run local rapidkit: ${l.message}`),process.exit(1);}),true}if(e&&await k.pathExists(e))try{if((await k.readJson(e)).engine==="pip"){let l=i[0],d=process.platform==="win32"?[w.join(t,"rapidkit.cmd"),w.join(t,"rapidkit"),w.join(t,".rapidkit","rapidkit.cmd"),w.join(t,".rapidkit","rapidkit")]:[w.join(t,"rapidkit"),w.join(t,".rapidkit","rapidkit")],u=null;for(let y of d)if(await k.pathExists(y)){u=y;break}if(u&&l&&Ve.includes(l)){f.debug(`Delegating to local CLI (early detection): ${u} ${i.join(" ")}`);let y=spawn(u,i,{stdio:"inherit",cwd:t});return y.on("close",x=>process.exit(x??0)),y.on("error",x=>{f.error(`Failed to run local rapidkit: ${x.message}`),process.exit(1);}),!0}if(l==="shell"&&i[1]==="activate"){let y=`# RapidKit: activation snippet - eval "$(rapidkit shell activate)"
|
|
1472
1499
|
VENV='.venv'
|
|
1473
1500
|
if [ -f "$VENV/bin/activate" ]; then
|
|
1474
1501
|
. "$VENV/bin/activate"
|
|
@@ -1479,9 +1506,9 @@ export RAPIDKIT_PROJECT_ROOT="$(pwd)"
|
|
|
1479
1506
|
export PATH="$(pwd)/.rapidkit:$(pwd):$PATH"
|
|
1480
1507
|
`;console.log(m.green.bold(`
|
|
1481
1508
|
\u2705 Activation snippet \u2014 run the following to activate this project in your current shell:
|
|
1482
|
-
`)),console.log(
|
|
1509
|
+
`)),console.log(y),console.log(m.gray(`
|
|
1483
1510
|
\u{1F4A1} After activation you can run: rapidkit dev
|
|
1484
|
-
`)),process.exit(0);}let
|
|
1511
|
+
`)),process.exit(0);}let h=await B(i,{cwd:t});process.exit(h);}}catch{}return false}var Z=null,At=false,tt=new Command;async function Yi(t){if(t.length===0)return false;let i=t[0],e=t[1];if(i==="shell"&&e==="activate"||i==="workspace"||i==="doctor")return false;if(t.includes("--tui"))return true;if(i==="--help"||i==="-h"||i==="help"||i==="--version"||i==="-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 Vt();return r?r.has(i):!!(ye.has(i)||t.length>1)}tt.name("rapidkit").description("Create RapidKit workspaces and projects").version(H());tt.addHelpText("beforeAll",`RapidKit
|
|
1485
1512
|
|
|
1486
1513
|
Global CLI
|
|
1487
1514
|
Create RapidKit workspaces and projects
|
|
@@ -1495,58 +1522,27 @@ Project Commands
|
|
|
1495
1522
|
rapidkit dev
|
|
1496
1523
|
|
|
1497
1524
|
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,
|
|
1525
|
+
`);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,i)=>{try{i.debug&&(f.setDebug(!0),f.debug("Debug mode enabled"));let e=await ht();f.debug("User config loaded",e);let o=await oe();f.debug("RapidKit config loaded",o);let r=ne(e,o,{author:i.author,pythonVersion:void 0,skipGit:i.skipGit});f.debug("Merged config",r),i.updateCheck!==!1&&await ee(),console.log(m.blue.bold(`
|
|
1499
1526
|
\u{1F680} Welcome to RapidKit!
|
|
1500
|
-
`)),t||(
|
|
1501
|
-
\u274C ${
|
|
1502
|
-
`),process.exit(1)),
|
|
1527
|
+
`)),t||(zi(),process.exit(0));try{re(t);}catch(s){throw s instanceof G&&(f.error(`
|
|
1528
|
+
\u274C ${s.message}`),s.details&&f.warn(`\u{1F4A1} ${s.details}
|
|
1529
|
+
`),process.exit(1)),s}let n=w.resolve(process.cwd(),t);Z=n,await k.pathExists(n)&&(f.error(`
|
|
1503
1530
|
\u274C Directory "${t}" already exists`),console.log(m.cyan(`
|
|
1504
1531
|
\u{1F4A1} Choose a different name or delete the existing directory.
|
|
1505
|
-
`)),process.exit(1));let
|
|
1532
|
+
`)),process.exit(1));let a=!!i.template;if(i.dryRun){console.log(m.cyan(`
|
|
1506
1533
|
\u{1F50D} Dry-run mode - showing what would be created:
|
|
1507
|
-
`)),console.log(m.white("\u{1F4C2} Path:"),
|
|
1508
|
-
`)),
|
|
1509
|
-
`),
|
|
1510
|
-
`),
|
|
1511
|
-
\u274C ${
|
|
1512
|
-
\u274C An unexpected error occurred:`),console.error(
|
|
1513
|
-
VENV='.venv'
|
|
1514
|
-
if [ -f "$VENV/bin/activate" ]; then
|
|
1515
|
-
. "$VENV/bin/activate"
|
|
1516
|
-
elif [ -f "$VENV/bin/activate.fish" ]; then
|
|
1517
|
-
source "$VENV/bin/activate.fish"
|
|
1518
|
-
fi
|
|
1519
|
-
export RAPIDKIT_PROJECT_ROOT="$(pwd)"
|
|
1520
|
-
export PATH="$(pwd)/.rapidkit:$(pwd):$PATH"
|
|
1521
|
-
`;console.log(m.green.bold(`
|
|
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:
|
|
1534
|
+
`)),console.log(m.white("\u{1F4C2} Path:"),n),console.log(m.white("\u{1F4E6} Type:"),a?`Project (${i.template})`:"Workspace"),console.log();return}if(!i.yes&&!a?await Jt.prompt([{type:"input",name:"author",message:"Author name:",default:process.env.USER||"RapidKit User"}]):i.yes&&console.log(m.gray(`Using default values (--yes flag)
|
|
1535
|
+
`)),a){let s=String(i.template||"").trim(),c=s.toLowerCase(),l=c==="fastapi"?"fastapi.standard":c==="nestjs"?"nestjs.standard":s;if(!!!It(process.cwd())){if(i.createWorkspace)await rt(process.cwd(),{skipGit:i.skipGit,yes:i.yes,userConfig:e});else if(!i.noWorkspace)if(i.yes)await rt(process.cwd(),{skipGit:i.skipGit,yes:!0,userConfig:e});else {let{createWs:y}=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}]);y&&await rt(process.cwd(),{skipGit:i.skipGit,yes:!1,userConfig:e});}}let d=["create","project",l,t,"--output",process.cwd(),"--install-essentials"],u=await B(d,{cwd:process.cwd()});u!==0&&process.exit(u);let h=It(process.cwd());if(h){let y=w.dirname(h),x=w.join(y,".python-version"),A=w.join(n,".python-version");try{if(await k.pathExists(x)){let D=F.readFileSync(x,"utf-8");F.writeFileSync(A,D.trim()+`
|
|
1536
|
+
`),f.debug(`Synced Python version ${D.trim()} from workspace to project`);}}catch(D){f.debug("Could not sync Python version from workspace:",D);}}if(!i.skipInstall){let y=await B(["init",n],{cwd:process.cwd()});if(y!==0&&process.exit(y),h){let x=w.dirname(h),A=w.join(x,".python-version"),D=w.join(n,".python-version");try{if(await k.pathExists(A)){let O=F.readFileSync(A,"utf-8");F.writeFileSync(D,O.trim()+`
|
|
1537
|
+
`),f.debug(`Re-synced Python version ${O.trim()} after init`);}}catch(O){f.debug("Could not re-sync Python version after init:",O);}}}}else await Ce(t,{skipGit:i.skipGit,dryRun:i.dryRun,yes:i.yes,userConfig:r,installMethod:i.installMethod});}catch(e){e instanceof G?(f.error(`
|
|
1538
|
+
\u274C ${e.message}`),e.details&&f.warn(`\u{1F4A1} ${e.details}`),f.debug("Error code:",e.code)):(f.error(`
|
|
1539
|
+
\u274C An unexpected error occurred:`),console.error(e)),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(m.red(`Unknown shell command: ${t}`)),process.exit(1));let i=process.cwd();function e(c){let l=c;for(;;){let p=w.join(l,".rapidkit","context.json");if(F.existsSync(p))return p;let d=w.dirname(l);if(d===l)break;l=d;}return null}let o=e(i);function r(c){let l=c;for(;;){let p=w.join(l,".venv"),d=w.join(l,".rapidkit","activate");if(F.existsSync(d)||F.existsSync(p))return {venv:p,activateFile:d};let u=w.dirname(l);if(u===l)break;l=u;}return null}let n=r(i);!o&&!n&&(console.log(m.yellow("No RapidKit project found in this directory")),process.exit(1));let a;n&&F.existsSync(n.activateFile)?a=n.activateFile:n&&F.existsSync(n.venv)?a=process.platform==="win32"?w.join(n.venv,"Scripts","activate"):w.join(n.venv,"bin","activate"):(console.log(m.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)").option("--json","Output results in JSON format (for CI/CD pipelines)").option("--fix","Automatically fix common issues (with confirmation)").action(async t=>{await Ke(t);});tt.command("workspace <action>").description("Manage RapidKit workspaces (list, sync)").action(async t=>{if(t==="list"){let{listWorkspaces:i}=await Promise.resolve().then(()=>(Q(),q));await i();}else if(t==="sync"){let i=St(process.cwd());i||(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:e}=await Promise.resolve().then(()=>(Q(),q));console.log(m.cyan(`\u{1F4C2} Scanning workspace: ${w.basename(i)}`)),await e(i);}else console.log(m.red(`Unknown workspace action: ${t}`)),console.log(m.gray("Available: list, sync")),process.exit(1);});function zi(){console.log(m.white(`Usage:
|
|
1544
1540
|
`)),console.log(m.cyan(" npx rapidkit <workspace-name> [options]")),console.log(m.cyan(` npx rapidkit create <...>
|
|
1545
1541
|
`)),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
1542
|
`)),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
1543
|
`)),console.log(m.gray(`Tip: set RAPIDKIT_SHOW_LEGACY=1 to show legacy template flags in help.
|
|
1548
|
-
`));}process.on("SIGINT",async()=>{if(!
|
|
1544
|
+
`));}process.on("SIGINT",async()=>{if(!At){if(At=true,console.log(m.yellow(`
|
|
1549
1545
|
|
|
1550
|
-
\u26A0\uFE0F Interrupted by user`)),
|
|
1551
|
-
`),
|
|
1552
|
-
`),
|
|
1546
|
+
\u26A0\uFE0F Interrupted by user`)),Z&&await k.pathExists(Z)){console.log(m.gray("Cleaning up partial installation..."));try{await k.remove(Z),console.log(m.green("\u2713 Cleanup complete"));}catch(t){f.debug("Cleanup failed:",t);}}process.exit(130);}});process.on("SIGTERM",async()=>{if(!At){if(At=true,f.debug("Received SIGTERM"),Z&&await k.pathExists(Z))try{await k.remove(Z);}catch(t){f.debug("Cleanup failed:",t);}process.exit(143);}});Bi().then(async t=>{if(!t){let i=process.argv.slice(2);if(process.env.RAPIDKIT_NPM_DEBUG_ARGS==="1"&&process.stderr.write(`[rapidkit-npm] argv=${JSON.stringify(i)}
|
|
1547
|
+
`),i[0]==="create"){let o=await Ui(i);process.exit(o);}let e=await Yi(i);if(process.env.RAPIDKIT_NPM_DEBUG_ARGS==="1"&&process.stderr.write(`[rapidkit-npm] shouldForwardToCore=${e}
|
|
1548
|
+
`),e){let o=await B(i,{cwd:process.cwd()});process.exit(o);}tt.parse();}});export{Ui as handleCreateOrFallback};
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rapidkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
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.
|
|
3
|
+
"version": "0.17.0",
|
|
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",
|