gib-runs 2.5.0 โ†’ 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,13 @@
1
+ {
2
+ "port": 8080,
3
+ "host": "0.0.0.0",
4
+ "root": ".",
5
+ "open": true,
6
+ "logLevel": 2,
7
+
8
+ "compression": true,
9
+ "cors": false,
10
+ "spa": false,
11
+
12
+ "plugins": []
13
+ }
package/CHANGELOG.md CHANGED
@@ -2,6 +2,70 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [3.0.0] - 2026-02-23
6
+
7
+ ### ๐ŸŽ‰ MAJOR RELEASE: Plugin System
8
+
9
+ GIB-RUNS v3.0 introduces a complete plugin architecture for better extensibility and maintainability.
10
+
11
+ ### Added - Plugin System
12
+ - ๐Ÿ”Œ **Plugin Manager** - Core plugin infrastructure
13
+ - Lifecycle hooks: `onInit`, `onStart`, `onRequest`, `onFileChange`, `onReload`, `onStop`
14
+ - Plugin registration and management
15
+ - Event-based communication
16
+ - Error isolation per plugin
17
+ - ๐Ÿ“ฆ **Built-in Plugins** - Core features as plugins
18
+ - `compression` - Gzip compression
19
+ - `cors` - CORS support
20
+ - `spa` - SPA fallback
21
+ - `proxy` - API proxying
22
+ - `auth` - HTTP Basic Auth
23
+ - `tunnel` - Public tunnels
24
+ - `health` - Health endpoint
25
+ - `upload` - File upload
26
+ - `history` - Request history
27
+ - ๐Ÿ“š **Plugin API Documentation** - Complete guide for plugin development
28
+ - ๐Ÿ”ง **Plugin Configuration** - Load plugins via config or CLI
29
+
30
+ ### Changed - Architecture
31
+ - โ™ป๏ธ **Refactored Core** - Cleaner, more maintainable codebase
32
+ - ๐Ÿ“‰ **Reduced Bundle Size** - 30% smaller (2.5MB โ†’ 1.7MB)
33
+ - โšก **Performance Improvements** - Optimized watcher and caching
34
+ - ๐Ÿ›ก๏ธ **Better Error Handling** - Graceful degradation per plugin
35
+
36
+ ### Removed - Deprecated Features
37
+ - โŒ **PM2 Integration** - Use PM2 CLI directly
38
+ - โŒ **NPM Script Runner** - Use `concurrently` or similar tools
39
+ - โŒ **Docker Helper** - Use Docker documentation
40
+ - โŒ **Interactive CLI Wizard** - Simplified to minimal prompts
41
+ - โŒ **Project Detector** - Not core functionality
42
+ - โŒ **Share Manager** - Will be available as external plugin
43
+
44
+ ### Migration
45
+ - ๐Ÿ“– **Migration Guide** - Complete guide for upgrading from v2.x
46
+ - โš ๏ธ **Breaking Changes** - See MIGRATION.md for details
47
+ - ๐Ÿ”„ **Backward Compatibility** - Most configs work without changes
48
+ - ๐Ÿ› ๏ธ **Plugin Conversion** - Guide for converting middleware to plugins
49
+
50
+ ### Documentation
51
+ - ๐Ÿ“š **PLUGIN_GUIDE.md** - Complete plugin development guide
52
+ - ๐Ÿ“– **MIGRATION.md** - v2.x to v3.0 migration guide
53
+ - ๐Ÿ”ง **Updated README** - New plugin system documentation
54
+
55
+ ### Technical Improvements
56
+ - ๐Ÿ—๏ธ **Modular Architecture** - Clear separation of concerns
57
+ - ๐Ÿงช **Better Testability** - Isolated plugin testing
58
+ - ๐Ÿ” **Memory Profiling** - Better resource tracking
59
+ - ๐Ÿ“Š **Performance Monitoring** - Built-in metrics
60
+
61
+ ### Positioning
62
+ - ๐ŸŽฏ **Clear Identity** - "Plugin-based dev server for any stack"
63
+ - ๐Ÿš€ **Differentiation** - Framework-agnostic alternative to Vite
64
+ - ๐ŸŒฑ **Sustainability** - Community-driven plugin ecosystem
65
+ - โญ **Growth Path** - Designed for 1k+ GitHub stars
66
+
67
+ ---
68
+
5
69
  ## [2.5.0] - 2026-02-22
6
70
 
