rapidkit 0.21.0 → 0.21.2
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 +80 -8
- package/dist/index.js +96 -91
- package/dist/package.json +8 -3
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
|
-
# 🚀 RapidKit
|
|
3
|
+
# 🚀 RapidKit CLI
|
|
4
4
|
|
|
5
5
|
### Build Production-Ready APIs in Seconds
|
|
6
6
|
|
|
@@ -13,12 +13,25 @@ Clean architecture • Zero boilerplate • Instant deployment.
|
|
|
13
13
|
[](https://github.com/getrapidkit/rapidkit-npm/stargazers)
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
npx rapidkit
|
|
17
|
-
cd my-
|
|
16
|
+
npx rapidkit init
|
|
17
|
+
cd my-workspace
|
|
18
|
+
npx rapidkit create project
|
|
19
|
+
cd <project-name>
|
|
18
20
|
npx rapidkit init && npx rapidkit dev
|
|
19
21
|
# ✅ Production-ready API running at http://localhost:8000
|
|
20
22
|
```
|
|
21
23
|
|
|
24
|
+
Using Node.js/NestJS? Use this direct kit command (inside or outside a workspace):
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npx rapidkit create project nestjs.standard my-service # standard kit
|
|
28
|
+
```
|
|
29
|
+
Using Python/FastAPI? Use these direct kit commands (inside or outside a workspace):
|
|
30
|
+
```bash
|
|
31
|
+
npx rapidkit create project fastapi.standard my-service # standard kit
|
|
32
|
+
npx rapidkit create project fastapi.ddd my-service # DDD kit
|
|
33
|
+
```
|
|
34
|
+
|
|
22
35
|
[Quick Start](#-quick-start) • [Docs](https://getrapidkit.com) • [VS Code Extension](https://marketplace.visualstudio.com/items?itemName=rapidkit.rapidkit-vscode) • [Examples](https://github.com/getrapidkit/rapidkit-examples)
|
|
23
36
|
|
|
24
37
|
---
|
|
@@ -88,6 +101,30 @@ cd my-api && npx rapidkit init && npx rapidkit dev
|
|
|
88
101
|
|
|
89
102
|
## 🚀 Quick Start
|
|
90
103
|
|
|
104
|
+
### Option 0: Fastest Start (`npx rapidkit init`)
|
|
105
|
+
|
|
106
|
+
Use this when you want the quickest complete flow (workspace + project + run):
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
cd ~/my-empty-folder
|
|
110
|
+
npx rapidkit init
|
|
111
|
+
cd my-workspace
|
|
112
|
+
npx rapidkit create project
|
|
113
|
+
cd <project-name>
|
|
114
|
+
npx rapidkit init && npx rapidkit dev
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
This is the recommended quickest onboarding path for most users.
|
|
118
|
+
`npx rapidkit init` is context-aware and auto-detects plain folders, workspace roots, and project directories.
|
|
119
|
+
|
|
120
|
+
Prefer direct kit selection (works both inside and outside a workspace):
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
npx rapidkit create project fastapi.standard my-service
|
|
124
|
+
npx rapidkit create project fastapi.ddd my-service
|
|
125
|
+
npx rapidkit create project nestjs.standard my-service
|
|
126
|
+
```
|
|
127
|
+
|
|
91
128
|
### Option 1: Single Project (Fastest)
|
|
92
129
|
|
|
93
130
|
Perfect for trying out RapidKit or building a standalone service:
|
|
@@ -129,6 +166,10 @@ Organize multiple microservices with a shared environment:
|
|
|
129
166
|
```bash
|
|
130
167
|
# 1. Create workspace
|
|
131
168
|
npx rapidkit my-workspace
|
|
169
|
+
# Or with explicit command mode
|
|
170
|
+
npx rapidkit create workspace my-workspace
|
|
171
|
+
# Or interactive naming
|
|
172
|
+
npx rapidkit create workspace
|
|
132
173
|
cd my-workspace
|
|
133
174
|
|
|
134
175
|
# 2. Activate environment (choose one):
|
|
@@ -336,7 +377,7 @@ my-service/
|
|
|
336
377
|
├── Dockerfile # Production container
|
|
337
378
|
├── Makefile # Quick commands
|
|
338
379
|
├── package.json # npm dependencies
|
|
339
|
-
├──
|
|
380
|
+
├── package-lock.json # Locked dependencies
|
|
340
381
|
├── nest-cli.json # NestJS CLI config
|
|
341
382
|
├── tsconfig.json # TypeScript config
|
|
342
383
|
├── tsconfig.build.json # Build config
|
|
@@ -461,6 +502,11 @@ rapidkit add module auth api_keys db_postgres redis rate_limiting observability
|
|
|
461
502
|
### Global Commands (Run Anywhere)
|
|
462
503
|
|
|
463
504
|
```bash
|
|
505
|
+
# Workspace creation
|
|
506
|
+
npx rapidkit <name> # Legacy stable workspace creation
|
|
507
|
+
npx rapidkit create workspace # Interactive workspace creation
|
|
508
|
+
npx rapidkit create workspace <name> # Create workspace with name
|
|
509
|
+
|
|
464
510
|
# Project creation
|
|
465
511
|
npx rapidkit create project # Interactive wizard
|
|
466
512
|
npx rapidkit create project <kit> <name> # Direct creation
|
|
@@ -486,10 +532,15 @@ npx rapidkit --version # Show version
|
|
|
486
532
|
npx rapidkit --help # Show help
|
|
487
533
|
```
|
|
488
534
|
|
|
489
|
-
|
|
535
|
+
`npx rapidkit create workspace` interactive prompts:
|
|
536
|
+
- Without a name: asks workspace name, author name, Python version, and install method.
|
|
537
|
+
- With a name: asks author name, Python version, and install method.
|
|
538
|
+
- With `--yes`: skips prompts and uses defaults.
|
|
539
|
+
|
|
540
|
+
### Init & Project Commands
|
|
490
541
|
|
|
491
542
|
```bash
|
|
492
|
-
npx rapidkit init #
|
|
543
|
+
npx rapidkit init # Context-aware init (see behavior below)
|
|
493
544
|
npx rapidkit dev # Start dev server with hot reload
|
|
494
545
|
npx rapidkit start # Start production server
|
|
495
546
|
npx rapidkit build # Build for production
|
|
@@ -498,6 +549,24 @@ npx rapidkit lint # Run linting
|
|
|
498
549
|
npx rapidkit format # Format code
|
|
499
550
|
```
|
|
500
551
|
|
|
552
|
+
`npx rapidkit init` behavior:
|
|
553
|
+
- In a plain folder: creates `my-workspace` (or `my-workspace-<n>` if needed) and initializes it.
|
|
554
|
+
- In a workspace root: initializes workspace dependencies, then initializes all detected child projects.
|
|
555
|
+
- In a project inside a workspace: initializes only that project.
|
|
556
|
+
|
|
557
|
+
Quick examples:
|
|
558
|
+
|
|
559
|
+
```bash
|
|
560
|
+
# Plain folder
|
|
561
|
+
cd ~/new-folder && npx rapidkit init
|
|
562
|
+
|
|
563
|
+
# Workspace root
|
|
564
|
+
cd ~/my-workspace && npx rapidkit init
|
|
565
|
+
|
|
566
|
+
# Project inside workspace
|
|
567
|
+
cd ~/my-workspace/my-api && npx rapidkit init
|
|
568
|
+
```
|
|
569
|
+
|
|
501
570
|
### Module Commands
|
|
502
571
|
|
|
503
572
|
```bash
|
|
@@ -515,6 +584,8 @@ npx rapidkit <name> --yes # Skip prompts
|
|
|
515
584
|
npx rapidkit <name> --skip-git # Skip git init
|
|
516
585
|
npx rapidkit <name> --dry-run # Preview only
|
|
517
586
|
npx rapidkit <name> --debug # Verbose logging
|
|
587
|
+
npx rapidkit create workspace --yes # Create default my-workspace non-interactive
|
|
588
|
+
npx rapidkit create workspace <name> --yes # Create named workspace non-interactive
|
|
518
589
|
|
|
519
590
|
# Project creation
|
|
520
591
|
npx rapidkit create --output <dir> # Custom location
|
|
@@ -525,8 +596,9 @@ npx rapidkit create --no-update-check # Skip version check
|
|
|
525
596
|
|
|
526
597
|
| Command | Description | Context |
|
|
527
598
|
|---------|-------------|---------|
|
|
599
|
+
| `create workspace` | Create workspace | Anywhere |
|
|
528
600
|
| `create project` | Create project | Anywhere |
|
|
529
|
-
| `init` |
|
|
601
|
+
| `init` | Context-aware dependency setup | Folder / workspace / project |
|
|
530
602
|
| `dev` | Start dev server | Inside project |
|
|
531
603
|
| `test` | Run tests | Inside project |
|
|
532
604
|
| `add module` | Add module to project | Inside project |
|
|
@@ -553,7 +625,7 @@ npx rapidkit create --no-update-check # Skip version check
|
|
|
553
625
|
|
|
554
626
|
**NestJS Projects:**
|
|
555
627
|
- Node.js 20.19.6+
|
|
556
|
-
- npm
|
|
628
|
+
- npm
|
|
557
629
|
|
|
558
630
|
### Optional but Recommended
|
|
559
631
|
|
package/dist/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {d,c as c$1,g,a as a$1}from'./chunk-D2ZRDZOE.js';import {d as d$1,b as b$1}from'./chunk-RV6HBTFC.js';import {c,a,b}from'./chunk-7LU4Z66R.js';import {Command,Option}from'commander';import u from'chalk';import
|
|
2
|
+
import {d,c as c$1,g,a as a$1}from'./chunk-D2ZRDZOE.js';import {d as d$1,b as b$1}from'./chunk-RV6HBTFC.js';import {c,a,b}from'./chunk-7LU4Z66R.js';import {Command,Option}from'commander';import u from'chalk';import ue from'inquirer';import w from'path';import {exec,spawn}from'child_process';import S,{promises}from'fs';import*as zt from'os';import zt__default from'os';import {fileURLToPath,pathToFileURL}from'url';import Xt from'validate-npm-package-name';import*as k from'fs-extra';import k__default from'fs-extra';import {execa}from'execa';import Fe from'ora';import lo from'nunjucks';import uo from'crypto';import {promisify}from'util';var Yt=".rapidkitrc.json",Qt=["rapidkit.config.js","rapidkit.config.mjs","rapidkit.config.cjs"];async function z(){let e=w.join(zt__default.homedir(),Yt);try{let o=await promises.readFile(e,"utf-8"),t=JSON.parse(o);return a.debug(`Loaded config from ${e}`),t}catch{return a.debug("No user config found, using defaults"),{}}}async function Ze(e=process.cwd()){let o=e,t=w.parse(o).root;for(;o!==t;){for(let n of Qt){let i=w.join(o,n);try{await promises.access(i),a.debug(`Found config file: ${i}`);let s=await import(pathToFileURL(i).href),c=s.default||s;return a.debug(`Loaded RapidKit config from ${n}`),c}catch{continue}}o=w.dirname(o);}return a.debug("No RapidKit config file found, using defaults"),{}}function et(e,o,t){return {author:t.author||o.workspace?.defaultAuthor||e.author,pythonVersion:o.workspace?.pythonVersion||e.pythonVersion,defaultInstallMethod:t.defaultInstallMethod||o.workspace?.installMethod||e.defaultInstallMethod,defaultKit:t.defaultKit||o.projects?.defaultKit||e.defaultKit,skipGit:t.skipGit??o.projects?.skipGit??e.skipGit,license:t.license||e.license,testRapidKitPath:t.testRapidKitPath||e.testRapidKitPath}}function he(e){return process.env.RAPIDKIT_DEV_PATH||e.testRapidKitPath||void 0}var F=class extends Error{constructor(t,n,i){super(t);this.code=n;this.details=i;this.name="RapidKitError",Error.captureStackTrace(this,this.constructor);}},Z=class extends F{constructor(o,t){let n=t?`Python ${o}+ required, found ${t}`:`Python ${o}+ not found`;super(n,"PYTHON_NOT_FOUND","Please install Python from https://www.python.org/downloads/");}},re=class extends F{constructor(){super("Poetry is not installed","POETRY_NOT_FOUND","Install Poetry from https://python-poetry.org/docs/#installation");}},se=class extends F{constructor(){super("pipx is not installed","PIPX_NOT_FOUND","Install pipx from https://pypa.github.io/pipx/installation/");}},ye=class extends F{constructor(o){super(`Directory "${o}" already exists`,"DIRECTORY_EXISTS","Please choose a different name or remove the existing directory");}},H=class extends F{constructor(o,t){super(`Invalid project name: "${o}"`,"INVALID_PROJECT_NAME",t);}},K=class extends F{constructor(o,t){let n=`Installation failed at: ${o}`,i=`${t.message}
|
|
3
3
|
|
|
4
4
|
Troubleshooting:
|
|
5
5
|
- Check your internet connection
|
|
6
6
|
- Verify Python/Poetry installation
|
|
7
|
-
- Try running with --debug flag for more details`;super(n,"INSTALLATION_ERROR",
|
|
7
|
+
- Try running with --debug flag for more details`;super(n,"INSTALLATION_ERROR",i);}},ee=class extends F{constructor(){super("RapidKit Python package is not yet available on PyPI","RAPIDKIT_NOT_AVAILABLE",`Available options:
|
|
8
8
|
1. Install Python 3.10+ and retry the same command
|
|
9
9
|
2. Use the core workflow: npx rapidkit create workspace <name>
|
|
10
10
|
3. Offline fallback (limited): npx rapidkit create project fastapi.standard <name> --output .
|
|
11
11
|
|
|
12
|
-
Legacy: set RAPIDKIT_SHOW_LEGACY=1 to reveal template-mode flags in help.`);}};function
|
|
12
|
+
Legacy: set RAPIDKIT_SHOW_LEGACY=1 to reveal template-mode flags in help.`);}};function Me(e){let o=Xt(e);if(!o.validForNewPackages){let n=o.errors||[],i=o.warnings||[],r=[...n,...i];throw new H(e,`NPM validation failed: ${r.join(", ")}`)}if(!/^[a-z][a-z0-9_-]*$/.test(e))throw new H(e,"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(e.toLowerCase()))throw new H(e,`"${e}" is a reserved name. Please choose a different name.`);if(e.length<2)throw new H(e,"Name must be at least 2 characters long");if(e.length>214)throw new H(e,"Name must be less than 214 characters");return true}function eo(e){return typeof e=="object"&&e!==null}async function to(e,o,t,n=8e3){try{let i=await execa(e,o,{cwd:t,timeout:n,reject:false,stdio:"pipe"});return {ok:i.exitCode===0,exitCode:i.exitCode,stdout:i.stdout,stderr:i.stderr}}catch(i){return {ok:false,exitCode:void 0,stdout:"",stderr:i instanceof Error?i.message:String(i)}}}async function oo(e,o){let t=["-m","rapidkit",...e],n=["python3","python"];for(let i of n){let r=await to(i,t,o?.cwd,o?.timeoutMs);if(!r.ok)continue;let s=(r.stdout??"").trim();try{let c=JSON.parse(s);return eo(c)?{ok:true,command:i,exitCode:r.exitCode,stdout:r.stdout,stderr:r.stderr,data:c}:{ok:false,command:i,exitCode:r.exitCode,stdout:r.stdout,stderr:r.stderr}}catch{return {ok:false,command:i,exitCode:r.exitCode,stdout:r.stdout,stderr:r.stderr}}}return {ok:false}}async function tt(e,o){let t=await oo(["project","detect","--path",e,"--json"],o);return !t.ok||!t.data||t.data.schema_version!==1?{ok:false,command:t.command,exitCode:t.exitCode,stdout:t.stdout,stderr:t.stderr}:t}function we(){return process.platform==="win32"?"python":"python3"}async function it(e,o,t,n){let i=d$1(o,c(),t);n&&(i.metadata||(i.metadata={}),i.metadata.python={version:n}),await b$1(e,i);}async function rt(e){await k.outputFile(w.join(e,".gitignore"),`.venv/
|
|
13
13
|
__pycache__/
|
|
14
14
|
*.pyc
|
|
15
15
|
.env
|
|
16
16
|
.rapidkit-workspace/
|
|
17
17
|
|
|
18
|
-
`,"utf-8");}async function
|
|
19
|
-
`,"utf-8"),a.debug(`Created .python-version with ${o}`);}catch(t){a.warn(`Failed to create .python-version: ${t}`);}}function ae(){let e=w.join(
|
|
18
|
+
`,"utf-8");}async function ot(e){try{let{stdout:o}=await execa(e,["--version"],{timeout:3e3}),t=o.match(/Python (\d+\.\d+\.\d+)/);if(t)return t[1]}catch{}return null}async function no(e,o){try{await promises.writeFile(w.join(e,".python-version"),`${o}
|
|
19
|
+
`,"utf-8"),a.debug(`Created .python-version with ${o}`);}catch(t){a.warn(`Failed to create .python-version: ${t}`);}}function ae(){let e=w.join(zt.homedir(),".local","bin"),t=(process.env.PATH||"").split(w.delimiter).filter(Boolean);t.includes(e)||(process.env.PATH=[e,...t].join(w.delimiter));}async function ke(e,o){ae(),e.start("Checking pipx installation");try{return await execa("pipx",["--version"]),e.succeed("pipx found"),{kind:"binary"}}catch{}let t=we();try{return await execa(t,["-m","pipx","--version"]),e.succeed("pipx found"),{kind:"python-module",pythonCmd:t}}catch{}if(o)throw new se;let{installPipx:n}=await ue.prompt([{type:"confirm",name:"installPipx",message:"pipx is not installed. Install it now (user install via python -m pip)?",default:true}]);if(!n)throw new se;e.start("Installing pipx (user install)");try{try{await execa(t,["-m","pip","install","--user","--upgrade","pip"]);}catch{}await execa(t,["-m","pip","install","--user","--upgrade","pipx"]);}catch(i){let r=i,s=String(r?.stderr||r?.shortMessage||r?.message||"");throw new K("Install pipx with python -m pip",i instanceof Error?i:new Error(s))}e.succeed("pipx installed"),ae();try{return await execa(t,["-m","pipx","--version"]),{kind:"python-module",pythonCmd:t}}catch(i){let r=i,s=String(r?.stderr||r?.shortMessage||r?.message||"pipx not runnable after install");throw new K("Verify pipx after install",new Error(`${s}
|
|
20
20
|
|
|
21
|
-
Try reopening your terminal or run: python3 -m pipx ensurepath`))}}async function
|
|
21
|
+
Try reopening your terminal or run: python3 -m pipx ensurepath`))}}async function te(e,o){return e.kind==="binary"?execa("pipx",o):execa(e.pythonCmd,["-m","pipx",...o])}async function io(e,o){ae(),e.start("Checking Poetry installation");try{await execa("poetry",["--version"]),e.succeed("Poetry found");return}catch{}if(o)throw new re;let{installPoetry:t}=await ue.prompt([{type:"confirm",name:"installPoetry",message:"Poetry is not installed. Install it now using pipx?",default:true}]);if(!t)throw new re;let n=await ke(e,o);e.start("Installing Poetry with pipx");try{await te(n,["install","poetry"]);}catch(i){let r=i,s=String(r?.stderr||r?.shortMessage||r?.message||"");if(/already\s+installed|already\s+seems\s+to\s+be\s+installed|exists/i.test(s))try{await te(n,["upgrade","poetry"]);}catch{}else throw new K("Install Poetry with pipx",i instanceof Error?i:new Error(s))}e.succeed("Poetry installed"),ae();try{await execa("poetry",["--version"]);}catch(i){let r=i,s=String(r?.stderr||r?.shortMessage||r?.message||"Poetry not found on PATH");throw new K("Verify Poetry after pipx install",new Error(`${s}
|
|
22
22
|
|
|
23
|
-
Poetry may be installed but not on PATH yet. Try reopening your terminal or run: pipx ensurepath`))}}function
|
|
23
|
+
Poetry may be installed but not on PATH yet. Try reopening your terminal or run: pipx ensurepath`))}}function ro(e){let o=e==="poetry";return `#!/usr/bin/env sh
|
|
24
24
|
set -eu
|
|
25
25
|
|
|
26
26
|
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
@@ -39,7 +39,7 @@ echo "- If you used venv: ensure .venv exists (or re-run the installer)." 1>&2
|
|
|
39
39
|
${o?`echo "- If you used Poetry: run 'poetry install' and retry, or activate the env." 1>&2
|
|
40
40
|
`:""}echo "Tip: you can also run: ./.venv/bin/rapidkit --help" 1>&2
|
|
41
41
|
exit 1
|
|
42
|
-
`}function
|
|
42
|
+
`}function so(e){return `@echo off
|
|
43
43
|
setlocal
|
|
44
44
|
|
|
45
45
|
set "SCRIPT_DIR=%~dp0"
|
|
@@ -58,42 +58,42 @@ if %ERRORLEVEL%==0 if exist "%SCRIPT_DIR%\\pyproject.toml" (
|
|
|
58
58
|
`:""}echo RapidKit launcher could not find a local Python CLI. 1>&2
|
|
59
59
|
echo Tip: run .venv\\Scripts\\rapidkit.exe --help 1>&2
|
|
60
60
|
exit /b 1
|
|
61
|
-
`}async function
|
|
61
|
+
`}async function st(e,o){await k.outputFile(w.join(e,"rapidkit"),ro(o),{encoding:"utf-8",mode:493}),await k.outputFile(w.join(e,"rapidkit.cmd"),so(o),"utf-8");}async function ve(e,o){let{skipGit:t=false,testMode:n=false,demoMode:i=false,dryRun:r=false,yes:s=false,userConfig:c={},installMethod:a$1}=o,l=e||"rapidkit",d=w.resolve(process.cwd(),l);if(await k.pathExists(d))throw new ye(l);if(r){await co(d,l,i,c);return}if(i){await ao(d,l,t);return}let m=s?{pythonVersion:c.pythonVersion||"3.10",installMethod:a$1||c.defaultInstallMethod||"poetry"}:await ue.prompt([{type:"list",name:"pythonVersion",message:"Select Python version for RapidKit:",choices:["3.10","3.11","3.12"],default:c.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:c.defaultInstallMethod||"poetry"}]);a.step(1,3,"Setting up RapidKit environment");let p=Fe("Creating directory").start();try{await k.ensureDir(d),p.succeed("Directory created"),p.start("Detecting Python version");let y=null,P=await at(m.pythonVersion);if(P)y=await ot(P),y?(a.info(` Detected Python ${y}`),p.succeed(`Python ${y} detected`)):p.warn("Could not detect exact Python version");else {let v=we();y=await ot(v),y?p.succeed(`Python ${y} detected`):p.warn("Could not detect Python version, proceeding with defaults");}if(await it(d,l,m.installMethod,y||void 0),y&&await no(d,y),await rt(d),m.installMethod==="poetry")try{await ct(d,m.pythonVersion,p,n,c,s);}catch(v){let C=v?.details||v?.message||String(v);if(C.includes("pyenv")||C.includes("exit status 127")||C.includes("returned non-zero exit status 127")){p.warn("Poetry encountered Python discovery issues, trying venv method"),a.debug(`Poetry error (attempting venv fallback): ${C}`);try{await De(d,m.pythonVersion,p,n,c),m.installMethod="venv";}catch(M){throw M}}else throw v}else m.installMethod==="venv"?await De(d,m.pythonVersion,p,n,c):await lt(d,p,n,c,s);if(await st(d,m.installMethod),await dt(d,m.installMethod),p.succeed("RapidKit environment ready!"),!o.skipGit){p.start("Initializing git repository");try{await execa("git",["init"],{cwd:d}),await execa("git",["add","."],{cwd:d}),await execa("git",["commit","-m","Initial commit: RapidKit environment"],{cwd:d}),p.succeed("Git repository initialized");}catch{p.warn("Could not initialize git repository");}}try{let{registerWorkspace:v}=await import('./workspace-LZZGJRGV.js');await v(d,l);}catch{console.warn(u.gray("Note: Could not register workspace in shared registry"));}if(console.log(u.green(`
|
|
62
62
|
\u2728 RapidKit environment created successfully!
|
|
63
63
|
`)),console.log(u.cyan("\u{1F4C2} Location:"),u.white(d)),console.log(u.cyan(`\u{1F680} Get started:
|
|
64
|
-
`)),console.log(u.white(` cd ${
|
|
64
|
+
`)),console.log(u.white(` cd ${l}`)),m.installMethod==="poetry"){let v="source $(poetry env info --path)/bin/activate";try{ae();let{stdout:C}=await execa("poetry",["--version"]),E=C.match(/Poetry.*?(\d+)\.(\d+)/);E&&(parseInt(E[1])>=2?v="source $(poetry env info --path)/bin/activate":v="poetry shell");}catch{}console.log(u.white(` ${v} # Or: poetry run rapidkit`)),console.log(u.white(" rapidkit create # Interactive mode")),console.log(u.white(" cd <project-name> && rapidkit init && rapidkit dev"));}else m.installMethod==="venv"?(console.log(u.white(" source .venv/bin/activate # On Windows: .venv\\Scripts\\activate")),console.log(u.white(" rapidkit create # Interactive mode")),console.log(u.white(" cd <project-name> && rapidkit init && rapidkit dev"))):(console.log(u.white(" rapidkit create # Interactive mode")),console.log(u.white(" cd <project-name> && rapidkit init && rapidkit dev")));console.log(u.white(`
|
|
65
65
|
\u{1F4A1} For more information, check the README.md file.`)),console.log(u.cyan(`
|
|
66
66
|
\u{1F4DA} RapidKit commands:`)),console.log(u.white(" rapidkit create - Create a new project (interactive)")),console.log(u.white(" rapidkit dev - Run development server")),console.log(u.white(" rapidkit add module <name> - Add a module (e.g., settings)")),console.log(u.white(" rapidkit list - List available kits")),console.log(u.white(" rapidkit modules - List available modules")),console.log(u.white(` rapidkit --help - Show all commands
|
|
67
67
|
`));}catch(y){p.fail("Failed to create RapidKit environment"),console.error(u.red(`
|
|
68
|
-
\u274C Error:`),y);try{await k.remove(d);}catch{}throw y}}async function
|
|
69
|
-
package-mode = false`):
|
|
68
|
+
\u274C Error:`),y);try{await k.remove(d);}catch{}throw y}}async function at(e){let o=[];try{let{stdout:t}=await execa("pyenv",["root"]),n=t.trim();o.push(w.join(n,"versions",`${e}.*`,"bin","python"));let[i,r]=e.split(".");o.push(w.join(n,"versions",`${i}.${r}.*`,"bin","python"));}catch{}o.push(`python${e}`,`python3.${e.split(".")[1]}`,"python3","python"),o.push(`/usr/bin/python${e}`,"/usr/bin/python3",`/usr/local/bin/python${e}`,"/usr/local/bin/python3");for(let t of o)try{let n=t;if(t.includes("*")){if(n=(await execa("sh",["-c",`ls -d ${t} 2>/dev/null | head -1`])).stdout.trim(),!n)continue;n=w.join(n.split("/").slice(0,-1).join("/"),"../bin/python");}let{stdout:i}=await execa(n,["--version"],{timeout:2e3}),r=i.match(/Python (\d+\.\d+)/)?.[1];if(r&&parseFloat(r)>=parseFloat(e))return await execa(n,["-c","import sys; sys.exit(0)"],{timeout:2e3}),n}catch{continue}return null}async function ct(e,o,t,n,i,r=false){await io(t,r),t.start("Finding Python interpreter");let s=await at(o);s?(a.debug(`Found working Python: ${s}`),t.succeed("Python found")):t.warn("Could not verify Python path, proceeding with default"),t.start("Initializing Poetry project"),await execa("poetry",["init","--no-interaction","--python",`^${o}`],{cwd:e}),t.succeed("Poetry project initialized");let c=w.join(e,"pyproject.toml"),l=await promises.readFile(c,"utf-8");l.includes("[tool.poetry]")?l=l.replace("[tool.poetry]",`[tool.poetry]
|
|
69
|
+
package-mode = false`):l.includes("[project]")&&(l.includes("[build-system]")?l=l.replace("[build-system]",`
|
|
70
70
|
[tool.poetry]
|
|
71
71
|
package-mode = false
|
|
72
72
|
|
|
73
|
-
[build-system]`):
|
|
73
|
+
[build-system]`):l+=`
|
|
74
74
|
|
|
75
75
|
[tool.poetry]
|
|
76
76
|
package-mode = false
|
|
77
|
-
`),await promises.writeFile(l,
|
|
77
|
+
`),await promises.writeFile(c,l,"utf-8"),t.start("Configuring Poetry");try{if(await execa("poetry",["config","virtualenvs.in-project","true","--local"],{cwd:e}),s)try{await execa("poetry",["env","use",s],{cwd:e}),a.debug(`Poetry configured to use: ${s}`);}catch(d){a.debug(`Could not set Poetry env to ${s}: ${d}`);}t.succeed("Poetry configured");}catch{t.warn("Could not configure Poetry virtualenvs.in-project");}t.start("Creating virtualenv");try{await execa("poetry",["install","--no-root"],{cwd:e,timeout:3e4}),t.succeed("Virtualenv created");}catch(d){a.debug(`Failed to create virtualenv: ${d}`),t.warn("Could not create virtualenv, proceeding with add command");}if(t.start("Installing RapidKit"),n){let d=he(i||{});if(!d)throw new K("Test mode installation",new Error("No local RapidKit path configured. Set RAPIDKIT_DEV_PATH environment variable."));a.debug(`Installing from local path: ${d}`),t.text="Installing RapidKit from local path (test mode)",await execa("poetry",["add",d],{cwd:e});}else {t.text="Installing RapidKit from PyPI";let d=false,m=null;for(let p=1;p<=3;p++)try{await execa("poetry",["add","rapidkit-core"],{cwd:e,timeout:6e4*p}),d=true;break}catch(y){m=y,a.debug(`Poetry add attempt ${p} failed: ${y}`),p<3&&(t.text=`Retrying installation (attempt ${p+1}/3)`,await new Promise(P=>setTimeout(P,2e3)));}if(!d){let p=m?.stderr||m?.message||"Unknown error";throw a.debug(`All Poetry install attempts failed. Last error: ${p}`),p.includes("Could not find")||p.includes("No matching distribution")?new ee:new K("Install rapidkit-core with Poetry",new Error(`Failed to install rapidkit-core after 3 attempts.
|
|
78
78
|
Error: ${p}
|
|
79
79
|
|
|
80
80
|
Possible solutions:
|
|
81
81
|
1. Check your internet connection
|
|
82
82
|
2. Try installing manually: cd ${w.basename(e)} && poetry add rapidkit-core
|
|
83
|
-
3. Use venv method instead: npx rapidkit ${w.basename(e)} --install-method=venv`))}}t.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:d}=await import('./pythonRapidkitExec-GFCAVUOY.js');if(!await d()&&!n){t.start("Installing RapidKit globally with pipx for CLI access");let p=await
|
|
83
|
+
3. Use venv method instead: npx rapidkit ${w.basename(e)} --install-method=venv`))}}t.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:d}=await import('./pythonRapidkitExec-GFCAVUOY.js');if(!await d()&&!n){t.start("Installing RapidKit globally with pipx for CLI access");let p=await ke(t,r);try{await te(p,["install","rapidkit-core"]),t.succeed("RapidKit installed globally");}catch(y){t.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),a.debug(`pipx install failed: ${y}`);}}}catch(d){a.debug(`Global install check skipped: ${d}`);}}async function De(e,o,t,n,i,r=false){t.start(`Checking Python ${o}`);let s=we();try{let{stdout:a}=await execa(s,["--version"]),l=a.match(/Python (\d+\.\d+)/)?.[1];if(l&&parseFloat(l)<parseFloat(o))throw new Z(o,l);t.succeed(`Python ${l} found`);}catch(a){throw a instanceof Z?a:new Z(o)}t.start("Creating virtual environment");try{await execa(s,["-m","venv",".venv"],{cwd:e}),t.succeed("Virtual environment created");}catch(a){if(t.fail("Failed to create virtual environment"),(d=>typeof d=="object"&&d!==null&&"stdout"in d&&typeof d.stdout=="string")(a)&&a.stdout.includes("ensurepip is not")){let d=a.stdout.match(/apt install (python[\d.]+-venv)/),m=d?d[1]:"python3-venv";throw new K("Python venv module not available",new Error(`Virtual environment creation failed.
|
|
84
84
|
|
|
85
85
|
On Debian/Ubuntu systems, install the venv package:
|
|
86
|
-
sudo apt install ${
|
|
86
|
+
sudo apt install ${m}
|
|
87
87
|
|
|
88
88
|
Or use Poetry instead (recommended):
|
|
89
|
-
npx rapidkit ${w.basename(e)} --yes`))}throw new
|
|
89
|
+
npx rapidkit ${w.basename(e)} --yes`))}throw new K("Virtual environment creation",a instanceof Error?a:new Error(String(a)))}t.start("Installing RapidKit");let c=w.join(e,".venv",process.platform==="win32"?"Scripts":"bin",process.platform==="win32"?"python.exe":"python");if(await execa(c,["-m","pip","install","--upgrade","pip"],{cwd:e}),n){let a$1=he(i||{});if(!a$1)throw new K("Test mode installation",new Error("No local RapidKit path configured. Set RAPIDKIT_DEV_PATH environment variable."));a.debug(`Installing from local path: ${a$1}`),t.text="Installing RapidKit from local path (test mode)",await execa(c,["-m","pip","install","-e",a$1],{cwd:e});}else {t.text="Installing RapidKit from PyPI";let a$1=false,l=null;for(let d=1;d<=3;d++)try{await execa(c,["-m","pip","install","rapidkit-core"],{cwd:e,timeout:6e4*d}),a$1=true;break}catch(m){l=m,a.debug(`pip install attempt ${d} failed: ${m}`),d<3&&(t.text=`Retrying installation (attempt ${d+1}/3)`,await new Promise(p=>setTimeout(p,2e3)));}if(!a$1){let d=l?.stderr||l?.message||"Unknown error";throw a.debug(`All pip install attempts failed. Last error: ${d}`),d.includes("Could not find")||d.includes("No matching distribution")?new ee:new K("Install rapidkit-core with pip",new Error(`Failed to install rapidkit-core after 3 attempts.
|
|
90
90
|
Error: ${d}
|
|
91
91
|
|
|
92
92
|
Possible solutions:
|
|
93
93
|
1. Check your internet connection
|
|
94
94
|
2. Try installing manually: cd ${w.basename(e)} && .venv/bin/python -m pip install rapidkit-core
|
|
95
|
-
3. Use Poetry instead: npx rapidkit ${w.basename(e)} --install-method=poetry`))}}t.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:a$1}=await import('./pythonRapidkitExec-GFCAVUOY.js');if(!await a$1()&&!n){t.start("Installing RapidKit globally with pipx for CLI access");let d=await
|
|
96
|
-
`,"utf-8");}async function
|
|
95
|
+
3. Use Poetry instead: npx rapidkit ${w.basename(e)} --install-method=poetry`))}}t.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:a$1}=await import('./pythonRapidkitExec-GFCAVUOY.js');if(!await a$1()&&!n){t.start("Installing RapidKit globally with pipx for CLI access");let d=await ke(t,r);try{await te(d,["install","rapidkit-core"]),t.succeed("RapidKit installed globally");}catch(m){t.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),a.debug(`pipx install failed: ${m}`);}}}catch(a$1){a.debug(`Global install check skipped: ${a$1}`);}}async function lt(e,o,t,n,i=false){let r=await ke(o,i);if(o.start("Installing RapidKit globally with pipx"),t){let s=he(n||{});if(!s)throw new K("Test mode installation",new Error("No local RapidKit path configured. Set RAPIDKIT_DEV_PATH environment variable."));a.debug(`Installing from local path: ${s}`),o.text="Installing RapidKit from local path (test mode)",await te(r,["install","-e",s]);}else {o.text="Installing RapidKit from PyPI";try{await te(r,["install","rapidkit-core"]);}catch{throw new ee}}o.succeed("RapidKit installed globally"),await k.outputFile(w.join(e,".rapidkit-global"),`RapidKit installed globally with pipx
|
|
96
|
+
`,"utf-8");}async function Y(e,o){let{skipGit:t=false,testMode:n=false,userConfig:i={},yes:r=false,installMethod:s,pythonVersion:c="3.10"}=o||{},a=s||i.defaultInstallMethod||"poetry";await it(e,w.basename(e),a),await rt(e);let l=Fe("Registering workspace").start();try{a==="poetry"?await ct(e,c,l,n,i,r):a==="venv"?await De(e,c,l,n,i):await lt(e,l,n,i,r),await st(e,a),await dt(e,a),l.succeed("Workspace registered");try{let{registerWorkspace:d}=await import('./workspace-LZZGJRGV.js');await d(e,w.basename(e));}catch{}if(!t){l.start("Initializing git repository");try{await execa("git",["init"],{cwd:e}),await execa("git",["add","."],{cwd:e}),await execa("git",["commit","-m","Initial commit: RapidKit workspace"],{cwd:e}),l.succeed("Git repository initialized");}catch{l.warn("Could not initialize git repository");}}}catch(d){throw l.fail("Failed to register workspace"),d}}async function dt(e,o){let i=`# RapidKit Workspace
|
|
97
97
|
|
|
98
98
|
This directory contains a RapidKit development environment.
|
|
99
99
|
|
|
@@ -204,7 +204,7 @@ If you encounter issues:
|
|
|
204
204
|
2. Check RapidKit installation: \`rapidkit --version\`
|
|
205
205
|
3. Run diagnostics: \`rapidkit doctor\`
|
|
206
206
|
4. Visit RapidKit documentation or GitHub issues
|
|
207
|
-
`;await promises.writeFile(w.join(e,"README.md"),
|
|
207
|
+
`;await promises.writeFile(w.join(e,"README.md"),i,"utf-8");}async function ao(e,o,t){let n=Fe("Creating demo workspace").start();try{await k.ensureDir(e),n.succeed("Directory created"),n.start("Setting up demo kit generator");let i=JSON.stringify({name:`${o}-workspace`,version:"1.0.0",private:true,description:"RapidKit demo workspace",scripts:{generate:"node generate-demo.js"}},null,2);await promises.writeFile(w.join(e,"package.json"),i,"utf-8"),await promises.writeFile(w.join(e,"generate-demo.js"),`#!/usr/bin/env node
|
|
208
208
|
/**
|
|
209
209
|
* Demo Kit Generator - Create FastAPI demo projects
|
|
210
210
|
*
|
|
@@ -703,7 +703,7 @@ __pycache__/
|
|
|
703
703
|
`,"utf-8"),await execa("git",["add","."],{cwd:e}),await execa("git",["commit","-m","Initial commit: Demo workspace"],{cwd:e}),n.succeed("Git repository initialized");}catch{n.warn("Could not initialize git repository");}}console.log(u.green(`
|
|
704
704
|
\u2728 Demo workspace created successfully!
|
|
705
705
|
`)),console.log(u.cyan("\u{1F4C2} Location:"),u.white(e)),console.log(u.cyan(`\u{1F680} Get started:
|
|
706
|
-
`)),console.log(u.white(` cd ${o}`)),console.log(u.white(" node generate-demo.js my-api")),console.log(u.white(" cd my-api")),console.log(u.white(" rapidkit init")),console.log(u.white(" rapidkit dev")),console.log(),console.log(u.yellow("\u{1F4A1} Note:"),"This is a demo workspace. For full RapidKit features:"),console.log(u.cyan(" pipx install rapidkit")),console.log();}catch(
|
|
706
|
+
`)),console.log(u.white(` cd ${o}`)),console.log(u.white(" node generate-demo.js my-api")),console.log(u.white(" cd my-api")),console.log(u.white(" rapidkit init")),console.log(u.white(" rapidkit dev")),console.log(),console.log(u.yellow("\u{1F4A1} Note:"),"This is a demo workspace. For full RapidKit features:"),console.log(u.cyan(" pipx install rapidkit")),console.log();}catch(i){throw n.fail("Failed to create demo workspace"),i}}async function co(e,o,t,n){console.log(u.cyan(`
|
|
707
707
|
\u{1F50D} Dry-run mode - showing what would be created:
|
|
708
708
|
`)),console.log(u.white("\u{1F4C2} Project path:"),e),console.log(u.white("\u{1F4E6} Project type:"),t?"Demo workspace":"Full RapidKit environment"),t?(console.log(u.white(`
|
|
709
709
|
\u{1F4DD} Files to create:`)),console.log(u.gray(" - package.json")),console.log(u.gray(" - generate-demo.js (project generator)")),console.log(u.gray(" - README.md")),console.log(u.gray(" - .gitignore")),console.log(u.white(`
|
|
@@ -712,7 +712,7 @@ __pycache__/
|
|
|
712
712
|
\u{1F4DD} Files to create:`)),console.log(u.gray(" - pyproject.toml (Poetry) or .venv/ (venv)")),console.log(u.gray(" - README.md")),console.log(u.gray(" - .gitignore")),console.log(u.white(`
|
|
713
713
|
\u{1F3AF} Next steps after creation:`)),console.log(u.gray(" 1. Install RapidKit Python package")),console.log(u.gray(" 2. Create projects with rapidkit CLI")),console.log(u.gray(" 3. Add modules and customize"))),console.log(u.white(`
|
|
714
714
|
\u{1F4A1} To proceed with actual creation, run without --dry-run flag
|
|
715
|
-
`));}var
|
|
715
|
+
`));}var mo=fileURLToPath(import.meta.url),go=w.dirname(mo);function fo(e=32){let o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=uo.randomBytes(e),n="";for(let i=0;i<e;i++)n+=o[t[i]%o.length];return n}async function pt(e,o){let t=o.template||"fastapi",n=t==="fastapi",i=n?"FastAPI":"NestJS",r=Fe(`Generating ${i} project...`).start();try{let s=w.resolve(go,".."),c$1=o.kit_name||`${t}.standard`,a;c$1==="fastapi.ddd"?a="fastapi-ddd":c$1.startsWith("fastapi")?a="fastapi-standard":a="nestjs-standard";let l=w.join(s,"templates","kits",a),d=lo.configure(l,{autoescape:false,trimBlocks:true,lstripBlocks:true});d.addFilter("generate_secret",function(v,C=32){return fo(C)});let m={project_name:o.project_name,author:o.author||"RapidKit User",description:o.description||(n?"FastAPI service generated with RapidKit":"NestJS application generated with RapidKit"),app_version:o.app_version||"0.1.0",license:o.license||"MIT",package_manager:o.package_manager||"npm",node_version:o.node_version||"20.0.0",database_type:o.database_type||"postgresql",include_caching:o.include_caching||false,created_at:new Date().toISOString(),rapidkit_version:c()},p;n?p=["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"]:p=["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 v of p){let C=w.join(l,v);try{await promises.access(C);}catch{continue}let E=await promises.readFile(C,"utf-8"),M;try{M=d.renderString(E,m);}catch(Jt){throw console.error(`Failed to render template: ${v}`),Jt}let U=v.replace(/\.j2$/,""),Se=w.join(e,U);await promises.mkdir(w.dirname(Se),{recursive:true}),await promises.writeFile(Se,M),(U.endsWith(".rapidkit/rapidkit")||U.endsWith(".rapidkit/cli.py")||U.endsWith(".rapidkit/activate")||U==="rapidkit")&&await promises.chmod(Se,493);}if(n){let v=w.join(l,".rapidkit","context.json"),C=w.join(e,".rapidkit","context.json");try{await promises.mkdir(w.join(e,".rapidkit"),{recursive:true}),await promises.copyFile(v,C);}catch{await promises.mkdir(w.join(e,".rapidkit"),{recursive:true});let M=o.engine||"pip";await promises.writeFile(C,JSON.stringify({engine:M,created_by:"rapidkit-npm-fallback"},null,2));}}let y=n?`# Python
|
|
716
716
|
__pycache__/
|
|
717
717
|
*.py[cod]
|
|
718
718
|
*$py.class
|
|
@@ -780,7 +780,7 @@ Thumbs.db
|
|
|
780
780
|
|
|
781
781
|
# Coverage
|
|
782
782
|
coverage/
|
|
783
|
-
`;if(await promises.writeFile(w.join(e,".gitignore"),y),
|
|
783
|
+
`;if(await promises.writeFile(w.join(e,".gitignore"),y),r.succeed(`${i} project generated!`),!o.skipGit){let v=Fe("Initializing git repository...").start();try{await execa("git",["init"],{cwd:e}),await execa("git",["add","."],{cwd:e}),await execa("git",["commit","-m",`Initial commit: ${i} project via RapidKit`],{cwd:e}),v.succeed("Git repository initialized");}catch{v.warn("Could not initialize git repository");}}if(!n&&!o.skipInstall){let v=o.package_manager||"npm",C=Fe(`Installing dependencies with ${v}...`).start();try{await execa(v,v==="yarn"?["install"]:v==="pnpm"?["install"]:["install"],{cwd:e}),C.succeed("Dependencies installed");}catch{C.warn(`Could not install dependencies. Run '${v} install' manually.`);}}let P=w.basename(e);console.log(`
|
|
784
784
|
${u.yellow("\u26A0\uFE0F Limited offline mode:")} This project was created using basic templates.
|
|
785
785
|
${u.gray("For full kit features, install Python 3.10+ and rapidkit-core:")}
|
|
786
786
|
${u.cyan(" sudo apt install python3 python3-pip python3-venv")}
|
|
@@ -852,65 +852,65 @@ ${u.bold("\u{1F310} API endpoints:")}
|
|
|
852
852
|
|
|
853
853
|
${u.gray("Alternative: npm run start:dev, ./rapidkit dev")}
|
|
854
854
|
${u.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
|
|
855
|
-
`);}catch(s){throw i.fail(`Failed to generate ${r} project`),s}}async function pt(){let e=process.platform==="win32"?["python","python3"]:["python3","python"];for(let o of e)try{let{stdout:t}=await execa(o,["--version"],{timeout:3e3}),n=t.match(/Python (\d+\.\d+\.\d+)/);if(n){let r=n[1],[i,s]=r.split(".").map(Number);return i<3||i===3&&s<10?{status:"warn",message:`Python ${r} (requires 3.10+)`,details:`${o} found but version is below minimum requirement`}:{status:"ok",message:`Python ${r}`,details:`Using ${o}`}}}catch{continue}return {status:"error",message:"Python not found",details:"Install Python 3.10+ and ensure it's in PATH"}}async function ut(){try{let{stdout:e}=await execa("poetry",["--version"],{timeout:3e3}),o=e.match(/Poetry .*version ([\d.]+)/);return o?{status:"ok",message:`Poetry ${o[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 mt(){try{let{stdout:e}=await execa("pipx",["--version"],{timeout:3e3});return {status:"ok",message:`pipx ${e.trim()}`,details:"Available for global tool installation"}}catch{return {status:"warn",message:"pipx not installed",details:"Optional: Install for isolated Python tools"}}}async function gt(){let e=process.env.HOME||process.env.USERPROFILE||"",o=[],t=[{location:"Global (pipx)",path:w.join(e,".local","bin","rapidkit")},{location:"Global (pipx)",path:w.join(e,"AppData","Roaming","Python","Scripts","rapidkit.exe")},{location:"Global (pyenv)",path:w.join(e,".pyenv","shims","rapidkit")},{location:"Global (system)",path:"/usr/local/bin/rapidkit"},{location:"Global (system)",path:"/usr/bin/rapidkit"}],n=[{location:"Workspace (.venv)",path:w.join(process.cwd(),".venv","bin","rapidkit")},{location:"Workspace (.venv)",path:w.join(process.cwd(),".venv","Scripts","rapidkit.exe")}];for(let{location:i,path:s}of [...t,...n])try{if(await k__default.pathExists(s)){let{stdout:l,exitCode:a}=await execa(s,["--version"],{timeout:3e3,reject:false});if(a===0&&(l.includes("RapidKit Version")||l.includes("RapidKit"))){let c=l.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);c&&o.push({location:i,path:s,version:c[1]});}}}catch{continue}if(o.length>0)return {status:"ok",message:`RapidKit Core ${o[0].version}`,paths:o.map(s=>({location:s.location,path:s.path,version:s.version}))};try{let{stdout:i,exitCode:s}=await execa("rapidkit",["--version"],{timeout:3e3,reject:false});if(s===0&&(i.includes("RapidKit Version")||i.includes("RapidKit"))){let l=i.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(l)return {status:"ok",message:`RapidKit Core ${l[1]}`,details:"Available via PATH"}}}catch{}try{let{stdout:i,exitCode:s}=await execa("poetry",["run","rapidkit","--version"],{timeout:3e3,reject:false});if(s===0&&(i.includes("RapidKit Version")||i.includes("RapidKit"))){let l=i.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(l)return {status:"ok",message:`RapidKit Core ${l[1]}`,details:"Available via Poetry"}}}catch{}let r=process.platform==="win32"?["python","python3"]:["python3","python"];for(let i of r)try{let{stdout:s,exitCode:l}=await execa(i,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:3e3,reject:false});if(l===0&&s&&!s.includes("Traceback")&&!s.includes("ModuleNotFoundError")){let a=s.trim();if(a)return {status:"ok",message:`RapidKit Core ${a}`,details:`Available in ${i} environment`}}}catch{continue}return {status:"error",message:"RapidKit Core not installed",details:"Install with: pipx install rapidkit-core"}}async function Ke(e,o){let t=w.join(e,"Dockerfile");o.hasDocker=await k__default.pathExists(t);let n=w.join(e,"tests"),r=w.join(e,"test");if(o.hasTests=await k__default.pathExists(n)||await k__default.pathExists(r),o.framework==="NestJS"){let i=w.join(e,".eslintrc.js"),s=w.join(e,".eslintrc.json");o.hasCodeQuality=await k__default.pathExists(i)||await k__default.pathExists(s);}else if(o.framework==="FastAPI"){let i=w.join(e,"ruff.toml"),s=w.join(e,"pyproject.toml");if(await k__default.pathExists(s))try{let l=await k__default.readFile(s,"utf8");o.hasCodeQuality=l.includes("[tool.ruff]")||await k__default.pathExists(i);}catch{o.hasCodeQuality=await k__default.pathExists(i);}}try{if(o.framework==="NestJS"){let{stdout:i}=await execa("npm",["audit","--json"],{cwd:e,reject:false});if(i)try{let l=JSON.parse(i).metadata?.vulnerabilities;l&&(o.vulnerabilities=(l.high||0)+(l.critical||0)+(l.moderate||0));}catch{}}else if(o.framework==="FastAPI"){let i=w.join(e,".venv"),s=process.platform==="win32"?w.join(i,"Scripts","python.exe"):w.join(i,"bin","python");if(await k__default.pathExists(s))try{let{stdout:l}=await execa(s,["-m","pip","list","--format=json"],{timeout:5e3,reject:false});if(l){JSON.parse(l);o.vulnerabilities=0;}}catch{}}}catch{}}async function po(e){let t={name:w.basename(e),path:e,venvActive:false,depsInstalled:false,coreInstalled:false,issues:[],fixCommands:[]},n=w.join(e,".rapidkit");if(!await k__default.pathExists(n))return t.issues.push("Not a valid RapidKit project (missing .rapidkit directory)"),t;try{let a=w.join(e,"registry.json");if(await k__default.pathExists(a)){let c=await k__default.readJson(a);c.installed_modules&&(t.stats={modules:c.installed_modules.length});}}catch{}try{let a=w.join(n,"project.json");if(await k__default.pathExists(a)){let c=await k__default.readJson(a);c.kit&&(t.kit=c.kit);}}catch{}try{let a=w.join(e,".git");if(await k__default.pathExists(a)){let{stdout:c}=await execa("git",["log","-1","--format=%cr"],{cwd:e,reject:false});c&&(t.lastModified=c.trim());}else {let c=await k__default.stat(e),g=Date.now()-c.mtime.getTime(),p=Math.floor(g/(1e3*60*60*24));t.lastModified=p===0?"today":`${p} day${p>1?"s":""} ago`;}}catch{}let r=w.join(e,"package.json"),i=w.join(e,"pyproject.toml"),s=await k__default.pathExists(r),l=await k__default.pathExists(i);if(s){t.framework="NestJS",t.venvActive=true;let a=w.join(e,"node_modules");if(await k__default.pathExists(a))try{let p=(await k__default.readdir(a)).filter(y=>!y.startsWith(".")&&!y.startsWith("_"));t.depsInstalled=p.length>0;}catch{t.depsInstalled=false;}t.depsInstalled||(t.issues.push("Dependencies not installed (node_modules empty or missing)"),t.fixCommands?.push(`cd ${e} && rapidkit init`)),t.coreInstalled=false;let c=w.join(e,".env");if(t.hasEnvFile=await k__default.pathExists(c),!t.hasEnvFile){let g=w.join(e,".env.example");await k__default.pathExists(g)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(`cd ${e} && cp .env.example .env`));}let d=w.join(e,"src");if(t.modulesHealthy=true,t.missingModules=[],await k__default.pathExists(d))try{let g=await k__default.readdir(d);t.modulesHealthy=g.length>0;}catch{t.modulesHealthy=false;}return await Ke(e,t),t}if(l){t.framework="FastAPI";let a=w.join(e,".venv");if(await k__default.pathExists(a)){t.venvActive=true;let p=process.platform==="win32"?w.join(a,"Scripts","python.exe"):w.join(a,"bin","python");if(await k__default.pathExists(p)){try{let{stdout:y}=await execa(p,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:2e3});t.coreInstalled=true,t.coreVersion=y.trim();}catch{t.coreInstalled=false;}try{await execa(p,["-c","import fastapi"],{timeout:2e3}),t.depsInstalled=true;}catch{try{let y=w.join(a,"lib");if(await k__default.pathExists(y)){let v=(await k__default.readdir(y)).find(C=>C.startsWith("python"));if(v){let C=w.join(y,v,"site-packages");if(await k__default.pathExists(C)){let M=(await k__default.readdir(C)).filter(U=>!U.startsWith("_")&&!U.includes("dist-info")&&!["pip","setuptools","wheel","pkg_resources"].includes(U));t.depsInstalled=M.length>0;}}}t.depsInstalled||(t.issues.push("Dependencies not installed"),t.fixCommands?.push(`cd ${e} && rapidkit init`));}catch{t.issues.push("Could not verify dependency installation");}}}else t.issues.push("Virtual environment exists but Python executable not found");}else t.issues.push("Virtual environment not created"),t.fixCommands?.push(`cd ${e} && rapidkit init`);let c=w.join(e,".env");if(t.hasEnvFile=await k__default.pathExists(c),!t.hasEnvFile){let p=w.join(e,".env.example");await k__default.pathExists(p)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(`cd ${e} && cp .env.example .env`));}let d=w.join(e,"src"),g=w.join(e,"modules");if(t.modulesHealthy=true,t.missingModules=[],await k__default.pathExists(d)){let p=w.join(d,"__init__.py");await k__default.pathExists(p)||(t.modulesHealthy=false,t.missingModules.push("src/__init__.py"));}if(await k__default.pathExists(g))try{let p=await ft(g);for(let y of p){let P=w.join(g,y,"__init__.py");await k__default.pathExists(P)||(t.modulesHealthy=false,t.missingModules.push(`modules/${y}/__init__.py`));}}catch{}return !t.modulesHealthy&&t.missingModules.length>0&&t.issues.push(`Missing module init files: ${t.missingModules.join(", ")}`),await Ke(e,t),t}return t.issues.push("Unknown project type (no package.json or pyproject.toml)"),await Ke(e,t),t}async function ft(e){try{return (await k__default.readdir(e,{withFileTypes:true})).filter(t=>t.isDirectory()).map(t=>t.name)}catch{try{let o=await k__default.readdir(e),t=[];for(let n of o)try{(await k__default.stat(w.join(e,n))).isDirectory()&&t.push(n);}catch{continue}return t}catch{return []}}}async function uo(e,o,t){let n=new Set,r=[{dir:e,depth:0}];for(;r.length>0;){let i=r.shift();if(!i)break;try{let s=await k__default.readdir(i.dir);for(let l of s){if(t.has(l))continue;let a=w.join(i.dir,l),c;try{c=await k__default.stat(a);}catch{continue}if(!c.isDirectory())continue;let d=w.join(a,".rapidkit");if(await k__default.pathExists(d)){n.add(a);continue}i.depth<o&&r.push({dir:a,depth:i.depth+1});}}catch{continue}}return Array.from(n)}async function mo(e){let o=e,t=w.parse(o).root;for(;o!==t;){let n=[w.join(o,".rapidkit-workspace"),w.join(o,".rapidkit","workspace-marker.json"),w.join(o,".rapidkit","config.json")];for(let r of n)if(await k__default.pathExists(r))return o;o=w.dirname(o);}return null}function go(e,o){let t=0,n=0,r=0;return e.forEach(s=>{s.status==="ok"?t++:s.status==="warn"?n++:s.status==="error"&&r++;}),o.forEach(s=>{s.issues.length===0&&s.venvActive&&s.depsInstalled?t++:s.issues.length>0&&n++;}),{total:t+n+r,passed:t,warnings:n,errors:r}}async function fo(e){let o=w.basename(e);try{let r=w.join(e,".rapidkit-workspace");await k__default.pathExists(r)&&(o=(await k__default.readJSON(r)).name||o);}catch{try{let r=w.join(e,".rapidkit","config.json");o=(await k__default.readJSON(r)).workspace_name||o;}catch{}}let t={workspacePath:e,workspaceName:o,python:await pt(),poetry:await ut(),pipx:await mt(),rapidkitCore:await gt(),projects:[]};try{let r=new Set([".git",".venv","node_modules",".rapidkit","dist","build","coverage","__pycache__"]),i=new Set,s=w.join(e,".rapidkit");await k__default.pathExists(s)&&i.add(e);let l=async(a,c)=>{if(c<0)return;let d=await ft(a);for(let g of d){if(r.has(g))continue;let p=w.join(a,g),y=w.join(p,".rapidkit");if(await k__default.pathExists(y)){i.add(p);continue}c>0&&await l(p,c-1);}};if(await l(e,1),a.debug(`Workspace scan (shallow) found ${i.size} project(s)`),i.size===0){let a$1=await uo(e,3,r);a$1.forEach(c=>i.add(c)),a.debug(`Workspace scan (deep fallback) found ${a$1.length} project(s)`);}i.size>0&&a.debug(`Workspace projects detected: ${Array.from(i).join(", ")}`);for(let a of i){let c=await po(a);t.projects.push(c);}}catch(r){a.debug(`Failed to scan workspace projects: ${r}`);}let n=[t.python,t.poetry,t.pipx,t.rapidkitCore];if(t.healthScore=go(n,t.projects),t.rapidkitCore.status==="ok"){let r=t.rapidkitCore.message.match(/([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);r&&(t.coreVersion=r[1]);}return t}function q(e,o){let t=e.status==="ok"?"\u2705":e.status==="warn"?"\u26A0\uFE0F":"\u274C",n=e.status==="ok"?u.green:e.status==="warn"?u.yellow:u.red;console.log(`${t} ${u.bold(o)}: ${n(e.message)}`),e.paths&&e.paths.length>0?e.paths.forEach(r=>{let i=r.version?u.cyan(` -> ${r.version}`):"";console.log(` ${u.cyan("\u2022")} ${u.gray(r.location)}: ${u.dim(r.path)}${i}`);}):e.details&&console.log(` ${u.gray(e.details)}`);}function ho(e){let o=e.issues.length>0,t=o?"\u26A0\uFE0F":"\u2705",n=o?u.yellow:u.green;if(console.log(`
|
|
856
|
-
${t} ${u.bold("Project")}: ${n(e.name)}`),e.framework){let
|
|
857
|
-
${u.bold.cyan("\u{1F527} Quick Fix:")}`),e.fixCommands.forEach(
|
|
855
|
+
`);}catch(s){throw r.fail(`Failed to generate ${i} project`),s}}async function mt(){let e=process.platform==="win32"?["python","python3"]:["python3","python"];for(let o of e)try{let{stdout:t}=await execa(o,["--version"],{timeout:3e3}),n=t.match(/Python (\d+\.\d+\.\d+)/);if(n){let i=n[1],[r,s]=i.split(".").map(Number);return r<3||r===3&&s<10?{status:"warn",message:`Python ${i} (requires 3.10+)`,details:`${o} found but version is below minimum requirement`}:{status:"ok",message:`Python ${i}`,details:`Using ${o}`}}}catch{continue}return {status:"error",message:"Python not found",details:"Install Python 3.10+ and ensure it's in PATH"}}async function gt(){try{let{stdout:e}=await execa("poetry",["--version"],{timeout:3e3}),o=e.match(/Poetry .*version ([\d.]+)/);return o?{status:"ok",message:`Poetry ${o[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 ft(){try{let{stdout:e}=await execa("pipx",["--version"],{timeout:3e3});return {status:"ok",message:`pipx ${e.trim()}`,details:"Available for global tool installation"}}catch{return {status:"warn",message:"pipx not installed",details:"Optional: Install for isolated Python tools"}}}async function ht(){let e=process.env.HOME||process.env.USERPROFILE||"",o=[],t=[{location:"Global (pipx)",path:w.join(e,".local","bin","rapidkit")},{location:"Global (pipx)",path:w.join(e,"AppData","Roaming","Python","Scripts","rapidkit.exe")},{location:"Global (pyenv)",path:w.join(e,".pyenv","shims","rapidkit")},{location:"Global (system)",path:"/usr/local/bin/rapidkit"},{location:"Global (system)",path:"/usr/bin/rapidkit"}],n=[{location:"Workspace (.venv)",path:w.join(process.cwd(),".venv","bin","rapidkit")},{location:"Workspace (.venv)",path:w.join(process.cwd(),".venv","Scripts","rapidkit.exe")}];for(let{location:r,path:s}of [...t,...n])try{if(await k__default.pathExists(s)){let{stdout:c,exitCode:a}=await execa(s,["--version"],{timeout:3e3,reject:false});if(a===0&&(c.includes("RapidKit Version")||c.includes("RapidKit"))){let l=c.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);l&&o.push({location:r,path:s,version:l[1]});}}}catch{continue}if(o.length>0)return {status:"ok",message:`RapidKit Core ${o[0].version}`,paths:o.map(s=>({location:s.location,path:s.path,version:s.version}))};try{let{stdout:r,exitCode:s}=await execa("rapidkit",["--version"],{timeout:3e3,reject:false});if(s===0&&(r.includes("RapidKit Version")||r.includes("RapidKit"))){let c=r.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(c)return {status:"ok",message:`RapidKit Core ${c[1]}`,details:"Available via PATH"}}}catch{}try{let{stdout:r,exitCode:s}=await execa("poetry",["run","rapidkit","--version"],{timeout:3e3,reject:false});if(s===0&&(r.includes("RapidKit Version")||r.includes("RapidKit"))){let c=r.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(c)return {status:"ok",message:`RapidKit Core ${c[1]}`,details:"Available via Poetry"}}}catch{}let i=process.platform==="win32"?["python","python3"]:["python3","python"];for(let r of i)try{let{stdout:s,exitCode:c}=await execa(r,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:3e3,reject:false});if(c===0&&s&&!s.includes("Traceback")&&!s.includes("ModuleNotFoundError")){let a=s.trim();if(a)return {status:"ok",message:`RapidKit Core ${a}`,details:`Available in ${r} environment`}}}catch{continue}return {status:"error",message:"RapidKit Core not installed",details:"Install with: pipx install rapidkit-core"}}async function Te(e,o){let t=w.join(e,"Dockerfile");o.hasDocker=await k__default.pathExists(t);let n=w.join(e,"tests"),i=w.join(e,"test");if(o.hasTests=await k__default.pathExists(n)||await k__default.pathExists(i),o.framework==="NestJS"){let r=w.join(e,".eslintrc.js"),s=w.join(e,".eslintrc.json");o.hasCodeQuality=await k__default.pathExists(r)||await k__default.pathExists(s);}else if(o.framework==="FastAPI"){let r=w.join(e,"ruff.toml"),s=w.join(e,"pyproject.toml");if(await k__default.pathExists(s))try{let c=await k__default.readFile(s,"utf8");o.hasCodeQuality=c.includes("[tool.ruff]")||await k__default.pathExists(r);}catch{o.hasCodeQuality=await k__default.pathExists(r);}}try{if(o.framework==="NestJS"){let{stdout:r}=await execa("npm",["audit","--json"],{cwd:e,reject:false});if(r)try{let c=JSON.parse(r).metadata?.vulnerabilities;c&&(o.vulnerabilities=(c.high||0)+(c.critical||0)+(c.moderate||0));}catch{}}else if(o.framework==="FastAPI"){let r=w.join(e,".venv"),s=process.platform==="win32"?w.join(r,"Scripts","python.exe"):w.join(r,"bin","python");if(await k__default.pathExists(s))try{let{stdout:c}=await execa(s,["-m","pip","list","--format=json"],{timeout:5e3,reject:false});if(c){JSON.parse(c);o.vulnerabilities=0;}}catch{}}}catch{}}async function yo(e){let t={name:w.basename(e),path:e,venvActive:false,depsInstalled:false,coreInstalled:false,issues:[],fixCommands:[]},n=w.join(e,".rapidkit");if(!await k__default.pathExists(n))return t.issues.push("Not a valid RapidKit project (missing .rapidkit directory)"),t;try{let a=w.join(e,"registry.json");if(await k__default.pathExists(a)){let l=await k__default.readJson(a);l.installed_modules&&(t.stats={modules:l.installed_modules.length});}}catch{}try{let a=w.join(n,"project.json");if(await k__default.pathExists(a)){let l=await k__default.readJson(a);l.kit&&(t.kit=l.kit);}}catch{}try{let a=w.join(e,".git");if(await k__default.pathExists(a)){let{stdout:l}=await execa("git",["log","-1","--format=%cr"],{cwd:e,reject:false});l&&(t.lastModified=l.trim());}else {let l=await k__default.stat(e),m=Date.now()-l.mtime.getTime(),p=Math.floor(m/(1e3*60*60*24));t.lastModified=p===0?"today":`${p} day${p>1?"s":""} ago`;}}catch{}let i=w.join(e,"package.json"),r=w.join(e,"pyproject.toml"),s=await k__default.pathExists(i),c=await k__default.pathExists(r);if(s){t.framework="NestJS",t.venvActive=true;let a=w.join(e,"node_modules");if(await k__default.pathExists(a))try{let p=(await k__default.readdir(a)).filter(y=>!y.startsWith(".")&&!y.startsWith("_"));t.depsInstalled=p.length>0;}catch{t.depsInstalled=false;}t.depsInstalled||(t.issues.push("Dependencies not installed (node_modules empty or missing)"),t.fixCommands?.push(`cd ${e} && rapidkit init`)),t.coreInstalled=false;let l=w.join(e,".env");if(t.hasEnvFile=await k__default.pathExists(l),!t.hasEnvFile){let m=w.join(e,".env.example");await k__default.pathExists(m)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(`cd ${e} && cp .env.example .env`));}let d=w.join(e,"src");if(t.modulesHealthy=true,t.missingModules=[],await k__default.pathExists(d))try{let m=await k__default.readdir(d);t.modulesHealthy=m.length>0;}catch{t.modulesHealthy=false;}return await Te(e,t),t}if(c){t.framework="FastAPI";let a=w.join(e,".venv");if(await k__default.pathExists(a)){t.venvActive=true;let p=process.platform==="win32"?w.join(a,"Scripts","python.exe"):w.join(a,"bin","python");if(await k__default.pathExists(p)){try{let{stdout:y}=await execa(p,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:2e3});t.coreInstalled=true,t.coreVersion=y.trim();}catch{t.coreInstalled=false;}try{await execa(p,["-c","import fastapi"],{timeout:2e3}),t.depsInstalled=true;}catch{try{let y=w.join(a,"lib");if(await k__default.pathExists(y)){let v=(await k__default.readdir(y)).find(C=>C.startsWith("python"));if(v){let C=w.join(y,v,"site-packages");if(await k__default.pathExists(C)){let M=(await k__default.readdir(C)).filter(U=>!U.startsWith("_")&&!U.includes("dist-info")&&!["pip","setuptools","wheel","pkg_resources"].includes(U));t.depsInstalled=M.length>0;}}}t.depsInstalled||(t.issues.push("Dependencies not installed"),t.fixCommands?.push(`cd ${e} && rapidkit init`));}catch{t.issues.push("Could not verify dependency installation");}}}else t.issues.push("Virtual environment exists but Python executable not found");}else t.issues.push("Virtual environment not created"),t.fixCommands?.push(`cd ${e} && rapidkit init`);let l=w.join(e,".env");if(t.hasEnvFile=await k__default.pathExists(l),!t.hasEnvFile){let p=w.join(e,".env.example");await k__default.pathExists(p)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(`cd ${e} && cp .env.example .env`));}let d=w.join(e,"src"),m=w.join(e,"modules");if(t.modulesHealthy=true,t.missingModules=[],await k__default.pathExists(d)){let p=w.join(d,"__init__.py");await k__default.pathExists(p)||(t.modulesHealthy=false,t.missingModules.push("src/__init__.py"));}if(await k__default.pathExists(m))try{let p=await yt(m);for(let y of p){let P=w.join(m,y,"__init__.py");await k__default.pathExists(P)||(t.modulesHealthy=false,t.missingModules.push(`modules/${y}/__init__.py`));}}catch{}return !t.modulesHealthy&&t.missingModules.length>0&&t.issues.push(`Missing module init files: ${t.missingModules.join(", ")}`),await Te(e,t),t}return t.issues.push("Unknown project type (no package.json or pyproject.toml)"),await Te(e,t),t}async function yt(e){try{return (await k__default.readdir(e,{withFileTypes:true})).filter(t=>t.isDirectory()).map(t=>t.name)}catch{try{let o=await k__default.readdir(e),t=[];for(let n of o)try{(await k__default.stat(w.join(e,n))).isDirectory()&&t.push(n);}catch{continue}return t}catch{return []}}}async function Ne(e){let o=w.join(e,".rapidkit");if(!await k__default.pathExists(o))return false;let t=["project.json","context.json","file-hashes.json"];for(let n of t)if(await k__default.pathExists(w.join(o,n)))return true;return false}function wt(e,o){if(o.has(e))return true;let t=e.toLowerCase();return !!(t==="dist"||t.startsWith("dist-")||t.startsWith("dist_")||t==="build"||t.startsWith("build-")||t.startsWith("build_"))}async function wo(e,o,t){let n=new Set,i=[{dir:e,depth:0}];for(;i.length>0;){let r=i.shift();if(!r)break;try{let s=await k__default.readdir(r.dir);for(let c of s){if(wt(c,t))continue;let a=w.join(r.dir,c),l;try{l=await k__default.stat(a);}catch{continue}if(l.isDirectory()){if(await Ne(a)){n.add(a);continue}r.depth<o&&i.push({dir:a,depth:r.depth+1});}}}catch{continue}}return Array.from(n)}async function ko(e){let o=e,t=w.parse(o).root;for(;o!==t;){let n=[w.join(o,".rapidkit-workspace"),w.join(o,".rapidkit","workspace-marker.json"),w.join(o,".rapidkit","config.json")];for(let i of n)if(await k__default.pathExists(i))return o;o=w.dirname(o);}return null}function vo(e,o){let t=0,n=0,i=0;return e.forEach(s=>{s.status==="ok"?t++:s.status==="warn"?n++:s.status==="error"&&i++;}),o.forEach(s=>{s.issues.length===0&&s.venvActive&&s.depsInstalled?t++:s.issues.length>0&&n++;}),{total:t+n+i,passed:t,warnings:n,errors:i}}async function bo(e){let o=w.basename(e);try{let i=w.join(e,".rapidkit-workspace");await k__default.pathExists(i)&&(o=(await k__default.readJSON(i)).name||o);}catch{try{let i=w.join(e,".rapidkit","config.json");o=(await k__default.readJSON(i)).workspace_name||o;}catch{}}let t={workspacePath:e,workspaceName:o,python:await mt(),poetry:await gt(),pipx:await ft(),rapidkitCore:await ht(),projects:[]};try{let i=new Set([".git",".venv","node_modules",".rapidkit","dist","build","coverage","__pycache__"]),r=new Set;await Ne(e)&&r.add(e);let s=async(c,a)=>{if(a<0)return;let l=await yt(c);for(let d of l){if(wt(d,i))continue;let m=w.join(c,d);if(await Ne(m)){r.add(m);continue}a>0&&await s(m,a-1);}};if(await s(e,1),a.debug(`Workspace scan (shallow) found ${r.size} project(s)`),r.size===0){let c=await wo(e,3,i);c.forEach(a=>r.add(a)),a.debug(`Workspace scan (deep fallback) found ${c.length} project(s)`);}r.size>0&&a.debug(`Workspace projects detected: ${Array.from(r).join(", ")}`);for(let c of r){let a=await yo(c);t.projects.push(a);}}catch(i){a.debug(`Failed to scan workspace projects: ${i}`);}let n=[t.python,t.poetry,t.pipx,t.rapidkitCore];if(t.healthScore=vo(n,t.projects),t.rapidkitCore.status==="ok"){let i=t.rapidkitCore.message.match(/([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);i&&(t.coreVersion=i[1]);}return t}function q(e,o){let t=e.status==="ok"?"\u2705":e.status==="warn"?"\u26A0\uFE0F":"\u274C",n=e.status==="ok"?u.green:e.status==="warn"?u.yellow:u.red;console.log(`${t} ${u.bold(o)}: ${n(e.message)}`),e.paths&&e.paths.length>0?e.paths.forEach(i=>{let r=i.version?u.cyan(` -> ${i.version}`):"";console.log(` ${u.cyan("\u2022")} ${u.gray(i.location)}: ${u.dim(i.path)}${r}`);}):e.details&&console.log(` ${u.gray(e.details)}`);}function xo(e){let o=e.issues.length>0,t=o?"\u26A0\uFE0F":"\u2705",n=o?u.yellow:u.green;if(console.log(`
|
|
856
|
+
${t} ${u.bold("Project")}: ${n(e.name)}`),e.framework){let c=e.framework==="FastAPI"?"\u{1F40D}":e.framework==="NestJS"?"\u{1F985}":"\u{1F4E6}";console.log(` ${c} Framework: ${u.cyan(e.framework)}${e.kit?u.gray(` (${e.kit})`):""}`);}if(console.log(` ${u.gray(`Path: ${e.path}`)}`),!(e.venvActive&&!e.coreInstalled)&&(e.venvActive?console.log(` \u2705 Virtual environment: ${u.green("Active")}`):console.log(` \u274C Virtual environment: ${u.red("Not found")}`),e.coreInstalled?console.log(` ${u.dim("\u2139")} RapidKit Core: ${u.gray(e.coreVersion||"In venv")} ${u.dim("(optional)")}`):console.log(` ${u.dim("\u2139")} RapidKit Core: ${u.gray("Using global installation")} ${u.dim("(recommended)")}`)),e.depsInstalled?console.log(` \u2705 Dependencies: ${u.green("Installed")}`):console.log(` \u26A0\uFE0F Dependencies: ${u.yellow("Not installed")}`),e.hasEnvFile!==void 0&&(e.hasEnvFile?console.log(` \u2705 Environment: ${u.green(".env configured")}`):console.log(` \u26A0\uFE0F Environment: ${u.yellow(".env missing")}`)),e.modulesHealthy!==void 0&&(e.modulesHealthy?console.log(` \u2705 Modules: ${u.green("Healthy")}`):e.missingModules&&e.missingModules.length>0&&console.log(` \u26A0\uFE0F Modules: ${u.yellow(`Missing ${e.missingModules.length} init file(s)`)}`)),e.stats){let c=[];e.stats.modules!==void 0&&c.push(`${e.stats.modules} module${e.stats.modules!==1?"s":""}`),c.length>0&&console.log(` \u{1F4CA} Stats: ${u.cyan(c.join(" \u2022 "))}`);}e.lastModified&&console.log(` \u{1F552} Last Modified: ${u.gray(e.lastModified)}`);let s=[];if(e.hasTests!==void 0&&s.push(e.hasTests?"\u2705 Tests":u.dim("\u2298 No tests")),e.hasDocker!==void 0&&s.push(e.hasDocker?"\u2705 Docker":u.dim("\u2298 No Docker")),e.hasCodeQuality!==void 0){let c=e.framework==="NestJS"?"ESLint":"Ruff";s.push(e.hasCodeQuality?`\u2705 ${c}`:u.dim(`\u2298 No ${c}`));}s.length>0&&console.log(` ${s.join(" \u2022 ")}`),e.vulnerabilities!==void 0&&e.vulnerabilities>0&&console.log(` \u26A0\uFE0F Security: ${u.yellow(`${e.vulnerabilities} vulnerability(ies) found`)}`),e.issues.length>0&&(console.log(` ${u.bold("Issues:")}`),e.issues.forEach(c=>{console.log(` \u2022 ${u.yellow(c)}`);}),e.fixCommands&&e.fixCommands.length>0&&(console.log(`
|
|
857
|
+
${u.bold.cyan("\u{1F527} Quick Fix:")}`),e.fixCommands.forEach(c=>{console.log(` ${u.cyan("$")} ${u.white(c)}`);})));}async function ut(e,o=false){let t=e.filter(i=>i.fixCommands&&i.fixCommands.length>0);if(t.length===0){console.log(u.green(`
|
|
858
858
|
\u2705 No fixes needed - all projects are healthy!`));return}console.log(u.bold.cyan(`
|
|
859
859
|
\u{1F527} Available Fixes:
|
|
860
|
-
`));for(let
|
|
860
|
+
`));for(let i of t)console.log(u.bold(`Project: ${u.yellow(i.name)}`)),i.fixCommands.forEach((r,s)=>{console.log(` ${s+1}. ${u.cyan(r)}`);}),console.log();if(!o){console.log(u.gray("\u{1F4A1} Run with --fix flag to apply fixes automatically"));return}let{confirm:n}=await ue.prompt([{type:"confirm",name:"confirm",message:`Apply ${t.reduce((i,r)=>i+r.fixCommands.length,0)} fix(es)?`,default:false}]);if(!n){console.log(u.yellow(`
|
|
861
861
|
\u26A0\uFE0F Fixes cancelled by user`));return}console.log(u.bold.cyan(`
|
|
862
862
|
\u{1F680} Applying fixes...
|
|
863
|
-
`));for(let
|
|
863
|
+
`));for(let i of t){console.log(u.bold(`Fixing ${u.cyan(i.name)}...`));for(let r of i.fixCommands)try{console.log(u.gray(` $ ${r}`)),await execa(r,{shell:true,stdio:"inherit"}),console.log(u.green(` \u2705 Success
|
|
864
864
|
`));}catch(s){console.log(u.red(` \u274C Failed: ${s instanceof Error?s.message:String(s)}
|
|
865
865
|
`));}}console.log(u.bold.green(`
|
|
866
|
-
\u2705 Fix process completed!`));}async function
|
|
866
|
+
\u2705 Fix process completed!`));}async function kt(e={}){if(e.json||console.log(u.bold.cyan(`
|
|
867
867
|
\u{1FA7A} RapidKit Health Check
|
|
868
|
-
`)),e.workspace){let o=await
|
|
869
|
-
\u{1F4CA} Health Score:`)),console.log(` ${
|
|
868
|
+
`)),e.workspace){let o=await ko(process.cwd());o||(a.error("No RapidKit workspace found in current directory or parents"),a.info('Run this command from within a workspace, or use "rapidkit doctor" for system check'),process.exit(1)),e.json||(console.log(u.bold(`Workspace: ${u.cyan(w.basename(o))}`)),console.log(u.gray(`Path: ${o}`)));let t=await bo(o);if(e.json){let r={workspace:{name:w.basename(o),path:o},healthScore:t.healthScore,system:{python:t.python,poetry:t.poetry,pipx:t.pipx,rapidkitCore:t.rapidkitCore,versions:{core:t.coreVersion,npm:t.npmVersion}},projects:t.projects.map(s=>({name:s.name,path:s.path,venvActive:s.venvActive,depsInstalled:s.depsInstalled,coreInstalled:s.coreInstalled,coreVersion:s.coreVersion,issues:s.issues,fixCommands:s.fixCommands})),summary:{totalProjects:t.projects.length,totalIssues:t.projects.reduce((s,c)=>s+c.issues.length,0),hasSystemErrors:[t.python,t.rapidkitCore].some(s=>s.status==="error")}};console.log(JSON.stringify(r,null,2));return}if(t.healthScore){let r=t.healthScore,s=Math.round(r.passed/r.total*100),c=s>=80?u.green:s>=50?u.yellow:u.red,a="\u2588".repeat(Math.floor(s/5))+"\u2591".repeat(20-Math.floor(s/5));console.log(u.bold(`
|
|
869
|
+
\u{1F4CA} Health Score:`)),console.log(` ${c(`${s}%`)} ${u.gray(a)}`),console.log(` ${u.green(`\u2705 ${r.passed} passed`)} ${u.gray("|")} ${u.yellow(`\u26A0\uFE0F ${r.warnings} warnings`)} ${u.gray("|")} ${u.red(`\u274C ${r.errors} errors`)}`);}if(console.log(u.bold(`
|
|
870
870
|
|
|
871
871
|
System Tools:
|
|
872
|
-
`)),q(t.python,"Python"),q(t.poetry,"Poetry"),q(t.pipx,"pipx"),q(t.rapidkitCore,"RapidKit Core"),t.coreVersion&&t.npmVersion){let
|
|
872
|
+
`)),q(t.python,"Python"),q(t.poetry,"Poetry"),q(t.pipx,"pipx"),q(t.rapidkitCore,"RapidKit Core"),t.coreVersion&&t.npmVersion){let r=t.coreVersion.split(".")[1],s=t.npmVersion.split(".")[1];r!==s&&(console.log(u.yellow(`
|
|
873
873
|
\u26A0\uFE0F Version mismatch: Core ${t.coreVersion} / CLI ${t.npmVersion}`)),console.log(u.gray(" Consider updating to matching versions for best compatibility")));}t.projects.length>0?(console.log(u.bold(`
|
|
874
|
-
\u{1F4E6} Projects (${t.projects.length}):`)),t.projects.forEach(
|
|
875
|
-
\u{1F4E6} Projects:`)),console.log(u.gray(" No RapidKit projects found in workspace")));let n=t.projects.reduce((
|
|
876
|
-
\u26A0\uFE0F Found ${n} project issue(s)`)),
|
|
874
|
+
\u{1F4E6} Projects (${t.projects.length}):`)),t.projects.forEach(r=>xo(r))):(console.log(u.bold(`
|
|
875
|
+
\u{1F4E6} Projects:`)),console.log(u.gray(" No RapidKit projects found in workspace")));let n=t.projects.reduce((r,s)=>r+s.issues.length,0),i=[t.python,t.rapidkitCore].some(r=>r.status==="error");i||n>0?(console.log(u.bold.yellow(`
|
|
876
|
+
\u26A0\uFE0F Found ${n} project issue(s)`)),i&&console.log(u.bold.red("\u274C System requirements not met")),e.fix?await ut(t.projects,true):n>0&&await ut(t.projects,false)):console.log(u.bold.green(`
|
|
877
877
|
\u2705 All checks passed! Workspace is healthy.`));}else {console.log(u.bold(`System Tools:
|
|
878
|
-
`));let o=await
|
|
878
|
+
`));let o=await mt(),t=await gt(),n=await ft(),i=await ht();q(o,"Python"),q(t,"Poetry"),q(n,"pipx"),q(i,"RapidKit Core"),[o,i].some(s=>s.status==="error")?(console.log(u.bold.red(`
|
|
879
879
|
\u274C Some required tools are missing`)),console.log(u.gray(`
|
|
880
880
|
Tip: Run "rapidkit doctor --workspace" from within a workspace for detailed project checks`))):(console.log(u.bold.green(`
|
|
881
881
|
\u2705 All required tools are installed!`)),console.log(u.gray(`
|
|
882
|
-
Tip: Run "rapidkit doctor --workspace" from within a workspace for detailed project checks`)));}console.log("");}var
|
|
882
|
+
Tip: Run "rapidkit doctor --workspace" from within a workspace for detailed project checks`)));}console.log("");}var We=w.join(zt__default.homedir(),".rapidkit"),xe=w.join(We,"config.json");function oe(){try{if(!S.existsSync(xe))return {};let e=S.readFileSync(xe,"utf-8");return JSON.parse(e)}catch{return {}}}function Pe(e){let t={...oe(),...e};S.existsSync(We)||S.mkdirSync(We,{recursive:true}),S.writeFileSync(xe,JSON.stringify(t,null,2),"utf-8");}function le(){return process.env.OPENAI_API_KEY||oe().openaiApiKey||null}function Le(){return oe().aiEnabled!==false}function Ge(){return xe}async function bt(){return (await import('inquirer')).default}function xt(e){let o=e.command("config").description("Configure RapidKit settings");o.command("set-api-key").description("Set OpenAI API key for AI features").option("--key <key>","API key (or enter interactively)").action(async t=>{let n=t.key;n?n.startsWith("sk-")||(console.log(u.red(`
|
|
883
883
|
\u274C Invalid API key format (should start with sk-)
|
|
884
|
-
`)),process.exit(1)):n=(await(await
|
|
884
|
+
`)),process.exit(1)):n=(await(await bt()).prompt([{type:"password",name:"apiKey",message:"Enter your OpenAI API key:",validate:s=>s?s.startsWith("sk-")?s.length<20?"API key seems too short":true:"Invalid API key format (should start with sk-)":"API key is required"}])).apiKey,Pe({openaiApiKey:n}),console.log(u.green(`
|
|
885
885
|
\u2705 OpenAI API key saved successfully!
|
|
886
|
-
`)),console.log(u.gray(`Stored in: ${
|
|
886
|
+
`)),console.log(u.gray(`Stored in: ${Ge()}`)),console.log(u.cyan(`
|
|
887
887
|
\u{1F389} You can now use AI features:`)),console.log(u.white(' rapidkit ai recommend "I need user authentication"')),console.log(u.gray(`
|
|
888
888
|
\u{1F4A1} To generate module embeddings (one-time):`)),console.log(u.white(" cd rapidkit-npm")),console.log(u.white(` npx tsx src/ai/generate-embeddings.ts
|
|
889
|
-
`));}),o.command("show").description("Show current configuration").action(()=>{let t=
|
|
889
|
+
`));}),o.command("show").description("Show current configuration").action(()=>{let t=oe();if(console.log(u.bold(`
|
|
890
890
|
\u2699\uFE0F RapidKit Configuration
|
|
891
891
|
`)),t.openaiApiKey){let n=t.openaiApiKey.substring(0,8)+"..."+t.openaiApiKey.slice(-4);console.log(u.cyan("OpenAI API Key:"),u.white(n));}else console.log(u.cyan("OpenAI API Key:"),u.red("Not set")),console.log(u.gray(" Set with: rapidkit config set-api-key"));console.log(u.cyan("AI Features:"),t.aiEnabled!==false?u.green("Enabled"):u.red("Disabled")),console.log(u.gray(`
|
|
892
|
-
\u{1F4C1} Config file: ${
|
|
893
|
-
`));}),o.command("remove-api-key").description("Remove stored OpenAI API key").action(async()=>{if(!
|
|
892
|
+
\u{1F4C1} Config file: ${Ge()}
|
|
893
|
+
`));}),o.command("remove-api-key").description("Remove stored OpenAI API key").action(async()=>{if(!oe().openaiApiKey){console.log(u.yellow(`
|
|
894
894
|
\u26A0\uFE0F No API key is currently stored
|
|
895
|
-
`));return}(await(await
|
|
895
|
+
`));return}(await(await bt()).prompt([{type:"confirm",name:"confirm",message:"Are you sure you want to remove your OpenAI API key?",default:false}])).confirm?(Pe({openaiApiKey:void 0}),console.log(u.green(`
|
|
896
896
|
\u2705 API key removed successfully
|
|
897
897
|
`))):console.log(u.gray(`
|
|
898
898
|
Cancelled
|
|
899
899
|
`));}),o.command("ai <action>").description("Enable or disable AI features (enable|disable)").action(t=>{t!=="enable"&&t!=="disable"&&(console.log(u.red(`
|
|
900
900
|
\u274C Invalid action: ${t}`)),console.log(u.gray(`Use: rapidkit config ai enable|disable
|
|
901
|
-
`)),process.exit(1));let n=t==="enable";
|
|
901
|
+
`)),process.exit(1));let n=t==="enable";Pe({aiEnabled:n}),console.log(u.green(`
|
|
902
902
|
\u2705 AI features ${n?"enabled":"disabled"}
|
|
903
|
-
`));});}var be=null,xe=false,Ne=null;async function wo(){return Ne||(Ne=(await import('openai')).default),Ne}function vt(){xe=true;}function bt(e){let t=new Array(1536),n=0;for(let i=0;i<e.length;i++)n=(n<<5)-n+e.charCodeAt(i),n=n&n;for(let i=0;i<1536;i++)n=n*1664525+1013904223&4294967295,t[i]=n/4294967295*2-1;let r=Math.sqrt(t.reduce((i,s)=>i+s*s,0));return t.map(i=>i/r)}async function Pe(e){let o=await wo();be=new o({apiKey:e});}function xt(){if(!be)throw new Error("OpenAI client not initialized. Call initOpenAI() first with your API key.");return be}async function Pt(e){return xe?bt(e):(await xt().embeddings.create({model:"text-embedding-3-small",input:e,encoding_format:"float"})).data[0].embedding}async function It(e){return xe?e.map(bt):(await xt().embeddings.create({model:"text-embedding-3-small",input:e,encoding_format:"float"})).data.map(n=>n.embedding)}function jt(){return be!==null}function Ct(){return xe}var bo=promisify(exec),$t=[{id:"authentication-core",name:"Authentication Core",category:"auth",description:"Complete authentication system with password hashing, JWT tokens, OAuth 2.0, and secure session management",longDescription:"Production-ready authentication with bcrypt password hashing, JWT access/refresh tokens, OAuth 2.0 providers (Google, GitHub, etc), rate limiting, and security best practices.",keywords:["auth","login","password","jwt","oauth","token","authentication","security","signin","signup"],framework:"both",dependencies:[],useCases:["User login and logout","Password reset flow","OAuth social login (Google, GitHub)","JWT authentication","Secure session management","Token refresh","Rate limiting"]},{id:"users-core",name:"Users Core",category:"auth",description:"User management system with profiles, roles, permissions, and user CRUD operations",longDescription:"Complete user management with user profiles, role-based access control (RBAC), permissions, user search, soft delete, and audit trails.",keywords:["user","profile","role","permission","rbac","management","admin","accounts"],framework:"both",dependencies:["authentication-core"],useCases:["User registration","User profile management","Role management (admin, user, etc)","Permission system","User administration dashboard","Soft delete users"]},{id:"session-management",name:"Session Management",category:"auth",description:"Secure session handling with Redis storage, session rotation, and device tracking",longDescription:"Advanced session management with Redis-backed storage, automatic session rotation, device fingerprinting, IP tracking, and session revocation.",keywords:["session","redis","cookie","storage","device","tracking"],framework:"both",dependencies:["authentication-core","redis-cache"],useCases:["User session management","Remember me functionality","Device tracking","Session security","Logout from all devices","Session expiration"]},{id:"db-postgres",name:"PostgreSQL",category:"database",description:"PostgreSQL integration with async SQLAlchemy, migrations, connection pooling, and query optimization",longDescription:"Production-ready PostgreSQL with async SQLAlchemy 2.0, Alembic migrations, connection pooling, query optimization, JSON support, and full-text search.",keywords:["postgres","postgresql","database","sql","sqlalchemy","migration","orm","relational"],framework:"both",dependencies:[],useCases:["Relational database","Complex SQL queries","Database transactions","Data integrity","Production-grade database","ACID compliance"]},{id:"db-mongodb",name:"MongoDB",category:"database",description:"MongoDB integration with Motor async driver, schema validation, and aggregation pipelines",longDescription:"Async MongoDB with Motor driver, Pydantic schema validation, aggregation pipelines, indexes, and Atlas integration.",keywords:["mongodb","mongo","nosql","document","database","motor"],framework:"both",dependencies:[],useCases:["Document storage","Flexible schema","Real-time data","JSON documents","Unstructured data","Analytics"]},{id:"stripe-payment",name:"Stripe Payment",category:"payment",description:"Stripe integration with payment intents, subscriptions, webhooks, and customer portal",longDescription:"Complete Stripe integration with Payment Intents API, subscription management, automatic webhooks, customer portal, refunds, and SCA compliance.",keywords:["stripe","payment","subscription","billing","checkout","webhook","credit card"],framework:"both",dependencies:[],useCases:["Accept credit card payments","Subscription billing","One-time payments","Checkout flow","Payment webhooks","Refunds and disputes"]},{id:"email",name:"Email",category:"communication",description:"Email sending with templates, SMTP/SendGrid/AWS SES support, and queue management",longDescription:"Production email system with Jinja2 templates, multiple providers (SMTP, SendGrid, AWS SES), queue management, retry logic, and bounce handling.",keywords:["email","mail","smtp","sendgrid","ses","template","notification"],framework:"both",dependencies:[],useCases:["Welcome emails","Password reset emails","Notifications","Marketing emails","Transactional emails","Email templates"]},{id:"sms",name:"SMS",category:"communication",description:"SMS sending with Twilio, verification codes, and delivery tracking",longDescription:"SMS integration with Twilio, verification codes, two-factor authentication, delivery tracking, and international support.",keywords:["sms","twilio","text","message","2fa","verification","otp"],framework:"both",dependencies:[],useCases:["2FA verification codes","SMS notifications","Phone verification","OTP generation","SMS alerts"]},{id:"redis-cache",name:"Redis Cache",category:"infrastructure",description:"Redis caching with decorators, TTL management, and cache invalidation patterns",longDescription:"Redis integration with async client, caching decorators, TTL management, cache invalidation, pub/sub, and rate limiting.",keywords:["redis","cache","memory","performance","speed","pubsub"],framework:"both",dependencies:[],useCases:["API response caching","Session storage","Rate limiting","Real-time features","Performance optimization","Pub/sub messaging"]},{id:"celery",name:"Celery",category:"infrastructure",description:"Background task processing with Celery, periodic tasks, and monitoring",longDescription:"Celery task queue with Redis/RabbitMQ backend, periodic tasks (cron), task monitoring, retry logic, and failure handling.",keywords:["celery","task","background","queue","async","worker","job","cron"],framework:"fastapi",dependencies:["redis-cache"],useCases:["Background email sending","Data processing","Report generation","Scheduled tasks","Long-running jobs"]},{id:"storage",name:"Storage",category:"infrastructure",description:"File storage with S3, local filesystem, and image processing",longDescription:"Unified storage interface for AWS S3, local files, image resizing, format conversion, CDN integration, and presigned URLs.",keywords:["storage","s3","file","upload","image","cdn","aws"],framework:"both",dependencies:[],useCases:["File uploads","Image storage","Document management","Profile pictures","Media files","CDN integration"]}],oe=null,Rt=0,xo=300*1e3;function Po(e){return {id:e.name||e.id||e.module_id||"",name:e.display_name||e.name||"",category:Io(e.category||"infrastructure"),description:e.description||e.summary||"",longDescription:e.long_description||e.description||"",keywords:e.keywords||e.tags||[],framework:jo(e.framework),dependencies:e.dependencies||[],useCases:e.use_cases||e.useCases||[]}}function Io(e){return {auth:"auth",authentication:"auth",database:"database",payment:"payment",billing:"payment",communication:"communication",infrastructure:"infrastructure",security:"security",analytics:"analytics"}[e.toLowerCase()]||"infrastructure"}function jo(e){if(!e)return "both";if(typeof e=="string"){if(e.toLowerCase().includes("fastapi"))return "fastapi";if(e.toLowerCase().includes("nest"))return "nestjs"}return "both"}async function Co(){try{let{stdout:e}=await bo("rapidkit modules list --json-schema 1",{timeout:1e4,maxBuffer:10485760}),o=e.match(/\{[\s\S]*\}/),t=o?o[0]:e,n=JSON.parse(t),r=[];return Array.isArray(n)?r=n:n.modules&&Array.isArray(n.modules)?r=n.modules:n.data&&Array.isArray(n.data)&&(r=n.data),r.map(Po).filter(i=>i.id&&i.name)}catch(e){return e.code==="ENOENT"?console.warn("\u26A0\uFE0F RapidKit Python Core not found in PATH"):e.killed?console.warn("\u26A0\uFE0F Python Core command timed out"):console.warn("\u26A0\uFE0F Failed to fetch modules from Python Core:",e.message),console.warn(" Using fallback module catalog (11 modules)"),$t}}async function Ie(){let e=Date.now();return oe&&e-Rt<xo||(oe=await Co(),Rt=e,oe.length===0&&(console.warn("\u26A0\uFE0F No modules found, using fallback catalog"),oe=$t)),oe}var $o=fileURLToPath(import.meta.url),_t=w.dirname($o),de=null;function Ao(){if(de)return de;let e=[w.join(_t,"../../data/modules-embeddings.json"),w.join(_t,"../data/modules-embeddings.json"),w.join(process.cwd(),"data/modules-embeddings.json")],o=null;for(let r of e)if(S.existsSync(r)){o=r;break}if(!o)throw new Error("embeddings file not found");let t=S.readFileSync(o,"utf-8"),n=JSON.parse(t);return Array.isArray(n)?de={model:"mock-or-text-embedding-3-small",dimension:n[0]?.embedding?.length||1536,generated_at:new Date().toISOString(),modules:n}:de=n,de}function _o(e,o){if(e.length!==o.length)throw new Error("Vectors must have the same length");let t=0,n=0,r=0;for(let s=0;s<e.length;s++)t+=e[s]*o[s],n+=e[s]*e[s],r+=o[s]*o[s];let i=Math.sqrt(n)*Math.sqrt(r);return i===0?0:t/i}function Eo(e,o){let t=o.toLowerCase(),n=e.keywords.filter(r=>t.includes(r)||r.includes(t));return n.length>0?`Matches: ${n.slice(0,3).join(", ")}`:`Relevant for: ${e.useCases[0]}`}async function Et(e,o=5){let t=Ao(),n=await Ie(),r=await Pt(e),i=t.modules.map(s=>{let l=n.find(c=>c.id===s.id);if(!l)return null;let a=_o(r,s.embedding);return {module:l,score:a,reason:Eo(l,e)}}).filter(s=>s!==null);return i.sort((s,l)=>l.score-s.score),i.slice(0,o)}var Do=fileURLToPath(import.meta.url),St=w.dirname(Do);async function Mt(){return (await import('inquirer')).default}function Ko(){return [w.join(St,"../../data/modules-embeddings.json"),w.join(St,"../data/modules-embeddings.json"),w.join(process.cwd(),"data/modules-embeddings.json")]}function Dt(){let e=Ko();for(let o of e)if(S.existsSync(o))try{let t=JSON.parse(S.readFileSync(o,"utf-8")),n=Array.isArray(t)?t:t.modules||[];return {exists:true,path:o,moduleCount:n.length,generatedAt:t.generated_at||null}}catch{continue}return {exists:false,path:null,moduleCount:0,generatedAt:null}}async function Ce(e=true,o){try{if(!jt()&&!Ct())return console.log(u.red(`
|
|
903
|
+
`));});}var je=null,Ie=false,Ve=null;async function jo(){return Ve||(Ve=(await import('openai')).default),Ve}function Pt(){Ie=true;}function jt(e){let t=new Array(1536),n=0;for(let r=0;r<e.length;r++)n=(n<<5)-n+e.charCodeAt(r),n=n&n;for(let r=0;r<1536;r++)n=n*1664525+1013904223&4294967295,t[r]=n/4294967295*2-1;let i=Math.sqrt(t.reduce((r,s)=>r+s*s,0));return t.map(r=>r/i)}async function Ce(e){let o=await jo();je=new o({apiKey:e});}function It(){if(!je)throw new Error("OpenAI client not initialized. Call initOpenAI() first with your API key.");return je}async function Ct(e){return Ie?jt(e):(await It().embeddings.create({model:"text-embedding-3-small",input:e,encoding_format:"float"})).data[0].embedding}async function Rt(e){return Ie?e.map(jt):(await It().embeddings.create({model:"text-embedding-3-small",input:e,encoding_format:"float"})).data.map(n=>n.embedding)}function $t(){return je!==null}function At(){return Ie}var Ro=promisify(exec),Et=[{id:"authentication-core",name:"Authentication Core",category:"auth",description:"Complete authentication system with password hashing, JWT tokens, OAuth 2.0, and secure session management",longDescription:"Production-ready authentication with bcrypt password hashing, JWT access/refresh tokens, OAuth 2.0 providers (Google, GitHub, etc), rate limiting, and security best practices.",keywords:["auth","login","password","jwt","oauth","token","authentication","security","signin","signup"],framework:"both",dependencies:[],useCases:["User login and logout","Password reset flow","OAuth social login (Google, GitHub)","JWT authentication","Secure session management","Token refresh","Rate limiting"]},{id:"users-core",name:"Users Core",category:"auth",description:"User management system with profiles, roles, permissions, and user CRUD operations",longDescription:"Complete user management with user profiles, role-based access control (RBAC), permissions, user search, soft delete, and audit trails.",keywords:["user","profile","role","permission","rbac","management","admin","accounts"],framework:"both",dependencies:["authentication-core"],useCases:["User registration","User profile management","Role management (admin, user, etc)","Permission system","User administration dashboard","Soft delete users"]},{id:"session-management",name:"Session Management",category:"auth",description:"Secure session handling with Redis storage, session rotation, and device tracking",longDescription:"Advanced session management with Redis-backed storage, automatic session rotation, device fingerprinting, IP tracking, and session revocation.",keywords:["session","redis","cookie","storage","device","tracking"],framework:"both",dependencies:["authentication-core","redis-cache"],useCases:["User session management","Remember me functionality","Device tracking","Session security","Logout from all devices","Session expiration"]},{id:"db-postgres",name:"PostgreSQL",category:"database",description:"PostgreSQL integration with async SQLAlchemy, migrations, connection pooling, and query optimization",longDescription:"Production-ready PostgreSQL with async SQLAlchemy 2.0, Alembic migrations, connection pooling, query optimization, JSON support, and full-text search.",keywords:["postgres","postgresql","database","sql","sqlalchemy","migration","orm","relational"],framework:"both",dependencies:[],useCases:["Relational database","Complex SQL queries","Database transactions","Data integrity","Production-grade database","ACID compliance"]},{id:"db-mongodb",name:"MongoDB",category:"database",description:"MongoDB integration with Motor async driver, schema validation, and aggregation pipelines",longDescription:"Async MongoDB with Motor driver, Pydantic schema validation, aggregation pipelines, indexes, and Atlas integration.",keywords:["mongodb","mongo","nosql","document","database","motor"],framework:"both",dependencies:[],useCases:["Document storage","Flexible schema","Real-time data","JSON documents","Unstructured data","Analytics"]},{id:"stripe-payment",name:"Stripe Payment",category:"payment",description:"Stripe integration with payment intents, subscriptions, webhooks, and customer portal",longDescription:"Complete Stripe integration with Payment Intents API, subscription management, automatic webhooks, customer portal, refunds, and SCA compliance.",keywords:["stripe","payment","subscription","billing","checkout","webhook","credit card"],framework:"both",dependencies:[],useCases:["Accept credit card payments","Subscription billing","One-time payments","Checkout flow","Payment webhooks","Refunds and disputes"]},{id:"email",name:"Email",category:"communication",description:"Email sending with templates, SMTP/SendGrid/AWS SES support, and queue management",longDescription:"Production email system with Jinja2 templates, multiple providers (SMTP, SendGrid, AWS SES), queue management, retry logic, and bounce handling.",keywords:["email","mail","smtp","sendgrid","ses","template","notification"],framework:"both",dependencies:[],useCases:["Welcome emails","Password reset emails","Notifications","Marketing emails","Transactional emails","Email templates"]},{id:"sms",name:"SMS",category:"communication",description:"SMS sending with Twilio, verification codes, and delivery tracking",longDescription:"SMS integration with Twilio, verification codes, two-factor authentication, delivery tracking, and international support.",keywords:["sms","twilio","text","message","2fa","verification","otp"],framework:"both",dependencies:[],useCases:["2FA verification codes","SMS notifications","Phone verification","OTP generation","SMS alerts"]},{id:"redis-cache",name:"Redis Cache",category:"infrastructure",description:"Redis caching with decorators, TTL management, and cache invalidation patterns",longDescription:"Redis integration with async client, caching decorators, TTL management, cache invalidation, pub/sub, and rate limiting.",keywords:["redis","cache","memory","performance","speed","pubsub"],framework:"both",dependencies:[],useCases:["API response caching","Session storage","Rate limiting","Real-time features","Performance optimization","Pub/sub messaging"]},{id:"celery",name:"Celery",category:"infrastructure",description:"Background task processing with Celery, periodic tasks, and monitoring",longDescription:"Celery task queue with Redis/RabbitMQ backend, periodic tasks (cron), task monitoring, retry logic, and failure handling.",keywords:["celery","task","background","queue","async","worker","job","cron"],framework:"fastapi",dependencies:["redis-cache"],useCases:["Background email sending","Data processing","Report generation","Scheduled tasks","Long-running jobs"]},{id:"storage",name:"Storage",category:"infrastructure",description:"File storage with S3, local filesystem, and image processing",longDescription:"Unified storage interface for AWS S3, local files, image resizing, format conversion, CDN integration, and presigned URLs.",keywords:["storage","s3","file","upload","image","cdn","aws"],framework:"both",dependencies:[],useCases:["File uploads","Image storage","Document management","Profile pictures","Media files","CDN integration"]}],ne=null,_t=0,$o=300*1e3;function Ao(e){return {id:e.name||e.id||e.module_id||"",name:e.display_name||e.name||"",category:_o(e.category||"infrastructure"),description:e.description||e.summary||"",longDescription:e.long_description||e.description||"",keywords:e.keywords||e.tags||[],framework:Eo(e.framework),dependencies:e.dependencies||[],useCases:e.use_cases||e.useCases||[]}}function _o(e){return {auth:"auth",authentication:"auth",database:"database",payment:"payment",billing:"payment",communication:"communication",infrastructure:"infrastructure",security:"security",analytics:"analytics"}[e.toLowerCase()]||"infrastructure"}function Eo(e){if(!e)return "both";if(typeof e=="string"){if(e.toLowerCase().includes("fastapi"))return "fastapi";if(e.toLowerCase().includes("nest"))return "nestjs"}return "both"}async function So(){try{let{stdout:e}=await Ro("rapidkit modules list --json-schema 1",{timeout:1e4,maxBuffer:10485760}),o=e.match(/\{[\s\S]*\}/),t=o?o[0]:e,n=JSON.parse(t),i=[];return Array.isArray(n)?i=n:n.modules&&Array.isArray(n.modules)?i=n.modules:n.data&&Array.isArray(n.data)&&(i=n.data),i.map(Ao).filter(r=>r.id&&r.name)}catch(e){return e.code==="ENOENT"?console.warn("\u26A0\uFE0F RapidKit Python Core not found in PATH"):e.killed?console.warn("\u26A0\uFE0F Python Core command timed out"):console.warn("\u26A0\uFE0F Failed to fetch modules from Python Core:",e.message),console.warn(" Using fallback module catalog (11 modules)"),Et}}async function Re(){let e=Date.now();return ne&&e-_t<$o||(ne=await So(),_t=e,ne.length===0&&(console.warn("\u26A0\uFE0F No modules found, using fallback catalog"),ne=Et)),ne}var Do=fileURLToPath(import.meta.url),Mt=w.dirname(Do),de=null;function Ko(){if(de)return de;let e=[w.join(Mt,"../../data/modules-embeddings.json"),w.join(Mt,"../data/modules-embeddings.json"),w.join(process.cwd(),"data/modules-embeddings.json")],o=null;for(let i of e)if(S.existsSync(i)){o=i;break}if(!o)throw new Error("embeddings file not found");let t=S.readFileSync(o,"utf-8"),n=JSON.parse(t);return Array.isArray(n)?de={model:"mock-or-text-embedding-3-small",dimension:n[0]?.embedding?.length||1536,generated_at:new Date().toISOString(),modules:n}:de=n,de}function Fo(e,o){if(e.length!==o.length)throw new Error("Vectors must have the same length");let t=0,n=0,i=0;for(let s=0;s<e.length;s++)t+=e[s]*o[s],n+=e[s]*e[s],i+=o[s]*o[s];let r=Math.sqrt(n)*Math.sqrt(i);return r===0?0:t/r}function Oo(e,o){let t=o.toLowerCase(),n=e.keywords.filter(i=>t.includes(i)||i.includes(t));return n.length>0?`Matches: ${n.slice(0,3).join(", ")}`:`Relevant for: ${e.useCases[0]}`}async function Dt(e,o=5){let t=Ko(),n=await Re(),i=await Ct(e),r=t.modules.map(s=>{let c=n.find(l=>l.id===s.id);if(!c)return null;let a=Fo(i,s.embedding);return {module:c,score:a,reason:Oo(c,e)}}).filter(s=>s!==null);return r.sort((s,c)=>c.score-s.score),r.slice(0,o)}var Wo=fileURLToPath(import.meta.url),Kt=w.dirname(Wo);async function Ft(){return (await import('inquirer')).default}function Lo(){return [w.join(Kt,"../../data/modules-embeddings.json"),w.join(Kt,"../data/modules-embeddings.json"),w.join(process.cwd(),"data/modules-embeddings.json")]}function Ot(){let e=Lo();for(let o of e)if(S.existsSync(o))try{let t=JSON.parse(S.readFileSync(o,"utf-8")),n=Array.isArray(t)?t:t.modules||[];return {exists:true,path:o,moduleCount:n.length,generatedAt:t.generated_at||null}}catch{continue}return {exists:false,path:null,moduleCount:0,generatedAt:null}}async function Ae(e=true,o){try{if(!$t()&&!At())return console.log(u.red(`
|
|
904
904
|
\u274C OpenAI not initialized`)),console.log(u.yellow("Please set your API key:")),console.log(u.white(" rapidkit config set-api-key")),console.log(u.gray(` OR set: export OPENAI_API_KEY="sk-..."
|
|
905
905
|
`)),false;console.log(u.blue(`
|
|
906
906
|
\u{1F916} Generating AI embeddings for RapidKit modules...
|
|
907
|
-
`)),console.log(u.gray("\u{1F4E1} Fetching modules from RapidKit..."));let t=await
|
|
907
|
+
`)),console.log(u.gray("\u{1F4E1} Fetching modules from RapidKit..."));let t=await Re();console.log(u.green(`\u2713 Found ${t.length} modules
|
|
908
908
|
`));let n=t.length*50/1e6*.02;if(console.log(u.cyan(`\u{1F4B0} Estimated cost: ~$${n.toFixed(3)}`)),console.log(u.gray(` (Based on ${t.length} modules at $0.02/1M tokens)
|
|
909
|
-
`)),e){let s=await
|
|
909
|
+
`)),e){let s=await Ft(),{confirm:c}=await s.prompt([{type:"confirm",name:"confirm",message:"Generate embeddings now?",default:true}]);if(!c)return console.log(u.yellow(`
|
|
910
910
|
\u26A0\uFE0F Embeddings generation cancelled
|
|
911
|
-
`)),false}let
|
|
911
|
+
`)),false}let i=t.map(s=>`${s.name}. ${s.description}. ${s.longDescription}. Keywords: ${s.keywords.join(", ")}. Use cases: ${s.useCases.join(", ")}.`),r=Fe(`Generating embeddings for ${t.length} modules...`).start();try{let s=await Rt(i);r.succeed(`Generated embeddings for ${t.length} modules`);let c={model:"text-embedding-3-small",dimension:s[0].length,generated_at:new Date().toISOString(),modules:t.map((d,m)=>({id:d.id,name:d.name,embedding:s[m]}))},a=o||w.join(process.cwd(),"data","modules-embeddings.json"),l=w.dirname(a);return S.existsSync(l)||S.mkdirSync(l,{recursive:true}),S.writeFileSync(a,JSON.stringify(c,null,2)),console.log(u.green(`
|
|
912
912
|
\u2705 Embeddings generated successfully!`)),console.log(u.gray(`\u{1F4C1} Saved to: ${a}`)),console.log(u.gray(`\u{1F4CA} Size: ${t.length} modules, ${s[0].length} dimensions
|
|
913
|
-
`)),true}catch(s){return
|
|
913
|
+
`)),true}catch(s){return r.fail("Failed to generate embeddings"),s.message?.includes("429")?(console.log(u.red(`
|
|
914
914
|
\u274C OpenAI API quota exceeded`)),console.log(u.yellow(`Please check your billing: https://platform.openai.com/account/billing
|
|
915
915
|
`))):s.message?.includes("401")?(console.log(u.red(`
|
|
916
916
|
\u274C Invalid API key`)),console.log(u.yellow("Please set a valid API key:")),console.log(u.white(` rapidkit config set-api-key
|
|
@@ -918,49 +918,49 @@ Cancelled
|
|
|
918
918
|
\u274C Error: ${s.message}
|
|
919
919
|
`)),false}}catch(t){return console.log(u.red(`
|
|
920
920
|
\u274C Failed to generate embeddings: ${t.message}
|
|
921
|
-
`)),false}}async function
|
|
921
|
+
`)),false}}async function Tt(e=true){if(Ot().exists)return true;if(console.log(u.yellow(`
|
|
922
922
|
\u26A0\uFE0F Module embeddings not found`)),console.log(u.gray(`AI recommendations require embeddings to be generated.
|
|
923
923
|
`)),!e)return console.log(u.red("\u274C Cannot generate embeddings in non-interactive mode")),console.log(u.white(`Run: rapidkit ai generate-embeddings
|
|
924
|
-
`)),false;let t=await
|
|
924
|
+
`)),false;let t=await Ft(),{action:n}=await t.prompt([{type:"list",name:"action",message:"What would you like to do?",choices:[{name:"\u{1F680} Generate embeddings now (requires OpenAI API key)",value:"generate"},{name:"\u{1F4DD} Show me how to generate them manually",value:"manual"},{name:"\u274C Cancel",value:"cancel"}]}]);return n==="generate"?await Ae(true):(n==="manual"&&(console.log(u.cyan(`
|
|
925
925
|
\u{1F4DD} To generate embeddings manually:
|
|
926
926
|
`)),console.log(u.white("1. Get OpenAI API key from: https://platform.openai.com/api-keys")),console.log(u.white("2. Set the API key:")),console.log(u.gray(" rapidkit config set-api-key")),console.log(u.gray(` OR: export OPENAI_API_KEY="sk-..."
|
|
927
927
|
`)),console.log(u.white("3. Generate embeddings:")),console.log(u.gray(` rapidkit ai generate-embeddings
|
|
928
928
|
`)),console.log(u.cyan(`\u{1F4B0} Cost: ~$0.50 one-time
|
|
929
|
-
`))),false)}async function
|
|
929
|
+
`))),false)}async function Nt(){let e=Ot();return e.exists?(console.log(u.blue(`
|
|
930
930
|
\u{1F504} Updating embeddings...`)),console.log(u.gray(`Current: ${e.moduleCount} modules`)),console.log(u.gray(`Generated: ${e.generatedAt||"unknown"}
|
|
931
|
-
`)),await
|
|
931
|
+
`)),await Ae(true,e.path)):(console.log(u.yellow(`
|
|
932
932
|
\u26A0\uFE0F No existing embeddings found`)),console.log(u.gray(`Use: rapidkit ai generate-embeddings
|
|
933
|
-
`)),false)}async function
|
|
933
|
+
`)),false)}async function Wt(){return (await import('inquirer')).default}function Lt(e){let o=e.command("ai").description("AI-powered features");o.command("recommend").description("Get AI-powered module recommendations").argument("[query]",'What do you want to build? (e.g., "user authentication with email")').option("-n, --number <count>","Number of recommendations","5").option("--json","Output as JSON").action(async(t,n)=>{try{Le()||(console.log(u.yellow(`
|
|
934
934
|
\u26A0\uFE0F AI features are disabled`)),console.log(u.gray(`Enable with: rapidkit config ai enable
|
|
935
|
-
`)),process.exit(1));let
|
|
935
|
+
`)),process.exit(1));let i=le();i?await Ce(i):(console.log(u.yellow(`
|
|
936
936
|
\u26A0\uFE0F OpenAI API key not configured - using MOCK MODE for testing
|
|
937
937
|
`)),console.log(u.gray("\u{1F4DD} Note: Mock embeddings provide approximate results for testing.")),console.log(u.gray(` For production, configure your OpenAI API key:
|
|
938
938
|
`)),console.log(u.white(" 1. Get your key from: https://platform.openai.com/api-keys")),console.log(u.white(" 2. Configure it: rapidkit config set-api-key")),console.log(u.gray(` OR set: export OPENAI_API_KEY="sk-proj-..."
|
|
939
|
-
`)),
|
|
939
|
+
`)),Pt());let r=t;r||(r=(await(await Wt()).prompt([{type:"input",name:"query",message:"\u{1F916} What do you want to build?",validate:P=>P.length===0?"Please enter a description":P.length<3?"Please be more specific (at least 3 characters)":true}])).query),n.json||console.log(u.blue(`
|
|
940
940
|
\u{1F916} Analyzing your request...
|
|
941
|
-
`)),await
|
|
941
|
+
`)),await Tt(!n.json)||(console.log(u.yellow(`
|
|
942
942
|
\u26A0\uFE0F Cannot proceed without embeddings
|
|
943
|
-
`)),process.exit(1));let
|
|
943
|
+
`)),process.exit(1));let c=parseInt(n.number,10),a=await Dt(r,c);if(a.length===0||a[0].score<.3)if(console.log(u.yellow(`
|
|
944
944
|
\u26A0\uFE0F No matching modules found in RapidKit registry.
|
|
945
945
|
`)),console.log(u.cyan(`\u{1F4A1} Options:
|
|
946
946
|
`)),console.log(u.white("1. Create custom module:")),console.log(u.gray(" rapidkit modules scaffold <name> --category <category>")),console.log(u.gray(` Example: rapidkit modules scaffold blockchain-integration --category integrations
|
|
947
947
|
`)),console.log(u.white("2. Search with different keywords")),console.log(u.gray(` Try more general terms (e.g., "storage" instead of "blockchain")
|
|
948
948
|
`)),console.log(u.white("3. Request feature:")),console.log(u.gray(` https://github.com/getrapidkit/rapidkit/issues
|
|
949
949
|
`)),a.length>0)console.log(u.yellow(`\u26A0\uFE0F Low confidence matches found:
|
|
950
|
-
`));else return;if(n.json){console.log(JSON.stringify({query:
|
|
951
|
-
`)),a.forEach((p,y)=>{let P=(p.score*100).toFixed(1),v=p.score>.8?" \u2B50":"";console.log(u.bold(`${y+1}. ${p.module.name}${v}`)),console.log(u.gray(` ${p.module.description}`)),console.log(u.cyan(` Match: ${P}%`)+u.gray(` - ${p.reason}`)),console.log(u.yellow(` Category: ${p.module.category}`)),p.module.dependencies.length>0&&console.log(u.magenta(` Requires: ${p.module.dependencies.join(", ")}`)),console.log();});let
|
|
952
|
-
`));let d=await
|
|
950
|
+
`));else return;if(n.json){console.log(JSON.stringify({query:r,recommendations:a},null,2));return}console.log(u.green.bold(`\u{1F4E6} Recommended Modules:
|
|
951
|
+
`)),a.forEach((p,y)=>{let P=(p.score*100).toFixed(1),v=p.score>.8?" \u2B50":"";console.log(u.bold(`${y+1}. ${p.module.name}${v}`)),console.log(u.gray(` ${p.module.description}`)),console.log(u.cyan(` Match: ${P}%`)+u.gray(` - ${p.reason}`)),console.log(u.yellow(` Category: ${p.module.category}`)),p.module.dependencies.length>0&&console.log(u.magenta(` Requires: ${p.module.dependencies.join(", ")}`)),console.log();});let l=a.slice(0,3).map(p=>p.module.id);console.log(u.cyan("\u{1F4A1} Quick install (top 3):")),console.log(u.white(` rapidkit add module ${l.join(" ")}
|
|
952
|
+
`));let d=await Wt(),{shouldInstall:m}=await d.prompt([{type:"confirm",name:"shouldInstall",message:"Would you like to install these modules now?",default:false}]);if(m){let{selectedModules:p}=await d.prompt([{type:"checkbox",name:"selectedModules",message:"Select modules to install:",choices:a.map(y=>({name:`${y.module.name} - ${y.module.description}`,value:y.module.id,checked:y.score>.7}))}]);p.length>0?(console.log(u.blue(`
|
|
953
953
|
\u{1F4E6} Installing ${p.length} modules...
|
|
954
954
|
`)),console.log(u.gray(`Command: rapidkit add module ${p.join(" ")}`)),console.log(u.yellow(`
|
|
955
955
|
\u26A0\uFE0F Note: Module installation not yet implemented`)),console.log(u.gray(`Coming soon in next version!
|
|
956
956
|
`))):console.log(u.gray(`
|
|
957
957
|
No modules selected
|
|
958
|
-
`));}}catch(
|
|
959
|
-
\u274C Error:`,
|
|
958
|
+
`));}}catch(i){a.error(`
|
|
959
|
+
\u274C Error:`,i.message),i.code==="invalid_api_key"?(console.log(u.yellow(`
|
|
960
960
|
\u{1F4A1} Your API key may be invalid or expired`)),console.log(u.cyan(` Update it: rapidkit config set-api-key
|
|
961
|
-
`))):
|
|
961
|
+
`))):i.message.includes("embeddings file not found")&&(console.log(u.yellow(`
|
|
962
962
|
\u{1F4A1} Module embeddings not generated yet`)),console.log(u.cyan(" Generate them (one-time):")),console.log(u.white(" cd rapidkit-npm")),console.log(u.white(' export OPENAI_API_KEY="sk-proj-..."')),console.log(u.white(` npx tsx src/ai/generate-embeddings.ts
|
|
963
|
-
`))),process.exit(1);}}),o.command("info").description("Show AI features information").action(()=>{let t=le(),n=
|
|
963
|
+
`))),process.exit(1);}}),o.command("info").description("Show AI features information").action(()=>{let t=le(),n=Le();console.log(u.bold(`
|
|
964
964
|
\u{1F916} RapidKit AI Features
|
|
965
965
|
`)),console.log(u.cyan("Status:"),n?u.green("Enabled"):u.red("Disabled")),console.log(u.cyan("API Key:"),t?u.green("Configured \u2713"):u.red("Not configured \u2717")),console.log(u.bold(`
|
|
966
966
|
\u{1F4E6} Available Features:
|
|
@@ -973,27 +973,32 @@ No modules selected
|
|
|
973
973
|
`)),console.log(u.cyan(`To generate embeddings, you need an OpenAI API key:
|
|
974
974
|
`)),console.log(u.white("1. Get your key from: https://platform.openai.com/api-keys")),console.log(u.white("2. Configure it: rapidkit config set-api-key")),console.log(u.gray(`
|
|
975
975
|
OR set environment variable:`)),console.log(u.white(` export OPENAI_API_KEY="sk-proj-..."
|
|
976
|
-
`)),process.exit(1)),
|
|
976
|
+
`)),process.exit(1)),Ce(t);let n=await Ae(true);n&&(console.log(u.green("\u2705 Ready to use AI recommendations!")),console.log(u.cyan(`Try: rapidkit ai recommend "authentication"
|
|
977
977
|
`))),process.exit(n?0:1);}catch(t){a.error("Failed to generate embeddings:",t.message),process.exit(1);}}),o.command("update-embeddings").description("Update existing embeddings with latest modules").action(async()=>{try{let t=le();t||(console.log(u.red(`
|
|
978
978
|
\u274C OpenAI API key not configured
|
|
979
979
|
`)),console.log(u.white(`Set your API key: rapidkit config set-api-key
|
|
980
|
-
`)),process.exit(1)),
|
|
980
|
+
`)),process.exit(1)),Ce(t);let n=await Nt();process.exit(n?0:1);}catch(t){a.error("Failed to update embeddings:",t.message),process.exit(1);}});}function Ue(e){if(!e||typeof e!="object")return null;let o=e.code;return o==="PYTHON_NOT_FOUND"||o==="BRIDGE_VENV_BOOTSTRAP_FAILED"?o:null}function Vo(e){let o=e.trim().toLowerCase();return o?o.startsWith("fastapi")?"fastapi":o.startsWith("nestjs")?"nestjs":null:null}function Ht(e,o){let t=e.indexOf(o);if(t>=0&&t+1<e.length)return e[t+1];let n=e.find(i=>i.startsWith(`${o}=`));if(n)return n.slice(o.length+1)}async function He(e,o){if(e.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(e[0]!=="create")return 1;if(e[1]!=="project")return process.stderr.write(`RapidKit (npm) could not run the Python core engine for \`create\`.
|
|
981
981
|
Reason: ${o}.
|
|
982
982
|
Install Python 3.10+ to use the interactive wizard and full kit catalog.
|
|
983
|
-
`),1;let
|
|
983
|
+
`),1;let i=e[2],r=e[3];if(!i||!r)return process.stderr.write(`Usage: rapidkit create project <kit> <name> [--output <dir>]
|
|
984
984
|
Tip: offline fallback supports only fastapi* and nestjs* kits.
|
|
985
|
-
`),1;let s=
|
|
985
|
+
`),1;let s=Vo(i);if(!s)return process.stderr.write(`RapidKit (npm) could not run the Python core engine to create this kit.
|
|
986
986
|
Reason: ${o}.
|
|
987
|
-
Requested kit: ${
|
|
987
|
+
Requested kit: ${i}
|
|
988
988
|
Offline fallback only supports: fastapi.standard, nestjs.standard (and their shorthands).
|
|
989
989
|
Install Python 3.10+ to access all kits.
|
|
990
|
-
`),1;let
|
|
991
|
-
`),1;let
|
|
992
|
-
`),1}}async function
|
|
993
|
-
`),
|
|
994
|
-
`),1
|
|
995
|
-
`),1
|
|
996
|
-
`),1
|
|
990
|
+
`),1;let c=Ht(e,"--output")||process.cwd(),a=w.resolve(c,r),l=e.includes("--skip-git")||e.includes("--no-git"),d=e.includes("--skip-install");try{if(await k.ensureDir(w.dirname(a)),await k.pathExists(a))return process.stderr.write(`\u274C Directory "${a}" already exists
|
|
991
|
+
`),1;let m="pip",p=me(process.cwd());if(p)try{let{readWorkspaceMarker:y}=await import('./workspace-marker-IOPQ42A7.js'),P=await y(p);P?.metadata?.npm?.installMethod&&(m=P.metadata.npm.installMethod,console.log(`[DEBUG] Detected workspace engine: ${m}`));}catch(y){console.log("[DEBUG] Failed to read workspace marker:",y);}else console.log("[DEBUG] No workspace found, using default engine: pip");if(await k.ensureDir(a),await pt(a,{project_name:r,template:s,kit_name:i,skipGit:l,skipInstall:d,engine:m}),p){let{syncWorkspaceProjects:y}=await import('./workspace-LZZGJRGV.js');await y(p,true);}return 0}catch(m){return process.stderr.write(`RapidKit (npm) offline fallback failed: ${m?.message??m}
|
|
992
|
+
`),1}}async function Uo(e){let o=new Set(["--yes","-y","--skip-git","--skip-install","--debug","--dry-run","--no-update-check","--create-workspace","--no-workspace"]);if(e[0]==="create"&&e[1]==="workspace")try{let t=e.includes("--yes")||e.includes("-y"),n=e.includes("--skip-git")||e.includes("--no-git"),i=e[2]&&!e[2].startsWith("-")?e[2]:void 0,r=Ht(e,"--install-method"),s=r==="poetry"||r==="venv"||r==="pipx"?r:void 0,c=i||(t?"my-workspace":(await ue.prompt([{type:"input",name:"workspaceName",message:"Workspace name:",default:"my-workspace"}])).workspaceName);if(!c||!c.trim())return process.stderr.write(`Workspace name is required.
|
|
993
|
+
`),1;try{Me(c);}catch(m){if(m instanceof F)return process.stderr.write(`${m.message}
|
|
994
|
+
`),1;throw m}let a=w.resolve(process.cwd(),c);if(await k.pathExists(a))return process.stderr.write(`\u274C Directory "${c}" already exists
|
|
995
|
+
`),1;let l=await z(),d=l.author||process.env.USER||"RapidKit User";if(!t){let m=await ue.prompt([{type:"input",name:"author",message:"Author name:",default:d}]);m.author?.trim()&&(d=m.author.trim());}return await ve(c,{skipGit:n,yes:t,userConfig:{...l,author:d},installMethod:s}),0}catch(t){return process.stderr.write(`RapidKit (npm) failed to create workspace: ${t?.message??t}
|
|
996
|
+
`),1}try{if(e[0]==="create"&&e[1]==="project"){let t=e.includes("--create-workspace"),n=e.includes("--no-workspace"),i=e.includes("--yes")||e.includes("-y"),r=e.includes("--skip-git")||e.includes("--no-git");if(!!!_e(process.cwd())){if(t)await Y(process.cwd(),{skipGit:r,yes:i,userConfig:await z()});else if(!n)if(i)await Y(process.cwd(),{skipGit:r,yes:true,userConfig:await z()});else {let{createWs:a}=await ue.prompt([{type:"confirm",name:"createWs",message:"This project will be created outside a RapidKit workspace. Create and register a workspace here?",default:true}]);a&&await Y(process.cwd(),{skipGit:r,yes:false,userConfig:await z()});}}let c=e.filter(a=>{let l=a.split("=")[0];return !o.has(a)&&!o.has(l)});try{await c$1();let a$1=await d(c,{cwd:process.cwd()});if(a$1===0){let l=me(process.cwd());if(l){try{let m=e[3];if(m){let p=e.indexOf("--output"),y=p>=0?e[p+1]:".",P=w.resolve(process.cwd(),y,m),v=w.join(l,".python-version"),C=w.join(P,".python-version");if(S.existsSync(v)&&S.existsSync(P)){let E=S.readFileSync(v,"utf-8");S.writeFileSync(C,E.trim()+`
|
|
997
|
+
`),a.debug(`Synced Python version ${E.trim()} from workspace to ${m}`);}}}catch(m){a.debug("Could not sync Python version from workspace:",m);}let{syncWorkspaceProjects:d}=await import('./workspace-LZZGJRGV.js');await d(l,true);}}return a$1}catch(a){let l=Ue(a);return l?await He(c,l):(process.stderr.write(`RapidKit (npm) failed to run the Python core engine: ${a?.message??a}
|
|
998
|
+
`),1)}}if(e[0]==="create"&&e[1]!=="project")try{await c$1();let t=await d(e,{cwd:process.cwd()});if(t===0){let n=me(process.cwd());if(n){let{syncWorkspaceProjects:i}=await import('./workspace-LZZGJRGV.js');await i(n,true);}}return t}catch(t){let n=Ue(t);return n?await He(e,n):(process.stderr.write(`RapidKit (npm) failed to run the Python core engine: ${t?.message??t}
|
|
999
|
+
`),1)}return await c$1(),await d(e,{cwd:process.cwd()})}catch(t){let n=Ue(t);return n?await He(e,n):(process.stderr.write(`RapidKit (npm) failed to run the Python core engine: ${t?.message??t}
|
|
1000
|
+
`),1)}}var Gt=["dev","start","build","test","lint","format","create","help","--help","-h"];function qt(e){let o=e;for(;;){let t=w.join(o,".rapidkit","context.json");if(S.existsSync(t))return t;let n=w.dirname(o);if(n===o)break;o=n;}return null}function _e(e){let o=e;for(;;){let t=w.join(o,".rapidkit-workspace");if(S.existsSync(t))return t;let n=w.dirname(o);if(n===o)break;o=n;}return null}function me(e){let o=e;for(;;){let t=w.join(o,".rapidkit-workspace");if(S.existsSync(t))return o;let n=w.dirname(o);if(n===o)break;o=n;}return null}async function Vt(e,o,t){return await new Promise(n=>{let i=spawn(e,o,{stdio:"inherit",cwd:t,shell:process.platform==="win32"});i.on("close",r=>n(r??1)),i.on("error",()=>n(1));})}async function Ut(e){let o="poetry";try{let{readWorkspaceMarker:t}=await import('./workspace-marker-IOPQ42A7.js'),i=(await t(e))?.metadata?.npm?.installMethod;(i==="poetry"||i==="venv"||i==="pipx"||i==="pip")&&(o=i);}catch{}if(o==="poetry")return await Vt("poetry",["install","--no-root"],e);if(o==="venv"){let t=w.join(e,".venv",process.platform==="win32"?"Scripts":"bin",process.platform==="win32"?"python.exe":"python");return await k.pathExists(t)?await Vt(t,["-m","pip","install","--upgrade","rapidkit-core"],e):(process.stderr.write(`Workspace virtualenv not found (.venv).
|
|
1001
|
+
`),1)}return 0}async function Ho(e){let o=await S.promises.readdir(e,{withFileTypes:true}),t=[];for(let n of o){if(!n.isDirectory()||n.name.startsWith("."))continue;let i=w.join(e,n.name),r=w.join(i,".rapidkit","context.json"),s=w.join(i,".rapidkit","project.json");(await k.pathExists(r)||await k.pathExists(s))&&t.push(i);}return t}function qo(e){let o="my-workspace",t=1;for(;;){let n=t===1?o:`${o}-${t}`,i=w.join(e,n);if(!S.existsSync(i))return {name:n,targetPath:i};t+=1;}}async function Jo(e){let o=process.cwd();if(e.length>1)return await d(e,{cwd:o});let t=me(o),n=qt(o),i=n?w.dirname(w.dirname(n)):null;if(i&&i!==t)return await d(["init"],{cwd:i});if(t&&o===t){let r=await Ut(t);if(r!==0)return r;let s=await Ho(t);for(let c of s){let a=await d(["init"],{cwd:c});if(a!==0)return a}return 0}if(!t){let r=await z(),{name:s}=qo(o);await ve(s,{yes:true,userConfig:r});let c=w.join(o,s);return await Ut(c)}return await d(e,{cwd:o})}async function zo(){let e=process.cwd(),o=process.argv.slice(2);if(o[0]==="create")return false;try{let a=o[0],l=!a||a==="--help"||a==="-h"||a==="help";if(_e(e)&&l){let m=await d(a?["--help"]:[],{cwd:e});process.exit(m);}}catch{}try{let a=o[0],l=a==="shell"&&o[1]==="activate",d$1=a==="create",m=await tt(e,{cwd:e,timeoutMs:1200});if(m.ok&&m.data?.isRapidkitProject&&m.data.engine==="python"&&!l&&!d$1){let p=await d(process.argv.slice(2),{cwd:e});process.exit(p);}}catch{}let t=qt(e),n=process.platform==="win32",i=n?[w.join(e,"rapidkit.cmd"),w.join(e,"rapidkit"),w.join(e,".rapidkit","rapidkit.cmd"),w.join(e,".rapidkit","rapidkit")]:[w.join(e,"rapidkit"),w.join(e,".rapidkit","rapidkit")],r=null;for(let a of i)if(await k.pathExists(a)){r=a;break}let s=o[0],c=s==="create";if(r&&s&&Gt.includes(s)&&!c){a.debug(`Delegating to local CLI: ${r} ${o.join(" ")}`);let a$1=spawn(r,o,{stdio:"inherit",cwd:e,shell:n});return a$1.on("close",l=>{process.exit(l??0);}),a$1.on("error",l=>{a.error(`Failed to run local rapidkit: ${l.message}`),process.exit(1);}),true}if(t&&await k.pathExists(t))try{if((await k.readJson(t)).engine==="pip"){let l=o[0],m=process.platform==="win32"?[w.join(e,"rapidkit.cmd"),w.join(e,"rapidkit"),w.join(e,".rapidkit","rapidkit.cmd"),w.join(e,".rapidkit","rapidkit")]:[w.join(e,"rapidkit"),w.join(e,".rapidkit","rapidkit")],p=null;for(let P of m)if(await k.pathExists(P)){p=P;break}if(p&&l&&Gt.includes(l)){a.debug(`Delegating to local CLI (early detection): ${p} ${o.join(" ")}`);let P=spawn(p,o,{stdio:"inherit",cwd:e});return P.on("close",v=>process.exit(v??0)),P.on("error",v=>{a.error(`Failed to run local rapidkit: ${v.message}`),process.exit(1);}),true}if(l==="shell"&&o[1]==="activate"){let P=`# RapidKit: activation snippet - eval "$(rapidkit shell activate)"
|
|
997
1002
|
VENV='.venv'
|
|
998
1003
|
if [ -f "$VENV/bin/activate" ]; then
|
|
999
1004
|
. "$VENV/bin/activate"
|
|
@@ -1006,7 +1011,7 @@ export PATH="$(pwd)/.rapidkit:$(pwd):$PATH"
|
|
|
1006
1011
|
\u2705 Activation snippet \u2014 run the following to activate this project in your current shell:
|
|
1007
1012
|
`)),console.log(P),console.log(u.gray(`
|
|
1008
1013
|
\u{1F4A1} After activation you can run: rapidkit dev
|
|
1009
|
-
`)),process.exit(0);}let y=await d(o,{cwd:e});process.exit(y);}}catch{}return false}var J=null,
|
|
1014
|
+
`)),process.exit(0);}let y=await d(o,{cwd:e});process.exit(y);}}catch{}return false}var J=null,Ee=false,V=new Command;async function Yo(e){if(e.length===0)return false;let o=e[0],t=e[1];if(o==="shell"&&t==="activate"||o==="workspace"||o==="doctor"||o==="ai"||o==="config")return false;if(e.includes("--tui"))return true;if(o==="--help"||o==="-h"||o==="help"||o==="--version"||o==="-V"||e.includes("--template")||e.includes("-t"))return false;let n=new Set(["--yes","-y","--skip-git","--skip-install","--debug","--dry-run","--no-update-check","--create-workspace","--no-workspace"]);if(e.some(r=>n.has(r)))return false;let i=await g();return i?i.has(o):!!(a$1.has(o)||e.length>1)}V.name("rapidkit").description("Create RapidKit workspaces and projects").version(c());V.addHelpText("beforeAll",`RapidKit
|
|
1010
1015
|
|
|
1011
1016
|
Global CLI
|
|
1012
1017
|
Create RapidKit workspaces and projects
|
|
@@ -1020,27 +1025,27 @@ Project Commands
|
|
|
1020
1025
|
rapidkit dev
|
|
1021
1026
|
|
|
1022
1027
|
Use "rapidkit help <command>" for more information.
|
|
1023
|
-
`);V.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(e,o)=>{try{o.debug&&(a.setDebug(true),a.debug("Debug mode enabled"));let t=await
|
|
1028
|
+
`);V.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(e,o)=>{try{o.debug&&(a.setDebug(true),a.debug("Debug mode enabled"));let t=await z();a.debug("User config loaded",t);let n=await Ze();a.debug("RapidKit config loaded",n);let i=et(t,n,{author:o.author,skipGit:o.skipGit});a.debug("Merged config",i),o.updateCheck!==false&&await b(),console.log(u.blue.bold(`
|
|
1024
1029
|
\u{1F680} Welcome to RapidKit!
|
|
1025
|
-
`)),e||(
|
|
1026
|
-
\u274C ${
|
|
1027
|
-
`),process.exit(1)),
|
|
1030
|
+
`)),e||(Qo(),process.exit(0));try{Me(e);}catch(c){throw c instanceof F&&(a.error(`
|
|
1031
|
+
\u274C ${c.message}`),c.details&&a.warn(`\u{1F4A1} ${c.details}
|
|
1032
|
+
`),process.exit(1)),c}let r=w.resolve(process.cwd(),e);J=r,await k.pathExists(r)&&(a.error(`
|
|
1028
1033
|
\u274C Directory "${e}" already exists`),console.log(u.cyan(`
|
|
1029
1034
|
\u{1F4A1} Choose a different name or delete the existing directory.
|
|
1030
1035
|
`)),process.exit(1));let s=!!o.template;if(o.dryRun){console.log(u.cyan(`
|
|
1031
1036
|
\u{1F50D} Dry-run mode - showing what would be created:
|
|
1032
|
-
`)),console.log(u.white("\u{1F4C2} Path:"),
|
|
1033
|
-
`)),s){let
|
|
1034
|
-
`),a.debug(`Synced Python version ${
|
|
1035
|
-
`),a.debug(`Re-synced Python version ${M.trim()} after init`);}}catch(M){a.debug("Could not re-sync Python version after init:",M);}}}}else await
|
|
1037
|
+
`)),console.log(u.white("\u{1F4C2} Path:"),r),console.log(u.white("\u{1F4E6} Type:"),s?`Project (${o.template})`:"Workspace"),console.log();return}if(!o.yes&&!s?await ue.prompt([{type:"input",name:"author",message:"Author name:",default:process.env.USER||"RapidKit User"}]):o.yes&&console.log(u.gray(`Using default values (--yes flag)
|
|
1038
|
+
`)),s){let c=String(o.template||"").trim(),a$1=c.toLowerCase(),l=a$1==="fastapi"?"fastapi.standard":a$1==="nestjs"?"nestjs.standard":c;if(!!!_e(process.cwd())){if(o.createWorkspace)await Y(process.cwd(),{skipGit:o.skipGit,yes:o.yes,userConfig:t});else if(!o.noWorkspace)if(o.yes)await Y(process.cwd(),{skipGit:o.skipGit,yes:true,userConfig:t});else {let{createWs:P}=await ue.prompt([{type:"confirm",name:"createWs",message:"This project will be created outside a RapidKit workspace. Create and register a workspace here?",default:true}]);P&&await Y(process.cwd(),{skipGit:o.skipGit,yes:false,userConfig:t});}}let m=["create","project",l,e,"--output",process.cwd(),"--install-essentials"],p=await d(m,{cwd:process.cwd()});p!==0&&process.exit(p);let y=_e(process.cwd());if(y){let P=w.dirname(y),v=w.join(P,".python-version"),C=w.join(r,".python-version");try{if(await k.pathExists(v)){let E=S.readFileSync(v,"utf-8");S.writeFileSync(C,E.trim()+`
|
|
1039
|
+
`),a.debug(`Synced Python version ${E.trim()} from workspace to project`);}}catch(E){a.debug("Could not sync Python version from workspace:",E);}}if(!o.skipInstall){let P=await d(["init",r],{cwd:process.cwd()});if(P!==0&&process.exit(P),y){let v=w.dirname(y),C=w.join(v,".python-version"),E=w.join(r,".python-version");try{if(await k.pathExists(C)){let M=S.readFileSync(C,"utf-8");S.writeFileSync(E,M.trim()+`
|
|
1040
|
+
`),a.debug(`Re-synced Python version ${M.trim()} after init`);}}catch(M){a.debug("Could not re-sync Python version after init:",M);}}}}else await ve(e,{skipGit:o.skipGit,dryRun:o.dryRun,yes:o.yes,userConfig:i,installMethod:o.installMethod});}catch(t){t instanceof F?(a.error(`
|
|
1036
1041
|
\u274C ${t.message}`),t.details&&a.warn(`\u{1F4A1} ${t.details}`),a.debug("Error code:",t.code)):(a.error(`
|
|
1037
|
-
\u274C An unexpected error occurred:`),console.error(t)),process.exit(1);}finally{J=null;}});
|
|
1042
|
+
\u274C An unexpected error occurred:`),console.error(t)),process.exit(1);}finally{J=null;}});Lt(V);xt(V);V.command("shell <action>").description("Shell helpers (activate virtualenv in current shell)").action(async e=>{e!=="activate"&&(console.log(u.red(`Unknown shell command: ${e}`)),process.exit(1));let o=process.cwd();function t(a){let l=a;for(;;){let d=w.join(l,".rapidkit","context.json");if(S.existsSync(d))return d;let m=w.dirname(l);if(m===l)break;l=m;}return null}let n=t(o);function i(a){let l=a;for(;;){let d=w.join(l,".venv"),m=w.join(l,".rapidkit","activate");if(S.existsSync(m)||S.existsSync(d))return {venv:d,activateFile:m};let p=w.dirname(l);if(p===l)break;l=p;}return null}let r=i(o);!n&&!r&&(console.log(u.yellow("No RapidKit project found in this directory")),process.exit(1));let s;r&&S.existsSync(r.activateFile)?s=r.activateFile:r&&S.existsSync(r.venv)?s=process.platform==="win32"?w.join(r.venv,"Scripts","activate"):w.join(r.venv,"bin","activate"):(console.log(u.yellow("No virtual environment found")),process.exit(1));let c=process.platform==="win32";console.log(c?`call "${s}"`:`. "${s}"`);});V.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 e=>{await kt(e);});V.command("workspace <action>").description("Manage RapidKit workspaces (list, sync)").action(async e=>{if(e==="list"){let{listWorkspaces:o}=await import('./workspace-LZZGJRGV.js');await o();}else if(e==="sync"){let o=me(process.cwd());o||(console.log(u.red("\u274C Not inside a RapidKit workspace")),console.log(u.gray("\u{1F4A1} Run this command from within a workspace directory")),process.exit(1));let{syncWorkspaceProjects:t}=await import('./workspace-LZZGJRGV.js');console.log(u.cyan(`\u{1F4C2} Scanning workspace: ${w.basename(o)}`)),await t(o);}else console.log(u.red(`Unknown workspace action: ${e}`)),console.log(u.gray("Available: list, sync")),process.exit(1);});function Qo(){console.log(u.white(`Usage:
|
|
1038
1043
|
`)),console.log(u.cyan(" npx rapidkit <workspace-name> [options]")),console.log(u.cyan(` npx rapidkit create <...>
|
|
1039
1044
|
`)),console.log(u.bold("Recommended workflow:")),console.log(u.cyan(" npx rapidkit my-workspace")),console.log(u.cyan(" cd my-workspace")),console.log(u.cyan(" npx rapidkit create project fastapi.standard my-api --output .")),console.log(u.cyan(" cd my-api")),console.log(u.cyan(` npx rapidkit init && npx rapidkit dev
|
|
1040
1045
|
`)),console.log(u.bold("Options (workspace creation):")),console.log(u.gray(" -y, --yes Skip prompts and use defaults")),console.log(u.gray(" --skip-git Skip git initialization")),console.log(u.gray(" --debug Enable debug logging")),console.log(u.gray(" --dry-run Show what would be created")),console.log(u.gray(" --create-workspace When creating a project outside a workspace: create and register a workspace in the current directory")),console.log(u.gray(" --no-workspace When creating a project outside a workspace: do not create a workspace")),console.log(u.gray(` --no-update-check Skip checking for updates
|
|
1041
1046
|
`)),console.log(u.gray(`Tip: set RAPIDKIT_SHOW_LEGACY=1 to show legacy template flags in help.
|
|
1042
|
-
`));}process.on("SIGINT",async()=>{if(!
|
|
1047
|
+
`));}process.on("SIGINT",async()=>{if(!Ee){if(Ee=true,console.log(u.yellow(`
|
|
1043
1048
|
|
|
1044
|
-
\u26A0\uFE0F Interrupted by user`)),J&&await k.pathExists(J)){console.log(u.gray("Cleaning up partial installation..."));try{await k.remove(J),console.log(u.green("\u2713 Cleanup complete"));}catch(e){a.debug("Cleanup failed:",e);}}process.exit(130);}});process.on("SIGTERM",async()=>{if(!
|
|
1045
|
-
`),o[0]==="create"){let n=await
|
|
1046
|
-
`),t){let n=await d(o,{cwd:process.cwd()});process.exit(n);}V.parse();}});export{
|
|
1049
|
+
\u26A0\uFE0F Interrupted by user`)),J&&await k.pathExists(J)){console.log(u.gray("Cleaning up partial installation..."));try{await k.remove(J),console.log(u.green("\u2713 Cleanup complete"));}catch(e){a.debug("Cleanup failed:",e);}}process.exit(130);}});process.on("SIGTERM",async()=>{if(!Ee){if(Ee=true,a.debug("Received SIGTERM"),J&&await k.pathExists(J))try{await k.remove(J);}catch(e){a.debug("Cleanup failed:",e);}process.exit(143);}});zo().then(async e=>{if(!e){let o=process.argv.slice(2);if(process.env.RAPIDKIT_NPM_DEBUG_ARGS==="1"&&process.stderr.write(`[rapidkit-npm] argv=${JSON.stringify(o)}
|
|
1050
|
+
`),o[0]==="create"){let n=await Uo(o);process.exit(n);}if(o[0]==="init"){let n=await Jo(o);process.exit(n);}let t=await Yo(o);if(process.env.RAPIDKIT_NPM_DEBUG_ARGS==="1"&&process.stderr.write(`[rapidkit-npm] shouldForwardToCore=${t}
|
|
1051
|
+
`),t){let n=await d(o,{cwd:process.cwd()});process.exit(n);}V.parse();}});export{Uo as handleCreateOrFallback};
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rapidkit",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Create RapidKit projects with a single command - The official CLI for RapidKit framework",
|
|
6
6
|
"keywords": [
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
29
|
"scripts": {
|
|
30
|
+
"preinstall": "node scripts/enforce-package-manager.cjs",
|
|
30
31
|
"sync-kits": "bash scripts/sync-kits.sh",
|
|
31
32
|
"build": "tsup",
|
|
32
33
|
"build:watch": "tsup --watch",
|
|
@@ -62,7 +63,11 @@
|
|
|
62
63
|
"size-check": "npm run build && size-limit",
|
|
63
64
|
"bench": "npx tsx scripts/benchmarks.ts",
|
|
64
65
|
"quality": "npm run typecheck && npm run lint && npm run format:check && npm test && npm run size-check",
|
|
65
|
-
"act-matrix": "act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-22.04 -P macos-latest=ghcr.io/catthehacker/ubuntu:act-22.04 -P windows-latest=ghcr.io/catthehacker/ubuntu:act-22.04 --pull=false -j build-test-matrix"
|
|
66
|
+
"act-matrix": "act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-22.04 -P macos-latest=ghcr.io/catthehacker/ubuntu:act-22.04 -P windows-latest=ghcr.io/catthehacker/ubuntu:act-22.04 --pull=false -j build-test-matrix",
|
|
67
|
+
"release:dry": "bash scripts/release.sh --no-publish --yes --allow-dirty",
|
|
68
|
+
"release:patch": "bash scripts/release.sh patch",
|
|
69
|
+
"release:minor": "bash scripts/release.sh minor",
|
|
70
|
+
"release:major": "bash scripts/release.sh major"
|
|
66
71
|
},
|
|
67
72
|
"dependencies": {
|
|
68
73
|
"chalk": "^5.3.0",
|
|
@@ -109,5 +114,5 @@
|
|
|
109
114
|
"prettier --write"
|
|
110
115
|
]
|
|
111
116
|
},
|
|
112
|
-
"packageManager": "
|
|
117
|
+
"packageManager": "npm@10.8.2"
|
|
113
118
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rapidkit",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Create RapidKit projects with a single command - The official CLI for RapidKit framework",
|
|
6
6
|
"keywords": [
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
29
|
"scripts": {
|
|
30
|
+
"preinstall": "node scripts/enforce-package-manager.cjs",
|
|
30
31
|
"sync-kits": "bash scripts/sync-kits.sh",
|
|
31
32
|
"build": "tsup",
|
|
32
33
|
"build:watch": "tsup --watch",
|
|
@@ -62,7 +63,11 @@
|
|
|
62
63
|
"size-check": "npm run build && size-limit",
|
|
63
64
|
"bench": "npx tsx scripts/benchmarks.ts",
|
|
64
65
|
"quality": "npm run typecheck && npm run lint && npm run format:check && npm test && npm run size-check",
|
|
65
|
-
"act-matrix": "act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-22.04 -P macos-latest=ghcr.io/catthehacker/ubuntu:act-22.04 -P windows-latest=ghcr.io/catthehacker/ubuntu:act-22.04 --pull=false -j build-test-matrix"
|
|
66
|
+
"act-matrix": "act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-22.04 -P macos-latest=ghcr.io/catthehacker/ubuntu:act-22.04 -P windows-latest=ghcr.io/catthehacker/ubuntu:act-22.04 --pull=false -j build-test-matrix",
|
|
67
|
+
"release:dry": "bash scripts/release.sh --no-publish --yes --allow-dirty",
|
|
68
|
+
"release:patch": "bash scripts/release.sh patch",
|
|
69
|
+
"release:minor": "bash scripts/release.sh minor",
|
|
70
|
+
"release:major": "bash scripts/release.sh major"
|
|
66
71
|
},
|
|
67
72
|
"dependencies": {
|
|
68
73
|
"chalk": "^5.3.0",
|
|
@@ -109,5 +114,5 @@
|
|
|
109
114
|
"prettier --write"
|
|
110
115
|
]
|
|
111
116
|
},
|
|
112
|
-
"packageManager": "
|
|
117
|
+
"packageManager": "npm@10.8.2"
|
|
113
118
|
}
|