@redis-dev-panel/cli 0.1.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/LICENSE +21 -0
- package/package.json +45 -0
- package/src/index.js +110 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Your Name
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@redis-dev-panel/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CLI for Redis Dev Panel — npx redis-dev-panel",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"redis-dev-panel": "./src/index.js",
|
|
8
|
+
"rdp": "./src/index.js"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"redis",
|
|
12
|
+
"dev-tools",
|
|
13
|
+
"redis-panel",
|
|
14
|
+
"redis-gui",
|
|
15
|
+
"cli",
|
|
16
|
+
"npx",
|
|
17
|
+
"developer-tools"
|
|
18
|
+
],
|
|
19
|
+
"author": {
|
|
20
|
+
"name": "Tejas Chavan",
|
|
21
|
+
"url": "https://github.com/tejas1505"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"commander": "^12.1.0",
|
|
26
|
+
"ioredis": "^5.9.3",
|
|
27
|
+
"@redis-dev-panel/server": "0.1.0"
|
|
28
|
+
},
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=18.0.0"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"src/",
|
|
34
|
+
"README.md",
|
|
35
|
+
"LICENSE"
|
|
36
|
+
],
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public",
|
|
39
|
+
"registry": "https://registry.npmjs.org/"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/tejas1505/redis-dev-panel#readme",
|
|
42
|
+
"scripts": {
|
|
43
|
+
"start": "node src/index.js"
|
|
44
|
+
}
|
|
45
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
import { program } from 'commander';
|
|
5
|
+
import { startRedisPanel } from '@redis-dev-panel/server';
|
|
6
|
+
import pkg from '../package.json';
|
|
7
|
+
|
|
8
|
+
program
|
|
9
|
+
.name('redis-dev-panel')
|
|
10
|
+
.description('🔴 Redis Dev Panel — Visual Redis debugger for developers')
|
|
11
|
+
.version(pkg.version);
|
|
12
|
+
|
|
13
|
+
program
|
|
14
|
+
.command('start', { isDefault: true })
|
|
15
|
+
.description('Start the Redis Dev Panel server')
|
|
16
|
+
.option('-u, --url <url>', 'Redis URL', process.env.REDIS_URL || 'redis://localhost:6379')
|
|
17
|
+
.option('-p, --port <port>', 'Server port', String(process.env.PORT || '5174'))
|
|
18
|
+
.option('-t, --token <token>', 'Auth token (optional)', process.env.AUTH_TOKEN)
|
|
19
|
+
.option('-h, --host <host>', 'Bind host', process.env.HOST || '127.0.0.1')
|
|
20
|
+
.option('--open', 'Auto-open browser after start', false)
|
|
21
|
+
.action(async (options) => {
|
|
22
|
+
const port = parseInt(options.port, 10);
|
|
23
|
+
|
|
24
|
+
if (isNaN(port) || port < 1 || port > 65535) {
|
|
25
|
+
console.error('❌ Invalid port:', options.port);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
console.log('');
|
|
30
|
+
console.log(' 🔴 Redis Dev Panel');
|
|
31
|
+
console.log(` 📡 Connecting to: ${maskUrl(options.url)}`);
|
|
32
|
+
console.log('');
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
await startRedisPanel({
|
|
36
|
+
redisUrl: options.url,
|
|
37
|
+
port,
|
|
38
|
+
token: options.token,
|
|
39
|
+
host: options.host,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (options.open) {
|
|
43
|
+
const url = `http://${options.host}:${port}`;
|
|
44
|
+
openBrowser(url);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Graceful shutdown
|
|
48
|
+
process.on('SIGINT', () => {
|
|
49
|
+
console.log('\n 👋 Shutting down Redis Dev Panel...');
|
|
50
|
+
process.exit(0);
|
|
51
|
+
});
|
|
52
|
+
process.on('SIGTERM', () => process.exit(0));
|
|
53
|
+
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.error('❌ Failed to start:', error.message);
|
|
56
|
+
if (error.message.includes('ECONNREFUSED')) {
|
|
57
|
+
console.error(`\n 💡 Tip: Is Redis running at ${options.url}?`);
|
|
58
|
+
console.error(' Start Redis: redis-server');
|
|
59
|
+
console.error(' Or with Docker: docker run -p 6379:6379 redis\n');
|
|
60
|
+
}
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
program
|
|
66
|
+
.command('check')
|
|
67
|
+
.description('Check Redis connectivity without starting the server')
|
|
68
|
+
.option('-u, --url <url>', 'Redis URL', process.env.REDIS_URL || 'redis://localhost:6379')
|
|
69
|
+
.action(async (options) => {
|
|
70
|
+
const Redis = require('ioredis');
|
|
71
|
+
const client = new Redis(options.url, { maxRetriesPerRequest: 1 });
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
const pong = await client.ping();
|
|
75
|
+
console.log(`✅ Redis is reachable at ${maskUrl(options.url)} — Response: ${pong}`);
|
|
76
|
+
await client.quit();
|
|
77
|
+
process.exit(0);
|
|
78
|
+
} catch (error) {
|
|
79
|
+
console.error(`❌ Cannot connect to Redis at ${maskUrl(options.url)}`);
|
|
80
|
+
console.error(` ${error.message}`);
|
|
81
|
+
await client.quit().catch(() => { });
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
program.parse(process.argv);
|
|
87
|
+
|
|
88
|
+
// ── Helpers ────────────────────────────────────────────────────────────────
|
|
89
|
+
|
|
90
|
+
function maskUrl(url) {
|
|
91
|
+
try {
|
|
92
|
+
const u = new URL(url);
|
|
93
|
+
if (u.password) u.password = '***';
|
|
94
|
+
return u.toString();
|
|
95
|
+
} catch {
|
|
96
|
+
return url;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function openBrowser(url) {
|
|
101
|
+
const { exec } = require('child_process');
|
|
102
|
+
const cmd =
|
|
103
|
+
process.platform === 'win32' ? `start ${url}` :
|
|
104
|
+
process.platform === 'darwin' ? `open ${url}` :
|
|
105
|
+
`xdg-open ${url}`;
|
|
106
|
+
|
|
107
|
+
exec(cmd, (err) => {
|
|
108
|
+
if (!err) console.log(` 🌐 Opened: ${url}`);
|
|
109
|
+
});
|
|
110
|
+
}
|