1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407 |
- exports.id = 31;
- exports.ids = [31];
- exports.modules = {
- /***/ 53692:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
- const identity = val => val;
- /* eslint-disable no-control-regex */
- // this is a modified version of https://github.com/chalk/ansi-regex (MIT License)
- const ANSI_REGEX = /[\u001b\u009b][[\]#;?()]*(?:(?:(?:[^\W_]*;?[^\W_]*)\u0007)|(?:(?:[0-9]{1,4}(;[0-9]{0,4})*)?[~0-9=<>cf-nqrtyA-PRZ]))/g;
- const create = () => {
- const colors = { enabled: true, visible: true, styles: {}, keys: {} };
- if ('FORCE_COLOR' in process.env) {
- colors.enabled = process.env.FORCE_COLOR !== '0';
- }
- const ansi = style => {
- let open = style.open = `\u001b[${style.codes[0]}m`;
- let close = style.close = `\u001b[${style.codes[1]}m`;
- let regex = style.regex = new RegExp(`\\u001b\\[${style.codes[1]}m`, 'g');
- style.wrap = (input, newline) => {
- if (input.includes(close)) input = input.replace(regex, close + open);
- let output = open + input + close;
- // see https://github.com/chalk/chalk/pull/92, thanks to the
- // chalk contributors for this fix. However, we've confirmed that
- // this issue is also present in Windows terminals
- return newline ? output.replace(/\r*\n/g, `${close}$&${open}`) : output;
- };
- return style;
- };
- const wrap = (style, input, newline) => {
- return typeof style === 'function' ? style(input) : style.wrap(input, newline);
- };
- const style = (input, stack) => {
- if (input === '' || input == null) return '';
- if (colors.enabled === false) return input;
- if (colors.visible === false) return '';
- let str = '' + input;
- let nl = str.includes('\n');
- let n = stack.length;
- if (n > 0 && stack.includes('unstyle')) {
- stack = [...new Set(['unstyle', ...stack])].reverse();
- }
- while (n-- > 0) str = wrap(colors.styles[stack[n]], str, nl);
- return str;
- };
- const define = (name, codes, type) => {
- colors.styles[name] = ansi({ name, codes });
- let keys = colors.keys[type] || (colors.keys[type] = []);
- keys.push(name);
- Reflect.defineProperty(colors, name, {
- configurable: true,
- enumerable: true,
- set(value) {
- colors.alias(name, value);
- },
- get() {
- let color = input => style(input, color.stack);
- Reflect.setPrototypeOf(color, colors);
- color.stack = this.stack ? this.stack.concat(name) : [name];
- return color;
- }
- });
- };
- define('reset', [0, 0], 'modifier');
- define('bold', [1, 22], 'modifier');
- define('dim', [2, 22], 'modifier');
- define('italic', [3, 23], 'modifier');
- define('underline', [4, 24], 'modifier');
- define('inverse', [7, 27], 'modifier');
- define('hidden', [8, 28], 'modifier');
- define('strikethrough', [9, 29], 'modifier');
- define('black', [30, 39], 'color');
- define('red', [31, 39], 'color');
- define('green', [32, 39], 'color');
- define('yellow', [33, 39], 'color');
- define('blue', [34, 39], 'color');
- define('magenta', [35, 39], 'color');
- define('cyan', [36, 39], 'color');
- define('white', [37, 39], 'color');
- define('gray', [90, 39], 'color');
- define('grey', [90, 39], 'color');
- define('bgBlack', [40, 49], 'bg');
- define('bgRed', [41, 49], 'bg');
- define('bgGreen', [42, 49], 'bg');
- define('bgYellow', [43, 49], 'bg');
- define('bgBlue', [44, 49], 'bg');
- define('bgMagenta', [45, 49], 'bg');
- define('bgCyan', [46, 49], 'bg');
- define('bgWhite', [47, 49], 'bg');
- define('blackBright', [90, 39], 'bright');
- define('redBright', [91, 39], 'bright');
- define('greenBright', [92, 39], 'bright');
- define('yellowBright', [93, 39], 'bright');
- define('blueBright', [94, 39], 'bright');
- define('magentaBright', [95, 39], 'bright');
- define('cyanBright', [96, 39], 'bright');
- define('whiteBright', [97, 39], 'bright');
- define('bgBlackBright', [100, 49], 'bgBright');
- define('bgRedBright', [101, 49], 'bgBright');
- define('bgGreenBright', [102, 49], 'bgBright');
- define('bgYellowBright', [103, 49], 'bgBright');
- define('bgBlueBright', [104, 49], 'bgBright');
- define('bgMagentaBright', [105, 49], 'bgBright');
- define('bgCyanBright', [106, 49], 'bgBright');
- define('bgWhiteBright', [107, 49], 'bgBright');
- colors.ansiRegex = ANSI_REGEX;
- colors.hasColor = colors.hasAnsi = str => {
- colors.ansiRegex.lastIndex = 0;
- return typeof str === 'string' && str !== '' && colors.ansiRegex.test(str);
- };
- colors.alias = (name, color) => {
- let fn = typeof color === 'string' ? colors[color] : color;
- if (typeof fn !== 'function') {
- throw new TypeError('Expected alias to be the name of an existing color (string) or a function');
- }
- if (!fn.stack) {
- Reflect.defineProperty(fn, 'name', { value: name });
- colors.styles[name] = fn;
- fn.stack = [name];
- }
- Reflect.defineProperty(colors, name, {
- configurable: true,
- enumerable: true,
- set(value) {
- colors.alias(name, value);
- },
- get() {
- let color = input => style(input, color.stack);
- Reflect.setPrototypeOf(color, colors);
- color.stack = this.stack ? this.stack.concat(fn.stack) : fn.stack;
- return color;
- }
- });
- };
- colors.theme = custom => {
- if (!isObject(custom)) throw new TypeError('Expected theme to be an object');
- for (let name of Object.keys(custom)) {
- colors.alias(name, custom[name]);
- }
- return colors;
- };
- colors.alias('unstyle', str => {
- if (typeof str === 'string' && str !== '') {
- colors.ansiRegex.lastIndex = 0;
- return str.replace(colors.ansiRegex, '');
- }
- return '';
- });
- colors.alias('noop', str => str);
- colors.none = colors.clear = colors.noop;
- colors.stripColor = colors.unstyle;
- colors.symbols = __webpack_require__(17142);
- colors.define = define;
- return colors;
- };
- module.exports = create();
- module.exports.create = create;
- /***/ }),
- /***/ 17142:
- /***/ ((module) => {
- "use strict";
- const isHyper = process.env.TERM_PROGRAM === 'Hyper';
- const isWindows = process.platform === 'win32';
- const isLinux = process.platform === 'linux';
- const common = {
- ballotDisabled: '☒',
- ballotOff: '☐',
- ballotOn: '☑',
- bullet: '•',
- bulletWhite: '◦',
- fullBlock: '█',
- heart: '❤',
- identicalTo: '≡',
- line: '─',
- mark: '※',
- middot: '·',
- minus: '-',
- multiplication: '×',
- obelus: '÷',
- pencilDownRight: '✎',
- pencilRight: '✏',
- pencilUpRight: '✐',
- percent: '%',
- pilcrow2: '❡',
- pilcrow: '¶',
- plusMinus: '±',
- section: '§',
- starsOff: '☆',
- starsOn: '★',
- upDownArrow: '↕'
- };
- const windows = Object.assign({}, common, {
- check: '√',
- cross: '×',
- ellipsisLarge: '...',
- ellipsis: '...',
- info: 'i',
- question: '?',
- questionSmall: '?',
- pointer: '>',
- pointerSmall: '»',
- radioOff: '( )',
- radioOn: '(*)',
- warning: '‼'
- });
- const other = Object.assign({}, common, {
- ballotCross: '✘',
- check: '✔',
- cross: '✖',
- ellipsisLarge: '⋯',
- ellipsis: '…',
- info: 'ℹ',
- question: '?',
- questionFull: '?',
- questionSmall: '﹖',
- pointer: isLinux ? '▸' : '❯',
- pointerSmall: isLinux ? '‣' : '›',
- radioOff: '◯',
- radioOn: '◉',
- warning: '⚠'
- });
- module.exports = (isWindows && !isHyper) ? windows : other;
- Reflect.defineProperty(module.exports, 'common', { enumerable: false, value: common });
- Reflect.defineProperty(module.exports, 'windows', { enumerable: false, value: windows });
- Reflect.defineProperty(module.exports, 'other', { enumerable: false, value: other });
- /***/ }),
- /***/ 84031:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const assert = __webpack_require__(42357);
- const Events = __webpack_require__(28614);
- const utils = __webpack_require__(83546);
- /**
- * Create an instance of `Enquirer`.
- *
- * ```js
- * const Enquirer = require('enquirer');
- * const enquirer = new Enquirer();
- * ```
- * @name Enquirer
- * @param {Object} `options` (optional) Options to use with all prompts.
- * @param {Object} `answers` (optional) Answers object to initialize with.
- * @api public
- */
- class Enquirer extends Events {
- constructor(options, answers) {
- super();
- this.options = utils.merge({}, options);
- this.answers = { ...answers };
- }
- /**
- * Register a custom prompt type.
- *
- * ```js
- * const Enquirer = require('enquirer');
- * const enquirer = new Enquirer();
- * enquirer.register('customType', require('./custom-prompt'));
- * ```
- * @name register()
- * @param {String} `type`
- * @param {Function|Prompt} `fn` `Prompt` class, or a function that returns a `Prompt` class.
- * @return {Object} Returns the Enquirer instance
- * @api public
- */
- register(type, fn) {
- if (utils.isObject(type)) {
- for (let key of Object.keys(type)) this.register(key, type[key]);
- return this;
- }
- assert.equal(typeof fn, 'function', 'expected a function');
- let name = type.toLowerCase();
- if (fn.prototype instanceof this.Prompt) {
- this.prompts[name] = fn;
- } else {
- this.prompts[name] = fn(this.Prompt, this);
- }
- return this;
- }
- /**
- * Prompt function that takes a "question" object or array of question objects,
- * and returns an object with responses from the user.
- *
- * ```js
- * const Enquirer = require('enquirer');
- * const enquirer = new Enquirer();
- *
- * const response = await enquirer.prompt({
- * type: 'input',
- * name: 'username',
- * message: 'What is your username?'
- * });
- * console.log(response);
- * ```
- * @name prompt()
- * @param {Array|Object} `questions` Options objects for one or more prompts to run.
- * @return {Promise} Promise that returns an "answers" object with the user's responses.
- * @api public
- */
- async prompt(questions = []) {
- for (let question of [].concat(questions)) {
- try {
- if (typeof question === 'function') question = await question.call(this);
- await this.ask(utils.merge({}, this.options, question));
- } catch (err) {
- return Promise.reject(err);
- }
- }
- return this.answers;
- }
- async ask(question) {
- if (typeof question === 'function') {
- question = await question.call(this);
- }
- let opts = utils.merge({}, this.options, question);
- let { type, name } = question;
- let { set, get } = utils;
- if (typeof type === 'function') {
- type = await type.call(this, question, this.answers);
- }
- if (!type) return this.answers[name];
- assert(this.prompts[type], `Prompt "${type}" is not registered`);
- let prompt = new this.prompts[type](opts);
- let value = get(this.answers, name);
- prompt.state.answers = this.answers;
- prompt.enquirer = this;
- if (name) {
- prompt.on('submit', value => {
- this.emit('answer', name, value, prompt);
- set(this.answers, name, value);
- });
- }
- // bubble events
- let emit = prompt.emit.bind(prompt);
- prompt.emit = (...args) => {
- this.emit.call(this, ...args);
- return emit(...args);
- };
- this.emit('prompt', prompt, this);
- if (opts.autofill && value != null) {
- prompt.value = prompt.input = value;
- // if "autofill=show" render the prompt, otherwise stay "silent"
- if (opts.autofill === 'show') {
- await prompt.submit();
- }
- } else {
- value = prompt.value = await prompt.run();
- }
- return value;
- }
- /**
- * Use an enquirer plugin.
- *
- * ```js
- * const Enquirer = require('enquirer');
- * const enquirer = new Enquirer();
- * const plugin = enquirer => {
- * // do stuff to enquire instance
- * };
- * enquirer.use(plugin);
- * ```
- * @name use()
- * @param {Function} `plugin` Plugin function that takes an instance of Enquirer.
- * @return {Object} Returns the Enquirer instance.
- * @api public
- */
- use(plugin) {
- plugin.call(this, this);
- return this;
- }
- set Prompt(value) {
- this._Prompt = value;
- }
- get Prompt() {
- return this._Prompt || this.constructor.Prompt;
- }
- get prompts() {
- return this.constructor.prompts;
- }
- static set Prompt(value) {
- this._Prompt = value;
- }
- static get Prompt() {
- return this._Prompt || __webpack_require__(232);
- }
- static get prompts() {
- return __webpack_require__(29594);
- }
- static get types() {
- return __webpack_require__(29920);
- }
- /**
- * Prompt function that takes a "question" object or array of question objects,
- * and returns an object with responses from the user.
- *
- * ```js
- * const { prompt } = require('enquirer');
- * const response = await prompt({
- * type: 'input',
- * name: 'username',
- * message: 'What is your username?'
- * });
- * console.log(response);
- * ```
- * @name Enquirer#prompt
- * @param {Array|Object} `questions` Options objects for one or more prompts to run.
- * @return {Promise} Promise that returns an "answers" object with the user's responses.
- * @api public
- */
- static get prompt() {
- const fn = (questions, ...rest) => {
- let enquirer = new this(...rest);
- let emit = enquirer.emit.bind(enquirer);
- enquirer.emit = (...args) => {
- fn.emit(...args);
- return emit(...args);
- };
- return enquirer.prompt(questions);
- };
- utils.mixinEmitter(fn, new Events());
- return fn;
- }
- }
- utils.mixinEmitter(Enquirer, new Events());
- const prompts = Enquirer.prompts;
- for (let name of Object.keys(prompts)) {
- let key = name.toLowerCase();
- let run = options => new prompts[name](options).run();
- Enquirer.prompt[key] = run;
- Enquirer[key] = run;
- if (!Enquirer[name]) {
- Reflect.defineProperty(Enquirer, name, { get: () => prompts[name] });
- }
- }
- const exp = name => {
- utils.defineExport(Enquirer, name, () => Enquirer.types[name]);
- };
- exp('ArrayPrompt');
- exp('AuthPrompt');
- exp('BooleanPrompt');
- exp('NumberPrompt');
- exp('StringPrompt');
- module.exports = Enquirer;
- /***/ }),
- /***/ 94907:
- /***/ ((module, exports, __webpack_require__) => {
- "use strict";
- const isTerm = process.env.TERM_PROGRAM === 'Apple_Terminal';
- const colors = __webpack_require__(53692);
- const utils = __webpack_require__(83546);
- const ansi = module.exports = exports;
- const ESC = '\u001b[';
- const BEL = '\u0007';
- let hidden = false;
- const code = ansi.code = {
- bell: BEL,
- beep: BEL,
- beginning: `${ESC}G`,
- down: `${ESC}J`,
- esc: ESC,
- getPosition: `${ESC}6n`,
- hide: `${ESC}?25l`,
- line: `${ESC}2K`,
- lineEnd: `${ESC}K`,
- lineStart: `${ESC}1K`,
- restorePosition: ESC + (isTerm ? '8' : 'u'),
- savePosition: ESC + (isTerm ? '7' : 's'),
- screen: `${ESC}2J`,
- show: `${ESC}?25h`,
- up: `${ESC}1J`
- };
- const cursor = ansi.cursor = {
- get hidden() {
- return hidden;
- },
- hide() {
- hidden = true;
- return code.hide;
- },
- show() {
- hidden = false;
- return code.show;
- },
- forward: (count = 1) => `${ESC}${count}C`,
- backward: (count = 1) => `${ESC}${count}D`,
- nextLine: (count = 1) => `${ESC}E`.repeat(count),
- prevLine: (count = 1) => `${ESC}F`.repeat(count),
- up: (count = 1) => count ? `${ESC}${count}A` : '',
- down: (count = 1) => count ? `${ESC}${count}B` : '',
- right: (count = 1) => count ? `${ESC}${count}C` : '',
- left: (count = 1) => count ? `${ESC}${count}D` : '',
- to(x, y) {
- return y ? `${ESC}${y + 1};${x + 1}H` : `${ESC}${x + 1}G`;
- },
- move(x = 0, y = 0) {
- let res = '';
- res += (x < 0) ? cursor.left(-x) : (x > 0) ? cursor.right(x) : '';
- res += (y < 0) ? cursor.up(-y) : (y > 0) ? cursor.down(y) : '';
- return res;
- },
- restore(state = {}) {
- let { after, cursor, initial, input, prompt, size, value } = state;
- initial = utils.isPrimitive(initial) ? String(initial) : '';
- input = utils.isPrimitive(input) ? String(input) : '';
- value = utils.isPrimitive(value) ? String(value) : '';
- if (size) {
- let codes = ansi.cursor.up(size) + ansi.cursor.to(prompt.length);
- let diff = input.length - cursor;
- if (diff > 0) {
- codes += ansi.cursor.left(diff);
- }
- return codes;
- }
- if (value || after) {
- let pos = (!input && !!initial) ? -initial.length : -input.length + cursor;
- if (after) pos -= after.length;
- if (input === '' && initial && !prompt.includes(initial)) {
- pos += initial.length;
- }
- return ansi.cursor.move(pos);
- }
- }
- };
- const erase = ansi.erase = {
- screen: code.screen,
- up: code.up,
- down: code.down,
- line: code.line,
- lineEnd: code.lineEnd,
- lineStart: code.lineStart,
- lines(n) {
- let str = '';
- for (let i = 0; i < n; i++) {
- str += ansi.erase.line + (i < n - 1 ? ansi.cursor.up(1) : '');
- }
- if (n) str += ansi.code.beginning;
- return str;
- }
- };
- ansi.clear = (input = '', columns = process.stdout.columns) => {
- if (!columns) return erase.line + cursor.to(0);
- let width = str => [...colors.unstyle(str)].length;
- let lines = input.split(/\r?\n/);
- let rows = 0;
- for (let line of lines) {
- rows += 1 + Math.floor(Math.max(width(line) - 1, 0) / columns);
- }
- return (erase.line + cursor.prevLine()).repeat(rows - 1) + erase.line + cursor.to(0);
- };
- /***/ }),
- /***/ 64726:
- /***/ ((__unused_webpack_module, exports) => {
- "use strict";
- /**
- * Actions are mappings from keypress event names to method names
- * in the prompts.
- */
- exports.ctrl = {
- a: 'first',
- b: 'backward',
- c: 'cancel',
- d: 'deleteForward',
- e: 'last',
- f: 'forward',
- g: 'reset',
- i: 'tab',
- k: 'cutForward',
- l: 'reset',
- n: 'newItem',
- m: 'cancel',
- j: 'submit',
- p: 'search',
- r: 'remove',
- s: 'save',
- u: 'undo',
- w: 'cutLeft',
- x: 'toggleCursor',
- v: 'paste'
- };
- exports.shift = {
- up: 'shiftUp',
- down: 'shiftDown',
- left: 'shiftLeft',
- right: 'shiftRight',
- tab: 'prev'
- };
- exports.fn = {
- up: 'pageUp',
- down: 'pageDown',
- left: 'pageLeft',
- right: 'pageRight',
- delete: 'deleteForward'
- };
- // <alt> on Windows
- exports.option = {
- b: 'backward',
- f: 'forward',
- d: 'cutRight',
- left: 'cutLeft',
- up: 'altUp',
- down: 'altDown'
- };
- exports.keys = {
- pageup: 'pageUp', // <fn>+<up> (mac), <Page Up> (windows)
- pagedown: 'pageDown', // <fn>+<down> (mac), <Page Down> (windows)
- home: 'home', // <fn>+<left> (mac), <home> (windows)
- end: 'end', // <fn>+<right> (mac), <end> (windows)
- cancel: 'cancel',
- delete: 'deleteForward',
- backspace: 'delete',
- down: 'down',
- enter: 'submit',
- escape: 'cancel',
- left: 'left',
- space: 'space',
- number: 'number',
- return: 'submit',
- right: 'right',
- tab: 'next',
- up: 'up'
- };
- /***/ }),
- /***/ 73736:
- /***/ ((module) => {
- "use strict";
- const unique = arr => arr.filter((v, i) => arr.lastIndexOf(v) === i);
- const compact = arr => unique(arr).filter(Boolean);
- module.exports = (action, data = {}, value = '') => {
- let { past = [], present = '' } = data;
- let rest, prev;
- switch (action) {
- case 'prev':
- case 'undo':
- rest = past.slice(0, past.length - 1);
- prev = past[past.length - 1] || '';
- return {
- past: compact([value, ...rest]),
- present: prev
- };
- case 'next':
- case 'redo':
- rest = past.slice(1);
- prev = past[0] || '';
- return {
- past: compact([...rest, value]),
- present: prev
- };
- case 'save':
- return {
- past: compact([...past, value]),
- present: ''
- };
- case 'remove':
- prev = compact(past.filter(v => v !== value));
- present = '';
- if (prev.length) {
- present = prev.pop();
- }
- return {
- past: prev,
- present
- };
- default: {
- throw new Error(`Invalid action: "${action}"`);
- }
- }
- };
- /***/ }),
- /***/ 27189:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const colors = __webpack_require__(53692);
- const clean = (str = '') => {
- return typeof str === 'string' ? str.replace(/^['"]|['"]$/g, '') : '';
- };
- /**
- * This file contains the interpolation and rendering logic for
- * the Snippet prompt.
- */
- class Item {
- constructor(token) {
- this.name = token.key;
- this.field = token.field || {};
- this.value = clean(token.initial || this.field.initial || '');
- this.message = token.message || this.name;
- this.cursor = 0;
- this.input = '';
- this.lines = [];
- }
- }
- const tokenize = async(options = {}, defaults = {}, fn = token => token) => {
- let unique = new Set();
- let fields = options.fields || [];
- let input = options.template;
- let tabstops = [];
- let items = [];
- let keys = [];
- let line = 1;
- if (typeof input === 'function') {
- input = await input();
- }
- let i = -1;
- let next = () => input[++i];
- let peek = () => input[i + 1];
- let push = token => {
- token.line = line;
- tabstops.push(token);
- };
- push({ type: 'bos', value: '' });
- while (i < input.length - 1) {
- let value = next();
- if (/^[^\S\n ]$/.test(value)) {
- push({ type: 'text', value });
- continue;
- }
- if (value === '\n') {
- push({ type: 'newline', value });
- line++;
- continue;
- }
- if (value === '\\') {
- value += next();
- push({ type: 'text', value });
- continue;
- }
- if ((value === '$' || value === '#' || value === '{') && peek() === '{') {
- let n = next();
- value += n;
- let token = { type: 'template', open: value, inner: '', close: '', value };
- let ch;
- while ((ch = next())) {
- if (ch === '}') {
- if (peek() === '}') ch += next();
- token.value += ch;
- token.close = ch;
- break;
- }
- if (ch === ':') {
- token.initial = '';
- token.key = token.inner;
- } else if (token.initial !== void 0) {
- token.initial += ch;
- }
- token.value += ch;
- token.inner += ch;
- }
- token.template = token.open + (token.initial || token.inner) + token.close;
- token.key = token.key || token.inner;
- if (defaults.hasOwnProperty(token.key)) {
- token.initial = defaults[token.key];
- }
- token = fn(token);
- push(token);
- keys.push(token.key);
- unique.add(token.key);
- let item = items.find(item => item.name === token.key);
- token.field = fields.find(ch => ch.name === token.key);
- if (!item) {
- item = new Item(token);
- items.push(item);
- }
- item.lines.push(token.line - 1);
- continue;
- }
- let last = tabstops[tabstops.length - 1];
- if (last.type === 'text' && last.line === line) {
- last.value += value;
- } else {
- push({ type: 'text', value });
- }
- }
- push({ type: 'eos', value: '' });
- return { input, tabstops, unique, keys, items };
- };
- module.exports = async prompt => {
- let options = prompt.options;
- let required = new Set(options.required === true ? [] : (options.required || []));
- let defaults = { ...options.values, ...options.initial };
- let { tabstops, items, keys } = await tokenize(options, defaults);
- let result = createFn('result', prompt, options);
- let format = createFn('format', prompt, options);
- let isValid = createFn('validate', prompt, options, true);
- let isVal = prompt.isValue.bind(prompt);
- return async(state = {}, submitted = false) => {
- let index = 0;
- state.required = required;
- state.items = items;
- state.keys = keys;
- state.output = '';
- let validate = async(value, state, item, index) => {
- let error = await isValid(value, state, item, index);
- if (error === false) {
- return 'Invalid field ' + item.name;
- }
- return error;
- };
- for (let token of tabstops) {
- let value = token.value;
- let key = token.key;
- if (token.type !== 'template') {
- if (value) state.output += value;
- continue;
- }
- if (token.type === 'template') {
- let item = items.find(ch => ch.name === key);
- if (options.required === true) {
- state.required.add(item.name);
- }
- let val = [item.input, state.values[item.value], item.value, value].find(isVal);
- let field = item.field || {};
- let message = field.message || token.inner;
- if (submitted) {
- let error = await validate(state.values[key], state, item, index);
- if ((error && typeof error === 'string') || error === false) {
- state.invalid.set(key, error);
- continue;
- }
- state.invalid.delete(key);
- let res = await result(state.values[key], state, item, index);
- state.output += colors.unstyle(res);
- continue;
- }
- item.placeholder = false;
- let before = value;
- value = await format(value, state, item, index);
- if (val !== value) {
- state.values[key] = val;
- value = prompt.styles.typing(val);
- state.missing.delete(message);
- } else {
- state.values[key] = void 0;
- val = `<${message}>`;
- value = prompt.styles.primary(val);
- item.placeholder = true;
- if (state.required.has(key)) {
- state.missing.add(message);
- }
- }
- if (state.missing.has(message) && state.validating) {
- value = prompt.styles.warning(val);
- }
- if (state.invalid.has(key) && state.validating) {
- value = prompt.styles.danger(val);
- }
- if (index === state.index) {
- if (before !== value) {
- value = prompt.styles.underline(value);
- } else {
- value = prompt.styles.heading(colors.unstyle(value));
- }
- }
- index++;
- }
- if (value) {
- state.output += value;
- }
- }
- let lines = state.output.split('\n').map(l => ' ' + l);
- let len = items.length;
- let done = 0;
- for (let item of items) {
- if (state.invalid.has(item.name)) {
- item.lines.forEach(i => {
- if (lines[i][0] !== ' ') return;
- lines[i] = state.styles.danger(state.symbols.bullet) + lines[i].slice(1);
- });
- }
- if (prompt.isValue(state.values[item.name])) {
- done++;
- }
- }
- state.completed = ((done / len) * 100).toFixed(0);
- state.output = lines.join('\n');
- return state.output;
- };
- };
- function createFn(prop, prompt, options, fallback) {
- return (value, state, item, index) => {
- if (typeof item.field[prop] === 'function') {
- return item.field[prop].call(prompt, value, state, item, index);
- }
- return [fallback, value].find(v => prompt.isValue(v));
- };
- }
- /***/ }),
- /***/ 28914:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const readline = __webpack_require__(51058);
- const combos = __webpack_require__(64726);
- /* eslint-disable no-control-regex */
- const metaKeyCodeRe = /^(?:\x1b)([a-zA-Z0-9])$/;
- const fnKeyRe = /^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/;
- const keyName = {
- /* xterm/gnome ESC O letter */
- 'OP': 'f1',
- 'OQ': 'f2',
- 'OR': 'f3',
- 'OS': 'f4',
- /* xterm/rxvt ESC [ number ~ */
- '[11~': 'f1',
- '[12~': 'f2',
- '[13~': 'f3',
- '[14~': 'f4',
- /* from Cygwin and used in libuv */
- '[[A': 'f1',
- '[[B': 'f2',
- '[[C': 'f3',
- '[[D': 'f4',
- '[[E': 'f5',
- /* common */
- '[15~': 'f5',
- '[17~': 'f6',
- '[18~': 'f7',
- '[19~': 'f8',
- '[20~': 'f9',
- '[21~': 'f10',
- '[23~': 'f11',
- '[24~': 'f12',
- /* xterm ESC [ letter */
- '[A': 'up',
- '[B': 'down',
- '[C': 'right',
- '[D': 'left',
- '[E': 'clear',
- '[F': 'end',
- '[H': 'home',
- /* xterm/gnome ESC O letter */
- 'OA': 'up',
- 'OB': 'down',
- 'OC': 'right',
- 'OD': 'left',
- 'OE': 'clear',
- 'OF': 'end',
- 'OH': 'home',
- /* xterm/rxvt ESC [ number ~ */
- '[1~': 'home',
- '[2~': 'insert',
- '[3~': 'delete',
- '[4~': 'end',
- '[5~': 'pageup',
- '[6~': 'pagedown',
- /* putty */
- '[[5~': 'pageup',
- '[[6~': 'pagedown',
- /* rxvt */
- '[7~': 'home',
- '[8~': 'end',
- /* rxvt keys with modifiers */
- '[a': 'up',
- '[b': 'down',
- '[c': 'right',
- '[d': 'left',
- '[e': 'clear',
- '[2$': 'insert',
- '[3$': 'delete',
- '[5$': 'pageup',
- '[6$': 'pagedown',
- '[7$': 'home',
- '[8$': 'end',
- 'Oa': 'up',
- 'Ob': 'down',
- 'Oc': 'right',
- 'Od': 'left',
- 'Oe': 'clear',
- '[2^': 'insert',
- '[3^': 'delete',
- '[5^': 'pageup',
- '[6^': 'pagedown',
- '[7^': 'home',
- '[8^': 'end',
- /* misc. */
- '[Z': 'tab',
- }
- function isShiftKey(code) {
- return ['[a', '[b', '[c', '[d', '[e', '[2$', '[3$', '[5$', '[6$', '[7$', '[8$', '[Z'].includes(code)
- }
- function isCtrlKey(code) {
- return [ 'Oa', 'Ob', 'Oc', 'Od', 'Oe', '[2^', '[3^', '[5^', '[6^', '[7^', '[8^'].includes(code)
- }
- const keypress = (s = '', event = {}) => {
- let parts;
- let key = {
- name: event.name,
- ctrl: false,
- meta: false,
- shift: false,
- option: false,
- sequence: s,
- raw: s,
- ...event
- };
- if (Buffer.isBuffer(s)) {
- if (s[0] > 127 && s[1] === void 0) {
- s[0] -= 128;
- s = '\x1b' + String(s);
- } else {
- s = String(s);
- }
- } else if (s !== void 0 && typeof s !== 'string') {
- s = String(s);
- } else if (!s) {
- s = key.sequence || '';
- }
- key.sequence = key.sequence || s || key.name;
- if (s === '\r') {
- // carriage return
- key.raw = void 0;
- key.name = 'return';
- } else if (s === '\n') {
- // enter, should have been called linefeed
- key.name = 'enter';
- } else if (s === '\t') {
- // tab
- key.name = 'tab';
- } else if (s === '\b' || s === '\x7f' || s === '\x1b\x7f' || s === '\x1b\b') {
- // backspace or ctrl+h
- key.name = 'backspace';
- key.meta = s.charAt(0) === '\x1b';
- } else if (s === '\x1b' || s === '\x1b\x1b') {
- // escape key
- key.name = 'escape';
- key.meta = s.length === 2;
- } else if (s === ' ' || s === '\x1b ') {
- key.name = 'space';
- key.meta = s.length === 2;
- } else if (s <= '\x1a') {
- // ctrl+letter
- key.name = String.fromCharCode(s.charCodeAt(0) + 'a'.charCodeAt(0) - 1);
- key.ctrl = true;
- } else if (s.length === 1 && s >= '0' && s <= '9') {
- // number
- key.name = 'number';
- } else if (s.length === 1 && s >= 'a' && s <= 'z') {
- // lowercase letter
- key.name = s;
- } else if (s.length === 1 && s >= 'A' && s <= 'Z') {
- // shift+letter
- key.name = s.toLowerCase();
- key.shift = true;
- } else if ((parts = metaKeyCodeRe.exec(s))) {
- // meta+character key
- key.meta = true;
- key.shift = /^[A-Z]$/.test(parts[1]);
- } else if ((parts = fnKeyRe.exec(s))) {
- let segs = [...s];
- if (segs[0] === '\u001b' && segs[1] === '\u001b') {
- key.option = true;
- }
- // ansi escape sequence
- // reassemble the key code leaving out leading \x1b's,
- // the modifier key bitflag and any meaningless "1;" sequence
- let code = [parts[1], parts[2], parts[4], parts[6]].filter(Boolean).join('');
- let modifier = (parts[3] || parts[5] || 1) - 1;
- // Parse the key modifier
- key.ctrl = !!(modifier & 4);
- key.meta = !!(modifier & 10);
- key.shift = !!(modifier & 1);
- key.code = code;
- key.name = keyName[code];
- key.shift = isShiftKey(code) || key.shift;
- key.ctrl = isCtrlKey(code) || key.ctrl;
- }
- return key;
- };
- keypress.listen = (options = {}, onKeypress) => {
- let { stdin } = options;
- if (!stdin || (stdin !== process.stdin && !stdin.isTTY)) {
- throw new Error('Invalid stream passed');
- }
- let rl = readline.createInterface({ terminal: true, input: stdin });
- readline.emitKeypressEvents(stdin, rl);
- let on = (buf, key) => onKeypress(buf, keypress(buf, key), rl);
- let isRaw = stdin.isRaw;
- if (stdin.isTTY) stdin.setRawMode(true);
- stdin.on('keypress', on);
- rl.resume();
- let off = () => {
- if (stdin.isTTY) stdin.setRawMode(isRaw);
- stdin.removeListener('keypress', on);
- rl.pause();
- rl.close();
- };
- return off;
- };
- keypress.action = (buf, key, customActions) => {
- let obj = { ...combos, ...customActions };
- if (key.ctrl) {
- key.action = obj.ctrl[key.name];
- return key;
- }
- if (key.option && obj.option) {
- key.action = obj.option[key.name];
- return key;
- }
- if (key.shift) {
- key.action = obj.shift[key.name];
- return key;
- }
- key.action = obj.keys[key.name];
- return key;
- };
- module.exports = keypress;
- /***/ }),
- /***/ 12786:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const utils = __webpack_require__(83546);
- /**
- * Render a placeholder value with cursor and styling based on the
- * position of the cursor.
- *
- * @param {Object} `prompt` Prompt instance.
- * @param {String} `input` Input string.
- * @param {String} `initial` The initial user-provided value.
- * @param {Number} `pos` Current cursor position.
- * @param {Boolean} `showCursor` Render a simulated cursor using the inverse primary style.
- * @return {String} Returns the styled placeholder string.
- * @api public
- */
- module.exports = (prompt, options = {}) => {
- prompt.cursorHide();
- let { input = '', initial = '', pos, showCursor = true, color } = options;
- let style = color || prompt.styles.placeholder;
- let inverse = utils.inverse(prompt.styles.primary);
- let blinker = str => inverse(prompt.styles.black(str));
- let output = input;
- let char = ' ';
- let reverse = blinker(char);
- if (prompt.blink && prompt.blink.off === true) {
- blinker = str => str;
- reverse = '';
- }
- if (showCursor && pos === 0 && initial === '' && input === '') {
- return blinker(char);
- }
- if (showCursor && pos === 0 && (input === initial || input === '')) {
- return blinker(initial[0]) + style(initial.slice(1));
- }
- initial = utils.isPrimitive(initial) ? `${initial}` : '';
- input = utils.isPrimitive(input) ? `${input}` : '';
- let placeholder = initial && initial.startsWith(input) && initial !== input;
- let cursor = placeholder ? blinker(initial[input.length]) : reverse;
- if (pos !== input.length && showCursor === true) {
- output = input.slice(0, pos) + blinker(input[pos]) + input.slice(pos + 1);
- cursor = '';
- }
- if (showCursor === false) {
- cursor = '';
- }
- if (placeholder) {
- let raw = prompt.styles.unstyle(output + cursor);
- return output + cursor + style(initial.slice(raw.length));
- }
- return output + cursor;
- };
- /***/ }),
- /***/ 232:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const Events = __webpack_require__(28614);
- const colors = __webpack_require__(53692);
- const keypress = __webpack_require__(28914);
- const timer = __webpack_require__(33940);
- const State = __webpack_require__(36873);
- const theme = __webpack_require__(39227);
- const utils = __webpack_require__(83546);
- const ansi = __webpack_require__(94907);
- /**
- * Base class for creating a new Prompt.
- * @param {Object} `options` Question object.
- */
- class Prompt extends Events {
- constructor(options = {}) {
- super();
- this.name = options.name;
- this.type = options.type;
- this.options = options;
- theme(this);
- timer(this);
- this.state = new State(this);
- this.initial = [options.initial, options.default].find(v => v != null);
- this.stdout = options.stdout || process.stdout;
- this.stdin = options.stdin || process.stdin;
- this.scale = options.scale || 1;
- this.term = this.options.term || process.env.TERM_PROGRAM;
- this.margin = margin(this.options.margin);
- this.setMaxListeners(0);
- setOptions(this);
- }
- async keypress(input, event = {}) {
- this.keypressed = true;
- let key = keypress.action(input, keypress(input, event), this.options.actions);
- this.state.keypress = key;
- this.emit('keypress', input, key);
- this.emit('state', this.state.clone());
- let fn = this.options[key.action] || this[key.action] || this.dispatch;
- if (typeof fn === 'function') {
- return await fn.call(this, input, key);
- }
- this.alert();
- }
- alert() {
- delete this.state.alert;
- if (this.options.show === false) {
- this.emit('alert');
- } else {
- this.stdout.write(ansi.code.beep);
- }
- }
- cursorHide() {
- this.stdout.write(ansi.cursor.hide());
- utils.onExit(() => this.cursorShow());
- }
- cursorShow() {
- this.stdout.write(ansi.cursor.show());
- }
- write(str) {
- if (!str) return;
- if (this.stdout && this.state.show !== false) {
- this.stdout.write(str);
- }
- this.state.buffer += str;
- }
- clear(lines = 0) {
- let buffer = this.state.buffer;
- this.state.buffer = '';
- if ((!buffer && !lines) || this.options.show === false) return;
- this.stdout.write(ansi.cursor.down(lines) + ansi.clear(buffer, this.width));
- }
- restore() {
- if (this.state.closed || this.options.show === false) return;
- let { prompt, after, rest } = this.sections();
- let { cursor, initial = '', input = '', value = '' } = this;
- let size = this.state.size = rest.length;
- let state = { after, cursor, initial, input, prompt, size, value };
- let codes = ansi.cursor.restore(state);
- if (codes) {
- this.stdout.write(codes);
- }
- }
- sections() {
- let { buffer, input, prompt } = this.state;
- prompt = colors.unstyle(prompt);
- let buf = colors.unstyle(buffer);
- let idx = buf.indexOf(prompt);
- let header = buf.slice(0, idx);
- let rest = buf.slice(idx);
- let lines = rest.split('\n');
- let first = lines[0];
- let last = lines[lines.length - 1];
- let promptLine = prompt + (input ? ' ' + input : '');
- let len = promptLine.length;
- let after = len < first.length ? first.slice(len + 1) : '';
- return { header, prompt: first, after, rest: lines.slice(1), last };
- }
- async submit() {
- this.state.submitted = true;
- this.state.validating = true;
- // this will only be called when the prompt is directly submitted
- // without initializing, i.e. when the prompt is skipped, etc. Otherwize,
- // "options.onSubmit" is will be handled by the "initialize()" method.
- if (this.options.onSubmit) {
- await this.options.onSubmit.call(this, this.name, this.value, this);
- }
- let result = this.state.error || await this.validate(this.value, this.state);
- if (result !== true) {
- let error = '\n' + this.symbols.pointer + ' ';
- if (typeof result === 'string') {
- error += result.trim();
- } else {
- error += 'Invalid input';
- }
- this.state.error = '\n' + this.styles.danger(error);
- this.state.submitted = false;
- await this.render();
- await this.alert();
- this.state.validating = false;
- this.state.error = void 0;
- return;
- }
- this.state.validating = false;
- await this.render();
- await this.close();
- this.value = await this.result(this.value);
- this.emit('submit', this.value);
- }
- async cancel(err) {
- this.state.cancelled = this.state.submitted = true;
- await this.render();
- await this.close();
- if (typeof this.options.onCancel === 'function') {
- await this.options.onCancel.call(this, this.name, this.value, this);
- }
- this.emit('cancel', await this.error(err));
- }
- async close() {
- this.state.closed = true;
- try {
- let sections = this.sections();
- let lines = Math.ceil(sections.prompt.length / this.width);
- if (sections.rest) {
- this.write(ansi.cursor.down(sections.rest.length));
- }
- this.write('\n'.repeat(lines));
- } catch (err) { /* do nothing */ }
- this.emit('close');
- }
- start() {
- if (!this.stop && this.options.show !== false) {
- this.stop = keypress.listen(this, this.keypress.bind(this));
- this.once('close', this.stop);
- }
- }
- async skip() {
- this.skipped = this.options.skip === true;
- if (typeof this.options.skip === 'function') {
- this.skipped = await this.options.skip.call(this, this.name, this.value);
- }
- return this.skipped;
- }
- async initialize() {
- let { format, options, result } = this;
- this.format = () => format.call(this, this.value);
- this.result = () => result.call(this, this.value);
- if (typeof options.initial === 'function') {
- this.initial = await options.initial.call(this, this);
- }
- if (typeof options.onRun === 'function') {
- await options.onRun.call(this, this);
- }
- // if "options.onSubmit" is defined, we wrap the "submit" method to guarantee
- // that "onSubmit" will always called first thing inside the submit
- // method, regardless of how it's handled in inheriting prompts.
- if (typeof options.onSubmit === 'function') {
- let onSubmit = options.onSubmit.bind(this);
- let submit = this.submit.bind(this);
- delete this.options.onSubmit;
- this.submit = async() => {
- await onSubmit(this.name, this.value, this);
- return submit();
- };
- }
- await this.start();
- await this.render();
- }
- render() {
- throw new Error('expected prompt to have a custom render method');
- }
- run() {
- return new Promise(async(resolve, reject) => {
- this.once('submit', resolve);
- this.once('cancel', reject);
- if (await this.skip()) {
- this.render = () => {};
- return this.submit();
- }
- await this.initialize();
- this.emit('run');
- });
- }
- async element(name, choice, i) {
- let { options, state, symbols, timers } = this;
- let timer = timers && timers[name];
- state.timer = timer;
- let value = options[name] || state[name] || symbols[name];
- let val = choice && choice[name] != null ? choice[name] : await value;
- if (val === '') return val;
- let res = await this.resolve(val, state, choice, i);
- if (!res && choice && choice[name]) {
- return this.resolve(value, state, choice, i);
- }
- return res;
- }
- async prefix() {
- let element = await this.element('prefix') || this.symbols;
- let timer = this.timers && this.timers.prefix;
- let state = this.state;
- state.timer = timer;
- if (utils.isObject(element)) element = element[state.status] || element.pending;
- if (!utils.hasColor(element)) {
- let style = this.styles[state.status] || this.styles.pending;
- return style(element);
- }
- return element;
- }
- async message() {
- let message = await this.element('message');
- if (!utils.hasColor(message)) {
- return this.styles.strong(message);
- }
- return message;
- }
- async separator() {
- let element = await this.element('separator') || this.symbols;
- let timer = this.timers && this.timers.separator;
- let state = this.state;
- state.timer = timer;
- let value = element[state.status] || element.pending || state.separator;
- let ele = await this.resolve(value, state);
- if (utils.isObject(ele)) ele = ele[state.status] || ele.pending;
- if (!utils.hasColor(ele)) {
- return this.styles.muted(ele);
- }
- return ele;
- }
- async pointer(choice, i) {
- let val = await this.element('pointer', choice, i);
- if (typeof val === 'string' && utils.hasColor(val)) {
- return val;
- }
- if (val) {
- let styles = this.styles;
- let focused = this.index === i;
- let style = focused ? styles.primary : val => val;
- let ele = await this.resolve(val[focused ? 'on' : 'off'] || val, this.state);
- let styled = !utils.hasColor(ele) ? style(ele) : ele;
- return focused ? styled : ' '.repeat(ele.length);
- }
- }
- async indicator(choice, i) {
- let val = await this.element('indicator', choice, i);
- if (typeof val === 'string' && utils.hasColor(val)) {
- return val;
- }
- if (val) {
- let styles = this.styles;
- let enabled = choice.enabled === true;
- let style = enabled ? styles.success : styles.dark;
- let ele = val[enabled ? 'on' : 'off'] || val;
- return !utils.hasColor(ele) ? style(ele) : ele;
- }
- return '';
- }
- body() {
- return null;
- }
- footer() {
- if (this.state.status === 'pending') {
- return this.element('footer');
- }
- }
- header() {
- if (this.state.status === 'pending') {
- return this.element('header');
- }
- }
- async hint() {
- if (this.state.status === 'pending' && !this.isValue(this.state.input)) {
- let hint = await this.element('hint');
- if (!utils.hasColor(hint)) {
- return this.styles.muted(hint);
- }
- return hint;
- }
- }
- error(err) {
- return !this.state.submitted ? (err || this.state.error) : '';
- }
- format(value) {
- return value;
- }
- result(value) {
- return value;
- }
- validate(value) {
- if (this.options.required === true) {
- return this.isValue(value);
- }
- return true;
- }
- isValue(value) {
- return value != null && value !== '';
- }
- resolve(value, ...args) {
- return utils.resolve(this, value, ...args);
- }
- get base() {
- return Prompt.prototype;
- }
- get style() {
- return this.styles[this.state.status];
- }
- get height() {
- return this.options.rows || utils.height(this.stdout, 25);
- }
- get width() {
- return this.options.columns || utils.width(this.stdout, 80);
- }
- get size() {
- return { width: this.width, height: this.height };
- }
- set cursor(value) {
- this.state.cursor = value;
- }
- get cursor() {
- return this.state.cursor;
- }
- set input(value) {
- this.state.input = value;
- }
- get input() {
- return this.state.input;
- }
- set value(value) {
- this.state.value = value;
- }
- get value() {
- let { input, value } = this.state;
- let result = [value, input].find(this.isValue.bind(this));
- return this.isValue(result) ? result : this.initial;
- }
- static get prompt() {
- return options => new this(options).run();
- }
- }
- function setOptions(prompt) {
- let isValidKey = key => {
- return prompt[key] === void 0 || typeof prompt[key] === 'function';
- };
- let ignore = [
- 'actions',
- 'choices',
- 'initial',
- 'margin',
- 'roles',
- 'styles',
- 'symbols',
- 'theme',
- 'timers',
- 'value'
- ];
- let ignoreFn = [
- 'body',
- 'footer',
- 'error',
- 'header',
- 'hint',
- 'indicator',
- 'message',
- 'prefix',
- 'separator',
- 'skip'
- ];
- for (let key of Object.keys(prompt.options)) {
- if (ignore.includes(key)) continue;
- if (/^on[A-Z]/.test(key)) continue;
- let option = prompt.options[key];
- if (typeof option === 'function' && isValidKey(key)) {
- if (!ignoreFn.includes(key)) {
- prompt[key] = option.bind(prompt);
- }
- } else if (typeof prompt[key] !== 'function') {
- prompt[key] = option;
- }
- }
- }
- function margin(value) {
- if (typeof value === 'number') {
- value = [value, value, value, value];
- }
- let arr = [].concat(value || []);
- let pad = i => i % 2 === 0 ? '\n' : ' ';
- let res = [];
- for (let i = 0; i < 4; i++) {
- let char = pad(i);
- if (arr[i]) {
- res.push(char.repeat(arr[i]));
- } else {
- res.push('');
- }
- }
- return res;
- }
- module.exports = Prompt;
- /***/ }),
- /***/ 89317:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const Select = __webpack_require__(13466);
- const highlight = (input, color) => {
- let val = input.toLowerCase();
- return str => {
- let s = str.toLowerCase();
- let i = s.indexOf(val);
- let colored = color(str.slice(i, i + val.length));
- return i >= 0 ? str.slice(0, i) + colored + str.slice(i + val.length) : str;
- };
- };
- class AutoComplete extends Select {
- constructor(options) {
- super(options);
- this.cursorShow();
- }
- moveCursor(n) {
- this.state.cursor += n;
- }
- dispatch(ch) {
- return this.append(ch);
- }
- space(ch) {
- return this.options.multiple ? super.space(ch) : this.append(ch);
- }
- append(ch) {
- let { cursor, input } = this.state;
- this.input = input.slice(0, cursor) + ch + input.slice(cursor);
- this.moveCursor(1);
- return this.complete();
- }
- delete() {
- let { cursor, input } = this.state;
- if (!input) return this.alert();
- this.input = input.slice(0, cursor - 1) + input.slice(cursor);
- this.moveCursor(-1);
- return this.complete();
- }
- deleteForward() {
- let { cursor, input } = this.state;
- if (input[cursor] === void 0) return this.alert();
- this.input = `${input}`.slice(0, cursor) + `${input}`.slice(cursor + 1);
- return this.complete();
- }
- number(ch) {
- return this.append(ch);
- }
- async complete() {
- this.completing = true;
- this.choices = await this.suggest(this.input, this.state._choices);
- this.state.limit = void 0; // allow getter/setter to reset limit
- this.index = Math.min(Math.max(this.visible.length - 1, 0), this.index);
- await this.render();
- this.completing = false;
- }
- suggest(input = this.input, choices = this.state._choices) {
- if (typeof this.options.suggest === 'function') {
- return this.options.suggest.call(this, input, choices);
- }
- let str = input.toLowerCase();
- return choices.filter(ch => ch.message.toLowerCase().includes(str));
- }
- pointer() {
- return '';
- }
- format() {
- if (!this.focused) return this.input;
- if (this.options.multiple && this.state.submitted) {
- return this.selected.map(ch => this.styles.primary(ch.message)).join(', ');
- }
- if (this.state.submitted) {
- let value = this.value = this.input = this.focused.value;
- return this.styles.primary(value);
- }
- return this.input;
- }
- async render() {
- if (this.state.status !== 'pending') return super.render();
- let style = this.options.highlight
- ? this.options.highlight.bind(this)
- : this.styles.placeholder;
- let color = highlight(this.input, style);
- let choices = this.choices;
- this.choices = choices.map(ch => ({ ...ch, message: color(ch.message) }));
- await super.render();
- this.choices = choices;
- }
- submit() {
- if (this.options.multiple) {
- this.value = this.selected.map(ch => ch.name);
- }
- return super.submit();
- }
- }
- module.exports = AutoComplete;
- /***/ }),
- /***/ 7186:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const AuthPrompt = __webpack_require__(66926);
- function defaultAuthenticate(value, state) {
- if (value.username === this.options.username && value.password === this.options.password) {
- return true;
- }
- return false;
- }
- const factory = (authenticate = defaultAuthenticate) => {
- const choices = [
- { name: 'username', message: 'username' },
- {
- name: 'password',
- message: 'password',
- format(input) {
- if (this.options.showPassword) {
- return input;
- }
- let color = this.state.submitted ? this.styles.primary : this.styles.muted;
- return color(this.symbols.asterisk.repeat(input.length));
- }
- }
- ];
- class BasicAuthPrompt extends AuthPrompt.create(authenticate) {
- constructor(options) {
- super({ ...options, choices });
- }
- static create(authenticate) {
- return factory(authenticate);
- }
- }
- return BasicAuthPrompt;
- };
- module.exports = factory();
- /***/ }),
- /***/ 31291:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const BooleanPrompt = __webpack_require__(23838);
- class ConfirmPrompt extends BooleanPrompt {
- constructor(options) {
- super(options);
- this.default = this.options.default || (this.initial ? '(Y/n)' : '(y/N)');
- }
- }
- module.exports = ConfirmPrompt;
- /***/ }),
- /***/ 50848:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const Select = __webpack_require__(13466);
- const Form = __webpack_require__(21826);
- const form = Form.prototype;
- class Editable extends Select {
- constructor(options) {
- super({ ...options, multiple: true });
- this.align = [this.options.align, 'left'].find(v => v != null);
- this.emptyError = '';
- this.values = {};
- }
- dispatch(char, key) {
- let choice = this.focused;
- let parent = choice.parent || {};
- if (!choice.editable && !parent.editable) {
- if (char === 'a' || char === 'i') return super[char]();
- }
- return form.dispatch.call(this, char, key);
- }
- append(char, key) {
- return form.append.call(this, char, key);
- }
- delete(char, key) {
- return form.delete.call(this, char, key);
- }
- space(char) {
- return this.focused.editable ? this.append(char) : super.space();
- }
- number(char) {
- return this.focused.editable ? this.append(char) : super.number(char);
- }
- next() {
- return this.focused.editable ? form.next.call(this) : super.next();
- }
- prev() {
- return this.focused.editable ? form.prev.call(this) : super.prev();
- }
- async indicator(choice, i) {
- let symbol = choice.indicator || '';
- let value = choice.editable ? symbol : super.indicator(choice, i);
- return await this.resolve(value, this.state, choice, i) || '';
- }
- indent(choice) {
- return choice.role === 'heading' ? '' : (choice.editable ? ' ' : ' ');
- }
- async renderChoice(choice, i) {
- choice.indent = '';
- if (choice.editable) return form.renderChoice.call(this, choice, i);
- return super.renderChoice(choice, i);
- }
- error() {
- return '';
- }
- footer() {
- return this.state.error;
- }
- async validate() {
- let result = true;
- for (let choice of this.choices) {
- if (typeof choice.validate !== 'function') {
- continue;
- }
- if (choice.role === 'heading') {
- continue;
- }
- let val = choice.parent ? this.value[choice.parent.name] : this.value;
- if (choice.editable) {
- val = choice.value === choice.name ? choice.initial || '' : choice.value;
- } else if (!this.isDisabled(choice)) {
- val = choice.enabled === true;
- }
- result = await choice.validate(val, this.state);
- if (result !== true) {
- break;
- }
- }
- if (result !== true) {
- this.state.error = typeof result === 'string' ? result : 'Invalid Input';
- }
- return result;
- }
- submit() {
- if (this.focused.newChoice === true) return super.submit();
- if (this.choices.some(ch => ch.newChoice)) {
- return this.alert();
- }
- this.value = {};
- for (let choice of this.choices) {
- let val = choice.parent ? this.value[choice.parent.name] : this.value;
- if (choice.role === 'heading') {
- this.value[choice.name] = {};
- continue;
- }
- if (choice.editable) {
- val[choice.name] = choice.value === choice.name
- ? (choice.initial || '')
- : choice.value;
- } else if (!this.isDisabled(choice)) {
- val[choice.name] = choice.enabled === true;
- }
- }
- return this.base.submit.call(this);
- }
- }
- module.exports = Editable;
- /***/ }),
- /***/ 21826:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const colors = __webpack_require__(53692);
- const SelectPrompt = __webpack_require__(13466);
- const placeholder = __webpack_require__(12786);
- class FormPrompt extends SelectPrompt {
- constructor(options) {
- super({ ...options, multiple: true });
- this.type = 'form';
- this.initial = this.options.initial;
- this.align = [this.options.align, 'right'].find(v => v != null);
- this.emptyError = '';
- this.values = {};
- }
- async reset(first) {
- await super.reset();
- if (first === true) this._index = this.index;
- this.index = this._index;
- this.values = {};
- this.choices.forEach(choice => choice.reset && choice.reset());
- return this.render();
- }
- dispatch(char) {
- return !!char && this.append(char);
- }
- append(char) {
- let choice = this.focused;
- if (!choice) return this.alert();
- let { cursor, input } = choice;
- choice.value = choice.input = input.slice(0, cursor) + char + input.slice(cursor);
- choice.cursor++;
- return this.render();
- }
- delete() {
- let choice = this.focused;
- if (!choice || choice.cursor <= 0) return this.alert();
- let { cursor, input } = choice;
- choice.value = choice.input = input.slice(0, cursor - 1) + input.slice(cursor);
- choice.cursor--;
- return this.render();
- }
- deleteForward() {
- let choice = this.focused;
- if (!choice) return this.alert();
- let { cursor, input } = choice;
- if (input[cursor] === void 0) return this.alert();
- let str = `${input}`.slice(0, cursor) + `${input}`.slice(cursor + 1);
- choice.value = choice.input = str;
- return this.render();
- }
- right() {
- let choice = this.focused;
- if (!choice) return this.alert();
- if (choice.cursor >= choice.input.length) return this.alert();
- choice.cursor++;
- return this.render();
- }
- left() {
- let choice = this.focused;
- if (!choice) return this.alert();
- if (choice.cursor <= 0) return this.alert();
- choice.cursor--;
- return this.render();
- }
- space(ch, key) {
- return this.dispatch(ch, key);
- }
- number(ch, key) {
- return this.dispatch(ch, key);
- }
- next() {
- let ch = this.focused;
- if (!ch) return this.alert();
- let { initial, input } = ch;
- if (initial && initial.startsWith(input) && input !== initial) {
- ch.value = ch.input = initial;
- ch.cursor = ch.value.length;
- return this.render();
- }
- return super.next();
- }
- prev() {
- let ch = this.focused;
- if (!ch) return this.alert();
- if (ch.cursor === 0) return super.prev();
- ch.value = ch.input = '';
- ch.cursor = 0;
- return this.render();
- }
- separator() {
- return '';
- }
- format(value) {
- return !this.state.submitted ? super.format(value) : '';
- }
- pointer() {
- return '';
- }
- indicator(choice) {
- return choice.input ? '⦿' : '⊙';
- }
- async choiceSeparator(choice, i) {
- let sep = await this.resolve(choice.separator, this.state, choice, i) || ':';
- return sep ? ' ' + this.styles.disabled(sep) : '';
- }
- async renderChoice(choice, i) {
- await this.onChoice(choice, i);
- let { state, styles } = this;
- let { cursor, initial = '', name, hint, input = '' } = choice;
- let { muted, submitted, primary, danger } = styles;
- let help = hint;
- let focused = this.index === i;
- let validate = choice.validate || (() => true);
- let sep = await this.choiceSeparator(choice, i);
- let msg = choice.message;
- if (this.align === 'right') msg = msg.padStart(this.longest + 1, ' ');
- if (this.align === 'left') msg = msg.padEnd(this.longest + 1, ' ');
- // re-populate the form values (answers) object
- let value = this.values[name] = (input || initial);
- let color = input ? 'success' : 'dark';
- if ((await validate.call(choice, value, this.state)) !== true) {
- color = 'danger';
- }
- let style = styles[color];
- let indicator = style(await this.indicator(choice, i)) + (choice.pad || '');
- let indent = this.indent(choice);
- let line = () => [indent, indicator, msg + sep, input, help].filter(Boolean).join(' ');
- if (state.submitted) {
- msg = colors.unstyle(msg);
- input = submitted(input);
- help = '';
- return line();
- }
- if (choice.format) {
- input = await choice.format.call(this, input, choice, i);
- } else {
- let color = this.styles.muted;
- let options = { input, initial, pos: cursor, showCursor: focused, color };
- input = placeholder(this, options);
- }
- if (!this.isValue(input)) {
- input = this.styles.muted(this.symbols.ellipsis);
- }
- if (choice.result) {
- this.values[name] = await choice.result.call(this, value, choice, i);
- }
- if (focused) {
- msg = primary(msg);
- }
- if (choice.error) {
- input += (input ? ' ' : '') + danger(choice.error.trim());
- } else if (choice.hint) {
- input += (input ? ' ' : '') + muted(choice.hint.trim());
- }
- return line();
- }
- async submit() {
- this.value = this.values;
- return super.base.submit.call(this);
- }
- }
- module.exports = FormPrompt;
- /***/ }),
- /***/ 29594:
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- const utils = __webpack_require__(83546);
- const define = (key, fn) => {
- utils.defineExport(exports, key, fn);
- utils.defineExport(exports, key.toLowerCase(), fn);
- };
- define('AutoComplete', () => __webpack_require__(89317));
- define('BasicAuth', () => __webpack_require__(7186));
- define('Confirm', () => __webpack_require__(31291));
- define('Editable', () => __webpack_require__(50848));
- define('Form', () => __webpack_require__(21826));
- define('Input', () => __webpack_require__(66719));
- define('Invisible', () => __webpack_require__(99822));
- define('List', () => __webpack_require__(16795));
- define('MultiSelect', () => __webpack_require__(91056));
- define('Numeral', () => __webpack_require__(17403));
- define('Password', () => __webpack_require__(46847));
- define('Scale', () => __webpack_require__(17813));
- define('Select', () => __webpack_require__(13466));
- define('Snippet', () => __webpack_require__(19451));
- define('Sort', () => __webpack_require__(7144));
- define('Survey', () => __webpack_require__(83755));
- define('Text', () => __webpack_require__(5781));
- define('Toggle', () => __webpack_require__(10653));
- define('Quiz', () => __webpack_require__(92249));
- /***/ }),
- /***/ 66719:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const Prompt = __webpack_require__(43391);
- const completer = __webpack_require__(73736);
- class Input extends Prompt {
- constructor(options) {
- super(options);
- let history = this.options.history;
- if (history && history.store) {
- let initial = history.values || this.initial;
- this.autosave = !!history.autosave;
- this.store = history.store;
- this.data = this.store.get('values') || { past: [], present: initial };
- this.initial = this.data.present || this.data.past[this.data.past.length - 1];
- }
- }
- completion(action) {
- if (!this.store) return this.alert();
- this.data = completer(action, this.data, this.input);
- if (!this.data.present) return this.alert();
- this.input = this.data.present;
- this.cursor = this.input.length;
- return this.render();
- }
- altUp() {
- return this.completion('prev');
- }
- altDown() {
- return this.completion('next');
- }
- prev() {
- this.save();
- return super.prev();
- }
- save() {
- if (!this.store) return;
- this.data = completer('save', this.data, this.input);
- this.store.set('values', this.data);
- }
- submit() {
- if (this.store && this.autosave === true) {
- this.save();
- }
- return super.submit();
- }
- }
- module.exports = Input;
- /***/ }),
- /***/ 99822:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const StringPrompt = __webpack_require__(43391);
- class InvisiblePrompt extends StringPrompt {
- format() {
- return '';
- }
- }
- module.exports = InvisiblePrompt;
- /***/ }),
- /***/ 16795:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const StringPrompt = __webpack_require__(43391);
- class ListPrompt extends StringPrompt {
- constructor(options = {}) {
- super(options);
- this.sep = this.options.separator || /, */;
- this.initial = options.initial || '';
- }
- split(input = this.value) {
- return input ? String(input).split(this.sep) : [];
- }
- format() {
- let style = this.state.submitted ? this.styles.primary : val => val;
- return this.list.map(style).join(', ');
- }
- async submit(value) {
- let result = this.state.error || await this.validate(this.list, this.state);
- if (result !== true) {
- this.state.error = result;
- return super.submit();
- }
- this.value = this.list;
- return super.submit();
- }
- get list() {
- return this.split();
- }
- }
- module.exports = ListPrompt;
- /***/ }),
- /***/ 91056:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const Select = __webpack_require__(13466);
- class MultiSelect extends Select {
- constructor(options) {
- super({ ...options, multiple: true });
- }
- }
- module.exports = MultiSelect;
- /***/ }),
- /***/ 17403:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- module.exports = __webpack_require__(45376);
- /***/ }),
- /***/ 46847:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const StringPrompt = __webpack_require__(43391);
- class PasswordPrompt extends StringPrompt {
- constructor(options) {
- super(options);
- this.cursorShow();
- }
- format(input = this.input) {
- if (!this.keypressed) return '';
- let color = this.state.submitted ? this.styles.primary : this.styles.muted;
- return color(this.symbols.asterisk.repeat(input.length));
- }
- }
- module.exports = PasswordPrompt;
- /***/ }),
- /***/ 92249:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const SelectPrompt = __webpack_require__(13466);
- class Quiz extends SelectPrompt {
- constructor(options) {
- super(options);
- if (typeof this.options.correctChoice !== 'number' || this.options.correctChoice < 0) {
- throw new Error('Please specify the index of the correct answer from the list of choices');
- }
- }
- async toChoices(value, parent) {
- let choices = await super.toChoices(value, parent);
- if (choices.length < 2) {
- throw new Error('Please give at least two choices to the user');
- }
- if (this.options.correctChoice > choices.length) {
- throw new Error('Please specify the index of the correct answer from the list of choices');
- }
- return choices;
- }
- check(state) {
- return state.index === this.options.correctChoice;
- }
- async result(selected) {
- return {
- selectedAnswer: selected,
- correctAnswer: this.options.choices[this.options.correctChoice].value,
- correct: await this.check(this.state)
- };
- }
- }
- module.exports = Quiz;
- /***/ }),
- /***/ 17813:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const colors = __webpack_require__(53692);
- const ArrayPrompt = __webpack_require__(98575);
- const utils = __webpack_require__(83546);
- class LikertScale extends ArrayPrompt {
- constructor(options = {}) {
- super(options);
- this.widths = [].concat(options.messageWidth || 50);
- this.align = [].concat(options.align || 'left');
- this.linebreak = options.linebreak || false;
- this.edgeLength = options.edgeLength || 3;
- this.newline = options.newline || '\n ';
- let start = options.startNumber || 1;
- if (typeof this.scale === 'number') {
- this.scaleKey = false;
- this.scale = Array(this.scale).fill(0).map((v, i) => ({ name: i + start }));
- }
- }
- async reset() {
- this.tableized = false;
- await super.reset();
- return this.render();
- }
- tableize() {
- if (this.tableized === true) return;
- this.tableized = true;
- let longest = 0;
- for (let ch of this.choices) {
- longest = Math.max(longest, ch.message.length);
- ch.scaleIndex = ch.initial || 2;
- ch.scale = [];
- for (let i = 0; i < this.scale.length; i++) {
- ch.scale.push({ index: i });
- }
- }
- this.widths[0] = Math.min(this.widths[0], longest + 3);
- }
- async dispatch(s, key) {
- if (this.multiple) {
- return this[key.name] ? await this[key.name](s, key) : await super.dispatch(s, key);
- }
- this.alert();
- }
- heading(msg, item, i) {
- return this.styles.strong(msg);
- }
- separator() {
- return this.styles.muted(this.symbols.ellipsis);
- }
- right() {
- let choice = this.focused;
- if (choice.scaleIndex >= this.scale.length - 1) return this.alert();
- choice.scaleIndex++;
- return this.render();
- }
- left() {
- let choice = this.focused;
- if (choice.scaleIndex <= 0) return this.alert();
- choice.scaleIndex--;
- return this.render();
- }
- indent() {
- return '';
- }
- format() {
- if (this.state.submitted) {
- let values = this.choices.map(ch => this.styles.info(ch.index));
- return values.join(', ');
- }
- return '';
- }
- pointer() {
- return '';
- }
- /**
- * Render the scale "Key". Something like:
- * @return {String}
- */
- renderScaleKey() {
- if (this.scaleKey === false) return '';
- if (this.state.submitted) return '';
- let scale = this.scale.map(item => ` ${item.name} - ${item.message}`);
- let key = ['', ...scale].map(item => this.styles.muted(item));
- return key.join('\n');
- }
- /**
- * Render the heading row for the scale.
- * @return {String}
- */
- renderScaleHeading(max) {
- let keys = this.scale.map(ele => ele.name);
- if (typeof this.options.renderScaleHeading === 'function') {
- keys = this.options.renderScaleHeading.call(this, max);
- }
- let diff = this.scaleLength - keys.join('').length;
- let spacing = Math.round(diff / (keys.length - 1));
- let names = keys.map(key => this.styles.strong(key));
- let headings = names.join(' '.repeat(spacing));
- let padding = ' '.repeat(this.widths[0]);
- return this.margin[3] + padding + this.margin[1] + headings;
- }
- /**
- * Render a scale indicator => ◯ or ◉ by default
- */
- scaleIndicator(choice, item, i) {
- if (typeof this.options.scaleIndicator === 'function') {
- return this.options.scaleIndicator.call(this, choice, item, i);
- }
- let enabled = choice.scaleIndex === item.index;
- if (item.disabled) return this.styles.hint(this.symbols.radio.disabled);
- if (enabled) return this.styles.success(this.symbols.radio.on);
- return this.symbols.radio.off;
- }
- /**
- * Render the actual scale => ◯────◯────◉────◯────◯
- */
- renderScale(choice, i) {
- let scale = choice.scale.map(item => this.scaleIndicator(choice, item, i));
- let padding = this.term === 'Hyper' ? '' : ' ';
- return scale.join(padding + this.symbols.line.repeat(this.edgeLength));
- }
- /**
- * Render a choice, including scale =>
- * "The website is easy to navigate. ◯───◯───◉───◯───◯"
- */
- async renderChoice(choice, i) {
- await this.onChoice(choice, i);
- let focused = this.index === i;
- let pointer = await this.pointer(choice, i);
- let hint = await choice.hint;
- if (hint && !utils.hasColor(hint)) {
- hint = this.styles.muted(hint);
- }
- let pad = str => this.margin[3] + str.replace(/\s+$/, '').padEnd(this.widths[0], ' ');
- let newline = this.newline;
- let ind = this.indent(choice);
- let message = await this.resolve(choice.message, this.state, choice, i);
- let scale = await this.renderScale(choice, i);
- let margin = this.margin[1] + this.margin[3];
- this.scaleLength = colors.unstyle(scale).length;
- this.widths[0] = Math.min(this.widths[0], this.width - this.scaleLength - margin.length);
- let msg = utils.wordWrap(message, { width: this.widths[0], newline });
- let lines = msg.split('\n').map(line => pad(line) + this.margin[1]);
- if (focused) {
- scale = this.styles.info(scale);
- lines = lines.map(line => this.styles.info(line));
- }
- lines[0] += scale;
- if (this.linebreak) lines.push('');
- return [ind + pointer, lines.join('\n')].filter(Boolean);
- }
- async renderChoices() {
- if (this.state.submitted) return '';
- this.tableize();
- let choices = this.visible.map(async(ch, i) => await this.renderChoice(ch, i));
- let visible = await Promise.all(choices);
- let heading = await this.renderScaleHeading();
- return this.margin[0] + [heading, ...visible.map(v => v.join(' '))].join('\n');
- }
- async render() {
- let { submitted, size } = this.state;
- let prefix = await this.prefix();
- let separator = await this.separator();
- let message = await this.message();
- let prompt = '';
- if (this.options.promptLine !== false) {
- prompt = [prefix, message, separator, ''].join(' ');
- this.state.prompt = prompt;
- }
- let header = await this.header();
- let output = await this.format();
- let key = await this.renderScaleKey();
- let help = await this.error() || await this.hint();
- let body = await this.renderChoices();
- let footer = await this.footer();
- let err = this.emptyError;
- if (output) prompt += output;
- if (help && !prompt.includes(help)) prompt += ' ' + help;
- if (submitted && !output && !body.trim() && this.multiple && err != null) {
- prompt += this.styles.danger(err);
- }
- this.clear(size);
- this.write([header, prompt, key, body, footer].filter(Boolean).join('\n'));
- if (!this.state.submitted) {
- this.write(this.margin[2]);
- }
- this.restore();
- }
- submit() {
- this.value = {};
- for (let choice of this.choices) {
- this.value[choice.name] = choice.scaleIndex;
- }
- return this.base.submit.call(this);
- }
- }
- module.exports = LikertScale;
- /***/ }),
- /***/ 13466:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const ArrayPrompt = __webpack_require__(98575);
- const utils = __webpack_require__(83546);
- class SelectPrompt extends ArrayPrompt {
- constructor(options) {
- super(options);
- this.emptyError = this.options.emptyError || 'No items were selected';
- }
- async dispatch(s, key) {
- if (this.multiple) {
- return this[key.name] ? await this[key.name](s, key) : await super.dispatch(s, key);
- }
- this.alert();
- }
- separator() {
- if (this.options.separator) return super.separator();
- let sep = this.styles.muted(this.symbols.ellipsis);
- return this.state.submitted ? super.separator() : sep;
- }
- pointer(choice, i) {
- return (!this.multiple || this.options.pointer) ? super.pointer(choice, i) : '';
- }
- indicator(choice, i) {
- return this.multiple ? super.indicator(choice, i) : '';
- }
- choiceMessage(choice, i) {
- let message = this.resolve(choice.message, this.state, choice, i);
- if (choice.role === 'heading' && !utils.hasColor(message)) {
- message = this.styles.strong(message);
- }
- return this.resolve(message, this.state, choice, i);
- }
- choiceSeparator() {
- return ':';
- }
- async renderChoice(choice, i) {
- await this.onChoice(choice, i);
- let focused = this.index === i;
- let pointer = await this.pointer(choice, i);
- let check = await this.indicator(choice, i) + (choice.pad || '');
- let hint = await this.resolve(choice.hint, this.state, choice, i);
- if (hint && !utils.hasColor(hint)) {
- hint = this.styles.muted(hint);
- }
- let ind = this.indent(choice);
- let msg = await this.choiceMessage(choice, i);
- let line = () => [this.margin[3], ind + pointer + check, msg, this.margin[1], hint].filter(Boolean).join(' ');
- if (choice.role === 'heading') {
- return line();
- }
- if (choice.disabled) {
- if (!utils.hasColor(msg)) {
- msg = this.styles.disabled(msg);
- }
- return line();
- }
- if (focused) {
- msg = this.styles.em(msg);
- }
- return line();
- }
- async renderChoices() {
- if (this.state.loading === 'choices') {
- return this.styles.warning('Loading choices');
- }
- if (this.state.submitted) return '';
- let choices = this.visible.map(async(ch, i) => await this.renderChoice(ch, i));
- let visible = await Promise.all(choices);
- if (!visible.length) visible.push(this.styles.danger('No matching choices'));
- let result = this.margin[0] + visible.join('\n');
- let header;
- if (this.options.choicesHeader) {
- header = await this.resolve(this.options.choicesHeader, this.state);
- }
- return [header, result].filter(Boolean).join('\n');
- }
- format() {
- if (!this.state.submitted || this.state.cancelled) return '';
- if (Array.isArray(this.selected)) {
- return this.selected.map(choice => this.styles.primary(choice.name)).join(', ');
- }
- return this.styles.primary(this.selected.name);
- }
- async render() {
- let { submitted, size } = this.state;
- let prompt = '';
- let header = await this.header();
- let prefix = await this.prefix();
- let separator = await this.separator();
- let message = await this.message();
- if (this.options.promptLine !== false) {
- prompt = [prefix, message, separator, ''].join(' ');
- this.state.prompt = prompt;
- }
- let output = await this.format();
- let help = (await this.error()) || (await this.hint());
- let body = await this.renderChoices();
- let footer = await this.footer();
- if (output) prompt += output;
- if (help && !prompt.includes(help)) prompt += ' ' + help;
- if (submitted && !output && !body.trim() && this.multiple && this.emptyError != null) {
- prompt += this.styles.danger(this.emptyError);
- }
- this.clear(size);
- this.write([header, prompt, body, footer].filter(Boolean).join('\n'));
- this.write(this.margin[2]);
- this.restore();
- }
- }
- module.exports = SelectPrompt;
- /***/ }),
- /***/ 19451:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const colors = __webpack_require__(53692);
- const interpolate = __webpack_require__(27189);
- const Prompt = __webpack_require__(232);
- class SnippetPrompt extends Prompt {
- constructor(options) {
- super(options);
- this.cursorHide();
- this.reset(true);
- }
- async initialize() {
- this.interpolate = await interpolate(this);
- await super.initialize();
- }
- async reset(first) {
- this.state.keys = [];
- this.state.invalid = new Map();
- this.state.missing = new Set();
- this.state.completed = 0;
- this.state.values = {};
- if (first !== true) {
- await this.initialize();
- await this.render();
- }
- }
- moveCursor(n) {
- let item = this.getItem();
- this.cursor += n;
- item.cursor += n;
- }
- dispatch(ch, key) {
- if (!key.code && !key.ctrl && ch != null && this.getItem()) {
- this.append(ch, key);
- return;
- }
- this.alert();
- }
- append(ch, key) {
- let item = this.getItem();
- let prefix = item.input.slice(0, this.cursor);
- let suffix = item.input.slice(this.cursor);
- this.input = item.input = `${prefix}${ch}${suffix}`;
- this.moveCursor(1);
- this.render();
- }
- delete() {
- let item = this.getItem();
- if (this.cursor <= 0 || !item.input) return this.alert();
- let suffix = item.input.slice(this.cursor);
- let prefix = item.input.slice(0, this.cursor - 1);
- this.input = item.input = `${prefix}${suffix}`;
- this.moveCursor(-1);
- this.render();
- }
- increment(i) {
- return i >= this.state.keys.length - 1 ? 0 : i + 1;
- }
- decrement(i) {
- return i <= 0 ? this.state.keys.length - 1 : i - 1;
- }
- first() {
- this.state.index = 0;
- this.render();
- }
- last() {
- this.state.index = this.state.keys.length - 1;
- this.render();
- }
- right() {
- if (this.cursor >= this.input.length) return this.alert();
- this.moveCursor(1);
- this.render();
- }
- left() {
- if (this.cursor <= 0) return this.alert();
- this.moveCursor(-1);
- this.render();
- }
- prev() {
- this.state.index = this.decrement(this.state.index);
- this.getItem();
- this.render();
- }
- next() {
- this.state.index = this.increment(this.state.index);
- this.getItem();
- this.render();
- }
- up() {
- this.prev();
- }
- down() {
- this.next();
- }
- format(value) {
- let color = this.state.completed < 100 ? this.styles.warning : this.styles.success;
- if (this.state.submitted === true && this.state.completed !== 100) {
- color = this.styles.danger;
- }
- return color(`${this.state.completed}% completed`);
- }
- async render() {
- let { index, keys = [], submitted, size } = this.state;
- let newline = [this.options.newline, '\n'].find(v => v != null);
- let prefix = await this.prefix();
- let separator = await this.separator();
- let message = await this.message();
- let prompt = [prefix, message, separator].filter(Boolean).join(' ');
- this.state.prompt = prompt;
- let header = await this.header();
- let error = (await this.error()) || '';
- let hint = (await this.hint()) || '';
- let body = submitted ? '' : await this.interpolate(this.state);
- let key = this.state.key = keys[index] || '';
- let input = await this.format(key);
- let footer = await this.footer();
- if (input) prompt += ' ' + input;
- if (hint && !input && this.state.completed === 0) prompt += ' ' + hint;
- this.clear(size);
- let lines = [header, prompt, body, footer, error.trim()];
- this.write(lines.filter(Boolean).join(newline));
- this.restore();
- }
- getItem(name) {
- let { items, keys, index } = this.state;
- let item = items.find(ch => ch.name === keys[index]);
- if (item && item.input != null) {
- this.input = item.input;
- this.cursor = item.cursor;
- }
- return item;
- }
- async submit() {
- if (typeof this.interpolate !== 'function') await this.initialize();
- await this.interpolate(this.state, true);
- let { invalid, missing, output, values } = this.state;
- if (invalid.size) {
- let err = '';
- for (let [key, value] of invalid) err += `Invalid ${key}: ${value}\n`;
- this.state.error = err;
- return super.submit();
- }
- if (missing.size) {
- this.state.error = 'Required: ' + [...missing.keys()].join(', ');
- return super.submit();
- }
- let lines = colors.unstyle(output).split('\n');
- let result = lines.map(v => v.slice(1)).join('\n');
- this.value = { values, result };
- return super.submit();
- }
- }
- module.exports = SnippetPrompt;
- /***/ }),
- /***/ 7144:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const hint = '(Use <shift>+<up/down> to sort)';
- const Prompt = __webpack_require__(13466);
- class Sort extends Prompt {
- constructor(options) {
- super({ ...options, reorder: false, sort: true, multiple: true });
- this.state.hint = [this.options.hint, hint].find(this.isValue.bind(this));
- }
- indicator() {
- return '';
- }
- async renderChoice(choice, i) {
- let str = await super.renderChoice(choice, i);
- let sym = this.symbols.identicalTo + ' ';
- let pre = (this.index === i && this.sorting) ? this.styles.muted(sym) : ' ';
- if (this.options.drag === false) pre = '';
- if (this.options.numbered === true) {
- return pre + `${i + 1} - ` + str;
- }
- return pre + str;
- }
- get selected() {
- return this.choices;
- }
- submit() {
- this.value = this.choices.map(choice => choice.value);
- return super.submit();
- }
- }
- module.exports = Sort;
- /***/ }),
- /***/ 83755:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const ArrayPrompt = __webpack_require__(98575);
- class Survey extends ArrayPrompt {
- constructor(options = {}) {
- super(options);
- this.emptyError = options.emptyError || 'No items were selected';
- this.term = process.env.TERM_PROGRAM;
- if (!this.options.header) {
- let header = ['', '4 - Strongly Agree', '3 - Agree', '2 - Neutral', '1 - Disagree', '0 - Strongly Disagree', ''];
- header = header.map(ele => this.styles.muted(ele));
- this.state.header = header.join('\n ');
- }
- }
- async toChoices(...args) {
- if (this.createdScales) return false;
- this.createdScales = true;
- let choices = await super.toChoices(...args);
- for (let choice of choices) {
- choice.scale = createScale(5, this.options);
- choice.scaleIdx = 2;
- }
- return choices;
- }
- dispatch() {
- this.alert();
- }
- space() {
- let choice = this.focused;
- let ele = choice.scale[choice.scaleIdx];
- let selected = ele.selected;
- choice.scale.forEach(e => (e.selected = false));
- ele.selected = !selected;
- return this.render();
- }
- indicator() {
- return '';
- }
- pointer() {
- return '';
- }
- separator() {
- return this.styles.muted(this.symbols.ellipsis);
- }
- right() {
- let choice = this.focused;
- if (choice.scaleIdx >= choice.scale.length - 1) return this.alert();
- choice.scaleIdx++;
- return this.render();
- }
- left() {
- let choice = this.focused;
- if (choice.scaleIdx <= 0) return this.alert();
- choice.scaleIdx--;
- return this.render();
- }
- indent() {
- return ' ';
- }
- async renderChoice(item, i) {
- await this.onChoice(item, i);
- let focused = this.index === i;
- let isHyper = this.term === 'Hyper';
- let n = !isHyper ? 8 : 9;
- let s = !isHyper ? ' ' : '';
- let ln = this.symbols.line.repeat(n);
- let sp = ' '.repeat(n + (isHyper ? 0 : 1));
- let dot = enabled => (enabled ? this.styles.success('◉') : '◯') + s;
- let num = i + 1 + '.';
- let color = focused ? this.styles.heading : this.styles.noop;
- let msg = await this.resolve(item.message, this.state, item, i);
- let indent = this.indent(item);
- let scale = indent + item.scale.map((e, i) => dot(i === item.scaleIdx)).join(ln);
- let val = i => i === item.scaleIdx ? color(i) : i;
- let next = indent + item.scale.map((e, i) => val(i)).join(sp);
- let line = () => [num, msg].filter(Boolean).join(' ');
- let lines = () => [line(), scale, next, ' '].filter(Boolean).join('\n');
- if (focused) {
- scale = this.styles.cyan(scale);
- next = this.styles.cyan(next);
- }
- return lines();
- }
- async renderChoices() {
- if (this.state.submitted) return '';
- let choices = this.visible.map(async(ch, i) => await this.renderChoice(ch, i));
- let visible = await Promise.all(choices);
- if (!visible.length) visible.push(this.styles.danger('No matching choices'));
- return visible.join('\n');
- }
- format() {
- if (this.state.submitted) {
- let values = this.choices.map(ch => this.styles.info(ch.scaleIdx));
- return values.join(', ');
- }
- return '';
- }
- async render() {
- let { submitted, size } = this.state;
- let prefix = await this.prefix();
- let separator = await this.separator();
- let message = await this.message();
- let prompt = [prefix, message, separator].filter(Boolean).join(' ');
- this.state.prompt = prompt;
- let header = await this.header();
- let output = await this.format();
- let help = await this.error() || await this.hint();
- let body = await this.renderChoices();
- let footer = await this.footer();
- if (output || !help) prompt += ' ' + output;
- if (help && !prompt.includes(help)) prompt += ' ' + help;
- if (submitted && !output && !body && this.multiple && this.type !== 'form') {
- prompt += this.styles.danger(this.emptyError);
- }
- this.clear(size);
- this.write([prompt, header, body, footer].filter(Boolean).join('\n'));
- this.restore();
- }
- submit() {
- this.value = {};
- for (let choice of this.choices) {
- this.value[choice.name] = choice.scaleIdx;
- }
- return this.base.submit.call(this);
- }
- }
- function createScale(n, options = {}) {
- if (Array.isArray(options.scale)) {
- return options.scale.map(ele => ({ ...ele }));
- }
- let scale = [];
- for (let i = 1; i < n + 1; i++) scale.push({ i, selected: false });
- return scale;
- }
- module.exports = Survey;
- /***/ }),
- /***/ 5781:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- module.exports = __webpack_require__(66719);
- /***/ }),
- /***/ 10653:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const BooleanPrompt = __webpack_require__(23838);
- class TogglePrompt extends BooleanPrompt {
- async initialize() {
- await super.initialize();
- this.value = this.initial = !!this.options.initial;
- this.disabled = this.options.disabled || 'no';
- this.enabled = this.options.enabled || 'yes';
- await this.render();
- }
- reset() {
- this.value = this.initial;
- this.render();
- }
- delete() {
- this.alert();
- }
- toggle() {
- this.value = !this.value;
- this.render();
- }
- enable() {
- if (this.value === true) return this.alert();
- this.value = true;
- this.render();
- }
- disable() {
- if (this.value === false) return this.alert();
- this.value = false;
- this.render();
- }
- up() {
- this.toggle();
- }
- down() {
- this.toggle();
- }
- right() {
- this.toggle();
- }
- left() {
- this.toggle();
- }
- next() {
- this.toggle();
- }
- prev() {
- this.toggle();
- }
- dispatch(ch = '', key) {
- switch (ch.toLowerCase()) {
- case ' ':
- return this.toggle();
- case '1':
- case 'y':
- case 't':
- return this.enable();
- case '0':
- case 'n':
- case 'f':
- return this.disable();
- default: {
- return this.alert();
- }
- }
- }
- format() {
- let active = str => this.styles.primary.underline(str);
- let value = [
- this.value ? this.disabled : active(this.disabled),
- this.value ? active(this.enabled) : this.enabled
- ];
- return value.join(this.styles.muted(' / '));
- }
- async render() {
- let { size } = this.state;
- let header = await this.header();
- let prefix = await this.prefix();
- let separator = await this.separator();
- let message = await this.message();
- let output = await this.format();
- let help = (await this.error()) || (await this.hint());
- let footer = await this.footer();
- let prompt = [prefix, message, separator, output].join(' ');
- this.state.prompt = prompt;
- if (help && !prompt.includes(help)) prompt += ' ' + help;
- this.clear(size);
- this.write([header, prompt, footer].filter(Boolean).join('\n'));
- this.write(this.margin[2]);
- this.restore();
- }
- }
- module.exports = TogglePrompt;
- /***/ }),
- /***/ 31502:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const utils = __webpack_require__(83546);
- const roles = {
- default(prompt, choice) {
- return choice;
- },
- checkbox(prompt, choice) {
- throw new Error('checkbox role is not implemented yet');
- },
- editable(prompt, choice) {
- throw new Error('editable role is not implemented yet');
- },
- expandable(prompt, choice) {
- throw new Error('expandable role is not implemented yet');
- },
- heading(prompt, choice) {
- choice.disabled = '';
- choice.indicator = [choice.indicator, ' '].find(v => v != null);
- choice.message = choice.message || '';
- return choice;
- },
- input(prompt, choice) {
- throw new Error('input role is not implemented yet');
- },
- option(prompt, choice) {
- return roles.default(prompt, choice);
- },
- radio(prompt, choice) {
- throw new Error('radio role is not implemented yet');
- },
- separator(prompt, choice) {
- choice.disabled = '';
- choice.indicator = [choice.indicator, ' '].find(v => v != null);
- choice.message = choice.message || prompt.symbols.line.repeat(5);
- return choice;
- },
- spacer(prompt, choice) {
- return choice;
- }
- };
- module.exports = (name, options = {}) => {
- let role = utils.merge({}, roles, options.roles);
- return role[name] || role.default;
- };
- /***/ }),
- /***/ 36873:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const { define, width } = __webpack_require__(83546);
- class State {
- constructor(prompt) {
- let options = prompt.options;
- define(this, '_prompt', prompt);
- this.type = prompt.type;
- this.name = prompt.name;
- this.message = '';
- this.header = '';
- this.footer = '';
- this.error = '';
- this.hint = '';
- this.input = '';
- this.cursor = 0;
- this.index = 0;
- this.lines = 0;
- this.tick = 0;
- this.prompt = '';
- this.buffer = '';
- this.width = width(options.stdout || process.stdout);
- Object.assign(this, options);
- this.name = this.name || this.message;
- this.message = this.message || this.name;
- this.symbols = prompt.symbols;
- this.styles = prompt.styles;
- this.required = new Set();
- this.cancelled = false;
- this.submitted = false;
- }
- clone() {
- let state = { ...this };
- state.status = this.status;
- state.buffer = Buffer.from(state.buffer);
- delete state.clone;
- return state;
- }
- set color(val) {
- this._color = val;
- }
- get color() {
- let styles = this.prompt.styles;
- if (this.cancelled) return styles.cancelled;
- if (this.submitted) return styles.submitted;
- let color = this._color || styles[this.status];
- return typeof color === 'function' ? color : styles.pending;
- }
- set loading(value) {
- this._loading = value;
- }
- get loading() {
- if (typeof this._loading === 'boolean') return this._loading;
- if (this.loadingChoices) return 'choices';
- return false;
- }
- get status() {
- if (this.cancelled) return 'cancelled';
- if (this.submitted) return 'submitted';
- return 'pending';
- }
- }
- module.exports = State;
- /***/ }),
- /***/ 79217:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const utils = __webpack_require__(83546);
- const colors = __webpack_require__(53692);
- const styles = {
- default: colors.noop,
- noop: colors.noop,
- /**
- * Modifiers
- */
- set inverse(custom) {
- this._inverse = custom;
- },
- get inverse() {
- return this._inverse || utils.inverse(this.primary);
- },
- set complement(custom) {
- this._complement = custom;
- },
- get complement() {
- return this._complement || utils.complement(this.primary);
- },
- /**
- * Main color
- */
- primary: colors.cyan,
- /**
- * Main palette
- */
- success: colors.green,
- danger: colors.magenta,
- strong: colors.bold,
- warning: colors.yellow,
- muted: colors.dim,
- disabled: colors.gray,
- dark: colors.dim.gray,
- underline: colors.underline,
- set info(custom) {
- this._info = custom;
- },
- get info() {
- return this._info || this.primary;
- },
- set em(custom) {
- this._em = custom;
- },
- get em() {
- return this._em || this.primary.underline;
- },
- set heading(custom) {
- this._heading = custom;
- },
- get heading() {
- return this._heading || this.muted.underline;
- },
- /**
- * Statuses
- */
- set pending(custom) {
- this._pending = custom;
- },
- get pending() {
- return this._pending || this.primary;
- },
- set submitted(custom) {
- this._submitted = custom;
- },
- get submitted() {
- return this._submitted || this.success;
- },
- set cancelled(custom) {
- this._cancelled = custom;
- },
- get cancelled() {
- return this._cancelled || this.danger;
- },
- /**
- * Special styling
- */
- set typing(custom) {
- this._typing = custom;
- },
- get typing() {
- return this._typing || this.dim;
- },
- set placeholder(custom) {
- this._placeholder = custom;
- },
- get placeholder() {
- return this._placeholder || this.primary.dim;
- },
- set highlight(custom) {
- this._highlight = custom;
- },
- get highlight() {
- return this._highlight || this.inverse;
- }
- };
- styles.merge = (options = {}) => {
- if (options.styles && typeof options.styles.enabled === 'boolean') {
- colors.enabled = options.styles.enabled;
- }
- if (options.styles && typeof options.styles.visible === 'boolean') {
- colors.visible = options.styles.visible;
- }
- let result = utils.merge({}, styles, options.styles);
- delete result.merge;
- for (let key of Object.keys(colors)) {
- if (!result.hasOwnProperty(key)) {
- Reflect.defineProperty(result, key, { get: () => colors[key] });
- }
- }
- for (let key of Object.keys(colors.styles)) {
- if (!result.hasOwnProperty(key)) {
- Reflect.defineProperty(result, key, { get: () => colors[key] });
- }
- }
- return result;
- };
- module.exports = styles;
- /***/ }),
- /***/ 74739:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const isWindows = process.platform === 'win32';
- const colors = __webpack_require__(53692);
- const utils = __webpack_require__(83546);
- const symbols = {
- ...colors.symbols,
- upDownDoubleArrow: '⇕',
- upDownDoubleArrow2: '⬍',
- upDownArrow: '↕',
- asterisk: '*',
- asterism: '⁂',
- bulletWhite: '◦',
- electricArrow: '⌁',
- ellipsisLarge: '⋯',
- ellipsisSmall: '…',
- fullBlock: '█',
- identicalTo: '≡',
- indicator: colors.symbols.check,
- leftAngle: '‹',
- mark: '※',
- minus: '−',
- multiplication: '×',
- obelus: '÷',
- percent: '%',
- pilcrow: '¶',
- pilcrow2: '❡',
- pencilUpRight: '✐',
- pencilDownRight: '✎',
- pencilRight: '✏',
- plus: '+',
- plusMinus: '±',
- pointRight: '☞',
- rightAngle: '›',
- section: '§',
- hexagon: { off: '⬡', on: '⬢', disabled: '⬢' },
- ballot: { on: '☑', off: '☐', disabled: '☒' },
- stars: { on: '★', off: '☆', disabled: '☆' },
- folder: { on: '▼', off: '▶', disabled: '▶' },
- prefix: {
- pending: colors.symbols.question,
- submitted: colors.symbols.check,
- cancelled: colors.symbols.cross
- },
- separator: {
- pending: colors.symbols.pointerSmall,
- submitted: colors.symbols.middot,
- cancelled: colors.symbols.middot
- },
- radio: {
- off: isWindows ? '( )' : '◯',
- on: isWindows ? '(*)' : '◉',
- disabled: isWindows ? '(|)' : 'Ⓘ'
- },
- numbers: ['⓪', '①', '②', '③', '④', '⑤', '⑥', '⑦', '⑧', '⑨', '⑩', '⑪', '⑫', '⑬', '⑭', '⑮', '⑯', '⑰', '⑱', '⑲', '⑳', '㉑', '㉒', '㉓', '㉔', '㉕', '㉖', '㉗', '㉘', '㉙', '㉚', '㉛', '㉜', '㉝', '㉞', '㉟', '㊱', '㊲', '㊳', '㊴', '㊵', '㊶', '㊷', '㊸', '㊹', '㊺', '㊻', '㊼', '㊽', '㊾', '㊿']
- };
- symbols.merge = options => {
- let result = utils.merge({}, colors.symbols, symbols, options.symbols);
- delete result.merge;
- return result;
- };
- module.exports = symbols;
- /***/ }),
- /***/ 39227:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const styles = __webpack_require__(79217);
- const symbols = __webpack_require__(74739);
- const utils = __webpack_require__(83546);
- module.exports = prompt => {
- prompt.options = utils.merge({}, prompt.options.theme, prompt.options);
- prompt.symbols = symbols.merge(prompt.options);
- prompt.styles = styles.merge(prompt.options);
- };
- /***/ }),
- /***/ 33940:
- /***/ ((module) => {
- "use strict";
- module.exports = prompt => {
- prompt.timers = prompt.timers || {};
- let timers = prompt.options.timers;
- if (!timers) return;
- for (let key of Object.keys(timers)) {
- let opts = timers[key];
- if (typeof opts === 'number') {
- opts = { interval: opts };
- }
- create(prompt, key, opts);
- }
- };
- function create(prompt, name, options = {}) {
- let timer = prompt.timers[name] = { name, start: Date.now(), ms: 0, tick: 0 };
- let ms = options.interval || 120;
- timer.frames = options.frames || [];
- timer.loading = true;
- let interval = setInterval(() => {
- timer.ms = Date.now() - timer.start;
- timer.tick++;
- prompt.render();
- }, ms);
- timer.stop = () => {
- timer.loading = false;
- clearInterval(interval);
- };
- Reflect.defineProperty(timer, 'interval', { value: interval });
- prompt.once('close', () => timer.stop());
- return timer.stop;
- }
- /***/ }),
- /***/ 98575:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const colors = __webpack_require__(53692);
- const Prompt = __webpack_require__(232);
- const roles = __webpack_require__(31502);
- const utils = __webpack_require__(83546);
- const { reorder, scrollUp, scrollDown, isObject, swap } = utils;
- class ArrayPrompt extends Prompt {
- constructor(options) {
- super(options);
- this.cursorHide();
- this.maxSelected = options.maxSelected || Infinity;
- this.multiple = options.multiple || false;
- this.initial = options.initial || 0;
- this.delay = options.delay || 0;
- this.longest = 0;
- this.num = '';
- }
- async initialize() {
- if (typeof this.options.initial === 'function') {
- this.initial = await this.options.initial.call(this);
- }
- await this.reset(true);
- await super.initialize();
- }
- async reset() {
- let { choices, initial, autofocus, suggest } = this.options;
- this.state._choices = [];
- this.state.choices = [];
- this.choices = await Promise.all(await this.toChoices(choices));
- this.choices.forEach(ch => (ch.enabled = false));
- if (typeof suggest !== 'function' && this.selectable.length === 0) {
- throw new Error('At least one choice must be selectable');
- }
- if (isObject(initial)) initial = Object.keys(initial);
- if (Array.isArray(initial)) {
- if (autofocus != null) this.index = this.findIndex(autofocus);
- initial.forEach(v => this.enable(this.find(v)));
- await this.render();
- } else {
- if (autofocus != null) initial = autofocus;
- if (typeof initial === 'string') initial = this.findIndex(initial);
- if (typeof initial === 'number' && initial > -1) {
- this.index = Math.max(0, Math.min(initial, this.choices.length));
- this.enable(this.find(this.index));
- }
- }
- if (this.isDisabled(this.focused)) {
- await this.down();
- }
- }
- async toChoices(value, parent) {
- this.state.loadingChoices = true;
- let choices = [];
- let index = 0;
- let toChoices = async(items, parent) => {
- if (typeof items === 'function') items = await items.call(this);
- if (items instanceof Promise) items = await items;
- for (let i = 0; i < items.length; i++) {
- let choice = items[i] = await this.toChoice(items[i], index++, parent);
- choices.push(choice);
- if (choice.choices) {
- await toChoices(choice.choices, choice);
- }
- }
- return choices;
- };
- return toChoices(value, parent)
- .then(choices => {
- this.state.loadingChoices = false;
- return choices;
- });
- }
- async toChoice(ele, i, parent) {
- if (typeof ele === 'function') ele = await ele.call(this, this);
- if (ele instanceof Promise) ele = await ele;
- if (typeof ele === 'string') ele = { name: ele };
- if (ele.normalized) return ele;
- ele.normalized = true;
- let origVal = ele.value;
- let role = roles(ele.role, this.options);
- ele = role(this, ele);
- if (typeof ele.disabled === 'string' && !ele.hint) {
- ele.hint = ele.disabled;
- ele.disabled = true;
- }
- if (ele.disabled === true && ele.hint == null) {
- ele.hint = '(disabled)';
- }
- // if the choice was already normalized, return it
- if (ele.index != null) return ele;
- ele.name = ele.name || ele.key || ele.title || ele.value || ele.message;
- ele.message = ele.message || ele.name || '';
- ele.value = [ele.value, ele.name].find(this.isValue.bind(this));
- ele.input = '';
- ele.index = i;
- ele.cursor = 0;
- utils.define(ele, 'parent', parent);
- ele.level = parent ? parent.level + 1 : 1;
- if (ele.indent == null) {
- ele.indent = parent ? parent.indent + ' ' : (ele.indent || '');
- }
- ele.path = parent ? parent.path + '.' + ele.name : ele.name;
- ele.enabled = !!(this.multiple && !this.isDisabled(ele) && (ele.enabled || this.isSelected(ele)));
- if (!this.isDisabled(ele)) {
- this.longest = Math.max(this.longest, colors.unstyle(ele.message).length);
- }
- // shallow clone the choice first
- let choice = { ...ele };
- // then allow the choice to be reset using the "original" values
- ele.reset = (input = choice.input, value = choice.value) => {
- for (let key of Object.keys(choice)) ele[key] = choice[key];
- ele.input = input;
- ele.value = value;
- };
- if (origVal == null && typeof ele.initial === 'function') {
- ele.input = await ele.initial.call(this, this.state, ele, i);
- }
- return ele;
- }
- async onChoice(choice, i) {
- this.emit('choice', choice, i, this);
- if (typeof choice.onChoice === 'function') {
- await choice.onChoice.call(this, this.state, choice, i);
- }
- }
- async addChoice(ele, i, parent) {
- let choice = await this.toChoice(ele, i, parent);
- this.choices.push(choice);
- this.index = this.choices.length - 1;
- this.limit = this.choices.length;
- return choice;
- }
- async newItem(item, i, parent) {
- let ele = { name: 'New choice name?', editable: true, newChoice: true, ...item };
- let choice = await this.addChoice(ele, i, parent);
- choice.updateChoice = () => {
- delete choice.newChoice;
- choice.name = choice.message = choice.input;
- choice.input = '';
- choice.cursor = 0;
- };
- return this.render();
- }
- indent(choice) {
- if (choice.indent == null) {
- return choice.level > 1 ? ' '.repeat(choice.level - 1) : '';
- }
- return choice.indent;
- }
- dispatch(s, key) {
- if (this.multiple && this[key.name]) return this[key.name]();
- this.alert();
- }
- focus(choice, enabled) {
- if (typeof enabled !== 'boolean') enabled = choice.enabled;
- if (enabled && !choice.enabled && this.selected.length >= this.maxSelected) {
- return this.alert();
- }
- this.index = choice.index;
- choice.enabled = enabled && !this.isDisabled(choice);
- return choice;
- }
- space() {
- if (!this.multiple) return this.alert();
- this.toggle(this.focused);
- return this.render();
- }
- a() {
- if (this.maxSelected < this.choices.length) return this.alert();
- let enabled = this.selectable.every(ch => ch.enabled);
- this.choices.forEach(ch => (ch.enabled = !enabled));
- return this.render();
- }
- i() {
- // don't allow choices to be inverted if it will result in
- // more than the maximum number of allowed selected items.
- if (this.choices.length - this.selected.length > this.maxSelected) {
- return this.alert();
- }
- this.choices.forEach(ch => (ch.enabled = !ch.enabled));
- return this.render();
- }
- g(choice = this.focused) {
- if (!this.choices.some(ch => !!ch.parent)) return this.a();
- this.toggle((choice.parent && !choice.choices) ? choice.parent : choice);
- return this.render();
- }
- toggle(choice, enabled) {
- if (!choice.enabled && this.selected.length >= this.maxSelected) {
- return this.alert();
- }
- if (typeof enabled !== 'boolean') enabled = !choice.enabled;
- choice.enabled = enabled;
- if (choice.choices) {
- choice.choices.forEach(ch => this.toggle(ch, enabled));
- }
- let parent = choice.parent;
- while (parent) {
- let choices = parent.choices.filter(ch => this.isDisabled(ch));
- parent.enabled = choices.every(ch => ch.enabled === true);
- parent = parent.parent;
- }
- reset(this, this.choices);
- this.emit('toggle', choice, this);
- return choice;
- }
- enable(choice) {
- if (this.selected.length >= this.maxSelected) return this.alert();
- choice.enabled = !this.isDisabled(choice);
- choice.choices && choice.choices.forEach(this.enable.bind(this));
- return choice;
- }
- disable(choice) {
- choice.enabled = false;
- choice.choices && choice.choices.forEach(this.disable.bind(this));
- return choice;
- }
- number(n) {
- this.num += n;
- let number = num => {
- let i = Number(num);
- if (i > this.choices.length - 1) return this.alert();
- let focused = this.focused;
- let choice = this.choices.find(ch => i === ch.index);
- if (!choice.enabled && this.selected.length >= this.maxSelected) {
- return this.alert();
- }
- if (this.visible.indexOf(choice) === -1) {
- let choices = reorder(this.choices);
- let actualIdx = choices.indexOf(choice);
- if (focused.index > actualIdx) {
- let start = choices.slice(actualIdx, actualIdx + this.limit);
- let end = choices.filter(ch => !start.includes(ch));
- this.choices = start.concat(end);
- } else {
- let pos = actualIdx - this.limit + 1;
- this.choices = choices.slice(pos).concat(choices.slice(0, pos));
- }
- }
- this.index = this.choices.indexOf(choice);
- this.toggle(this.focused);
- return this.render();
- };
- clearTimeout(this.numberTimeout);
- return new Promise(resolve => {
- let len = this.choices.length;
- let num = this.num;
- let handle = (val = false, res) => {
- clearTimeout(this.numberTimeout);
- if (val) res = number(num);
- this.num = '';
- resolve(res);
- };
- if (num === '0' || (num.length === 1 && Number(num + '0') > len)) {
- return handle(true);
- }
- if (Number(num) > len) {
- return handle(false, this.alert());
- }
- this.numberTimeout = setTimeout(() => handle(true), this.delay);
- });
- }
- home() {
- this.choices = reorder(this.choices);
- this.index = 0;
- return this.render();
- }
- end() {
- let pos = this.choices.length - this.limit;
- let choices = reorder(this.choices);
- this.choices = choices.slice(pos).concat(choices.slice(0, pos));
- this.index = this.limit - 1;
- return this.render();
- }
- first() {
- this.index = 0;
- return this.render();
- }
- last() {
- this.index = this.visible.length - 1;
- return this.render();
- }
- prev() {
- if (this.visible.length <= 1) return this.alert();
- return this.up();
- }
- next() {
- if (this.visible.length <= 1) return this.alert();
- return this.down();
- }
- right() {
- if (this.cursor >= this.input.length) return this.alert();
- this.cursor++;
- return this.render();
- }
- left() {
- if (this.cursor <= 0) return this.alert();
- this.cursor--;
- return this.render();
- }
- up() {
- let len = this.choices.length;
- let vis = this.visible.length;
- let idx = this.index;
- if (this.options.scroll === false && idx === 0) {
- return this.alert();
- }
- if (len > vis && idx === 0) {
- return this.scrollUp();
- }
- this.index = ((idx - 1 % len) + len) % len;
- if (this.isDisabled()) {
- return this.up();
- }
- return this.render();
- }
- down() {
- let len = this.choices.length;
- let vis = this.visible.length;
- let idx = this.index;
- if (this.options.scroll === false && idx === vis - 1) {
- return this.alert();
- }
- if (len > vis && idx === vis - 1) {
- return this.scrollDown();
- }
- this.index = (idx + 1) % len;
- if (this.isDisabled()) {
- return this.down();
- }
- return this.render();
- }
- scrollUp(i = 0) {
- this.choices = scrollUp(this.choices);
- this.index = i;
- if (this.isDisabled()) {
- return this.up();
- }
- return this.render();
- }
- scrollDown(i = this.visible.length - 1) {
- this.choices = scrollDown(this.choices);
- this.index = i;
- if (this.isDisabled()) {
- return this.down();
- }
- return this.render();
- }
- async shiftUp() {
- if (this.options.sort === true) {
- this.sorting = true;
- this.swap(this.index - 1);
- await this.up();
- this.sorting = false;
- return;
- }
- return this.scrollUp(this.index);
- }
- async shiftDown() {
- if (this.options.sort === true) {
- this.sorting = true;
- this.swap(this.index + 1);
- await this.down();
- this.sorting = false;
- return;
- }
- return this.scrollDown(this.index);
- }
- pageUp() {
- if (this.visible.length <= 1) return this.alert();
- this.limit = Math.max(this.limit - 1, 0);
- this.index = Math.min(this.limit - 1, this.index);
- this._limit = this.limit;
- if (this.isDisabled()) {
- return this.up();
- }
- return this.render();
- }
- pageDown() {
- if (this.visible.length >= this.choices.length) return this.alert();
- this.index = Math.max(0, this.index);
- this.limit = Math.min(this.limit + 1, this.choices.length);
- this._limit = this.limit;
- if (this.isDisabled()) {
- return this.down();
- }
- return this.render();
- }
- swap(pos) {
- swap(this.choices, this.index, pos);
- }
- isDisabled(choice = this.focused) {
- let keys = ['disabled', 'collapsed', 'hidden', 'completing', 'readonly'];
- if (choice && keys.some(key => choice[key] === true)) {
- return true;
- }
- return choice && choice.role === 'heading';
- }
- isEnabled(choice = this.focused) {
- if (Array.isArray(choice)) return choice.every(ch => this.isEnabled(ch));
- if (choice.choices) {
- let choices = choice.choices.filter(ch => !this.isDisabled(ch));
- return choice.enabled && choices.every(ch => this.isEnabled(ch));
- }
- return choice.enabled && !this.isDisabled(choice);
- }
- isChoice(choice, value) {
- return choice.name === value || choice.index === Number(value);
- }
- isSelected(choice) {
- if (Array.isArray(this.initial)) {
- return this.initial.some(value => this.isChoice(choice, value));
- }
- return this.isChoice(choice, this.initial);
- }
- map(names = [], prop = 'value') {
- return [].concat(names || []).reduce((acc, name) => {
- acc[name] = this.find(name, prop);
- return acc;
- }, {});
- }
- filter(value, prop) {
- let isChoice = (ele, i) => [ele.name, i].includes(value);
- let fn = typeof value === 'function' ? value : isChoice;
- let choices = this.options.multiple ? this.state._choices : this.choices;
- let result = choices.filter(fn);
- if (prop) {
- return result.map(ch => ch[prop]);
- }
- return result;
- }
- find(value, prop) {
- if (isObject(value)) return prop ? value[prop] : value;
- let isChoice = (ele, i) => [ele.name, i].includes(value);
- let fn = typeof value === 'function' ? value : isChoice;
- let choice = this.choices.find(fn);
- if (choice) {
- return prop ? choice[prop] : choice;
- }
- }
- findIndex(value) {
- return this.choices.indexOf(this.find(value));
- }
- async submit() {
- let choice = this.focused;
- if (!choice) return this.alert();
- if (choice.newChoice) {
- if (!choice.input) return this.alert();
- choice.updateChoice();
- return this.render();
- }
- if (this.choices.some(ch => ch.newChoice)) {
- return this.alert();
- }
- let { reorder, sort } = this.options;
- let multi = this.multiple === true;
- let value = this.selected;
- if (value === void 0) {
- return this.alert();
- }
- // re-sort choices to original order
- if (Array.isArray(value) && reorder !== false && sort !== true) {
- value = utils.reorder(value);
- }
- this.value = multi ? value.map(ch => ch.name) : value.name;
- return super.submit();
- }
- set choices(choices = []) {
- this.state._choices = this.state._choices || [];
- this.state.choices = choices;
- for (let choice of choices) {
- if (!this.state._choices.some(ch => ch.name === choice.name)) {
- this.state._choices.push(choice);
- }
- }
- if (!this._initial && this.options.initial) {
- this._initial = true;
- let init = this.initial;
- if (typeof init === 'string' || typeof init === 'number') {
- let choice = this.find(init);
- if (choice) {
- this.initial = choice.index;
- this.focus(choice, true);
- }
- }
- }
- }
- get choices() {
- return reset(this, this.state.choices || []);
- }
- set visible(visible) {
- this.state.visible = visible;
- }
- get visible() {
- return (this.state.visible || this.choices).slice(0, this.limit);
- }
- set limit(num) {
- this.state.limit = num;
- }
- get limit() {
- let { state, options, choices } = this;
- let limit = state.limit || this._limit || options.limit || choices.length;
- return Math.min(limit, this.height);
- }
- set value(value) {
- super.value = value;
- }
- get value() {
- if (typeof super.value !== 'string' && super.value === this.initial) {
- return this.input;
- }
- return super.value;
- }
- set index(i) {
- this.state.index = i;
- }
- get index() {
- return Math.max(0, this.state ? this.state.index : 0);
- }
- get enabled() {
- return this.filter(this.isEnabled.bind(this));
- }
- get focused() {
- let choice = this.choices[this.index];
- if (choice && this.state.submitted && this.multiple !== true) {
- choice.enabled = true;
- }
- return choice;
- }
- get selectable() {
- return this.choices.filter(choice => !this.isDisabled(choice));
- }
- get selected() {
- return this.multiple ? this.enabled : this.focused;
- }
- }
- function reset(prompt, choices) {
- if (choices instanceof Promise) return choices;
- if (typeof choices === 'function') {
- if (utils.isAsyncFn(choices)) return choices;
- choices = choices.call(prompt, prompt);
- }
- for (let choice of choices) {
- if (Array.isArray(choice.choices)) {
- let items = choice.choices.filter(ch => !prompt.isDisabled(ch));
- choice.enabled = items.every(ch => ch.enabled === true);
- }
- if (prompt.isDisabled(choice) === true) {
- delete choice.enabled;
- }
- }
- return choices;
- }
- module.exports = ArrayPrompt;
- /***/ }),
- /***/ 66926:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const FormPrompt = __webpack_require__(21826);
- const defaultAuthenticate = () => {
- throw new Error('expected prompt to have a custom authenticate method');
- };
- const factory = (authenticate = defaultAuthenticate) => {
- class AuthPrompt extends FormPrompt {
- constructor(options) {
- super(options);
- }
- async submit() {
- this.value = await authenticate.call(this, this.values, this.state);
- super.base.submit.call(this);
- }
- static create(authenticate) {
- return factory(authenticate);
- }
- }
- return AuthPrompt;
- };
- module.exports = factory();
- /***/ }),
- /***/ 23838:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const Prompt = __webpack_require__(232);
- const { isPrimitive, hasColor } = __webpack_require__(83546);
- class BooleanPrompt extends Prompt {
- constructor(options) {
- super(options);
- this.cursorHide();
- }
- async initialize() {
- let initial = await this.resolve(this.initial, this.state);
- this.input = await this.cast(initial);
- await super.initialize();
- }
- dispatch(ch) {
- if (!this.isValue(ch)) return this.alert();
- this.input = ch;
- return this.submit();
- }
- format(value) {
- let { styles, state } = this;
- return !state.submitted ? styles.primary(value) : styles.success(value);
- }
- cast(input) {
- return this.isTrue(input);
- }
- isTrue(input) {
- return /^[ty1]/i.test(input);
- }
- isFalse(input) {
- return /^[fn0]/i.test(input);
- }
- isValue(value) {
- return isPrimitive(value) && (this.isTrue(value) || this.isFalse(value));
- }
- async hint() {
- if (this.state.status === 'pending') {
- let hint = await this.element('hint');
- if (!hasColor(hint)) {
- return this.styles.muted(hint);
- }
- return hint;
- }
- }
- async render() {
- let { input, size } = this.state;
- let prefix = await this.prefix();
- let sep = await this.separator();
- let msg = await this.message();
- let hint = this.styles.muted(this.default);
- let promptLine = [prefix, msg, hint, sep].filter(Boolean).join(' ');
- this.state.prompt = promptLine;
- let header = await this.header();
- let value = this.value = this.cast(input);
- let output = await this.format(value);
- let help = (await this.error()) || (await this.hint());
- let footer = await this.footer();
- if (help && !promptLine.includes(help)) output += ' ' + help;
- promptLine += ' ' + output;
- this.clear(size);
- this.write([header, promptLine, footer].filter(Boolean).join('\n'));
- this.restore();
- }
- set value(value) {
- super.value = value;
- }
- get value() {
- return this.cast(super.value);
- }
- }
- module.exports = BooleanPrompt;
- /***/ }),
- /***/ 29920:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- module.exports = {
- ArrayPrompt: __webpack_require__(98575),
- AuthPrompt: __webpack_require__(66926),
- BooleanPrompt: __webpack_require__(23838),
- NumberPrompt: __webpack_require__(45376),
- StringPrompt: __webpack_require__(43391)
- };
- /***/ }),
- /***/ 45376:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const StringPrompt = __webpack_require__(43391);
- class NumberPrompt extends StringPrompt {
- constructor(options = {}) {
- super({ style: 'number', ...options });
- this.min = this.isValue(options.min) ? this.toNumber(options.min) : -Infinity;
- this.max = this.isValue(options.max) ? this.toNumber(options.max) : Infinity;
- this.delay = options.delay != null ? options.delay : 1000;
- this.float = options.float !== false;
- this.round = options.round === true || options.float === false;
- this.major = options.major || 10;
- this.minor = options.minor || 1;
- this.initial = options.initial != null ? options.initial : '';
- this.input = String(this.initial);
- this.cursor = this.input.length;
- this.cursorShow();
- }
- append(ch) {
- if (!/[-+.]/.test(ch) || (ch === '.' && this.input.includes('.'))) {
- return this.alert('invalid number');
- }
- return super.append(ch);
- }
- number(ch) {
- return super.append(ch);
- }
- next() {
- if (this.input && this.input !== this.initial) return this.alert();
- if (!this.isValue(this.initial)) return this.alert();
- this.input = this.initial;
- this.cursor = String(this.initial).length;
- return this.render();
- }
- up(number) {
- let step = number || this.minor;
- let num = this.toNumber(this.input);
- if (num > this.max + step) return this.alert();
- this.input = `${num + step}`;
- return this.render();
- }
- down(number) {
- let step = number || this.minor;
- let num = this.toNumber(this.input);
- if (num < this.min - step) return this.alert();
- this.input = `${num - step}`;
- return this.render();
- }
- shiftDown() {
- return this.down(this.major);
- }
- shiftUp() {
- return this.up(this.major);
- }
- format(input = this.input) {
- if (typeof this.options.format === 'function') {
- return this.options.format.call(this, input);
- }
- return this.styles.info(input);
- }
- toNumber(value = '') {
- return this.float ? +value : Math.round(+value);
- }
- isValue(value) {
- return /^[-+]?[0-9]+((\.)|(\.[0-9]+))?$/.test(value);
- }
- submit() {
- let value = [this.input, this.initial].find(v => this.isValue(v));
- this.value = this.toNumber(value || 0);
- return super.submit();
- }
- }
- module.exports = NumberPrompt;
- /***/ }),
- /***/ 43391:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const Prompt = __webpack_require__(232);
- const placeholder = __webpack_require__(12786);
- const { isPrimitive } = __webpack_require__(83546);
- class StringPrompt extends Prompt {
- constructor(options) {
- super(options);
- this.initial = isPrimitive(this.initial) ? String(this.initial) : '';
- if (this.initial) this.cursorHide();
- this.state.prevCursor = 0;
- this.state.clipboard = [];
- }
- async keypress(input, key = {}) {
- let prev = this.state.prevKeypress;
- this.state.prevKeypress = key;
- if (this.options.multiline === true && key.name === 'return') {
- if (!prev || prev.name !== 'return') {
- return this.append('\n', key);
- }
- }
- return super.keypress(input, key);
- }
- moveCursor(n) {
- this.cursor += n;
- }
- reset() {
- this.input = this.value = '';
- this.cursor = 0;
- return this.render();
- }
- dispatch(ch, key) {
- if (!ch || key.ctrl || key.code) return this.alert();
- this.append(ch);
- }
- append(ch) {
- let { cursor, input } = this.state;
- this.input = `${input}`.slice(0, cursor) + ch + `${input}`.slice(cursor);
- this.moveCursor(String(ch).length);
- this.render();
- }
- insert(str) {
- this.append(str);
- }
- delete() {
- let { cursor, input } = this.state;
- if (cursor <= 0) return this.alert();
- this.input = `${input}`.slice(0, cursor - 1) + `${input}`.slice(cursor);
- this.moveCursor(-1);
- this.render();
- }
- deleteForward() {
- let { cursor, input } = this.state;
- if (input[cursor] === void 0) return this.alert();
- this.input = `${input}`.slice(0, cursor) + `${input}`.slice(cursor + 1);
- this.render();
- }
- cutForward() {
- let pos = this.cursor;
- if (this.input.length <= pos) return this.alert();
- this.state.clipboard.push(this.input.slice(pos));
- this.input = this.input.slice(0, pos);
- this.render();
- }
- cutLeft() {
- let pos = this.cursor;
- if (pos === 0) return this.alert();
- let before = this.input.slice(0, pos);
- let after = this.input.slice(pos);
- let words = before.split(' ');
- this.state.clipboard.push(words.pop());
- this.input = words.join(' ');
- this.cursor = this.input.length;
- this.input += after;
- this.render();
- }
- paste() {
- if (!this.state.clipboard.length) return this.alert();
- this.insert(this.state.clipboard.pop());
- this.render();
- }
- toggleCursor() {
- if (this.state.prevCursor) {
- this.cursor = this.state.prevCursor;
- this.state.prevCursor = 0;
- } else {
- this.state.prevCursor = this.cursor;
- this.cursor = 0;
- }
- this.render();
- }
- first() {
- this.cursor = 0;
- this.render();
- }
- last() {
- this.cursor = this.input.length - 1;
- this.render();
- }
- next() {
- let init = this.initial != null ? String(this.initial) : '';
- if (!init || !init.startsWith(this.input)) return this.alert();
- this.input = this.initial;
- this.cursor = this.initial.length;
- this.render();
- }
- prev() {
- if (!this.input) return this.alert();
- this.reset();
- }
- backward() {
- return this.left();
- }
- forward() {
- return this.right();
- }
- right() {
- if (this.cursor >= this.input.length) return this.alert();
- this.moveCursor(1);
- return this.render();
- }
- left() {
- if (this.cursor <= 0) return this.alert();
- this.moveCursor(-1);
- return this.render();
- }
- isValue(value) {
- return !!value;
- }
- async format(input = this.value) {
- let initial = await this.resolve(this.initial, this.state);
- if (!this.state.submitted) {
- return placeholder(this, { input, initial, pos: this.cursor });
- }
- return this.styles.submitted(input || initial);
- }
- async render() {
- let size = this.state.size;
- let prefix = await this.prefix();
- let separator = await this.separator();
- let message = await this.message();
- let prompt = [prefix, message, separator].filter(Boolean).join(' ');
- this.state.prompt = prompt;
- let header = await this.header();
- let output = await this.format();
- let help = (await this.error()) || (await this.hint());
- let footer = await this.footer();
- if (help && !output.includes(help)) output += ' ' + help;
- prompt += ' ' + output;
- this.clear(size);
- this.write([header, prompt, footer].filter(Boolean).join('\n'));
- this.restore();
- }
- }
- module.exports = StringPrompt;
- /***/ }),
- /***/ 83546:
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- const toString = Object.prototype.toString;
- const colors = __webpack_require__(53692);
- let called = false;
- let fns = [];
- const complements = {
- 'yellow': 'blue',
- 'cyan': 'red',
- 'green': 'magenta',
- 'black': 'white',
- 'blue': 'yellow',
- 'red': 'cyan',
- 'magenta': 'green',
- 'white': 'black'
- };
- exports.longest = (arr, prop) => {
- return arr.reduce((a, v) => Math.max(a, prop ? v[prop].length : v.length), 0);
- };
- exports.hasColor = str => !!str && colors.hasColor(str);
- const isObject = exports.isObject = val => {
- return val !== null && typeof val === 'object' && !Array.isArray(val);
- };
- exports.nativeType = val => {
- return toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, '');
- };
- exports.isAsyncFn = val => {
- return exports.nativeType(val) === 'asyncfunction';
- };
- exports.isPrimitive = val => {
- return val != null && typeof val !== 'object' && typeof val !== 'function';
- };
- exports.resolve = (context, value, ...rest) => {
- if (typeof value === 'function') {
- return value.call(context, ...rest);
- }
- return value;
- };
- exports.scrollDown = (choices = []) => [...choices.slice(1), choices[0]];
- exports.scrollUp = (choices = []) => [choices.pop(), ...choices];
- exports.reorder = (arr = []) => {
- let res = arr.slice();
- res.sort((a, b) => {
- if (a.index > b.index) return 1;
- if (a.index < b.index) return -1;
- return 0;
- });
- return res;
- };
- exports.swap = (arr, index, pos) => {
- let len = arr.length;
- let idx = pos === len ? 0 : pos < 0 ? len - 1 : pos;
- let choice = arr[index];
- arr[index] = arr[idx];
- arr[idx] = choice;
- };
- exports.width = (stream, fallback = 80) => {
- let columns = (stream && stream.columns) ? stream.columns : fallback;
- if (stream && typeof stream.getWindowSize === 'function') {
- columns = stream.getWindowSize()[0];
- }
- if (process.platform === 'win32') {
- return columns - 1;
- }
- return columns;
- };
- exports.height = (stream, fallback = 20) => {
- let rows = (stream && stream.rows) ? stream.rows : fallback;
- if (stream && typeof stream.getWindowSize === 'function') {
- rows = stream.getWindowSize()[1];
- }
- return rows;
- };
- exports.wordWrap = (str, options = {}) => {
- if (!str) return str;
- if (typeof options === 'number') {
- options = { width: options };
- }
- let { indent = '', newline = ('\n' + indent), width = 80 } = options;
- let spaces = (newline + indent).match(/[^\S\n]/g) || [];
- width -= spaces.length;
- let source = `.{1,${width}}([\\s\\u200B]+|$)|[^\\s\\u200B]+?([\\s\\u200B]+|$)`;
- let output = str.trim();
- let regex = new RegExp(source, 'g');
- let lines = output.match(regex) || [];
- lines = lines.map(line => line.replace(/\n$/, ''));
- if (options.padEnd) lines = lines.map(line => line.padEnd(width, ' '));
- if (options.padStart) lines = lines.map(line => line.padStart(width, ' '));
- return indent + lines.join(newline);
- };
- exports.unmute = color => {
- let name = color.stack.find(n => colors.keys.color.includes(n));
- if (name) {
- return colors[name];
- }
- let bg = color.stack.find(n => n.slice(2) === 'bg');
- if (bg) {
- return colors[name.slice(2)];
- }
- return str => str;
- };
- exports.pascal = str => str ? str[0].toUpperCase() + str.slice(1) : '';
- exports.inverse = color => {
- if (!color || !color.stack) return color;
- let name = color.stack.find(n => colors.keys.color.includes(n));
- if (name) {
- let col = colors['bg' + exports.pascal(name)];
- return col ? col.black : color;
- }
- let bg = color.stack.find(n => n.slice(0, 2) === 'bg');
- if (bg) {
- return colors[bg.slice(2).toLowerCase()] || color;
- }
- return colors.none;
- };
- exports.complement = color => {
- if (!color || !color.stack) return color;
- let name = color.stack.find(n => colors.keys.color.includes(n));
- let bg = color.stack.find(n => n.slice(0, 2) === 'bg');
- if (name && !bg) {
- return colors[complements[name] || name];
- }
- if (bg) {
- let lower = bg.slice(2).toLowerCase();
- let comp = complements[lower];
- if (!comp) return color;
- return colors['bg' + exports.pascal(comp)] || color;
- }
- return colors.none;
- };
- exports.meridiem = date => {
- let hours = date.getHours();
- let minutes = date.getMinutes();
- let ampm = hours >= 12 ? 'pm' : 'am';
- hours = hours % 12;
- let hrs = hours === 0 ? 12 : hours;
- let min = minutes < 10 ? '0' + minutes : minutes;
- return hrs + ':' + min + ' ' + ampm;
- };
- /**
- * Set a value on the given object.
- * @param {Object} obj
- * @param {String} prop
- * @param {any} value
- */
- exports.set = (obj = {}, prop = '', val) => {
- return prop.split('.').reduce((acc, k, i, arr) => {
- let value = arr.length - 1 > i ? (acc[k] || {}) : val;
- if (!exports.isObject(value) && i < arr.length - 1) value = {};
- return (acc[k] = value);
- }, obj);
- };
- /**
- * Get a value from the given object.
- * @param {Object} obj
- * @param {String} prop
- */
- exports.get = (obj = {}, prop = '', fallback) => {
- let value = obj[prop] == null
- ? prop.split('.').reduce((acc, k) => acc && acc[k], obj)
- : obj[prop];
- return value == null ? fallback : value;
- };
- exports.mixin = (target, b) => {
- if (!isObject(target)) return b;
- if (!isObject(b)) return target;
- for (let key of Object.keys(b)) {
- let desc = Object.getOwnPropertyDescriptor(b, key);
- if (desc.hasOwnProperty('value')) {
- if (target.hasOwnProperty(key) && isObject(desc.value)) {
- let existing = Object.getOwnPropertyDescriptor(target, key);
- if (isObject(existing.value)) {
- target[key] = exports.merge({}, target[key], b[key]);
- } else {
- Reflect.defineProperty(target, key, desc);
- }
- } else {
- Reflect.defineProperty(target, key, desc);
- }
- } else {
- Reflect.defineProperty(target, key, desc);
- }
- }
- return target;
- };
- exports.merge = (...args) => {
- let target = {};
- for (let ele of args) exports.mixin(target, ele);
- return target;
- };
- exports.mixinEmitter = (obj, emitter) => {
- let proto = emitter.constructor.prototype;
- for (let key of Object.keys(proto)) {
- let val = proto[key];
- if (typeof val === 'function') {
- exports.define(obj, key, val.bind(emitter));
- } else {
- exports.define(obj, key, val);
- }
- }
- };
- exports.onExit = callback => {
- const onExit = (quit, code) => {
- if (called) return;
- called = true;
- fns.forEach(fn => fn());
- if (quit === true) {
- process.exit(128 + code);
- }
- };
- if (fns.length === 0) {
- process.once('SIGTERM', onExit.bind(null, true, 15));
- process.once('SIGINT', onExit.bind(null, true, 2));
- process.once('exit', onExit);
- }
- fns.push(callback);
- };
- exports.define = (obj, key, value) => {
- Reflect.defineProperty(obj, key, { value });
- };
- exports.defineExport = (obj, key, fn) => {
- let custom;
- Reflect.defineProperty(obj, key, {
- enumerable: true,
- configurable: true,
- set(val) {
- custom = val;
- },
- get() {
- return custom ? custom() : fn();
- }
- });
- };
- /***/ })
- };
- ;
- //# sourceMappingURL=31.index.js.map
|