kami-redis 2.1.4 → 2.2.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/dist/index.js +1 -1
- package/package.json +1 -2
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
2
|
+
import U from"meow";import P from"picocolors";import{createClient as V}from"redis";function y(e){try{let r=new URL(e);return(r.protocol==="redis:"||r.protocol==="rediss:")&&!!r.hostname&&(!r.port||!Number.isNaN(Number(r.port)))}catch{return!1}}import I from"inquirer";async function h(e=0){try{if(process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}try{process.stdin.pause()}catch{await t.quit()}}catch{}finally{console.clear(),process.exit(e)}}async function w(){let e=await t.keys("*");if(e.length===0)return null;try{let{selectedKey:r}=await I.prompt({type:"list",name:"selectedKey",message:"Select a key to view its value:",choices:e,pageSize:20,theme:{icon:{cursor:">"},prefix:"0_0"}});return r}catch{await h(0)}}import K from"boxen";import{highlight as W}from"cli-highlight";import{exec as Y}from"child_process";import $ from"readline";import A from"picocolors";var p=globalThis.process?.platform||"",n=/^win/i.test(p),x=/^linux/i.test(p),S=/^darwin/i.test(p),l=!!process.env.WAYLAND_DISPLAY,b=!!process.env.DISPLAY&&!l,v=process.env.PSModulePath!==void 0;function R(e){return`'${e.replace(/'/g,"''")}'`}function c(e){return`'${e.replace(/'/g,"'\\''")}'`}function C(e){if(n)return`powershell -Command "Set-Clipboard -Value ${R(e)}"`;if(x){if(l)return`echo ${c(e)} | wl-copy`;if(b)return`echo ${c(e)} | xclip -selection clipboard`}return S?`echo ${c(e)} | pbcopy`:""}function L(e){if(typeof e=="object"&&e!==null)return JSON.stringify(e,null,2);if(typeof e=="string")try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}return String(e)}async function N(e,r){switch(r){case"string":return t.get(e);case"hash":return t.hGetAll(e);case"list":return t.lRange(e,0,-1);case"set":return t.sMembers(e);case"zset":return t.zRangeWithScores(e,0,-1);default:return"(unsupported type)"}}var T=!1;function O(){!T&&process.stdin.isTTY&&($.emitKeypressEvents(process.stdin),T=!0)}async function q(e){let r=await t.type(e),M=await N(e,r),f=L(M);return console.clear(),console.log(K(W(f,{language:"json",ignoreIllegals:!0}),{borderColor:"cyan",padding:1,title:e,borderStyle:"round"})),console.log(A.dim("d: delete | c: copy | \u2190: back | ctrl+c: quit")),O(),new Promise(s=>{let a=!1,i=()=>{if(!a){if(a=!0,process.stdin.removeListener("keypress",d),process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}process.stdin.pause()}},d=async(E,o)=>{if(!(!o||a)){if(o.ctrl&&o.name==="c"){i(),console.clear(),s("quit");return}if(o.name==="d"){i();try{await t.del(e)}catch{}console.clear(),s("deleted");return}if(o.name==="c"){let F=C(f);Y(F,n?{shell:"powershell.exe"}:{},g=>{g&&console.error(`Copy failed: ${g}`)}),i(),console.clear(),s("back")}o.name==="left"&&(i(),console.clear(),s("back"))}};process.stdin.isTTY&&process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("keypress",d)})}var u=U("Usage: kami-redis <url>",{importMeta:import.meta}),[m]=u.input;m||(console.log(u.help),process.exit(1));y(m)||(console.log(u.help),console.log(P.red("Invalid Redis URL")),process.exit(1));var t=V({url:m});async function z(){try{for(console.clear(),await t.connect();;){let e=await w();e||(console.log("No keys in Redis"),await t.quit(),process.exit(0)),await q(e)==="quit"&&(await t.quit(),process.exit(0))}}catch(e){console.error(P.red("Error:"),e);try{await t.quit()}catch{}process.exit(1)}}process.on("SIGINT",async()=>{try{await t.quit()}catch{}process.exit(0)});z();export{t as client};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kami-redis",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.2.0",
|
|
5
5
|
"description": "Browse, inspect, copy, and delete Redis keys from your CLI",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "dist/index.js",
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"boxen": "^8.0.1",
|
|
31
31
|
"cli-highlight": "^2.1.11",
|
|
32
|
-
"clipboardy": "^5.0.0",
|
|
33
32
|
"inquirer": "^12.9.6",
|
|
34
33
|
"meow": "^14.0.0",
|
|
35
34
|
"picocolors": "^1.1.1",
|