@burger-api/cli 0.7.0 → 0.9.1

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/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  All notable changes to the Burger API CLI will be documented in this file.
4
4
 
5
+ ## Version 0.9.0 - (March 15, 2026)
6
+
7
+ - ✨ **Create** – New projects get a config file (`burger.config.ts`) from
8
+ your answers; the build uses this config when present.
9
+ - 🔨 **Build** – One build pipeline for both bundle and executable; routes
10
+ are found at build time so production is fast and reliable.
11
+ - 📂 **Defaults** – Executable output: `.build/executable/<project>` (or
12
+ `.exe` on Windows); bundle: `.build/bundle/app.js`.
13
+ - 🧪 **Tests** – New tests for routes, config, and build output; CI catches
14
+ broken builds early.
15
+ - 🐛 **Fixed** – Invalid route combinations are caught at build time.
16
+ - 🐛 **Fixed** – Production build keeps your middleware and options (e.g.
17
+ title, description) instead of dropping them.
18
+ - 📚 **Docs** – README updated with production build steps and test
19
+ commands.
20
+
5
21
  ## Version 0.7.0 - (December 23, 2025)
6
22
 
7
23
  ### Added
@@ -32,7 +48,7 @@ All notable changes to the Burger API CLI will be documented in this file.
32
48
  - `list` command to show available middleware from ecosystem
33
49
  - `add` command to download and install middleware
34
50
  - `build` command to bundle projects to single JS file
35
- - `build:executable` command to compile to standalone executable
51
+ - `build:exec` command to compile to standalone executable
36
52
  - `serve` command for development server with hot reload
37
53
  - Beautiful console output with colors and symbols
