rapidkit 0.12.7 โ 0.12.9
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
CHANGED
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
```bash
|
|
20
20
|
npx rapidkit my-api --template fastapi
|
|
21
21
|
cd my-api
|
|
22
|
-
rapidkit init
|
|
23
|
-
rapidkit dev
|
|
22
|
+
npx rapidkit init # Install dependencies
|
|
23
|
+
npx rapidkit dev # Start dev server at http://localhost:8000
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
### Create a NestJS Project
|
|
@@ -28,8 +28,8 @@ rapidkit dev # Start dev server at http://localhost:8000
|
|
|
28
28
|
```bash
|
|
29
29
|
npx rapidkit my-api --template nestjs
|
|
30
30
|
cd my-api
|
|
31
|
-
rapidkit init
|
|
32
|
-
rapidkit dev
|
|
31
|
+
npx rapidkit init # Install dependencies
|
|
32
|
+
npx rapidkit dev # Start dev server at http://localhost:8000
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
Your API will be available at `http://localhost:8000` with Swagger docs at `/docs`
|
|
@@ -47,15 +47,17 @@ npx rapidkit my-api --template nestjs # Create NestJS project
|
|
|
47
47
|
|
|
48
48
|
### 2. Workspace Mode (without `--template`)
|
|
49
49
|
|
|
50
|
-
Create a workspace
|
|
50
|
+
Create a workspace to organize multiple projects:
|
|
51
51
|
|
|
52
52
|
```bash
|
|
53
53
|
npx rapidkit my-workspace # Create workspace
|
|
54
54
|
cd my-workspace
|
|
55
|
-
rapidkit
|
|
56
|
-
rapidkit
|
|
55
|
+
npx rapidkit my-api --template fastapi # Create FastAPI project
|
|
56
|
+
npx rapidkit admin-api --template nestjs # Create NestJS project
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
+
> **Note:** The same `npx rapidkit <name> --template <type>` command works everywhere - in any directory or inside a workspace!
|
|
60
|
+
|
|
59
61
|
## Templates
|
|
60
62
|
|
|
61
63
|
| Template | Framework | Description |
|
|
@@ -88,17 +90,19 @@ After creating a project, use these commands:
|
|
|
88
90
|
|
|
89
91
|
```bash
|
|
90
92
|
cd my-api
|
|
91
|
-
rapidkit init # Install dependencies (auto-activates environment)
|
|
92
|
-
rapidkit dev # Start dev server with hot reload (port 8000)
|
|
93
|
-
rapidkit start # Start production server
|
|
94
|
-
rapidkit build # Build for production
|
|
95
|
-
rapidkit test # Run tests
|
|
96
|
-
rapidkit lint # Lint code
|
|
97
|
-
rapidkit format # Format code
|
|
98
|
-
rapidkit --help # Show all commands
|
|
93
|
+
npx rapidkit init # Install dependencies (auto-activates environment)
|
|
94
|
+
npx rapidkit dev # Start dev server with hot reload (port 8000)
|
|
95
|
+
npx rapidkit start # Start production server
|
|
96
|
+
npx rapidkit build # Build for production
|
|
97
|
+
npx rapidkit test # Run tests
|
|
98
|
+
npx rapidkit lint # Lint code
|
|
99
|
+
npx rapidkit format # Format code
|
|
100
|
+
npx rapidkit --help # Show all commands
|
|
99
101
|
```
|
|
100
102
|
|
|
101
|
-
> **Note:**
|
|
103
|
+
> **Note:** `npx rapidkit` automatically detects when you're inside a RapidKit project and delegates to the local CLI. Works everywhere without any setup!
|
|
104
|
+
|
|
105
|
+
> **๐ก Tip:** Install globally with `npm i -g rapidkit` to use `rapidkit` directly without `npx`.
|
|
102
106
|
|
|
103
107
|
### Alternative: Direct Commands
|
|
104
108
|
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {Command}from'commander';import
|
|
3
|
-
[${t}/${i}]`),
|
|
4
|
-
\u26A0\uFE0F Update available: ${
|
|
5
|
-
`))):
|
|
2
|
+
import {Command}from'commander';import r from'chalk';import O from'inquirer';import l,{dirname,join}from'path';import {spawn}from'child_process';import {execa}from'execa';import y,{readFileSync,promises}from'fs';import {fileURLToPath}from'url';import le from'os';import me from'validate-npm-package-name';import*as h from'fs-extra';import A from'ora';var F=class{debugEnabled=false;setDebug(t){this.debugEnabled=t;}debug(t,...i){this.debugEnabled&&console.log(r.gray(`[DEBUG] ${t}`),...i);}info(t,...i){console.log(r.blue(t),...i);}success(t,...i){console.log(r.green(t),...i);}warn(t,...i){console.log(r.yellow(t),...i);}error(t,...i){console.error(r.red(t),...i);}step(t,i,n){console.log(r.cyan(`
|
|
3
|
+
[${t}/${i}]`),r.white(n));}},m=new F;var ne="rapidkit",oe=fileURLToPath(import.meta.url),ae=dirname(oe),re=join(ae,"..","package.json"),se=JSON.parse(readFileSync(re,"utf-8")),V=se.version;async function J(){try{m.debug("Checking for updates...");let{stdout:e}=await execa("npm",["view",ne,"version"],{timeout:3e3}),t=e.trim();t&&t!==V?(console.log(r.yellow(`
|
|
4
|
+
\u26A0\uFE0F Update available: ${V} \u2192 ${t}`)),console.log(r.cyan(`Run: npm install -g rapidkit@latest
|
|
5
|
+
`))):m.debug("You are using the latest version");}catch{m.debug("Could not check for updates");}}function N(){return V}var de=".rapidkitrc.json";async function W(){let e=l.join(le.homedir(),de);try{let t=await promises.readFile(e,"utf-8"),i=JSON.parse(t);return m.debug(`Loaded config from ${e}`),i}catch{return m.debug("No user config found, using defaults"),{}}}var S=class extends Error{constructor(i,n,a){super(i);this.code=n;this.details=a;this.name="RapidKitError",Error.captureStackTrace(this,this.constructor);}};var v=class extends S{constructor(t,i){super(`Invalid project name: "${t}"`,"INVALID_PROJECT_NAME",i);}};function M(e){let t=me(e);if(!t.validForNewPackages){let n=t.errors||[],a=t.warnings||[],s=[...n,...a];throw new v(e,`NPM validation failed: ${s.join(", ")}`)}if(!/^[a-z][a-z0-9_-]*$/.test(e))throw new v(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 v(e,`"${e}" is a reserved name. Please choose a different name.`);if(e.length<2)throw new v(e,"Name must be at least 2 characters long");if(e.length>214)throw new v(e,"Name must be less than 214 characters");return true}async function H(e,t){let i=A("Creating RapidKit workspace...").start();try{await promises.mkdir(e,{recursive:!0}),await promises.mkdir(l.join(e,".rapidkit"),{recursive:!0});let n={workspace_name:t.name,author:t.author,rapidkit_version:N(),created_at:new Date().toISOString(),type:"workspace"};await promises.writeFile(l.join(e,".rapidkit","config.json"),JSON.stringify(n,null,2));let a=ge();await promises.writeFile(l.join(e,"rapidkit"),a),await promises.chmod(l.join(e,"rapidkit"),493);let s=ue(t.name);if(await promises.writeFile(l.join(e,"README.md"),s),await promises.writeFile(l.join(e,".gitignore"),`# RapidKit workspace
|
|
6
6
|
.env
|
|
7
7
|
.env.*
|
|
8
8
|
!.env.example
|
|
@@ -17,36 +17,37 @@ Thumbs.db
|
|
|
17
17
|
|
|
18
18
|
# Logs
|
|
19
19
|
*.log
|
|
20
|
-
`),await
|
|
21
|
-
${
|
|
20
|
+
`),await fe(e),i.succeed("Workspace created!"),!t.skipGit){let o=A("Initializing git repository...").start();try{await execa("git",["init"],{cwd:e}),await execa("git",["add","."],{cwd:e}),await execa("git",["commit","-m","Initial commit: RapidKit workspace"],{cwd:e}),o.succeed("Git repository initialized");}catch{o.warn("Could not initialize git repository");}}console.log(`
|
|
21
|
+
${r.green("\u2728 RapidKit workspace created successfully!")}
|
|
22
22
|
|
|
23
|
-
${
|
|
23
|
+
${r.bold("\u{1F4C2} Workspace structure:")}
|
|
24
24
|
${e}/
|
|
25
|
-
\u251C\u2500\u2500 rapidkit # Local CLI
|
|
25
|
+
\u251C\u2500\u2500 rapidkit # Local CLI wrapper
|
|
26
26
|
\u251C\u2500\u2500 .rapidkit/ # Workspace configuration
|
|
27
27
|
\u2502 \u251C\u2500\u2500 config.json # Workspace settings
|
|
28
28
|
\u2502 \u2514\u2500\u2500 templates/ # Project templates
|
|
29
29
|
\u2514\u2500\u2500 README.md
|
|
30
30
|
|
|
31
|
-
${
|
|
32
|
-
${
|
|
33
|
-
${
|
|
34
|
-
${
|
|
35
|
-
${
|
|
36
|
-
${
|
|
31
|
+
${r.bold("\u{1F680} Get started:")}
|
|
32
|
+
${r.cyan(`cd ${t.name}`)}
|
|
33
|
+
${r.cyan("npx rapidkit my-api --template fastapi")}
|
|
34
|
+
${r.cyan("cd my-api")}
|
|
35
|
+
${r.cyan("npx rapidkit init")}
|
|
36
|
+
${r.cyan("npx rapidkit dev")}
|
|
37
37
|
|
|
38
|
-
${
|
|
38
|
+
${r.bold("\u{1F4E6} Available templates:")}
|
|
39
39
|
fastapi - FastAPI + Python (default)
|
|
40
40
|
nestjs - NestJS + TypeScript
|
|
41
41
|
|
|
42
|
-
${
|
|
43
|
-
rapidkit
|
|
44
|
-
rapidkit
|
|
45
|
-
rapidkit
|
|
42
|
+
${r.bold("\u{1F4DA} Commands:")}
|
|
43
|
+
npx rapidkit <name> --template <type> Create a new project
|
|
44
|
+
npx rapidkit init Install dependencies
|
|
45
|
+
npx rapidkit dev Start dev server
|
|
46
|
+
npx rapidkit help Show all commands
|
|
46
47
|
|
|
47
|
-
${
|
|
48
|
-
|
|
49
|
-
`);}catch(n){throw i.fail("Failed to create workspace"),n}}function
|
|
48
|
+
${r.gray("Alternative: ./rapidkit dev, make dev")}
|
|
49
|
+
${r.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
|
|
50
|
+
`);}catch(n){throw i.fail("Failed to create workspace"),n}}function ge(){return `#!/usr/bin/env bash
|
|
50
51
|
#
|
|
51
52
|
# RapidKit CLI - Local workspace commands
|
|
52
53
|
# This script provides rapidkit commands within the workspace
|
|
@@ -382,7 +383,7 @@ main() {
|
|
|
382
383
|
print_help
|
|
383
384
|
;;
|
|
384
385
|
version|-v|--version)
|
|
385
|
-
echo "RapidKit CLI (npm workspace) v${
|
|
386
|
+
echo "RapidKit CLI (npm workspace) v${N()}"
|
|
386
387
|
;;
|
|
387
388
|
*)
|
|
388
389
|
echo -e "\${RED}\u274C Unknown command: $cmd\${NC}"
|
|
@@ -394,7 +395,7 @@ main() {
|
|
|
394
395
|
}
|
|
395
396
|
|
|
396
397
|
main "$@"
|
|
397
|
-
`}function
|
|
398
|
+
`}function ue(e){return `# ${e}
|
|
398
399
|
|
|
399
400
|
RapidKit workspace for building API projects.
|
|
400
401
|
|
|
@@ -405,15 +406,15 @@ RapidKit workspace for building API projects.
|
|
|
405
406
|
export PATH="$PWD:$PATH"
|
|
406
407
|
|
|
407
408
|
# Create a FastAPI project
|
|
408
|
-
rapidkit
|
|
409
|
+
npx rapidkit my-api --template fastapi
|
|
409
410
|
|
|
410
411
|
# Or create a NestJS project
|
|
411
|
-
rapidkit
|
|
412
|
+
npx rapidkit my-app --template nestjs
|
|
412
413
|
|
|
413
414
|
# Enter project and start development
|
|
414
415
|
cd my-api
|
|
415
|
-
rapidkit init # Install dependencies
|
|
416
|
-
rapidkit dev # Start dev server
|
|
416
|
+
npx rapidkit init # Install dependencies
|
|
417
|
+
npx rapidkit dev # Start dev server
|
|
417
418
|
\`\`\`
|
|
418
419
|
|
|
419
420
|
## Available Templates
|
|
@@ -425,31 +426,24 @@ rapidkit dev # Start dev server
|
|
|
425
426
|
|
|
426
427
|
## Commands
|
|
427
428
|
|
|
428
|
-
###
|
|
429
|
+
### Commands
|
|
429
430
|
|
|
430
431
|
| Command | Description |
|
|
431
432
|
|---------|-------------|
|
|
432
|
-
| \`rapidkit
|
|
433
|
-
| \`rapidkit
|
|
434
|
-
| \`rapidkit
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
|
439
|
-
|
|
440
|
-
| \`rapidkit init\` | Install dependencies |
|
|
441
|
-
| \`rapidkit dev\` | Start development server |
|
|
442
|
-
| \`rapidkit start\` | Start production server |
|
|
443
|
-
| \`rapidkit build\` | Build for production |
|
|
444
|
-
| \`rapidkit test\` | Run tests |
|
|
445
|
-
| \`rapidkit lint\` | Run linting |
|
|
446
|
-
| \`rapidkit format\` | Format code |
|
|
433
|
+
| \`npx rapidkit <name> --template <type>\` | Create a new project |
|
|
434
|
+
| \`npx rapidkit init\` | Install dependencies |
|
|
435
|
+
| \`npx rapidkit dev\` | Start development server |
|
|
436
|
+
| \`npx rapidkit start\` | Start production server |
|
|
437
|
+
| \`npx rapidkit build\` | Build for production |
|
|
438
|
+
| \`npx rapidkit test\` | Run tests |
|
|
439
|
+
| \`npx rapidkit lint\` | Run linting |
|
|
440
|
+
| \`npx rapidkit format\` | Format code |
|
|
447
441
|
|
|
448
442
|
## Learn More
|
|
449
443
|
|
|
450
444
|
- [RapidKit Documentation](https://rapidkit.dev)
|
|
451
445
|
- [GitHub Repository](https://github.com/Baziar/rapidkit)
|
|
452
|
-
`}async function
|
|
446
|
+
`}async function fe(e){let{fileURLToPath:t}=await import('url'),i=t(import.meta.url),n=l.dirname(i),a=l.resolve(n,".."),s=l.join(a,"templates","kits"),c=l.join(e,".rapidkit","templates"),{default:o}=await import('fs-extra');await o.copy(s,c);let d=l.join(a,"templates","generator.js"),f=l.join(e,".rapidkit","generator.js");await o.copy(d,f);}async function Y(e,t){let i=t.template==="fastapi",n=i?"FastAPI":"NestJS",a=A(`Creating ${n} project...`).start();try{let{fileURLToPath:s}=await import('url'),c=s(import.meta.url),o=l.dirname(c),d=l.resolve(o,".."),f=i?"fastapi-standard":"nestjs-standard",$=l.join(d,"templates","kits",f);await promises.mkdir(e,{recursive:!0});let j={project_name:i?t.name.replace(/-/g,"_").toLowerCase():t.name.replace(/_/g,"-").toLowerCase(),author:t.author,description:t.description||`${n} application generated with RapidKit`,app_version:"0.1.0",license:"MIT",package_manager:t.package_manager||"npm",created_at:new Date().toISOString(),rapidkit_version:N()};await z($,e,j);let _=i?`# Python
|
|
453
447
|
__pycache__/
|
|
454
448
|
*.py[cod]
|
|
455
449
|
*$py.class
|
|
@@ -517,10 +511,10 @@ Thumbs.db
|
|
|
517
511
|
|
|
518
512
|
# Coverage
|
|
519
513
|
coverage/
|
|
520
|
-
`;if(await promises.writeFile(l.join(e,".gitignore"),
|
|
521
|
-
${
|
|
514
|
+
`;if(await promises.writeFile(l.join(e,".gitignore"),_),a.succeed(`${n} project created!`),!t.skipGit){let w=A("Initializing git repository...").start();try{await execa("git",["init"],{cwd:e}),await execa("git",["add","."],{cwd:e}),await execa("git",["commit","-m",`Initial commit: ${n} project via RapidKit`],{cwd:e}),w.succeed("Git repository initialized");}catch{w.warn("Could not initialize git repository");}}if(!t.skipInstall&&!i){let w=t.package_manager||"npm",D=A(`Installing dependencies with ${w}...`).start();try{await execa(w,["install"],{cwd:e}),D.succeed("Dependencies installed");}catch{D.warn(`Could not install dependencies. Run '${w} install' manually.`);}}let L=l.basename(e);console.log(i?`
|
|
515
|
+
${r.green("\u2728 FastAPI project created successfully!")}
|
|
522
516
|
|
|
523
|
-
${
|
|
517
|
+
${r.bold("\u{1F4C2} Project structure:")}
|
|
524
518
|
${e}/
|
|
525
519
|
\u251C\u2500\u2500 .rapidkit/ # RapidKit CLI module
|
|
526
520
|
\u251C\u2500\u2500 src/
|
|
@@ -532,24 +526,25 @@ ${e}/
|
|
|
532
526
|
\u251C\u2500\u2500 pyproject.toml # Poetry configuration
|
|
533
527
|
\u2514\u2500\u2500 README.md
|
|
534
528
|
|
|
535
|
-
${
|
|
536
|
-
${
|
|
537
|
-
${
|
|
538
|
-
${
|
|
539
|
-
|
|
540
|
-
${
|
|
541
|
-
rapidkit init
|
|
542
|
-
rapidkit dev
|
|
543
|
-
rapidkit start
|
|
544
|
-
rapidkit test
|
|
545
|
-
rapidkit lint
|
|
546
|
-
rapidkit format
|
|
547
|
-
|
|
548
|
-
${
|
|
529
|
+
${r.bold("\u{1F680} Get started:")}
|
|
530
|
+
${r.cyan(`cd ${L}`)}
|
|
531
|
+
${r.cyan("npx rapidkit init")} ${r.gray("# Install dependencies")}
|
|
532
|
+
${r.cyan("npx rapidkit dev")} ${r.gray("# Start dev server")}
|
|
533
|
+
|
|
534
|
+
${r.bold("\u{1F4DA} Available commands:")}
|
|
535
|
+
npx rapidkit init # Install dependencies (poetry install)
|
|
536
|
+
npx rapidkit dev # Start dev server with hot reload
|
|
537
|
+
npx rapidkit start # Start production server
|
|
538
|
+
npx rapidkit test # Run tests
|
|
539
|
+
npx rapidkit lint # Lint code
|
|
540
|
+
npx rapidkit format # Format code
|
|
541
|
+
|
|
542
|
+
${r.gray("Alternative: make dev, ./rapidkit dev, poetry run dev")}
|
|
543
|
+
${r.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
|
|
549
544
|
`:`
|
|
550
|
-
${
|
|
545
|
+
${r.green("\u2728 NestJS project created successfully!")}
|
|
551
546
|
|
|
552
|
-
${
|
|
547
|
+
${r.bold("\u{1F4C2} Project structure:")}
|
|
553
548
|
${e}/
|
|
554
549
|
\u251C\u2500\u2500 .rapidkit/ # RapidKit CLI module
|
|
555
550
|
\u251C\u2500\u2500 src/
|
|
@@ -561,29 +556,31 @@ ${e}/
|
|
|
561
556
|
\u251C\u2500\u2500 package.json # Dependencies
|
|
562
557
|
\u2514\u2500\u2500 README.md
|
|
563
558
|
|
|
564
|
-
${
|
|
565
|
-
${
|
|
566
|
-
${t.skipInstall?
|
|
567
|
-
`:""}${
|
|
568
|
-
${
|
|
569
|
-
|
|
570
|
-
${
|
|
571
|
-
rapidkit init
|
|
572
|
-
rapidkit dev
|
|
573
|
-
rapidkit start
|
|
574
|
-
rapidkit build
|
|
575
|
-
rapidkit test
|
|
576
|
-
rapidkit lint
|
|
577
|
-
rapidkit format
|
|
578
|
-
|
|
579
|
-
${
|
|
559
|
+
${r.bold("\u{1F680} Get started:")}
|
|
560
|
+
${r.cyan(`cd ${L}`)}
|
|
561
|
+
${t.skipInstall?r.cyan("npx rapidkit init")+r.gray(" # npm install")+`
|
|
562
|
+
`:""}${r.cyan("cp .env.example .env")}
|
|
563
|
+
${r.cyan("npx rapidkit dev")} ${r.gray("# Start dev server")}
|
|
564
|
+
|
|
565
|
+
${r.bold("\u{1F4DA} Available commands:")}
|
|
566
|
+
npx rapidkit init # Install dependencies
|
|
567
|
+
npx rapidkit dev # Start dev server with hot reload
|
|
568
|
+
npx rapidkit start # Start production server
|
|
569
|
+
npx rapidkit build # Build for production
|
|
570
|
+
npx rapidkit test # Run tests
|
|
571
|
+
npx rapidkit lint # Lint code
|
|
572
|
+
npx rapidkit format # Format code
|
|
573
|
+
|
|
574
|
+
${r.bold("\u{1F310} API endpoints:")}
|
|
580
575
|
http://localhost:8000/health # Health check
|
|
581
576
|
http://localhost:8000/docs # Swagger docs
|
|
582
577
|
http://localhost:8000/examples/notes # Example API
|
|
583
|
-
|
|
578
|
+
|
|
579
|
+
${r.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
|
|
580
|
+
`);}catch(s){throw a.fail(`Failed to create ${n} project`),s}}async function z(e,t,i){let n=await promises.readdir(e,{withFileTypes:true});for(let a of n){let s=l.join(e,a.name),c=a.name.replace(/\.j2$/,""),o=l.join(t,c);if(a.isDirectory())await promises.mkdir(o,{recursive:true}),await z(s,o,i);else {let d=await promises.readFile(s,"utf-8");a.name.endsWith(".j2")&&(d=he(d,i)),await promises.writeFile(o,d),(c==="rapidkit"||c==="activate"||c.endsWith(".py")&&o.includes(".rapidkit"))&&await promises.chmod(o,493);}}}function he(e,t){let i=e;for(let[n,a]of Object.entries(t)){let s=new RegExp(`\\{\\{\\s*${n}\\s*\\}\\}`,"g");i=i.replace(s,String(a));let c=new RegExp(`\\{\\{\\s*${n}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\}\\}`,"g");i=i.replace(c,(f,$,j)=>String(a).replace(new RegExp($,"g"),j));let o=new RegExp(`\\{\\{\\s*${n}\\s*\\|\\s*lower\\s*\\}\\}`,"g");i=i.replace(o,String(a).toLowerCase());let d=new RegExp(`\\{\\{\\s*${n}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\|\\s*lower\\s*\\}\\}`,"g");i=i.replace(d,(f,$,j)=>String(a).replace(new RegExp($,"g"),j).toLowerCase());}return i}var B=["init","dev","start","build","test","lint","format","create","help","--help","-h"];function ye(e){let t=e;for(;;){let i=l.join(t,".rapidkit","context.json");if(y.existsSync(i))return i;let n=l.dirname(t);if(n===t)break;t=n;}return null}function $e(e){let t=process.platform==="win32",i=e;for(;;){if(t){let c=l.join(i,"rapidkit.cmd"),o=l.join(i,".rapidkit","rapidkit.cmd");if(y.existsSync(c))return c;if(y.existsSync(o))return o}let n=l.join(i,"rapidkit"),a=l.join(i,".rapidkit","rapidkit");if(y.existsSync(n))return n;if(y.existsSync(a))return a;let s=l.dirname(i);if(s===i)break;i=s;}return null}(()=>{try{let e=process.cwd(),i=process.argv.slice(2)[0],n=ye(e);if(n&&y.existsSync(n)){let a=y.readFileSync(n,"utf8");try{let s=JSON.parse(a),c=i==="shell"&&process.argv.slice(2)[1]==="activate",d=$e(e)&&i&&B.includes(i);s?.engine==="pip"&&!c&&!d&&i!=="init"&&(console.log(r.yellow(`
|
|
584
581
|
\u26A0\uFE0F This project uses the Python RapidKit engine (pip). The global npm RapidKit CLI will not operate on this project.
|
|
585
582
|
\u{1F4A1} To prepare this project run: 'rapidkit init' (it uses the project's Python toolchain)
|
|
586
|
-
`)),process.exit(0));}catch{}}}catch{}})();function
|
|
583
|
+
`)),process.exit(0));}catch{}}}catch{}})();function X(e){let t=e;for(;;){let i=l.join(t,".rapidkit","context.json");if(y.existsSync(i))return i;let n=l.dirname(t);if(n===t)break;t=n;}return null}async function we(){let e=process.cwd(),t=X(e),i=process.platform==="win32",n=i?[l.join(e,"rapidkit.cmd"),l.join(e,"rapidkit"),l.join(e,".rapidkit","rapidkit.cmd"),l.join(e,".rapidkit","rapidkit")]:[l.join(e,"rapidkit"),l.join(e,".rapidkit","rapidkit")],a=null;for(let o of n)if(await h.pathExists(o)){a=o;break}let s=process.argv.slice(2),c=s[0];if(a&&c&&B.includes(c)){m.debug(`Delegating to local CLI: ${a} ${s.join(" ")}`);let o=spawn(a,s,{stdio:"inherit",cwd:e,shell:i});return o.on("close",d=>{process.exit(d??0);}),o.on("error",d=>{m.error(`Failed to run local rapidkit: ${d.message}`),process.exit(1);}),true}if(t&&await h.pathExists(t))try{if((await h.readJson(t)).engine==="pip"){let d=process.argv.slice(2),f=d[0],j=process.platform==="win32"?[l.join(e,"rapidkit.cmd"),l.join(e,"rapidkit"),l.join(e,".rapidkit","rapidkit.cmd"),l.join(e,".rapidkit","rapidkit")]:[l.join(e,"rapidkit"),l.join(e,".rapidkit","rapidkit")],_=null;for(let g of j)if(await h.pathExists(g)){_=g;break}if(_&&f&&B.includes(f)){m.debug(`Delegating to local CLI (early detection): ${_} ${d.join(" ")}`);let g=spawn(_,d,{stdio:"inherit",cwd:e});return g.on("close",E=>process.exit(E??0)),g.on("error",E=>{m.error(`Failed to run local rapidkit: ${E.message}`),process.exit(1);}),!0}if(f==="shell"&&d[1]==="activate"){let g=`# RapidKit: activation snippet - eval "$(rapidkit shell activate)"
|
|
587
584
|
VENV='.venv'
|
|
588
585
|
if [ -f "$VENV/bin/activate" ]; then
|
|
589
586
|
. "$VENV/bin/activate"
|
|
@@ -592,21 +589,21 @@ elif [ -f "$VENV/bin/activate.fish" ]; then
|
|
|
592
589
|
fi
|
|
593
590
|
export RAPIDKIT_PROJECT_ROOT="$(pwd)"
|
|
594
591
|
export PATH="$(pwd)/.rapidkit:$(pwd):$PATH"
|
|
595
|
-
`;console.log(
|
|
592
|
+
`;console.log(r.green.bold(`
|
|
596
593
|
\u2705 Activation snippet \u2014 run the following to activate this project in your current shell:
|
|
597
|
-
`)),console.log(g),console.log(
|
|
594
|
+
`)),console.log(g),console.log(r.gray(`
|
|
598
595
|
\u{1F4A1} After activation you can run: rapidkit dev
|
|
599
|
-
`)),process.exit(0);}if(
|
|
596
|
+
`)),process.exit(0);}if(f!=="init"){let g=(await import('chalk')).default;console.log(g.yellow(`
|
|
600
597
|
\u26A0\uFE0F This project uses the Python RapidKit engine (pip). The global npm RapidKit CLI will not operate on this project.
|
|
601
598
|
\u{1F4A1} To prepare this project run: 'rapidkit init' (it uses the project's Python toolchain)
|
|
602
599
|
|
|
603
|
-
`)),process.exit(0);}let
|
|
600
|
+
`)),process.exit(0);}let L=(await import('chalk')).default;console.log(L.yellow(`
|
|
604
601
|
\u26A0\uFE0F This project was created with the Python engine (pip). RapidKit (npm) will try to install the Python CLI for you...
|
|
605
|
-
`));let{spawnSync:
|
|
602
|
+
`));let{spawnSync:w}=await import('child_process'),D=[["python3",["-m","pip","install","rapidkit-core"]],["python",["-m","pip","install","rapidkit-core"]],["pip",["install","rapidkit-core"]]],P=!0;if(process.stdin.isTTY)try{P=!!(await O.prompt([{type:"confirm",name:"confirm",message:"This project needs the Python RapidKit CLI (rapidkit). Do you want to try installing it now using pip?",default:!0}])).confirm;}catch{P=!1;}else P=!1;if(!P){let g=(await import('chalk')).default;console.log(g.yellow(`
|
|
606
603
|
\u26A0\uFE0F Skipping automatic installation of the Python RapidKit CLI (rapidkit-core).
|
|
607
604
|
\u{1F4A1} To continue, either run 'rapidkit init' locally after installing rapidkit-core: \`python3 -m pip install rapidkit-core\`
|
|
608
|
-
`)),process.exit(0);}let
|
|
609
|
-
`)),
|
|
605
|
+
`)),process.exit(0);}let R={status:1};if(P)for(let[g,E]of D)try{if(console.log(r.gray(`Running: ${g} ${E.join(" ")}
|
|
606
|
+
`)),R=w(g,E,{stdio:"inherit"}),R&&R.status===0)break}catch{}if(R&&R.status===0){let g=(await import('chalk')).default;console.log(g.green(`
|
|
610
607
|
\u2705 RapidKit Python CLI (rapidkit) installed successfully!
|
|
611
608
|
Please re-run your command.
|
|
612
609
|
`));}else {let g=(await import('chalk')).default;console.log(g.red(`
|
|
@@ -615,22 +612,22 @@ Please re-run your command.
|
|
|
615
612
|
python3 -m pip install rapidkit
|
|
616
613
|
python -m pip install rapidkit
|
|
617
614
|
pip install rapidkit
|
|
618
|
-
`));}process.exit(
|
|
615
|
+
`));}process.exit(R.status??1);}}catch{}return false}var x=null,U=false,K=new Command;K.name("rapidkit").description("Create RapidKit workspaces and projects").version(N());K.argument("[name]","Name of the workspace or project directory").option("-t, --template <template>","Create project with template (fastapi, nestjs) instead of workspace").option("-y, --yes","Skip prompts and use defaults").option("--skip-git","Skip git initialization").option("--skip-install","Skip installing dependencies").option("--debug","Enable debug logging").option("--dry-run","Show what would be created without creating it").option("--no-update-check","Skip checking for updates").action(async(e,t)=>{try{t.debug&&(m.setDebug(!0),m.debug("Debug mode enabled"));let i=await W();m.debug("User config loaded",i),t.updateCheck!==!1&&await J(),console.log(r.blue.bold(`
|
|
619
616
|
\u{1F680} Welcome to RapidKit!
|
|
620
|
-
`)),e||(
|
|
621
|
-
\u274C ${c.message}`),c.details&&
|
|
622
|
-
`),process.exit(1)),c}let n=l.resolve(process.cwd(),e);
|
|
623
|
-
\u274C Directory "${e}" already exists`),console.log(
|
|
617
|
+
`)),e||(ve(),process.exit(0));try{M(e);}catch(c){throw c instanceof S&&(m.error(`
|
|
618
|
+
\u274C ${c.message}`),c.details&&m.warn(`\u{1F4A1} ${c.details}
|
|
619
|
+
`),process.exit(1)),c}let n=l.resolve(process.cwd(),e);x=n,await h.pathExists(n)&&(m.error(`
|
|
620
|
+
\u274C Directory "${e}" already exists`),console.log(r.cyan(`
|
|
624
621
|
\u{1F4A1} Choose a different name or delete the existing directory.
|
|
625
|
-
`)),process.exit(1));let
|
|
626
|
-
\u274C Invalid template: ${t.template}`),console.log(
|
|
627
|
-
\u{1F4E6} Available templates: ${
|
|
628
|
-
`)),process.exit(1));}if(t.dryRun){console.log(
|
|
622
|
+
`)),process.exit(1));let a=!!t.template;if(a){let c=t.template.toLowerCase(),o=["fastapi","nestjs"];o.includes(c)||(m.error(`
|
|
623
|
+
\u274C Invalid template: ${t.template}`),console.log(r.cyan(`
|
|
624
|
+
\u{1F4E6} Available templates: ${o.join(", ")}
|
|
625
|
+
`)),process.exit(1));}if(t.dryRun){console.log(r.cyan(`
|
|
629
626
|
\u{1F50D} Dry-run mode - showing what would be created:
|
|
630
|
-
`)),console.log(
|
|
631
|
-
`))):
|
|
632
|
-
\u274C ${i.message}`),i.details&&
|
|
633
|
-
\u274C An unexpected error occurred:`),console.error(i)),process.exit(1);}finally{
|
|
627
|
+
`)),console.log(r.white("\u{1F4C2} Path:"),n),console.log(r.white("\u{1F4E6} Type:"),a?`Project (${t.template})`:"Workspace"),console.log();return}let s;t.yes?(s={author:process.env.USER||"RapidKit User",description:a?`${t.template==="nestjs"?"NestJS":"FastAPI"} application generated with RapidKit`:void 0,package_manager:"npm"},console.log(r.gray(`Using default values (--yes flag)
|
|
628
|
+
`))):a?t.template.toLowerCase()==="fastapi"?s=await O.prompt([{type:"input",name:"author",message:"Author name:",default:process.env.USER||"RapidKit User"},{type:"input",name:"description",message:"Project description:",default:"FastAPI service generated with RapidKit"}]):s=await O.prompt([{type:"input",name:"author",message:"Author name:",default:process.env.USER||"RapidKit User"},{type:"input",name:"description",message:"Project description:",default:"NestJS application generated with RapidKit"},{type:"list",name:"package_manager",message:"Package manager:",choices:["npm","yarn","pnpm"],default:"npm"}]):s=await O.prompt([{type:"input",name:"author",message:"Author name:",default:process.env.USER||"RapidKit User"}]),a?await Y(n,{name:e,template:t.template.toLowerCase(),author:s.author,description:s.description,package_manager:s.package_manager,skipGit:t.skipGit,skipInstall:t.skipInstall}):await H(n,{name:e,author:s.author,skipGit:t.skipGit});}catch(i){i instanceof S?(m.error(`
|
|
629
|
+
\u274C ${i.message}`),i.details&&m.warn(`\u{1F4A1} ${i.details}`),m.debug("Error code:",i.code)):(m.error(`
|
|
630
|
+
\u274C An unexpected error occurred:`),console.error(i)),process.exit(1);}finally{x=null;}});K.command("shell <action>").description("Shell helpers (activate virtualenv in current shell)").action(async e=>{e!=="activate"&&(console.log(r.red(`Unknown shell command: ${e}`)),process.exit(1));let t=process.cwd();function i(c){let o=c;for(;;){let d=l.join(o,".rapidkit","context.json");if(y.existsSync(d))return d;let f=l.dirname(o);if(f===o)break;o=f;}return null}let n=i(t);function a(c){let o=c;for(;;){let d=l.join(o,".venv"),f=l.join(o,".rapidkit","activate");if(y.existsSync(f)||y.existsSync(d))return {venv:d,activateFile:f};let $=l.dirname(o);if($===o)break;o=$;}return null}let s=a(t);if(!n&&!s&&(console.log(r.red("No RapidKit project found to activate")),process.exit(1)),s){let c=`# RapidKit: activation snippet - eval "$(rapidkit shell activate)"
|
|
634
631
|
VENV='.venv'
|
|
635
632
|
if [ -f "$VENV/bin/activate" ]; then
|
|
636
633
|
. "$VENV/bin/activate"
|
|
@@ -639,11 +636,11 @@ elif [ -f "$VENV/bin/activate.fish" ]; then
|
|
|
639
636
|
fi
|
|
640
637
|
export RAPIDKIT_PROJECT_ROOT="$(pwd)"
|
|
641
638
|
export PATH="$(pwd)/.rapidkit:$(pwd):$PATH"
|
|
642
|
-
`;console.log(
|
|
639
|
+
`;console.log(r.green.bold(`
|
|
643
640
|
\u2705 Activation snippet \u2014 run the following to activate this project in your current shell:
|
|
644
|
-
`)),console.log(c),console.log(
|
|
641
|
+
`)),console.log(c),console.log(r.gray(`
|
|
645
642
|
\u{1F4A1} After activation you can run: rapidkit dev
|
|
646
|
-
`)),process.exit(0);}try{(await
|
|
643
|
+
`)),process.exit(0);}try{(await h.readJson(n)).engine!=="pip"&&(console.log(r.yellow("This project is not a pip-based RapidKit project.")),process.exit(1)),console.log(`# RapidKit: activation snippet - eval "$(rapidkit shell activate)"
|
|
647
644
|
VENV='.venv'
|
|
648
645
|
if [ -f "$VENV/bin/activate" ]; then
|
|
649
646
|
. "$VENV/bin/activate"
|
|
@@ -652,7 +649,7 @@ elif [ -f "$VENV/bin/activate.fish" ]; then
|
|
|
652
649
|
fi
|
|
653
650
|
export RAPIDKIT_PROJECT_ROOT="$(pwd)"
|
|
654
651
|
export PATH="$(pwd)/.rapidkit:$(pwd):$PATH"
|
|
655
|
-
`),process.exit(0);}catch{console.log(
|
|
652
|
+
`),process.exit(0);}catch{console.log(r.yellow("Could not read project context but found a venv or activation file \u2014 printing activation snippet")),console.log(`# RapidKit: activation snippet - eval "$(rapidkit shell activate)"
|
|
656
653
|
VENV='.venv'
|
|
657
654
|
if [ -f "$VENV/bin/activate" ]; then
|
|
658
655
|
. "$VENV/bin/activate"
|
|
@@ -661,15 +658,15 @@ elif [ -f "$VENV/bin/activate.fish" ]; then
|
|
|
661
658
|
fi
|
|
662
659
|
export RAPIDKIT_PROJECT_ROOT="$(pwd)"
|
|
663
660
|
export PATH="$(pwd):$PATH"
|
|
664
|
-
`),process.exit(0);}});function
|
|
665
|
-
`)),console.log(
|
|
666
|
-
`)),console.log(
|
|
667
|
-
`)),console.log(
|
|
668
|
-
`)),console.log(
|
|
669
|
-
`));}process.on("SIGINT",async()=>{if(!
|
|
670
|
-
|
|
671
|
-
\u26A0\uFE0F Interrupted by user`)),
|
|
661
|
+
`),process.exit(0);}});function ve(){console.log(r.white(`Usage: npx rapidkit <name> [options]
|
|
662
|
+
`)),console.log(r.bold("Create a workspace (recommended):")),console.log(r.cyan(" npx rapidkit my-workspace")),console.log(r.cyan(" cd my-workspace")),console.log(r.cyan(" rapidkit create my-api --template fastapi")),console.log(r.cyan(" cd my-api")),console.log(r.cyan(` rapidkit dev
|
|
663
|
+
`)),console.log(r.bold("Or create a project directly:")),console.log(r.cyan(" npx rapidkit my-project --template fastapi")),console.log(r.cyan(` npx rapidkit my-project --template nestjs
|
|
664
|
+
`)),console.log(r.bold("Options:")),console.log(r.gray(" -t, --template <template> Create project with template (fastapi, nestjs)")),console.log(r.gray(" -y, --yes Skip prompts and use defaults")),console.log(r.gray(" --skip-git Skip git initialization")),console.log(r.gray(" --skip-install Skip installing dependencies")),console.log(r.gray(" --debug Enable debug logging")),console.log(r.gray(` --dry-run Show what would be created
|
|
665
|
+
`)),console.log(r.bold("Templates:")),console.log(r.gray(" fastapi FastAPI + Python")),console.log(r.gray(` nestjs NestJS + TypeScript
|
|
666
|
+
`));}process.on("SIGINT",async()=>{if(!U){if(U=true,console.log(r.yellow(`
|
|
667
|
+
|
|
668
|
+
\u26A0\uFE0F Interrupted by user`)),x&&await h.pathExists(x)){console.log(r.gray("Cleaning up partial installation..."));try{await h.remove(x),console.log(r.green("\u2713 Cleanup complete"));}catch(e){m.debug("Cleanup failed:",e);}}process.exit(130);}});process.on("SIGTERM",async()=>{if(!U){if(U=true,m.debug("Received SIGTERM"),x&&await h.pathExists(x))try{await h.remove(x);}catch(e){m.debug("Cleanup failed:",e);}process.exit(143);}});we().then(async e=>{if(!e){let t=process.cwd();try{let i=X(t);if(i&&await h.pathExists(i)){let n=await h.readJson(i),a=process.argv.slice(2)[0];if(n?.engine==="pip"&&a!=="init"){let s=(await import('chalk')).default;console.log(s.yellow(`
|
|
672
669
|
\u26A0\uFE0F This project uses the Python RapidKit engine (pip). The global npm RapidKit CLI will not operate on this project.
|
|
673
670
|
\u{1F4A1} To prepare this project run: 'rapidkit init' (it uses the project's Python toolchain)
|
|
674
671
|
|
|
675
|
-
`)),process.exit(0);}}}catch{}
|
|
672
|
+
`)),process.exit(0);}}}catch{}K.parse();}});
|
package/dist/package.json
CHANGED
package/package.json
CHANGED
|
@@ -5,18 +5,25 @@ A minimal FastAPI service generated with the **FastAPI Standard Kit**. All domai
|
|
|
5
5
|
## Quick start
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
rapidkit init
|
|
9
|
-
rapidkit dev
|
|
8
|
+
npx rapidkit init # Install dependencies
|
|
9
|
+
npx rapidkit dev # Start dev server at http://localhost:8000
|
|
10
10
|
```
|
|
11
11
|
|
|
12
12
|
## Available commands
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
rapidkit init
|
|
16
|
-
rapidkit dev
|
|
17
|
-
rapidkit start
|
|
18
|
-
rapidkit test
|
|
19
|
-
rapidkit help
|
|
15
|
+
npx rapidkit init # ๐ง Install dependencies (poetry install)
|
|
16
|
+
npx rapidkit dev # ๐ Start development server with hot reload
|
|
17
|
+
npx rapidkit start # โก Start production server
|
|
18
|
+
npx rapidkit test # ๐งช Run tests
|
|
19
|
+
npx rapidkit help # ๐ Show available commands
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**Alternative commands:**
|
|
23
|
+
```bash
|
|
24
|
+
./rapidkit dev # Using the local wrapper script
|
|
25
|
+
make dev # Using Makefile
|
|
26
|
+
poetry run dev # Using Poetry directly
|
|
20
27
|
```
|
|
21
28
|
|
|
22
29
|
## Project layout
|
|
@@ -41,8 +41,31 @@ if %ERRORLEVEL% EQU 0 (
|
|
|
41
41
|
goto :run
|
|
42
42
|
)
|
|
43
43
|
|
|
44
|
-
echo
|
|
45
|
-
echo
|
|
44
|
+
echo.
|
|
45
|
+
echo ============================================================
|
|
46
|
+
echo Python not found!
|
|
47
|
+
echo ============================================================
|
|
48
|
+
echo.
|
|
49
|
+
echo RapidKit FastAPI projects require Python 3.11 or newer.
|
|
50
|
+
echo.
|
|
51
|
+
echo Install Python using one of these methods:
|
|
52
|
+
echo.
|
|
53
|
+
echo 1. Microsoft Store (recommended):
|
|
54
|
+
echo https://apps.microsoft.com/detail/9NRWMJP3717K
|
|
55
|
+
echo.
|
|
56
|
+
echo 2. Official installer:
|
|
57
|
+
echo https://www.python.org/downloads/
|
|
58
|
+
echo (Check "Add Python to PATH" during installation)
|
|
59
|
+
echo.
|
|
60
|
+
echo 3. Using winget:
|
|
61
|
+
echo winget install Python.Python.3.12
|
|
62
|
+
echo.
|
|
63
|
+
echo 4. Using chocolatey:
|
|
64
|
+
echo choco install python
|
|
65
|
+
echo.
|
|
66
|
+
echo After installing, restart your terminal and try again.
|
|
67
|
+
echo ============================================================
|
|
68
|
+
echo.
|
|
46
69
|
exit /b 127
|
|
47
70
|
|
|
48
71
|
:run
|
|
@@ -15,19 +15,32 @@ A production-ready NestJS 11 application generated with RapidKit.
|
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
17
|
# Install dependencies
|
|
18
|
-
|
|
18
|
+
npx rapidkit init
|
|
19
19
|
|
|
20
20
|
# Copy environment file
|
|
21
21
|
cp .env.example .env
|
|
22
22
|
|
|
23
23
|
# Start development server
|
|
24
|
-
|
|
24
|
+
npx rapidkit dev
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
Your API will be available at `http://localhost:8000`
|
|
28
28
|
API docs available at `http://localhost:8000/docs`
|
|
29
29
|
|
|
30
|
-
## ๐ Available
|
|
30
|
+
## ๐ Available Commands
|
|
31
|
+
|
|
32
|
+
**RapidKit CLI (recommended):**
|
|
33
|
+
```bash
|
|
34
|
+
npx rapidkit init # Install dependencies
|
|
35
|
+
npx rapidkit dev # Start dev server with hot reload
|
|
36
|
+
npx rapidkit build # Build for production
|
|
37
|
+
npx rapidkit start # Start production server
|
|
38
|
+
npx rapidkit test # Run tests
|
|
39
|
+
npx rapidkit lint # Lint code
|
|
40
|
+
npx rapidkit format # Format code
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Alternative ({{ package_manager }}):**
|
|
31
44
|
|
|
32
45
|
| Command | Description |
|
|
33
46
|
|---------|-------------|
|