@initx-plugin/utils 0.0.37 → 0.1.1

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/gpg.mjs CHANGED
@@ -1 +1 @@
1
- export{g as gpgList}from"./shared/utils.BoT6_OSW.mjs";import"ora";import"tinyexec";import"which";
1
+ export{g as gpgList}from"./shared/utils.Crl5PLcv.mjs";import"ora";import"tinyexec";import"which";
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export{c,g as gpgList,l as loadingFunction,w as where}from"./shared/utils.BoT6_OSW.mjs";import s from"inquirer";import e from"picocolors";import"ora";import"tinyexec";import"which";async function l(o){const{result:t}=await s.prompt([{type:"confirm",name:"result",message:o}]);return t}async function i(o,t){const{result:r}=await s.prompt([{type:"list",name:"result",message:o,choices:t.map((n,c)=>typeof n=="string"?{name:n,value:c}:n)}]);return r}const a={confirm:l,select:i},m={success:o=>console.log(`${e.bgGreen(e.black(" SUCCESS "))} ${o}`),info:o=>console.log(`${e.bgBlue(e.white(" INFO "))} ${o}`),warn:o=>console.log(`${e.bgYellow(e.black(" WARN "))} ${o}`),error:o=>console.log(`${e.bgRed(e.white(" ERROR "))} ${o}`)};export{a as inquirer,m as log};
1
+ export{c,g as gpgList,l as loadingFunction,w as where}from"./shared/utils.Crl5PLcv.mjs";import s from"inquirer";import e from"picocolors";import"ora";import"tinyexec";import"which";async function l(o){const{result:t}=await s.prompt([{type:"confirm",name:"result",message:o}]);return t}async function i(o,t){const{result:r}=await s.prompt([{type:"list",name:"result",message:o,choices:t.map((n,c)=>typeof n=="string"?{name:n,value:c}:n)}]);return r}const a={confirm:l,select:i},m={success:o=>console.log(`${e.bgGreen(e.black(" SUCCESS "))} ${o}`),info:o=>console.log(`${e.bgBlue(e.white(" INFO "))} ${o}`),warn:o=>console.log(`${e.bgYellow(e.black(" WARN "))} ${o}`),error:o=>console.log(`${e.bgRed(e.white(" ERROR "))} ${o}`)};export{a as inquirer,m as log};
@@ -0,0 +1 @@
1
+ import l from"ora";import{x as w}from"tinyexec";import y from"which";const i=y.sync,o=new Map;async function u(n,e,r={}){const t={success:!1,content:"Unknown error"};try{if(!g(n))return t.content=`Can not find command: ${n}`,t;const s=await w(n,e,r);t.success=s.exitCode===0,t.content=(t.success?s.stdout:s.stderr).trim()}catch(s){t.content=s.message}return t}async function p(n,e){const r=l(n).start();return e().finally(()=>{r.stop()})}function g(n){if(o.has(n))return o.get(n);let e;try{i(n),e=!0}catch{e=!1}return o.set(n,e),e}async function h(){const n=await u("gpg",["-k"]),e=[],r=n.content.split(/\r?\n|\r/).filter(c=>c.trim()!=="");if(!r||r.length<4)return[];const t={key:"",name:"",email:""},s={key:/^\s+(\w{40})$/,user:/\s(\w+)\s<([\w-]+@[\w-]+(?:\.[\w-]+)+)>/};return r.forEach(c=>{const[,a]=s.key.exec(c)||[];if(a){t.key=a;return}if(c.startsWith("uid")){const[,f,m]=s.user.exec(c)||[];t.name=f,t.email=m;return}c.startsWith("sub")&&e.push({...t})}),e}export{u as c,h as g,p as l,i as w};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@initx-plugin/utils",
3
3
  "type": "module",
4
- "version": "0.0.37",
4
+ "version": "0.1.1",
5
5
  "description": "A more convenient scripting engine",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/initx-collective/initx#readme",
@@ -32,10 +32,10 @@
32
32
  "dist"
33
33
  ],
34
34
  "dependencies": {
35
- "inquirer": "^12.4.2",
35
+ "inquirer": "^12.6.1",
36
36
  "ora": "^8.2.0",
37
37
  "picocolors": "^1.1.1",
38
- "tinyexec": "^0.3.2",
38
+ "tinyexec": "^1.0.1",
39
39
  "which": "^5.0.0"
40
40
  },
41
41
  "devDependencies": {
@@ -1 +0,0 @@
1
- import f from"ora";import{x as g}from"tinyexec";import l from"which";const a=l.sync;async function i(s,o,e={}){const t={success:!1,content:"Unknown error"};try{a(s);const n=await g(s,o,e);t.success=n.exitCode===0,t.content=(t.success?n.stdout:n.stderr).trim()}catch(n){n.message&&n.message.startsWith("not found")?t.content=`can not find command: ${s}`:t.content=n.message}return t}async function w(s,o){const e=f(s).start();return o().finally(()=>{e.stop()})}async function y(){const s=await i("gpg",["-k"]),o=[],e=s.content.split(/\r?\n|\r/).filter(r=>r.trim()!=="");if(!e||e.length<4)return[];const t={key:"",name:"",email:""},n={key:/^\s+(\w{40})$/,user:/\s(\w+)\s<([\w-]+@[\w-]+(?:\.[\w-]+)+)>/};return e.forEach(r=>{const[,c]=n.key.exec(r)||[];if(c){t.key=c;return}if(r.startsWith("uid")){const[,u,m]=n.user.exec(r)||[];t.name=u,t.email=m;return}r.startsWith("sub")&&o.push({...t})}),o}export{i as c,y as g,w as l,a as w};