38
54
  - Zero external dependencies for file operations (uses Bun's native APIs)
package/README.md CHANGED
@@ -1,79 +1,57 @@
1
- # Burger API CLI
1
+ # BurgerAPI CLI 👨‍💻
2
2
 
3
- Simple command-line tool for creating and managing Burger API projects.
3
+ A Command-Line Tool for Creating and Managing BurgerAPI Projects.
4
4
 
5
5
  ## Installation
6
6
 
7
- ### Option 1: npm/bun (Recommended if you have Bun installed)
7
+ ### Option 1: Bun Global Installation (Recommended if you have Bun installed)
8
+
9
+ **Global Installation:**
8
10
 
9
- **Global installation:**
10
11
  ```bash
11
12
  bun add -g @burger-api/cli
12
13
  ```
13
14
 
14
- **Or use with bunx (no installation needed):**
15
+ **Or use with bunx (No Installation Needed):**
16
+
15
17
  ```bash
16
18
  bunx @burger-api/cli create my-project
17
19
  ```
18
20
 
19
- ### Option 2: Standalone Executable
21
+ ### Option 2: Standalone Executable (Alternative Installation Method)
20
22
 
21
23
  **macOS, Linux, WSL:**
24
+
22
25
  ```bash
23
26
  curl -fsSL https://burger-api.com/install.sh | bash
24
27
  ```
25
28
 
26
29
  **Windows PowerShell:**
30
+
27
31
  ```powershell
28
32
  irm https://burger-api.com/install.ps1 | iex
29
33
  ```
30
34
 
31
- ### Option 3: Manual Download
35
+ ### Option 3: Manual Download (Alternative Installation Method)
32
36
 
33
- 1. Download the executable for your platform from [GitHub Releases](https://github.com/isfhan/burger-api/releases/latest)
37
+ 1. Download the executable for your platform from
38
+ [GitHub Releases](https://github.com/isfhan/burger-api/releases/latest)
34
39
  2. Add to PATH
35
40
  3. Make executable (Linux/macOS): `chmod +x burger-api`
36
41
 
37
- ### Verify Installation
42
+ ### Verify Installation (To Check if the CLI is Installed Correctly)
38
43
 
39
44
  ```bash
40
45
  burger-api --version
41
46
  ```
42
47
 
43
- ## Quick Start
44
-
45
- Create a new project in 30 seconds:
46
-
47
- ```bash
48
- # Create a new project
49
- burger-api create my-awesome-api
50
-
51
- # Navigate to your project
52
- cd my-awesome-api
53
-
54
- # Start development server
55
- bun run dev
56
-
57
- # Open http://localhost:4000 in your browser
58
- ```
59
-
60
- That's it! Your Burger API server is running! 🎉
61
-
62
- ---
63
-
64
- ## Commands
48
+ ## Available Commands (To Manage Your Project)
65
49
 
66
50
  ### `burger-api create <project-name>`
67
51
 
68
52
  Create a new Burger API project with interactive prompts.
69
53
 
70
- **Example:**
71
-
72
- ```bash
73
- burger-api create my-api
74
- ```
75
-
76
- The CLI will ask you:
54
+ **Questions You Will Be Asked:**
77
55
 
78
56
  - Do you need API routes? (yes/no)
79
57
  - API directory name (default: api)
@@ -91,9 +69,24 @@ installed!
91
69
  - ✅ Full project structure
92
70
  - ✅ TypeScript configured
93
71
  - ✅ Dependencies installed
72
+ - ✅ `burger.config.ts` generated from your answers
94
73
  - ✅ Example routes
95
74
  - ✅ Ready to run!
96
75
 
76
+ Generated config example:
77
+
78
+ ```ts
79
+ export default {
80
+ apiDir: './src/api',
81
+ pageDir: './src/pages',
82
+ apiPrefix: '/api',
83
+ pagePrefix: '/',
84
+ debug: false,
85
+ };
86
+ ```
87
+
88
+ Edit `burger.config.ts` anytime to change routes, prefixes, or debug mode.
89
+
97
90
  ---
98
91
 
99
92
  ### `burger-api list`
@@ -173,7 +166,8 @@ const app = new Burger({
173
166
 
174
167
  ### `burger-api build <file>`
175
168
 
176
- Bundle your project into a single JavaScript file.
169
+ Bundle your project with build-time (AOT) route discovery.
170
+ The CLI scans routes first, generates a virtual entry file, then runs Bun build.
177
171
 
178
172
  **Example:**
179
173
 
@@ -193,22 +187,29 @@ burger-api build index.ts --sourcemap linked
193
187
 
194
188
  **Options:**
195
189
 
196
- - `--outfile <path>` - Output file path (default: `.build/bundle.js`)
190
+ - `--outfile <path>` - Output file path (default: `.build/bundle/app.js`)
197
191
  - `--minify` - Minify the output for smaller file size
198
192
  - `--sourcemap <type>` - Generate sourcemaps (inline, linked, or none)
199
193
  - `--target <target>` - Target environment (e.g., bun, node)
200
194
 
195
+ Build config is loaded from `burger.config.ts` or `burger.config.js` when
196
+ present. If no config exists, the CLI uses defaults:
197
+ `apiDir=./src/api`, `pageDir=./src/pages`, `apiPrefix=/api`, `pagePrefix=/`.
198
+
201
199
  **Output:**
202
200
 
203
201
  ```
204
202
  ✓ Build completed successfully!
205
- Output: .build/bundle.js
203
+ Output: .build/bundle/app.js
206
204
  Size: 42.5 KB
207
205
  ```
208
206
 
207
+ - API-only apps: `app.js` is usually enough to deploy.
208
+ - Apps with pages/assets: deploy the full `.build/bundle/` directory.
209
+
209
210
  ---
210
211
 
211
- ### `burger-api build:executable <file>`
212
+ ### `burger-api build:exec <file>`
212
213
 
213
214
  Compile your project to a standalone executable that runs without Bun installed!
214
215
 
@@ -216,19 +217,19 @@ Compile your project to a standalone executable that runs without Bun installed!
216
217
 
217
218
  ```bash
218
219
  # Build for current platform
219
- burger-api build:executable index.ts
220
+ burger-api build:exec index.ts
220
221
 
221
222
  # Build for Windows
222
- burger-api build:executable index.ts --target bun-windows-x64
223
+ burger-api build:exec index.ts --target bun-windows-x64
223
224
 
224
225
  # Build for Linux
225
- burger-api build:executable index.ts --target bun-linux-x64
226
+ burger-api build:exec index.ts --target bun-linux-x64
226
227
 
227
228
  # Build for Mac (ARM)
228
- burger-api build:executable index.ts --target bun-darwin-arm64
229
+ burger-api build:exec index.ts --target bun-darwin-arm64
229
230
 
230
231
  # Custom output name
231
- burger-api build:executable index.ts --outfile my-server.exe
232
+ burger-api build:exec index.ts --outfile my-server.exe
232
233
  ```
233
234
 
234
235
  **Options:**
@@ -250,11 +251,11 @@ burger-api build:executable index.ts --outfile my-server.exe
250
251
 
251
252
  ```
252
253
  ✓ Compilation completed successfully!
253
- Executable: .build/my-api.exe
254
+ Executable: .build/executable/<project>.exe
254
255
  Size: 45.2 MB
255
256
 
256
257
  Your standalone executable is ready to run!
257
- Run it: .build/my-api.exe
258
+ Run it: .build/executable/<project>.exe
258
259
  ```
259
260
 
260
261
  **Use case:** Perfect for deploying your API to production servers without
@@ -346,69 +347,24 @@ export async function POST(req: BurgerRequest) {
346
347
 
347
348
  That's it! The route is automatically available at `/api/users`
348
349
 
349
- ## Common Workflows
350
-
351
- ### Workflow 1: Create and Run a Project
352
-
353
- ```bash
354
- # 1. Create project
355
- burger-api create my-api
356
-
357
- # 2. Navigate to it
358
- cd my-api
359
-
360
- # 3. Start dev server
361
- bun run dev
362
-
363
- # 4. Make changes and see them instantly!
364
- ```
365
-
366
- ### Workflow 2: Add Middleware
367
-
368
- ```bash
369
- # 1. See what's available
370
- burger-api list
350
+ ### Adding Pages
371
351
 
372
- # 2. Add what you need
373
- burger-api add cors logger rate-limiter
352
+ Create a new file in the `pages/` folder:
374
353
 
375
- # 3. Use them in index.ts (CLI shows you how!)
354
+ ```html
355
+ <!-- pages/about.html -->
356
+ <html>
357
+ <body>
358
+ <h1>About Page</h1>
359
+ <p>This is the about page.</p>
360
+ </body>
361
+ </html>
376
362
  ```
377
363
 
378
- ### Workflow 3: Build for Production
379
-
380
- ```bash
381
- # 1. Test your app works
382
- burger-api serve
383
-
384
- # 2. Build an executable
385
- burger-api build:executable index.ts --target bun-linux-x64
386
-
387
- # 3. Deploy to your server
388
- scp .build/my-api user@server:/opt/
389
- ssh user@server
390
- chmod +x /opt/my-api
391
- /opt/my-api
392
- ```
364
+ That's it! The page is automatically available at `/about`
393
365
 
394
366
  ## Troubleshooting
395
367
 
396
- ### "burger-api: command not found"
397
-
398
- **Solution:** Install the CLI using the install script:
399
-
400
- **macOS/Linux:**
401
- ```bash
402
- curl -fsSL https://burger-api.com/install.sh | bash
403
- ```
404
-
405
- **Windows:**
406
- ```powershell
407
- irm https://burger-api.com/install.ps1 | iex
408
- ```
409
-
410
- Or manually download from [GitHub Releases](https://github.com/isfhan/burger-api/releases/latest) and add to PATH.
411
-
412
368
  ### "Directory already exists"
413
369
 
414
370
  **Solution:** Choose a different project name or remove the existing directory:
@@ -438,9 +394,13 @@ burger-api serve
438
394
  1. You're in a Burger API project directory
439
395
  2. The entry file exists
440
396
  3. There are no TypeScript errors in your code
397
+ 4. Route folder rules are valid (no mixed dynamic + wildcard siblings)
441
398
 
442
399
  Run `bun run dev` first to see any errors.
443
400
 
401
+ If you use custom folders or prefixes, verify your `burger.config.ts` /
402
+ `burger.config.js` values.
403
+
444
404
  ### Cross-compilation fails from Windows (D:\ drive)
445
405
 
446
406
  **Error:**
@@ -567,17 +527,23 @@ you encounter crashes, rebuild without `--bytecode`. The build scripts use
567
527
 
568
528
  ### Testing
569
529
 
570
- Test commands locally:
530
+ Run tests (from `packages/cli`):
571
531
 
572
532
  ```bash
573
- # Create a test project
574
- bun run src/index.ts create test-app
533
+ # Run all CLI tests
534
+ bun run test
575
535
 
576
- # Test other commands
577
- cd test-app
578
- bun run ../src/index.ts list
579
- bun run ../src/index.ts add cors
580
- bun run ../src/index.ts serve
536
+ # Run build tests only (check production matches dev)
537
+ bun run test:build
538
+
539
+ # Run one test file
540
+ bun test test/build-output.test.ts
541
+ ```
542
+
543
+ From the **repo root**, run all CLI tests with:
544
+
545
+ ```bash
546
+ bun run test:cli
581
547
  ```
582
548
 
583
549
  ### Contributing
@@ -594,6 +560,11 @@ bun run ../src/index.ts serve
594
560
  - Add comments explaining your code
595
561
  - Test all commands before submitting
596
562
  - Update README if adding new features
563
+ - Keep route rules in one place:
564
+ - runtime/shared rules: `packages/burger-api/src/utils/pathConversion.ts`
565
+ - scanner traversal: `packages/cli/src/utils/scanner.ts`
566
+ - Run build tests when changing routing/build (keeps dev and production behavior the same):
567
+ - `bun run test:build`
597
568
 
598
569
  ### Design Principles
599
570
 
@@ -602,30 +573,6 @@ bun run ../src/index.ts serve
602
573
  - **Simple language** - No jargon, clear explanations
603
574
  - **Well commented** - Explain why, not just what
604
575
 
605
- ---
606
-
607
- ## Release Process
608
-
609
- For maintainers releasing new versions:
610
-
611
- 1. **Update versions** in `package.json` and `src/index.ts`
612
- 2. **Update CHANGELOG.md** with all changes
613
- 3. **Create and push a version tag:**
614
- ```bash
615
- git tag v1.0.0
616
- git push origin v1.0.0
617
- ```
618
- 4. **GitHub Actions automatically:**
619
- - Builds executables for all platforms (Linux, Windows, macOS ARM64, macOS Intel)
620
- - Creates a GitHub Release with all executables attached
621
- - Generates SHA256 checksums for verification
622
-
623
- The release workflow is triggered automatically when you push a tag matching `v*` pattern.
624
-
625
- See [CHANGELOG.md](./CHANGELOG.md) for version history.
626
-
627
- ---
628
-
629
576
  ## Technical Details
630
577
 
631
578
  **Built with:**
@@ -653,4 +600,4 @@ See [CHANGELOG.md](./CHANGELOG.md) for version history.
653
600
 
654
601
  MIT License - See [LICENSE](../../LICENSE) for details.
655
602
 
656
- **Built with ❤️ for the Burger API community**
603
+ **Built with ❤️ for the BurgerAPI community**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burger-api/cli",
3
- "version": "0.7.0",
3
+ "version": "0.9.1",
4
4
  "description": "Simple command-line tool for Burger API projects",
5
5
  "module": "src/index.ts",
6
6
  "type": "module",
@@ -18,6 +18,8 @@
18
18
  },
19
19
  "scripts": {
20
20
  "dev": "bun run src/index.ts",
21
+ "test": "bun test --timeout 30000 ./test",
22
+ "test:build": "bun test test/scanner.test.ts test/virtual-entry.test.ts test/entry-options.test.ts test/build-preserve-options.test.ts",
21
23
  "build:win": "bun build ./src/index.ts --compile --target bun-windows-x64 --outfile dist/burger-api.exe --minify",
22
24
  "build:linux": "bun build ./src/index.ts --compile --target bun-linux-x64 --outfile dist/burger-api-linux --minify",
23
25
  "build:mac": "bun build ./src/index.ts --compile --target bun-darwin-arm64 --outfile dist/burger-api-mac --minify",
@@ -29,8 +31,7 @@
29
31
  "@clack/prompts": "^0.7.0"
30
32
  },
31
33
  "devDependencies": {
32
- "@types/bun": "latest",
33
- "@types/commander": "^2.12.5"
34
+ "@types/bun": "latest"
34
35
  },
35
36
  "peerDependencies": {
36
37
  "typescript": "^5"
@@ -47,5 +48,8 @@
47
48
  "type": "git",
48
49
  "url": "git+https://github.com/isfhan/burger-api.git",
49
50
  "directory": "packages/cli"
51
+ },
52
+ "publishConfig": {
53
+ "access": "public"
50
54
  }
51
- }
55
+ }