ccommand 1.0.40 → 1.0.41

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 CHANGED
@@ -1,16 +1,16 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var ge=require("module"),Z=require("fs/promises"),ee=require("path"),p=require("lazy-js-utils"),re=require("fast-glob"),te=require("@simon_he/colorize"),ue=require("os"),ne=require("tty");function R(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var q=R(Z),V=R(ee),oe=R(re),a=R(te),se=R(ue),ae=R(ne),ie=require;const i="\x1B[",A="\x1B]",k="\x07",v=";",G=process.env.TERM_PROGRAM==="Apple_Terminal",s={};s.cursorTo=(e,r)=>{if(typeof e!="number")throw new TypeError("The `x` argument is required");return typeof r!="number"?i+(e+1)+"G":i+(r+1)+";"+(e+1)+"H"},s.cursorMove=(e,r)=>{if(typeof e!="number")throw new TypeError("The `x` argument is required");let t="";return e<0?t+=i+-e+"D":e>0&&(t+=i+e+"C"),r<0?t+=i+-r+"A":r>0&&(t+=i+r+"B"),t},s.cursorUp=(e=1)=>i+e+"A",s.cursorDown=(e=1)=>i+e+"B",s.cursorForward=(e=1)=>i+e+"C",s.cursorBackward=(e=1)=>i+e+"D",s.cursorLeft=i+"G",s.cursorSavePosition=G?"\x1B7":i+"s",s.cursorRestorePosition=G?"\x1B8":i+"u",s.cursorGetPosition=i+"6n",s.cursorNextLine=i+"E",s.cursorPrevLine=i+"F",s.cursorHide=i+"?25l",s.cursorShow=i+"?25h",s.eraseLines=e=>{let r="";for(let t=0;t<e;t++)r+=s.eraseLine+(t<e-1?s.cursorUp():"");return e&&(r+=s.cursorLeft),r},s.eraseEndLine=i+"K",s.eraseStartLine=i+"1K",s.eraseLine=i+"2K",s.eraseDown=i+"J",s.eraseUp=i+"1J",s.eraseScreen=i+"2J",s.scrollUp=i+"S",s.scrollDown=i+"T",s.clearScreen="\x1Bc",s.clearTerminal=process.platform==="win32"?`${s.eraseScreen}${i}0f`:`${s.eraseScreen}${i}3J${i}H`,s.beep=k,s.link=(e,r)=>[A,"8",v,v,r,k,e,A,"8",v,v,k].join(""),s.image=(e,r={})=>{let t=`${A}1337;File=inline=1`;return r.width&&(t+=`;width=${r.width}`),r.height&&(t+=`;height=${r.height}`),r.preserveAspectRatio===!1&&(t+=";preserveAspectRatio=0"),t+":"+e.toString("base64")+k},s.iTerm={setCwd:(e=process.cwd())=>`${A}50;CurrentDir=${e}${k}`,annotation:(e,r={})=>{let t=`${A}1337;`;const u=typeof r.x<"u",l=typeof r.y<"u";if((u||l)&&!(u&&l&&typeof r.length<"u"))throw new Error("`x`, `y` and `length` must be defined when `x` or `y` is defined");return e=e.replace(/\|/g,""),t+=r.isHidden?"AddHiddenAnnotation=":"AddAnnotation=",r.length>0?t+=(u?[e,r.length,r.x,r.y]:[r.length,e]).join("|"):t+=e,t+k}};var H=(e,r=process.argv)=>{const t=e.startsWith("-")?"":e.length===1?"-":"--",u=r.indexOf(t+e),l=r.indexOf("--");return u!==-1&&(l===-1||u<l)};const le=se.default,Y=ae.default,g=H,{env:m}=process;let w;g("no-color")||g("no-colors")||g("color=false")||g("color=never")?w=0:(g("color")||g("colors")||g("color=true")||g("color=always"))&&(w=1),"FORCE_COLOR"in m&&(m.FORCE_COLOR==="true"?w=1:m.FORCE_COLOR==="false"?w=0:w=m.FORCE_COLOR.length===0?1:Math.min(parseInt(m.FORCE_COLOR,10),3));function S(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function B(e,r){if(w===0)return 0;if(g("color=16m")||g("color=full")||g("color=truecolor"))return 3;if(g("color=256"))return 2;if(e&&!r&&w===void 0)return 0;const t=w||0;if(m.TERM==="dumb")return t;if(process.platform==="win32"){const u=le.release().split(".");return Number(u[0])>=10&&Number(u[2])>=10586?Number(u[2])>=14931?3:2:1}if("CI"in m)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(u=>u in m)||m.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in m)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(m.TEAMCITY_VERSION)?1:0;if(m.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in m){const u=parseInt((m.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(m.TERM_PROGRAM){case"iTerm.app":return u>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(m.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(m.TERM)||"COLORTERM"in m?1:t}function ce(e){const r=B(e,e&&e.isTTY);return S(r)}var fe={supportsColor:ce,stdout:S(B(!0,Y.isatty(1))),stderr:S(B(!0,Y.isatty(2)))};const de=fe,_=H;function z(e){if(/^\d{3,4}$/.test(e)){const t=/(\d{1,2})(\d{2})/.exec(e);return{major:0,minor:parseInt(t[1],10),patch:parseInt(t[2],10)}}const r=(e||"").split(".").map(t=>parseInt(t,10));return{major:r[0],minor:r[1],patch:r[2]}}function D(e){const{env:r}=process;if("FORCE_HYPERLINK"in r)return!(r.FORCE_HYPERLINK.length>0&&parseInt(r.FORCE_HYPERLINK,10)===0);if(_("no-hyperlink")||_("no-hyperlinks")||_("hyperlink=false")||_("hyperlink=never"))return!1;if(_("hyperlink=true")||_("hyperlink=always")||"NETLIFY"in r)return!0;if(!de.supportsColor(e)||e&&!e.isTTY||process.platform==="win32"||"CI"in r||"TEAMCITY_VERSION"in r)return!1;if("TERM_PROGRAM"in r){const t=z(r.TERM_PROGRAM_VERSION);switch(r.TERM_PROGRAM){case"iTerm.app":return t.major===3?t.minor>=1:t.major>3;case"WezTerm":return t.major>=20200620;case"vscode":return t.major>1||t.major===1&&t.minor>=72}}if("VTE_VERSION"in r){if(r.VTE_VERSION==="0.50.0")return!1;const t=z(r.VTE_VERSION);return t.major>0||t.minor>=50}return!1}var x={supportsHyperlink:D,stdout:D(process.stdout),stderr:D(process.stderr)};function C(e,r,{target:t="stdout",...u}={}){return x[t]?s.link(e,r):u.fallback===!1?e:typeof u.fallback=="function"?u.fallback(e,r):`${e} (\u200B${r}\u200B)`}C.isSupported=x.stdout,C.stderr=(e,r,t={})=>C(e,r,{target:"stderr",...t}),C.stderr.isSupported=x.stderr;var U="1.0.40";const I=console.log;function pe(e){const{status:r}=p.jsShell("gum -v","pipe");if(r!==0){I(a.default({color:"blue",text:e?"\u6B63\u5728\u4E3A\u60A8\u5B89\u88C5gum...":"install gum..."}));const{status:t}=p.jsShell("brew install gum");if(t!==0){const{status:u}=p.jsShell(`sudo mkdir -p /etc/apt/keyrings
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var Ce=require("module"),ue=require("fs/promises"),ne=require("path"),p=require("lazy-js-utils"),oe=require("fast-glob"),se=require("@simon_he/colorize"),ae=require("os"),ie=require("tty");function b(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Y=b(ue),z=b(ne),ce=b(oe),i=b(se),le=b(ae),fe=b(ie),de=require;const c="\x1B[",j="\x1B]",T="\x07",S=";",U=process.env.TERM_PROGRAM==="Apple_Terminal",a={};a.cursorTo=(e,t)=>{if(typeof e!="number")throw new TypeError("The `x` argument is required");return typeof t!="number"?c+(e+1)+"G":c+(t+1)+";"+(e+1)+"H"},a.cursorMove=(e,t)=>{if(typeof e!="number")throw new TypeError("The `x` argument is required");let r="";return e<0?r+=c+-e+"D":e>0&&(r+=c+e+"C"),t<0?r+=c+-t+"A":t>0&&(r+=c+t+"B"),r},a.cursorUp=(e=1)=>c+e+"A",a.cursorDown=(e=1)=>c+e+"B",a.cursorForward=(e=1)=>c+e+"C",a.cursorBackward=(e=1)=>c+e+"D",a.cursorLeft=c+"G",a.cursorSavePosition=U?"\x1B7":c+"s",a.cursorRestorePosition=U?"\x1B8":c+"u",a.cursorGetPosition=c+"6n",a.cursorNextLine=c+"E",a.cursorPrevLine=c+"F",a.cursorHide=c+"?25l",a.cursorShow=c+"?25h",a.eraseLines=e=>{let t="";for(let r=0;r<e;r++)t+=a.eraseLine+(r<e-1?a.cursorUp():"");return e&&(t+=a.cursorLeft),t},a.eraseEndLine=c+"K",a.eraseStartLine=c+"1K",a.eraseLine=c+"2K",a.eraseDown=c+"J",a.eraseUp=c+"1J",a.eraseScreen=c+"2J",a.scrollUp=c+"S",a.scrollDown=c+"T",a.clearScreen="\x1Bc",a.clearTerminal=process.platform==="win32"?`${a.eraseScreen}${c}0f`:`${a.eraseScreen}${c}3J${c}H`,a.beep=T,a.link=(e,t)=>[j,"8",S,S,t,T,e,j,"8",S,S,T].join(""),a.image=(e,t={})=>{let r=`${j}1337;File=inline=1`;return t.width&&(r+=`;width=${t.width}`),t.height&&(r+=`;height=${t.height}`),t.preserveAspectRatio===!1&&(r+=";preserveAspectRatio=0"),r+":"+e.toString("base64")+T},a.iTerm={setCwd:(e=process.cwd())=>`${j}50;CurrentDir=${e}${T}`,annotation:(e,t={})=>{let r=`${j}1337;`;const n=typeof t.x<"u",u=typeof t.y<"u";if((n||u)&&!(n&&u&&typeof t.length<"u"))throw new Error("`x`, `y` and `length` must be defined when `x` or `y` is defined");return e=e.replace(/\|/g,""),r+=t.isHidden?"AddHiddenAnnotation=":"AddAnnotation=",t.length>0?r+=(n?[e,t.length,t.x,t.y]:[t.length,e]).join("|"):r+=e,r+T}};var W=(e,t=process.argv)=>{const r=e.startsWith("-")?"":e.length===1?"-":"--",n=t.indexOf(r+e),u=t.indexOf("--");return n!==-1&&(u===-1||n<u)};const pe=le.default,K=fe.default,y=W,{env:m}=process;let C;y("no-color")||y("no-colors")||y("color=false")||y("color=never")?C=0:(y("color")||y("colors")||y("color=true")||y("color=always"))&&(C=1),"FORCE_COLOR"in m&&(m.FORCE_COLOR==="true"?C=1:m.FORCE_COLOR==="false"?C=0:C=m.FORCE_COLOR.length===0?1:Math.min(parseInt(m.FORCE_COLOR,10),3));function D(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function L(e,t){if(C===0)return 0;if(y("color=16m")||y("color=full")||y("color=truecolor"))return 3;if(y("color=256"))return 2;if(e&&!t&&C===void 0)return 0;const r=C||0;if(m.TERM==="dumb")return r;if(process.platform==="win32"){const n=pe.release().split(".");return Number(n[0])>=10&&Number(n[2])>=10586?Number(n[2])>=14931?3:2:1}if("CI"in m)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(n=>n in m)||m.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in m)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(m.TEAMCITY_VERSION)?1:0;if(m.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in m){const n=parseInt((m.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(m.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(m.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(m.TERM)||"COLORTERM"in m?1:r}function me(e){const t=L(e,e&&e.isTTY);return D(t)}var Ee={supportsColor:me,stdout:D(L(!0,K.isatty(1))),stderr:D(L(!0,K.isatty(2)))};const he=Ee,A=W;function J(e){if(/^\d{3,4}$/.test(e)){const r=/(\d{1,2})(\d{2})/.exec(e);return{major:0,minor:parseInt(r[1],10),patch:parseInt(r[2],10)}}const t=(e||"").split(".").map(r=>parseInt(r,10));return{major:t[0],minor:t[1],patch:t[2]}}function P(e){const{env:t}=process;if("FORCE_HYPERLINK"in t)return!(t.FORCE_HYPERLINK.length>0&&parseInt(t.FORCE_HYPERLINK,10)===0);if(A("no-hyperlink")||A("no-hyperlinks")||A("hyperlink=false")||A("hyperlink=never"))return!1;if(A("hyperlink=true")||A("hyperlink=always")||"NETLIFY"in t)return!0;if(!he.supportsColor(e)||e&&!e.isTTY||process.platform==="win32"||"CI"in t||"TEAMCITY_VERSION"in t)return!1;if("TERM_PROGRAM"in t){const r=J(t.TERM_PROGRAM_VERSION);switch(t.TERM_PROGRAM){case"iTerm.app":return r.major===3?r.minor>=1:r.major>3;case"WezTerm":return r.major>=20200620;case"vscode":return r.major>1||r.major===1&&r.minor>=72}}if("VTE_VERSION"in t){if(t.VTE_VERSION==="0.50.0")return!1;const r=J(t.VTE_VERSION);return r.major>0||r.minor>=50}return!1}var M={supportsHyperlink:P,stdout:P(process.stdout),stderr:P(process.stderr)};function k(e,t,{target:r="stdout",...n}={}){return M[r]?a.link(e,t):n.fallback===!1?e:typeof n.fallback=="function"?n.fallback(e,t):`${e} (\u200B${t}\u200B)`}k.isSupported=M.stdout,k.stderr=(e,t,r={})=>k(e,t,{target:"stderr",...r}),k.stderr.isSupported=M.stderr;var X="1.0.41";const N=console.log;function $e(e){const{status:t}=p.jsShell("gum -v","pipe");if(t!==0){N(i.default({color:"blue",text:e?"\u6B63\u5728\u4E3A\u60A8\u5B89\u88C5gum...":"install gum..."}));const{status:r}=p.jsShell("brew install gum");if(r!==0){const{status:n}=p.jsShell(`sudo mkdir -p /etc/apt/keyrings
2
2
  curl -fsSL https://repo.charm.sh/apt/gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/charm.gpg
3
3
  echo "deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" | sudo tee /etc/apt/sources.list.d/charm.list
4
- sudo apt update && sudo apt install gum`);if(u!==0){const l=C(e?"gum\u5B98\u7F51\u94FE\u63A5":"the official website of gum","https://github.com/charmbracelet/gum#installation");return I(a.default({color:"red",text:`${e?"gum\u5B89\u88C5\u5931\u8D25,\u4F60\u53EF\u4EE5\u81EA\u884C\u4ECE\u4EE5\u4E0B\u94FE\u63A5\u5B89\u88C5":"gum install error, you can install it yourself through"} ${a.default({color:"yellow",text:l,bold:!0})}`}))}}I(a.default({color:"green",text:e?"gum\u5B89\u88C5\u6210\u529F \u{1F389}":"gum install successfully \u{1F389}"}))}}const me=ie("yamljs");let b=[],y=null;const d=console.log,W="__ccommand__split",f=process.env.PI_Lang==="zh";async function K(){pe(f);const e=process.argv.slice(2);if(e[0]==="-v"||e[0]==="--version")return d(a.default({text:f?`ccommand \u5F53\u524D\u7248\u672C: ${U}`:`ccommand Version: ${U}`,color:"green"}));if(e[0]==="-h"||e[0]==="--help"){const n=C(f?"\u6253\u5F00\u4E00\u4E2A\u65B0\u7684\u95EE\u9898":"open an issue","https://github.com/Simon-He95/ccommand/issues"),o=C(f?"\u2728\u5E2E\u52A9\u70B9\u4E00\u4E2A\u661F\u661F":"\u2728star it","https://github.com/Simon-He95/ccommand");return d(a.default({color:"white",text:`
5
- ${a.default({bold:!0,text:"Common Commands:",bgColor:"blue"})}
6
- ${a.default({text:`- ccommand -v \u67E5\u770B\u5F53\u524D\u7248\u672C
4
+ sudo apt update && sudo apt install gum`);if(n!==0){const u=k(e?"gum\u5B98\u7F51\u94FE\u63A5":"the official website of gum","https://github.com/charmbracelet/gum#installation");return N(i.default({color:"red",text:`${e?"gum\u5B89\u88C5\u5931\u8D25,\u4F60\u53EF\u4EE5\u81EA\u884C\u4ECE\u4EE5\u4E0B\u94FE\u63A5\u5B89\u88C5":"gum install error, you can install it yourself through"} ${i.default({color:"yellow",text:u,bold:!0})}`}))}}N(i.default({color:"green",text:e?"gum\u5B89\u88C5\u6210\u529F \u{1F389}":"gum install successfully \u{1F389}"}))}}const ge=de("yamljs");let O=[],F=null;const f=console.log,Q="__ccommand__split",d=process.env.PI_Lang==="zh";async function Z(){$e(d);const e=d?"\u5DF2\u53D6\u6D88":"Cancelled",t=d?"\u5F53\u524D\u76EE\u5F55\u4E0D\u5B58\u5728\u4EFB\u4F55\u5B50\u76EE\u5F55":"The current directory does not have any subdirectories",r=d?"\u8FD0\u884C\u6210\u529F":"run successfully",n=d?"\u8FD0\u884C\u5931\u8D25":"run error",u=process.argv.slice(2);if(u[0]==="-v"||u[0]==="--version")return f(i.default({text:d?`ccommand \u5F53\u524D\u7248\u672C: ${X}`:`ccommand Version: ${X}`,color:"green"}));if(u[0]==="-h"||u[0]==="--help"){const o=k(d?"\u6253\u5F00\u4E00\u4E2A\u65B0\u7684\u95EE\u9898":"open an issue","https://github.com/Simon-He95/ccommand/issues"),s=k(d?"\u2728\u5E2E\u52A9\u70B9\u4E00\u4E2A\u661F\u661F":"\u2728star it","https://github.com/Simon-He95/ccommand");return f(i.default({color:"white",text:`
5
+ ${i.default({bold:!0,text:"Common Commands:",bgColor:"blue"})}
6
+ ${i.default({text:`- ccommand -v \u67E5\u770B\u5F53\u524D\u7248\u672C
7
7
  - ccommand -help \u67E5\u770B\u5E2E\u52A9
8
8
  - ccommand \u6267\u884C\u5F53\u524Dpackage.json
9
9
  - ccommand find \u67E5\u627E\u5F53\u524Dworkspace\u7684\u6240\u6709\u76EE\u5F55
10
10
  `,color:"cyan"})}
11
- If you encounter any problems, you can ${a.default({color:"magenta",text:n})}.
12
- If you like it, please ${a.default({text:o,bold:!0,color:"cyan"})} `}))}const r=p.getPkgTool(),[t,u,l]=Ee(e);let c=t,F;if(e[0]==="find"){if(u)await O(r),c=b.filter(n=>n.includes(u))[0];else if(r==="yarn"){if(await O(r),!b.length)return d(a.default({color:"yellow",text:"\u5F53\u524D\u76EE\u5F55\u4E0D\u5B58\u5728\u4EFB\u4F55\u5B50\u76EE\u5F55"}));const{result:n}=p.jsShell(`echo ${b.join(",")} | sed "s/,/\\n/g" | gum filter --placeholder=" \u{1F914}${f?"\u8BF7\u9009\u62E9\u4E00\u4E2A\u8981\u6267\u884C\u7684\u76EE\u5F55":"Please select a directory to execute"}"`,"pipe");if(c=n,!c)return d(a.default({color:"yellow",text:f?"\u5DF2\u53D6\u6D88":"Cancelled"}))}else if(r==="pnpm"){if(await O(r),!b.length)return d(a.default({color:"yellow",text:f?"\u5F53\u524D\u76EE\u5F55\u4E0D\u5B58\u5728\u4EFB\u4F55\u5B50\u76EE\u5F55":"The current directory does not have any subdirectories"}));const{result:n}=p.jsShell(`echo ${b.join(",")} | sed "s/,/\\n/g" | gum filter --placeholder=" \u{1F914}${f?"\u8BF7\u9009\u62E9\u4E00\u4E2A\u8981\u6267\u884C\u7684\u76EE\u5F55":"Please select a directory to execute"}"`,"pipe");if(c=n.trim(),!c)return d(a.default({color:"yellow",text:f?"\u5DF2\u53D6\u6D88":"Cancelled"}))}else return d(a.default({color:"red",text:f?"find\u6307\u4EE4\u53EA\u80FD\u652F\u6301\u5728yarn\u6216pnpm\u7684monorepo\u6A21\u5F0F\u4E0B\u4F7F\u7528":"find command only support yarn or pnpm"}));F=await P()}else{if(F=await P(),t&&y&&!y[t]||!y)try{const n=(await p.getPkg("./package.json")||{})?.scripts;if(n&&n[e[0]])return d(a.default({text:`${f?"ccommand\u6B63\u5728\u6267\u884C":"ccommand is executing"} ${a.default({color:"cyan",text:`'${e[0]}'`})} \u{1F914} `,color:"yellow"})),M(e[0],e.slice(1).join(" "));if(n&&t){const o=$e(n,e[0]),$=e.slice(1).join(" ");return M(o,$)}}catch{}y&&!y[e[0]]&&(d(a.default({color:"red",text:`"${e[0]}" ${f?"\u5728\u5DE5\u4F5C\u533A\u3001\u5F53\u524D\u76EE\u5F55\u4E2D\u627E\u4E0D\u5230\u4EFB\u4F55\u53EF\u6267\u884C\u7684\u811A\u672C,\u8BF7\u68C0\u67E5":"is not found in workspace, current directory or current scripts, please check"}`})),process.exit())}if(!F)return d(a.default({color:"red",text:f?"\u627E\u4E0D\u5230\u4EFB\u4F55\u53EF\u6267\u884C\u811A\u672C":"No scripts found"}));const j=[];let h="";if(!u||e[0]==="find"&&(!e[2]||e[2].startsWith("--"))){const n=Object.keys(F).reduce(($,E)=>{const T=F[E];return j.push(E),$+=`"${E}: ${T.replace(/\"/g,"'")}"${W}`,$},""),{result:o}=p.jsShell(`echo ${n} | sed "s/${W}/\\n/g" | gum filter --placeholder=" \u{1F914}\u8BF7\u9009\u62E9\u4E00\u4E2A\u8981\u6267\u884C\u7684\u6307\u4EE4"`,"pipe");h=o.substring(0,o.indexOf(": "))}if(!u&&!h)return d(a.default({color:"yellow",text:f?"\u5DF2\u53D6\u6D88":"Cancelled"})),process.exit();const{status:J}=await p.jsShell(X());if(J===0)return d(a.default({color:"green",text:`
13
- command '${(e[0]==="find"?e[2]:e[1])||h}' ${f?"\u8FD0\u884C\u6210\u529F":"run successfully"} \u{1F389}`})),process.exit();d(a.default({color:"red",text:`
14
- command '${h}' ${f?"\u8FD0\u884C\u5931\u8D25":"run error"} \u274C`}));function L(n){return j.find(o=>o===n)??j.find(o=>n.startsWith(o))}function X(){let n="",o="";const $=r!=="yarn";r==="npm"?(o=l?` -- ${l}`:"",n=c?` --prefix ${c} `:" "):r==="pnpm"?(o=l?` ${l}`:"",n=c?` --filter ${c} `:" "):r==="yarn"?(o=l?` ${l}`:"",n=c?` workspace ${c} `:" "):r==="bun"&&(o=l?` ${l}`:"",n="");let E="";if(o&&!o.startsWith(" --")){const N=o.split(" ").filter(Boolean);E=N[0],o=N.slice(1).join(" ")}const T=`${r}${$?" run":" "}${n} ${E||(h?L(h)||h:u)} ${Q(o)?`-- ${o}`:o}`;return h=`${E||(h?L(h):u)}`,e[0]==="find"?d(a.default({text:`${f?"\u63D0\u793A":"tips"}: pfind ${c} ${h} ${o}`.replace(/\s+/g," "),color:"blue",bold:!0})):d(a.default({text:`${f?"\u63D0\u793A":"tips"}: prun ${h} ${o}`.replace(/\s+/g," "),color:"blue",bold:!0})),T}async function P(){try{if(!c||r==="bun"||r==="npm")return(await p.getPkg("./package.json"))?.scripts;if(r==="pnpm")return(await O(r))[c]||(await p.getPkg(`${c}/package.json`))?.scripts;if(r==="yarn")return(await O(r))[c]||(await p.getPkg(`${c}/package.json`))?.scripts}catch{}}function Q(n){return e[0]==="find",e[1]&&n}async function M(n,o){let $;switch(n&&e[0]!==n&&d(a.default({text:`\u{1F914} ${a.default({text:`'${e[0]}'`,color:"cyan"})} ${f?"\u81EA\u52A8\u7684\u4E3A\u60A8\u5339\u914D\u6210":"automatically match for you to"} ${a.default({text:`'${n}${o?` ${o}`:""}'`,color:"cyan"})} `,color:"yellow"})),r){case"npm":{const{status:E}=p.jsShell(`npm run ${n}${o?` -- ${o}`:""}`);$=E;break}case"pnpm":{const{status:E}=p.jsShell(`pnpm run ${n}${o?` ${o}`:""}`);$=E;break}case"yarn":{const{status:E}=p.jsShell(`yarn ${n}${o?` ${o}`:""}`);$=E;break}case"bun":{const{status:E}=p.jsShell(`bun ${n} ${o}`);$=E;break}}return d($===0?a.default({color:"green",text:`
15
- command '${n}${o?` ${o}`:""}' ${f?"\u6267\u884C\u6210\u529F":"run successfully"} \u{1F389}`}):a.default({color:"red",text:`
16
- command ${a.default({bold:!0,color:"cyan",text:`'${n||e[0]}${o?` ${o}`:""}'`})} ${f?"\u6267\u884C\u5931\u8D25":"run error"} \u274C`}))}}async function O(e){if(y)return y;const r=e==="pnpm"?await q.default.readFile(V.default.resolve(process.cwd(),"pnpm-workspace.yaml"),"utf-8"):await q.default.readFile(V.default.resolve(process.cwd(),"package.json"),"utf-8");let t;if(e==="pnpm")t=me.parse(r)?.packages||[];else{const u=JSON.parse(r)?.workspaces;p.isPlainObject(u)?t=u?.packages:t=u||[]}return y=await he(t)||{},b=Object.keys(y).filter(u=>y[u]&&Object.keys(y[u]).length),y}function Ee(e){const r=e[0];return r?r.startsWith("--")?["","",e.join(" ")]:e[1]&&e[1].startsWith("--")?[r,"",e.slice(1).join(" ")]:[r,e[1],e.slice(2).join(" ")]:["","",""]}async function he(e){if(!e.length)return;const r=await oe.default(e.map(t=>`${t}/package.json`),{dot:!0,ignore:["**/node_modules/**"]});return Promise.all(r.map(async t=>{const u=await p.getPkg(t);if(!u)return;const{name:l,scripts:c}=u;return{name:l,scripts:c}})).then(t=>t.reduce((u,l)=>{const{name:c,scripts:F}=l;return!c||!F||(u[c]=F),u},{}))}function $e(e,r){const t=Object.keys(e),u=t.find(l=>l.startsWith(r));if(u)return u;try{const l=new RegExp(r.split("").join("[_-\\w$.:]*"));return t.find(c=>l.test(c))}catch(l){d(a.default({text:`${f?"\u6B63\u5219\u9519\u8BEF":"RegExp error"}: ${l}`,color:"red"})),process.exit(1)}}K(),exports.ccommand=K;
11
+ If you encounter any problems, you can ${i.default({color:"magenta",text:o})}.
12
+ If you like it, please ${i.default({text:s,bold:!0,color:"cyan"})} `}))}const l=p.getPkgTool(),[R,_,w]=ye(u);let E=R,v;if(u[0]==="find"){if(_)await x(l),E=O.filter(o=>o.includes(_))[0];else if(l==="yarn"){if(await x(l),!O.length)return f(i.default({color:"yellow",text:t}));const{result:o}=p.jsShell(`echo ${O.join(",")} | sed "s/,/\\n/g" | gum filter --placeholder=" \u{1F914}${d?"\u8BF7\u9009\u62E9\u4E00\u4E2A\u8981\u6267\u884C\u7684\u76EE\u5F55":"Please select a directory to execute"}"`,"pipe");if(E=o,!E)return f(i.default({color:"yellow",text:e}))}else if(l==="pnpm"){if(await x(l),!O.length)return f(i.default({color:"yellow",text:t}));const{result:o}=p.jsShell(`echo ${O.join(",")} | sed "s/,/\\n/g" | gum filter --placeholder=" \u{1F914}${d?"\u8BF7\u9009\u62E9\u4E00\u4E2A\u8981\u6267\u884C\u7684\u76EE\u5F55":"Please select a directory to execute"}"`,"pipe");if(E=o.trim(),!E)return f(i.default({color:"yellow",text:e}))}else return f(i.default({color:"red",text:d?"find\u6307\u4EE4\u53EA\u80FD\u652F\u6301\u5728yarn\u6216pnpm\u7684monorepo\u6A21\u5F0F\u4E0B\u4F7F\u7528":"find command only support yarn or pnpm"}));v=await V()}else{if(v=await V(),R&&F&&!F[R]||!F)try{const o=(await p.getPkg("./package.json")||{})?.scripts;if(o&&o[u[0]])return f(i.default({text:`${d?"ccommand\u6B63\u5728\u6267\u884C":"ccommand is executing"} ${i.default({color:"cyan",text:`'${u[0]}'`})} \u{1F914} `,color:"yellow"})),G(u[0],u.slice(1).join(" "));if(o&&R){const s=we(o,u[0]),g=u.slice(1).join(" ");return G(s,g)}}catch{}F&&!F[u[0]]&&(f(i.default({color:"red",text:`"${u[0]}" ${d?"\u5728\u5DE5\u4F5C\u533A\u3001\u5F53\u524D\u76EE\u5F55\u4E2D\u627E\u4E0D\u5230\u4EFB\u4F55\u53EF\u6267\u884C\u7684\u811A\u672C,\u8BF7\u68C0\u67E5":"is not found in workspace, current directory or current scripts, please check"}`})),process.exit())}if(!v)return f(i.default({color:"red",text:d?"\u627E\u4E0D\u5230\u4EFB\u4F55\u53EF\u6267\u884C\u811A\u672C":"No scripts found"}));const B=[];let $="";if(!_||u[0]==="find"&&(!u[2]||u[2].startsWith("--"))){const o=Object.keys(v).reduce((g,h)=>{const I=v[h];return B.push(h),g+=`"${h}: ${I.replace(/\"/g,"'")}"${Q}`,g},""),{result:s}=p.jsShell(`echo ${o} | sed "s/${Q}/\\n/g" | gum filter --placeholder=" \u{1F914}\u8BF7\u9009\u62E9\u4E00\u4E2A\u8981\u6267\u884C\u7684\u6307\u4EE4"`,"pipe");$=s.substring(0,s.indexOf(": "))}if(!_&&!$)return f(i.default({color:"yellow",text:e})),process.exit();const{status:ee}=await p.jsShell(te());if(ee===0)return f(i.default({color:"green",text:`
13
+ command '${(u[0]==="find"?u[2]:u[1])||$}' ${r} \u{1F389}`})),process.exit();f(i.default({color:"red",text:`
14
+ command '${$}' ${n} \u274C`}));function q(o){return B.find(s=>s===o)??B.find(s=>o.startsWith(s))}function te(){let o="",s="";const g=l!=="yarn";l==="npm"?(s=w?` -- ${w}`:"",o=E?` --prefix ${E} `:" "):l==="pnpm"?(s=w?` ${w}`:"",o=E?` --filter ${E} `:" "):l==="yarn"?(s=w?` ${w}`:"",o=E?` workspace ${E} `:" "):l==="bun"&&(s=w?` ${w}`:"",o="");let h="";if(s&&!s.startsWith(" --")){const H=s.split(" ").filter(Boolean);h=H[0],s=H.slice(1).join(" ")}const I=`${l}${g?" run":" "}${o} ${h||($?q($)||$:_)} ${re(s)?`-- ${s}`:s}`;return $=`${h||($?q($):_)}`,u[0]==="find"?f(i.default({text:`${d?"\u63D0\u793A":"tips"}: pfind ${E} ${$} ${s}`.replace(/\s+/g," "),color:"blue",bold:!0})):f(i.default({text:`${d?"\u63D0\u793A":"tips"}: prun ${$} ${s}`.replace(/\s+/g," "),color:"blue",bold:!0})),I}async function V(){try{if(!E||l==="bun"||l==="npm")return(await p.getPkg("./package.json"))?.scripts;if(l==="pnpm")return(await x(l))[E]||(await p.getPkg(`${E}/package.json`))?.scripts;if(l==="yarn")return(await x(l))[E]||(await p.getPkg(`${E}/package.json`))?.scripts}catch{}}function re(o){return u[0]==="find",u[1]&&o}async function G(o,s){let g;switch(o&&u[0]!==o&&f(i.default({text:`\u{1F914} ${i.default({text:`'${u[0]}'`,color:"cyan"})} ${d?"\u81EA\u52A8\u7684\u4E3A\u60A8\u5339\u914D\u6210":"automatically match for you to"} ${i.default({text:`'${o}${s?` ${s}`:""}'`,color:"cyan"})} `,color:"yellow"})),l){case"npm":{const{status:h}=p.jsShell(`npm run ${o}${s?` -- ${s}`:""}`);g=h;break}case"pnpm":{const{status:h}=p.jsShell(`pnpm run ${o}${s?` ${s}`:""}`);g=h;break}case"yarn":{const{status:h}=p.jsShell(`yarn ${o}${s?` ${s}`:""}`);g=h;break}case"bun":{const{status:h}=p.jsShell(`bun ${o} ${s}`);g=h;break}}return f(g===0?i.default({color:"green",text:`
15
+ command '${o}${s?` ${s}`:""}' ${r} \u{1F389}`}):i.default({color:"red",text:`
16
+ command ${i.default({bold:!0,color:"cyan",text:`'${o||u[0]}${s?` ${s}`:""}'`})} ${n} \u274C`}))}}async function x(e){if(F)return F;let t="";try{t=e==="pnpm"?await Y.default.readFile(z.default.resolve(process.cwd(),"pnpm-workspace.yaml"),"utf-8"):await Y.default.readFile(z.default.resolve(process.cwd(),"package.json"),"utf-8")}catch{f(i.default({color:"red",text:d?"pfind\u547D\u4EE4\u9700\u8981\u8BFB\u53D6pnpm-workspace.yaml,\u5F53\u524D\u76EE\u5F55\u4E0B\u5E76\u4E0D\u5B58\u5728":"The pfind command needs to read pnpm-workspace.yaml, which does not exist in the current directory"})),process.exit(0)}let r;if(e==="pnpm")r=ge.parse(t)?.packages||[];else{const n=JSON.parse(t)?.workspaces;p.isPlainObject(n)?r=n?.packages:r=n||[]}return F=await Fe(r)||{},O=Object.keys(F).filter(n=>F[n]&&Object.keys(F[n]).length),F}function ye(e){const t=e[0];return t?t.startsWith("--")?["","",e.join(" ")]:e[1]&&e[1].startsWith("--")?[t,"",e.slice(1).join(" ")]:[t,e[1],e.slice(2).join(" ")]:["","",""]}async function Fe(e){if(!e.length)return;const t=await ce.default(e.map(r=>`${r}/package.json`),{dot:!0,ignore:["**/node_modules/**"]});return Promise.all(t.map(async r=>{const n=await p.getPkg(r);if(!n)return;const{name:u,scripts:l}=n;return{name:u,scripts:l}})).then(r=>r.reduce((n,u)=>{const{name:l,scripts:R}=u;return!l||!R||(n[l]=R),n},{}))}function we(e,t){const r=Object.keys(e),n=r.find(u=>u.startsWith(t));if(n)return n;try{const u=new RegExp(t.split("").join("[_-\\w$.:]*"));return r.find(l=>u.test(l))}catch(u){f(i.default({text:`${d?"\u6B63\u5219\u9519\u8BEF":"RegExp error"}: ${u}`,color:"red"})),process.exit(1)}}Z(),exports.ccommand=Z;
package/dist/index.mjs CHANGED
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as Z}from"module";import V from"fs/promises";import G from"path";import{jsShell as y,getPkgTool as ee,getPkg as b,isPlainObject as re}from"lazy-js-utils";import te from"fast-glob";import i from"@simon_he/colorize";import ue from"os";import ne from"tty";var oe=Z(import.meta.url);const c="\x1B[",O="\x1B]",R="\x07",B=";",H=process.env.TERM_PROGRAM==="Apple_Terminal",s={};s.cursorTo=(e,r)=>{if(typeof e!="number")throw new TypeError("The `x` argument is required");return typeof r!="number"?c+(e+1)+"G":c+(r+1)+";"+(e+1)+"H"},s.cursorMove=(e,r)=>{if(typeof e!="number")throw new TypeError("The `x` argument is required");let t="";return e<0?t+=c+-e+"D":e>0&&(t+=c+e+"C"),r<0?t+=c+-r+"A":r>0&&(t+=c+r+"B"),t},s.cursorUp=(e=1)=>c+e+"A",s.cursorDown=(e=1)=>c+e+"B",s.cursorForward=(e=1)=>c+e+"C",s.cursorBackward=(e=1)=>c+e+"D",s.cursorLeft=c+"G",s.cursorSavePosition=H?"\x1B7":c+"s",s.cursorRestorePosition=H?"\x1B8":c+"u",s.cursorGetPosition=c+"6n",s.cursorNextLine=c+"E",s.cursorPrevLine=c+"F",s.cursorHide=c+"?25l",s.cursorShow=c+"?25h",s.eraseLines=e=>{let r="";for(let t=0;t<e;t++)r+=s.eraseLine+(t<e-1?s.cursorUp():"");return e&&(r+=s.cursorLeft),r},s.eraseEndLine=c+"K",s.eraseStartLine=c+"1K",s.eraseLine=c+"2K",s.eraseDown=c+"J",s.eraseUp=c+"1J",s.eraseScreen=c+"2J",s.scrollUp=c+"S",s.scrollDown=c+"T",s.clearScreen="\x1Bc",s.clearTerminal=process.platform==="win32"?`${s.eraseScreen}${c}0f`:`${s.eraseScreen}${c}3J${c}H`,s.beep=R,s.link=(e,r)=>[O,"8",B,B,r,R,e,O,"8",B,B,R].join(""),s.image=(e,r={})=>{let t=`${O}1337;File=inline=1`;return r.width&&(t+=`;width=${r.width}`),r.height&&(t+=`;height=${r.height}`),r.preserveAspectRatio===!1&&(t+=";preserveAspectRatio=0"),t+":"+e.toString("base64")+R},s.iTerm={setCwd:(e=process.cwd())=>`${O}50;CurrentDir=${e}${R}`,annotation:(e,r={})=>{let t=`${O}1337;`;const u=typeof r.x<"u",a=typeof r.y<"u";if((u||a)&&!(u&&a&&typeof r.length<"u"))throw new Error("`x`, `y` and `length` must be defined when `x` or `y` is defined");return e=e.replace(/\|/g,""),t+=r.isHidden?"AddHiddenAnnotation=":"AddAnnotation=",r.length>0?t+=(u?[e,r.length,r.x,r.y]:[r.length,e]).join("|"):t+=e,t+R}};var Y=(e,r=process.argv)=>{const t=e.startsWith("-")?"":e.length===1?"-":"--",u=r.indexOf(t+e),a=r.indexOf("--");return u!==-1&&(a===-1||u<a)};const se=ue,W=ne,h=Y,{env:m}=process;let C;h("no-color")||h("no-colors")||h("color=false")||h("color=never")?C=0:(h("color")||h("colors")||h("color=true")||h("color=always"))&&(C=1),"FORCE_COLOR"in m&&(m.FORCE_COLOR==="true"?C=1:m.FORCE_COLOR==="false"?C=0:C=m.FORCE_COLOR.length===0?1:Math.min(parseInt(m.FORCE_COLOR,10),3));function x(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function I(e,r){if(C===0)return 0;if(h("color=16m")||h("color=full")||h("color=truecolor"))return 3;if(h("color=256"))return 2;if(e&&!r&&C===void 0)return 0;const t=C||0;if(m.TERM==="dumb")return t;if(process.platform==="win32"){const u=se.release().split(".");return Number(u[0])>=10&&Number(u[2])>=10586?Number(u[2])>=14931?3:2:1}if("CI"in m)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(u=>u in m)||m.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in m)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(m.TEAMCITY_VERSION)?1:0;if(m.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in m){const u=parseInt((m.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(m.TERM_PROGRAM){case"iTerm.app":return u>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(m.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(m.TERM)||"COLORTERM"in m?1:t}function ie(e){const r=I(e,e&&e.isTTY);return x(r)}var ce={supportsColor:ie,stdout:x(I(!0,W.isatty(1))),stderr:x(I(!0,W.isatty(2)))};const ae=ce,k=Y;function q(e){if(/^\d{3,4}$/.test(e)){const t=/(\d{1,2})(\d{2})/.exec(e);return{major:0,minor:parseInt(t[1],10),patch:parseInt(t[2],10)}}const r=(e||"").split(".").map(t=>parseInt(t,10));return{major:r[0],minor:r[1],patch:r[2]}}function v(e){const{env:r}=process;if("FORCE_HYPERLINK"in r)return!(r.FORCE_HYPERLINK.length>0&&parseInt(r.FORCE_HYPERLINK,10)===0);if(k("no-hyperlink")||k("no-hyperlinks")||k("hyperlink=false")||k("hyperlink=never"))return!1;if(k("hyperlink=true")||k("hyperlink=always")||"NETLIFY"in r)return!0;if(!ae.supportsColor(e)||e&&!e.isTTY||process.platform==="win32"||"CI"in r||"TEAMCITY_VERSION"in r)return!1;if("TERM_PROGRAM"in r){const t=q(r.TERM_PROGRAM_VERSION);switch(r.TERM_PROGRAM){case"iTerm.app":return t.major===3?t.minor>=1:t.major>3;case"WezTerm":return t.major>=20200620;case"vscode":return t.major>1||t.major===1&&t.minor>=72}}if("VTE_VERSION"in r){if(r.VTE_VERSION==="0.50.0")return!1;const t=q(r.VTE_VERSION);return t.major>0||t.minor>=50}return!1}var j={supportsHyperlink:v,stdout:v(process.stdout),stderr:v(process.stderr)};function w(e,r,{target:t="stdout",...u}={}){return j[t]?s.link(e,r):u.fallback===!1?e:typeof u.fallback=="function"?u.fallback(e,r):`${e} (\u200B${r}\u200B)`}w.isSupported=j.stdout,w.stderr=(e,r,t={})=>w(e,r,{target:"stderr",...t}),w.stderr.isSupported=j.stderr;var z="1.0.40";const S=console.log;function le(e){const{status:r}=y("gum -v","pipe");if(r!==0){S(i({color:"blue",text:e?"\u6B63\u5728\u4E3A\u60A8\u5B89\u88C5gum...":"install gum..."}));const{status:t}=y("brew install gum");if(t!==0){const{status:u}=y(`sudo mkdir -p /etc/apt/keyrings
2
+ import{createRequire as ue}from"module";import W from"fs/promises";import q from"path";import{jsShell as F,getPkgTool as ne,getPkg as B,isPlainObject as oe}from"lazy-js-utils";import se from"fast-glob";import c from"@simon_he/colorize";import ie from"os";import ce from"tty";var ae=ue(import.meta.url);const a="\x1B[",_="\x1B]",A="\x07",D=";",z=process.env.TERM_PROGRAM==="Apple_Terminal",i={};i.cursorTo=(e,r)=>{if(typeof e!="number")throw new TypeError("The `x` argument is required");return typeof r!="number"?a+(e+1)+"G":a+(r+1)+";"+(e+1)+"H"},i.cursorMove=(e,r)=>{if(typeof e!="number")throw new TypeError("The `x` argument is required");let t="";return e<0?t+=a+-e+"D":e>0&&(t+=a+e+"C"),r<0?t+=a+-r+"A":r>0&&(t+=a+r+"B"),t},i.cursorUp=(e=1)=>a+e+"A",i.cursorDown=(e=1)=>a+e+"B",i.cursorForward=(e=1)=>a+e+"C",i.cursorBackward=(e=1)=>a+e+"D",i.cursorLeft=a+"G",i.cursorSavePosition=z?"\x1B7":a+"s",i.cursorRestorePosition=z?"\x1B8":a+"u",i.cursorGetPosition=a+"6n",i.cursorNextLine=a+"E",i.cursorPrevLine=a+"F",i.cursorHide=a+"?25l",i.cursorShow=a+"?25h",i.eraseLines=e=>{let r="";for(let t=0;t<e;t++)r+=i.eraseLine+(t<e-1?i.cursorUp():"");return e&&(r+=i.cursorLeft),r},i.eraseEndLine=a+"K",i.eraseStartLine=a+"1K",i.eraseLine=a+"2K",i.eraseDown=a+"J",i.eraseUp=a+"1J",i.eraseScreen=a+"2J",i.scrollUp=a+"S",i.scrollDown=a+"T",i.clearScreen="\x1Bc",i.clearTerminal=process.platform==="win32"?`${i.eraseScreen}${a}0f`:`${i.eraseScreen}${a}3J${a}H`,i.beep=A,i.link=(e,r)=>[_,"8",D,D,r,A,e,_,"8",D,D,A].join(""),i.image=(e,r={})=>{let t=`${_}1337;File=inline=1`;return r.width&&(t+=`;width=${r.width}`),r.height&&(t+=`;height=${r.height}`),r.preserveAspectRatio===!1&&(t+=";preserveAspectRatio=0"),t+":"+e.toString("base64")+A},i.iTerm={setCwd:(e=process.cwd())=>`${_}50;CurrentDir=${e}${A}`,annotation:(e,r={})=>{let t=`${_}1337;`;const n=typeof r.x<"u",u=typeof r.y<"u";if((n||u)&&!(n&&u&&typeof r.length<"u"))throw new Error("`x`, `y` and `length` must be defined when `x` or `y` is defined");return e=e.replace(/\|/g,""),t+=r.isHidden?"AddHiddenAnnotation=":"AddAnnotation=",r.length>0?t+=(n?[e,r.length,r.x,r.y]:[r.length,e]).join("|"):t+=e,t+A}};var K=(e,r=process.argv)=>{const t=e.startsWith("-")?"":e.length===1?"-":"--",n=r.indexOf(t+e),u=r.indexOf("--");return n!==-1&&(u===-1||n<u)};const le=ie,U=ce,g=K,{env:m}=process;let C;g("no-color")||g("no-colors")||g("color=false")||g("color=never")?C=0:(g("color")||g("colors")||g("color=true")||g("color=always"))&&(C=1),"FORCE_COLOR"in m&&(m.FORCE_COLOR==="true"?C=1:m.FORCE_COLOR==="false"?C=0:C=m.FORCE_COLOR.length===0?1:Math.min(parseInt(m.FORCE_COLOR,10),3));function S(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function L(e,r){if(C===0)return 0;if(g("color=16m")||g("color=full")||g("color=truecolor"))return 3;if(g("color=256"))return 2;if(e&&!r&&C===void 0)return 0;const t=C||0;if(m.TERM==="dumb")return t;if(process.platform==="win32"){const n=le.release().split(".");return Number(n[0])>=10&&Number(n[2])>=10586?Number(n[2])>=14931?3:2:1}if("CI"in m)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(n=>n in m)||m.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in m)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(m.TEAMCITY_VERSION)?1:0;if(m.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in m){const n=parseInt((m.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(m.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(m.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(m.TERM)||"COLORTERM"in m?1:t}function fe(e){const r=L(e,e&&e.isTTY);return S(r)}var pe={supportsColor:fe,stdout:S(L(!0,U.isatty(1))),stderr:S(L(!0,U.isatty(2)))};const me=pe,b=K;function J(e){if(/^\d{3,4}$/.test(e)){const t=/(\d{1,2})(\d{2})/.exec(e);return{major:0,minor:parseInt(t[1],10),patch:parseInt(t[2],10)}}const r=(e||"").split(".").map(t=>parseInt(t,10));return{major:r[0],minor:r[1],patch:r[2]}}function M(e){const{env:r}=process;if("FORCE_HYPERLINK"in r)return!(r.FORCE_HYPERLINK.length>0&&parseInt(r.FORCE_HYPERLINK,10)===0);if(b("no-hyperlink")||b("no-hyperlinks")||b("hyperlink=false")||b("hyperlink=never"))return!1;if(b("hyperlink=true")||b("hyperlink=always")||"NETLIFY"in r)return!0;if(!me.supportsColor(e)||e&&!e.isTTY||process.platform==="win32"||"CI"in r||"TEAMCITY_VERSION"in r)return!1;if("TERM_PROGRAM"in r){const t=J(r.TERM_PROGRAM_VERSION);switch(r.TERM_PROGRAM){case"iTerm.app":return t.major===3?t.minor>=1:t.major>3;case"WezTerm":return t.major>=20200620;case"vscode":return t.major>1||t.major===1&&t.minor>=72}}if("VTE_VERSION"in r){if(r.VTE_VERSION==="0.50.0")return!1;const t=J(r.VTE_VERSION);return t.major>0||t.minor>=50}return!1}var P={supportsHyperlink:M,stdout:M(process.stdout),stderr:M(process.stderr)};function k(e,r,{target:t="stdout",...n}={}){return P[t]?i.link(e,r):n.fallback===!1?e:typeof n.fallback=="function"?n.fallback(e,r):`${e} (\u200B${r}\u200B)`}k.isSupported=P.stdout,k.stderr=(e,r,t={})=>k(e,r,{target:"stderr",...t}),k.stderr.isSupported=P.stderr;var X="1.0.41";const N=console.log;function de(e){const{status:r}=F("gum -v","pipe");if(r!==0){N(c({color:"blue",text:e?"\u6B63\u5728\u4E3A\u60A8\u5B89\u88C5gum...":"install gum..."}));const{status:t}=F("brew install gum");if(t!==0){const{status:n}=F(`sudo mkdir -p /etc/apt/keyrings
3
3
  curl -fsSL https://repo.charm.sh/apt/gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/charm.gpg
4
4
  echo "deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" | sudo tee /etc/apt/sources.list.d/charm.list
5
- sudo apt update && sudo apt install gum`);if(u!==0){const a=w(e?"gum\u5B98\u7F51\u94FE\u63A5":"the official website of gum","https://github.com/charmbracelet/gum#installation");return S(i({color:"red",text:`${e?"gum\u5B89\u88C5\u5931\u8D25,\u4F60\u53EF\u4EE5\u81EA\u884C\u4ECE\u4EE5\u4E0B\u94FE\u63A5\u5B89\u88C5":"gum install error, you can install it yourself through"} ${i({color:"yellow",text:a,bold:!0})}`}))}}S(i({color:"green",text:e?"gum\u5B89\u88C5\u6210\u529F \u{1F389}":"gum install successfully \u{1F389}"}))}}const fe=oe("yamljs");let A=[],g=null;const p=console.log,K="__ccommand__split",f=process.env.PI_Lang==="zh";async function U(){le(f);const e=process.argv.slice(2);if(e[0]==="-v"||e[0]==="--version")return p(i({text:f?`ccommand \u5F53\u524D\u7248\u672C: ${z}`:`ccommand Version: ${z}`,color:"green"}));if(e[0]==="-h"||e[0]==="--help"){const n=w(f?"\u6253\u5F00\u4E00\u4E2A\u65B0\u7684\u95EE\u9898":"open an issue","https://github.com/Simon-He95/ccommand/issues"),o=w(f?"\u2728\u5E2E\u52A9\u70B9\u4E00\u4E2A\u661F\u661F":"\u2728star it","https://github.com/Simon-He95/ccommand");return p(i({color:"white",text:`
6
- ${i({bold:!0,text:"Common Commands:",bgColor:"blue"})}
7
- ${i({text:`- ccommand -v \u67E5\u770B\u5F53\u524D\u7248\u672C
5
+ sudo apt update && sudo apt install gum`);if(n!==0){const u=k(e?"gum\u5B98\u7F51\u94FE\u63A5":"the official website of gum","https://github.com/charmbracelet/gum#installation");return N(c({color:"red",text:`${e?"gum\u5B89\u88C5\u5931\u8D25,\u4F60\u53EF\u4EE5\u81EA\u884C\u4ECE\u4EE5\u4E0B\u94FE\u63A5\u5B89\u88C5":"gum install error, you can install it yourself through"} ${c({color:"yellow",text:u,bold:!0})}`}))}}N(c({color:"green",text:e?"gum\u5B89\u88C5\u6210\u529F \u{1F389}":"gum install successfully \u{1F389}"}))}}const Ee=ae("yamljs");let O=[],y=null;const f=console.log,Q="__ccommand__split",p=process.env.PI_Lang==="zh";async function Z(){de(p);const e=p?"\u5DF2\u53D6\u6D88":"Cancelled",r=p?"\u5F53\u524D\u76EE\u5F55\u4E0D\u5B58\u5728\u4EFB\u4F55\u5B50\u76EE\u5F55":"The current directory does not have any subdirectories",t=p?"\u8FD0\u884C\u6210\u529F":"run successfully",n=p?"\u8FD0\u884C\u5931\u8D25":"run error",u=process.argv.slice(2);if(u[0]==="-v"||u[0]==="--version")return f(c({text:p?`ccommand \u5F53\u524D\u7248\u672C: ${X}`:`ccommand Version: ${X}`,color:"green"}));if(u[0]==="-h"||u[0]==="--help"){const o=k(p?"\u6253\u5F00\u4E00\u4E2A\u65B0\u7684\u95EE\u9898":"open an issue","https://github.com/Simon-He95/ccommand/issues"),s=k(p?"\u2728\u5E2E\u52A9\u70B9\u4E00\u4E2A\u661F\u661F":"\u2728star it","https://github.com/Simon-He95/ccommand");return f(c({color:"white",text:`
6
+ ${c({bold:!0,text:"Common Commands:",bgColor:"blue"})}
7
+ ${c({text:`- ccommand -v \u67E5\u770B\u5F53\u524D\u7248\u672C
8
8
  - ccommand -help \u67E5\u770B\u5E2E\u52A9
9
9
  - ccommand \u6267\u884C\u5F53\u524Dpackage.json
10
10
  - ccommand find \u67E5\u627E\u5F53\u524Dworkspace\u7684\u6240\u6709\u76EE\u5F55
11
11
  `,color:"cyan"})}
12
- If you encounter any problems, you can ${i({color:"magenta",text:n})}.
13
- If you like it, please ${i({text:o,bold:!0,color:"cyan"})} `}))}const r=ee(),[t,u,a]=pe(e);let l=t,F;if(e[0]==="find"){if(u)await T(r),l=A.filter(n=>n.includes(u))[0];else if(r==="yarn"){if(await T(r),!A.length)return p(i({color:"yellow",text:"\u5F53\u524D\u76EE\u5F55\u4E0D\u5B58\u5728\u4EFB\u4F55\u5B50\u76EE\u5F55"}));const{result:n}=y(`echo ${A.join(",")} | sed "s/,/\\n/g" | gum filter --placeholder=" \u{1F914}${f?"\u8BF7\u9009\u62E9\u4E00\u4E2A\u8981\u6267\u884C\u7684\u76EE\u5F55":"Please select a directory to execute"}"`,"pipe");if(l=n,!l)return p(i({color:"yellow",text:f?"\u5DF2\u53D6\u6D88":"Cancelled"}))}else if(r==="pnpm"){if(await T(r),!A.length)return p(i({color:"yellow",text:f?"\u5F53\u524D\u76EE\u5F55\u4E0D\u5B58\u5728\u4EFB\u4F55\u5B50\u76EE\u5F55":"The current directory does not have any subdirectories"}));const{result:n}=y(`echo ${A.join(",")} | sed "s/,/\\n/g" | gum filter --placeholder=" \u{1F914}${f?"\u8BF7\u9009\u62E9\u4E00\u4E2A\u8981\u6267\u884C\u7684\u76EE\u5F55":"Please select a directory to execute"}"`,"pipe");if(l=n.trim(),!l)return p(i({color:"yellow",text:f?"\u5DF2\u53D6\u6D88":"Cancelled"}))}else return p(i({color:"red",text:f?"find\u6307\u4EE4\u53EA\u80FD\u652F\u6301\u5728yarn\u6216pnpm\u7684monorepo\u6A21\u5F0F\u4E0B\u4F7F\u7528":"find command only support yarn or pnpm"}));F=await M()}else{if(F=await M(),t&&g&&!g[t]||!g)try{const n=(await b("./package.json")||{})?.scripts;if(n&&n[e[0]])return p(i({text:`${f?"ccommand\u6B63\u5728\u6267\u884C":"ccommand is executing"} ${i({color:"cyan",text:`'${e[0]}'`})} \u{1F914} `,color:"yellow"})),P(e[0],e.slice(1).join(" "));if(n&&t){const o=de(n,e[0]),$=e.slice(1).join(" ");return P(o,$)}}catch{}g&&!g[e[0]]&&(p(i({color:"red",text:`"${e[0]}" ${f?"\u5728\u5DE5\u4F5C\u533A\u3001\u5F53\u524D\u76EE\u5F55\u4E2D\u627E\u4E0D\u5230\u4EFB\u4F55\u53EF\u6267\u884C\u7684\u811A\u672C,\u8BF7\u68C0\u67E5":"is not found in workspace, current directory or current scripts, please check"}`})),process.exit())}if(!F)return p(i({color:"red",text:f?"\u627E\u4E0D\u5230\u4EFB\u4F55\u53EF\u6267\u884C\u811A\u672C":"No scripts found"}));const D=[];let E="";if(!u||e[0]==="find"&&(!e[2]||e[2].startsWith("--"))){const n=Object.keys(F).reduce(($,d)=>{const _=F[d];return D.push(d),$+=`"${d}: ${_.replace(/\"/g,"'")}"${K}`,$},""),{result:o}=y(`echo ${n} | sed "s/${K}/\\n/g" | gum filter --placeholder=" \u{1F914}\u8BF7\u9009\u62E9\u4E00\u4E2A\u8981\u6267\u884C\u7684\u6307\u4EE4"`,"pipe");E=o.substring(0,o.indexOf(": "))}if(!u&&!E)return p(i({color:"yellow",text:f?"\u5DF2\u53D6\u6D88":"Cancelled"})),process.exit();const{status:J}=await y(X());if(J===0)return p(i({color:"green",text:`
14
- command '${(e[0]==="find"?e[2]:e[1])||E}' ${f?"\u8FD0\u884C\u6210\u529F":"run successfully"} \u{1F389}`})),process.exit();p(i({color:"red",text:`
15
- command '${E}' ${f?"\u8FD0\u884C\u5931\u8D25":"run error"} \u274C`}));function L(n){return D.find(o=>o===n)??D.find(o=>n.startsWith(o))}function X(){let n="",o="";const $=r!=="yarn";r==="npm"?(o=a?` -- ${a}`:"",n=l?` --prefix ${l} `:" "):r==="pnpm"?(o=a?` ${a}`:"",n=l?` --filter ${l} `:" "):r==="yarn"?(o=a?` ${a}`:"",n=l?` workspace ${l} `:" "):r==="bun"&&(o=a?` ${a}`:"",n="");let d="";if(o&&!o.startsWith(" --")){const N=o.split(" ").filter(Boolean);d=N[0],o=N.slice(1).join(" ")}const _=`${r}${$?" run":" "}${n} ${d||(E?L(E)||E:u)} ${Q(o)?`-- ${o}`:o}`;return E=`${d||(E?L(E):u)}`,e[0]==="find"?p(i({text:`${f?"\u63D0\u793A":"tips"}: pfind ${l} ${E} ${o}`.replace(/\s+/g," "),color:"blue",bold:!0})):p(i({text:`${f?"\u63D0\u793A":"tips"}: prun ${E} ${o}`.replace(/\s+/g," "),color:"blue",bold:!0})),_}async function M(){try{if(!l||r==="bun"||r==="npm")return(await b("./package.json"))?.scripts;if(r==="pnpm")return(await T(r))[l]||(await b(`${l}/package.json`))?.scripts;if(r==="yarn")return(await T(r))[l]||(await b(`${l}/package.json`))?.scripts}catch{}}function Q(n){return e[0]==="find",e[1]&&n}async function P(n,o){let $;switch(n&&e[0]!==n&&p(i({text:`\u{1F914} ${i({text:`'${e[0]}'`,color:"cyan"})} ${f?"\u81EA\u52A8\u7684\u4E3A\u60A8\u5339\u914D\u6210":"automatically match for you to"} ${i({text:`'${n}${o?` ${o}`:""}'`,color:"cyan"})} `,color:"yellow"})),r){case"npm":{const{status:d}=y(`npm run ${n}${o?` -- ${o}`:""}`);$=d;break}case"pnpm":{const{status:d}=y(`pnpm run ${n}${o?` ${o}`:""}`);$=d;break}case"yarn":{const{status:d}=y(`yarn ${n}${o?` ${o}`:""}`);$=d;break}case"bun":{const{status:d}=y(`bun ${n} ${o}`);$=d;break}}return p($===0?i({color:"green",text:`
16
- command '${n}${o?` ${o}`:""}' ${f?"\u6267\u884C\u6210\u529F":"run successfully"} \u{1F389}`}):i({color:"red",text:`
17
- command ${i({bold:!0,color:"cyan",text:`'${n||e[0]}${o?` ${o}`:""}'`})} ${f?"\u6267\u884C\u5931\u8D25":"run error"} \u274C`}))}}async function T(e){if(g)return g;const r=e==="pnpm"?await V.readFile(G.resolve(process.cwd(),"pnpm-workspace.yaml"),"utf-8"):await V.readFile(G.resolve(process.cwd(),"package.json"),"utf-8");let t;if(e==="pnpm")t=fe.parse(r)?.packages||[];else{const u=JSON.parse(r)?.workspaces;re(u)?t=u?.packages:t=u||[]}return g=await me(t)||{},A=Object.keys(g).filter(u=>g[u]&&Object.keys(g[u]).length),g}function pe(e){const r=e[0];return r?r.startsWith("--")?["","",e.join(" ")]:e[1]&&e[1].startsWith("--")?[r,"",e.slice(1).join(" ")]:[r,e[1],e.slice(2).join(" ")]:["","",""]}async function me(e){if(!e.length)return;const r=await te(e.map(t=>`${t}/package.json`),{dot:!0,ignore:["**/node_modules/**"]});return Promise.all(r.map(async t=>{const u=await b(t);if(!u)return;const{name:a,scripts:l}=u;return{name:a,scripts:l}})).then(t=>t.reduce((u,a)=>{const{name:l,scripts:F}=a;return!l||!F||(u[l]=F),u},{}))}function de(e,r){const t=Object.keys(e),u=t.find(a=>a.startsWith(r));if(u)return u;try{const a=new RegExp(r.split("").join("[_-\\w$.:]*"));return t.find(l=>a.test(l))}catch(a){p(i({text:`${f?"\u6B63\u5219\u9519\u8BEF":"RegExp error"}: ${a}`,color:"red"})),process.exit(1)}}U();export{U as ccommand};
12
+ If you encounter any problems, you can ${c({color:"magenta",text:o})}.
13
+ If you like it, please ${c({text:s,bold:!0,color:"cyan"})} `}))}const l=ne(),[R,T,w]=he(u);let d=R,x;if(u[0]==="find"){if(T)await I(l),d=O.filter(o=>o.includes(T))[0];else if(l==="yarn"){if(await I(l),!O.length)return f(c({color:"yellow",text:r}));const{result:o}=F(`echo ${O.join(",")} | sed "s/,/\\n/g" | gum filter --placeholder=" \u{1F914}${p?"\u8BF7\u9009\u62E9\u4E00\u4E2A\u8981\u6267\u884C\u7684\u76EE\u5F55":"Please select a directory to execute"}"`,"pipe");if(d=o,!d)return f(c({color:"yellow",text:e}))}else if(l==="pnpm"){if(await I(l),!O.length)return f(c({color:"yellow",text:r}));const{result:o}=F(`echo ${O.join(",")} | sed "s/,/\\n/g" | gum filter --placeholder=" \u{1F914}${p?"\u8BF7\u9009\u62E9\u4E00\u4E2A\u8981\u6267\u884C\u7684\u76EE\u5F55":"Please select a directory to execute"}"`,"pipe");if(d=o.trim(),!d)return f(c({color:"yellow",text:e}))}else return f(c({color:"red",text:p?"find\u6307\u4EE4\u53EA\u80FD\u652F\u6301\u5728yarn\u6216pnpm\u7684monorepo\u6A21\u5F0F\u4E0B\u4F7F\u7528":"find command only support yarn or pnpm"}));x=await G()}else{if(x=await G(),R&&y&&!y[R]||!y)try{const o=(await B("./package.json")||{})?.scripts;if(o&&o[u[0]])return f(c({text:`${p?"ccommand\u6B63\u5728\u6267\u884C":"ccommand is executing"} ${c({color:"cyan",text:`'${u[0]}'`})} \u{1F914} `,color:"yellow"})),H(u[0],u.slice(1).join(" "));if(o&&R){const s=ge(o,u[0]),$=u.slice(1).join(" ");return H(s,$)}}catch{}y&&!y[u[0]]&&(f(c({color:"red",text:`"${u[0]}" ${p?"\u5728\u5DE5\u4F5C\u533A\u3001\u5F53\u524D\u76EE\u5F55\u4E2D\u627E\u4E0D\u5230\u4EFB\u4F55\u53EF\u6267\u884C\u7684\u811A\u672C,\u8BF7\u68C0\u67E5":"is not found in workspace, current directory or current scripts, please check"}`})),process.exit())}if(!x)return f(c({color:"red",text:p?"\u627E\u4E0D\u5230\u4EFB\u4F55\u53EF\u6267\u884C\u811A\u672C":"No scripts found"}));const v=[];let h="";if(!T||u[0]==="find"&&(!u[2]||u[2].startsWith("--"))){const o=Object.keys(x).reduce(($,E)=>{const j=x[E];return v.push(E),$+=`"${E}: ${j.replace(/\"/g,"'")}"${Q}`,$},""),{result:s}=F(`echo ${o} | sed "s/${Q}/\\n/g" | gum filter --placeholder=" \u{1F914}\u8BF7\u9009\u62E9\u4E00\u4E2A\u8981\u6267\u884C\u7684\u6307\u4EE4"`,"pipe");h=s.substring(0,s.indexOf(": "))}if(!T&&!h)return f(c({color:"yellow",text:e})),process.exit();const{status:ee}=await F(re());if(ee===0)return f(c({color:"green",text:`
14
+ command '${(u[0]==="find"?u[2]:u[1])||h}' ${t} \u{1F389}`})),process.exit();f(c({color:"red",text:`
15
+ command '${h}' ${n} \u274C`}));function V(o){return v.find(s=>s===o)??v.find(s=>o.startsWith(s))}function re(){let o="",s="";const $=l!=="yarn";l==="npm"?(s=w?` -- ${w}`:"",o=d?` --prefix ${d} `:" "):l==="pnpm"?(s=w?` ${w}`:"",o=d?` --filter ${d} `:" "):l==="yarn"?(s=w?` ${w}`:"",o=d?` workspace ${d} `:" "):l==="bun"&&(s=w?` ${w}`:"",o="");let E="";if(s&&!s.startsWith(" --")){const Y=s.split(" ").filter(Boolean);E=Y[0],s=Y.slice(1).join(" ")}const j=`${l}${$?" run":" "}${o} ${E||(h?V(h)||h:T)} ${te(s)?`-- ${s}`:s}`;return h=`${E||(h?V(h):T)}`,u[0]==="find"?f(c({text:`${p?"\u63D0\u793A":"tips"}: pfind ${d} ${h} ${s}`.replace(/\s+/g," "),color:"blue",bold:!0})):f(c({text:`${p?"\u63D0\u793A":"tips"}: prun ${h} ${s}`.replace(/\s+/g," "),color:"blue",bold:!0})),j}async function G(){try{if(!d||l==="bun"||l==="npm")return(await B("./package.json"))?.scripts;if(l==="pnpm")return(await I(l))[d]||(await B(`${d}/package.json`))?.scripts;if(l==="yarn")return(await I(l))[d]||(await B(`${d}/package.json`))?.scripts}catch{}}function te(o){return u[0]==="find",u[1]&&o}async function H(o,s){let $;switch(o&&u[0]!==o&&f(c({text:`\u{1F914} ${c({text:`'${u[0]}'`,color:"cyan"})} ${p?"\u81EA\u52A8\u7684\u4E3A\u60A8\u5339\u914D\u6210":"automatically match for you to"} ${c({text:`'${o}${s?` ${s}`:""}'`,color:"cyan"})} `,color:"yellow"})),l){case"npm":{const{status:E}=F(`npm run ${o}${s?` -- ${s}`:""}`);$=E;break}case"pnpm":{const{status:E}=F(`pnpm run ${o}${s?` ${s}`:""}`);$=E;break}case"yarn":{const{status:E}=F(`yarn ${o}${s?` ${s}`:""}`);$=E;break}case"bun":{const{status:E}=F(`bun ${o} ${s}`);$=E;break}}return f($===0?c({color:"green",text:`
16
+ command '${o}${s?` ${s}`:""}' ${t} \u{1F389}`}):c({color:"red",text:`
17
+ command ${c({bold:!0,color:"cyan",text:`'${o||u[0]}${s?` ${s}`:""}'`})} ${n} \u274C`}))}}async function I(e){if(y)return y;let r="";try{r=e==="pnpm"?await W.readFile(q.resolve(process.cwd(),"pnpm-workspace.yaml"),"utf-8"):await W.readFile(q.resolve(process.cwd(),"package.json"),"utf-8")}catch{f(c({color:"red",text:p?"pfind\u547D\u4EE4\u9700\u8981\u8BFB\u53D6pnpm-workspace.yaml,\u5F53\u524D\u76EE\u5F55\u4E0B\u5E76\u4E0D\u5B58\u5728":"The pfind command needs to read pnpm-workspace.yaml, which does not exist in the current directory"})),process.exit(0)}let t;if(e==="pnpm")t=Ee.parse(r)?.packages||[];else{const n=JSON.parse(r)?.workspaces;oe(n)?t=n?.packages:t=n||[]}return y=await $e(t)||{},O=Object.keys(y).filter(n=>y[n]&&Object.keys(y[n]).length),y}function he(e){const r=e[0];return r?r.startsWith("--")?["","",e.join(" ")]:e[1]&&e[1].startsWith("--")?[r,"",e.slice(1).join(" ")]:[r,e[1],e.slice(2).join(" ")]:["","",""]}async function $e(e){if(!e.length)return;const r=await se(e.map(t=>`${t}/package.json`),{dot:!0,ignore:["**/node_modules/**"]});return Promise.all(r.map(async t=>{const n=await B(t);if(!n)return;const{name:u,scripts:l}=n;return{name:u,scripts:l}})).then(t=>t.reduce((n,u)=>{const{name:l,scripts:R}=u;return!l||!R||(n[l]=R),n},{}))}function ge(e,r){const t=Object.keys(e),n=t.find(u=>u.startsWith(r));if(n)return n;try{const u=new RegExp(r.split("").join("[_-\\w$.:]*"));return t.find(l=>u.test(l))}catch(u){f(c({text:`${p?"\u6B63\u5219\u9519\u8BEF":"RegExp error"}: ${u}`,color:"red"})),process.exit(1)}}Z();export{Z as ccommand};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccommand",
3
- "version": "1.0.40",
3
+ "version": "1.0.41",
4
4
  "packageManager": "pnpm@6.32.3",
5
5
  "description": "ccommand",
6
6
  "author": "Simon He",