@simon_he/pi 0.0.22 → 0.0.23
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.cjs +2 -2
- package/dist/index.js +2 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -49,9 +49,9 @@ Minimum version required to store current data is: `+i+`.
|
|
|
49
49
|
`);return i!==-1&&(t=Yp(t,n,u,i)),u+t+n};Object.defineProperties(D0.prototype,Ys);var gy=D0(),E5=D0({level:Zp?Zp.level:0});var ta=gy;var Sf=lu(require("process"),1);var sg=lu(require("process"),1),lg=lu(tg(),1),cg=lu(og(),1),my=(0,lg.default)(()=>{(0,cg.default)(()=>{sg.default.stderr.write("\x1B[?25h")},{alwaysLast:!0})}),fg=my;var Bl=!1,Ks={};Ks.show=(e=Sf.default.stderr)=>{!e.isTTY||(Bl=!1,e.write("\x1B[?25h"))};Ks.hide=(e=Sf.default.stderr)=>{!e.isTTY||(fg(),Bl=!0,e.write("\x1B[?25l"))};Ks.toggle=(e,t)=>{e!==void 0&&(Bl=e),Bl?Ks.show(t):Ks.hide(t)};var Cf=Ks;var W0=lu(gg(),1);var Yu=lu(require("process"),1);function L0(){return Yu.default.platform!=="win32"?Yu.default.env.TERM!=="linux":Boolean(Yu.default.env.CI)||Boolean(Yu.default.env.WT_SESSION)||Boolean(Yu.default.env.TERMINUS_SUBLIME)||Yu.default.env.ConEmuTask==="{cmd::Cmder}"||Yu.default.env.TERM_PROGRAM==="Terminus-Sublime"||Yu.default.env.TERM_PROGRAM==="vscode"||Yu.default.env.TERM==="xterm-256color"||Yu.default.env.TERM==="alacritty"||Yu.default.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var xy={info:ta.blue("\u2139"),success:ta.green("\u2714"),warning:ta.yellow("\u26A0"),error:ta.red("\u2716")},vy={info:ta.blue("i"),success:ta.green("\u221A"),warning:ta.yellow("\u203C"),error:ta.red("\xD7")},wy=L0()?xy:vy,N0=wy;function If({onlyFirst:e=!1}={}){let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}function Mf(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(If(),"")}var R2=lu(Tg(),1);function Of({stream:e=process.stdout}={}){return Boolean(e&&e.isTTY&&process.env.TERM!=="dumb"&&!("CI"in process.env))}var Ju=lu(require("process"),1),L2=lu(require("readline"),1),N2=lu(O2(),1);var Ix=3,va,G0,u0,Ha,ec=class{constructor(){wu(this,va,0);wu(this,G0,new N2.BufferListStream);wu(this,u0,void 0);wu(this,Ha,void 0);Me(this,G0).pipe(Ju.default.stdout);let t=this;nu(this,u0,function(r,u,...n){let{stdin:i}=Ju.default;if(Me(t,va)>0||i.emit===Me(t,u0)){if(r==="keypress")return;r==="data"&&u.includes(Ix)&&Ju.default.emit("SIGINT"),Reflect.apply(Me(t,u0),this,[r,u,...n])}else Reflect.apply(Ju.default.stdin.emit,this,[r,u,...n])})}start(){l0(this,va)._++,Me(this,va)===1&&this._realStart()}stop(){if(Me(this,va)<=0)throw new Error("`stop` called more times than `start`");l0(this,va)._--,Me(this,va)===0&&this._realStop()}_realStart(){Ju.default.platform!=="win32"&&(nu(this,Ha,L2.default.createInterface({input:Ju.default.stdin,output:Me(this,G0)})),Me(this,Ha).on("SIGINT",()=>{Ju.default.listenerCount("SIGINT")===0?Ju.default.emit("SIGINT"):(Me(this,Ha).close(),Ju.default.kill(Ju.default.pid,"SIGINT"))}))}_realStop(){Ju.default.platform!=="win32"&&(Me(this,Ha).close(),nu(this,Ha,void 0))}};va=new WeakMap,G0=new WeakMap,u0=new WeakMap,Ha=new WeakMap;var tc,za,n0,As,wa,Su,da,Du,Ss,i0,ha,pa,ga,a0,ua,ld=class{constructor(t){wu(this,za,0);wu(this,n0,!1);wu(this,As,0);wu(this,wa,0);wu(this,Su,void 0);wu(this,da,void 0);wu(this,Du,void 0);wu(this,Ss,void 0);wu(this,i0,void 0);wu(this,ha,void 0);wu(this,pa,void 0);wu(this,ga,void 0);wu(this,a0,void 0);wu(this,ua,void 0);ou(this,"color");tc||(tc=new ec),typeof t=="string"&&(t={text:t}),nu(this,Su,{color:"cyan",stream:V0.default.stderr,discardStdin:!0,hideCursor:!0,...t}),this.color=Me(this,Su).color,this.spinner=Me(this,Su).spinner,nu(this,i0,Me(this,Su).interval),nu(this,Du,Me(this,Su).stream),nu(this,ha,typeof Me(this,Su).isEnabled=="boolean"?Me(this,Su).isEnabled:Of({stream:Me(this,Du)})),nu(this,pa,typeof Me(this,Su).isSilent=="boolean"?Me(this,Su).isSilent:!1),this.text=Me(this,Su).text,this.prefixText=Me(this,Su).prefixText,this.indent=Me(this,Su).indent,V0.default.env.NODE_ENV==="test"&&(this._stream=Me(this,Du),this._isEnabled=Me(this,ha),Object.defineProperty(this,"_linesToClear",{get(){return Me(this,za)},set(r){nu(this,za,r)}}),Object.defineProperty(this,"_frameIndex",{get(){return Me(this,wa)}}),Object.defineProperty(this,"_lineCount",{get(){return Me(this,As)}}))}get indent(){return Me(this,ga)}set indent(t=0){if(!(t>=0&&Number.isInteger(t)))throw new Error("The `indent` option must be an integer from 0 and up");nu(this,ga,t),this.updateLineCount()}get interval(){return Me(this,i0)||Me(this,da).interval||100}get spinner(){return Me(this,da)}set spinner(t){if(nu(this,wa,0),nu(this,i0,void 0),typeof t=="object"){if(t.frames===void 0)throw new Error("The given spinner must have a `frames` property");nu(this,da,t)}else if(!L0())nu(this,da,W0.default.line);else if(t===void 0)nu(this,da,W0.default.dots);else if(t!=="default"&&W0.default[t])nu(this,da,W0.default[t]);else throw new Error(`There is no built-in spinner named '${t}'. See https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json for a full list.`)}get text(){return Me(this,a0)}set text(t){nu(this,a0,t||""),this.updateLineCount()}get prefixText(){return Me(this,ua)}set prefixText(t){nu(this,ua,t||""),this.updateLineCount()}get isSpinning(){return Me(this,Ss)!==void 0}getFullPrefixText(t=Me(this,ua),r=" "){return typeof t=="string"&&t!==""?t+r:typeof t=="function"?t()+r:""}updateLineCount(){let t=Me(this,Du).columns||80,r=this.getFullPrefixText(Me(this,ua),"-");nu(this,As,0);for(let u of Mf(" ".repeat(Me(this,ga))+r+"--"+Me(this,a0)).split(`
|
|
50
50
|
`))nu(this,As,Me(this,As)+Math.max(1,Math.ceil((0,R2.default)(u)/t)))}get isEnabled(){return Me(this,ha)&&!Me(this,pa)}set isEnabled(t){if(typeof t!="boolean")throw new TypeError("The `isEnabled` option must be a boolean");nu(this,ha,t)}get isSilent(){return Me(this,pa)}set isSilent(t){if(typeof t!="boolean")throw new TypeError("The `isSilent` option must be a boolean");nu(this,pa,t)}frame(){let{frames:t}=Me(this,da),r=t[Me(this,wa)];this.color&&(r=ta[this.color](r)),nu(this,wa,++l0(this,wa)._%t.length);let u=typeof Me(this,ua)=="string"&&Me(this,ua)!==""?Me(this,ua)+" ":"",n=typeof this.text=="string"?" "+this.text:"";return u+r+n}clear(){if(!Me(this,ha)||!Me(this,Du).isTTY)return this;Me(this,Du).cursorTo(0);for(let t=0;t<Me(this,za);t++)t>0&&Me(this,Du).moveCursor(0,-1),Me(this,Du).clearLine(1);return(Me(this,ga)||this.lastIndent!==Me(this,ga))&&Me(this,Du).cursorTo(Me(this,ga)),this.lastIndent=Me(this,ga),nu(this,za,0),this}render(){return Me(this,pa)?this:(this.clear(),Me(this,Du).write(this.frame()),nu(this,za,Me(this,As)),this)}start(t){return t&&(this.text=t),Me(this,pa)?this:Me(this,ha)?this.isSpinning?this:(Me(this,Su).hideCursor&&Cf.hide(Me(this,Du)),Me(this,Su).discardStdin&&V0.default.stdin.isTTY&&(nu(this,n0,!0),tc.start()),this.render(),nu(this,Ss,setInterval(this.render.bind(this),this.interval)),this):(this.text&&Me(this,Du).write(`- ${this.text}
|
|
51
51
|
`),this)}stop(){return Me(this,ha)?(clearInterval(Me(this,Ss)),nu(this,Ss,void 0),nu(this,wa,0),this.clear(),Me(this,Su).hideCursor&&Cf.show(Me(this,Du)),Me(this,Su).discardStdin&&V0.default.stdin.isTTY&&Me(this,n0)&&(tc.stop(),nu(this,n0,!1)),this):this}succeed(t){return this.stopAndPersist({symbol:N0.success,text:t})}fail(t){return this.stopAndPersist({symbol:N0.error,text:t})}warn(t){return this.stopAndPersist({symbol:N0.warning,text:t})}info(t){return this.stopAndPersist({symbol:N0.info,text:t})}stopAndPersist(t={}){if(Me(this,pa))return this;let r=t.prefixText||Me(this,ua),u=t.text||this.text,n=typeof u=="string"?" "+u:"";return this.stop(),Me(this,Du).write(`${this.getFullPrefixText(r," ")}${t.symbol||" "}${n}
|
|
52
|
-
`),this}};za=new WeakMap,n0=new WeakMap,As=new WeakMap,wa=new WeakMap,Su=new WeakMap,da=new WeakMap,Du=new WeakMap,Ss=new WeakMap,i0=new WeakMap,ha=new WeakMap,pa=new WeakMap,ga=new WeakMap,a0=new WeakMap,ua=new WeakMap;function cd(e){return new ld(e)}var B2=/-DW/,fd=/-W/,P2=/-Dw/,Mx=/-w/;async function q2(e){switch((0,Y0.getPkgTool)()){case"pnpm":return B2.test(e)?e=e.replace(B2,"-Dw"):fd.test(e)&&(e=e.replace(fd,"-w")),e;case"yarn":return P2.test(e)?e=e.replace(P2,"-DW"):fd.test(e)&&(e=e.replace(Mx,"-W")),e;default:return e}}async function _a(e){let{color:t,spinner:r}=await Dx();return cd({text:e,spinner:r,color:t}).start()}async function Dx(){let{result:e="yellow"}=await(0,Y0.jsShell)("echo $PI_COLOR","pipe"),t=e,{result:r="star"}=await(0,Y0.jsShell)("echo $PI_SPINNER","pipe");return{color:t,spinner:r}}var dd=lu(ju(),1);var k2="0.0.
|
|
52
|
+
`),this}};za=new WeakMap,n0=new WeakMap,As=new WeakMap,wa=new WeakMap,Su=new WeakMap,da=new WeakMap,Du=new WeakMap,Ss=new WeakMap,i0=new WeakMap,ha=new WeakMap,pa=new WeakMap,ga=new WeakMap,a0=new WeakMap,ua=new WeakMap;function cd(e){return new ld(e)}var B2=/-DW/,fd=/-W/,P2=/-Dw/,Mx=/-w/;async function q2(e){switch((0,Y0.getPkgTool)()){case"pnpm":return B2.test(e)?e=e.replace(B2,"-Dw"):fd.test(e)&&(e=e.replace(fd,"-w")),e;case"yarn":return P2.test(e)?e=e.replace(P2,"-DW"):fd.test(e)&&(e=e.replace(Mx,"-W")),e;default:return e}}async function _a(e){let{color:t,spinner:r}=await Dx();return cd({text:e,spinner:r,color:t}).start()}async function Dx(){let{result:e="yellow"}=await(0,Y0.jsShell)("echo $PI_COLOR","pipe"),t=e,{result:r="star"}=await(0,Y0.jsShell)("echo $PI_SPINNER","pipe");return{color:t,spinner:r}}var dd=lu(ju(),1);var k2="0.0.23";function F2(e){let t=e[0];t==="-v"||t==="--version"?((0,dd.jsShell)(`gum style --foreground 212 --border-foreground 212 --border double --align center --width 50 --margin "1 2" --padding "2 4" 'pi version:${k2}' 'Please give me a \u{1F31F} for my efforts'`),process.exit(0)):(t==="-h"||t==="--help")&&((0,dd.jsShell)(`gum style --foreground 212 --border-foreground 212 --border double --align left --width 50 --margin "1 2" --padding "1 1" 'PI Commands:' '~ pi: install package' '~ pix: npx package' '~ pui: uninstall package' '~ prun: run package script' '~ pinit: package init' '~ pbuild: go build | cargo build' '~ pfind: find monorepo of yarn or pnpm' '~ pa: agent alias' '~ pu: package upgrade' '~ pci: package clean install' '~ pil: package latest install'`),process.exit(0))}var Cs=lu(ju(),1);async function j2(){let{status:e}=(0,Cs.jsShell)("gum -v","pipe");e===1&&await(0,Cs.jsShell)("brew install gum","pipe");let{status:t}=(0,Cs.jsShell)("ni -v","pipe");t===1&&await(0,Cs.jsShell)("npm i -g @antfu/ni","pipe");let{status:r}=(0,Cs.jsShell)("ccommand -v","pipe");r===1&&await(0,Cs.jsShell)("npm i -g ccommand","pipe")}var U2=lu(ju(),1);async function o0(e,t,r="ni"){let u=t?`Installing ${t} ...
|
|
53
53
|
`:`Updating dependency ...
|
|
54
|
-
`,n=t?`Installed ${t} successfully! \u{1F60A}`:"Updated dependency successfully! \u{1F60A}",i=t?`Failed to install ${t} \u{1F62D}`:"Failed to update dependency! \u{1F62D}",a=await q2(e),o=await _a(u),{status:s}=await(0,U2.useNodeWorker)(`${r} ${a}`);s===0?o.succeed(n):o.fail(i),process.exit()}var H2=lu(ju(),1);function z2(){return(0,H2.jsShell)("na")}function $2(e,t){return o0(e,t,"nci")}var G2=lu(ju(),1);function V2(e){return(0,G2.jsShell)(`ccommand find ${e}`)}var hd=lu(ju(),1);function W2(e,t){let r=(0,hd.spaceFormat)(e,"@latest ");return o0(r,t?(0,hd.spaceFormat)(`${t} `,"@latest ").trim():"")}var Is=lu(ju(),1);function Y2(){switch(console.log("Initializing project..."),(0,Is.getPkgTool)()){case"npm":(0,Is.jsShell)("npm init -y");return;case"yarn":(0,Is.jsShell)("yarn init -y");return;case"pnpm":(0,Is.jsShell)("pnpm init -y");return;default:(0,Is.jsShell)("npm init -y")}}var Q0=lu(ju(),1);async function Q2(e){switch((0,Q0.getPkgTool)()){case"bun":return(0,Q0.jsShell)(`bunx ${e}`);default:return(0,Q0.jsShell)(`npx ${e}`)}}var Z2=lu(ju(),1);function J2(e){return(0,Z2.jsShell)(`ccommand ${e}`)}var K2=lu(ju(),1);function X2(){return(0,K2.jsShell)("nu")}var eb=lu(ju(),1);async function tb(e,t){let r=`Uninstalling ${t} ...
|
|
54
|
+
`,n=t?`Installed ${t} successfully! \u{1F60A}`:"Updated dependency successfully! \u{1F60A}",i=t?`Failed to install ${t} \u{1F62D}`:"Failed to update dependency! \u{1F62D}",a=await q2(e),o=await _a(u),{status:s,result:l}=await(0,U2.useNodeWorker)(`${r} ${a}`);s===0?o.succeed(n):o.fail(l||i),process.exit()}var H2=lu(ju(),1);function z2(){return(0,H2.jsShell)("na")}function $2(e,t){return o0(e,t,"nci")}var G2=lu(ju(),1);function V2(e){return(0,G2.jsShell)(`ccommand find ${e}`)}var hd=lu(ju(),1);function W2(e,t){let r=(0,hd.spaceFormat)(e,"@latest ");return o0(r,t?(0,hd.spaceFormat)(`${t} `,"@latest ").trim():"")}var Is=lu(ju(),1);function Y2(){switch(console.log("Initializing project..."),(0,Is.getPkgTool)()){case"npm":(0,Is.jsShell)("npm init -y");return;case"yarn":(0,Is.jsShell)("yarn init -y");return;case"pnpm":(0,Is.jsShell)("pnpm init -y");return;default:(0,Is.jsShell)("npm init -y")}}var Q0=lu(ju(),1);async function Q2(e){switch((0,Q0.getPkgTool)()){case"bun":return(0,Q0.jsShell)(`bunx ${e}`);default:return(0,Q0.jsShell)(`npx ${e}`)}}var Z2=lu(ju(),1);function J2(e){return(0,Z2.jsShell)(`ccommand ${e}`)}var K2=lu(ju(),1);function X2(){return(0,K2.jsShell)("nu")}var eb=lu(ju(),1);async function tb(e,t){let r=`Uninstalling ${t} ...
|
|
55
55
|
`,u=`
|
|
56
56
|
UnInstalled ${t} successfully! \u{1F60A}`,n=`
|
|
57
57
|
Failed to uninstall ${t} \u{1F62D}`;t||(console.log("Need to specify an uninstall package name"),process.exit(1));let i=await _a(r),{status:a}=await(0,eb.useNodeWorker)(`nun ${e}`);a===0?i.succeed(u):i.fail(n),process.exit()}var Lx=Ms.default.cwd(),rb={pi:o0,pix:Q2,pa:z2,pui:tb,pu:X2,pil:W2,pci:$2,prun:J2,pinit:Y2,pfind:V2};async function nb(){let e=Ms.default.argv[1],t=e.lastIndexOf("/")+1,r=e.slice(t,e.length),u=Ms.default.argv.slice(2);F2(u);let n=(0,Eu.spaceFormat)(u.join(" ")).trim();if(!(0,Eu.hasPkg)(Lx)){if((0,Eu.isGo)()){if(r==="pi"){let a=await _a(`Installing ${n} ...
|
package/dist/index.js
CHANGED
|
@@ -49,9 +49,9 @@ Minimum version required to store current data is: `+i+`.
|
|
|
49
49
|
`);return i!==-1&&(t=Vp(t,n,u,i)),u+t+n};Object.defineProperties(D0.prototype,Ys);var cy=D0(),T5=D0({level:Yp?Yp.level:0});var ea=cy;import lg from"process";var ag=Cu(Xp(),1),og=Cu(ig(),1);import dy from"process";var hy=(0,ag.default)(()=>{(0,og.default)(()=>{dy.stderr.write("\x1B[?25h")},{alwaysLast:!0})}),sg=hy;var Nl=!1,Ks={};Ks.show=(e=lg.stderr)=>{!e.isTTY||(Nl=!1,e.write("\x1B[?25h"))};Ks.hide=(e=lg.stderr)=>{!e.isTTY||(sg(),Nl=!0,e.write("\x1B[?25l"))};Ks.toggle=(e,t)=>{e!==void 0&&(Nl=e),Nl?Ks.show(t):Ks.hide(t)};var Sf=Ks;var V0=Cu(hg(),1);import ta from"process";function L0(){return ta.platform!=="win32"?ta.env.TERM!=="linux":Boolean(ta.env.CI)||Boolean(ta.env.WT_SESSION)||Boolean(ta.env.TERMINUS_SUBLIME)||ta.env.ConEmuTask==="{cmd::Cmder}"||ta.env.TERM_PROGRAM==="Terminus-Sublime"||ta.env.TERM_PROGRAM==="vscode"||ta.env.TERM==="xterm-256color"||ta.env.TERM==="alacritty"||ta.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var gy={info:ea.blue("\u2139"),success:ea.green("\u2714"),warning:ea.yellow("\u26A0"),error:ea.red("\u2716")},by={info:ea.blue("i"),success:ea.green("\u221A"),warning:ea.yellow("\u203C"),error:ea.red("\xD7")},my=L0()?gy:by,N0=my;function Cf({onlyFirst:e=!1}={}){let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}function If(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(Cf(),"")}var O2=Cu(_g(),1);function Df({stream:e=process.stdout}={}){return Boolean(e&&e.isTTY&&process.env.TERM!=="dumb"&&!("CI"in process.env))}var D2=Cu(M2(),1);import ua from"process";import Tx from"readline";var Ax=3,wa,G0,u0,za,Kl=class{constructor(){wu(this,wa,0);wu(this,G0,new D2.BufferListStream);wu(this,u0,void 0);wu(this,za,void 0);Me(this,G0).pipe(ua.stdout);let t=this;iu(this,u0,function(r,u,...n){let{stdin:i}=ua;if(Me(t,wa)>0||i.emit===Me(t,u0)){if(r==="keypress")return;r==="data"&&u.includes(Ax)&&ua.emit("SIGINT"),Reflect.apply(Me(t,u0),this,[r,u,...n])}else Reflect.apply(ua.stdin.emit,this,[r,u,...n])})}start(){l0(this,wa)._++,Me(this,wa)===1&&this._realStart()}stop(){if(Me(this,wa)<=0)throw new Error("`stop` called more times than `start`");l0(this,wa)._--,Me(this,wa)===0&&this._realStop()}_realStart(){ua.platform!=="win32"&&(iu(this,za,Tx.createInterface({input:ua.stdin,output:Me(this,G0)})),Me(this,za).on("SIGINT",()=>{ua.listenerCount("SIGINT")===0?ua.emit("SIGINT"):(Me(this,za).close(),ua.kill(ua.pid,"SIGINT"))}))}_realStop(){ua.platform!=="win32"&&(Me(this,za).close(),iu(this,za,void 0))}};wa=new WeakMap,G0=new WeakMap,u0=new WeakMap,za=new WeakMap;var ec,$a,n0,Ss,_a,Su,ha,Ou,Cs,i0,pa,ga,ba,a0,na,sd=class{constructor(t){wu(this,$a,0);wu(this,n0,!1);wu(this,Ss,0);wu(this,_a,0);wu(this,Su,void 0);wu(this,ha,void 0);wu(this,Ou,void 0);wu(this,Cs,void 0);wu(this,i0,void 0);wu(this,pa,void 0);wu(this,ga,void 0);wu(this,ba,void 0);wu(this,a0,void 0);wu(this,na,void 0);su(this,"color");ec||(ec=new Kl),typeof t=="string"&&(t={text:t}),iu(this,Su,{color:"cyan",stream:Xl.stderr,discardStdin:!0,hideCursor:!0,...t}),this.color=Me(this,Su).color,this.spinner=Me(this,Su).spinner,iu(this,i0,Me(this,Su).interval),iu(this,Ou,Me(this,Su).stream),iu(this,pa,typeof Me(this,Su).isEnabled=="boolean"?Me(this,Su).isEnabled:Df({stream:Me(this,Ou)})),iu(this,ga,typeof Me(this,Su).isSilent=="boolean"?Me(this,Su).isSilent:!1),this.text=Me(this,Su).text,this.prefixText=Me(this,Su).prefixText,this.indent=Me(this,Su).indent,Xl.env.NODE_ENV==="test"&&(this._stream=Me(this,Ou),this._isEnabled=Me(this,pa),Object.defineProperty(this,"_linesToClear",{get(){return Me(this,$a)},set(r){iu(this,$a,r)}}),Object.defineProperty(this,"_frameIndex",{get(){return Me(this,_a)}}),Object.defineProperty(this,"_lineCount",{get(){return Me(this,Ss)}}))}get indent(){return Me(this,ba)}set indent(t=0){if(!(t>=0&&Number.isInteger(t)))throw new Error("The `indent` option must be an integer from 0 and up");iu(this,ba,t),this.updateLineCount()}get interval(){return Me(this,i0)||Me(this,ha).interval||100}get spinner(){return Me(this,ha)}set spinner(t){if(iu(this,_a,0),iu(this,i0,void 0),typeof t=="object"){if(t.frames===void 0)throw new Error("The given spinner must have a `frames` property");iu(this,ha,t)}else if(!L0())iu(this,ha,V0.default.line);else if(t===void 0)iu(this,ha,V0.default.dots);else if(t!=="default"&&V0.default[t])iu(this,ha,V0.default[t]);else throw new Error(`There is no built-in spinner named '${t}'. See https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json for a full list.`)}get text(){return Me(this,a0)}set text(t){iu(this,a0,t||""),this.updateLineCount()}get prefixText(){return Me(this,na)}set prefixText(t){iu(this,na,t||""),this.updateLineCount()}get isSpinning(){return Me(this,Cs)!==void 0}getFullPrefixText(t=Me(this,na),r=" "){return typeof t=="string"&&t!==""?t+r:typeof t=="function"?t()+r:""}updateLineCount(){let t=Me(this,Ou).columns||80,r=this.getFullPrefixText(Me(this,na),"-");iu(this,Ss,0);for(let u of If(" ".repeat(Me(this,ba))+r+"--"+Me(this,a0)).split(`
|
|
50
50
|
`))iu(this,Ss,Me(this,Ss)+Math.max(1,Math.ceil((0,O2.default)(u)/t)))}get isEnabled(){return Me(this,pa)&&!Me(this,ga)}set isEnabled(t){if(typeof t!="boolean")throw new TypeError("The `isEnabled` option must be a boolean");iu(this,pa,t)}get isSilent(){return Me(this,ga)}set isSilent(t){if(typeof t!="boolean")throw new TypeError("The `isSilent` option must be a boolean");iu(this,ga,t)}frame(){let{frames:t}=Me(this,ha),r=t[Me(this,_a)];this.color&&(r=ea[this.color](r)),iu(this,_a,++l0(this,_a)._%t.length);let u=typeof Me(this,na)=="string"&&Me(this,na)!==""?Me(this,na)+" ":"",n=typeof this.text=="string"?" "+this.text:"";return u+r+n}clear(){if(!Me(this,pa)||!Me(this,Ou).isTTY)return this;Me(this,Ou).cursorTo(0);for(let t=0;t<Me(this,$a);t++)t>0&&Me(this,Ou).moveCursor(0,-1),Me(this,Ou).clearLine(1);return(Me(this,ba)||this.lastIndent!==Me(this,ba))&&Me(this,Ou).cursorTo(Me(this,ba)),this.lastIndent=Me(this,ba),iu(this,$a,0),this}render(){return Me(this,ga)?this:(this.clear(),Me(this,Ou).write(this.frame()),iu(this,$a,Me(this,Ss)),this)}start(t){return t&&(this.text=t),Me(this,ga)?this:Me(this,pa)?this.isSpinning?this:(Me(this,Su).hideCursor&&Sf.hide(Me(this,Ou)),Me(this,Su).discardStdin&&Xl.stdin.isTTY&&(iu(this,n0,!0),ec.start()),this.render(),iu(this,Cs,setInterval(this.render.bind(this),this.interval)),this):(this.text&&Me(this,Ou).write(`- ${this.text}
|
|
51
51
|
`),this)}stop(){return Me(this,pa)?(clearInterval(Me(this,Cs)),iu(this,Cs,void 0),iu(this,_a,0),this.clear(),Me(this,Su).hideCursor&&Sf.show(Me(this,Ou)),Me(this,Su).discardStdin&&Xl.stdin.isTTY&&Me(this,n0)&&(ec.stop(),iu(this,n0,!1)),this):this}succeed(t){return this.stopAndPersist({symbol:N0.success,text:t})}fail(t){return this.stopAndPersist({symbol:N0.error,text:t})}warn(t){return this.stopAndPersist({symbol:N0.warning,text:t})}info(t){return this.stopAndPersist({symbol:N0.info,text:t})}stopAndPersist(t={}){if(Me(this,ga))return this;let r=t.prefixText||Me(this,na),u=t.text||this.text,n=typeof u=="string"?" "+u:"";return this.stop(),Me(this,Ou).write(`${this.getFullPrefixText(r," ")}${t.symbol||" "}${n}
|
|
52
|
-
`),this}};$a=new WeakMap,n0=new WeakMap,Ss=new WeakMap,_a=new WeakMap,Su=new WeakMap,ha=new WeakMap,Ou=new WeakMap,Cs=new WeakMap,i0=new WeakMap,pa=new WeakMap,ga=new WeakMap,ba=new WeakMap,a0=new WeakMap,na=new WeakMap;function ld(e){return new sd(e)}var L2=/-DW/,cd=/-W/,N2=/-Dw/,Sx=/-w/;async function R2(e){switch((0,W0.getPkgTool)()){case"pnpm":return L2.test(e)?e=e.replace(L2,"-Dw"):cd.test(e)&&(e=e.replace(cd,"-w")),e;case"yarn":return N2.test(e)?e=e.replace(N2,"-DW"):cd.test(e)&&(e=e.replace(Sx,"-W")),e;default:return e}}async function Ea(e){let{color:t,spinner:r}=await Cx();return ld({text:e,spinner:r,color:t}).start()}async function Cx(){let{result:e="yellow"}=await(0,W0.jsShell)("echo $PI_COLOR","pipe"),t=e,{result:r="star"}=await(0,W0.jsShell)("echo $PI_SPINNER","pipe");return{color:t,spinner:r}}var fd=Cu(Uu(),1);var B2="0.0.
|
|
52
|
+
`),this}};$a=new WeakMap,n0=new WeakMap,Ss=new WeakMap,_a=new WeakMap,Su=new WeakMap,ha=new WeakMap,Ou=new WeakMap,Cs=new WeakMap,i0=new WeakMap,pa=new WeakMap,ga=new WeakMap,ba=new WeakMap,a0=new WeakMap,na=new WeakMap;function ld(e){return new sd(e)}var L2=/-DW/,cd=/-W/,N2=/-Dw/,Sx=/-w/;async function R2(e){switch((0,W0.getPkgTool)()){case"pnpm":return L2.test(e)?e=e.replace(L2,"-Dw"):cd.test(e)&&(e=e.replace(cd,"-w")),e;case"yarn":return N2.test(e)?e=e.replace(N2,"-DW"):cd.test(e)&&(e=e.replace(Sx,"-W")),e;default:return e}}async function Ea(e){let{color:t,spinner:r}=await Cx();return ld({text:e,spinner:r,color:t}).start()}async function Cx(){let{result:e="yellow"}=await(0,W0.jsShell)("echo $PI_COLOR","pipe"),t=e,{result:r="star"}=await(0,W0.jsShell)("echo $PI_SPINNER","pipe");return{color:t,spinner:r}}var fd=Cu(Uu(),1);var B2="0.0.23";function P2(e){let t=e[0];t==="-v"||t==="--version"?((0,fd.jsShell)(`gum style --foreground 212 --border-foreground 212 --border double --align center --width 50 --margin "1 2" --padding "2 4" 'pi version:${B2}' 'Please give me a \u{1F31F} for my efforts'`),process.exit(0)):(t==="-h"||t==="--help")&&((0,fd.jsShell)(`gum style --foreground 212 --border-foreground 212 --border double --align left --width 50 --margin "1 2" --padding "1 1" 'PI Commands:' '~ pi: install package' '~ pix: npx package' '~ pui: uninstall package' '~ prun: run package script' '~ pinit: package init' '~ pbuild: go build | cargo build' '~ pfind: find monorepo of yarn or pnpm' '~ pa: agent alias' '~ pu: package upgrade' '~ pci: package clean install' '~ pil: package latest install'`),process.exit(0))}var Is=Cu(Uu(),1);async function q2(){let{status:e}=(0,Is.jsShell)("gum -v","pipe");e===1&&await(0,Is.jsShell)("brew install gum","pipe");let{status:t}=(0,Is.jsShell)("ni -v","pipe");t===1&&await(0,Is.jsShell)("npm i -g @antfu/ni","pipe");let{status:r}=(0,Is.jsShell)("ccommand -v","pipe");r===1&&await(0,Is.jsShell)("npm i -g ccommand","pipe")}var k2=Cu(Uu(),1);async function o0(e,t,r="ni"){let u=t?`Installing ${t} ...
|
|
53
53
|
`:`Updating dependency ...
|
|
54
|
-
`,n=t?`Installed ${t} successfully! \u{1F60A}`:"Updated dependency successfully! \u{1F60A}",i=t?`Failed to install ${t} \u{1F62D}`:"Failed to update dependency! \u{1F62D}",a=await R2(e),o=await Ea(u),{status:s}=await(0,k2.useNodeWorker)(`${r} ${a}`);s===0?o.succeed(n):o.fail(i),process.exit()}var F2=Cu(Uu(),1);function j2(){return(0,F2.jsShell)("na")}function U2(e,t){return o0(e,t,"nci")}var H2=Cu(Uu(),1);function z2(e){return(0,H2.jsShell)(`ccommand find ${e}`)}var dd=Cu(Uu(),1);function $2(e,t){let r=(0,dd.spaceFormat)(e,"@latest ");return o0(r,t?(0,dd.spaceFormat)(`${t} `,"@latest ").trim():"")}var Ms=Cu(Uu(),1);function G2(){switch(console.log("Initializing project..."),(0,Ms.getPkgTool)()){case"npm":(0,Ms.jsShell)("npm init -y");return;case"yarn":(0,Ms.jsShell)("yarn init -y");return;case"pnpm":(0,Ms.jsShell)("pnpm init -y");return;default:(0,Ms.jsShell)("npm init -y")}}var Y0=Cu(Uu(),1);async function V2(e){switch((0,Y0.getPkgTool)()){case"bun":return(0,Y0.jsShell)(`bunx ${e}`);default:return(0,Y0.jsShell)(`npx ${e}`)}}var W2=Cu(Uu(),1);function Y2(e){return(0,W2.jsShell)(`ccommand ${e}`)}var Q2=Cu(Uu(),1);function Z2(){return(0,Q2.jsShell)("nu")}var J2=Cu(Uu(),1);async function K2(e,t){let r=`Uninstalling ${t} ...
|
|
54
|
+
`,n=t?`Installed ${t} successfully! \u{1F60A}`:"Updated dependency successfully! \u{1F60A}",i=t?`Failed to install ${t} \u{1F62D}`:"Failed to update dependency! \u{1F62D}",a=await R2(e),o=await Ea(u),{status:s,result:l}=await(0,k2.useNodeWorker)(`${r} ${a}`);s===0?o.succeed(n):o.fail(l||i),process.exit()}var F2=Cu(Uu(),1);function j2(){return(0,F2.jsShell)("na")}function U2(e,t){return o0(e,t,"nci")}var H2=Cu(Uu(),1);function z2(e){return(0,H2.jsShell)(`ccommand find ${e}`)}var dd=Cu(Uu(),1);function $2(e,t){let r=(0,dd.spaceFormat)(e,"@latest ");return o0(r,t?(0,dd.spaceFormat)(`${t} `,"@latest ").trim():"")}var Ms=Cu(Uu(),1);function G2(){switch(console.log("Initializing project..."),(0,Ms.getPkgTool)()){case"npm":(0,Ms.jsShell)("npm init -y");return;case"yarn":(0,Ms.jsShell)("yarn init -y");return;case"pnpm":(0,Ms.jsShell)("pnpm init -y");return;default:(0,Ms.jsShell)("npm init -y")}}var Y0=Cu(Uu(),1);async function V2(e){switch((0,Y0.getPkgTool)()){case"bun":return(0,Y0.jsShell)(`bunx ${e}`);default:return(0,Y0.jsShell)(`npx ${e}`)}}var W2=Cu(Uu(),1);function Y2(e){return(0,W2.jsShell)(`ccommand ${e}`)}var Q2=Cu(Uu(),1);function Z2(){return(0,Q2.jsShell)("nu")}var J2=Cu(Uu(),1);async function K2(e,t){let r=`Uninstalling ${t} ...
|
|
55
55
|
`,u=`
|
|
56
56
|
UnInstalled ${t} successfully! \u{1F60A}`,n=`
|
|
57
57
|
Failed to uninstall ${t} \u{1F62D}`;t||(console.log("Need to specify an uninstall package name"),process.exit(1));let i=await Ea(r),{status:a}=await(0,J2.useNodeWorker)(`nun ${e}`);a===0?i.succeed(u):i.fail(n),process.exit()}var Dx=s0.cwd(),X2={pi:o0,pix:V2,pa:j2,pui:K2,pu:Z2,pil:$2,pci:U2,prun:Y2,pinit:G2,pfind:z2};async function Ox(){let e=s0.argv[1],t=e.lastIndexOf("/")+1,r=e.slice(t,e.length),u=s0.argv.slice(2);P2(u);let n=(0,Eu.spaceFormat)(u.join(" ")).trim();if(!(0,Eu.hasPkg)(Dx)){if((0,Eu.isGo)()){if(r==="pi"){let a=await Ea(`Installing ${n} ...
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simon_he/pi",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.23",
|
|
5
5
|
"packageManager": "pnpm@7.22.0",
|
|
6
6
|
"description": "",
|
|
7
7
|
"author": "Simon He",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"tsx": "^3.12.1",
|
|
87
87
|
"typescript": "^4.9.4",
|
|
88
88
|
"unbuild": "^1.0.0",
|
|
89
|
-
"vitest": "^0.
|
|
89
|
+
"vitest": "^0.27.0"
|
|
90
90
|
},
|
|
91
91
|
"simple-git-hooks": {
|
|
92
92
|
"pre-commit": "pnpm exec lint-staged --concurrent false",
|