UNPKG

create-abi

Version:

Interactive CLI for create Abi.js projects.

3 lines (2 loc) 4.01 kB
import{confirm as B,isCancel as E,log as c,select as k,text as I}from"@clack/prompts";import{bgBlack as C,bgBlue as M,bgCyan as P,bgGreen as N,bgMagenta as U,bgRed as A,bgWhite as L,bgYellow as W,black as G,blue as b,bold as D,cyan as F,dim as J,gray as p,green as m,grey as K,hidden as V,inverse as Y,italic as j,magenta as T,red as v,reset as q,strikethrough as z,underline as H,white as S,yellow as O}from"kleur/colors";import{cancel as Ie,intro as Ce,note as Me,outro as Pe,spinner as Ne}from"@clack/prompts";function Q(){return process.platform!=="win32"?process.env.TERM!=="linux":!!process.env.CI||!!process.env.WT_SESSION||!!process.env.TERMINUS_SUBLIME||process.env.ConEmuTask==="{cmd::Cmder}"||process.env.TERM_PROGRAM==="Terminus-Sublime"||process.env.TERM_PROGRAM==="vscode"||process.env.TERM==="xterm-256color"||process.env.TERM==="alacritty"||process.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var s=Q(),r={success:s?"\u2705":"[OK]",error:s?"\u274C":"[ERROR]",info:s?"\u2139\uFE0F":"[INFO]",warning:s?"\u26A0\uFE0F":"[WARN]",debug:s?"\u{1F41E}":"[DEBUG]",verbose:s?"\u{1F50D}":"[DETAILS]",line:s?"\u2500\u2500":"----"},X={red:v,green:m,blue:b,yellow:O,magenta:T,cyan:F,gray:p,grey:K,white:S,black:G},Z={red:A,green:N,blue:M,yellow:W,magenta:U,cyan:P,white:L,black:C},_={reset:q,bold:D,dim:J,italic:j,underline:H,inverse:Y,hidden:V,strikethrough:z},l=class e extends String{constructor(n,t){super(n),t&&this.apply(t)}append(n){return new e(this.toString()+n)}prepend(n){return new e(n+this.toString())}apply(n){n.icon&&this.icon(n.icon),n.color&&this.color(n.color),n.bg&&this.bg(n.bg),n.style&&this.style(n.style)}icon(n){return this.prepend(r[n])}color(n){return new e(X[n](this.toString()))}bg(n){return new e(Z[n](this.toString()))}style(n){return new e(_[n](this.toString()))}toString(){return super.toString()}};function ae(e,n){return new l(e,n)}function $(e){return m(`${r.success} ${e}`)}function f(e){return v(`${r.error} ${e}`)}function h(e){return b(`${r.info} ${e}`)}function w(e){return O(`${r.warning} ${e}`)}function ee(e){return T(`${r.debug} ${e}`)}function ne(e){return p(`${r.verbose} ${e}`)}function te(e){return`${p(r.line)} ${S(e)} ${p(r.line)}`}function pe(e,n=0){console.log($(e)+i(n))}function ge(e,n=0){console.error(f(e)+i(n))}function le(e,n=0){console.info(h(e)+i(n))}function fe(e,n=0){console.warn(w(e)+i(n))}function ye(e,n=0){console.debug(ee(e)+i(n))}function de(e){console.log(te(e))}function xe(e){console.log(ne(e))}function be(e){c.info(h(e))}function me(e){c.success($(e))}function Te(e){c.step(e)}function ve(e){c.warn(w(e))}function Se(e){c.error(f(e))}function y(e){console.error(`${i()}${f(e)}${i()}`),process.exit(1)}function i(e=1){return` `.repeat(e)}async function Oe(e,n,t){let o=t&&await I({message:e,placeholder:n,defaultValue:n})||n;return o!==n&&R(o),o}async function $e(e,n,t,o){let u=o&&await k({message:e,options:n,initialValue:t})||t;return u!==t&&R(u),u}async function he(e,n,t,o,u){let g=u===!0&&!n?!1:o===!0&&n===void 0?!0:t?await B({message:e,initialValue:n}):n;return g!==n&&oe(g),g}function R(e,n){a(e,n?t=>d(t)&&n(t):d,"string")}function we(e,n){a(e,n?t=>x(t)&&n(t):x,"number")}function oe(e){a(e,se,"boolean")}function Re(e){a(e,n=>n===!0,"true")}function Be(e){a(e,n=>n===!1,"false")}function a(e,n,t){re(e,n,t,typeof e)}function re(e,n,t,o){ie(e)&&y("Operation canceled."),n(e)||y(`Invalid input${t?`: ${t} expected`:""}${o?`, ${o} provided`:""}.`)}function d(e){return typeof e=="string"||e instanceof String}function x(e){return typeof e=="number"&&!Number.isNaN(e)}function se(e){return typeof e=="boolean"}function ie(e){return E(e)||typeof e=="symbol"}export{Q as a,r as b,X as c,Z as d,_ as e,l as f,ae as g,$ as h,f as i,h as j,w as k,ee as l,ne as m,te as n,pe as o,ge as p,le as q,fe as r,ye as s,de as t,xe as u,be as v,me as w,Te as x,ve as y,Se as z,y as A,i as B,Oe as C,$e as D,he as E,R as F,we as G,oe as H,Re as I,Be as J,a as K,re as L,d as M,x as N,se as O,ie as P,Ie as Q,Ce as R,Me as S,Pe as T,Ne as U};