gib-runs 2.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.
- package/CHANGELOG.md +50 -0
- package/LICENSE +21 -0
- package/README.md +441 -0
- package/gib-run.js +206 -0
- package/index.js +464 -0
- package/injected.html +116 -0
- package/middleware/example.js +5 -0
- package/middleware/spa-ignore-assets.js +14 -0
- package/middleware/spa.js +13 -0
- package/package.json +87 -0
package/injected.html
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
<!-- Code injected by gib-runs -->
|
|
2
|
+
<script type="text/javascript">
|
|
3
|
+
// <![CDATA[ <-- For SVG support
|
|
4
|
+
// Live reload enabled
|
|
5
|
+
if ('WebSocket' in window) {
|
|
6
|
+
(function() {
|
|
7
|
+
var gibRunsConnected = false;
|
|
8
|
+
var reconnectAttempts = 0;
|
|
9
|
+
var maxReconnectAttempts = 10;
|
|
10
|
+
|
|
11
|
+
// Inject status indicator
|
|
12
|
+
var statusDiv = document.createElement('div');
|
|
13
|
+
statusDiv.id = 'gib-runs-status';
|
|
14
|
+
statusDiv.style.cssText = 'position:fixed;bottom:20px;right:20px;padding:10px 15px;background:linear-gradient(135deg,#667eea 0%,#764ba2 100%);color:#fff;border-radius:8px;font-family:system-ui,-apple-system,sans-serif;font-size:12px;font-weight:600;box-shadow:0 4px 12px rgba(0,0,0,0.15);z-index:999999;display:flex;align-items:center;gap:8px;transition:all 0.3s ease;opacity:0;transform:translateY(10px)';
|
|
15
|
+
|
|
16
|
+
var statusIcon = document.createElement('span');
|
|
17
|
+
statusIcon.innerHTML = '●';
|
|
18
|
+
statusIcon.style.cssText = 'font-size:16px;animation:pulse 2s ease-in-out infinite';
|
|
19
|
+
|
|
20
|
+
var statusText = document.createElement('span');
|
|
21
|
+
statusText.textContent = 'Connecting...';
|
|
22
|
+
|
|
23
|
+
statusDiv.appendChild(statusIcon);
|
|
24
|
+
statusDiv.appendChild(statusText);
|
|
25
|
+
|
|
26
|
+
// Add pulse animation
|
|
27
|
+
var style = document.createElement('style');
|
|
28
|
+
style.textContent = '@keyframes pulse{0%,100%{opacity:1}50%{opacity:0.5}}@keyframes slideIn{to{opacity:1;transform:translateY(0)}}';
|
|
29
|
+
document.head.appendChild(style);
|
|
30
|
+
|
|
31
|
+
function updateStatus(status, color) {
|
|
32
|
+
statusIcon.style.color = color;
|
|
33
|
+
statusText.textContent = status;
|
|
34
|
+
if (!gibRunsConnected && status === 'Live Reload Active') {
|
|
35
|
+
statusDiv.style.animation = 'slideIn 0.3s ease forwards';
|
|
36
|
+
setTimeout(function() {
|
|
37
|
+
statusDiv.style.opacity = '0.7';
|
|
38
|
+
}, 2000);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function refreshCSS() {
|
|
43
|
+
var sheets = [].slice.call(document.getElementsByTagName("link"));
|
|
44
|
+
var head = document.getElementsByTagName("head")[0];
|
|
45
|
+
for (var i = 0; i < sheets.length; ++i) {
|
|
46
|
+
var elem = sheets[i];
|
|
47
|
+
var rel = elem.rel;
|
|
48
|
+
if (elem.href && typeof rel != "string" || rel.length == 0 || rel.toLowerCase() == "stylesheet") {
|
|
49
|
+
head.removeChild(elem);
|
|
50
|
+
var url = elem.href.replace(/(&|\?)_cacheOverride=\d+/, '');
|
|
51
|
+
elem.href = url + (url.indexOf('?') >= 0 ? '&' : '?') + '_cacheOverride=' + (new Date().valueOf());
|
|
52
|
+
head.appendChild(elem);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
updateStatus('CSS Updated ✨', '#4ade80');
|
|
56
|
+
setTimeout(function() {
|
|
57
|
+
updateStatus('Live Reload Active', '#4ade80');
|
|
58
|
+
}, 1500);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function connect() {
|
|
62
|
+
var protocol = window.location.protocol === 'http:' ? 'ws://' : 'wss://';
|
|
63
|
+
var address = protocol + window.location.host + window.location.pathname + '/ws';
|
|
64
|
+
var socket = new WebSocket(address);
|
|
65
|
+
|
|
66
|
+
socket.onopen = function() {
|
|
67
|
+
gibRunsConnected = true;
|
|
68
|
+
reconnectAttempts = 0;
|
|
69
|
+
updateStatus('Live Reload Active', '#4ade80');
|
|
70
|
+
console.log('%c🚀 GIB-RUNS %cLive reload connected', 'color:#667eea;font-weight:bold;font-size:14px', 'color:#666;font-size:12px');
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
socket.onmessage = function(msg) {
|
|
74
|
+
if (msg.data == 'reload') {
|
|
75
|
+
updateStatus('Reloading...', '#fbbf24');
|
|
76
|
+
setTimeout(function() {
|
|
77
|
+
window.location.reload();
|
|
78
|
+
}, 100);
|
|
79
|
+
}
|
|
80
|
+
else if (msg.data == 'refreshcss') {
|
|
81
|
+
refreshCSS();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
socket.onclose = function() {
|
|
86
|
+
gibRunsConnected = false;
|
|
87
|
+
if (reconnectAttempts < maxReconnectAttempts) {
|
|
88
|
+
reconnectAttempts++;
|
|
89
|
+
updateStatus('Reconnecting...', '#fbbf24');
|
|
90
|
+
setTimeout(connect, 1000 * reconnectAttempts);
|
|
91
|
+
} else {
|
|
92
|
+
updateStatus('Disconnected', '#ef4444');
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
socket.onerror = function() {
|
|
97
|
+
updateStatus('Connection Error', '#ef4444');
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Wait for DOM to be ready
|
|
102
|
+
if (document.readyState === 'loading') {
|
|
103
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
104
|
+
document.body.appendChild(statusDiv);
|
|
105
|
+
connect();
|
|
106
|
+
});
|
|
107
|
+
} else {
|
|
108
|
+
document.body.appendChild(statusDiv);
|
|
109
|
+
connect();
|
|
110
|
+
}
|
|
111
|
+
})();
|
|
112
|
+
} else {
|
|
113
|
+
console.warn('WebSocket not supported. Live reload disabled.');
|
|
114
|
+
}
|
|
115
|
+
// ]]>
|
|
116
|
+
</script>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Single Page Apps - redirect to /#/ except when a file extension is given
|
|
2
|
+
var path = require('path');
|
|
3
|
+
module.exports = function(req, res, next) {
|
|
4
|
+
if (req.method !== "GET" && req.method !== "HEAD")
|
|
5
|
+
next();
|
|
6
|
+
if (req.url !== '/' && path.extname(req.url) === '') {
|
|
7
|
+
var route = req.url;
|
|
8
|
+
req.url = '/';
|
|
9
|
+
res.statusCode = 302;
|
|
10
|
+
res.setHeader('Location', req.url + '#' + route);
|
|
11
|
+
res.end();
|
|
12
|
+
}
|
|
13
|
+
else next();
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Single Page Apps - redirect to /#/
|
|
2
|
+
module.exports = function(req, res, next) {
|
|
3
|
+
if (req.method !== "GET" && req.method !== "HEAD")
|
|
4
|
+
next();
|
|
5
|
+
if (req.url !== '/') {
|
|
6
|
+
var route = req.url;
|
|
7
|
+
req.url = '/';
|
|
8
|
+
res.statusCode = 302;
|
|
9
|
+
res.setHeader('Location', req.url + '#' + route);
|
|
10
|
+
res.end();
|
|
11
|
+
}
|
|
12
|
+
else next();
|
|
13
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "gib-runs",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Modern development server with live reload, hot module replacement, and advanced features for all project types - runs on merit, not nepotism",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"development",
|
|
7
|
+
"server",
|
|
8
|
+
"live-reload",
|
|
9
|
+
"hot-reload",
|
|
10
|
+
"hmr",
|
|
11
|
+
"http",
|
|
12
|
+
"https",
|
|
13
|
+
"http2",
|
|
14
|
+
"spa",
|
|
15
|
+
"cli",
|
|
16
|
+
"devserver",
|
|
17
|
+
"watch",
|
|
18
|
+
"websocket",
|
|
19
|
+
"performance",
|
|
20
|
+
"compression",
|
|
21
|
+
"proxy"
|
|
22
|
+
],
|
|
23
|
+
"author": "sofinco (https://github.com/levouinse)",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"chokidar": "^3.5.3",
|
|
26
|
+
"chalk": "^4.1.2",
|
|
27
|
+
"connect": "^3.7.0",
|
|
28
|
+
"compression": "^1.7.4",
|
|
29
|
+
"cors": "^2.8.5",
|
|
30
|
+
"event-stream": "^4.0.1",
|
|
31
|
+
"faye-websocket": "^0.11.4",
|
|
32
|
+
"http-auth": "^4.2.0",
|
|
33
|
+
"morgan": "^1.10.0",
|
|
34
|
+
"object-assign": "^4.1.1",
|
|
35
|
+
"open": "^8.4.2",
|
|
36
|
+
"proxy-middleware": "^0.15.0",
|
|
37
|
+
"send": "^0.18.0",
|
|
38
|
+
"serve-index": "^1.9.1",
|
|
39
|
+
"boxen": "^5.1.2",
|
|
40
|
+
"ora": "^5.4.1"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"eslint": "^8.56.0",
|
|
44
|
+
"jshint": "^2.13.6",
|
|
45
|
+
"mocha": "^10.2.0",
|
|
46
|
+
"supertest": "^6.3.3"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"lint": "eslint gib-run.js index.js",
|
|
50
|
+
"hint": "jshint gib-run.js index.js",
|
|
51
|
+
"test": "mocha test --exit && npm run lint"
|
|
52
|
+
},
|
|
53
|
+
"bin": {
|
|
54
|
+
"gib-runs": "gib-run.js"
|
|
55
|
+
},
|
|
56
|
+
"repository": {
|
|
57
|
+
"type": "git",
|
|
58
|
+
"url": "git+https://github.com/levouinse/gib-runs.git"
|
|
59
|
+
},
|
|
60
|
+
"bugs": {
|
|
61
|
+
"url": "https://github.com/levouinse/gib-runs/issues"
|
|
62
|
+
},
|
|
63
|
+
"homepage": "https://github.com/levouinse/gib-runs#readme",
|
|
64
|
+
"engines": {
|
|
65
|
+
"node": ">=16.0.0"
|
|
66
|
+
},
|
|
67
|
+
"preferGlobal": true,
|
|
68
|
+
"license": "MIT",
|
|
69
|
+
"eslintConfig": {
|
|
70
|
+
"env": {
|
|
71
|
+
"node": true,
|
|
72
|
+
"es6": true
|
|
73
|
+
},
|
|
74
|
+
"parserOptions": {
|
|
75
|
+
"ecmaVersion": 2020
|
|
76
|
+
},
|
|
77
|
+
"rules": {
|
|
78
|
+
"quotes": 0,
|
|
79
|
+
"curly": 0,
|
|
80
|
+
"strict": 0,
|
|
81
|
+
"no-process-exit": 0,
|
|
82
|
+
"eqeqeq": 1,
|
|
83
|
+
"no-unused-vars": 1,
|
|
84
|
+
"no-shadow": 1
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|