@burger-api/cli 0.6.6
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 +57 -0
- package/README.md +656 -0
- package/package.json +51 -0
- package/src/commands/add.ts +201 -0
- package/src/commands/build.ts +250 -0
- package/src/commands/create.ts +229 -0
- package/src/commands/list.ts +88 -0
- package/src/commands/serve.ts +100 -0
- package/src/index.ts +59 -0
- package/src/types/index.ts +53 -0
- package/src/utils/github.ts +260 -0
- package/src/utils/logger.ts +478 -0
- package/src/utils/templates.ts +1120 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
## 📣 Release Notes - Burger API CLI
|
|
2
|
+
|
|
3
|
+
All notable changes to the Burger API CLI will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## Version 0.6.6 - (December 23, 2025)
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- `.llm-context` folder to the project with AI context files
|
|
9
|
+
- `llms.txt`, `llms-small.txt`, and `llms-full.txt` files
|
|
10
|
+
- Updated README.md
|
|
11
|
+
|
|
12
|
+
## Version 0.6.3 - (December 17, 2025)
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
- GitHub Actions release workflow
|
|
16
|
+
- Updated README.md
|
|
17
|
+
|
|
18
|
+
## Version 0.1.0 - (December 14, 2025)
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
- Initial release of Burger API CLI
|
|
22
|
+
- `create` command to generate new projects with interactive prompts
|
|
23
|
+
- `list` command to show available middleware from ecosystem
|
|
24
|
+
- `add` command to download and install middleware
|
|
25
|
+
- `build` command to bundle projects to single JS file
|
|
26
|
+
- `build:executable` command to compile to standalone executable
|
|
27
|
+
- `serve` command for development server with hot reload
|
|
28
|
+
- Beautiful console output with colors and symbols
|
|
29
|
+
- Zero external dependencies for file operations (uses Bun's native APIs)
|
|
30
|
+
- Comprehensive documentation and examples
|
|
31
|
+
- Support for Windows, macOS, and Linux
|
|
32
|
+
|
|
33
|
+
### Technical Details
|
|
34
|
+
- Built with TypeScript and Bun.js
|
|
35
|
+
- Uses only 2 dependencies: `commander` and `@clack/prompts`
|
|
36
|
+
- All file downloads use Bun's native `fetch()` API
|
|
37
|
+
- All file operations use Bun's fast file system APIs
|
|
38
|
+
- All process spawning uses `Bun.spawn()`
|
|
39
|
+
- Comprehensive JSDoc comments throughout codebase
|
|
40
|
+
|
|
41
|
+
## Release Process
|
|
42
|
+
|
|
43
|
+
See [RELEASING.md](./RELEASING.md) for the release process.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Change Categories
|
|
48
|
+
|
|
49
|
+
We use these categories to organize changes:
|
|
50
|
+
|
|
51
|
+
- **Added** - New features or commands
|
|
52
|
+
- **Changed** - Changes to existing functionality
|
|
53
|
+
- **Deprecated** - Features that will be removed in future
|
|
54
|
+
- **Removed** - Features that have been removed
|
|
55
|
+
- **Fixed** - Bug fixes
|
|
56
|
+
- **Security** - Security improvements
|
|
57
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,656 @@
|
|
|
1
|
+
# Burger API CLI
|
|
2
|
+
|
|
3
|
+
Simple command-line tool for creating and managing Burger API projects.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
### Option 1: npm/bun (Recommended if you have Bun installed)
|
|
8
|
+
|
|
9
|
+
**Global installation:**
|
|
10
|
+
```bash
|
|
11
|
+
bun add -g @burger-api/cli
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
**Or use with bunx (no installation needed):**
|
|
15
|
+
```bash
|
|
16
|
+
bunx @burger-api/cli create my-project
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Option 2: Standalone Executable
|
|
20
|
+
|
|
21
|
+
**macOS, Linux, WSL:**
|
|
22
|
+
```bash
|
|
23
|
+
curl -fsSL https://burger-api.com/install.sh | bash
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Windows PowerShell:**
|
|
27
|
+
```powershell
|
|
28
|
+
irm https://burger-api.com/install.ps1 | iex
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Option 3: Manual Download
|
|
32
|
+
|
|
33
|
+
1. Download the executable for your platform from [GitHub Releases](https://github.com/isfhan/burger-api/releases/latest)
|
|
34
|
+
2. Add to PATH
|
|
35
|
+
3. Make executable (Linux/macOS): `chmod +x burger-api`
|
|
36
|
+
|
|
37
|
+
### Verify Installation
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
burger-api --version
|
|
41
|
+
```
|
|
42
|
+
|
|
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
|
|
65
|
+
|
|
66
|
+
### `burger-api create <project-name>`
|
|
67
|
+
|
|
68
|
+
Create a new Burger API project with interactive prompts.
|
|
69
|
+
|
|
70
|
+
**Example:**
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
burger-api create my-api
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The CLI will ask you:
|
|
77
|
+
|
|
78
|
+
- Do you need API routes? (yes/no)
|
|
79
|
+
- API directory name (default: api)
|
|
80
|
+
- API route prefix (default: /api)
|
|
81
|
+
- Enable debug mode? (yes/no)
|
|
82
|
+
- Do you need Page routes? (yes/no)
|
|
83
|
+
- Page directory name (default: pages)
|
|
84
|
+
- Page route prefix (default: /)
|
|
85
|
+
|
|
86
|
+
After answering, your project will be created with all files and dependencies
|
|
87
|
+
installed!
|
|
88
|
+
|
|
89
|
+
**What you get:**
|
|
90
|
+
|
|
91
|
+
- ✅ Full project structure
|
|
92
|
+
- ✅ TypeScript configured
|
|
93
|
+
- ✅ Dependencies installed
|
|
94
|
+
- ✅ Example routes
|
|
95
|
+
- ✅ Ready to run!
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
### `burger-api list`
|
|
100
|
+
|
|
101
|
+
Show all available middleware you can add to your project.
|
|
102
|
+
|
|
103
|
+
**Example:**
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
burger-api list
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**Alias:**
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
burger-api ls
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**Output:**
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
Available Middleware
|
|
119
|
+
────────────────────────────────
|
|
120
|
+
|
|
121
|
+
Name Description
|
|
122
|
+
─────────────────────────────────────────────────
|
|
123
|
+
cors Cross-Origin Resource Sharing
|
|
124
|
+
logger Request/response logging
|
|
125
|
+
rate-limiter Request rate limiting
|
|
126
|
+
jwt-auth JWT authentication
|
|
127
|
+
api-key-auth API key authentication
|
|
128
|
+
compression Response compression
|
|
129
|
+
...
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
### `burger-api add <middleware...>`
|
|
135
|
+
|
|
136
|
+
Add one or more middleware to your project.
|
|
137
|
+
|
|
138
|
+
**Examples:**
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
# Add a single middleware
|
|
142
|
+
burger-api add cors
|
|
143
|
+
|
|
144
|
+
# Add multiple middleware at once
|
|
145
|
+
burger-api add cors logger rate-limiter
|
|
146
|
+
|
|
147
|
+
# Add authentication
|
|
148
|
+
burger-api add jwt-auth api-key-auth
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
**What it does:**
|
|
152
|
+
|
|
153
|
+
1. Downloads middleware code from GitHub
|
|
154
|
+
2. Copies files to your `middleware/` folder
|
|
155
|
+
3. Shows you example code to use it
|
|
156
|
+
4. You can modify the code to fit your needs!
|
|
157
|
+
|
|
158
|
+
**After adding:** The CLI shows you exactly how to use the middleware in your
|
|
159
|
+
project:
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
import { Burger } from 'burger-api';
|
|
163
|
+
import { cors } from './middleware/cors/cors';
|
|
164
|
+
import { logger } from './middleware/logger/logger';
|
|
165
|
+
|
|
166
|
+
const app = new Burger({
|
|
167
|
+
apiDir: './api',
|
|
168
|
+
globalMiddleware: [logger(), cors()],
|
|
169
|
+
});
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
### `burger-api build <file>`
|
|
175
|
+
|
|
176
|
+
Bundle your project into a single JavaScript file.
|
|
177
|
+
|
|
178
|
+
**Example:**
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
# Basic build
|
|
182
|
+
burger-api build index.ts
|
|
183
|
+
|
|
184
|
+
# Build with minification
|
|
185
|
+
burger-api build index.ts --minify
|
|
186
|
+
|
|
187
|
+
# Custom output location
|
|
188
|
+
burger-api build index.ts --outfile dist/app.js
|
|
189
|
+
|
|
190
|
+
# With sourcemaps
|
|
191
|
+
burger-api build index.ts --sourcemap linked
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**Options:**
|
|
195
|
+
|
|
196
|
+
- `--outfile <path>` - Output file path (default: `.build/bundle.js`)
|
|
197
|
+
- `--minify` - Minify the output for smaller file size
|
|
198
|
+
- `--sourcemap <type>` - Generate sourcemaps (inline, linked, or none)
|
|
199
|
+
- `--target <target>` - Target environment (e.g., bun, node)
|
|
200
|
+
|
|
201
|
+
**Output:**
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
✓ Build completed successfully!
|
|
205
|
+
Output: .build/bundle.js
|
|
206
|
+
Size: 42.5 KB
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
### `burger-api build:executable <file>`
|
|
212
|
+
|
|
213
|
+
Compile your project to a standalone executable that runs without Bun installed!
|
|
214
|
+
|
|
215
|
+
**Example:**
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
# Build for current platform
|
|
219
|
+
burger-api build:executable index.ts
|
|
220
|
+
|
|
221
|
+
# Build for Windows
|
|
222
|
+
burger-api build:executable index.ts --target bun-windows-x64
|
|
223
|
+
|
|
224
|
+
# Build for Linux
|
|
225
|
+
burger-api build:executable index.ts --target bun-linux-x64
|
|
226
|
+
|
|
227
|
+
# Build for Mac (ARM)
|
|
228
|
+
burger-api build:executable index.ts --target bun-darwin-arm64
|
|
229
|
+
|
|
230
|
+
# Custom output name
|
|
231
|
+
burger-api build:executable index.ts --outfile my-server.exe
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
**Options:**
|
|
235
|
+
|
|
236
|
+
- `--outfile <path>` - Output file path
|
|
237
|
+
- `--target <target>` - Target platform
|
|
238
|
+
- `--minify` - Minify the output (enabled by default)
|
|
239
|
+
- `--no-bytecode` - Disable bytecode compilation
|
|
240
|
+
|
|
241
|
+
**Targets:**
|
|
242
|
+
|
|
243
|
+
- `bun-windows-x64` - Windows (64-bit)
|
|
244
|
+
- `bun-linux-x64` - Linux (64-bit)
|
|
245
|
+
- `bun-linux-arm64` - Linux (ARM 64-bit)
|
|
246
|
+
- `bun-darwin-x64` - macOS (Intel)
|
|
247
|
+
- `bun-darwin-arm64` - macOS (Apple Silicon)
|
|
248
|
+
|
|
249
|
+
**Output:**
|
|
250
|
+
|
|
251
|
+
```
|
|
252
|
+
✓ Compilation completed successfully!
|
|
253
|
+
Executable: .build/my-api.exe
|
|
254
|
+
Size: 45.2 MB
|
|
255
|
+
|
|
256
|
+
Your standalone executable is ready to run!
|
|
257
|
+
Run it: .build/my-api.exe
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
**Use case:** Perfect for deploying your API to production servers without
|
|
261
|
+
installing Bun or Node.js!
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
### `burger-api serve`
|
|
266
|
+
|
|
267
|
+
Start a development server with hot reload (auto-restart on file changes).
|
|
268
|
+
|
|
269
|
+
**Example:**
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
# Default (port 4000, index.ts)
|
|
273
|
+
burger-api serve
|
|
274
|
+
|
|
275
|
+
# Custom port
|
|
276
|
+
burger-api serve --port 4000
|
|
277
|
+
|
|
278
|
+
# Custom entry file
|
|
279
|
+
burger-api serve --file server.ts
|
|
280
|
+
|
|
281
|
+
# Both
|
|
282
|
+
burger-api serve --port 8080 --file app.ts
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
**Options:**
|
|
286
|
+
|
|
287
|
+
- `-p, --port <port>` - Port to run on (default: 4000)
|
|
288
|
+
- `-f, --file <file>` - Entry file (default: index.ts)
|
|
289
|
+
|
|
290
|
+
**What you'll see:**
|
|
291
|
+
|
|
292
|
+
```
|
|
293
|
+
→ Starting development server...
|
|
294
|
+
|
|
295
|
+
✓ Server running on http://localhost:4000
|
|
296
|
+
ℹ Press Ctrl+C to stop
|
|
297
|
+
File changes will automatically restart the server
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
**Pro tip:** Edit your code and save - the server restarts automatically! No
|
|
301
|
+
need to manually restart.
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## Project Structure
|
|
306
|
+
|
|
307
|
+
When you create a project, this is what you get:
|
|
308
|
+
|
|
309
|
+
```
|
|
310
|
+
my-awesome-api/
|
|
311
|
+
├── api/ # Your API routes
|
|
312
|
+
│ └── route.ts # Example route
|
|
313
|
+
├── pages/ # Your HTML pages (optional)
|
|
314
|
+
│ └── index.html # Example page
|
|
315
|
+
├── middleware/ # Middleware folder
|
|
316
|
+
│ └── index.ts # Export middleware here
|
|
317
|
+
├── index.ts # Main server file
|
|
318
|
+
├── package.json # Dependencies
|
|
319
|
+
├── tsconfig.json # TypeScript config
|
|
320
|
+
├── .gitignore # Git ignore rules
|
|
321
|
+
└── .prettierrc # Code formatting
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### Adding Routes
|
|
325
|
+
|
|
326
|
+
Create a new file in the `api/` folder:
|
|
327
|
+
|
|
328
|
+
```typescript
|
|
329
|
+
// api/users/route.ts
|
|
330
|
+
import type { BurgerRequest } from 'burger-api';
|
|
331
|
+
|
|
332
|
+
export async function GET(req: BurgerRequest) {
|
|
333
|
+
return Response.json({
|
|
334
|
+
users: ['Alice', 'Bob', 'Charlie'],
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export async function POST(req: BurgerRequest) {
|
|
339
|
+
const body = await req.json();
|
|
340
|
+
return Response.json({
|
|
341
|
+
message: 'User created',
|
|
342
|
+
data: body,
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
That's it! The route is automatically available at `/api/users`
|
|
348
|
+
|
|
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
|
|
371
|
+
|
|
372
|
+
# 2. Add what you need
|
|
373
|
+
burger-api add cors logger rate-limiter
|
|
374
|
+
|
|
375
|
+
# 3. Use them in index.ts (CLI shows you how!)
|
|
376
|
+
```
|
|
377
|
+
|
|
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
|
+
```
|
|
393
|
+
|
|
394
|
+
## Troubleshooting
|
|
395
|
+
|
|
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
|
+
### "Directory already exists"
|
|
413
|
+
|
|
414
|
+
**Solution:** Choose a different project name or remove the existing directory:
|
|
415
|
+
|
|
416
|
+
```bash
|
|
417
|
+
burger-api create my-api-v2
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
### "Could not get middleware list from GitHub"
|
|
421
|
+
|
|
422
|
+
**Solution:** Check your internet connection. The CLI needs internet to download
|
|
423
|
+
middleware from GitHub.
|
|
424
|
+
|
|
425
|
+
### "Entry file not found: index.ts"
|
|
426
|
+
|
|
427
|
+
**Solution:** Make sure you're in the project directory:
|
|
428
|
+
|
|
429
|
+
```bash
|
|
430
|
+
cd my-project
|
|
431
|
+
burger-api serve
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
### Build fails with errors
|
|
435
|
+
|
|
436
|
+
**Solution:** Check that:
|
|
437
|
+
|
|
438
|
+
1. You're in a Burger API project directory
|
|
439
|
+
2. The entry file exists
|
|
440
|
+
3. There are no TypeScript errors in your code
|
|
441
|
+
|
|
442
|
+
Run `bun run dev` first to see any errors.
|
|
443
|
+
|
|
444
|
+
### Cross-compilation fails from Windows (D:\ drive)
|
|
445
|
+
|
|
446
|
+
**Error:**
|
|
447
|
+
|
|
448
|
+
```
|
|
449
|
+
Failed to extract executable for 'bun-linux-x64-v1.3.4'. The download may be incomplete.
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
**Cause:** Bun's cross-compilation has a bug when working from non-system drives
|
|
453
|
+
on Windows (D:\, E:\, etc.).
|
|
454
|
+
|
|
455
|
+
**Solution:** Move your project to `C:\` drive. Cross-compilation works
|
|
456
|
+
correctly from the system drive.
|
|
457
|
+
|
|
458
|
+
**Example:**
|
|
459
|
+
|
|
460
|
+
```bash
|
|
461
|
+
# ❌ This fails if project is on D:\
|
|
462
|
+
cd D:\Coding\burger-api\packages\cli
|
|
463
|
+
bun run build:linux
|
|
464
|
+
|
|
465
|
+
# ✅ This works from C:\
|
|
466
|
+
cd C:\burger-api\packages\cli
|
|
467
|
+
bun run build:linux
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
## Getting Help
|
|
471
|
+
|
|
472
|
+
Get help for any command:
|
|
473
|
+
|
|
474
|
+
```bash
|
|
475
|
+
burger-api --help # General help
|
|
476
|
+
burger-api create --help # Command-specific help
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
**Resources:**
|
|
480
|
+
|
|
481
|
+
- Main website: https://burger-api.com
|
|
482
|
+
- GitHub: https://github.com/isfhan/burger-api
|
|
483
|
+
- Issues: https://github.com/isfhan/burger-api/issues
|
|
484
|
+
|
|
485
|
+
---
|
|
486
|
+
|
|
487
|
+
## Development
|
|
488
|
+
|
|
489
|
+
Want to contribute or develop locally?
|
|
490
|
+
|
|
491
|
+
### Setup
|
|
492
|
+
|
|
493
|
+
```bash
|
|
494
|
+
# Clone the repo
|
|
495
|
+
git clone https://github.com/isfhan/burger-api.git
|
|
496
|
+
cd burger-api/packages/cli
|
|
497
|
+
|
|
498
|
+
# Install dependencies
|
|
499
|
+
bun install
|
|
500
|
+
|
|
501
|
+
# Run locally
|
|
502
|
+
bun run src/index.ts --help
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
### Project Structure
|
|
506
|
+
|
|
507
|
+
```
|
|
508
|
+
packages/cli/
|
|
509
|
+
├── src/
|
|
510
|
+
│ ├── index.ts # Main entry point
|
|
511
|
+
│ ├── commands/ # All CLI commands
|
|
512
|
+
│ ├── utils/ # Shared utilities
|
|
513
|
+
│ └── types/ # TypeScript types
|
|
514
|
+
├── package.json # Dependencies and scripts
|
|
515
|
+
└── README.md # This file
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
### Build Executables
|
|
519
|
+
|
|
520
|
+
Build standalone executables for all platforms:
|
|
521
|
+
|
|
522
|
+
```bash
|
|
523
|
+
bun run build:win # Windows (x64)
|
|
524
|
+
bun run build:linux # Linux (x64)
|
|
525
|
+
bun run build:mac # macOS (ARM64/Apple Silicon)
|
|
526
|
+
bun run build:mac-intel # macOS (Intel x64)
|
|
527
|
+
bun run build:all # All platforms
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
**Cross-Compilation from Windows:**
|
|
531
|
+
|
|
532
|
+
Bun supports cross-compilation - you can build Linux and macOS executables from
|
|
533
|
+
Windows using the `--target` flag:
|
|
534
|
+
|
|
535
|
+
```bash
|
|
536
|
+
# Build for Linux from Windows
|
|
537
|
+
bun build ./src/index.ts --compile --target bun-linux-x64 --outfile dist/burger-api-linux --minify
|
|
538
|
+
|
|
539
|
+
# Build for macOS ARM64 from Windows
|
|
540
|
+
bun build ./src/index.ts --compile --target bun-darwin-arm64 --outfile dist/burger-api-mac --minify
|
|
541
|
+
|
|
542
|
+
# Build for macOS Intel from Windows
|
|
543
|
+
bun build ./src/index.ts --compile --target bun-darwin-x64 --outfile dist/burger-api-mac-intel --minify
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
**Important: Windows D:\ Drive Bug**
|
|
547
|
+
|
|
548
|
+
If you see this error when cross-compiling from Windows:
|
|
549
|
+
|
|
550
|
+
```
|
|
551
|
+
Error: Failed to extract executable for 'bun-linux-x64-v1.3.4'. The download may be incomplete.
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
**Cause:** Cross-compilation fails when working from non-system drives (like
|
|
555
|
+
`D:\`) on Windows due to cross-volume file move operations failing when Bun
|
|
556
|
+
tries to cache the downloaded base executable.
|
|
557
|
+
|
|
558
|
+
**Solution:** Move your project to the `C:\` drive and run the build from there.
|
|
559
|
+
Cross-compilation works correctly from the system drive.
|
|
560
|
+
|
|
561
|
+
**Caution: `--bytecode` Flag with Cross-Compilation**
|
|
562
|
+
|
|
563
|
+
The `--bytecode` flag improves startup time, but there are known issues where
|
|
564
|
+
cross-compiled executables with `--bytecode` may segfault on the target OS. If
|
|
565
|
+
you encounter crashes, rebuild without `--bytecode`. The build scripts use
|
|
566
|
+
`--minify` only for safety with cross-compilation.
|
|
567
|
+
|
|
568
|
+
### Testing
|
|
569
|
+
|
|
570
|
+
Test commands locally:
|
|
571
|
+
|
|
572
|
+
```bash
|
|
573
|
+
# Create a test project
|
|
574
|
+
bun run src/index.ts create test-app
|
|
575
|
+
|
|
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
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
### Contributing
|
|
584
|
+
|
|
585
|
+
1. Fork the repo
|
|
586
|
+
2. Create a feature branch
|
|
587
|
+
3. Make your changes
|
|
588
|
+
4. Test everything manually
|
|
589
|
+
5. Submit a Pull Request
|
|
590
|
+
|
|
591
|
+
**Guidelines:**
|
|
592
|
+
|
|
593
|
+
- Use simple, beginner-friendly language
|
|
594
|
+
- Add comments explaining your code
|
|
595
|
+
- Test all commands before submitting
|
|
596
|
+
- Update README if adding new features
|
|
597
|
+
|
|
598
|
+
### Design Principles
|
|
599
|
+
|
|
600
|
+
- **Minimal dependencies** - Only use `commander` and `@clack/prompts`
|
|
601
|
+
- **Beautiful output** - Use colors and symbols for clarity
|
|
602
|
+
- **Simple language** - No jargon, clear explanations
|
|
603
|
+
- **Well commented** - Explain why, not just what
|
|
604
|
+
|
|
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
|
+
## Technical Details
|
|
630
|
+
|
|
631
|
+
**Built with:**
|
|
632
|
+
|
|
633
|
+
- TypeScript for type safety
|
|
634
|
+
- Bun.js for speed and native APIs
|
|
635
|
+
- Commander for CLI framework
|
|
636
|
+
- @clack/prompts for beautiful prompts
|
|
637
|
+
|
|
638
|
+
**Zero external dependencies for:**
|
|
639
|
+
|
|
640
|
+
- File operations (uses `Bun.write()`)
|
|
641
|
+
- Downloads (uses native `fetch()`)
|
|
642
|
+
- Process spawning (uses `Bun.spawn()`)
|
|
643
|
+
|
|
644
|
+
**Supported platforms:**
|
|
645
|
+
|
|
646
|
+
- Windows (x64)
|
|
647
|
+
- Linux (x64, ARM64)
|
|
648
|
+
- macOS (Intel, Apple Silicon)
|
|
649
|
+
|
|
650
|
+
---
|
|
651
|
+
|
|
652
|
+
## License
|
|
653
|
+
|
|
654
|
+
MIT License - See [LICENSE](../../LICENSE) for details.
|
|
655
|
+
|
|
656
|
+
**Built with ❤️ for the Burger API community**
|