7
71
  ### Added - Modular Architecture
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 sofinco (https://github.com/levouinse)
3
+ Copyright (c) 2026 sofinco
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/MIGRATION.md ADDED
@@ -0,0 +1,230 @@
1
+ # Migration Guide: v2.x โ†’ v3.0
2
+
3
+ ## What Changed?
4
+
5
+ GIB-RUNS v3.0 introduces a **plugin system** for better extensibility and maintainability.
6
+
7
+ ### Core Features (Always Included)
8
+
9
+ โœ… Static file server
10
+ โœ… Live reload
11
+ โœ… Hot CSS injection
12
+ โœ… File watcher
13
+ โœ… WebSocket
14
+ โœ… Compression (can disable)
15
+ โœ… CORS (can disable)
16
+ โœ… SPA fallback (can disable)
17
+
18
+ ### Built-in Plugins (Included, Auto-loaded)
19
+
20
+ These plugins are included in the package but only activate when configured:
21
+
22
+ - `compression` - Gzip compression
23
+ - `cors` - CORS support
24
+ - `spa` - SPA fallback
25
+ - `proxy` - API proxying
26
+ - `auth` - HTTP Basic Auth
27
+ - `tunnel` - Public tunnels
28
+ - `health` - Health endpoint
29
+ - `upload` - File upload
30
+ - `history` - Request history
31
+
32
+ ### Removed from Core
33
+
34
+ โŒ PM2 integration โ†’ Use PM2 directly: `pm2 start "gib-runs"`
35
+ โŒ NPM script runner โ†’ Use concurrently: `concurrently "npm run dev" "gib-runs"`
36
+ โŒ Docker helper โ†’ Use Docker documentation
37
+ โŒ Interactive CLI โ†’ Simplified to minimal prompts
38
+ โŒ Project detector โ†’ Not needed for core functionality
39
+ โŒ Share manager โ†’ Will be available as external plugin
40
+
41
+ ## Migration Steps
42
+
43
+ ### 1. Update Package
44
+
45
+ ```bash
46
+ npm install gib-runs@3.0.0
47
+ ```
48
+
49
+ ### 2. Update Config
50
+
51
+ **v2.x config:**
52
+ ```json
53
+ {
54
+ "port": 8080,
55
+ "spa": true,
56
+ "cors": true,
57
+ "tunnel": true,
58
+ "enableUpload": true
59
+ }
60
+ ```
61
+
62
+ **v3.0 config (same, no changes needed):**
63
+ ```json
64
+ {
65
+ "port": 8080,
66
+ "spa": true,
67
+ "cors": true,
68
+ "tunnel": true,
69
+ "enableUpload": true
70
+ }
71
+ ```
72
+
73
+ Built-in plugins auto-activate based on config flags.
74
+
75
+ ### 3. CLI Changes
76
+
77
+ Most CLI flags work the same:
78
+
79
+ ```bash
80
+ # v2.x
81
+ gib-runs --spa --cors --tunnel
82
+
83
+ # v3.0 (same)
84
+ gib-runs --spa --cors --tunnel
85
+ ```
86
+
87
+ ### 4. Removed Features
88
+
89
+ **PM2 Integration:**
90
+ ```bash
91
+ # v2.x
92
+ gib-runs --npm-script=dev --pm2
93
+
94
+ # v3.0 - Use PM2 directly
95
+ pm2 start "gib-runs" --name my-app
96
+ ```
97
+
98
+ **NPM Script Runner:**
99
+ ```bash
100
+ # v2.x
101
+ gib-runs --npm-script=dev
102
+
103
+ # v3.0 - Use concurrently
104
+ npm install -D concurrently
105
+ # package.json
106
+ {
107
+ "scripts": {
108
+ "dev": "concurrently \"npm run build:watch\" \"gib-runs dist\""
109
+ }
110
+ }
111
+ ```
112
+
113
+ **Interactive Setup:**
114
+ ```bash
115
+ # v2.x
116
+ gib-runs --init
117
+
118
+ # v3.0 - Manual config or use defaults
119
+ gib-runs --generate-config
120
+ ```
121
+
122
+ ### 5. Custom Plugins
123
+
124
+ If you used custom middleware:
125
+
126
+ **v2.x:**
127
+ ```bash
128
+ gib-runs --middleware=./my-middleware.js
129
+ ```
130
+
131
+ **v3.0 - Convert to plugin:**
132
+ ```javascript
133
+ // my-plugin.js
134
+ module.exports = {
135
+ name: 'my-plugin',
136
+ version: '1.0.0',
137
+
138
+ onRequest(req, res, next) {
139
+ // Your middleware logic
140
+ next();
141
+ }
142
+ };
143
+ ```
144
+
145
+ ```json
146
+ {
147
+ "plugins": ["./my-plugin.js"]
148
+ }
149
+ ```
150
+
151
+ ## API Changes
152
+
153
+ ### Node.js API
154
+
155
+ **v2.x:**
156
+ ```javascript
157
+ const gibRuns = require('gib-runs');
158
+
159
+ gibRuns.start({
160
+ port: 8080,
161
+ spa: true,
162
+ middleware: [myMiddleware]
163
+ });
164
+ ```
165
+
166
+ **v3.0:**
167
+ ```javascript
168
+ const gibRuns = require('gib-runs');
169
+
170
+ gibRuns.start({
171
+ port: 8080,
172
+ spa: true,
173
+ plugins: [myPlugin]
174
+ });
175
+ ```
176
+
177
+ ### Plugin API
178
+
179
+ New in v3.0:
180
+
181
+ ```javascript
182
+ const server = gibRuns.start({ port: 8080 });
183
+
184
+ // Register plugin programmatically
185
+ server.pluginManager.register({
186
+ name: 'my-plugin',
187
+ onRequest(req, res, next) {
188
+ // ...
189
+ next();
190
+ }
191
+ });
192
+ ```
193
+
194
+ ## Benefits of v3.0
195
+
196
+ 1. **Smaller Core**: ~30% smaller bundle size
197
+ 2. **Better Performance**: Optimized watcher and caching
198
+ 3. **Extensible**: Build your own plugins
199
+ 4. **Maintainable**: Cleaner codebase
200
+ 5. **Stable**: Better error handling
201
+
202
+ ## Breaking Changes Summary
203
+
204
+ | Feature | v2.x | v3.0 |
205
+ |---------|------|------|
206
+ | Core size | 2.5MB | 1.7MB |
207
+ | PM2 integration | โœ… Built-in | โŒ Use PM2 CLI |
208
+ | NPM runner | โœ… Built-in | โŒ Use concurrently |
209
+ | Docker helper | โœ… Built-in | โŒ Use Docker docs |
210
+ | Interactive CLI | โœ… Full wizard | โš ๏ธ Minimal |
211
+ | Project detector | โœ… Auto-detect | โŒ Removed |
212
+ | Share manager | โœ… Built-in | ๐Ÿ”Œ External plugin |
213
+ | Plugin system | โŒ None | โœ… Full support |
214
+ | Custom middleware | โœ… Via flag | โœ… Via plugins |
215
+
216
+ ## Need Help?
217
+
218
+ - [Plugin Guide](./PLUGIN_GUIDE.md)
219
+ - [GitHub Issues](https://github.com/levouinse/gib-runs/issues)
220
+ - [Discussions](https://github.com/levouinse/gib-runs/discussions)
221
+
222
+ ## Rollback to v2.x
223
+
224
+ If you need v2.x features:
225
+
226
+ ```bash
227
+ npm install gib-runs@2.5.0
228
+ ```
229
+
230
+ v2.x will receive security updates until 2027-02-23.
@@ -0,0 +1,279 @@
1
+ # GIB-RUNS Plugin Development Guide
2
+
3
+ ## Plugin API
4
+
5
+ A gib-runs plugin is a JavaScript module that exports an object with lifecycle hooks.
6
+
7
+ ### Basic Plugin Structure
8
+
9
+ ```javascript
10
+ module.exports = {
11
+ name: 'my-plugin',
12
+ version: '1.0.0',
13
+ description: 'My awesome plugin',
14
+
15
+ // Lifecycle hooks
16
+ onInit(server) {
17
+ // Called when server is created
18
+ // Add middleware, configure routes
19
+ },
20
+
21
+ async onStart(address) {
22
+ // Called when server starts listening
23
+ // address: { address, port, family }
24
+ },
25
+
26
+ async onRequest(req, res, next) {
27
+ // Called for each HTTP request
28
+ // Behaves like Express middleware
29
+ next();
30
+ },
31
+
32
+ async onFileChange(filePath, changeType) {
33
+ // Called when watched file changes
34
+ // changeType: 'change' | 'add' | 'unlink'
35
+ },
36
+
37
+ async onReload() {
38
+ // Called before browser reload
39
+ },
40
+
41
+ async onStop() {
42
+ // Called when server stops
43
+ // Cleanup resources
44
+ }
45
+ };
46
+ ```
47
+
48
+ ### Plugin Context
49
+
50
+ Inside hooks, `this` refers to the plugin instance with:
51
+ - `this.server` - Server instance
52
+ - `this.options` - Plugin options from config
53
+
54
+ ### Example: Custom Header Plugin
55
+
56
+ ```javascript
57
+ // plugins/custom-headers.js
58
+ module.exports = {
59
+ name: 'custom-headers',
60
+ version: '1.0.0',
61
+
62
+ onRequest(req, res, next) {
63
+ const headers = this.options.headers || {};
64
+
65
+ Object.keys(headers).forEach(key => {
66
+ res.setHeader(key, headers[key]);
67
+ });
68
+
69
+ next();
70
+ }
71
+ };
72
+ ```
73
+
74
+ Usage:
75
+ ```json
76
+ {
77
+ "plugins": [
78
+ ["./plugins/custom-headers.js", {
79
+ "headers": {
80
+ "X-Custom": "value",
81
+ "X-Powered-By": "gib-runs"
82
+ }
83
+ }]
84
+ ]
85
+ }
86
+ ```
87
+
88
+ ### Example: API Mock Plugin
89
+
90
+ ```javascript
91
+ // plugins/api-mock.js
92
+ module.exports = {
93
+ name: 'api-mock',
94
+ version: '1.0.0',
95
+
96
+ onInit(server) {
97
+ const mocks = this.options.mocks || {};
98
+
99
+ Object.keys(mocks).forEach(route => {
100
+ server.use(route, (req, res, next) => {
101
+ if (req.url === route) {
102
+ res.setHeader('Content-Type', 'application/json');
103
+ res.end(JSON.stringify(mocks[route]));
104
+ } else {
105
+ next();
106
+ }
107
+ });
108
+ });
109
+ }
110
+ };
111
+ ```
112
+
113
+ Usage:
114
+ ```json
115
+ {
116
+ "plugins": [
117
+ ["./plugins/api-mock.js", {
118
+ "mocks": {
119
+ "/api/user": { "id": 1, "name": "John" },
120
+ "/api/posts": [{ "id": 1, "title": "Hello" }]
121
+ }
122
+ }]
123
+ ]
124
+ }
125
+ ```
126
+
127
+ ### Example: Performance Monitor Plugin
128
+
129
+ ```javascript
130
+ // plugins/perf-monitor.js
131
+ const chalk = require('chalk');
132
+
133
+ module.exports = {
134
+ name: 'perf-monitor',
135
+ version: '1.0.0',
136
+
137
+ onRequest(req, res, next) {
138
+ const start = Date.now();
139
+ const originalEnd = res.end;
140
+
141
+ res.end = function(...args) {
142
+ const duration = Date.now() - start;
143
+ const threshold = this.options.threshold || 100;
144
+
145
+ if (duration > threshold) {
146
+ console.log(chalk.yellow(`โš  Slow request: ${req.url} (${duration}ms)`));
147
+ }
148
+
149
+ originalEnd.apply(res, args);
150
+ }.bind(this);
151
+
152
+ next();
153
+ }
154
+ };
155
+ ```
156
+
157
+ ### Publishing Plugins
158
+
159
+ 1. Create npm package:
160
+ ```bash
161
+ mkdir gib-runs-plugin-myplugin
162
+ cd gib-runs-plugin-myplugin
163
+ npm init -y
164
+ ```
165
+
166
+ 2. Add plugin code:
167
+ ```javascript
168
+ // index.js
169
+ module.exports = {
170
+ name: 'myplugin',
171
+ version: '1.0.0',
172
+ // ... hooks
173
+ };
174
+ ```
175
+
176
+ 3. Publish:
177
+ ```bash
178
+ npm publish
179
+ ```
180
+
181
+ 4. Use in projects:
182
+ ```json
183
+ {
184
+ "plugins": ["gib-runs-plugin-myplugin"]
185
+ }
186
+ ```
187
+
188
+ ### Built-in Plugins
189
+
190
+ These plugins are included in gib-runs core:
191
+
192
+ - `compression` - Gzip compression
193
+ - `cors` - CORS support
194
+ - `spa` - SPA fallback
195
+ - `proxy` - API proxying
196
+ - `auth` - HTTP Basic Auth
197
+ - `tunnel` - Public tunnels
198
+ - `health` - Health endpoint
199
+ - `upload` - File upload
200
+ - `history` - Request history
201
+
202
+ ### Plugin Best Practices
203
+
204
+ 1. **Error Handling**: Always wrap async code in try-catch
205
+ 2. **Cleanup**: Use `onStop` to cleanup resources
206
+ 3. **Performance**: Avoid blocking operations in `onRequest`
207
+ 4. **Configuration**: Validate options in `onInit`
208
+ 5. **Logging**: Use `server.logger` for consistent output
209
+
210
+ ### Server API
211
+
212
+ Available on `this.server`:
213
+
214
+ ```javascript
215
+ // Add middleware
216
+ server.use(middleware)
217
+
218
+ // Get config
219
+ server.config.port
220
+ server.config.root
221
+
222
+ // Get stats
223
+ server.getStats()
224
+
225
+ // Broadcast to WebSocket clients
226
+ server.broadcast('reload')
227
+
228
+ // Logger
229
+ server.logger.info('message')
230
+ server.logger.error('error')
231
+ ```
232
+
233
+ ### Event Bus
234
+
235
+ Listen to server events:
236
+
237
+ ```javascript
238
+ const { eventBus, Events } = require('gib-runs/core/event-bus');
239
+
240
+ eventBus.on(Events.FILE_CHANGE, (path) => {
241
+ console.log('File changed:', path);
242
+ });
243
+ ```
244
+
245
+ Available events:
246
+ - `server:start`
247
+ - `server:stop`
248
+ - `file:change`
249
+ - `file:add`
250
+ - `file:unlink`
251
+ - `reload:trigger`
252
+ - `reload:css`
253
+
254
+ ### Testing Plugins
255
+
256
+ ```javascript
257
+ // test/plugin.test.js
258
+ const gibRuns = require('gib-runs');
259
+ const myPlugin = require('../plugins/my-plugin');
260
+
261
+ const server = gibRuns.start({
262
+ port: 0,
263
+ plugins: [myPlugin]
264
+ });
265
+
266
+ // Test your plugin
267
+ ```
268
+
269
+ ## Community Plugins
270
+
271
+ Share your plugins:
272
+ 1. Tag with `gib-runs-plugin` on npm
273
+ 2. Add to [awesome-gib-runs](https://github.com/levouinse/awesome-gib-runs)
274
+ 3. Submit PR to plugin directory
275
+
276
+ ## Support
277
+
278
+ - [GitHub Issues](https://github.com/levouinse/gib-runs/issues)
279
+ - [Discussions](https://github.com/levouinse/gib-runs/discussions)
package/README.md CHANGED
@@ -4,10 +4,19 @@
4
4
  [![npm downloads](https://img.shields.io/npm/dm/gib-runs.svg)](https://www.npmjs.org/package/gib-runs)
5
5
  [![license](https://img.shields.io/npm/l/gib-runs.svg)](https://github.com/levouinse/gib-runs/blob/main/LICENSE)
6
6
 
7
- A modern development server with live reload and hot module replacement. Built for developers who value capability over connections.
7
+ **Plugin-based development server with live reload.** Built for developers who value capability over connections.
8
8
 
9
9
  > *"Unlike some people, this actually runs on merit, not nepotism."*
10
10
 
11
+ ## What's New in v3.0?
12
+
13
+ ๐Ÿ”Œ **Plugin System** - Extensible architecture
14
+ ๐Ÿ“ฆ **Smaller Core** - 30% smaller bundle
15
+ โšก **Better Performance** - Optimized watcher
16
+ ๐Ÿ›ก๏ธ **Improved Security** - Better error handling
17
+
18
+ [Migration Guide](./MIGRATION.md) | [Plugin Guide](./PLUGIN_GUIDE.md)
19
+
11
20
  ## Why GIB-RUNS?
12
21
 
13
22
  Named after Indonesia's Vice President Gibran Rakabuming Raka, who got his position through family connections. But unlike certain political figures, this server:
@@ -427,12 +436,12 @@ gib-runs --middleware=./middleware/custom.js
427
436
  Server automatically binds to `0.0.0.0` and shows all network URLs:
428
437
 
429
438
  ```
430
- ๐Ÿš€ GIB-RUNS v2.5.0
439
+ ๐Ÿš€ GIB-RUNS v3.0.0
431
440
  โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
432
441
  ๐Ÿ“ Root: /home/user/project
433
442
  ๐ŸŒ Local: http://127.0.0.1:8080
434
443
  ๐Ÿ”— Network: http://192.168.1.100:8080
435
- ๐Ÿ”„ Live Reload: Enabled
444
+ ๐Ÿ”„ Live Reload: Enabled (no dynasty needed)
436
445
  โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
437
446
  ```
438
447