cli.mjs 224 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282
  1. import { createRequire as __prettierCreateRequire } from "module";
  2. import { fileURLToPath as __prettierFileUrlToPath } from "url";
  3. import { dirname as __prettierDirname } from "path";
  4. const require = __prettierCreateRequire(import.meta.url);
  5. const __filename = __prettierFileUrlToPath(import.meta.url);
  6. const __dirname = __prettierDirname(__filename);
  7. var __create = Object.create;
  8. var __defProp = Object.defineProperty;
  9. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  10. var __getOwnPropNames = Object.getOwnPropertyNames;
  11. var __getProtoOf = Object.getPrototypeOf;
  12. var __hasOwnProp = Object.prototype.hasOwnProperty;
  13. var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
  14. get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
  15. }) : x)(function(x) {
  16. if (typeof require !== "undefined")
  17. return require.apply(this, arguments);
  18. throw Error('Dynamic require of "' + x + '" is not supported');
  19. });
  20. var __commonJS = (cb, mod) => function __require2() {
  21. return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
  22. };
  23. var __copyProps = (to, from, except, desc) => {
  24. if (from && typeof from === "object" || typeof from === "function") {
  25. for (let key of __getOwnPropNames(from))
  26. if (!__hasOwnProp.call(to, key) && key !== except)
  27. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  28. }
  29. return to;
  30. };
  31. var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  32. // If the importer is in node compatibility mode or this is not an ESM
  33. // file that has been converted to a CommonJS file using a Babel-
  34. // compatible transform (i.e. "__esModule" has not been set), then set
  35. // "default" to the CommonJS "module.exports" for node compatibility.
  36. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  37. mod
  38. ));
  39. var __accessCheck = (obj, member, msg) => {
  40. if (!member.has(obj))
  41. throw TypeError("Cannot " + msg);
  42. };
  43. var __privateGet = (obj, member, getter) => {
  44. __accessCheck(obj, member, "read from private field");
  45. return getter ? getter.call(obj) : member.get(obj);
  46. };
  47. var __privateAdd = (obj, member, value) => {
  48. if (member.has(obj))
  49. throw TypeError("Cannot add the same private member more than once");
  50. member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
  51. };
  52. var __privateSet = (obj, member, value, setter) => {
  53. __accessCheck(obj, member, "write to private field");
  54. setter ? setter.call(obj, value) : member.set(obj, value);
  55. return value;
  56. };
  57. var __privateWrapper = (obj, member, setter, getter) => ({
  58. set _(value) {
  59. __privateSet(obj, member, value, setter);
  60. },
  61. get _() {
  62. return __privateGet(obj, member, getter);
  63. }
  64. });
  65. // node_modules/clone/clone.js
  66. var require_clone = __commonJS({
  67. "node_modules/clone/clone.js"(exports, module) {
  68. var clone = function() {
  69. "use strict";
  70. function clone2(parent, circular, depth, prototype) {
  71. var filter;
  72. if (typeof circular === "object") {
  73. depth = circular.depth;
  74. prototype = circular.prototype;
  75. filter = circular.filter;
  76. circular = circular.circular;
  77. }
  78. var allParents = [];
  79. var allChildren = [];
  80. var useBuffer = typeof Buffer != "undefined";
  81. if (typeof circular == "undefined")
  82. circular = true;
  83. if (typeof depth == "undefined")
  84. depth = Infinity;
  85. function _clone(parent2, depth2) {
  86. if (parent2 === null)
  87. return null;
  88. if (depth2 == 0)
  89. return parent2;
  90. var child;
  91. var proto2;
  92. if (typeof parent2 != "object") {
  93. return parent2;
  94. }
  95. if (clone2.__isArray(parent2)) {
  96. child = [];
  97. } else if (clone2.__isRegExp(parent2)) {
  98. child = new RegExp(parent2.source, __getRegExpFlags(parent2));
  99. if (parent2.lastIndex)
  100. child.lastIndex = parent2.lastIndex;
  101. } else if (clone2.__isDate(parent2)) {
  102. child = new Date(parent2.getTime());
  103. } else if (useBuffer && Buffer.isBuffer(parent2)) {
  104. if (Buffer.allocUnsafe) {
  105. child = Buffer.allocUnsafe(parent2.length);
  106. } else {
  107. child = new Buffer(parent2.length);
  108. }
  109. parent2.copy(child);
  110. return child;
  111. } else {
  112. if (typeof prototype == "undefined") {
  113. proto2 = Object.getPrototypeOf(parent2);
  114. child = Object.create(proto2);
  115. } else {
  116. child = Object.create(prototype);
  117. proto2 = prototype;
  118. }
  119. }
  120. if (circular) {
  121. var index = allParents.indexOf(parent2);
  122. if (index != -1) {
  123. return allChildren[index];
  124. }
  125. allParents.push(parent2);
  126. allChildren.push(child);
  127. }
  128. for (var i in parent2) {
  129. var attrs;
  130. if (proto2) {
  131. attrs = Object.getOwnPropertyDescriptor(proto2, i);
  132. }
  133. if (attrs && attrs.set == null) {
  134. continue;
  135. }
  136. child[i] = _clone(parent2[i], depth2 - 1);
  137. }
  138. return child;
  139. }
  140. return _clone(parent, depth);
  141. }
  142. clone2.clonePrototype = function clonePrototype(parent) {
  143. if (parent === null)
  144. return null;
  145. var c = function() {
  146. };
  147. c.prototype = parent;
  148. return new c();
  149. };
  150. function __objToStr(o) {
  151. return Object.prototype.toString.call(o);
  152. }
  153. ;
  154. clone2.__objToStr = __objToStr;
  155. function __isDate(o) {
  156. return typeof o === "object" && __objToStr(o) === "[object Date]";
  157. }
  158. ;
  159. clone2.__isDate = __isDate;
  160. function __isArray(o) {
  161. return typeof o === "object" && __objToStr(o) === "[object Array]";
  162. }
  163. ;
  164. clone2.__isArray = __isArray;
  165. function __isRegExp(o) {
  166. return typeof o === "object" && __objToStr(o) === "[object RegExp]";
  167. }
  168. ;
  169. clone2.__isRegExp = __isRegExp;
  170. function __getRegExpFlags(re) {
  171. var flags = "";
  172. if (re.global)
  173. flags += "g";
  174. if (re.ignoreCase)
  175. flags += "i";
  176. if (re.multiline)
  177. flags += "m";
  178. return flags;
  179. }
  180. ;
  181. clone2.__getRegExpFlags = __getRegExpFlags;
  182. return clone2;
  183. }();
  184. if (typeof module === "object" && module.exports) {
  185. module.exports = clone;
  186. }
  187. }
  188. });
  189. // node_modules/defaults/index.js
  190. var require_defaults = __commonJS({
  191. "node_modules/defaults/index.js"(exports, module) {
  192. var clone = require_clone();
  193. module.exports = function(options, defaults) {
  194. options = options || {};
  195. Object.keys(defaults).forEach(function(key) {
  196. if (typeof options[key] === "undefined") {
  197. options[key] = clone(defaults[key]);
  198. }
  199. });
  200. return options;
  201. };
  202. }
  203. });
  204. // node_modules/wcwidth/combining.js
  205. var require_combining = __commonJS({
  206. "node_modules/wcwidth/combining.js"(exports, module) {
  207. module.exports = [
  208. [768, 879],
  209. [1155, 1158],
  210. [1160, 1161],
  211. [1425, 1469],
  212. [1471, 1471],
  213. [1473, 1474],
  214. [1476, 1477],
  215. [1479, 1479],
  216. [1536, 1539],
  217. [1552, 1557],
  218. [1611, 1630],
  219. [1648, 1648],
  220. [1750, 1764],
  221. [1767, 1768],
  222. [1770, 1773],
  223. [1807, 1807],
  224. [1809, 1809],
  225. [1840, 1866],
  226. [1958, 1968],
  227. [2027, 2035],
  228. [2305, 2306],
  229. [2364, 2364],
  230. [2369, 2376],
  231. [2381, 2381],
  232. [2385, 2388],
  233. [2402, 2403],
  234. [2433, 2433],
  235. [2492, 2492],
  236. [2497, 2500],
  237. [2509, 2509],
  238. [2530, 2531],
  239. [2561, 2562],
  240. [2620, 2620],
  241. [2625, 2626],
  242. [2631, 2632],
  243. [2635, 2637],
  244. [2672, 2673],
  245. [2689, 2690],
  246. [2748, 2748],
  247. [2753, 2757],
  248. [2759, 2760],
  249. [2765, 2765],
  250. [2786, 2787],
  251. [2817, 2817],
  252. [2876, 2876],
  253. [2879, 2879],
  254. [2881, 2883],
  255. [2893, 2893],
  256. [2902, 2902],
  257. [2946, 2946],
  258. [3008, 3008],
  259. [3021, 3021],
  260. [3134, 3136],
  261. [3142, 3144],
  262. [3146, 3149],
  263. [3157, 3158],
  264. [3260, 3260],
  265. [3263, 3263],
  266. [3270, 3270],
  267. [3276, 3277],
  268. [3298, 3299],
  269. [3393, 3395],
  270. [3405, 3405],
  271. [3530, 3530],
  272. [3538, 3540],
  273. [3542, 3542],
  274. [3633, 3633],
  275. [3636, 3642],
  276. [3655, 3662],
  277. [3761, 3761],
  278. [3764, 3769],
  279. [3771, 3772],
  280. [3784, 3789],
  281. [3864, 3865],
  282. [3893, 3893],
  283. [3895, 3895],
  284. [3897, 3897],
  285. [3953, 3966],
  286. [3968, 3972],
  287. [3974, 3975],
  288. [3984, 3991],
  289. [3993, 4028],
  290. [4038, 4038],
  291. [4141, 4144],
  292. [4146, 4146],
  293. [4150, 4151],
  294. [4153, 4153],
  295. [4184, 4185],
  296. [4448, 4607],
  297. [4959, 4959],
  298. [5906, 5908],
  299. [5938, 5940],
  300. [5970, 5971],
  301. [6002, 6003],
  302. [6068, 6069],
  303. [6071, 6077],
  304. [6086, 6086],
  305. [6089, 6099],
  306. [6109, 6109],
  307. [6155, 6157],
  308. [6313, 6313],
  309. [6432, 6434],
  310. [6439, 6440],
  311. [6450, 6450],
  312. [6457, 6459],
  313. [6679, 6680],
  314. [6912, 6915],
  315. [6964, 6964],
  316. [6966, 6970],
  317. [6972, 6972],
  318. [6978, 6978],
  319. [7019, 7027],
  320. [7616, 7626],
  321. [7678, 7679],
  322. [8203, 8207],
  323. [8234, 8238],
  324. [8288, 8291],
  325. [8298, 8303],
  326. [8400, 8431],
  327. [12330, 12335],
  328. [12441, 12442],
  329. [43014, 43014],
  330. [43019, 43019],
  331. [43045, 43046],
  332. [64286, 64286],
  333. [65024, 65039],
  334. [65056, 65059],
  335. [65279, 65279],
  336. [65529, 65531],
  337. [68097, 68099],
  338. [68101, 68102],
  339. [68108, 68111],
  340. [68152, 68154],
  341. [68159, 68159],
  342. [119143, 119145],
  343. [119155, 119170],
  344. [119173, 119179],
  345. [119210, 119213],
  346. [119362, 119364],
  347. [917505, 917505],
  348. [917536, 917631],
  349. [917760, 917999]
  350. ];
  351. }
  352. });
  353. // node_modules/wcwidth/index.js
  354. var require_wcwidth = __commonJS({
  355. "node_modules/wcwidth/index.js"(exports, module) {
  356. "use strict";
  357. var defaults = require_defaults();
  358. var combining = require_combining();
  359. var DEFAULTS = {
  360. nul: 0,
  361. control: 0
  362. };
  363. module.exports = function wcwidth3(str) {
  364. return wcswidth(str, DEFAULTS);
  365. };
  366. module.exports.config = function(opts) {
  367. opts = defaults(opts || {}, DEFAULTS);
  368. return function wcwidth3(str) {
  369. return wcswidth(str, opts);
  370. };
  371. };
  372. function wcswidth(str, opts) {
  373. if (typeof str !== "string")
  374. return wcwidth2(str, opts);
  375. var s = 0;
  376. for (var i = 0; i < str.length; i++) {
  377. var n = wcwidth2(str.charCodeAt(i), opts);
  378. if (n < 0)
  379. return -1;
  380. s += n;
  381. }
  382. return s;
  383. }
  384. function wcwidth2(ucs, opts) {
  385. if (ucs === 0)
  386. return opts.nul;
  387. if (ucs < 32 || ucs >= 127 && ucs < 160)
  388. return opts.control;
  389. if (bisearch(ucs))
  390. return 0;
  391. return 1 + (ucs >= 4352 && (ucs <= 4447 || // Hangul Jamo init. consonants
  392. ucs == 9001 || ucs == 9002 || ucs >= 11904 && ucs <= 42191 && ucs != 12351 || // CJK ... Yi
  393. ucs >= 44032 && ucs <= 55203 || // Hangul Syllables
  394. ucs >= 63744 && ucs <= 64255 || // CJK Compatibility Ideographs
  395. ucs >= 65040 && ucs <= 65049 || // Vertical forms
  396. ucs >= 65072 && ucs <= 65135 || // CJK Compatibility Forms
  397. ucs >= 65280 && ucs <= 65376 || // Fullwidth Forms
  398. ucs >= 65504 && ucs <= 65510 || ucs >= 131072 && ucs <= 196605 || ucs >= 196608 && ucs <= 262141));
  399. }
  400. function bisearch(ucs) {
  401. var min = 0;
  402. var max = combining.length - 1;
  403. var mid;
  404. if (ucs < combining[0][0] || ucs > combining[max][1])
  405. return false;
  406. while (max >= min) {
  407. mid = Math.floor((min + max) / 2);
  408. if (ucs > combining[mid][1])
  409. min = mid + 1;
  410. else if (ucs < combining[mid][0])
  411. max = mid - 1;
  412. else
  413. return true;
  414. }
  415. return false;
  416. }
  417. }
  418. });
  419. // node_modules/dashify/index.js
  420. var require_dashify = __commonJS({
  421. "node_modules/dashify/index.js"(exports, module) {
  422. "use strict";
  423. module.exports = (str, options) => {
  424. if (typeof str !== "string")
  425. throw new TypeError("expected a string");
  426. return str.trim().replace(/([a-z])([A-Z])/g, "$1-$2").replace(/\W/g, (m) => /[À-ž]/.test(m) ? m : "-").replace(/^-+|-+$/g, "").replace(/-{2,}/g, (m) => options && options.condense ? "-" : m).toLowerCase();
  427. };
  428. }
  429. });
  430. // node_modules/minimist/index.js
  431. var require_minimist = __commonJS({
  432. "node_modules/minimist/index.js"(exports, module) {
  433. "use strict";
  434. function hasKey(obj, keys) {
  435. var o = obj;
  436. keys.slice(0, -1).forEach(function(key2) {
  437. o = o[key2] || {};
  438. });
  439. var key = keys[keys.length - 1];
  440. return key in o;
  441. }
  442. function isNumber(x) {
  443. if (typeof x === "number") {
  444. return true;
  445. }
  446. if (/^0x[0-9a-f]+$/i.test(x)) {
  447. return true;
  448. }
  449. return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
  450. }
  451. function isConstructorOrProto(obj, key) {
  452. return key === "constructor" && typeof obj[key] === "function" || key === "__proto__";
  453. }
  454. module.exports = function(args, opts) {
  455. if (!opts) {
  456. opts = {};
  457. }
  458. var flags = {
  459. bools: {},
  460. strings: {},
  461. unknownFn: null
  462. };
  463. if (typeof opts.unknown === "function") {
  464. flags.unknownFn = opts.unknown;
  465. }
  466. if (typeof opts.boolean === "boolean" && opts.boolean) {
  467. flags.allBools = true;
  468. } else {
  469. [].concat(opts.boolean).filter(Boolean).forEach(function(key2) {
  470. flags.bools[key2] = true;
  471. });
  472. }
  473. var aliases = {};
  474. function aliasIsBoolean(key2) {
  475. return aliases[key2].some(function(x) {
  476. return flags.bools[x];
  477. });
  478. }
  479. Object.keys(opts.alias || {}).forEach(function(key2) {
  480. aliases[key2] = [].concat(opts.alias[key2]);
  481. aliases[key2].forEach(function(x) {
  482. aliases[x] = [key2].concat(aliases[key2].filter(function(y) {
  483. return x !== y;
  484. }));
  485. });
  486. });
  487. [].concat(opts.string).filter(Boolean).forEach(function(key2) {
  488. flags.strings[key2] = true;
  489. if (aliases[key2]) {
  490. [].concat(aliases[key2]).forEach(function(k) {
  491. flags.strings[k] = true;
  492. });
  493. }
  494. });
  495. var defaults = opts.default || {};
  496. var argv = { _: [] };
  497. function argDefined(key2, arg2) {
  498. return flags.allBools && /^--[^=]+$/.test(arg2) || flags.strings[key2] || flags.bools[key2] || aliases[key2];
  499. }
  500. function setKey(obj, keys, value2) {
  501. var o = obj;
  502. for (var i2 = 0; i2 < keys.length - 1; i2++) {
  503. var key2 = keys[i2];
  504. if (isConstructorOrProto(o, key2)) {
  505. return;
  506. }
  507. if (o[key2] === void 0) {
  508. o[key2] = {};
  509. }
  510. if (o[key2] === Object.prototype || o[key2] === Number.prototype || o[key2] === String.prototype) {
  511. o[key2] = {};
  512. }
  513. if (o[key2] === Array.prototype) {
  514. o[key2] = [];
  515. }
  516. o = o[key2];
  517. }
  518. var lastKey = keys[keys.length - 1];
  519. if (isConstructorOrProto(o, lastKey)) {
  520. return;
  521. }
  522. if (o === Object.prototype || o === Number.prototype || o === String.prototype) {
  523. o = {};
  524. }
  525. if (o === Array.prototype) {
  526. o = [];
  527. }
  528. if (o[lastKey] === void 0 || flags.bools[lastKey] || typeof o[lastKey] === "boolean") {
  529. o[lastKey] = value2;
  530. } else if (Array.isArray(o[lastKey])) {
  531. o[lastKey].push(value2);
  532. } else {
  533. o[lastKey] = [o[lastKey], value2];
  534. }
  535. }
  536. function setArg(key2, val, arg2) {
  537. if (arg2 && flags.unknownFn && !argDefined(key2, arg2)) {
  538. if (flags.unknownFn(arg2) === false) {
  539. return;
  540. }
  541. }
  542. var value2 = !flags.strings[key2] && isNumber(val) ? Number(val) : val;
  543. setKey(argv, key2.split("."), value2);
  544. (aliases[key2] || []).forEach(function(x) {
  545. setKey(argv, x.split("."), value2);
  546. });
  547. }
  548. Object.keys(flags.bools).forEach(function(key2) {
  549. setArg(key2, defaults[key2] === void 0 ? false : defaults[key2]);
  550. });
  551. var notFlags = [];
  552. if (args.indexOf("--") !== -1) {
  553. notFlags = args.slice(args.indexOf("--") + 1);
  554. args = args.slice(0, args.indexOf("--"));
  555. }
  556. for (var i = 0; i < args.length; i++) {
  557. var arg = args[i];
  558. var key;
  559. var next;
  560. if (/^--.+=/.test(arg)) {
  561. var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
  562. key = m[1];
  563. var value = m[2];
  564. if (flags.bools[key]) {
  565. value = value !== "false";
  566. }
  567. setArg(key, value, arg);
  568. } else if (/^--no-.+/.test(arg)) {
  569. key = arg.match(/^--no-(.+)/)[1];
  570. setArg(key, false, arg);
  571. } else if (/^--.+/.test(arg)) {
  572. key = arg.match(/^--(.+)/)[1];
  573. next = args[i + 1];
  574. if (next !== void 0 && !/^(-|--)[^-]/.test(next) && !flags.bools[key] && !flags.allBools && (aliases[key] ? !aliasIsBoolean(key) : true)) {
  575. setArg(key, next, arg);
  576. i += 1;
  577. } else if (/^(true|false)$/.test(next)) {
  578. setArg(key, next === "true", arg);
  579. i += 1;
  580. } else {
  581. setArg(key, flags.strings[key] ? "" : true, arg);
  582. }
  583. } else if (/^-[^-]+/.test(arg)) {
  584. var letters = arg.slice(1, -1).split("");
  585. var broken = false;
  586. for (var j = 0; j < letters.length; j++) {
  587. next = arg.slice(j + 2);
  588. if (next === "-") {
  589. setArg(letters[j], next, arg);
  590. continue;
  591. }
  592. if (/[A-Za-z]/.test(letters[j]) && next[0] === "=") {
  593. setArg(letters[j], next.slice(1), arg);
  594. broken = true;
  595. break;
  596. }
  597. if (/[A-Za-z]/.test(letters[j]) && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
  598. setArg(letters[j], next, arg);
  599. broken = true;
  600. break;
  601. }
  602. if (letters[j + 1] && letters[j + 1].match(/\W/)) {
  603. setArg(letters[j], arg.slice(j + 2), arg);
  604. broken = true;
  605. break;
  606. } else {
  607. setArg(letters[j], flags.strings[letters[j]] ? "" : true, arg);
  608. }
  609. }
  610. key = arg.slice(-1)[0];
  611. if (!broken && key !== "-") {
  612. if (args[i + 1] && !/^(-|--)[^-]/.test(args[i + 1]) && !flags.bools[key] && (aliases[key] ? !aliasIsBoolean(key) : true)) {
  613. setArg(key, args[i + 1], arg);
  614. i += 1;
  615. } else if (args[i + 1] && /^(true|false)$/.test(args[i + 1])) {
  616. setArg(key, args[i + 1] === "true", arg);
  617. i += 1;
  618. } else {
  619. setArg(key, flags.strings[key] ? "" : true, arg);
  620. }
  621. }
  622. } else {
  623. if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
  624. argv._.push(flags.strings._ || !isNumber(arg) ? arg : Number(arg));
  625. }
  626. if (opts.stopEarly) {
  627. argv._.push.apply(argv._, args.slice(i + 1));
  628. break;
  629. }
  630. }
  631. }
  632. Object.keys(defaults).forEach(function(k) {
  633. if (!hasKey(argv, k.split("."))) {
  634. setKey(argv, k.split("."), defaults[k]);
  635. (aliases[k] || []).forEach(function(x) {
  636. setKey(argv, x.split("."), defaults[k]);
  637. });
  638. }
  639. });
  640. if (opts["--"]) {
  641. argv["--"] = notFlags.slice();
  642. } else {
  643. notFlags.forEach(function(k) {
  644. argv._.push(k);
  645. });
  646. }
  647. return argv;
  648. };
  649. }
  650. });
  651. // node_modules/diff/lib/diff/base.js
  652. var require_base = __commonJS({
  653. "node_modules/diff/lib/diff/base.js"(exports) {
  654. "use strict";
  655. Object.defineProperty(exports, "__esModule", {
  656. value: true
  657. });
  658. exports["default"] = Diff;
  659. function Diff() {
  660. }
  661. Diff.prototype = {
  662. /*istanbul ignore start*/
  663. /*istanbul ignore end*/
  664. diff: function diff2(oldString, newString) {
  665. var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
  666. var callback = options.callback;
  667. if (typeof options === "function") {
  668. callback = options;
  669. options = {};
  670. }
  671. this.options = options;
  672. var self = this;
  673. function done(value) {
  674. if (callback) {
  675. setTimeout(function() {
  676. callback(void 0, value);
  677. }, 0);
  678. return true;
  679. } else {
  680. return value;
  681. }
  682. }
  683. oldString = this.castInput(oldString);
  684. newString = this.castInput(newString);
  685. oldString = this.removeEmpty(this.tokenize(oldString));
  686. newString = this.removeEmpty(this.tokenize(newString));
  687. var newLen = newString.length, oldLen = oldString.length;
  688. var editLength = 1;
  689. var maxEditLength = newLen + oldLen;
  690. if (options.maxEditLength) {
  691. maxEditLength = Math.min(maxEditLength, options.maxEditLength);
  692. }
  693. var bestPath = [{
  694. newPos: -1,
  695. components: []
  696. }];
  697. var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
  698. if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
  699. return done([{
  700. value: this.join(newString),
  701. count: newString.length
  702. }]);
  703. }
  704. function execEditLength() {
  705. for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
  706. var basePath = (
  707. /*istanbul ignore start*/
  708. void 0
  709. );
  710. var addPath = bestPath[diagonalPath - 1], removePath = bestPath[diagonalPath + 1], _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
  711. if (addPath) {
  712. bestPath[diagonalPath - 1] = void 0;
  713. }
  714. var canAdd = addPath && addPath.newPos + 1 < newLen, canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
  715. if (!canAdd && !canRemove) {
  716. bestPath[diagonalPath] = void 0;
  717. continue;
  718. }
  719. if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
  720. basePath = clonePath(removePath);
  721. self.pushComponent(basePath.components, void 0, true);
  722. } else {
  723. basePath = addPath;
  724. basePath.newPos++;
  725. self.pushComponent(basePath.components, true, void 0);
  726. }
  727. _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath);
  728. if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
  729. return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
  730. } else {
  731. bestPath[diagonalPath] = basePath;
  732. }
  733. }
  734. editLength++;
  735. }
  736. if (callback) {
  737. (function exec() {
  738. setTimeout(function() {
  739. if (editLength > maxEditLength) {
  740. return callback();
  741. }
  742. if (!execEditLength()) {
  743. exec();
  744. }
  745. }, 0);
  746. })();
  747. } else {
  748. while (editLength <= maxEditLength) {
  749. var ret = execEditLength();
  750. if (ret) {
  751. return ret;
  752. }
  753. }
  754. }
  755. },
  756. /*istanbul ignore start*/
  757. /*istanbul ignore end*/
  758. pushComponent: function pushComponent(components, added, removed) {
  759. var last = components[components.length - 1];
  760. if (last && last.added === added && last.removed === removed) {
  761. components[components.length - 1] = {
  762. count: last.count + 1,
  763. added,
  764. removed
  765. };
  766. } else {
  767. components.push({
  768. count: 1,
  769. added,
  770. removed
  771. });
  772. }
  773. },
  774. /*istanbul ignore start*/
  775. /*istanbul ignore end*/
  776. extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
  777. var newLen = newString.length, oldLen = oldString.length, newPos = basePath.newPos, oldPos = newPos - diagonalPath, commonCount = 0;
  778. while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
  779. newPos++;
  780. oldPos++;
  781. commonCount++;
  782. }
  783. if (commonCount) {
  784. basePath.components.push({
  785. count: commonCount
  786. });
  787. }
  788. basePath.newPos = newPos;
  789. return oldPos;
  790. },
  791. /*istanbul ignore start*/
  792. /*istanbul ignore end*/
  793. equals: function equals(left, right) {
  794. if (this.options.comparator) {
  795. return this.options.comparator(left, right);
  796. } else {
  797. return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
  798. }
  799. },
  800. /*istanbul ignore start*/
  801. /*istanbul ignore end*/
  802. removeEmpty: function removeEmpty(array2) {
  803. var ret = [];
  804. for (var i = 0; i < array2.length; i++) {
  805. if (array2[i]) {
  806. ret.push(array2[i]);
  807. }
  808. }
  809. return ret;
  810. },
  811. /*istanbul ignore start*/
  812. /*istanbul ignore end*/
  813. castInput: function castInput(value) {
  814. return value;
  815. },
  816. /*istanbul ignore start*/
  817. /*istanbul ignore end*/
  818. tokenize: function tokenize(value) {
  819. return value.split("");
  820. },
  821. /*istanbul ignore start*/
  822. /*istanbul ignore end*/
  823. join: function join(chars) {
  824. return chars.join("");
  825. }
  826. };
  827. function buildValues(diff2, components, newString, oldString, useLongestToken) {
  828. var componentPos = 0, componentLen = components.length, newPos = 0, oldPos = 0;
  829. for (; componentPos < componentLen; componentPos++) {
  830. var component = components[componentPos];
  831. if (!component.removed) {
  832. if (!component.added && useLongestToken) {
  833. var value = newString.slice(newPos, newPos + component.count);
  834. value = value.map(function(value2, i) {
  835. var oldValue = oldString[oldPos + i];
  836. return oldValue.length > value2.length ? oldValue : value2;
  837. });
  838. component.value = diff2.join(value);
  839. } else {
  840. component.value = diff2.join(newString.slice(newPos, newPos + component.count));
  841. }
  842. newPos += component.count;
  843. if (!component.added) {
  844. oldPos += component.count;
  845. }
  846. } else {
  847. component.value = diff2.join(oldString.slice(oldPos, oldPos + component.count));
  848. oldPos += component.count;
  849. if (componentPos && components[componentPos - 1].added) {
  850. var tmp = components[componentPos - 1];
  851. components[componentPos - 1] = components[componentPos];
  852. components[componentPos] = tmp;
  853. }
  854. }
  855. }
  856. var lastComponent = components[componentLen - 1];
  857. if (componentLen > 1 && typeof lastComponent.value === "string" && (lastComponent.added || lastComponent.removed) && diff2.equals("", lastComponent.value)) {
  858. components[componentLen - 2].value += lastComponent.value;
  859. components.pop();
  860. }
  861. return components;
  862. }
  863. function clonePath(path10) {
  864. return {
  865. newPos: path10.newPos,
  866. components: path10.components.slice(0)
  867. };
  868. }
  869. }
  870. });
  871. // node_modules/diff/lib/util/params.js
  872. var require_params = __commonJS({
  873. "node_modules/diff/lib/util/params.js"(exports) {
  874. "use strict";
  875. Object.defineProperty(exports, "__esModule", {
  876. value: true
  877. });
  878. exports.generateOptions = generateOptions;
  879. function generateOptions(options, defaults) {
  880. if (typeof options === "function") {
  881. defaults.callback = options;
  882. } else if (options) {
  883. for (var name in options) {
  884. if (options.hasOwnProperty(name)) {
  885. defaults[name] = options[name];
  886. }
  887. }
  888. }
  889. return defaults;
  890. }
  891. }
  892. });
  893. // node_modules/diff/lib/diff/line.js
  894. var require_line = __commonJS({
  895. "node_modules/diff/lib/diff/line.js"(exports) {
  896. "use strict";
  897. Object.defineProperty(exports, "__esModule", {
  898. value: true
  899. });
  900. exports.diffLines = diffLines;
  901. exports.diffTrimmedLines = diffTrimmedLines;
  902. exports.lineDiff = void 0;
  903. var _base = _interopRequireDefault(require_base());
  904. var _params = require_params();
  905. function _interopRequireDefault(obj) {
  906. return obj && obj.__esModule ? obj : { "default": obj };
  907. }
  908. var lineDiff = new /*istanbul ignore start*/
  909. _base[
  910. /*istanbul ignore start*/
  911. "default"
  912. /*istanbul ignore end*/
  913. ]();
  914. exports.lineDiff = lineDiff;
  915. lineDiff.tokenize = function(value) {
  916. var retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
  917. if (!linesAndNewlines[linesAndNewlines.length - 1]) {
  918. linesAndNewlines.pop();
  919. }
  920. for (var i = 0; i < linesAndNewlines.length; i++) {
  921. var line = linesAndNewlines[i];
  922. if (i % 2 && !this.options.newlineIsToken) {
  923. retLines[retLines.length - 1] += line;
  924. } else {
  925. if (this.options.ignoreWhitespace) {
  926. line = line.trim();
  927. }
  928. retLines.push(line);
  929. }
  930. }
  931. return retLines;
  932. };
  933. function diffLines(oldStr, newStr, callback) {
  934. return lineDiff.diff(oldStr, newStr, callback);
  935. }
  936. function diffTrimmedLines(oldStr, newStr, callback) {
  937. var options = (
  938. /*istanbul ignore start*/
  939. (0, /*istanbul ignore end*/
  940. /*istanbul ignore start*/
  941. _params.generateOptions)(callback, {
  942. ignoreWhitespace: true
  943. })
  944. );
  945. return lineDiff.diff(oldStr, newStr, options);
  946. }
  947. }
  948. });
  949. // node_modules/diff/lib/patch/create.js
  950. var require_create = __commonJS({
  951. "node_modules/diff/lib/patch/create.js"(exports) {
  952. "use strict";
  953. Object.defineProperty(exports, "__esModule", {
  954. value: true
  955. });
  956. exports.structuredPatch = structuredPatch;
  957. exports.formatPatch = formatPatch;
  958. exports.createTwoFilesPatch = createTwoFilesPatch2;
  959. exports.createPatch = createPatch;
  960. var _line = require_line();
  961. function _toConsumableArray(arr) {
  962. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
  963. }
  964. function _nonIterableSpread() {
  965. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  966. }
  967. function _unsupportedIterableToArray(o, minLen) {
  968. if (!o)
  969. return;
  970. if (typeof o === "string")
  971. return _arrayLikeToArray(o, minLen);
  972. var n = Object.prototype.toString.call(o).slice(8, -1);
  973. if (n === "Object" && o.constructor)
  974. n = o.constructor.name;
  975. if (n === "Map" || n === "Set")
  976. return Array.from(o);
  977. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
  978. return _arrayLikeToArray(o, minLen);
  979. }
  980. function _iterableToArray(iter) {
  981. if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter))
  982. return Array.from(iter);
  983. }
  984. function _arrayWithoutHoles(arr) {
  985. if (Array.isArray(arr))
  986. return _arrayLikeToArray(arr);
  987. }
  988. function _arrayLikeToArray(arr, len) {
  989. if (len == null || len > arr.length)
  990. len = arr.length;
  991. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  992. arr2[i] = arr[i];
  993. }
  994. return arr2;
  995. }
  996. function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  997. if (!options) {
  998. options = {};
  999. }
  1000. if (typeof options.context === "undefined") {
  1001. options.context = 4;
  1002. }
  1003. var diff2 = (
  1004. /*istanbul ignore start*/
  1005. (0, /*istanbul ignore end*/
  1006. /*istanbul ignore start*/
  1007. _line.diffLines)(oldStr, newStr, options)
  1008. );
  1009. if (!diff2) {
  1010. return;
  1011. }
  1012. diff2.push({
  1013. value: "",
  1014. lines: []
  1015. });
  1016. function contextLines(lines) {
  1017. return lines.map(function(entry) {
  1018. return " " + entry;
  1019. });
  1020. }
  1021. var hunks = [];
  1022. var oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1;
  1023. var _loop = function _loop2(i2) {
  1024. var current = diff2[i2], lines = current.lines || current.value.replace(/\n$/, "").split("\n");
  1025. current.lines = lines;
  1026. if (current.added || current.removed) {
  1027. var _curRange;
  1028. if (!oldRangeStart) {
  1029. var prev = diff2[i2 - 1];
  1030. oldRangeStart = oldLine;
  1031. newRangeStart = newLine;
  1032. if (prev) {
  1033. curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
  1034. oldRangeStart -= curRange.length;
  1035. newRangeStart -= curRange.length;
  1036. }
  1037. }
  1038. (_curRange = /*istanbul ignore end*/
  1039. curRange).push.apply(
  1040. /*istanbul ignore start*/
  1041. _curRange,
  1042. /*istanbul ignore start*/
  1043. _toConsumableArray(
  1044. /*istanbul ignore end*/
  1045. lines.map(function(entry) {
  1046. return (current.added ? "+" : "-") + entry;
  1047. })
  1048. )
  1049. );
  1050. if (current.added) {
  1051. newLine += lines.length;
  1052. } else {
  1053. oldLine += lines.length;
  1054. }
  1055. } else {
  1056. if (oldRangeStart) {
  1057. if (lines.length <= options.context * 2 && i2 < diff2.length - 2) {
  1058. var _curRange2;
  1059. (_curRange2 = /*istanbul ignore end*/
  1060. curRange).push.apply(
  1061. /*istanbul ignore start*/
  1062. _curRange2,
  1063. /*istanbul ignore start*/
  1064. _toConsumableArray(
  1065. /*istanbul ignore end*/
  1066. contextLines(lines)
  1067. )
  1068. );
  1069. } else {
  1070. var _curRange3;
  1071. var contextSize = Math.min(lines.length, options.context);
  1072. (_curRange3 = /*istanbul ignore end*/
  1073. curRange).push.apply(
  1074. /*istanbul ignore start*/
  1075. _curRange3,
  1076. /*istanbul ignore start*/
  1077. _toConsumableArray(
  1078. /*istanbul ignore end*/
  1079. contextLines(lines.slice(0, contextSize))
  1080. )
  1081. );
  1082. var hunk = {
  1083. oldStart: oldRangeStart,
  1084. oldLines: oldLine - oldRangeStart + contextSize,
  1085. newStart: newRangeStart,
  1086. newLines: newLine - newRangeStart + contextSize,
  1087. lines: curRange
  1088. };
  1089. if (i2 >= diff2.length - 2 && lines.length <= options.context) {
  1090. var oldEOFNewline = /\n$/.test(oldStr);
  1091. var newEOFNewline = /\n$/.test(newStr);
  1092. var noNlBeforeAdds = lines.length == 0 && curRange.length > hunk.oldLines;
  1093. if (!oldEOFNewline && noNlBeforeAdds && oldStr.length > 0) {
  1094. curRange.splice(hunk.oldLines, 0, "\\ No newline at end of file");
  1095. }
  1096. if (!oldEOFNewline && !noNlBeforeAdds || !newEOFNewline) {
  1097. curRange.push("\\ No newline at end of file");
  1098. }
  1099. }
  1100. hunks.push(hunk);
  1101. oldRangeStart = 0;
  1102. newRangeStart = 0;
  1103. curRange = [];
  1104. }
  1105. }
  1106. oldLine += lines.length;
  1107. newLine += lines.length;
  1108. }
  1109. };
  1110. for (var i = 0; i < diff2.length; i++) {
  1111. _loop(
  1112. /*istanbul ignore end*/
  1113. i
  1114. );
  1115. }
  1116. return {
  1117. oldFileName,
  1118. newFileName,
  1119. oldHeader,
  1120. newHeader,
  1121. hunks
  1122. };
  1123. }
  1124. function formatPatch(diff2) {
  1125. var ret = [];
  1126. if (diff2.oldFileName == diff2.newFileName) {
  1127. ret.push("Index: " + diff2.oldFileName);
  1128. }
  1129. ret.push("===================================================================");
  1130. ret.push("--- " + diff2.oldFileName + (typeof diff2.oldHeader === "undefined" ? "" : " " + diff2.oldHeader));
  1131. ret.push("+++ " + diff2.newFileName + (typeof diff2.newHeader === "undefined" ? "" : " " + diff2.newHeader));
  1132. for (var i = 0; i < diff2.hunks.length; i++) {
  1133. var hunk = diff2.hunks[i];
  1134. if (hunk.oldLines === 0) {
  1135. hunk.oldStart -= 1;
  1136. }
  1137. if (hunk.newLines === 0) {
  1138. hunk.newStart -= 1;
  1139. }
  1140. ret.push("@@ -" + hunk.oldStart + "," + hunk.oldLines + " +" + hunk.newStart + "," + hunk.newLines + " @@");
  1141. ret.push.apply(ret, hunk.lines);
  1142. }
  1143. return ret.join("\n") + "\n";
  1144. }
  1145. function createTwoFilesPatch2(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  1146. return formatPatch(structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options));
  1147. }
  1148. function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
  1149. return createTwoFilesPatch2(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
  1150. }
  1151. }
  1152. });
  1153. // node_modules/common-path-prefix/index.js
  1154. var require_common_path_prefix = __commonJS({
  1155. "node_modules/common-path-prefix/index.js"(exports, module) {
  1156. "use strict";
  1157. var { sep: DEFAULT_SEPARATOR } = __require("path");
  1158. var determineSeparator = (paths) => {
  1159. for (const path10 of paths) {
  1160. const match = /(\/|\\)/.exec(path10);
  1161. if (match !== null)
  1162. return match[0];
  1163. }
  1164. return DEFAULT_SEPARATOR;
  1165. };
  1166. module.exports = function commonPathPrefix2(paths, sep = determineSeparator(paths)) {
  1167. const [first = "", ...remaining] = paths;
  1168. if (first === "" || remaining.length === 0)
  1169. return "";
  1170. const parts = first.split(sep);
  1171. let endOfPrefix = parts.length;
  1172. for (const path10 of remaining) {
  1173. const compare = path10.split(sep);
  1174. for (let i = 0; i < endOfPrefix; i++) {
  1175. if (compare[i] !== parts[i]) {
  1176. endOfPrefix = i;
  1177. }
  1178. }
  1179. if (endOfPrefix === 0)
  1180. return "";
  1181. }
  1182. const prefix = parts.slice(0, endOfPrefix).join(sep);
  1183. return prefix.endsWith(sep) ? prefix : prefix + sep;
  1184. };
  1185. }
  1186. });
  1187. // node_modules/json-buffer/index.js
  1188. var require_json_buffer = __commonJS({
  1189. "node_modules/json-buffer/index.js"(exports) {
  1190. exports.stringify = function stringify4(o) {
  1191. if ("undefined" == typeof o)
  1192. return o;
  1193. if (o && Buffer.isBuffer(o))
  1194. return JSON.stringify(":base64:" + o.toString("base64"));
  1195. if (o && o.toJSON)
  1196. o = o.toJSON();
  1197. if (o && "object" === typeof o) {
  1198. var s = "";
  1199. var array2 = Array.isArray(o);
  1200. s = array2 ? "[" : "{";
  1201. var first = true;
  1202. for (var k in o) {
  1203. var ignore = "function" == typeof o[k] || !array2 && "undefined" === typeof o[k];
  1204. if (Object.hasOwnProperty.call(o, k) && !ignore) {
  1205. if (!first)
  1206. s += ",";
  1207. first = false;
  1208. if (array2) {
  1209. if (o[k] == void 0)
  1210. s += "null";
  1211. else
  1212. s += stringify4(o[k]);
  1213. } else if (o[k] !== void 0) {
  1214. s += stringify4(k) + ":" + stringify4(o[k]);
  1215. }
  1216. }
  1217. }
  1218. s += array2 ? "]" : "}";
  1219. return s;
  1220. } else if ("string" === typeof o) {
  1221. return JSON.stringify(/^:/.test(o) ? ":" + o : o);
  1222. } else if ("undefined" === typeof o) {
  1223. return "null";
  1224. } else
  1225. return JSON.stringify(o);
  1226. };
  1227. exports.parse = function(s) {
  1228. return JSON.parse(s, function(key, value) {
  1229. if ("string" === typeof value) {
  1230. if (/^:base64:/.test(value))
  1231. return Buffer.from(value.substring(8), "base64");
  1232. else
  1233. return /^:/.test(value) ? value.substring(1) : value;
  1234. }
  1235. return value;
  1236. });
  1237. };
  1238. }
  1239. });
  1240. // node_modules/keyv/src/index.js
  1241. var require_src = __commonJS({
  1242. "node_modules/keyv/src/index.js"(exports, module) {
  1243. "use strict";
  1244. var EventEmitter = __require("events");
  1245. var JSONB = require_json_buffer();
  1246. var loadStore = (options) => {
  1247. const adapters = {
  1248. redis: "@keyv/redis",
  1249. rediss: "@keyv/redis",
  1250. mongodb: "@keyv/mongo",
  1251. mongo: "@keyv/mongo",
  1252. sqlite: "@keyv/sqlite",
  1253. postgresql: "@keyv/postgres",
  1254. postgres: "@keyv/postgres",
  1255. mysql: "@keyv/mysql",
  1256. etcd: "@keyv/etcd",
  1257. offline: "@keyv/offline",
  1258. tiered: "@keyv/tiered"
  1259. };
  1260. if (options.adapter || options.uri) {
  1261. const adapter = options.adapter || /^[^:+]*/.exec(options.uri)[0];
  1262. return new (__require(adapters[adapter]))(options);
  1263. }
  1264. return /* @__PURE__ */ new Map();
  1265. };
  1266. var iterableAdapters = [
  1267. "sqlite",
  1268. "postgres",
  1269. "mysql",
  1270. "mongo",
  1271. "redis",
  1272. "tiered"
  1273. ];
  1274. var Keyv = class extends EventEmitter {
  1275. constructor(uri, { emitErrors = true, ...options } = {}) {
  1276. super();
  1277. this.opts = {
  1278. namespace: "keyv",
  1279. serialize: JSONB.stringify,
  1280. deserialize: JSONB.parse,
  1281. ...typeof uri === "string" ? { uri } : uri,
  1282. ...options
  1283. };
  1284. if (!this.opts.store) {
  1285. const adapterOptions = { ...this.opts };
  1286. this.opts.store = loadStore(adapterOptions);
  1287. }
  1288. if (this.opts.compression) {
  1289. const compression = this.opts.compression;
  1290. this.opts.serialize = compression.serialize.bind(compression);
  1291. this.opts.deserialize = compression.deserialize.bind(compression);
  1292. }
  1293. if (typeof this.opts.store.on === "function" && emitErrors) {
  1294. this.opts.store.on("error", (error) => this.emit("error", error));
  1295. }
  1296. this.opts.store.namespace = this.opts.namespace;
  1297. const generateIterator = (iterator) => async function* () {
  1298. for await (const [key, raw] of typeof iterator === "function" ? iterator(this.opts.store.namespace) : iterator) {
  1299. const data = await this.opts.deserialize(raw);
  1300. if (this.opts.store.namespace && !key.includes(this.opts.store.namespace)) {
  1301. continue;
  1302. }
  1303. if (typeof data.expires === "number" && Date.now() > data.expires) {
  1304. this.delete(key);
  1305. continue;
  1306. }
  1307. yield [this._getKeyUnprefix(key), data.value];
  1308. }
  1309. };
  1310. if (typeof this.opts.store[Symbol.iterator] === "function" && this.opts.store instanceof Map) {
  1311. this.iterator = generateIterator(this.opts.store);
  1312. } else if (typeof this.opts.store.iterator === "function" && this.opts.store.opts && this._checkIterableAdaptar()) {
  1313. this.iterator = generateIterator(this.opts.store.iterator.bind(this.opts.store));
  1314. }
  1315. }
  1316. _checkIterableAdaptar() {
  1317. return iterableAdapters.includes(this.opts.store.opts.dialect) || iterableAdapters.findIndex((element) => this.opts.store.opts.url.includes(element)) >= 0;
  1318. }
  1319. _getKeyPrefix(key) {
  1320. return `${this.opts.namespace}:${key}`;
  1321. }
  1322. _getKeyPrefixArray(keys) {
  1323. return keys.map((key) => `${this.opts.namespace}:${key}`);
  1324. }
  1325. _getKeyUnprefix(key) {
  1326. return key.split(":").splice(1).join(":");
  1327. }
  1328. get(key, options) {
  1329. const { store } = this.opts;
  1330. const isArray = Array.isArray(key);
  1331. const keyPrefixed = isArray ? this._getKeyPrefixArray(key) : this._getKeyPrefix(key);
  1332. if (isArray && store.getMany === void 0) {
  1333. const promises = [];
  1334. for (const key2 of keyPrefixed) {
  1335. promises.push(
  1336. Promise.resolve().then(() => store.get(key2)).then((data) => typeof data === "string" ? this.opts.deserialize(data) : this.opts.compression ? this.opts.deserialize(data) : data).then((data) => {
  1337. if (data === void 0 || data === null) {
  1338. return void 0;
  1339. }
  1340. if (typeof data.expires === "number" && Date.now() > data.expires) {
  1341. return this.delete(key2).then(() => void 0);
  1342. }
  1343. return options && options.raw ? data : data.value;
  1344. })
  1345. );
  1346. }
  1347. return Promise.allSettled(promises).then((values) => {
  1348. const data = [];
  1349. for (const value of values) {
  1350. data.push(value.value);
  1351. }
  1352. return data;
  1353. });
  1354. }
  1355. return Promise.resolve().then(() => isArray ? store.getMany(keyPrefixed) : store.get(keyPrefixed)).then((data) => typeof data === "string" ? this.opts.deserialize(data) : this.opts.compression ? this.opts.deserialize(data) : data).then((data) => {
  1356. if (data === void 0 || data === null) {
  1357. return void 0;
  1358. }
  1359. if (isArray) {
  1360. const result = [];
  1361. for (let row of data) {
  1362. if (typeof row === "string") {
  1363. row = this.opts.deserialize(row);
  1364. }
  1365. if (row === void 0 || row === null) {
  1366. result.push(void 0);
  1367. continue;
  1368. }
  1369. if (typeof row.expires === "number" && Date.now() > row.expires) {
  1370. this.delete(key).then(() => void 0);
  1371. result.push(void 0);
  1372. } else {
  1373. result.push(options && options.raw ? row : row.value);
  1374. }
  1375. }
  1376. return result;
  1377. }
  1378. if (typeof data.expires === "number" && Date.now() > data.expires) {
  1379. return this.delete(key).then(() => void 0);
  1380. }
  1381. return options && options.raw ? data : data.value;
  1382. });
  1383. }
  1384. set(key, value, ttl) {
  1385. const keyPrefixed = this._getKeyPrefix(key);
  1386. if (typeof ttl === "undefined") {
  1387. ttl = this.opts.ttl;
  1388. }
  1389. if (ttl === 0) {
  1390. ttl = void 0;
  1391. }
  1392. const { store } = this.opts;
  1393. return Promise.resolve().then(() => {
  1394. const expires = typeof ttl === "number" ? Date.now() + ttl : null;
  1395. if (typeof value === "symbol") {
  1396. this.emit("error", "symbol cannot be serialized");
  1397. }
  1398. value = { value, expires };
  1399. return this.opts.serialize(value);
  1400. }).then((value2) => store.set(keyPrefixed, value2, ttl)).then(() => true);
  1401. }
  1402. delete(key) {
  1403. const { store } = this.opts;
  1404. if (Array.isArray(key)) {
  1405. const keyPrefixed2 = this._getKeyPrefixArray(key);
  1406. if (store.deleteMany === void 0) {
  1407. const promises = [];
  1408. for (const key2 of keyPrefixed2) {
  1409. promises.push(store.delete(key2));
  1410. }
  1411. return Promise.allSettled(promises).then((values) => values.every((x) => x.value === true));
  1412. }
  1413. return Promise.resolve().then(() => store.deleteMany(keyPrefixed2));
  1414. }
  1415. const keyPrefixed = this._getKeyPrefix(key);
  1416. return Promise.resolve().then(() => store.delete(keyPrefixed));
  1417. }
  1418. clear() {
  1419. const { store } = this.opts;
  1420. return Promise.resolve().then(() => store.clear());
  1421. }
  1422. has(key) {
  1423. const keyPrefixed = this._getKeyPrefix(key);
  1424. const { store } = this.opts;
  1425. return Promise.resolve().then(async () => {
  1426. if (typeof store.has === "function") {
  1427. return store.has(keyPrefixed);
  1428. }
  1429. const value = await store.get(keyPrefixed);
  1430. return value !== void 0;
  1431. });
  1432. }
  1433. disconnect() {
  1434. const { store } = this.opts;
  1435. if (typeof store.disconnect === "function") {
  1436. return store.disconnect();
  1437. }
  1438. }
  1439. };
  1440. module.exports = Keyv;
  1441. }
  1442. });
  1443. // node_modules/flatted/cjs/index.js
  1444. var require_cjs = __commonJS({
  1445. "node_modules/flatted/cjs/index.js"(exports) {
  1446. "use strict";
  1447. var { parse: $parse, stringify: $stringify } = JSON;
  1448. var { keys } = Object;
  1449. var Primitive = String;
  1450. var primitive = "string";
  1451. var ignore = {};
  1452. var object = "object";
  1453. var noop = (_, value) => value;
  1454. var primitives = (value) => value instanceof Primitive ? Primitive(value) : value;
  1455. var Primitives = (_, value) => typeof value === primitive ? new Primitive(value) : value;
  1456. var revive = (input, parsed, output, $) => {
  1457. const lazy = [];
  1458. for (let ke = keys(output), { length } = ke, y = 0; y < length; y++) {
  1459. const k = ke[y];
  1460. const value = output[k];
  1461. if (value instanceof Primitive) {
  1462. const tmp = input[value];
  1463. if (typeof tmp === object && !parsed.has(tmp)) {
  1464. parsed.add(tmp);
  1465. output[k] = ignore;
  1466. lazy.push({ k, a: [input, parsed, tmp, $] });
  1467. } else
  1468. output[k] = $.call(output, k, tmp);
  1469. } else if (output[k] !== ignore)
  1470. output[k] = $.call(output, k, value);
  1471. }
  1472. for (let { length } = lazy, i = 0; i < length; i++) {
  1473. const { k, a } = lazy[i];
  1474. output[k] = $.call(output, k, revive.apply(null, a));
  1475. }
  1476. return output;
  1477. };
  1478. var set = (known, input, value) => {
  1479. const index = Primitive(input.push(value) - 1);
  1480. known.set(value, index);
  1481. return index;
  1482. };
  1483. var parse = (text, reviver) => {
  1484. const input = $parse(text, Primitives).map(primitives);
  1485. const value = input[0];
  1486. const $ = reviver || noop;
  1487. const tmp = typeof value === object && value ? revive(input, /* @__PURE__ */ new Set(), value, $) : value;
  1488. return $.call({ "": tmp }, "", tmp);
  1489. };
  1490. exports.parse = parse;
  1491. var stringify4 = (value, replacer, space) => {
  1492. const $ = replacer && typeof replacer === object ? (k, v) => k === "" || -1 < replacer.indexOf(k) ? v : void 0 : replacer || noop;
  1493. const known = /* @__PURE__ */ new Map();
  1494. const input = [];
  1495. const output = [];
  1496. let i = +set(known, input, $.call({ "": value }, "", value));
  1497. let firstRun = !i;
  1498. while (i < input.length) {
  1499. firstRun = true;
  1500. output[i] = $stringify(input[i++], replace, space);
  1501. }
  1502. return "[" + output.join(",") + "]";
  1503. function replace(key, value2) {
  1504. if (firstRun) {
  1505. firstRun = !firstRun;
  1506. return value2;
  1507. }
  1508. const after = $.call(this, key, value2);
  1509. switch (typeof after) {
  1510. case object:
  1511. if (after === null)
  1512. return after;
  1513. case primitive:
  1514. return known.get(after) || set(known, input, after);
  1515. }
  1516. return after;
  1517. }
  1518. };
  1519. exports.stringify = stringify4;
  1520. var toJSON = (any) => $parse(stringify4(any));
  1521. exports.toJSON = toJSON;
  1522. var fromJSON = (any) => parse($stringify(any));
  1523. exports.fromJSON = fromJSON;
  1524. }
  1525. });
  1526. // node_modules/flat-cache/src/utils.js
  1527. var require_utils = __commonJS({
  1528. "node_modules/flat-cache/src/utils.js"(exports, module) {
  1529. var fs6 = __require("fs");
  1530. var path10 = __require("path");
  1531. var flatted = require_cjs();
  1532. module.exports = {
  1533. tryParse: function(filePath, defaultValue) {
  1534. var result;
  1535. try {
  1536. result = this.readJSON(filePath);
  1537. } catch (ex) {
  1538. result = defaultValue;
  1539. }
  1540. return result;
  1541. },
  1542. /**
  1543. * Read json file synchronously using flatted
  1544. *
  1545. * @method readJSON
  1546. * @param {String} filePath Json filepath
  1547. * @returns {*} parse result
  1548. */
  1549. readJSON: function(filePath) {
  1550. return flatted.parse(
  1551. fs6.readFileSync(filePath, {
  1552. encoding: "utf8"
  1553. })
  1554. );
  1555. },
  1556. /**
  1557. * Write json file synchronously using circular-json
  1558. *
  1559. * @method writeJSON
  1560. * @param {String} filePath Json filepath
  1561. * @param {*} data Object to serialize
  1562. */
  1563. writeJSON: function(filePath, data) {
  1564. fs6.mkdirSync(path10.dirname(filePath), {
  1565. recursive: true
  1566. });
  1567. fs6.writeFileSync(filePath, flatted.stringify(data));
  1568. }
  1569. };
  1570. }
  1571. });
  1572. // node_modules/fs.realpath/old.js
  1573. var require_old = __commonJS({
  1574. "node_modules/fs.realpath/old.js"(exports) {
  1575. var pathModule = __require("path");
  1576. var isWindows = process.platform === "win32";
  1577. var fs6 = __require("fs");
  1578. var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
  1579. function rethrow() {
  1580. var callback;
  1581. if (DEBUG) {
  1582. var backtrace = new Error();
  1583. callback = debugCallback;
  1584. } else
  1585. callback = missingCallback;
  1586. return callback;
  1587. function debugCallback(err) {
  1588. if (err) {
  1589. backtrace.message = err.message;
  1590. err = backtrace;
  1591. missingCallback(err);
  1592. }
  1593. }
  1594. function missingCallback(err) {
  1595. if (err) {
  1596. if (process.throwDeprecation)
  1597. throw err;
  1598. else if (!process.noDeprecation) {
  1599. var msg = "fs: missing callback " + (err.stack || err.message);
  1600. if (process.traceDeprecation)
  1601. console.trace(msg);
  1602. else
  1603. console.error(msg);
  1604. }
  1605. }
  1606. }
  1607. }
  1608. function maybeCallback(cb) {
  1609. return typeof cb === "function" ? cb : rethrow();
  1610. }
  1611. var normalize = pathModule.normalize;
  1612. if (isWindows) {
  1613. nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
  1614. } else {
  1615. nextPartRe = /(.*?)(?:[\/]+|$)/g;
  1616. }
  1617. var nextPartRe;
  1618. if (isWindows) {
  1619. splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
  1620. } else {
  1621. splitRootRe = /^[\/]*/;
  1622. }
  1623. var splitRootRe;
  1624. exports.realpathSync = function realpathSync(p, cache) {
  1625. p = pathModule.resolve(p);
  1626. if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
  1627. return cache[p];
  1628. }
  1629. var original = p, seenLinks = {}, knownHard = {};
  1630. var pos;
  1631. var current;
  1632. var base;
  1633. var previous;
  1634. start();
  1635. function start() {
  1636. var m = splitRootRe.exec(p);
  1637. pos = m[0].length;
  1638. current = m[0];
  1639. base = m[0];
  1640. previous = "";
  1641. if (isWindows && !knownHard[base]) {
  1642. fs6.lstatSync(base);
  1643. knownHard[base] = true;
  1644. }
  1645. }
  1646. while (pos < p.length) {
  1647. nextPartRe.lastIndex = pos;
  1648. var result = nextPartRe.exec(p);
  1649. previous = current;
  1650. current += result[0];
  1651. base = previous + result[1];
  1652. pos = nextPartRe.lastIndex;
  1653. if (knownHard[base] || cache && cache[base] === base) {
  1654. continue;
  1655. }
  1656. var resolvedLink;
  1657. if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
  1658. resolvedLink = cache[base];
  1659. } else {
  1660. var stat = fs6.lstatSync(base);
  1661. if (!stat.isSymbolicLink()) {
  1662. knownHard[base] = true;
  1663. if (cache)
  1664. cache[base] = base;
  1665. continue;
  1666. }
  1667. var linkTarget = null;
  1668. if (!isWindows) {
  1669. var id = stat.dev.toString(32) + ":" + stat.ino.toString(32);
  1670. if (seenLinks.hasOwnProperty(id)) {
  1671. linkTarget = seenLinks[id];
  1672. }
  1673. }
  1674. if (linkTarget === null) {
  1675. fs6.statSync(base);
  1676. linkTarget = fs6.readlinkSync(base);
  1677. }
  1678. resolvedLink = pathModule.resolve(previous, linkTarget);
  1679. if (cache)
  1680. cache[base] = resolvedLink;
  1681. if (!isWindows)
  1682. seenLinks[id] = linkTarget;
  1683. }
  1684. p = pathModule.resolve(resolvedLink, p.slice(pos));
  1685. start();
  1686. }
  1687. if (cache)
  1688. cache[original] = p;
  1689. return p;
  1690. };
  1691. exports.realpath = function realpath(p, cache, cb) {
  1692. if (typeof cb !== "function") {
  1693. cb = maybeCallback(cache);
  1694. cache = null;
  1695. }
  1696. p = pathModule.resolve(p);
  1697. if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
  1698. return process.nextTick(cb.bind(null, null, cache[p]));
  1699. }
  1700. var original = p, seenLinks = {}, knownHard = {};
  1701. var pos;
  1702. var current;
  1703. var base;
  1704. var previous;
  1705. start();
  1706. function start() {
  1707. var m = splitRootRe.exec(p);
  1708. pos = m[0].length;
  1709. current = m[0];
  1710. base = m[0];
  1711. previous = "";
  1712. if (isWindows && !knownHard[base]) {
  1713. fs6.lstat(base, function(err) {
  1714. if (err)
  1715. return cb(err);
  1716. knownHard[base] = true;
  1717. LOOP();
  1718. });
  1719. } else {
  1720. process.nextTick(LOOP);
  1721. }
  1722. }
  1723. function LOOP() {
  1724. if (pos >= p.length) {
  1725. if (cache)
  1726. cache[original] = p;
  1727. return cb(null, p);
  1728. }
  1729. nextPartRe.lastIndex = pos;
  1730. var result = nextPartRe.exec(p);
  1731. previous = current;
  1732. current += result[0];
  1733. base = previous + result[1];
  1734. pos = nextPartRe.lastIndex;
  1735. if (knownHard[base] || cache && cache[base] === base) {
  1736. return process.nextTick(LOOP);
  1737. }
  1738. if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
  1739. return gotResolvedLink(cache[base]);
  1740. }
  1741. return fs6.lstat(base, gotStat);
  1742. }
  1743. function gotStat(err, stat) {
  1744. if (err)
  1745. return cb(err);
  1746. if (!stat.isSymbolicLink()) {
  1747. knownHard[base] = true;
  1748. if (cache)
  1749. cache[base] = base;
  1750. return process.nextTick(LOOP);
  1751. }
  1752. if (!isWindows) {
  1753. var id = stat.dev.toString(32) + ":" + stat.ino.toString(32);
  1754. if (seenLinks.hasOwnProperty(id)) {
  1755. return gotTarget(null, seenLinks[id], base);
  1756. }
  1757. }
  1758. fs6.stat(base, function(err2) {
  1759. if (err2)
  1760. return cb(err2);
  1761. fs6.readlink(base, function(err3, target) {
  1762. if (!isWindows)
  1763. seenLinks[id] = target;
  1764. gotTarget(err3, target);
  1765. });
  1766. });
  1767. }
  1768. function gotTarget(err, target, base2) {
  1769. if (err)
  1770. return cb(err);
  1771. var resolvedLink = pathModule.resolve(previous, target);
  1772. if (cache)
  1773. cache[base2] = resolvedLink;
  1774. gotResolvedLink(resolvedLink);
  1775. }
  1776. function gotResolvedLink(resolvedLink) {
  1777. p = pathModule.resolve(resolvedLink, p.slice(pos));
  1778. start();
  1779. }
  1780. };
  1781. }
  1782. });
  1783. // node_modules/fs.realpath/index.js
  1784. var require_fs = __commonJS({
  1785. "node_modules/fs.realpath/index.js"(exports, module) {
  1786. module.exports = realpath;
  1787. realpath.realpath = realpath;
  1788. realpath.sync = realpathSync;
  1789. realpath.realpathSync = realpathSync;
  1790. realpath.monkeypatch = monkeypatch;
  1791. realpath.unmonkeypatch = unmonkeypatch;
  1792. var fs6 = __require("fs");
  1793. var origRealpath = fs6.realpath;
  1794. var origRealpathSync = fs6.realpathSync;
  1795. var version2 = process.version;
  1796. var ok = /^v[0-5]\./.test(version2);
  1797. var old = require_old();
  1798. function newError(er) {
  1799. return er && er.syscall === "realpath" && (er.code === "ELOOP" || er.code === "ENOMEM" || er.code === "ENAMETOOLONG");
  1800. }
  1801. function realpath(p, cache, cb) {
  1802. if (ok) {
  1803. return origRealpath(p, cache, cb);
  1804. }
  1805. if (typeof cache === "function") {
  1806. cb = cache;
  1807. cache = null;
  1808. }
  1809. origRealpath(p, cache, function(er, result) {
  1810. if (newError(er)) {
  1811. old.realpath(p, cache, cb);
  1812. } else {
  1813. cb(er, result);
  1814. }
  1815. });
  1816. }
  1817. function realpathSync(p, cache) {
  1818. if (ok) {
  1819. return origRealpathSync(p, cache);
  1820. }
  1821. try {
  1822. return origRealpathSync(p, cache);
  1823. } catch (er) {
  1824. if (newError(er)) {
  1825. return old.realpathSync(p, cache);
  1826. } else {
  1827. throw er;
  1828. }
  1829. }
  1830. }
  1831. function monkeypatch() {
  1832. fs6.realpath = realpath;
  1833. fs6.realpathSync = realpathSync;
  1834. }
  1835. function unmonkeypatch() {
  1836. fs6.realpath = origRealpath;
  1837. fs6.realpathSync = origRealpathSync;
  1838. }
  1839. }
  1840. });
  1841. // node_modules/concat-map/index.js
  1842. var require_concat_map = __commonJS({
  1843. "node_modules/concat-map/index.js"(exports, module) {
  1844. module.exports = function(xs, fn) {
  1845. var res = [];
  1846. for (var i = 0; i < xs.length; i++) {
  1847. var x = fn(xs[i], i);
  1848. if (isArray(x))
  1849. res.push.apply(res, x);
  1850. else
  1851. res.push(x);
  1852. }
  1853. return res;
  1854. };
  1855. var isArray = Array.isArray || function(xs) {
  1856. return Object.prototype.toString.call(xs) === "[object Array]";
  1857. };
  1858. }
  1859. });
  1860. // node_modules/balanced-match/index.js
  1861. var require_balanced_match = __commonJS({
  1862. "node_modules/balanced-match/index.js"(exports, module) {
  1863. "use strict";
  1864. module.exports = balanced;
  1865. function balanced(a, b, str) {
  1866. if (a instanceof RegExp)
  1867. a = maybeMatch(a, str);
  1868. if (b instanceof RegExp)
  1869. b = maybeMatch(b, str);
  1870. var r = range(a, b, str);
  1871. return r && {
  1872. start: r[0],
  1873. end: r[1],
  1874. pre: str.slice(0, r[0]),
  1875. body: str.slice(r[0] + a.length, r[1]),
  1876. post: str.slice(r[1] + b.length)
  1877. };
  1878. }
  1879. function maybeMatch(reg, str) {
  1880. var m = str.match(reg);
  1881. return m ? m[0] : null;
  1882. }
  1883. balanced.range = range;
  1884. function range(a, b, str) {
  1885. var begs, beg, left, right, result;
  1886. var ai = str.indexOf(a);
  1887. var bi = str.indexOf(b, ai + 1);
  1888. var i = ai;
  1889. if (ai >= 0 && bi > 0) {
  1890. if (a === b) {
  1891. return [ai, bi];
  1892. }
  1893. begs = [];
  1894. left = str.length;
  1895. while (i >= 0 && !result) {
  1896. if (i == ai) {
  1897. begs.push(i);
  1898. ai = str.indexOf(a, i + 1);
  1899. } else if (begs.length == 1) {
  1900. result = [begs.pop(), bi];
  1901. } else {
  1902. beg = begs.pop();
  1903. if (beg < left) {
  1904. left = beg;
  1905. right = bi;
  1906. }
  1907. bi = str.indexOf(b, i + 1);
  1908. }
  1909. i = ai < bi && ai >= 0 ? ai : bi;
  1910. }
  1911. if (begs.length) {
  1912. result = [left, right];
  1913. }
  1914. }
  1915. return result;
  1916. }
  1917. }
  1918. });
  1919. // node_modules/brace-expansion/index.js
  1920. var require_brace_expansion = __commonJS({
  1921. "node_modules/brace-expansion/index.js"(exports, module) {
  1922. var concatMap = require_concat_map();
  1923. var balanced = require_balanced_match();
  1924. module.exports = expandTop;
  1925. var escSlash = "\0SLASH" + Math.random() + "\0";
  1926. var escOpen = "\0OPEN" + Math.random() + "\0";
  1927. var escClose = "\0CLOSE" + Math.random() + "\0";
  1928. var escComma = "\0COMMA" + Math.random() + "\0";
  1929. var escPeriod = "\0PERIOD" + Math.random() + "\0";
  1930. function numeric(str) {
  1931. return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
  1932. }
  1933. function escapeBraces(str) {
  1934. return str.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod);
  1935. }
  1936. function unescapeBraces(str) {
  1937. return str.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".");
  1938. }
  1939. function parseCommaParts(str) {
  1940. if (!str)
  1941. return [""];
  1942. var parts = [];
  1943. var m = balanced("{", "}", str);
  1944. if (!m)
  1945. return str.split(",");
  1946. var pre = m.pre;
  1947. var body = m.body;
  1948. var post = m.post;
  1949. var p = pre.split(",");
  1950. p[p.length - 1] += "{" + body + "}";
  1951. var postParts = parseCommaParts(post);
  1952. if (post.length) {
  1953. p[p.length - 1] += postParts.shift();
  1954. p.push.apply(p, postParts);
  1955. }
  1956. parts.push.apply(parts, p);
  1957. return parts;
  1958. }
  1959. function expandTop(str) {
  1960. if (!str)
  1961. return [];
  1962. if (str.substr(0, 2) === "{}") {
  1963. str = "\\{\\}" + str.substr(2);
  1964. }
  1965. return expand(escapeBraces(str), true).map(unescapeBraces);
  1966. }
  1967. function embrace(str) {
  1968. return "{" + str + "}";
  1969. }
  1970. function isPadded(el) {
  1971. return /^-?0\d/.test(el);
  1972. }
  1973. function lte(i, y) {
  1974. return i <= y;
  1975. }
  1976. function gte(i, y) {
  1977. return i >= y;
  1978. }
  1979. function expand(str, isTop) {
  1980. var expansions = [];
  1981. var m = balanced("{", "}", str);
  1982. if (!m || /\$$/.test(m.pre))
  1983. return [str];
  1984. var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
  1985. var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
  1986. var isSequence = isNumericSequence || isAlphaSequence;
  1987. var isOptions = m.body.indexOf(",") >= 0;
  1988. if (!isSequence && !isOptions) {
  1989. if (m.post.match(/,.*\}/)) {
  1990. str = m.pre + "{" + m.body + escClose + m.post;
  1991. return expand(str);
  1992. }
  1993. return [str];
  1994. }
  1995. var n;
  1996. if (isSequence) {
  1997. n = m.body.split(/\.\./);
  1998. } else {
  1999. n = parseCommaParts(m.body);
  2000. if (n.length === 1) {
  2001. n = expand(n[0], false).map(embrace);
  2002. if (n.length === 1) {
  2003. var post = m.post.length ? expand(m.post, false) : [""];
  2004. return post.map(function(p) {
  2005. return m.pre + n[0] + p;
  2006. });
  2007. }
  2008. }
  2009. }
  2010. var pre = m.pre;
  2011. var post = m.post.length ? expand(m.post, false) : [""];
  2012. var N;
  2013. if (isSequence) {
  2014. var x = numeric(n[0]);
  2015. var y = numeric(n[1]);
  2016. var width = Math.max(n[0].length, n[1].length);
  2017. var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
  2018. var test = lte;
  2019. var reverse = y < x;
  2020. if (reverse) {
  2021. incr *= -1;
  2022. test = gte;
  2023. }
  2024. var pad = n.some(isPadded);
  2025. N = [];
  2026. for (var i = x; test(i, y); i += incr) {
  2027. var c;
  2028. if (isAlphaSequence) {
  2029. c = String.fromCharCode(i);
  2030. if (c === "\\")
  2031. c = "";
  2032. } else {
  2033. c = String(i);
  2034. if (pad) {
  2035. var need = width - c.length;
  2036. if (need > 0) {
  2037. var z = new Array(need + 1).join("0");
  2038. if (i < 0)
  2039. c = "-" + z + c.slice(1);
  2040. else
  2041. c = z + c;
  2042. }
  2043. }
  2044. }
  2045. N.push(c);
  2046. }
  2047. } else {
  2048. N = concatMap(n, function(el) {
  2049. return expand(el, false);
  2050. });
  2051. }
  2052. for (var j = 0; j < N.length; j++) {
  2053. for (var k = 0; k < post.length; k++) {
  2054. var expansion = pre + N[j] + post[k];
  2055. if (!isTop || isSequence || expansion)
  2056. expansions.push(expansion);
  2057. }
  2058. }
  2059. return expansions;
  2060. }
  2061. }
  2062. });
  2063. // node_modules/minimatch/minimatch.js
  2064. var require_minimatch = __commonJS({
  2065. "node_modules/minimatch/minimatch.js"(exports, module) {
  2066. module.exports = minimatch;
  2067. minimatch.Minimatch = Minimatch;
  2068. var path10 = function() {
  2069. try {
  2070. return __require("path");
  2071. } catch (e) {
  2072. }
  2073. }() || {
  2074. sep: "/"
  2075. };
  2076. minimatch.sep = path10.sep;
  2077. var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {};
  2078. var expand = require_brace_expansion();
  2079. var plTypes = {
  2080. "!": { open: "(?:(?!(?:", close: "))[^/]*?)" },
  2081. "?": { open: "(?:", close: ")?" },
  2082. "+": { open: "(?:", close: ")+" },
  2083. "*": { open: "(?:", close: ")*" },
  2084. "@": { open: "(?:", close: ")" }
  2085. };
  2086. var qmark = "[^/]";
  2087. var star = qmark + "*?";
  2088. var twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
  2089. var twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
  2090. var reSpecials = charSet("().*{}+?[]^$\\!");
  2091. function charSet(s) {
  2092. return s.split("").reduce(function(set, c) {
  2093. set[c] = true;
  2094. return set;
  2095. }, {});
  2096. }
  2097. var slashSplit = /\/+/;
  2098. minimatch.filter = filter;
  2099. function filter(pattern, options) {
  2100. options = options || {};
  2101. return function(p, i, list) {
  2102. return minimatch(p, pattern, options);
  2103. };
  2104. }
  2105. function ext(a, b) {
  2106. b = b || {};
  2107. var t = {};
  2108. Object.keys(a).forEach(function(k) {
  2109. t[k] = a[k];
  2110. });
  2111. Object.keys(b).forEach(function(k) {
  2112. t[k] = b[k];
  2113. });
  2114. return t;
  2115. }
  2116. minimatch.defaults = function(def) {
  2117. if (!def || typeof def !== "object" || !Object.keys(def).length) {
  2118. return minimatch;
  2119. }
  2120. var orig = minimatch;
  2121. var m = function minimatch2(p, pattern, options) {
  2122. return orig(p, pattern, ext(def, options));
  2123. };
  2124. m.Minimatch = function Minimatch2(pattern, options) {
  2125. return new orig.Minimatch(pattern, ext(def, options));
  2126. };
  2127. m.Minimatch.defaults = function defaults(options) {
  2128. return orig.defaults(ext(def, options)).Minimatch;
  2129. };
  2130. m.filter = function filter2(pattern, options) {
  2131. return orig.filter(pattern, ext(def, options));
  2132. };
  2133. m.defaults = function defaults(options) {
  2134. return orig.defaults(ext(def, options));
  2135. };
  2136. m.makeRe = function makeRe2(pattern, options) {
  2137. return orig.makeRe(pattern, ext(def, options));
  2138. };
  2139. m.braceExpand = function braceExpand2(pattern, options) {
  2140. return orig.braceExpand(pattern, ext(def, options));
  2141. };
  2142. m.match = function(list, pattern, options) {
  2143. return orig.match(list, pattern, ext(def, options));
  2144. };
  2145. return m;
  2146. };
  2147. Minimatch.defaults = function(def) {
  2148. return minimatch.defaults(def).Minimatch;
  2149. };
  2150. function minimatch(p, pattern, options) {
  2151. assertValidPattern(pattern);
  2152. if (!options)
  2153. options = {};
  2154. if (!options.nocomment && pattern.charAt(0) === "#") {
  2155. return false;
  2156. }
  2157. return new Minimatch(pattern, options).match(p);
  2158. }
  2159. function Minimatch(pattern, options) {
  2160. if (!(this instanceof Minimatch)) {
  2161. return new Minimatch(pattern, options);
  2162. }
  2163. assertValidPattern(pattern);
  2164. if (!options)
  2165. options = {};
  2166. pattern = pattern.trim();
  2167. if (!options.allowWindowsEscape && path10.sep !== "/") {
  2168. pattern = pattern.split(path10.sep).join("/");
  2169. }
  2170. this.options = options;
  2171. this.set = [];
  2172. this.pattern = pattern;
  2173. this.regexp = null;
  2174. this.negate = false;
  2175. this.comment = false;
  2176. this.empty = false;
  2177. this.partial = !!options.partial;
  2178. this.make();
  2179. }
  2180. Minimatch.prototype.debug = function() {
  2181. };
  2182. Minimatch.prototype.make = make;
  2183. function make() {
  2184. var pattern = this.pattern;
  2185. var options = this.options;
  2186. if (!options.nocomment && pattern.charAt(0) === "#") {
  2187. this.comment = true;
  2188. return;
  2189. }
  2190. if (!pattern) {
  2191. this.empty = true;
  2192. return;
  2193. }
  2194. this.parseNegate();
  2195. var set = this.globSet = this.braceExpand();
  2196. if (options.debug)
  2197. this.debug = function debug() {
  2198. console.error.apply(console, arguments);
  2199. };
  2200. this.debug(this.pattern, set);
  2201. set = this.globParts = set.map(function(s) {
  2202. return s.split(slashSplit);
  2203. });
  2204. this.debug(this.pattern, set);
  2205. set = set.map(function(s, si, set2) {
  2206. return s.map(this.parse, this);
  2207. }, this);
  2208. this.debug(this.pattern, set);
  2209. set = set.filter(function(s) {
  2210. return s.indexOf(false) === -1;
  2211. });
  2212. this.debug(this.pattern, set);
  2213. this.set = set;
  2214. }
  2215. Minimatch.prototype.parseNegate = parseNegate;
  2216. function parseNegate() {
  2217. var pattern = this.pattern;
  2218. var negate = false;
  2219. var options = this.options;
  2220. var negateOffset = 0;
  2221. if (options.nonegate)
  2222. return;
  2223. for (var i = 0, l = pattern.length; i < l && pattern.charAt(i) === "!"; i++) {
  2224. negate = !negate;
  2225. negateOffset++;
  2226. }
  2227. if (negateOffset)
  2228. this.pattern = pattern.substr(negateOffset);
  2229. this.negate = negate;
  2230. }
  2231. minimatch.braceExpand = function(pattern, options) {
  2232. return braceExpand(pattern, options);
  2233. };
  2234. Minimatch.prototype.braceExpand = braceExpand;
  2235. function braceExpand(pattern, options) {
  2236. if (!options) {
  2237. if (this instanceof Minimatch) {
  2238. options = this.options;
  2239. } else {
  2240. options = {};
  2241. }
  2242. }
  2243. pattern = typeof pattern === "undefined" ? this.pattern : pattern;
  2244. assertValidPattern(pattern);
  2245. if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
  2246. return [pattern];
  2247. }
  2248. return expand(pattern);
  2249. }
  2250. var MAX_PATTERN_LENGTH = 1024 * 64;
  2251. var assertValidPattern = function(pattern) {
  2252. if (typeof pattern !== "string") {
  2253. throw new TypeError("invalid pattern");
  2254. }
  2255. if (pattern.length > MAX_PATTERN_LENGTH) {
  2256. throw new TypeError("pattern is too long");
  2257. }
  2258. };
  2259. Minimatch.prototype.parse = parse;
  2260. var SUBPARSE = {};
  2261. function parse(pattern, isSub) {
  2262. assertValidPattern(pattern);
  2263. var options = this.options;
  2264. if (pattern === "**") {
  2265. if (!options.noglobstar)
  2266. return GLOBSTAR;
  2267. else
  2268. pattern = "*";
  2269. }
  2270. if (pattern === "")
  2271. return "";
  2272. var re = "";
  2273. var hasMagic = !!options.nocase;
  2274. var escaping = false;
  2275. var patternListStack = [];
  2276. var negativeLists = [];
  2277. var stateChar;
  2278. var inClass = false;
  2279. var reClassStart = -1;
  2280. var classStart = -1;
  2281. var patternStart = pattern.charAt(0) === "." ? "" : options.dot ? "(?!(?:^|\\/)\\.{1,2}(?:$|\\/))" : "(?!\\.)";
  2282. var self = this;
  2283. function clearStateChar() {
  2284. if (stateChar) {
  2285. switch (stateChar) {
  2286. case "*":
  2287. re += star;
  2288. hasMagic = true;
  2289. break;
  2290. case "?":
  2291. re += qmark;
  2292. hasMagic = true;
  2293. break;
  2294. default:
  2295. re += "\\" + stateChar;
  2296. break;
  2297. }
  2298. self.debug("clearStateChar %j %j", stateChar, re);
  2299. stateChar = false;
  2300. }
  2301. }
  2302. for (var i = 0, len = pattern.length, c; i < len && (c = pattern.charAt(i)); i++) {
  2303. this.debug("%s %s %s %j", pattern, i, re, c);
  2304. if (escaping && reSpecials[c]) {
  2305. re += "\\" + c;
  2306. escaping = false;
  2307. continue;
  2308. }
  2309. switch (c) {
  2310. case "/": {
  2311. return false;
  2312. }
  2313. case "\\":
  2314. clearStateChar();
  2315. escaping = true;
  2316. continue;
  2317. case "?":
  2318. case "*":
  2319. case "+":
  2320. case "@":
  2321. case "!":
  2322. this.debug("%s %s %s %j <-- stateChar", pattern, i, re, c);
  2323. if (inClass) {
  2324. this.debug(" in class");
  2325. if (c === "!" && i === classStart + 1)
  2326. c = "^";
  2327. re += c;
  2328. continue;
  2329. }
  2330. self.debug("call clearStateChar %j", stateChar);
  2331. clearStateChar();
  2332. stateChar = c;
  2333. if (options.noext)
  2334. clearStateChar();
  2335. continue;
  2336. case "(":
  2337. if (inClass) {
  2338. re += "(";
  2339. continue;
  2340. }
  2341. if (!stateChar) {
  2342. re += "\\(";
  2343. continue;
  2344. }
  2345. patternListStack.push({
  2346. type: stateChar,
  2347. start: i - 1,
  2348. reStart: re.length,
  2349. open: plTypes[stateChar].open,
  2350. close: plTypes[stateChar].close
  2351. });
  2352. re += stateChar === "!" ? "(?:(?!(?:" : "(?:";
  2353. this.debug("plType %j %j", stateChar, re);
  2354. stateChar = false;
  2355. continue;
  2356. case ")":
  2357. if (inClass || !patternListStack.length) {
  2358. re += "\\)";
  2359. continue;
  2360. }
  2361. clearStateChar();
  2362. hasMagic = true;
  2363. var pl = patternListStack.pop();
  2364. re += pl.close;
  2365. if (pl.type === "!") {
  2366. negativeLists.push(pl);
  2367. }
  2368. pl.reEnd = re.length;
  2369. continue;
  2370. case "|":
  2371. if (inClass || !patternListStack.length || escaping) {
  2372. re += "\\|";
  2373. escaping = false;
  2374. continue;
  2375. }
  2376. clearStateChar();
  2377. re += "|";
  2378. continue;
  2379. case "[":
  2380. clearStateChar();
  2381. if (inClass) {
  2382. re += "\\" + c;
  2383. continue;
  2384. }
  2385. inClass = true;
  2386. classStart = i;
  2387. reClassStart = re.length;
  2388. re += c;
  2389. continue;
  2390. case "]":
  2391. if (i === classStart + 1 || !inClass) {
  2392. re += "\\" + c;
  2393. escaping = false;
  2394. continue;
  2395. }
  2396. var cs = pattern.substring(classStart + 1, i);
  2397. try {
  2398. RegExp("[" + cs + "]");
  2399. } catch (er) {
  2400. var sp = this.parse(cs, SUBPARSE);
  2401. re = re.substr(0, reClassStart) + "\\[" + sp[0] + "\\]";
  2402. hasMagic = hasMagic || sp[1];
  2403. inClass = false;
  2404. continue;
  2405. }
  2406. hasMagic = true;
  2407. inClass = false;
  2408. re += c;
  2409. continue;
  2410. default:
  2411. clearStateChar();
  2412. if (escaping) {
  2413. escaping = false;
  2414. } else if (reSpecials[c] && !(c === "^" && inClass)) {
  2415. re += "\\";
  2416. }
  2417. re += c;
  2418. }
  2419. }
  2420. if (inClass) {
  2421. cs = pattern.substr(classStart + 1);
  2422. sp = this.parse(cs, SUBPARSE);
  2423. re = re.substr(0, reClassStart) + "\\[" + sp[0];
  2424. hasMagic = hasMagic || sp[1];
  2425. }
  2426. for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
  2427. var tail = re.slice(pl.reStart + pl.open.length);
  2428. this.debug("setting tail", re, pl);
  2429. tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function(_, $1, $2) {
  2430. if (!$2) {
  2431. $2 = "\\";
  2432. }
  2433. return $1 + $1 + $2 + "|";
  2434. });
  2435. this.debug("tail=%j\n %s", tail, tail, pl, re);
  2436. var t = pl.type === "*" ? star : pl.type === "?" ? qmark : "\\" + pl.type;
  2437. hasMagic = true;
  2438. re = re.slice(0, pl.reStart) + t + "\\(" + tail;
  2439. }
  2440. clearStateChar();
  2441. if (escaping) {
  2442. re += "\\\\";
  2443. }
  2444. var addPatternStart = false;
  2445. switch (re.charAt(0)) {
  2446. case "[":
  2447. case ".":
  2448. case "(":
  2449. addPatternStart = true;
  2450. }
  2451. for (var n = negativeLists.length - 1; n > -1; n--) {
  2452. var nl = negativeLists[n];
  2453. var nlBefore = re.slice(0, nl.reStart);
  2454. var nlFirst = re.slice(nl.reStart, nl.reEnd - 8);
  2455. var nlLast = re.slice(nl.reEnd - 8, nl.reEnd);
  2456. var nlAfter = re.slice(nl.reEnd);
  2457. nlLast += nlAfter;
  2458. var openParensBefore = nlBefore.split("(").length - 1;
  2459. var cleanAfter = nlAfter;
  2460. for (i = 0; i < openParensBefore; i++) {
  2461. cleanAfter = cleanAfter.replace(/\)[+*?]?/, "");
  2462. }
  2463. nlAfter = cleanAfter;
  2464. var dollar = "";
  2465. if (nlAfter === "" && isSub !== SUBPARSE) {
  2466. dollar = "$";
  2467. }
  2468. var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast;
  2469. re = newRe;
  2470. }
  2471. if (re !== "" && hasMagic) {
  2472. re = "(?=.)" + re;
  2473. }
  2474. if (addPatternStart) {
  2475. re = patternStart + re;
  2476. }
  2477. if (isSub === SUBPARSE) {
  2478. return [re, hasMagic];
  2479. }
  2480. if (!hasMagic) {
  2481. return globUnescape(pattern);
  2482. }
  2483. var flags = options.nocase ? "i" : "";
  2484. try {
  2485. var regExp = new RegExp("^" + re + "$", flags);
  2486. } catch (er) {
  2487. return new RegExp("$.");
  2488. }
  2489. regExp._glob = pattern;
  2490. regExp._src = re;
  2491. return regExp;
  2492. }
  2493. minimatch.makeRe = function(pattern, options) {
  2494. return new Minimatch(pattern, options || {}).makeRe();
  2495. };
  2496. Minimatch.prototype.makeRe = makeRe;
  2497. function makeRe() {
  2498. if (this.regexp || this.regexp === false)
  2499. return this.regexp;
  2500. var set = this.set;
  2501. if (!set.length) {
  2502. this.regexp = false;
  2503. return this.regexp;
  2504. }
  2505. var options = this.options;
  2506. var twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot;
  2507. var flags = options.nocase ? "i" : "";
  2508. var re = set.map(function(pattern) {
  2509. return pattern.map(function(p) {
  2510. return p === GLOBSTAR ? twoStar : typeof p === "string" ? regExpEscape(p) : p._src;
  2511. }).join("\\/");
  2512. }).join("|");
  2513. re = "^(?:" + re + ")$";
  2514. if (this.negate)
  2515. re = "^(?!" + re + ").*$";
  2516. try {
  2517. this.regexp = new RegExp(re, flags);
  2518. } catch (ex) {
  2519. this.regexp = false;
  2520. }
  2521. return this.regexp;
  2522. }
  2523. minimatch.match = function(list, pattern, options) {
  2524. options = options || {};
  2525. var mm = new Minimatch(pattern, options);
  2526. list = list.filter(function(f) {
  2527. return mm.match(f);
  2528. });
  2529. if (mm.options.nonull && !list.length) {
  2530. list.push(pattern);
  2531. }
  2532. return list;
  2533. };
  2534. Minimatch.prototype.match = function match(f, partial) {
  2535. if (typeof partial === "undefined")
  2536. partial = this.partial;
  2537. this.debug("match", f, this.pattern);
  2538. if (this.comment)
  2539. return false;
  2540. if (this.empty)
  2541. return f === "";
  2542. if (f === "/" && partial)
  2543. return true;
  2544. var options = this.options;
  2545. if (path10.sep !== "/") {
  2546. f = f.split(path10.sep).join("/");
  2547. }
  2548. f = f.split(slashSplit);
  2549. this.debug(this.pattern, "split", f);
  2550. var set = this.set;
  2551. this.debug(this.pattern, "set", set);
  2552. var filename;
  2553. var i;
  2554. for (i = f.length - 1; i >= 0; i--) {
  2555. filename = f[i];
  2556. if (filename)
  2557. break;
  2558. }
  2559. for (i = 0; i < set.length; i++) {
  2560. var pattern = set[i];
  2561. var file = f;
  2562. if (options.matchBase && pattern.length === 1) {
  2563. file = [filename];
  2564. }
  2565. var hit = this.matchOne(file, pattern, partial);
  2566. if (hit) {
  2567. if (options.flipNegate)
  2568. return true;
  2569. return !this.negate;
  2570. }
  2571. }
  2572. if (options.flipNegate)
  2573. return false;
  2574. return this.negate;
  2575. };
  2576. Minimatch.prototype.matchOne = function(file, pattern, partial) {
  2577. var options = this.options;
  2578. this.debug(
  2579. "matchOne",
  2580. { "this": this, file, pattern }
  2581. );
  2582. this.debug("matchOne", file.length, pattern.length);
  2583. for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
  2584. this.debug("matchOne loop");
  2585. var p = pattern[pi];
  2586. var f = file[fi];
  2587. this.debug(pattern, p, f);
  2588. if (p === false)
  2589. return false;
  2590. if (p === GLOBSTAR) {
  2591. this.debug("GLOBSTAR", [pattern, p, f]);
  2592. var fr = fi;
  2593. var pr = pi + 1;
  2594. if (pr === pl) {
  2595. this.debug("** at the end");
  2596. for (; fi < fl; fi++) {
  2597. if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".")
  2598. return false;
  2599. }
  2600. return true;
  2601. }
  2602. while (fr < fl) {
  2603. var swallowee = file[fr];
  2604. this.debug("\nglobstar while", file, fr, pattern, pr, swallowee);
  2605. if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
  2606. this.debug("globstar found match!", fr, fl, swallowee);
  2607. return true;
  2608. } else {
  2609. if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
  2610. this.debug("dot detected!", file, fr, pattern, pr);
  2611. break;
  2612. }
  2613. this.debug("globstar swallow a segment, and continue");
  2614. fr++;
  2615. }
  2616. }
  2617. if (partial) {
  2618. this.debug("\n>>> no match, partial?", file, fr, pattern, pr);
  2619. if (fr === fl)
  2620. return true;
  2621. }
  2622. return false;
  2623. }
  2624. var hit;
  2625. if (typeof p === "string") {
  2626. hit = f === p;
  2627. this.debug("string match", p, f, hit);
  2628. } else {
  2629. hit = f.match(p);
  2630. this.debug("pattern match", p, f, hit);
  2631. }
  2632. if (!hit)
  2633. return false;
  2634. }
  2635. if (fi === fl && pi === pl) {
  2636. return true;
  2637. } else if (fi === fl) {
  2638. return partial;
  2639. } else if (pi === pl) {
  2640. return fi === fl - 1 && file[fi] === "";
  2641. }
  2642. throw new Error("wtf?");
  2643. };
  2644. function globUnescape(s) {
  2645. return s.replace(/\\(.)/g, "$1");
  2646. }
  2647. function regExpEscape(s) {
  2648. return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
  2649. }
  2650. }
  2651. });
  2652. // node_modules/inherits/inherits_browser.js
  2653. var require_inherits_browser = __commonJS({
  2654. "node_modules/inherits/inherits_browser.js"(exports, module) {
  2655. if (typeof Object.create === "function") {
  2656. module.exports = function inherits(ctor, superCtor) {
  2657. if (superCtor) {
  2658. ctor.super_ = superCtor;
  2659. ctor.prototype = Object.create(superCtor.prototype, {
  2660. constructor: {
  2661. value: ctor,
  2662. enumerable: false,
  2663. writable: true,
  2664. configurable: true
  2665. }
  2666. });
  2667. }
  2668. };
  2669. } else {
  2670. module.exports = function inherits(ctor, superCtor) {
  2671. if (superCtor) {
  2672. ctor.super_ = superCtor;
  2673. var TempCtor = function() {
  2674. };
  2675. TempCtor.prototype = superCtor.prototype;
  2676. ctor.prototype = new TempCtor();
  2677. ctor.prototype.constructor = ctor;
  2678. }
  2679. };
  2680. }
  2681. }
  2682. });
  2683. // node_modules/inherits/inherits.js
  2684. var require_inherits = __commonJS({
  2685. "node_modules/inherits/inherits.js"(exports, module) {
  2686. try {
  2687. util = __require("util");
  2688. if (typeof util.inherits !== "function")
  2689. throw "";
  2690. module.exports = util.inherits;
  2691. } catch (e) {
  2692. module.exports = require_inherits_browser();
  2693. }
  2694. var util;
  2695. }
  2696. });
  2697. // node_modules/path-is-absolute/index.js
  2698. var require_path_is_absolute = __commonJS({
  2699. "node_modules/path-is-absolute/index.js"(exports, module) {
  2700. "use strict";
  2701. function posix(path10) {
  2702. return path10.charAt(0) === "/";
  2703. }
  2704. function win32(path10) {
  2705. var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
  2706. var result = splitDeviceRe.exec(path10);
  2707. var device = result[1] || "";
  2708. var isUnc = Boolean(device && device.charAt(1) !== ":");
  2709. return Boolean(result[2] || isUnc);
  2710. }
  2711. module.exports = process.platform === "win32" ? win32 : posix;
  2712. module.exports.posix = posix;
  2713. module.exports.win32 = win32;
  2714. }
  2715. });
  2716. // node_modules/glob/common.js
  2717. var require_common = __commonJS({
  2718. "node_modules/glob/common.js"(exports) {
  2719. exports.setopts = setopts;
  2720. exports.ownProp = ownProp;
  2721. exports.makeAbs = makeAbs;
  2722. exports.finish = finish;
  2723. exports.mark = mark;
  2724. exports.isIgnored = isIgnored;
  2725. exports.childrenIgnored = childrenIgnored;
  2726. function ownProp(obj, field) {
  2727. return Object.prototype.hasOwnProperty.call(obj, field);
  2728. }
  2729. var fs6 = __require("fs");
  2730. var path10 = __require("path");
  2731. var minimatch = require_minimatch();
  2732. var isAbsolute = require_path_is_absolute();
  2733. var Minimatch = minimatch.Minimatch;
  2734. function alphasort(a, b) {
  2735. return a.localeCompare(b, "en");
  2736. }
  2737. function setupIgnores(self, options) {
  2738. self.ignore = options.ignore || [];
  2739. if (!Array.isArray(self.ignore))
  2740. self.ignore = [self.ignore];
  2741. if (self.ignore.length) {
  2742. self.ignore = self.ignore.map(ignoreMap);
  2743. }
  2744. }
  2745. function ignoreMap(pattern) {
  2746. var gmatcher = null;
  2747. if (pattern.slice(-3) === "/**") {
  2748. var gpattern = pattern.replace(/(\/\*\*)+$/, "");
  2749. gmatcher = new Minimatch(gpattern, { dot: true });
  2750. }
  2751. return {
  2752. matcher: new Minimatch(pattern, { dot: true }),
  2753. gmatcher
  2754. };
  2755. }
  2756. function setopts(self, pattern, options) {
  2757. if (!options)
  2758. options = {};
  2759. if (options.matchBase && -1 === pattern.indexOf("/")) {
  2760. if (options.noglobstar) {
  2761. throw new Error("base matching requires globstar");
  2762. }
  2763. pattern = "**/" + pattern;
  2764. }
  2765. self.silent = !!options.silent;
  2766. self.pattern = pattern;
  2767. self.strict = options.strict !== false;
  2768. self.realpath = !!options.realpath;
  2769. self.realpathCache = options.realpathCache || /* @__PURE__ */ Object.create(null);
  2770. self.follow = !!options.follow;
  2771. self.dot = !!options.dot;
  2772. self.mark = !!options.mark;
  2773. self.nodir = !!options.nodir;
  2774. if (self.nodir)
  2775. self.mark = true;
  2776. self.sync = !!options.sync;
  2777. self.nounique = !!options.nounique;
  2778. self.nonull = !!options.nonull;
  2779. self.nosort = !!options.nosort;
  2780. self.nocase = !!options.nocase;
  2781. self.stat = !!options.stat;
  2782. self.noprocess = !!options.noprocess;
  2783. self.absolute = !!options.absolute;
  2784. self.fs = options.fs || fs6;
  2785. self.maxLength = options.maxLength || Infinity;
  2786. self.cache = options.cache || /* @__PURE__ */ Object.create(null);
  2787. self.statCache = options.statCache || /* @__PURE__ */ Object.create(null);
  2788. self.symlinks = options.symlinks || /* @__PURE__ */ Object.create(null);
  2789. setupIgnores(self, options);
  2790. self.changedCwd = false;
  2791. var cwd2 = process.cwd();
  2792. if (!ownProp(options, "cwd"))
  2793. self.cwd = cwd2;
  2794. else {
  2795. self.cwd = path10.resolve(options.cwd);
  2796. self.changedCwd = self.cwd !== cwd2;
  2797. }
  2798. self.root = options.root || path10.resolve(self.cwd, "/");
  2799. self.root = path10.resolve(self.root);
  2800. if (process.platform === "win32")
  2801. self.root = self.root.replace(/\\/g, "/");
  2802. self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd);
  2803. if (process.platform === "win32")
  2804. self.cwdAbs = self.cwdAbs.replace(/\\/g, "/");
  2805. self.nomount = !!options.nomount;
  2806. options.nonegate = true;
  2807. options.nocomment = true;
  2808. options.allowWindowsEscape = false;
  2809. self.minimatch = new Minimatch(pattern, options);
  2810. self.options = self.minimatch.options;
  2811. }
  2812. function finish(self) {
  2813. var nou = self.nounique;
  2814. var all = nou ? [] : /* @__PURE__ */ Object.create(null);
  2815. for (var i = 0, l = self.matches.length; i < l; i++) {
  2816. var matches = self.matches[i];
  2817. if (!matches || Object.keys(matches).length === 0) {
  2818. if (self.nonull) {
  2819. var literal = self.minimatch.globSet[i];
  2820. if (nou)
  2821. all.push(literal);
  2822. else
  2823. all[literal] = true;
  2824. }
  2825. } else {
  2826. var m = Object.keys(matches);
  2827. if (nou)
  2828. all.push.apply(all, m);
  2829. else
  2830. m.forEach(function(m2) {
  2831. all[m2] = true;
  2832. });
  2833. }
  2834. }
  2835. if (!nou)
  2836. all = Object.keys(all);
  2837. if (!self.nosort)
  2838. all = all.sort(alphasort);
  2839. if (self.mark) {
  2840. for (var i = 0; i < all.length; i++) {
  2841. all[i] = self._mark(all[i]);
  2842. }
  2843. if (self.nodir) {
  2844. all = all.filter(function(e) {
  2845. var notDir = !/\/$/.test(e);
  2846. var c = self.cache[e] || self.cache[makeAbs(self, e)];
  2847. if (notDir && c)
  2848. notDir = c !== "DIR" && !Array.isArray(c);
  2849. return notDir;
  2850. });
  2851. }
  2852. }
  2853. if (self.ignore.length)
  2854. all = all.filter(function(m2) {
  2855. return !isIgnored(self, m2);
  2856. });
  2857. self.found = all;
  2858. }
  2859. function mark(self, p) {
  2860. var abs = makeAbs(self, p);
  2861. var c = self.cache[abs];
  2862. var m = p;
  2863. if (c) {
  2864. var isDir = c === "DIR" || Array.isArray(c);
  2865. var slash = p.slice(-1) === "/";
  2866. if (isDir && !slash)
  2867. m += "/";
  2868. else if (!isDir && slash)
  2869. m = m.slice(0, -1);
  2870. if (m !== p) {
  2871. var mabs = makeAbs(self, m);
  2872. self.statCache[mabs] = self.statCache[abs];
  2873. self.cache[mabs] = self.cache[abs];
  2874. }
  2875. }
  2876. return m;
  2877. }
  2878. function makeAbs(self, f) {
  2879. var abs = f;
  2880. if (f.charAt(0) === "/") {
  2881. abs = path10.join(self.root, f);
  2882. } else if (isAbsolute(f) || f === "") {
  2883. abs = f;
  2884. } else if (self.changedCwd) {
  2885. abs = path10.resolve(self.cwd, f);
  2886. } else {
  2887. abs = path10.resolve(f);
  2888. }
  2889. if (process.platform === "win32")
  2890. abs = abs.replace(/\\/g, "/");
  2891. return abs;
  2892. }
  2893. function isIgnored(self, path11) {
  2894. if (!self.ignore.length)
  2895. return false;
  2896. return self.ignore.some(function(item) {
  2897. return item.matcher.match(path11) || !!(item.gmatcher && item.gmatcher.match(path11));
  2898. });
  2899. }
  2900. function childrenIgnored(self, path11) {
  2901. if (!self.ignore.length)
  2902. return false;
  2903. return self.ignore.some(function(item) {
  2904. return !!(item.gmatcher && item.gmatcher.match(path11));
  2905. });
  2906. }
  2907. }
  2908. });
  2909. // node_modules/glob/sync.js
  2910. var require_sync = __commonJS({
  2911. "node_modules/glob/sync.js"(exports, module) {
  2912. module.exports = globSync;
  2913. globSync.GlobSync = GlobSync;
  2914. var rp = require_fs();
  2915. var minimatch = require_minimatch();
  2916. var Minimatch = minimatch.Minimatch;
  2917. var Glob = require_glob().Glob;
  2918. var util = __require("util");
  2919. var path10 = __require("path");
  2920. var assert = __require("assert");
  2921. var isAbsolute = require_path_is_absolute();
  2922. var common = require_common();
  2923. var setopts = common.setopts;
  2924. var ownProp = common.ownProp;
  2925. var childrenIgnored = common.childrenIgnored;
  2926. var isIgnored = common.isIgnored;
  2927. function globSync(pattern, options) {
  2928. if (typeof options === "function" || arguments.length === 3)
  2929. throw new TypeError("callback provided to sync glob\nSee: https://github.com/isaacs/node-glob/issues/167");
  2930. return new GlobSync(pattern, options).found;
  2931. }
  2932. function GlobSync(pattern, options) {
  2933. if (!pattern)
  2934. throw new Error("must provide pattern");
  2935. if (typeof options === "function" || arguments.length === 3)
  2936. throw new TypeError("callback provided to sync glob\nSee: https://github.com/isaacs/node-glob/issues/167");
  2937. if (!(this instanceof GlobSync))
  2938. return new GlobSync(pattern, options);
  2939. setopts(this, pattern, options);
  2940. if (this.noprocess)
  2941. return this;
  2942. var n = this.minimatch.set.length;
  2943. this.matches = new Array(n);
  2944. for (var i = 0; i < n; i++) {
  2945. this._process(this.minimatch.set[i], i, false);
  2946. }
  2947. this._finish();
  2948. }
  2949. GlobSync.prototype._finish = function() {
  2950. assert.ok(this instanceof GlobSync);
  2951. if (this.realpath) {
  2952. var self = this;
  2953. this.matches.forEach(function(matchset, index) {
  2954. var set = self.matches[index] = /* @__PURE__ */ Object.create(null);
  2955. for (var p in matchset) {
  2956. try {
  2957. p = self._makeAbs(p);
  2958. var real = rp.realpathSync(p, self.realpathCache);
  2959. set[real] = true;
  2960. } catch (er) {
  2961. if (er.syscall === "stat")
  2962. set[self._makeAbs(p)] = true;
  2963. else
  2964. throw er;
  2965. }
  2966. }
  2967. });
  2968. }
  2969. common.finish(this);
  2970. };
  2971. GlobSync.prototype._process = function(pattern, index, inGlobStar) {
  2972. assert.ok(this instanceof GlobSync);
  2973. var n = 0;
  2974. while (typeof pattern[n] === "string") {
  2975. n++;
  2976. }
  2977. var prefix;
  2978. switch (n) {
  2979. case pattern.length:
  2980. this._processSimple(pattern.join("/"), index);
  2981. return;
  2982. case 0:
  2983. prefix = null;
  2984. break;
  2985. default:
  2986. prefix = pattern.slice(0, n).join("/");
  2987. break;
  2988. }
  2989. var remain = pattern.slice(n);
  2990. var read;
  2991. if (prefix === null)
  2992. read = ".";
  2993. else if (isAbsolute(prefix) || isAbsolute(pattern.map(function(p) {
  2994. return typeof p === "string" ? p : "[*]";
  2995. }).join("/"))) {
  2996. if (!prefix || !isAbsolute(prefix))
  2997. prefix = "/" + prefix;
  2998. read = prefix;
  2999. } else
  3000. read = prefix;
  3001. var abs = this._makeAbs(read);
  3002. if (childrenIgnored(this, read))
  3003. return;
  3004. var isGlobStar = remain[0] === minimatch.GLOBSTAR;
  3005. if (isGlobStar)
  3006. this._processGlobStar(prefix, read, abs, remain, index, inGlobStar);
  3007. else
  3008. this._processReaddir(prefix, read, abs, remain, index, inGlobStar);
  3009. };
  3010. GlobSync.prototype._processReaddir = function(prefix, read, abs, remain, index, inGlobStar) {
  3011. var entries = this._readdir(abs, inGlobStar);
  3012. if (!entries)
  3013. return;
  3014. var pn = remain[0];
  3015. var negate = !!this.minimatch.negate;
  3016. var rawGlob = pn._glob;
  3017. var dotOk = this.dot || rawGlob.charAt(0) === ".";
  3018. var matchedEntries = [];
  3019. for (var i = 0; i < entries.length; i++) {
  3020. var e = entries[i];
  3021. if (e.charAt(0) !== "." || dotOk) {
  3022. var m;
  3023. if (negate && !prefix) {
  3024. m = !e.match(pn);
  3025. } else {
  3026. m = e.match(pn);
  3027. }
  3028. if (m)
  3029. matchedEntries.push(e);
  3030. }
  3031. }
  3032. var len = matchedEntries.length;
  3033. if (len === 0)
  3034. return;
  3035. if (remain.length === 1 && !this.mark && !this.stat) {
  3036. if (!this.matches[index])
  3037. this.matches[index] = /* @__PURE__ */ Object.create(null);
  3038. for (var i = 0; i < len; i++) {
  3039. var e = matchedEntries[i];
  3040. if (prefix) {
  3041. if (prefix.slice(-1) !== "/")
  3042. e = prefix + "/" + e;
  3043. else
  3044. e = prefix + e;
  3045. }
  3046. if (e.charAt(0) === "/" && !this.nomount) {
  3047. e = path10.join(this.root, e);
  3048. }
  3049. this._emitMatch(index, e);
  3050. }
  3051. return;
  3052. }
  3053. remain.shift();
  3054. for (var i = 0; i < len; i++) {
  3055. var e = matchedEntries[i];
  3056. var newPattern;
  3057. if (prefix)
  3058. newPattern = [prefix, e];
  3059. else
  3060. newPattern = [e];
  3061. this._process(newPattern.concat(remain), index, inGlobStar);
  3062. }
  3063. };
  3064. GlobSync.prototype._emitMatch = function(index, e) {
  3065. if (isIgnored(this, e))
  3066. return;
  3067. var abs = this._makeAbs(e);
  3068. if (this.mark)
  3069. e = this._mark(e);
  3070. if (this.absolute) {
  3071. e = abs;
  3072. }
  3073. if (this.matches[index][e])
  3074. return;
  3075. if (this.nodir) {
  3076. var c = this.cache[abs];
  3077. if (c === "DIR" || Array.isArray(c))
  3078. return;
  3079. }
  3080. this.matches[index][e] = true;
  3081. if (this.stat)
  3082. this._stat(e);
  3083. };
  3084. GlobSync.prototype._readdirInGlobStar = function(abs) {
  3085. if (this.follow)
  3086. return this._readdir(abs, false);
  3087. var entries;
  3088. var lstat;
  3089. var stat;
  3090. try {
  3091. lstat = this.fs.lstatSync(abs);
  3092. } catch (er) {
  3093. if (er.code === "ENOENT") {
  3094. return null;
  3095. }
  3096. }
  3097. var isSym = lstat && lstat.isSymbolicLink();
  3098. this.symlinks[abs] = isSym;
  3099. if (!isSym && lstat && !lstat.isDirectory())
  3100. this.cache[abs] = "FILE";
  3101. else
  3102. entries = this._readdir(abs, false);
  3103. return entries;
  3104. };
  3105. GlobSync.prototype._readdir = function(abs, inGlobStar) {
  3106. var entries;
  3107. if (inGlobStar && !ownProp(this.symlinks, abs))
  3108. return this._readdirInGlobStar(abs);
  3109. if (ownProp(this.cache, abs)) {
  3110. var c = this.cache[abs];
  3111. if (!c || c === "FILE")
  3112. return null;
  3113. if (Array.isArray(c))
  3114. return c;
  3115. }
  3116. try {
  3117. return this._readdirEntries(abs, this.fs.readdirSync(abs));
  3118. } catch (er) {
  3119. this._readdirError(abs, er);
  3120. return null;
  3121. }
  3122. };
  3123. GlobSync.prototype._readdirEntries = function(abs, entries) {
  3124. if (!this.mark && !this.stat) {
  3125. for (var i = 0; i < entries.length; i++) {
  3126. var e = entries[i];
  3127. if (abs === "/")
  3128. e = abs + e;
  3129. else
  3130. e = abs + "/" + e;
  3131. this.cache[e] = true;
  3132. }
  3133. }
  3134. this.cache[abs] = entries;
  3135. return entries;
  3136. };
  3137. GlobSync.prototype._readdirError = function(f, er) {
  3138. switch (er.code) {
  3139. case "ENOTSUP":
  3140. case "ENOTDIR":
  3141. var abs = this._makeAbs(f);
  3142. this.cache[abs] = "FILE";
  3143. if (abs === this.cwdAbs) {
  3144. var error = new Error(er.code + " invalid cwd " + this.cwd);
  3145. error.path = this.cwd;
  3146. error.code = er.code;
  3147. throw error;
  3148. }
  3149. break;
  3150. case "ENOENT":
  3151. case "ELOOP":
  3152. case "ENAMETOOLONG":
  3153. case "UNKNOWN":
  3154. this.cache[this._makeAbs(f)] = false;
  3155. break;
  3156. default:
  3157. this.cache[this._makeAbs(f)] = false;
  3158. if (this.strict)
  3159. throw er;
  3160. if (!this.silent)
  3161. console.error("glob error", er);
  3162. break;
  3163. }
  3164. };
  3165. GlobSync.prototype._processGlobStar = function(prefix, read, abs, remain, index, inGlobStar) {
  3166. var entries = this._readdir(abs, inGlobStar);
  3167. if (!entries)
  3168. return;
  3169. var remainWithoutGlobStar = remain.slice(1);
  3170. var gspref = prefix ? [prefix] : [];
  3171. var noGlobStar = gspref.concat(remainWithoutGlobStar);
  3172. this._process(noGlobStar, index, false);
  3173. var len = entries.length;
  3174. var isSym = this.symlinks[abs];
  3175. if (isSym && inGlobStar)
  3176. return;
  3177. for (var i = 0; i < len; i++) {
  3178. var e = entries[i];
  3179. if (e.charAt(0) === "." && !this.dot)
  3180. continue;
  3181. var instead = gspref.concat(entries[i], remainWithoutGlobStar);
  3182. this._process(instead, index, true);
  3183. var below = gspref.concat(entries[i], remain);
  3184. this._process(below, index, true);
  3185. }
  3186. };
  3187. GlobSync.prototype._processSimple = function(prefix, index) {
  3188. var exists = this._stat(prefix);
  3189. if (!this.matches[index])
  3190. this.matches[index] = /* @__PURE__ */ Object.create(null);
  3191. if (!exists)
  3192. return;
  3193. if (prefix && isAbsolute(prefix) && !this.nomount) {
  3194. var trail = /[\/\\]$/.test(prefix);
  3195. if (prefix.charAt(0) === "/") {
  3196. prefix = path10.join(this.root, prefix);
  3197. } else {
  3198. prefix = path10.resolve(this.root, prefix);
  3199. if (trail)
  3200. prefix += "/";
  3201. }
  3202. }
  3203. if (process.platform === "win32")
  3204. prefix = prefix.replace(/\\/g, "/");
  3205. this._emitMatch(index, prefix);
  3206. };
  3207. GlobSync.prototype._stat = function(f) {
  3208. var abs = this._makeAbs(f);
  3209. var needDir = f.slice(-1) === "/";
  3210. if (f.length > this.maxLength)
  3211. return false;
  3212. if (!this.stat && ownProp(this.cache, abs)) {
  3213. var c = this.cache[abs];
  3214. if (Array.isArray(c))
  3215. c = "DIR";
  3216. if (!needDir || c === "DIR")
  3217. return c;
  3218. if (needDir && c === "FILE")
  3219. return false;
  3220. }
  3221. var exists;
  3222. var stat = this.statCache[abs];
  3223. if (!stat) {
  3224. var lstat;
  3225. try {
  3226. lstat = this.fs.lstatSync(abs);
  3227. } catch (er) {
  3228. if (er && (er.code === "ENOENT" || er.code === "ENOTDIR")) {
  3229. this.statCache[abs] = false;
  3230. return false;
  3231. }
  3232. }
  3233. if (lstat && lstat.isSymbolicLink()) {
  3234. try {
  3235. stat = this.fs.statSync(abs);
  3236. } catch (er) {
  3237. stat = lstat;
  3238. }
  3239. } else {
  3240. stat = lstat;
  3241. }
  3242. }
  3243. this.statCache[abs] = stat;
  3244. var c = true;
  3245. if (stat)
  3246. c = stat.isDirectory() ? "DIR" : "FILE";
  3247. this.cache[abs] = this.cache[abs] || c;
  3248. if (needDir && c === "FILE")
  3249. return false;
  3250. return c;
  3251. };
  3252. GlobSync.prototype._mark = function(p) {
  3253. return common.mark(this, p);
  3254. };
  3255. GlobSync.prototype._makeAbs = function(f) {
  3256. return common.makeAbs(this, f);
  3257. };
  3258. }
  3259. });
  3260. // node_modules/wrappy/wrappy.js
  3261. var require_wrappy = __commonJS({
  3262. "node_modules/wrappy/wrappy.js"(exports, module) {
  3263. module.exports = wrappy;
  3264. function wrappy(fn, cb) {
  3265. if (fn && cb)
  3266. return wrappy(fn)(cb);
  3267. if (typeof fn !== "function")
  3268. throw new TypeError("need wrapper function");
  3269. Object.keys(fn).forEach(function(k) {
  3270. wrapper[k] = fn[k];
  3271. });
  3272. return wrapper;
  3273. function wrapper() {
  3274. var args = new Array(arguments.length);
  3275. for (var i = 0; i < args.length; i++) {
  3276. args[i] = arguments[i];
  3277. }
  3278. var ret = fn.apply(this, args);
  3279. var cb2 = args[args.length - 1];
  3280. if (typeof ret === "function" && ret !== cb2) {
  3281. Object.keys(cb2).forEach(function(k) {
  3282. ret[k] = cb2[k];
  3283. });
  3284. }
  3285. return ret;
  3286. }
  3287. }
  3288. }
  3289. });
  3290. // node_modules/once/once.js
  3291. var require_once = __commonJS({
  3292. "node_modules/once/once.js"(exports, module) {
  3293. var wrappy = require_wrappy();
  3294. module.exports = wrappy(once);
  3295. module.exports.strict = wrappy(onceStrict);
  3296. once.proto = once(function() {
  3297. Object.defineProperty(Function.prototype, "once", {
  3298. value: function() {
  3299. return once(this);
  3300. },
  3301. configurable: true
  3302. });
  3303. Object.defineProperty(Function.prototype, "onceStrict", {
  3304. value: function() {
  3305. return onceStrict(this);
  3306. },
  3307. configurable: true
  3308. });
  3309. });
  3310. function once(fn) {
  3311. var f = function() {
  3312. if (f.called)
  3313. return f.value;
  3314. f.called = true;
  3315. return f.value = fn.apply(this, arguments);
  3316. };
  3317. f.called = false;
  3318. return f;
  3319. }
  3320. function onceStrict(fn) {
  3321. var f = function() {
  3322. if (f.called)
  3323. throw new Error(f.onceError);
  3324. f.called = true;
  3325. return f.value = fn.apply(this, arguments);
  3326. };
  3327. var name = fn.name || "Function wrapped with `once`";
  3328. f.onceError = name + " shouldn't be called more than once";
  3329. f.called = false;
  3330. return f;
  3331. }
  3332. }
  3333. });
  3334. // node_modules/inflight/inflight.js
  3335. var require_inflight = __commonJS({
  3336. "node_modules/inflight/inflight.js"(exports, module) {
  3337. var wrappy = require_wrappy();
  3338. var reqs = /* @__PURE__ */ Object.create(null);
  3339. var once = require_once();
  3340. module.exports = wrappy(inflight);
  3341. function inflight(key, cb) {
  3342. if (reqs[key]) {
  3343. reqs[key].push(cb);
  3344. return null;
  3345. } else {
  3346. reqs[key] = [cb];
  3347. return makeres(key);
  3348. }
  3349. }
  3350. function makeres(key) {
  3351. return once(function RES() {
  3352. var cbs = reqs[key];
  3353. var len = cbs.length;
  3354. var args = slice(arguments);
  3355. try {
  3356. for (var i = 0; i < len; i++) {
  3357. cbs[i].apply(null, args);
  3358. }
  3359. } finally {
  3360. if (cbs.length > len) {
  3361. cbs.splice(0, len);
  3362. process.nextTick(function() {
  3363. RES.apply(null, args);
  3364. });
  3365. } else {
  3366. delete reqs[key];
  3367. }
  3368. }
  3369. });
  3370. }
  3371. function slice(args) {
  3372. var length = args.length;
  3373. var array2 = [];
  3374. for (var i = 0; i < length; i++)
  3375. array2[i] = args[i];
  3376. return array2;
  3377. }
  3378. }
  3379. });
  3380. // node_modules/glob/glob.js
  3381. var require_glob = __commonJS({
  3382. "node_modules/glob/glob.js"(exports, module) {
  3383. module.exports = glob;
  3384. var rp = require_fs();
  3385. var minimatch = require_minimatch();
  3386. var Minimatch = minimatch.Minimatch;
  3387. var inherits = require_inherits();
  3388. var EE = __require("events").EventEmitter;
  3389. var path10 = __require("path");
  3390. var assert = __require("assert");
  3391. var isAbsolute = require_path_is_absolute();
  3392. var globSync = require_sync();
  3393. var common = require_common();
  3394. var setopts = common.setopts;
  3395. var ownProp = common.ownProp;
  3396. var inflight = require_inflight();
  3397. var util = __require("util");
  3398. var childrenIgnored = common.childrenIgnored;
  3399. var isIgnored = common.isIgnored;
  3400. var once = require_once();
  3401. function glob(pattern, options, cb) {
  3402. if (typeof options === "function")
  3403. cb = options, options = {};
  3404. if (!options)
  3405. options = {};
  3406. if (options.sync) {
  3407. if (cb)
  3408. throw new TypeError("callback provided to sync glob");
  3409. return globSync(pattern, options);
  3410. }
  3411. return new Glob(pattern, options, cb);
  3412. }
  3413. glob.sync = globSync;
  3414. var GlobSync = glob.GlobSync = globSync.GlobSync;
  3415. glob.glob = glob;
  3416. function extend(origin, add) {
  3417. if (add === null || typeof add !== "object") {
  3418. return origin;
  3419. }
  3420. var keys = Object.keys(add);
  3421. var i = keys.length;
  3422. while (i--) {
  3423. origin[keys[i]] = add[keys[i]];
  3424. }
  3425. return origin;
  3426. }
  3427. glob.hasMagic = function(pattern, options_) {
  3428. var options = extend({}, options_);
  3429. options.noprocess = true;
  3430. var g = new Glob(pattern, options);
  3431. var set = g.minimatch.set;
  3432. if (!pattern)
  3433. return false;
  3434. if (set.length > 1)
  3435. return true;
  3436. for (var j = 0; j < set[0].length; j++) {
  3437. if (typeof set[0][j] !== "string")
  3438. return true;
  3439. }
  3440. return false;
  3441. };
  3442. glob.Glob = Glob;
  3443. inherits(Glob, EE);
  3444. function Glob(pattern, options, cb) {
  3445. if (typeof options === "function") {
  3446. cb = options;
  3447. options = null;
  3448. }
  3449. if (options && options.sync) {
  3450. if (cb)
  3451. throw new TypeError("callback provided to sync glob");
  3452. return new GlobSync(pattern, options);
  3453. }
  3454. if (!(this instanceof Glob))
  3455. return new Glob(pattern, options, cb);
  3456. setopts(this, pattern, options);
  3457. this._didRealPath = false;
  3458. var n = this.minimatch.set.length;
  3459. this.matches = new Array(n);
  3460. if (typeof cb === "function") {
  3461. cb = once(cb);
  3462. this.on("error", cb);
  3463. this.on("end", function(matches) {
  3464. cb(null, matches);
  3465. });
  3466. }
  3467. var self = this;
  3468. this._processing = 0;
  3469. this._emitQueue = [];
  3470. this._processQueue = [];
  3471. this.paused = false;
  3472. if (this.noprocess)
  3473. return this;
  3474. if (n === 0)
  3475. return done();
  3476. var sync = true;
  3477. for (var i = 0; i < n; i++) {
  3478. this._process(this.minimatch.set[i], i, false, done);
  3479. }
  3480. sync = false;
  3481. function done() {
  3482. --self._processing;
  3483. if (self._processing <= 0) {
  3484. if (sync) {
  3485. process.nextTick(function() {
  3486. self._finish();
  3487. });
  3488. } else {
  3489. self._finish();
  3490. }
  3491. }
  3492. }
  3493. }
  3494. Glob.prototype._finish = function() {
  3495. assert(this instanceof Glob);
  3496. if (this.aborted)
  3497. return;
  3498. if (this.realpath && !this._didRealpath)
  3499. return this._realpath();
  3500. common.finish(this);
  3501. this.emit("end", this.found);
  3502. };
  3503. Glob.prototype._realpath = function() {
  3504. if (this._didRealpath)
  3505. return;
  3506. this._didRealpath = true;
  3507. var n = this.matches.length;
  3508. if (n === 0)
  3509. return this._finish();
  3510. var self = this;
  3511. for (var i = 0; i < this.matches.length; i++)
  3512. this._realpathSet(i, next);
  3513. function next() {
  3514. if (--n === 0)
  3515. self._finish();
  3516. }
  3517. };
  3518. Glob.prototype._realpathSet = function(index, cb) {
  3519. var matchset = this.matches[index];
  3520. if (!matchset)
  3521. return cb();
  3522. var found = Object.keys(matchset);
  3523. var self = this;
  3524. var n = found.length;
  3525. if (n === 0)
  3526. return cb();
  3527. var set = this.matches[index] = /* @__PURE__ */ Object.create(null);
  3528. found.forEach(function(p, i) {
  3529. p = self._makeAbs(p);
  3530. rp.realpath(p, self.realpathCache, function(er, real) {
  3531. if (!er)
  3532. set[real] = true;
  3533. else if (er.syscall === "stat")
  3534. set[p] = true;
  3535. else
  3536. self.emit("error", er);
  3537. if (--n === 0) {
  3538. self.matches[index] = set;
  3539. cb();
  3540. }
  3541. });
  3542. });
  3543. };
  3544. Glob.prototype._mark = function(p) {
  3545. return common.mark(this, p);
  3546. };
  3547. Glob.prototype._makeAbs = function(f) {
  3548. return common.makeAbs(this, f);
  3549. };
  3550. Glob.prototype.abort = function() {
  3551. this.aborted = true;
  3552. this.emit("abort");
  3553. };
  3554. Glob.prototype.pause = function() {
  3555. if (!this.paused) {
  3556. this.paused = true;
  3557. this.emit("pause");
  3558. }
  3559. };
  3560. Glob.prototype.resume = function() {
  3561. if (this.paused) {
  3562. this.emit("resume");
  3563. this.paused = false;
  3564. if (this._emitQueue.length) {
  3565. var eq = this._emitQueue.slice(0);
  3566. this._emitQueue.length = 0;
  3567. for (var i = 0; i < eq.length; i++) {
  3568. var e = eq[i];
  3569. this._emitMatch(e[0], e[1]);
  3570. }
  3571. }
  3572. if (this._processQueue.length) {
  3573. var pq = this._processQueue.slice(0);
  3574. this._processQueue.length = 0;
  3575. for (var i = 0; i < pq.length; i++) {
  3576. var p = pq[i];
  3577. this._processing--;
  3578. this._process(p[0], p[1], p[2], p[3]);
  3579. }
  3580. }
  3581. }
  3582. };
  3583. Glob.prototype._process = function(pattern, index, inGlobStar, cb) {
  3584. assert(this instanceof Glob);
  3585. assert(typeof cb === "function");
  3586. if (this.aborted)
  3587. return;
  3588. this._processing++;
  3589. if (this.paused) {
  3590. this._processQueue.push([pattern, index, inGlobStar, cb]);
  3591. return;
  3592. }
  3593. var n = 0;
  3594. while (typeof pattern[n] === "string") {
  3595. n++;
  3596. }
  3597. var prefix;
  3598. switch (n) {
  3599. case pattern.length:
  3600. this._processSimple(pattern.join("/"), index, cb);
  3601. return;
  3602. case 0:
  3603. prefix = null;
  3604. break;
  3605. default:
  3606. prefix = pattern.slice(0, n).join("/");
  3607. break;
  3608. }
  3609. var remain = pattern.slice(n);
  3610. var read;
  3611. if (prefix === null)
  3612. read = ".";
  3613. else if (isAbsolute(prefix) || isAbsolute(pattern.map(function(p) {
  3614. return typeof p === "string" ? p : "[*]";
  3615. }).join("/"))) {
  3616. if (!prefix || !isAbsolute(prefix))
  3617. prefix = "/" + prefix;
  3618. read = prefix;
  3619. } else
  3620. read = prefix;
  3621. var abs = this._makeAbs(read);
  3622. if (childrenIgnored(this, read))
  3623. return cb();
  3624. var isGlobStar = remain[0] === minimatch.GLOBSTAR;
  3625. if (isGlobStar)
  3626. this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb);
  3627. else
  3628. this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb);
  3629. };
  3630. Glob.prototype._processReaddir = function(prefix, read, abs, remain, index, inGlobStar, cb) {
  3631. var self = this;
  3632. this._readdir(abs, inGlobStar, function(er, entries) {
  3633. return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb);
  3634. });
  3635. };
  3636. Glob.prototype._processReaddir2 = function(prefix, read, abs, remain, index, inGlobStar, entries, cb) {
  3637. if (!entries)
  3638. return cb();
  3639. var pn = remain[0];
  3640. var negate = !!this.minimatch.negate;
  3641. var rawGlob = pn._glob;
  3642. var dotOk = this.dot || rawGlob.charAt(0) === ".";
  3643. var matchedEntries = [];
  3644. for (var i = 0; i < entries.length; i++) {
  3645. var e = entries[i];
  3646. if (e.charAt(0) !== "." || dotOk) {
  3647. var m;
  3648. if (negate && !prefix) {
  3649. m = !e.match(pn);
  3650. } else {
  3651. m = e.match(pn);
  3652. }
  3653. if (m)
  3654. matchedEntries.push(e);
  3655. }
  3656. }
  3657. var len = matchedEntries.length;
  3658. if (len === 0)
  3659. return cb();
  3660. if (remain.length === 1 && !this.mark && !this.stat) {
  3661. if (!this.matches[index])
  3662. this.matches[index] = /* @__PURE__ */ Object.create(null);
  3663. for (var i = 0; i < len; i++) {
  3664. var e = matchedEntries[i];
  3665. if (prefix) {
  3666. if (prefix !== "/")
  3667. e = prefix + "/" + e;
  3668. else
  3669. e = prefix + e;
  3670. }
  3671. if (e.charAt(0) === "/" && !this.nomount) {
  3672. e = path10.join(this.root, e);
  3673. }
  3674. this._emitMatch(index, e);
  3675. }
  3676. return cb();
  3677. }
  3678. remain.shift();
  3679. for (var i = 0; i < len; i++) {
  3680. var e = matchedEntries[i];
  3681. var newPattern;
  3682. if (prefix) {
  3683. if (prefix !== "/")
  3684. e = prefix + "/" + e;
  3685. else
  3686. e = prefix + e;
  3687. }
  3688. this._process([e].concat(remain), index, inGlobStar, cb);
  3689. }
  3690. cb();
  3691. };
  3692. Glob.prototype._emitMatch = function(index, e) {
  3693. if (this.aborted)
  3694. return;
  3695. if (isIgnored(this, e))
  3696. return;
  3697. if (this.paused) {
  3698. this._emitQueue.push([index, e]);
  3699. return;
  3700. }
  3701. var abs = isAbsolute(e) ? e : this._makeAbs(e);
  3702. if (this.mark)
  3703. e = this._mark(e);
  3704. if (this.absolute)
  3705. e = abs;
  3706. if (this.matches[index][e])
  3707. return;
  3708. if (this.nodir) {
  3709. var c = this.cache[abs];
  3710. if (c === "DIR" || Array.isArray(c))
  3711. return;
  3712. }
  3713. this.matches[index][e] = true;
  3714. var st = this.statCache[abs];
  3715. if (st)
  3716. this.emit("stat", e, st);
  3717. this.emit("match", e);
  3718. };
  3719. Glob.prototype._readdirInGlobStar = function(abs, cb) {
  3720. if (this.aborted)
  3721. return;
  3722. if (this.follow)
  3723. return this._readdir(abs, false, cb);
  3724. var lstatkey = "lstat\0" + abs;
  3725. var self = this;
  3726. var lstatcb = inflight(lstatkey, lstatcb_);
  3727. if (lstatcb)
  3728. self.fs.lstat(abs, lstatcb);
  3729. function lstatcb_(er, lstat) {
  3730. if (er && er.code === "ENOENT")
  3731. return cb();
  3732. var isSym = lstat && lstat.isSymbolicLink();
  3733. self.symlinks[abs] = isSym;
  3734. if (!isSym && lstat && !lstat.isDirectory()) {
  3735. self.cache[abs] = "FILE";
  3736. cb();
  3737. } else
  3738. self._readdir(abs, false, cb);
  3739. }
  3740. };
  3741. Glob.prototype._readdir = function(abs, inGlobStar, cb) {
  3742. if (this.aborted)
  3743. return;
  3744. cb = inflight("readdir\0" + abs + "\0" + inGlobStar, cb);
  3745. if (!cb)
  3746. return;
  3747. if (inGlobStar && !ownProp(this.symlinks, abs))
  3748. return this._readdirInGlobStar(abs, cb);
  3749. if (ownProp(this.cache, abs)) {
  3750. var c = this.cache[abs];
  3751. if (!c || c === "FILE")
  3752. return cb();
  3753. if (Array.isArray(c))
  3754. return cb(null, c);
  3755. }
  3756. var self = this;
  3757. self.fs.readdir(abs, readdirCb(this, abs, cb));
  3758. };
  3759. function readdirCb(self, abs, cb) {
  3760. return function(er, entries) {
  3761. if (er)
  3762. self._readdirError(abs, er, cb);
  3763. else
  3764. self._readdirEntries(abs, entries, cb);
  3765. };
  3766. }
  3767. Glob.prototype._readdirEntries = function(abs, entries, cb) {
  3768. if (this.aborted)
  3769. return;
  3770. if (!this.mark && !this.stat) {
  3771. for (var i = 0; i < entries.length; i++) {
  3772. var e = entries[i];
  3773. if (abs === "/")
  3774. e = abs + e;
  3775. else
  3776. e = abs + "/" + e;
  3777. this.cache[e] = true;
  3778. }
  3779. }
  3780. this.cache[abs] = entries;
  3781. return cb(null, entries);
  3782. };
  3783. Glob.prototype._readdirError = function(f, er, cb) {
  3784. if (this.aborted)
  3785. return;
  3786. switch (er.code) {
  3787. case "ENOTSUP":
  3788. case "ENOTDIR":
  3789. var abs = this._makeAbs(f);
  3790. this.cache[abs] = "FILE";
  3791. if (abs === this.cwdAbs) {
  3792. var error = new Error(er.code + " invalid cwd " + this.cwd);
  3793. error.path = this.cwd;
  3794. error.code = er.code;
  3795. this.emit("error", error);
  3796. this.abort();
  3797. }
  3798. break;
  3799. case "ENOENT":
  3800. case "ELOOP":
  3801. case "ENAMETOOLONG":
  3802. case "UNKNOWN":
  3803. this.cache[this._makeAbs(f)] = false;
  3804. break;
  3805. default:
  3806. this.cache[this._makeAbs(f)] = false;
  3807. if (this.strict) {
  3808. this.emit("error", er);
  3809. this.abort();
  3810. }
  3811. if (!this.silent)
  3812. console.error("glob error", er);
  3813. break;
  3814. }
  3815. return cb();
  3816. };
  3817. Glob.prototype._processGlobStar = function(prefix, read, abs, remain, index, inGlobStar, cb) {
  3818. var self = this;
  3819. this._readdir(abs, inGlobStar, function(er, entries) {
  3820. self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb);
  3821. });
  3822. };
  3823. Glob.prototype._processGlobStar2 = function(prefix, read, abs, remain, index, inGlobStar, entries, cb) {
  3824. if (!entries)
  3825. return cb();
  3826. var remainWithoutGlobStar = remain.slice(1);
  3827. var gspref = prefix ? [prefix] : [];
  3828. var noGlobStar = gspref.concat(remainWithoutGlobStar);
  3829. this._process(noGlobStar, index, false, cb);
  3830. var isSym = this.symlinks[abs];
  3831. var len = entries.length;
  3832. if (isSym && inGlobStar)
  3833. return cb();
  3834. for (var i = 0; i < len; i++) {
  3835. var e = entries[i];
  3836. if (e.charAt(0) === "." && !this.dot)
  3837. continue;
  3838. var instead = gspref.concat(entries[i], remainWithoutGlobStar);
  3839. this._process(instead, index, true, cb);
  3840. var below = gspref.concat(entries[i], remain);
  3841. this._process(below, index, true, cb);
  3842. }
  3843. cb();
  3844. };
  3845. Glob.prototype._processSimple = function(prefix, index, cb) {
  3846. var self = this;
  3847. this._stat(prefix, function(er, exists) {
  3848. self._processSimple2(prefix, index, er, exists, cb);
  3849. });
  3850. };
  3851. Glob.prototype._processSimple2 = function(prefix, index, er, exists, cb) {
  3852. if (!this.matches[index])
  3853. this.matches[index] = /* @__PURE__ */ Object.create(null);
  3854. if (!exists)
  3855. return cb();
  3856. if (prefix && isAbsolute(prefix) && !this.nomount) {
  3857. var trail = /[\/\\]$/.test(prefix);
  3858. if (prefix.charAt(0) === "/") {
  3859. prefix = path10.join(this.root, prefix);
  3860. } else {
  3861. prefix = path10.resolve(this.root, prefix);
  3862. if (trail)
  3863. prefix += "/";
  3864. }
  3865. }
  3866. if (process.platform === "win32")
  3867. prefix = prefix.replace(/\\/g, "/");
  3868. this._emitMatch(index, prefix);
  3869. cb();
  3870. };
  3871. Glob.prototype._stat = function(f, cb) {
  3872. var abs = this._makeAbs(f);
  3873. var needDir = f.slice(-1) === "/";
  3874. if (f.length > this.maxLength)
  3875. return cb();
  3876. if (!this.stat && ownProp(this.cache, abs)) {
  3877. var c = this.cache[abs];
  3878. if (Array.isArray(c))
  3879. c = "DIR";
  3880. if (!needDir || c === "DIR")
  3881. return cb(null, c);
  3882. if (needDir && c === "FILE")
  3883. return cb();
  3884. }
  3885. var exists;
  3886. var stat = this.statCache[abs];
  3887. if (stat !== void 0) {
  3888. if (stat === false)
  3889. return cb(null, stat);
  3890. else {
  3891. var type = stat.isDirectory() ? "DIR" : "FILE";
  3892. if (needDir && type === "FILE")
  3893. return cb();
  3894. else
  3895. return cb(null, type, stat);
  3896. }
  3897. }
  3898. var self = this;
  3899. var statcb = inflight("stat\0" + abs, lstatcb_);
  3900. if (statcb)
  3901. self.fs.lstat(abs, statcb);
  3902. function lstatcb_(er, lstat) {
  3903. if (lstat && lstat.isSymbolicLink()) {
  3904. return self.fs.stat(abs, function(er2, stat2) {
  3905. if (er2)
  3906. self._stat2(f, abs, null, lstat, cb);
  3907. else
  3908. self._stat2(f, abs, er2, stat2, cb);
  3909. });
  3910. } else {
  3911. self._stat2(f, abs, er, lstat, cb);
  3912. }
  3913. }
  3914. };
  3915. Glob.prototype._stat2 = function(f, abs, er, stat, cb) {
  3916. if (er && (er.code === "ENOENT" || er.code === "ENOTDIR")) {
  3917. this.statCache[abs] = false;
  3918. return cb();
  3919. }
  3920. var needDir = f.slice(-1) === "/";
  3921. this.statCache[abs] = stat;
  3922. if (abs.slice(-1) === "/" && stat && !stat.isDirectory())
  3923. return cb(null, false, stat);
  3924. var c = true;
  3925. if (stat)
  3926. c = stat.isDirectory() ? "DIR" : "FILE";
  3927. this.cache[abs] = this.cache[abs] || c;
  3928. if (needDir && c === "FILE")
  3929. return cb();
  3930. return cb(null, c, stat);
  3931. };
  3932. }
  3933. });
  3934. // node_modules/rimraf/rimraf.js
  3935. var require_rimraf = __commonJS({
  3936. "node_modules/rimraf/rimraf.js"(exports, module) {
  3937. var assert = __require("assert");
  3938. var path10 = __require("path");
  3939. var fs6 = __require("fs");
  3940. var glob = void 0;
  3941. try {
  3942. glob = require_glob();
  3943. } catch (_err) {
  3944. }
  3945. var defaultGlobOpts = {
  3946. nosort: true,
  3947. silent: true
  3948. };
  3949. var timeout = 0;
  3950. var isWindows = process.platform === "win32";
  3951. var defaults = (options) => {
  3952. const methods = [
  3953. "unlink",
  3954. "chmod",
  3955. "stat",
  3956. "lstat",
  3957. "rmdir",
  3958. "readdir"
  3959. ];
  3960. methods.forEach((m) => {
  3961. options[m] = options[m] || fs6[m];
  3962. m = m + "Sync";
  3963. options[m] = options[m] || fs6[m];
  3964. });
  3965. options.maxBusyTries = options.maxBusyTries || 3;
  3966. options.emfileWait = options.emfileWait || 1e3;
  3967. if (options.glob === false) {
  3968. options.disableGlob = true;
  3969. }
  3970. if (options.disableGlob !== true && glob === void 0) {
  3971. throw Error("glob dependency not found, set `options.disableGlob = true` if intentional");
  3972. }
  3973. options.disableGlob = options.disableGlob || false;
  3974. options.glob = options.glob || defaultGlobOpts;
  3975. };
  3976. var rimraf = (p, options, cb) => {
  3977. if (typeof options === "function") {
  3978. cb = options;
  3979. options = {};
  3980. }
  3981. assert(p, "rimraf: missing path");
  3982. assert.equal(typeof p, "string", "rimraf: path should be a string");
  3983. assert.equal(typeof cb, "function", "rimraf: callback function required");
  3984. assert(options, "rimraf: invalid options argument provided");
  3985. assert.equal(typeof options, "object", "rimraf: options should be object");
  3986. defaults(options);
  3987. let busyTries = 0;
  3988. let errState = null;
  3989. let n = 0;
  3990. const next = (er) => {
  3991. errState = errState || er;
  3992. if (--n === 0)
  3993. cb(errState);
  3994. };
  3995. const afterGlob = (er, results) => {
  3996. if (er)
  3997. return cb(er);
  3998. n = results.length;
  3999. if (n === 0)
  4000. return cb();
  4001. results.forEach((p2) => {
  4002. const CB = (er2) => {
  4003. if (er2) {
  4004. if ((er2.code === "EBUSY" || er2.code === "ENOTEMPTY" || er2.code === "EPERM") && busyTries < options.maxBusyTries) {
  4005. busyTries++;
  4006. return setTimeout(() => rimraf_(p2, options, CB), busyTries * 100);
  4007. }
  4008. if (er2.code === "EMFILE" && timeout < options.emfileWait) {
  4009. return setTimeout(() => rimraf_(p2, options, CB), timeout++);
  4010. }
  4011. if (er2.code === "ENOENT")
  4012. er2 = null;
  4013. }
  4014. timeout = 0;
  4015. next(er2);
  4016. };
  4017. rimraf_(p2, options, CB);
  4018. });
  4019. };
  4020. if (options.disableGlob || !glob.hasMagic(p))
  4021. return afterGlob(null, [p]);
  4022. options.lstat(p, (er, stat) => {
  4023. if (!er)
  4024. return afterGlob(null, [p]);
  4025. glob(p, options.glob, afterGlob);
  4026. });
  4027. };
  4028. var rimraf_ = (p, options, cb) => {
  4029. assert(p);
  4030. assert(options);
  4031. assert(typeof cb === "function");
  4032. options.lstat(p, (er, st) => {
  4033. if (er && er.code === "ENOENT")
  4034. return cb(null);
  4035. if (er && er.code === "EPERM" && isWindows)
  4036. fixWinEPERM(p, options, er, cb);
  4037. if (st && st.isDirectory())
  4038. return rmdir(p, options, er, cb);
  4039. options.unlink(p, (er2) => {
  4040. if (er2) {
  4041. if (er2.code === "ENOENT")
  4042. return cb(null);
  4043. if (er2.code === "EPERM")
  4044. return isWindows ? fixWinEPERM(p, options, er2, cb) : rmdir(p, options, er2, cb);
  4045. if (er2.code === "EISDIR")
  4046. return rmdir(p, options, er2, cb);
  4047. }
  4048. return cb(er2);
  4049. });
  4050. });
  4051. };
  4052. var fixWinEPERM = (p, options, er, cb) => {
  4053. assert(p);
  4054. assert(options);
  4055. assert(typeof cb === "function");
  4056. options.chmod(p, 438, (er2) => {
  4057. if (er2)
  4058. cb(er2.code === "ENOENT" ? null : er);
  4059. else
  4060. options.stat(p, (er3, stats) => {
  4061. if (er3)
  4062. cb(er3.code === "ENOENT" ? null : er);
  4063. else if (stats.isDirectory())
  4064. rmdir(p, options, er, cb);
  4065. else
  4066. options.unlink(p, cb);
  4067. });
  4068. });
  4069. };
  4070. var fixWinEPERMSync = (p, options, er) => {
  4071. assert(p);
  4072. assert(options);
  4073. try {
  4074. options.chmodSync(p, 438);
  4075. } catch (er2) {
  4076. if (er2.code === "ENOENT")
  4077. return;
  4078. else
  4079. throw er;
  4080. }
  4081. let stats;
  4082. try {
  4083. stats = options.statSync(p);
  4084. } catch (er3) {
  4085. if (er3.code === "ENOENT")
  4086. return;
  4087. else
  4088. throw er;
  4089. }
  4090. if (stats.isDirectory())
  4091. rmdirSync(p, options, er);
  4092. else
  4093. options.unlinkSync(p);
  4094. };
  4095. var rmdir = (p, options, originalEr, cb) => {
  4096. assert(p);
  4097. assert(options);
  4098. assert(typeof cb === "function");
  4099. options.rmdir(p, (er) => {
  4100. if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM"))
  4101. rmkids(p, options, cb);
  4102. else if (er && er.code === "ENOTDIR")
  4103. cb(originalEr);
  4104. else
  4105. cb(er);
  4106. });
  4107. };
  4108. var rmkids = (p, options, cb) => {
  4109. assert(p);
  4110. assert(options);
  4111. assert(typeof cb === "function");
  4112. options.readdir(p, (er, files) => {
  4113. if (er)
  4114. return cb(er);
  4115. let n = files.length;
  4116. if (n === 0)
  4117. return options.rmdir(p, cb);
  4118. let errState;
  4119. files.forEach((f) => {
  4120. rimraf(path10.join(p, f), options, (er2) => {
  4121. if (errState)
  4122. return;
  4123. if (er2)
  4124. return cb(errState = er2);
  4125. if (--n === 0)
  4126. options.rmdir(p, cb);
  4127. });
  4128. });
  4129. });
  4130. };
  4131. var rimrafSync = (p, options) => {
  4132. options = options || {};
  4133. defaults(options);
  4134. assert(p, "rimraf: missing path");
  4135. assert.equal(typeof p, "string", "rimraf: path should be a string");
  4136. assert(options, "rimraf: missing options");
  4137. assert.equal(typeof options, "object", "rimraf: options should be object");
  4138. let results;
  4139. if (options.disableGlob || !glob.hasMagic(p)) {
  4140. results = [p];
  4141. } else {
  4142. try {
  4143. options.lstatSync(p);
  4144. results = [p];
  4145. } catch (er) {
  4146. results = glob.sync(p, options.glob);
  4147. }
  4148. }
  4149. if (!results.length)
  4150. return;
  4151. for (let i = 0; i < results.length; i++) {
  4152. const p2 = results[i];
  4153. let st;
  4154. try {
  4155. st = options.lstatSync(p2);
  4156. } catch (er) {
  4157. if (er.code === "ENOENT")
  4158. return;
  4159. if (er.code === "EPERM" && isWindows)
  4160. fixWinEPERMSync(p2, options, er);
  4161. }
  4162. try {
  4163. if (st && st.isDirectory())
  4164. rmdirSync(p2, options, null);
  4165. else
  4166. options.unlinkSync(p2);
  4167. } catch (er) {
  4168. if (er.code === "ENOENT")
  4169. return;
  4170. if (er.code === "EPERM")
  4171. return isWindows ? fixWinEPERMSync(p2, options, er) : rmdirSync(p2, options, er);
  4172. if (er.code !== "EISDIR")
  4173. throw er;
  4174. rmdirSync(p2, options, er);
  4175. }
  4176. }
  4177. };
  4178. var rmdirSync = (p, options, originalEr) => {
  4179. assert(p);
  4180. assert(options);
  4181. try {
  4182. options.rmdirSync(p);
  4183. } catch (er) {
  4184. if (er.code === "ENOENT")
  4185. return;
  4186. if (er.code === "ENOTDIR")
  4187. throw originalEr;
  4188. if (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM")
  4189. rmkidsSync(p, options);
  4190. }
  4191. };
  4192. var rmkidsSync = (p, options) => {
  4193. assert(p);
  4194. assert(options);
  4195. options.readdirSync(p).forEach((f) => rimrafSync(path10.join(p, f), options));
  4196. const retries = isWindows ? 100 : 1;
  4197. let i = 0;
  4198. do {
  4199. let threw = true;
  4200. try {
  4201. const ret = options.rmdirSync(p, options);
  4202. threw = false;
  4203. return ret;
  4204. } finally {
  4205. if (++i < retries && threw)
  4206. continue;
  4207. }
  4208. } while (true);
  4209. };
  4210. module.exports = rimraf;
  4211. rimraf.sync = rimrafSync;
  4212. }
  4213. });
  4214. // node_modules/flat-cache/src/del.js
  4215. var require_del = __commonJS({
  4216. "node_modules/flat-cache/src/del.js"(exports, module) {
  4217. var rimraf = require_rimraf().sync;
  4218. var fs6 = __require("fs");
  4219. module.exports = function del(file) {
  4220. if (fs6.existsSync(file)) {
  4221. rimraf(file, {
  4222. glob: false
  4223. });
  4224. return true;
  4225. }
  4226. return false;
  4227. };
  4228. }
  4229. });
  4230. // node_modules/flat-cache/src/cache.js
  4231. var require_cache = __commonJS({
  4232. "node_modules/flat-cache/src/cache.js"(exports, module) {
  4233. var path10 = __require("path");
  4234. var fs6 = __require("fs");
  4235. var Keyv = require_src();
  4236. var utils = require_utils();
  4237. var del = require_del();
  4238. var writeJSON = utils.writeJSON;
  4239. var cache = {
  4240. /**
  4241. * Load a cache identified by the given Id. If the element does not exists, then initialize an empty
  4242. * cache storage. If specified `cacheDir` will be used as the directory to persist the data to. If omitted
  4243. * then the cache module directory `./cache` will be used instead
  4244. *
  4245. * @method load
  4246. * @param docId {String} the id of the cache, would also be used as the name of the file cache
  4247. * @param [cacheDir] {String} directory for the cache entry
  4248. */
  4249. load: function(docId, cacheDir) {
  4250. var me = this;
  4251. me.keyv = new Keyv();
  4252. me.__visited = {};
  4253. me.__persisted = {};
  4254. me._pathToFile = cacheDir ? path10.resolve(cacheDir, docId) : path10.resolve(__dirname, "../.cache/", docId);
  4255. if (fs6.existsSync(me._pathToFile)) {
  4256. me._persisted = utils.tryParse(me._pathToFile, {});
  4257. }
  4258. },
  4259. get _persisted() {
  4260. return this.__persisted;
  4261. },
  4262. set _persisted(value) {
  4263. this.__persisted = value;
  4264. this.keyv.set("persisted", value);
  4265. },
  4266. get _visited() {
  4267. return this.__visited;
  4268. },
  4269. set _visited(value) {
  4270. this.__visited = value;
  4271. this.keyv.set("visited", value);
  4272. },
  4273. /**
  4274. * Load the cache from the provided file
  4275. * @method loadFile
  4276. * @param {String} pathToFile the path to the file containing the info for the cache
  4277. */
  4278. loadFile: function(pathToFile) {
  4279. var me = this;
  4280. var dir = path10.dirname(pathToFile);
  4281. var fName = path10.basename(pathToFile);
  4282. me.load(fName, dir);
  4283. },
  4284. /**
  4285. * Returns the entire persisted object
  4286. * @method all
  4287. * @returns {*}
  4288. */
  4289. all: function() {
  4290. return this._persisted;
  4291. },
  4292. keys: function() {
  4293. return Object.keys(this._persisted);
  4294. },
  4295. /**
  4296. * sets a key to a given value
  4297. * @method setKey
  4298. * @param key {string} the key to set
  4299. * @param value {object} the value of the key. Could be any object that can be serialized with JSON.stringify
  4300. */
  4301. setKey: function(key, value) {
  4302. this._visited[key] = true;
  4303. this._persisted[key] = value;
  4304. },
  4305. /**
  4306. * remove a given key from the cache
  4307. * @method removeKey
  4308. * @param key {String} the key to remove from the object
  4309. */
  4310. removeKey: function(key) {
  4311. delete this._visited[key];
  4312. delete this._persisted[key];
  4313. },
  4314. /**
  4315. * Return the value of the provided key
  4316. * @method getKey
  4317. * @param key {String} the name of the key to retrieve
  4318. * @returns {*} the value from the key
  4319. */
  4320. getKey: function(key) {
  4321. this._visited[key] = true;
  4322. return this._persisted[key];
  4323. },
  4324. /**
  4325. * Remove keys that were not accessed/set since the
  4326. * last time the `prune` method was called.
  4327. * @method _prune
  4328. * @private
  4329. */
  4330. _prune: function() {
  4331. var me = this;
  4332. var obj = {};
  4333. var keys = Object.keys(me._visited);
  4334. if (keys.length === 0) {
  4335. return;
  4336. }
  4337. keys.forEach(function(key) {
  4338. obj[key] = me._persisted[key];
  4339. });
  4340. me._visited = {};
  4341. me._persisted = obj;
  4342. },
  4343. /**
  4344. * Save the state of the cache identified by the docId to disk
  4345. * as a JSON structure
  4346. * @param [noPrune=false] {Boolean} whether to remove from cache the non visited files
  4347. * @method save
  4348. */
  4349. save: function(noPrune) {
  4350. var me = this;
  4351. !noPrune && me._prune();
  4352. writeJSON(me._pathToFile, me._persisted);
  4353. },
  4354. /**
  4355. * remove the file where the cache is persisted
  4356. * @method removeCacheFile
  4357. * @return {Boolean} true or false if the file was successfully deleted
  4358. */
  4359. removeCacheFile: function() {
  4360. return del(this._pathToFile);
  4361. },
  4362. /**
  4363. * Destroy the file cache and cache content.
  4364. * @method destroy
  4365. */
  4366. destroy: function() {
  4367. var me = this;
  4368. me._visited = {};
  4369. me._persisted = {};
  4370. me.removeCacheFile();
  4371. }
  4372. };
  4373. module.exports = {
  4374. /**
  4375. * Alias for create. Should be considered depreacted. Will be removed in next releases
  4376. *
  4377. * @method load
  4378. * @param docId {String} the id of the cache, would also be used as the name of the file cache
  4379. * @param [cacheDir] {String} directory for the cache entry
  4380. * @returns {cache} cache instance
  4381. */
  4382. load: function(docId, cacheDir) {
  4383. return this.create(docId, cacheDir);
  4384. },
  4385. /**
  4386. * Load a cache identified by the given Id. If the element does not exists, then initialize an empty
  4387. * cache storage.
  4388. *
  4389. * @method create
  4390. * @param docId {String} the id of the cache, would also be used as the name of the file cache
  4391. * @param [cacheDir] {String} directory for the cache entry
  4392. * @returns {cache} cache instance
  4393. */
  4394. create: function(docId, cacheDir) {
  4395. var obj = Object.create(cache);
  4396. obj.load(docId, cacheDir);
  4397. return obj;
  4398. },
  4399. createFromFile: function(filePath) {
  4400. var obj = Object.create(cache);
  4401. obj.loadFile(filePath);
  4402. return obj;
  4403. },
  4404. /**
  4405. * Clear the cache identified by the given id. Caches stored in a different cache directory can be deleted directly
  4406. *
  4407. * @method clearCache
  4408. * @param docId {String} the id of the cache, would also be used as the name of the file cache
  4409. * @param cacheDir {String} the directory where the cache file was written
  4410. * @returns {Boolean} true if the cache folder was deleted. False otherwise
  4411. */
  4412. clearCacheById: function(docId, cacheDir) {
  4413. var filePath = cacheDir ? path10.resolve(cacheDir, docId) : path10.resolve(__dirname, "../.cache/", docId);
  4414. return del(filePath);
  4415. },
  4416. /**
  4417. * Remove all cache stored in the cache directory
  4418. * @method clearAll
  4419. * @returns {Boolean} true if the cache folder was deleted. False otherwise
  4420. */
  4421. clearAll: function(cacheDir) {
  4422. var filePath = cacheDir ? path10.resolve(cacheDir) : path10.resolve(__dirname, "../.cache/");
  4423. return del(filePath);
  4424. }
  4425. };
  4426. }
  4427. });
  4428. // node_modules/file-entry-cache/cache.js
  4429. var require_cache2 = __commonJS({
  4430. "node_modules/file-entry-cache/cache.js"(exports, module) {
  4431. var path10 = __require("path");
  4432. var crypto = __require("crypto");
  4433. module.exports = {
  4434. createFromFile: function(filePath, useChecksum) {
  4435. var fname = path10.basename(filePath);
  4436. var dir = path10.dirname(filePath);
  4437. return this.create(fname, dir, useChecksum);
  4438. },
  4439. create: function(cacheId, _path, useChecksum) {
  4440. var fs6 = __require("fs");
  4441. var flatCache = require_cache();
  4442. var cache = flatCache.load(cacheId, _path);
  4443. var normalizedEntries = {};
  4444. var removeNotFoundFiles = function removeNotFoundFiles2() {
  4445. const cachedEntries = cache.keys();
  4446. cachedEntries.forEach(function remover(fPath) {
  4447. try {
  4448. fs6.statSync(fPath);
  4449. } catch (err) {
  4450. if (err.code === "ENOENT") {
  4451. cache.removeKey(fPath);
  4452. }
  4453. }
  4454. });
  4455. };
  4456. removeNotFoundFiles();
  4457. return {
  4458. /**
  4459. * the flat cache storage used to persist the metadata of the `files
  4460. * @type {Object}
  4461. */
  4462. cache,
  4463. /**
  4464. * Given a buffer, calculate md5 hash of its content.
  4465. * @method getHash
  4466. * @param {Buffer} buffer buffer to calculate hash on
  4467. * @return {String} content hash digest
  4468. */
  4469. getHash: function(buffer) {
  4470. return crypto.createHash("md5").update(buffer).digest("hex");
  4471. },
  4472. /**
  4473. * Return whether or not a file has changed since last time reconcile was called.
  4474. * @method hasFileChanged
  4475. * @param {String} file the filepath to check
  4476. * @return {Boolean} wheter or not the file has changed
  4477. */
  4478. hasFileChanged: function(file) {
  4479. return this.getFileDescriptor(file).changed;
  4480. },
  4481. /**
  4482. * given an array of file paths it return and object with three arrays:
  4483. * - changedFiles: Files that changed since previous run
  4484. * - notChangedFiles: Files that haven't change
  4485. * - notFoundFiles: Files that were not found, probably deleted
  4486. *
  4487. * @param {Array} files the files to analyze and compare to the previous seen files
  4488. * @return {[type]} [description]
  4489. */
  4490. analyzeFiles: function(files) {
  4491. var me = this;
  4492. files = files || [];
  4493. var res = {
  4494. changedFiles: [],
  4495. notFoundFiles: [],
  4496. notChangedFiles: []
  4497. };
  4498. me.normalizeEntries(files).forEach(function(entry) {
  4499. if (entry.changed) {
  4500. res.changedFiles.push(entry.key);
  4501. return;
  4502. }
  4503. if (entry.notFound) {
  4504. res.notFoundFiles.push(entry.key);
  4505. return;
  4506. }
  4507. res.notChangedFiles.push(entry.key);
  4508. });
  4509. return res;
  4510. },
  4511. getFileDescriptor: function(file) {
  4512. var fstat;
  4513. try {
  4514. fstat = fs6.statSync(file);
  4515. } catch (ex) {
  4516. this.removeEntry(file);
  4517. return { key: file, notFound: true, err: ex };
  4518. }
  4519. if (useChecksum) {
  4520. return this._getFileDescriptorUsingChecksum(file);
  4521. }
  4522. return this._getFileDescriptorUsingMtimeAndSize(file, fstat);
  4523. },
  4524. _getFileDescriptorUsingMtimeAndSize: function(file, fstat) {
  4525. var meta = cache.getKey(file);
  4526. var cacheExists = !!meta;
  4527. var cSize = fstat.size;
  4528. var cTime = fstat.mtime.getTime();
  4529. var isDifferentDate;
  4530. var isDifferentSize;
  4531. if (!meta) {
  4532. meta = { size: cSize, mtime: cTime };
  4533. } else {
  4534. isDifferentDate = cTime !== meta.mtime;
  4535. isDifferentSize = cSize !== meta.size;
  4536. }
  4537. var nEntry = normalizedEntries[file] = {
  4538. key: file,
  4539. changed: !cacheExists || isDifferentDate || isDifferentSize,
  4540. meta
  4541. };
  4542. return nEntry;
  4543. },
  4544. _getFileDescriptorUsingChecksum: function(file) {
  4545. var meta = cache.getKey(file);
  4546. var cacheExists = !!meta;
  4547. var contentBuffer;
  4548. try {
  4549. contentBuffer = fs6.readFileSync(file);
  4550. } catch (ex) {
  4551. contentBuffer = "";
  4552. }
  4553. var isDifferent = true;
  4554. var hash = this.getHash(contentBuffer);
  4555. if (!meta) {
  4556. meta = { hash };
  4557. } else {
  4558. isDifferent = hash !== meta.hash;
  4559. }
  4560. var nEntry = normalizedEntries[file] = {
  4561. key: file,
  4562. changed: !cacheExists || isDifferent,
  4563. meta
  4564. };
  4565. return nEntry;
  4566. },
  4567. /**
  4568. * Return the list o the files that changed compared
  4569. * against the ones stored in the cache
  4570. *
  4571. * @method getUpdated
  4572. * @param files {Array} the array of files to compare against the ones in the cache
  4573. * @returns {Array}
  4574. */
  4575. getUpdatedFiles: function(files) {
  4576. var me = this;
  4577. files = files || [];
  4578. return me.normalizeEntries(files).filter(function(entry) {
  4579. return entry.changed;
  4580. }).map(function(entry) {
  4581. return entry.key;
  4582. });
  4583. },
  4584. /**
  4585. * return the list of files
  4586. * @method normalizeEntries
  4587. * @param files
  4588. * @returns {*}
  4589. */
  4590. normalizeEntries: function(files) {
  4591. files = files || [];
  4592. var me = this;
  4593. var nEntries = files.map(function(file) {
  4594. return me.getFileDescriptor(file);
  4595. });
  4596. return nEntries;
  4597. },
  4598. /**
  4599. * Remove an entry from the file-entry-cache. Useful to force the file to still be considered
  4600. * modified the next time the process is run
  4601. *
  4602. * @method removeEntry
  4603. * @param entryName
  4604. */
  4605. removeEntry: function(entryName) {
  4606. delete normalizedEntries[entryName];
  4607. cache.removeKey(entryName);
  4608. },
  4609. /**
  4610. * Delete the cache file from the disk
  4611. * @method deleteCacheFile
  4612. */
  4613. deleteCacheFile: function() {
  4614. cache.removeCacheFile();
  4615. },
  4616. /**
  4617. * remove the cache from the file and clear the memory cache
  4618. */
  4619. destroy: function() {
  4620. normalizedEntries = {};
  4621. cache.destroy();
  4622. },
  4623. _getMetaForFileUsingCheckSum: function(cacheEntry) {
  4624. var contentBuffer = fs6.readFileSync(cacheEntry.key);
  4625. var hash = this.getHash(contentBuffer);
  4626. var meta = Object.assign(cacheEntry.meta, { hash });
  4627. delete meta.size;
  4628. delete meta.mtime;
  4629. return meta;
  4630. },
  4631. _getMetaForFileUsingMtimeAndSize: function(cacheEntry) {
  4632. var stat = fs6.statSync(cacheEntry.key);
  4633. var meta = Object.assign(cacheEntry.meta, {
  4634. size: stat.size,
  4635. mtime: stat.mtime.getTime()
  4636. });
  4637. delete meta.hash;
  4638. return meta;
  4639. },
  4640. /**
  4641. * Sync the files and persist them to the cache
  4642. * @method reconcile
  4643. */
  4644. reconcile: function(noPrune) {
  4645. removeNotFoundFiles();
  4646. noPrune = typeof noPrune === "undefined" ? true : noPrune;
  4647. var entries = normalizedEntries;
  4648. var keys = Object.keys(entries);
  4649. if (keys.length === 0) {
  4650. return;
  4651. }
  4652. var me = this;
  4653. keys.forEach(function(entryName) {
  4654. var cacheEntry = entries[entryName];
  4655. try {
  4656. var meta = useChecksum ? me._getMetaForFileUsingCheckSum(cacheEntry) : me._getMetaForFileUsingMtimeAndSize(cacheEntry);
  4657. cache.setKey(entryName, meta);
  4658. } catch (err) {
  4659. if (err.code !== "ENOENT") {
  4660. throw err;
  4661. }
  4662. }
  4663. });
  4664. cache.save(noPrune);
  4665. }
  4666. };
  4667. }
  4668. };
  4669. }
  4670. });
  4671. // node_modules/fast-json-stable-stringify/index.js
  4672. var require_fast_json_stable_stringify = __commonJS({
  4673. "node_modules/fast-json-stable-stringify/index.js"(exports, module) {
  4674. "use strict";
  4675. module.exports = function(data, opts) {
  4676. if (!opts)
  4677. opts = {};
  4678. if (typeof opts === "function")
  4679. opts = { cmp: opts };
  4680. var cycles = typeof opts.cycles === "boolean" ? opts.cycles : false;
  4681. var cmp = opts.cmp && function(f) {
  4682. return function(node) {
  4683. return function(a, b) {
  4684. var aobj = { key: a, value: node[a] };
  4685. var bobj = { key: b, value: node[b] };
  4686. return f(aobj, bobj);
  4687. };
  4688. };
  4689. }(opts.cmp);
  4690. var seen = [];
  4691. return function stringify4(node) {
  4692. if (node && node.toJSON && typeof node.toJSON === "function") {
  4693. node = node.toJSON();
  4694. }
  4695. if (node === void 0)
  4696. return;
  4697. if (typeof node == "number")
  4698. return isFinite(node) ? "" + node : "null";
  4699. if (typeof node !== "object")
  4700. return JSON.stringify(node);
  4701. var i, out;
  4702. if (Array.isArray(node)) {
  4703. out = "[";
  4704. for (i = 0; i < node.length; i++) {
  4705. if (i)
  4706. out += ",";
  4707. out += stringify4(node[i]) || "null";
  4708. }
  4709. return out + "]";
  4710. }
  4711. if (node === null)
  4712. return "null";
  4713. if (seen.indexOf(node) !== -1) {
  4714. if (cycles)
  4715. return JSON.stringify("__cycle__");
  4716. throw new TypeError("Converting circular structure to JSON");
  4717. }
  4718. var seenIndex = seen.push(node) - 1;
  4719. var keys = Object.keys(node).sort(cmp && cmp(node));
  4720. out = "";
  4721. for (i = 0; i < keys.length; i++) {
  4722. var key = keys[i];
  4723. var value = stringify4(node[key]);
  4724. if (!value)
  4725. continue;
  4726. if (out)
  4727. out += ",";
  4728. out += JSON.stringify(key) + ":" + value;
  4729. }
  4730. seen.splice(seenIndex, 1);
  4731. return "{" + out + "}";
  4732. }(data);
  4733. };
  4734. }
  4735. });
  4736. // src/cli/index.js
  4737. import * as prettier2 from "../index.mjs";
  4738. // scripts/build/shims/string-replace-all.js
  4739. var stringReplaceAll = (isOptionalObject, original, pattern, replacement) => {
  4740. if (isOptionalObject && (original === void 0 || original === null)) {
  4741. return;
  4742. }
  4743. if (original.replaceAll) {
  4744. return original.replaceAll(pattern, replacement);
  4745. }
  4746. if (pattern.global) {
  4747. return original.replace(pattern, replacement);
  4748. }
  4749. return original.split(pattern).join(replacement);
  4750. };
  4751. var string_replace_all_default = stringReplaceAll;
  4752. // src/cli/logger.js
  4753. import readline from "readline";
  4754. // node_modules/chalk/source/vendor/ansi-styles/index.js
  4755. var ANSI_BACKGROUND_OFFSET = 10;
  4756. var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
  4757. var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
  4758. var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
  4759. var styles = {
  4760. modifier: {
  4761. reset: [0, 0],
  4762. // 21 isn't widely supported and 22 does the same thing
  4763. bold: [1, 22],
  4764. dim: [2, 22],
  4765. italic: [3, 23],
  4766. underline: [4, 24],
  4767. overline: [53, 55],
  4768. inverse: [7, 27],
  4769. hidden: [8, 28],
  4770. strikethrough: [9, 29]
  4771. },
  4772. color: {
  4773. black: [30, 39],
  4774. red: [31, 39],
  4775. green: [32, 39],
  4776. yellow: [33, 39],
  4777. blue: [34, 39],
  4778. magenta: [35, 39],
  4779. cyan: [36, 39],
  4780. white: [37, 39],
  4781. // Bright color
  4782. blackBright: [90, 39],
  4783. gray: [90, 39],
  4784. // Alias of `blackBright`
  4785. grey: [90, 39],
  4786. // Alias of `blackBright`
  4787. redBright: [91, 39],
  4788. greenBright: [92, 39],
  4789. yellowBright: [93, 39],
  4790. blueBright: [94, 39],
  4791. magentaBright: [95, 39],
  4792. cyanBright: [96, 39],
  4793. whiteBright: [97, 39]
  4794. },
  4795. bgColor: {
  4796. bgBlack: [40, 49],
  4797. bgRed: [41, 49],
  4798. bgGreen: [42, 49],
  4799. bgYellow: [43, 49],
  4800. bgBlue: [44, 49],
  4801. bgMagenta: [45, 49],
  4802. bgCyan: [46, 49],
  4803. bgWhite: [47, 49],
  4804. // Bright color
  4805. bgBlackBright: [100, 49],
  4806. bgGray: [100, 49],
  4807. // Alias of `bgBlackBright`
  4808. bgGrey: [100, 49],
  4809. // Alias of `bgBlackBright`
  4810. bgRedBright: [101, 49],
  4811. bgGreenBright: [102, 49],
  4812. bgYellowBright: [103, 49],
  4813. bgBlueBright: [104, 49],
  4814. bgMagentaBright: [105, 49],
  4815. bgCyanBright: [106, 49],
  4816. bgWhiteBright: [107, 49]
  4817. }
  4818. };
  4819. var modifierNames = Object.keys(styles.modifier);
  4820. var foregroundColorNames = Object.keys(styles.color);
  4821. var backgroundColorNames = Object.keys(styles.bgColor);
  4822. var colorNames = [...foregroundColorNames, ...backgroundColorNames];
  4823. function assembleStyles() {
  4824. const codes = /* @__PURE__ */ new Map();
  4825. for (const [groupName, group] of Object.entries(styles)) {
  4826. for (const [styleName, style] of Object.entries(group)) {
  4827. styles[styleName] = {
  4828. open: `\x1B[${style[0]}m`,
  4829. close: `\x1B[${style[1]}m`
  4830. };
  4831. group[styleName] = styles[styleName];
  4832. codes.set(style[0], style[1]);
  4833. }
  4834. Object.defineProperty(styles, groupName, {
  4835. value: group,
  4836. enumerable: false
  4837. });
  4838. }
  4839. Object.defineProperty(styles, "codes", {
  4840. value: codes,
  4841. enumerable: false
  4842. });
  4843. styles.color.close = "\x1B[39m";
  4844. styles.bgColor.close = "\x1B[49m";
  4845. styles.color.ansi = wrapAnsi16();
  4846. styles.color.ansi256 = wrapAnsi256();
  4847. styles.color.ansi16m = wrapAnsi16m();
  4848. styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
  4849. styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
  4850. styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
  4851. Object.defineProperties(styles, {
  4852. rgbToAnsi256: {
  4853. value(red, green, blue) {
  4854. if (red === green && green === blue) {
  4855. if (red < 8) {
  4856. return 16;
  4857. }
  4858. if (red > 248) {
  4859. return 231;
  4860. }
  4861. return Math.round((red - 8) / 247 * 24) + 232;
  4862. }
  4863. return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
  4864. },
  4865. enumerable: false
  4866. },
  4867. hexToRgb: {
  4868. value(hex) {
  4869. const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
  4870. if (!matches) {
  4871. return [0, 0, 0];
  4872. }
  4873. let [colorString] = matches;
  4874. if (colorString.length === 3) {
  4875. colorString = [...colorString].map((character) => character + character).join("");
  4876. }
  4877. const integer = Number.parseInt(colorString, 16);
  4878. return [
  4879. /* eslint-disable no-bitwise */
  4880. integer >> 16 & 255,
  4881. integer >> 8 & 255,
  4882. integer & 255
  4883. /* eslint-enable no-bitwise */
  4884. ];
  4885. },
  4886. enumerable: false
  4887. },
  4888. hexToAnsi256: {
  4889. value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
  4890. enumerable: false
  4891. },
  4892. ansi256ToAnsi: {
  4893. value(code) {
  4894. if (code < 8) {
  4895. return 30 + code;
  4896. }
  4897. if (code < 16) {
  4898. return 90 + (code - 8);
  4899. }
  4900. let red;
  4901. let green;
  4902. let blue;
  4903. if (code >= 232) {
  4904. red = ((code - 232) * 10 + 8) / 255;
  4905. green = red;
  4906. blue = red;
  4907. } else {
  4908. code -= 16;
  4909. const remainder = code % 36;
  4910. red = Math.floor(code / 36) / 5;
  4911. green = Math.floor(remainder / 6) / 5;
  4912. blue = remainder % 6 / 5;
  4913. }
  4914. const value = Math.max(red, green, blue) * 2;
  4915. if (value === 0) {
  4916. return 30;
  4917. }
  4918. let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
  4919. if (value === 2) {
  4920. result += 60;
  4921. }
  4922. return result;
  4923. },
  4924. enumerable: false
  4925. },
  4926. rgbToAnsi: {
  4927. value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
  4928. enumerable: false
  4929. },
  4930. hexToAnsi: {
  4931. value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
  4932. enumerable: false
  4933. }
  4934. });
  4935. return styles;
  4936. }
  4937. var ansiStyles = assembleStyles();
  4938. var ansi_styles_default = ansiStyles;
  4939. // node_modules/chalk/source/vendor/supports-color/index.js
  4940. import process2 from "process";
  4941. import os from "os";
  4942. import tty from "tty";
  4943. function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process2.argv) {
  4944. const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
  4945. const position = argv.indexOf(prefix + flag);
  4946. const terminatorPosition = argv.indexOf("--");
  4947. return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
  4948. }
  4949. var { env } = process2;
  4950. var flagForceColor;
  4951. if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
  4952. flagForceColor = 0;
  4953. } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
  4954. flagForceColor = 1;
  4955. }
  4956. function envForceColor() {
  4957. if ("FORCE_COLOR" in env) {
  4958. if (env.FORCE_COLOR === "true") {
  4959. return 1;
  4960. }
  4961. if (env.FORCE_COLOR === "false") {
  4962. return 0;
  4963. }
  4964. return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
  4965. }
  4966. }
  4967. function translateLevel(level) {
  4968. if (level === 0) {
  4969. return false;
  4970. }
  4971. return {
  4972. level,
  4973. hasBasic: true,
  4974. has256: level >= 2,
  4975. has16m: level >= 3
  4976. };
  4977. }
  4978. function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
  4979. const noFlagForceColor = envForceColor();
  4980. if (noFlagForceColor !== void 0) {
  4981. flagForceColor = noFlagForceColor;
  4982. }
  4983. const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
  4984. if (forceColor === 0) {
  4985. return 0;
  4986. }
  4987. if (sniffFlags) {
  4988. if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
  4989. return 3;
  4990. }
  4991. if (hasFlag("color=256")) {
  4992. return 2;
  4993. }
  4994. }
  4995. if ("TF_BUILD" in env && "AGENT_NAME" in env) {
  4996. return 1;
  4997. }
  4998. if (haveStream && !streamIsTTY && forceColor === void 0) {
  4999. return 0;
  5000. }
  5001. const min = forceColor || 0;
  5002. if (env.TERM === "dumb") {
  5003. return min;
  5004. }
  5005. if (process2.platform === "win32") {
  5006. const osRelease = os.release().split(".");
  5007. if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
  5008. return Number(osRelease[2]) >= 14931 ? 3 : 2;
  5009. }
  5010. return 1;
  5011. }
  5012. if ("CI" in env) {
  5013. if ("GITHUB_ACTIONS" in env || "GITEA_ACTIONS" in env) {
  5014. return 3;
  5015. }
  5016. if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
  5017. return 1;
  5018. }
  5019. return min;
  5020. }
  5021. if ("TEAMCITY_VERSION" in env) {
  5022. return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
  5023. }
  5024. if (env.COLORTERM === "truecolor") {
  5025. return 3;
  5026. }
  5027. if (env.TERM === "xterm-kitty") {
  5028. return 3;
  5029. }
  5030. if ("TERM_PROGRAM" in env) {
  5031. const version2 = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
  5032. switch (env.TERM_PROGRAM) {
  5033. case "iTerm.app": {
  5034. return version2 >= 3 ? 3 : 2;
  5035. }
  5036. case "Apple_Terminal": {
  5037. return 2;
  5038. }
  5039. }
  5040. }
  5041. if (/-256(color)?$/i.test(env.TERM)) {
  5042. return 2;
  5043. }
  5044. if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
  5045. return 1;
  5046. }
  5047. if ("COLORTERM" in env) {
  5048. return 1;
  5049. }
  5050. return min;
  5051. }
  5052. function createSupportsColor(stream, options = {}) {
  5053. const level = _supportsColor(stream, {
  5054. streamIsTTY: stream && stream.isTTY,
  5055. ...options
  5056. });
  5057. return translateLevel(level);
  5058. }
  5059. var supportsColor = {
  5060. stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
  5061. stderr: createSupportsColor({ isTTY: tty.isatty(2) })
  5062. };
  5063. var supports_color_default = supportsColor;
  5064. // node_modules/chalk/source/utilities.js
  5065. function stringReplaceAll2(string, substring, replacer) {
  5066. let index = string.indexOf(substring);
  5067. if (index === -1) {
  5068. return string;
  5069. }
  5070. const substringLength = substring.length;
  5071. let endIndex = 0;
  5072. let returnValue = "";
  5073. do {
  5074. returnValue += string.slice(endIndex, index) + substring + replacer;
  5075. endIndex = index + substringLength;
  5076. index = string.indexOf(substring, endIndex);
  5077. } while (index !== -1);
  5078. returnValue += string.slice(endIndex);
  5079. return returnValue;
  5080. }
  5081. function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
  5082. let endIndex = 0;
  5083. let returnValue = "";
  5084. do {
  5085. const gotCR = string[index - 1] === "\r";
  5086. returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
  5087. endIndex = index + 1;
  5088. index = string.indexOf("\n", endIndex);
  5089. } while (index !== -1);
  5090. returnValue += string.slice(endIndex);
  5091. return returnValue;
  5092. }
  5093. // node_modules/chalk/source/index.js
  5094. var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
  5095. var GENERATOR = Symbol("GENERATOR");
  5096. var STYLER = Symbol("STYLER");
  5097. var IS_EMPTY = Symbol("IS_EMPTY");
  5098. var levelMapping = [
  5099. "ansi",
  5100. "ansi",
  5101. "ansi256",
  5102. "ansi16m"
  5103. ];
  5104. var styles2 = /* @__PURE__ */ Object.create(null);
  5105. var applyOptions = (object, options = {}) => {
  5106. if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
  5107. throw new Error("The `level` option should be an integer from 0 to 3");
  5108. }
  5109. const colorLevel = stdoutColor ? stdoutColor.level : 0;
  5110. object.level = options.level === void 0 ? colorLevel : options.level;
  5111. };
  5112. var chalkFactory = (options) => {
  5113. const chalk2 = (...strings) => strings.join(" ");
  5114. applyOptions(chalk2, options);
  5115. Object.setPrototypeOf(chalk2, createChalk.prototype);
  5116. return chalk2;
  5117. };
  5118. function createChalk(options) {
  5119. return chalkFactory(options);
  5120. }
  5121. Object.setPrototypeOf(createChalk.prototype, Function.prototype);
  5122. for (const [styleName, style] of Object.entries(ansi_styles_default)) {
  5123. styles2[styleName] = {
  5124. get() {
  5125. const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
  5126. Object.defineProperty(this, styleName, { value: builder });
  5127. return builder;
  5128. }
  5129. };
  5130. }
  5131. styles2.visible = {
  5132. get() {
  5133. const builder = createBuilder(this, this[STYLER], true);
  5134. Object.defineProperty(this, "visible", { value: builder });
  5135. return builder;
  5136. }
  5137. };
  5138. var getModelAnsi = (model, level, type, ...arguments_) => {
  5139. if (model === "rgb") {
  5140. if (level === "ansi16m") {
  5141. return ansi_styles_default[type].ansi16m(...arguments_);
  5142. }
  5143. if (level === "ansi256") {
  5144. return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
  5145. }
  5146. return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
  5147. }
  5148. if (model === "hex") {
  5149. return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
  5150. }
  5151. return ansi_styles_default[type][model](...arguments_);
  5152. };
  5153. var usedModels = ["rgb", "hex", "ansi256"];
  5154. for (const model of usedModels) {
  5155. styles2[model] = {
  5156. get() {
  5157. const { level } = this;
  5158. return function(...arguments_) {
  5159. const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
  5160. return createBuilder(this, styler, this[IS_EMPTY]);
  5161. };
  5162. }
  5163. };
  5164. const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
  5165. styles2[bgModel] = {
  5166. get() {
  5167. const { level } = this;
  5168. return function(...arguments_) {
  5169. const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
  5170. return createBuilder(this, styler, this[IS_EMPTY]);
  5171. };
  5172. }
  5173. };
  5174. }
  5175. var proto = Object.defineProperties(() => {
  5176. }, {
  5177. ...styles2,
  5178. level: {
  5179. enumerable: true,
  5180. get() {
  5181. return this[GENERATOR].level;
  5182. },
  5183. set(level) {
  5184. this[GENERATOR].level = level;
  5185. }
  5186. }
  5187. });
  5188. var createStyler = (open, close, parent) => {
  5189. let openAll;
  5190. let closeAll;
  5191. if (parent === void 0) {
  5192. openAll = open;
  5193. closeAll = close;
  5194. } else {
  5195. openAll = parent.openAll + open;
  5196. closeAll = close + parent.closeAll;
  5197. }
  5198. return {
  5199. open,
  5200. close,
  5201. openAll,
  5202. closeAll,
  5203. parent
  5204. };
  5205. };
  5206. var createBuilder = (self, _styler, _isEmpty) => {
  5207. const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
  5208. Object.setPrototypeOf(builder, proto);
  5209. builder[GENERATOR] = self;
  5210. builder[STYLER] = _styler;
  5211. builder[IS_EMPTY] = _isEmpty;
  5212. return builder;
  5213. };
  5214. var applyStyle = (self, string) => {
  5215. if (self.level <= 0 || !string) {
  5216. return self[IS_EMPTY] ? "" : string;
  5217. }
  5218. let styler = self[STYLER];
  5219. if (styler === void 0) {
  5220. return string;
  5221. }
  5222. const { openAll, closeAll } = styler;
  5223. if (string.includes("\x1B")) {
  5224. while (styler !== void 0) {
  5225. string = stringReplaceAll2(string, styler.close, styler.open);
  5226. styler = styler.parent;
  5227. }
  5228. }
  5229. const lfIndex = string.indexOf("\n");
  5230. if (lfIndex !== -1) {
  5231. string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
  5232. }
  5233. return openAll + string + closeAll;
  5234. };
  5235. Object.defineProperties(createChalk.prototype, styles2);
  5236. var chalk = createChalk();
  5237. var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
  5238. var source_default = chalk;
  5239. // node_modules/ansi-regex/index.js
  5240. function ansiRegex({ onlyFirst = false } = {}) {
  5241. const pattern = [
  5242. "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
  5243. "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
  5244. ].join("|");
  5245. return new RegExp(pattern, onlyFirst ? void 0 : "g");
  5246. }
  5247. // node_modules/strip-ansi/index.js
  5248. var regex = ansiRegex();
  5249. function stripAnsi(string) {
  5250. if (typeof string !== "string") {
  5251. throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
  5252. }
  5253. return string.replace(regex, "");
  5254. }
  5255. // src/cli/logger.js
  5256. var import_wcwidth = __toESM(require_wcwidth(), 1);
  5257. var countLines = (stream, text) => {
  5258. const columns = stream.columns || 80;
  5259. let lineCount = 0;
  5260. for (const line of stripAnsi(text).split("\n")) {
  5261. lineCount += Math.max(1, Math.ceil((0, import_wcwidth.default)(line) / columns));
  5262. }
  5263. return lineCount;
  5264. };
  5265. var clear = (stream, text) => () => {
  5266. const lineCount = countLines(stream, text);
  5267. for (let line = 0; line < lineCount; line++) {
  5268. if (line > 0) {
  5269. readline.moveCursor(stream, 0, -1);
  5270. }
  5271. readline.clearLine(stream, 0);
  5272. readline.cursorTo(stream, 0);
  5273. }
  5274. };
  5275. var emptyLogResult = {
  5276. clear() {
  5277. }
  5278. };
  5279. function createLogger(logLevel = "log") {
  5280. return {
  5281. logLevel,
  5282. warn: createLogFunc("warn", "yellow"),
  5283. error: createLogFunc("error", "red"),
  5284. debug: createLogFunc("debug", "blue"),
  5285. log: createLogFunc("log")
  5286. };
  5287. function createLogFunc(loggerName, color) {
  5288. if (!shouldLog(loggerName)) {
  5289. return () => emptyLogResult;
  5290. }
  5291. const stream = process[loggerName === "log" ? "stdout" : "stderr"];
  5292. const chalkInstance = loggerName === "log" ? source_default : chalkStderr;
  5293. const prefix = color ? `[${chalkInstance[color](loggerName)}] ` : "";
  5294. return (message, options) => {
  5295. options = {
  5296. newline: true,
  5297. clearable: false,
  5298. ...options
  5299. };
  5300. message = string_replace_all_default(
  5301. /* isOptionalObject*/
  5302. false,
  5303. message,
  5304. /^/gm,
  5305. prefix
  5306. ) + (options.newline ? "\n" : "");
  5307. stream.write(message);
  5308. if (options.clearable) {
  5309. return {
  5310. clear: clear(stream, message)
  5311. };
  5312. }
  5313. };
  5314. }
  5315. function shouldLog(loggerName) {
  5316. switch (logLevel) {
  5317. case "silent":
  5318. return false;
  5319. case "debug":
  5320. if (loggerName === "debug") {
  5321. return true;
  5322. }
  5323. case "log":
  5324. if (loggerName === "log") {
  5325. return true;
  5326. }
  5327. case "warn":
  5328. if (loggerName === "warn") {
  5329. return true;
  5330. }
  5331. case "error":
  5332. return loggerName === "error";
  5333. }
  5334. }
  5335. }
  5336. var logger_default = createLogger;
  5337. // scripts/build/shims/at.js
  5338. var at = (isOptionalObject, object, index) => {
  5339. if (isOptionalObject && (object === void 0 || object === null)) {
  5340. return;
  5341. }
  5342. if (Array.isArray(object) || typeof object === "string") {
  5343. return object[index < 0 ? object.length + index : index];
  5344. }
  5345. return object.at(index);
  5346. };
  5347. var at_default = at;
  5348. // src/cli/options/get-context-options.js
  5349. var import_dashify = __toESM(require_dashify(), 1);
  5350. import { getSupportInfo } from "../index.mjs";
  5351. // src/cli/prettier-internal.js
  5352. import { __internal as sharedWithCli } from "../index.mjs";
  5353. var {
  5354. errors,
  5355. optionCategories,
  5356. createIsIgnoredFunction,
  5357. formatOptionsHiddenDefaults,
  5358. normalizeOptions,
  5359. getSupportInfoWithoutPlugins,
  5360. normalizeOptionSettings,
  5361. vnopts,
  5362. fastGlob
  5363. } = sharedWithCli;
  5364. // src/cli/cli-options.evaluate.js
  5365. var cli_options_evaluate_default = {
  5366. "cache": {
  5367. "default": false,
  5368. "description": "Only format changed files. Cannot use with --stdin-filepath.",
  5369. "type": "boolean"
  5370. },
  5371. "cacheLocation": {
  5372. "description": "Path to the cache file.",
  5373. "type": "path"
  5374. },
  5375. "cacheStrategy": {
  5376. "choices": [
  5377. {
  5378. "description": "Use the file metadata such as timestamps as cache keys",
  5379. "value": "metadata"
  5380. },
  5381. {
  5382. "description": "Use the file content as cache keys",
  5383. "value": "content"
  5384. }
  5385. ],
  5386. "description": "Strategy for the cache to use for detecting changed files.",
  5387. "type": "choice"
  5388. },
  5389. "check": {
  5390. "alias": "c",
  5391. "category": "Output",
  5392. "description": "Check if the given files are formatted, print a human-friendly summary\nmessage and paths to unformatted files (see also --list-different).",
  5393. "type": "boolean"
  5394. },
  5395. "color": {
  5396. "default": true,
  5397. "description": "Colorize error messages.",
  5398. "oppositeDescription": "Do not colorize error messages.",
  5399. "type": "boolean"
  5400. },
  5401. "config": {
  5402. "category": "Config",
  5403. "description": "Path to a Prettier configuration file (.prettierrc, package.json, prettier.config.js).",
  5404. "exception": (value) => value === false,
  5405. "oppositeDescription": "Do not look for a configuration file.",
  5406. "type": "path"
  5407. },
  5408. "configPrecedence": {
  5409. "category": "Config",
  5410. "choices": [
  5411. {
  5412. "description": "CLI options take precedence over config file",
  5413. "value": "cli-override"
  5414. },
  5415. {
  5416. "description": "Config file take precedence over CLI options",
  5417. "value": "file-override"
  5418. },
  5419. {
  5420. "description": "If a config file is found will evaluate it and ignore other CLI options.\nIf no config file is found CLI options will evaluate as normal.",
  5421. "value": "prefer-file"
  5422. }
  5423. ],
  5424. "default": "cli-override",
  5425. "description": "Define in which order config files and CLI options should be evaluated.",
  5426. "type": "choice"
  5427. },
  5428. "debugBenchmark": {
  5429. "type": "boolean"
  5430. },
  5431. "debugCheck": {
  5432. "type": "boolean"
  5433. },
  5434. "debugPrintAst": {
  5435. "type": "boolean"
  5436. },
  5437. "debugPrintComments": {
  5438. "type": "boolean"
  5439. },
  5440. "debugPrintDoc": {
  5441. "type": "boolean"
  5442. },
  5443. "debugRepeat": {
  5444. "default": 0,
  5445. "type": "int"
  5446. },
  5447. "editorconfig": {
  5448. "category": "Config",
  5449. "default": true,
  5450. "description": "Take .editorconfig into account when parsing configuration.",
  5451. "oppositeDescription": "Don't take .editorconfig into account when parsing configuration.",
  5452. "type": "boolean"
  5453. },
  5454. "errorOnUnmatchedPattern": {
  5455. "oppositeDescription": "Prevent errors when pattern is unmatched.",
  5456. "type": "boolean"
  5457. },
  5458. "fileInfo": {
  5459. "description": "Extract the following info (as JSON) for a given file path. Reported fields:\n* ignored (boolean) - true if file path is filtered by --ignore-path\n* inferredParser (string | null) - name of parser inferred from file path",
  5460. "type": "path"
  5461. },
  5462. "findConfigPath": {
  5463. "category": "Config",
  5464. "description": "Find and print the path to a configuration file for the given input file.",
  5465. "type": "path"
  5466. },
  5467. "help": {
  5468. "alias": "h",
  5469. "description": "Show CLI usage, or details about the given flag.\nExample: --help write",
  5470. "exception": (value) => value === "",
  5471. "type": "flag"
  5472. },
  5473. "ignorePath": {
  5474. "array": true,
  5475. "category": "Config",
  5476. "default": [
  5477. {
  5478. "value": [
  5479. ".gitignore",
  5480. ".prettierignore"
  5481. ]
  5482. }
  5483. ],
  5484. "description": "Path to a file with patterns describing files to ignore.\nMultiple values are accepted.",
  5485. "type": "path"
  5486. },
  5487. "ignoreUnknown": {
  5488. "alias": "u",
  5489. "description": "Ignore unknown files.",
  5490. "type": "boolean"
  5491. },
  5492. "listDifferent": {
  5493. "alias": "l",
  5494. "category": "Output",
  5495. "description": "Print the names of files that are different from Prettier's formatting (see also --check).",
  5496. "type": "boolean"
  5497. },
  5498. "logLevel": {
  5499. "choices": [
  5500. "silent",
  5501. "error",
  5502. "warn",
  5503. "log",
  5504. "debug"
  5505. ],
  5506. "default": "log",
  5507. "description": "What level of logs to report.",
  5508. "type": "choice"
  5509. },
  5510. "supportInfo": {
  5511. "description": "Print support information as JSON.",
  5512. "type": "boolean"
  5513. },
  5514. "version": {
  5515. "alias": "v",
  5516. "description": "Print Prettier version.",
  5517. "type": "boolean"
  5518. },
  5519. "withNodeModules": {
  5520. "category": "Config",
  5521. "description": "Process files inside 'node_modules' directory.",
  5522. "type": "boolean"
  5523. },
  5524. "write": {
  5525. "alias": "w",
  5526. "category": "Output",
  5527. "description": "Edit files in-place. (Beware!)",
  5528. "type": "boolean"
  5529. }
  5530. };
  5531. // src/cli/options/get-context-options.js
  5532. var detailedCliOptions = normalizeOptionSettings(cli_options_evaluate_default).map(
  5533. (option) => normalizeDetailedOption(option)
  5534. );
  5535. function apiOptionToCliOption(apiOption) {
  5536. const cliOption = {
  5537. ...apiOption,
  5538. description: apiOption.cliDescription ?? apiOption.description,
  5539. category: apiOption.cliCategory ?? optionCategories.CATEGORY_FORMAT,
  5540. forwardToApi: apiOption.name
  5541. };
  5542. if (apiOption.deprecated) {
  5543. delete cliOption.forwardToApi;
  5544. delete cliOption.description;
  5545. delete cliOption.oppositeDescription;
  5546. cliOption.deprecated = true;
  5547. }
  5548. return normalizeDetailedOption(cliOption);
  5549. }
  5550. function normalizeDetailedOption(option) {
  5551. var _a;
  5552. return {
  5553. category: optionCategories.CATEGORY_OTHER,
  5554. ...option,
  5555. name: option.cliName ?? (0, import_dashify.default)(option.name),
  5556. choices: (_a = option.choices) == null ? void 0 : _a.map((choice) => {
  5557. const newChoice = {
  5558. description: "",
  5559. deprecated: false,
  5560. ...typeof choice === "object" ? choice : { value: choice }
  5561. };
  5562. if (newChoice.value === true) {
  5563. newChoice.value = "";
  5564. }
  5565. return newChoice;
  5566. })
  5567. };
  5568. }
  5569. function supportInfoToContextOptions({ options: supportOptions, languages }) {
  5570. const detailedOptions = [
  5571. ...detailedCliOptions,
  5572. ...supportOptions.map((apiOption) => apiOptionToCliOption(apiOption))
  5573. ];
  5574. return {
  5575. supportOptions,
  5576. languages,
  5577. detailedOptions
  5578. };
  5579. }
  5580. async function getContextOptions(plugins) {
  5581. const supportInfo = await getSupportInfo({
  5582. showDeprecated: true,
  5583. plugins
  5584. });
  5585. return supportInfoToContextOptions(supportInfo);
  5586. }
  5587. function getContextOptionsWithoutPlugins() {
  5588. const supportInfo = getSupportInfoWithoutPlugins();
  5589. return supportInfoToContextOptions(supportInfo);
  5590. }
  5591. // node_modules/camelcase/index.js
  5592. var UPPERCASE = /[\p{Lu}]/u;
  5593. var LOWERCASE = /[\p{Ll}]/u;
  5594. var LEADING_CAPITAL = /^[\p{Lu}](?![\p{Lu}])/gu;
  5595. var IDENTIFIER = /([\p{Alpha}\p{N}_]|$)/u;
  5596. var SEPARATORS = /[_.\- ]+/;
  5597. var LEADING_SEPARATORS = new RegExp("^" + SEPARATORS.source);
  5598. var SEPARATORS_AND_IDENTIFIER = new RegExp(SEPARATORS.source + IDENTIFIER.source, "gu");
  5599. var NUMBERS_AND_IDENTIFIER = new RegExp("\\d+" + IDENTIFIER.source, "gu");
  5600. var preserveCamelCase = (string, toLowerCase, toUpperCase, preserveConsecutiveUppercase2) => {
  5601. let isLastCharLower = false;
  5602. let isLastCharUpper = false;
  5603. let isLastLastCharUpper = false;
  5604. let isLastLastCharPreserved = false;
  5605. for (let index = 0; index < string.length; index++) {
  5606. const character = string[index];
  5607. isLastLastCharPreserved = index > 2 ? string[index - 3] === "-" : true;
  5608. if (isLastCharLower && UPPERCASE.test(character)) {
  5609. string = string.slice(0, index) + "-" + string.slice(index);
  5610. isLastCharLower = false;
  5611. isLastLastCharUpper = isLastCharUpper;
  5612. isLastCharUpper = true;
  5613. index++;
  5614. } else if (isLastCharUpper && isLastLastCharUpper && LOWERCASE.test(character) && (!isLastLastCharPreserved || preserveConsecutiveUppercase2)) {
  5615. string = string.slice(0, index - 1) + "-" + string.slice(index - 1);
  5616. isLastLastCharUpper = isLastCharUpper;
  5617. isLastCharUpper = false;
  5618. isLastCharLower = true;
  5619. } else {
  5620. isLastCharLower = toLowerCase(character) === character && toUpperCase(character) !== character;
  5621. isLastLastCharUpper = isLastCharUpper;
  5622. isLastCharUpper = toUpperCase(character) === character && toLowerCase(character) !== character;
  5623. }
  5624. }
  5625. return string;
  5626. };
  5627. var preserveConsecutiveUppercase = (input, toLowerCase) => {
  5628. LEADING_CAPITAL.lastIndex = 0;
  5629. return string_replace_all_default(
  5630. /* isOptionalObject*/
  5631. false,
  5632. input,
  5633. LEADING_CAPITAL,
  5634. (match) => toLowerCase(match)
  5635. );
  5636. };
  5637. var postProcess = (input, toUpperCase) => {
  5638. SEPARATORS_AND_IDENTIFIER.lastIndex = 0;
  5639. NUMBERS_AND_IDENTIFIER.lastIndex = 0;
  5640. return string_replace_all_default(
  5641. /* isOptionalObject*/
  5642. false,
  5643. string_replace_all_default(
  5644. /* isOptionalObject*/
  5645. false,
  5646. input,
  5647. NUMBERS_AND_IDENTIFIER,
  5648. (match, pattern, offset) => ["_", "-"].includes(input.charAt(offset + match.length)) ? match : toUpperCase(match)
  5649. ),
  5650. SEPARATORS_AND_IDENTIFIER,
  5651. (_, identifier) => toUpperCase(identifier)
  5652. );
  5653. };
  5654. function camelCase(input, options) {
  5655. if (!(typeof input === "string" || Array.isArray(input))) {
  5656. throw new TypeError("Expected the input to be `string | string[]`");
  5657. }
  5658. options = {
  5659. pascalCase: false,
  5660. preserveConsecutiveUppercase: false,
  5661. ...options
  5662. };
  5663. if (Array.isArray(input)) {
  5664. input = input.map((x) => x.trim()).filter((x) => x.length).join("-");
  5665. } else {
  5666. input = input.trim();
  5667. }
  5668. if (input.length === 0) {
  5669. return "";
  5670. }
  5671. const toLowerCase = options.locale === false ? (string) => string.toLowerCase() : (string) => string.toLocaleLowerCase(options.locale);
  5672. const toUpperCase = options.locale === false ? (string) => string.toUpperCase() : (string) => string.toLocaleUpperCase(options.locale);
  5673. if (input.length === 1) {
  5674. if (SEPARATORS.test(input)) {
  5675. return "";
  5676. }
  5677. return options.pascalCase ? toUpperCase(input) : toLowerCase(input);
  5678. }
  5679. const hasUpperCase = input !== toLowerCase(input);
  5680. if (hasUpperCase) {
  5681. input = preserveCamelCase(input, toLowerCase, toUpperCase, options.preserveConsecutiveUppercase);
  5682. }
  5683. input = input.replace(LEADING_SEPARATORS, "");
  5684. input = options.preserveConsecutiveUppercase ? preserveConsecutiveUppercase(input, toLowerCase) : toLowerCase(input);
  5685. if (options.pascalCase) {
  5686. input = toUpperCase(input.charAt(0)) + input.slice(1);
  5687. }
  5688. return postProcess(input, toUpperCase);
  5689. }
  5690. // src/cli/utils.js
  5691. import fs from "fs/promises";
  5692. import path from "path";
  5693. // node_modules/sdbm/index.js
  5694. function sdbm(string) {
  5695. let hash = 0;
  5696. for (let i = 0; i < string.length; i++) {
  5697. hash = string.charCodeAt(i) + (hash << 6) + (hash << 16) - hash;
  5698. }
  5699. return hash >>> 0;
  5700. }
  5701. // src/cli/utils.js
  5702. import { __internal as sharedWithCli2 } from "../index.mjs";
  5703. var printToScreen = console.log.bind(console);
  5704. function groupBy(array2, iteratee) {
  5705. const result = /* @__PURE__ */ Object.create(null);
  5706. for (const value of array2) {
  5707. const key = iteratee(value);
  5708. if (Array.isArray(result[key])) {
  5709. result[key].push(value);
  5710. } else {
  5711. result[key] = [value];
  5712. }
  5713. }
  5714. return result;
  5715. }
  5716. function pick(object, keys) {
  5717. const entries = keys.map((key) => [key, object[key]]);
  5718. return Object.fromEntries(entries);
  5719. }
  5720. function createHash(source) {
  5721. return String(sdbm(source));
  5722. }
  5723. async function statSafe(filePath) {
  5724. try {
  5725. return await fs.stat(filePath);
  5726. } catch (error) {
  5727. if (error.code !== "ENOENT") {
  5728. throw error;
  5729. }
  5730. }
  5731. }
  5732. async function lstatSafe(filePath) {
  5733. try {
  5734. return await fs.lstat(filePath);
  5735. } catch (error) {
  5736. if (error.code !== "ENOENT") {
  5737. throw error;
  5738. }
  5739. }
  5740. }
  5741. function isJson(value) {
  5742. try {
  5743. JSON.parse(value);
  5744. return true;
  5745. } catch {
  5746. return false;
  5747. }
  5748. }
  5749. var normalizeToPosix = path.sep === "\\" ? (filepath) => string_replace_all_default(
  5750. /* isOptionalObject*/
  5751. false,
  5752. filepath,
  5753. "\\",
  5754. "/"
  5755. ) : (filepath) => filepath;
  5756. var {
  5757. isNonEmptyArray,
  5758. partition,
  5759. omit
  5760. } = sharedWithCli2.utils;
  5761. // src/cli/options/minimist.js
  5762. var import_minimist = __toESM(require_minimist(), 1);
  5763. var PLACEHOLDER = null;
  5764. function minimistParse(args, options) {
  5765. const boolean = options.boolean ?? [];
  5766. const defaults = options.default ?? {};
  5767. const booleanWithoutDefault = boolean.filter((key) => !(key in defaults));
  5768. const newDefaults = {
  5769. ...defaults,
  5770. ...Object.fromEntries(
  5771. booleanWithoutDefault.map((key) => [key, PLACEHOLDER])
  5772. )
  5773. };
  5774. const parsed = (0, import_minimist.default)(args, { ...options, default: newDefaults });
  5775. return Object.fromEntries(
  5776. Object.entries(parsed).filter(([, value]) => value !== PLACEHOLDER)
  5777. );
  5778. }
  5779. // src/cli/options/create-minimist-options.js
  5780. function createMinimistOptions(detailedOptions) {
  5781. const booleanNames = [];
  5782. const stringNames = [];
  5783. const defaultValues = {};
  5784. for (const option of detailedOptions) {
  5785. const { name, alias, type } = option;
  5786. const names = type === "boolean" ? booleanNames : stringNames;
  5787. names.push(name);
  5788. if (alias) {
  5789. names.push(alias);
  5790. }
  5791. if (!option.deprecated && (!option.forwardToApi || name === "plugin") && option.default !== void 0) {
  5792. defaultValues[option.name] = option.default;
  5793. }
  5794. }
  5795. return {
  5796. // we use vnopts' AliasSchema to handle aliases for better error messages
  5797. alias: {},
  5798. boolean: booleanNames,
  5799. string: stringNames,
  5800. default: defaultValues
  5801. };
  5802. }
  5803. // node_modules/leven/index.js
  5804. var array = [];
  5805. var characterCodeCache = [];
  5806. function leven(first, second) {
  5807. if (first === second) {
  5808. return 0;
  5809. }
  5810. const swap = first;
  5811. if (first.length > second.length) {
  5812. first = second;
  5813. second = swap;
  5814. }
  5815. let firstLength = first.length;
  5816. let secondLength = second.length;
  5817. while (firstLength > 0 && first.charCodeAt(~-firstLength) === second.charCodeAt(~-secondLength)) {
  5818. firstLength--;
  5819. secondLength--;
  5820. }
  5821. let start = 0;
  5822. while (start < firstLength && first.charCodeAt(start) === second.charCodeAt(start)) {
  5823. start++;
  5824. }
  5825. firstLength -= start;
  5826. secondLength -= start;
  5827. if (firstLength === 0) {
  5828. return secondLength;
  5829. }
  5830. let bCharacterCode;
  5831. let result;
  5832. let temporary;
  5833. let temporary2;
  5834. let index = 0;
  5835. let index2 = 0;
  5836. while (index < firstLength) {
  5837. characterCodeCache[index] = first.charCodeAt(start + index);
  5838. array[index] = ++index;
  5839. }
  5840. while (index2 < secondLength) {
  5841. bCharacterCode = second.charCodeAt(start + index2);
  5842. temporary = index2++;
  5843. result = index2;
  5844. for (index = 0; index < firstLength; index++) {
  5845. temporary2 = bCharacterCode === characterCodeCache[index] ? temporary : temporary + 1;
  5846. temporary = array[index];
  5847. result = array[index] = temporary > result ? temporary2 > result ? result + 1 : temporary2 : temporary2 > temporary ? temporary + 1 : temporary2;
  5848. }
  5849. }
  5850. return result;
  5851. }
  5852. // src/cli/options/normalize-cli-options.js
  5853. var descriptor = {
  5854. key: (key) => key.length === 1 ? `-${key}` : `--${key}`,
  5855. value: (value) => vnopts.apiDescriptor.value(value),
  5856. pair: ({ key, value }) => value === false ? `--no-${key}` : value === true ? descriptor.key(key) : value === "" ? `${descriptor.key(key)} without an argument` : `${descriptor.key(key)}=${value}`
  5857. };
  5858. var _flags;
  5859. var FlagSchema = class extends vnopts.ChoiceSchema {
  5860. constructor({ name, flags }) {
  5861. super({ name, choices: flags });
  5862. __privateAdd(this, _flags, []);
  5863. __privateSet(this, _flags, [...flags].sort());
  5864. }
  5865. preprocess(value, utils) {
  5866. if (typeof value === "string" && value.length > 0 && !__privateGet(this, _flags).includes(value)) {
  5867. const suggestion = __privateGet(this, _flags).find((flag) => leven(flag, value) < 3);
  5868. if (suggestion) {
  5869. utils.logger.warn(
  5870. [
  5871. `Unknown flag ${source_default.yellow(utils.descriptor.value(value))},`,
  5872. `did you mean ${source_default.blue(utils.descriptor.value(suggestion))}?`
  5873. ].join(" ")
  5874. );
  5875. return suggestion;
  5876. }
  5877. }
  5878. return value;
  5879. }
  5880. expected() {
  5881. return "a flag";
  5882. }
  5883. };
  5884. _flags = new WeakMap();
  5885. function normalizeCliOptions(options, optionInfos, opts) {
  5886. return normalizeOptions(options, optionInfos, {
  5887. ...opts,
  5888. isCLI: true,
  5889. FlagSchema,
  5890. descriptor
  5891. });
  5892. }
  5893. var normalize_cli_options_default = normalizeCliOptions;
  5894. // src/cli/options/parse-cli-arguments.js
  5895. function parseArgv(rawArguments, detailedOptions, logger, keys) {
  5896. var _a;
  5897. const minimistOptions = createMinimistOptions(detailedOptions);
  5898. let argv = minimistParse(rawArguments, minimistOptions);
  5899. if (keys) {
  5900. detailedOptions = detailedOptions.filter(
  5901. (option) => keys.includes(option.name)
  5902. );
  5903. argv = pick(argv, keys);
  5904. }
  5905. const normalized = normalize_cli_options_default(argv, detailedOptions, { logger });
  5906. return {
  5907. ...Object.fromEntries(
  5908. Object.entries(normalized).map(([key, value]) => {
  5909. const option = detailedOptions.find(({ name }) => name === key) || {};
  5910. return [option.forwardToApi || camelCase(key), value];
  5911. })
  5912. ),
  5913. _: (_a = normalized._) == null ? void 0 : _a.map(String),
  5914. get __raw() {
  5915. return argv;
  5916. }
  5917. };
  5918. }
  5919. var { detailedOptions: detailedOptionsWithoutPlugins } = getContextOptionsWithoutPlugins();
  5920. function parseArgvWithoutPlugins(rawArguments, logger, keys) {
  5921. return parseArgv(
  5922. rawArguments,
  5923. detailedOptionsWithoutPlugins,
  5924. logger,
  5925. typeof keys === "string" ? [keys] : keys
  5926. );
  5927. }
  5928. // src/cli/context.js
  5929. var _stack;
  5930. var Context = class {
  5931. constructor({
  5932. rawArguments,
  5933. logger
  5934. }) {
  5935. __privateAdd(this, _stack, []);
  5936. this.rawArguments = rawArguments;
  5937. this.logger = logger;
  5938. }
  5939. async init() {
  5940. const {
  5941. rawArguments,
  5942. logger
  5943. } = this;
  5944. const {
  5945. plugins
  5946. } = parseArgvWithoutPlugins(rawArguments, logger, ["plugin"]);
  5947. await this.pushContextPlugins(plugins);
  5948. const argv = parseArgv(rawArguments, this.detailedOptions, logger);
  5949. this.argv = argv;
  5950. this.filePatterns = argv._;
  5951. }
  5952. /**
  5953. * @param {string[]} plugins
  5954. */
  5955. async pushContextPlugins(plugins) {
  5956. const options = await getContextOptions(plugins);
  5957. __privateGet(this, _stack).push(options);
  5958. Object.assign(this, options);
  5959. }
  5960. popContextPlugins() {
  5961. __privateGet(this, _stack).pop();
  5962. Object.assign(this, at_default(
  5963. /* isOptionalObject*/
  5964. false,
  5965. __privateGet(this, _stack),
  5966. -1
  5967. ));
  5968. }
  5969. // eslint-disable-next-line getter-return
  5970. get performanceTestFlag() {
  5971. const {
  5972. debugBenchmark,
  5973. debugRepeat
  5974. } = this.argv;
  5975. if (debugBenchmark) {
  5976. return {
  5977. name: "--debug-benchmark",
  5978. debugBenchmark: true
  5979. };
  5980. }
  5981. if (debugRepeat > 0) {
  5982. return {
  5983. name: "--debug-repeat",
  5984. debugRepeat
  5985. };
  5986. }
  5987. const {
  5988. PRETTIER_PERF_REPEAT
  5989. } = process.env;
  5990. if (PRETTIER_PERF_REPEAT && /^\d+$/.test(PRETTIER_PERF_REPEAT)) {
  5991. return {
  5992. name: "PRETTIER_PERF_REPEAT (environment variable)",
  5993. debugRepeat: Number(PRETTIER_PERF_REPEAT)
  5994. };
  5995. }
  5996. }
  5997. };
  5998. _stack = new WeakMap();
  5999. var context_default = Context;
  6000. // src/cli/constants.evaluate.js
  6001. var categoryOrder = [
  6002. "Output",
  6003. "Format",
  6004. "Config",
  6005. "Editor",
  6006. "Other"
  6007. ];
  6008. var usageSummary = "Usage: prettier [options] [file/dir/glob ...]\n\nBy default, output is written to stdout.\nStdin is read if it is piped to Prettier and no files are given.";
  6009. // src/cli/usage.js
  6010. var OPTION_USAGE_THRESHOLD = 25;
  6011. var CHOICE_USAGE_MARGIN = 3;
  6012. var CHOICE_USAGE_INDENTATION = 2;
  6013. function indent(str, spaces) {
  6014. return string_replace_all_default(
  6015. /* isOptionalObject*/
  6016. false,
  6017. str,
  6018. /^/gm,
  6019. " ".repeat(spaces)
  6020. );
  6021. }
  6022. function createDefaultValueDisplay(value) {
  6023. return Array.isArray(value) ? `[${value.map(createDefaultValueDisplay).join(", ")}]` : value;
  6024. }
  6025. function getOptionDefaultValue(context, optionName) {
  6026. var _a;
  6027. const option = context.detailedOptions.find(({
  6028. name
  6029. }) => name === optionName);
  6030. if ((option == null ? void 0 : option.default) !== void 0) {
  6031. return option.default;
  6032. }
  6033. const optionCamelName = camelCase(optionName);
  6034. return formatOptionsHiddenDefaults[optionCamelName] ?? ((_a = context.supportOptions.find((option2) => !option2.deprecated && option2.name === optionCamelName)) == null ? void 0 : _a.default);
  6035. }
  6036. function createOptionUsageHeader(option) {
  6037. const name = `--${option.name}`;
  6038. const alias = option.alias ? `-${option.alias},` : null;
  6039. const type = createOptionUsageType(option);
  6040. return [alias, name, type].filter(Boolean).join(" ");
  6041. }
  6042. function createOptionUsageRow(header, content, threshold) {
  6043. const separator = header.length >= threshold ? `
  6044. ${" ".repeat(threshold)}` : " ".repeat(threshold - header.length);
  6045. const description = string_replace_all_default(
  6046. /* isOptionalObject*/
  6047. false,
  6048. content,
  6049. "\n",
  6050. `
  6051. ${" ".repeat(threshold)}`
  6052. );
  6053. return `${header}${separator}${description}`;
  6054. }
  6055. function createOptionUsageType(option) {
  6056. switch (option.type) {
  6057. case "boolean":
  6058. return null;
  6059. case "choice":
  6060. return `<${option.choices.filter((choice) => !choice.deprecated).map((choice) => choice.value).join("|")}>`;
  6061. default:
  6062. return `<${option.type}>`;
  6063. }
  6064. }
  6065. function createChoiceUsages(choices, margin, indentation) {
  6066. const activeChoices = choices.filter((choice) => !choice.deprecated);
  6067. const threshold = Math.max(0, ...activeChoices.map((choice) => choice.value.length)) + margin;
  6068. return activeChoices.map((choice) => indent(createOptionUsageRow(choice.value, choice.description, threshold), indentation));
  6069. }
  6070. function createOptionUsage(context, option, threshold) {
  6071. const header = createOptionUsageHeader(option);
  6072. const optionDefaultValue = getOptionDefaultValue(context, option.name);
  6073. return createOptionUsageRow(header, `${option.description}${optionDefaultValue === void 0 ? "" : `
  6074. Defaults to ${createDefaultValueDisplay(optionDefaultValue)}.`}`, threshold);
  6075. }
  6076. function getOptionsWithOpposites(options) {
  6077. const optionsWithOpposites = options.map((option) => [option.description ? option : null, option.oppositeDescription ? {
  6078. ...option,
  6079. name: `no-${option.name}`,
  6080. type: "boolean",
  6081. description: option.oppositeDescription
  6082. } : null]);
  6083. return optionsWithOpposites.flat().filter(Boolean);
  6084. }
  6085. function createUsage(context) {
  6086. const sortedOptions = context.detailedOptions.sort((optionA, optionB) => optionA.name.localeCompare(optionB.name));
  6087. const options = getOptionsWithOpposites(sortedOptions).filter(
  6088. // remove unnecessary option (e.g. `semi`, `color`, etc.), which is only used for --help <flag>
  6089. (option) => !(option.type === "boolean" && option.oppositeDescription && !option.name.startsWith("no-"))
  6090. );
  6091. const groupedOptions = groupBy(options, (option) => option.category);
  6092. const firstCategories = categoryOrder.slice(0, -1);
  6093. const lastCategories = categoryOrder.slice(-1);
  6094. const restCategories = Object.keys(groupedOptions).filter((category) => !categoryOrder.includes(category));
  6095. const allCategories = [...firstCategories, ...restCategories, ...lastCategories];
  6096. const optionsUsage = allCategories.map((category) => {
  6097. const categoryOptions = groupedOptions[category].map((option) => createOptionUsage(context, option, OPTION_USAGE_THRESHOLD)).join("\n");
  6098. return `${category} options:
  6099. ${indent(categoryOptions, 2)}`;
  6100. });
  6101. return [usageSummary, ...optionsUsage, ""].join("\n\n");
  6102. }
  6103. function createPluginDefaults(pluginDefaults) {
  6104. if (!pluginDefaults || Object.keys(pluginDefaults).length === 0) {
  6105. return "";
  6106. }
  6107. const defaults = Object.entries(pluginDefaults).sort(([pluginNameA], [pluginNameB]) => pluginNameA.localeCompare(pluginNameB)).map(([plugin, value]) => `* ${plugin}: ${createDefaultValueDisplay(value)}`).join("\n");
  6108. return `
  6109. Plugin defaults:
  6110. ${defaults}`;
  6111. }
  6112. function createDetailedUsage(context, flag) {
  6113. const option = getOptionsWithOpposites(context.detailedOptions).find((option2) => option2.name === flag || option2.alias === flag);
  6114. const header = createOptionUsageHeader(option);
  6115. const description = `
  6116. ${indent(option.description, 2)}`;
  6117. const choices = option.type !== "choice" ? "" : `
  6118. Valid options:
  6119. ${createChoiceUsages(option.choices, CHOICE_USAGE_MARGIN, CHOICE_USAGE_INDENTATION).join("\n")}`;
  6120. const optionDefaultValue = getOptionDefaultValue(context, option.name);
  6121. const defaults = optionDefaultValue !== void 0 ? `
  6122. Default: ${createDefaultValueDisplay(optionDefaultValue)}` : "";
  6123. const pluginDefaults = createPluginDefaults(option.pluginDefaults);
  6124. return `${header}${description}${choices}${defaults}${pluginDefaults}`;
  6125. }
  6126. // src/cli/format.js
  6127. import fs5 from "fs/promises";
  6128. import path8 from "path";
  6129. var import_diff = __toESM(require_create(), 1);
  6130. import * as prettier from "../index.mjs";
  6131. import mockable2 from "./internal.mjs";
  6132. // src/cli/expand-patterns.js
  6133. import path2 from "path";
  6134. async function* expandPatterns(context) {
  6135. const seen = /* @__PURE__ */ new Set();
  6136. let noResults = true;
  6137. for await (const pathOrError of expandPatternsInternal(context)) {
  6138. noResults = false;
  6139. if (typeof pathOrError !== "string") {
  6140. yield pathOrError;
  6141. continue;
  6142. }
  6143. const fileName = path2.resolve(pathOrError);
  6144. if (seen.has(fileName)) {
  6145. continue;
  6146. }
  6147. seen.add(fileName);
  6148. yield fileName;
  6149. }
  6150. if (noResults && context.argv.errorOnUnmatchedPattern !== false) {
  6151. yield {
  6152. error: `No matching files. Patterns: ${context.filePatterns.join(" ")}`
  6153. };
  6154. }
  6155. }
  6156. async function* expandPatternsInternal(context) {
  6157. const silentlyIgnoredDirs = [".git", ".sl", ".svn", ".hg"];
  6158. if (context.argv.withNodeModules !== true) {
  6159. silentlyIgnoredDirs.push("node_modules");
  6160. }
  6161. const globOptions = {
  6162. dot: true,
  6163. ignore: silentlyIgnoredDirs.map((dir) => "**/" + dir),
  6164. followSymbolicLinks: false
  6165. };
  6166. let supportedFilesGlob;
  6167. const cwd2 = process.cwd();
  6168. const entries = [];
  6169. for (const pattern of context.filePatterns) {
  6170. const absolutePath = path2.resolve(cwd2, pattern);
  6171. if (containsIgnoredPathSegment(absolutePath, cwd2, silentlyIgnoredDirs)) {
  6172. continue;
  6173. }
  6174. const stat = await lstatSafe(absolutePath);
  6175. if (stat) {
  6176. if (stat.isSymbolicLink()) {
  6177. yield {
  6178. error: `Explicitly specified pattern "${pattern}" is a symbolic link.`
  6179. };
  6180. } else if (stat.isFile()) {
  6181. entries.push({
  6182. type: "file",
  6183. glob: escapePathForGlob(fixWindowsSlashes(pattern)),
  6184. input: pattern
  6185. });
  6186. } else if (stat.isDirectory()) {
  6187. const relativePath = path2.relative(cwd2, absolutePath) || ".";
  6188. const prefix = escapePathForGlob(fixWindowsSlashes(relativePath));
  6189. entries.push({
  6190. type: "dir",
  6191. glob: getSupportedFilesGlob().map((pattern2) => `${prefix}/**/${pattern2}`),
  6192. input: pattern
  6193. });
  6194. }
  6195. } else if (pattern[0] === "!") {
  6196. globOptions.ignore.push(fixWindowsSlashes(pattern.slice(1)));
  6197. } else {
  6198. entries.push({
  6199. type: "glob",
  6200. glob: fixWindowsSlashes(pattern),
  6201. input: pattern
  6202. });
  6203. }
  6204. }
  6205. for (const {
  6206. type,
  6207. glob,
  6208. input
  6209. } of entries) {
  6210. let result;
  6211. try {
  6212. result = await fastGlob(glob, globOptions);
  6213. } catch ({
  6214. message
  6215. }) {
  6216. yield {
  6217. error: `${errorMessages.globError[type]}: "${input}".
  6218. ${message}`
  6219. };
  6220. continue;
  6221. }
  6222. if (result.length === 0) {
  6223. if (context.argv.errorOnUnmatchedPattern !== false) {
  6224. yield {
  6225. error: `${errorMessages.emptyResults[type]}: "${input}".`
  6226. };
  6227. }
  6228. } else {
  6229. yield* sortPaths(result);
  6230. }
  6231. }
  6232. function getSupportedFilesGlob() {
  6233. supportedFilesGlob ?? (supportedFilesGlob = [...getSupportedFilesGlobWithoutCache()]);
  6234. return supportedFilesGlob;
  6235. }
  6236. function* getSupportedFilesGlobWithoutCache() {
  6237. for (const {
  6238. extensions = [],
  6239. filenames = []
  6240. } of context.languages) {
  6241. yield* filenames;
  6242. for (const extension of extensions) {
  6243. yield `*${extension.startsWith(".") ? extension : `.${extension}`}`;
  6244. }
  6245. }
  6246. }
  6247. }
  6248. var errorMessages = {
  6249. globError: {
  6250. file: "Unable to resolve file",
  6251. dir: "Unable to expand directory",
  6252. glob: "Unable to expand glob pattern"
  6253. },
  6254. emptyResults: {
  6255. file: "Explicitly specified file was ignored due to negative glob patterns",
  6256. dir: "No supported files were found in the directory",
  6257. glob: "No files matching the pattern were found"
  6258. }
  6259. };
  6260. function containsIgnoredPathSegment(absolutePath, cwd2, ignoredDirectories) {
  6261. return path2.relative(cwd2, absolutePath).split(path2.sep).some((dir) => ignoredDirectories.includes(dir));
  6262. }
  6263. function sortPaths(paths) {
  6264. return paths.sort((a, b) => a.localeCompare(b));
  6265. }
  6266. function escapePathForGlob(path10) {
  6267. return string_replace_all_default(
  6268. /* isOptionalObject*/
  6269. false,
  6270. string_replace_all_default(
  6271. /* isOptionalObject*/
  6272. false,
  6273. fastGlob.escapePath(
  6274. string_replace_all_default(
  6275. /* isOptionalObject*/
  6276. false,
  6277. path10,
  6278. "\\",
  6279. "\0"
  6280. )
  6281. // Workaround for fast-glob#262 (part 1)
  6282. ),
  6283. "\\!",
  6284. "@(!)"
  6285. ),
  6286. "\0",
  6287. "@(\\\\)"
  6288. );
  6289. }
  6290. var fixWindowsSlashes = normalizeToPosix;
  6291. // src/cli/options/get-options-for-file.js
  6292. var import_dashify2 = __toESM(require_dashify(), 1);
  6293. import { resolveConfig } from "../index.mjs";
  6294. function getOptions(argv, detailedOptions) {
  6295. return Object.fromEntries(
  6296. detailedOptions.filter(({ forwardToApi }) => forwardToApi).map(({ forwardToApi, name }) => [forwardToApi, argv[name]])
  6297. );
  6298. }
  6299. function cliifyOptions(object, apiDetailedOptionMap) {
  6300. return Object.fromEntries(
  6301. Object.entries(object || {}).map(([key, value]) => {
  6302. const apiOption = apiDetailedOptionMap[key];
  6303. const cliKey = apiOption ? apiOption.name : key;
  6304. return [(0, import_dashify2.default)(cliKey), value];
  6305. })
  6306. );
  6307. }
  6308. function createApiDetailedOptionMap(detailedOptions) {
  6309. return Object.fromEntries(
  6310. detailedOptions.filter(
  6311. (option) => option.forwardToApi && option.forwardToApi !== option.name
  6312. ).map((option) => [option.forwardToApi, option])
  6313. );
  6314. }
  6315. function parseArgsToOptions(context, overrideDefaults) {
  6316. const minimistOptions = createMinimistOptions(context.detailedOptions);
  6317. const apiDetailedOptionMap = createApiDetailedOptionMap(
  6318. context.detailedOptions
  6319. );
  6320. return getOptions(
  6321. normalize_cli_options_default(
  6322. minimistParse(context.rawArguments, {
  6323. string: minimistOptions.string,
  6324. boolean: minimistOptions.boolean,
  6325. default: cliifyOptions(overrideDefaults, apiDetailedOptionMap)
  6326. }),
  6327. context.detailedOptions,
  6328. { logger: false }
  6329. ),
  6330. context.detailedOptions
  6331. );
  6332. }
  6333. async function getOptionsOrDie(context, filePath) {
  6334. try {
  6335. if (context.argv.config === false) {
  6336. context.logger.debug(
  6337. "'--no-config' option found, skip loading config file."
  6338. );
  6339. return null;
  6340. }
  6341. context.logger.debug(
  6342. context.argv.config ? `load config file from '${context.argv.config}'` : `resolve config from '${filePath}'`
  6343. );
  6344. const options = await resolveConfig(filePath, {
  6345. editorconfig: context.argv.editorconfig,
  6346. config: context.argv.config
  6347. });
  6348. context.logger.debug("loaded options `" + JSON.stringify(options) + "`");
  6349. return options;
  6350. } catch (error) {
  6351. context.logger.error(
  6352. `Invalid configuration for file "${filePath}":
  6353. ` + error.message
  6354. );
  6355. process.exit(2);
  6356. }
  6357. }
  6358. function applyConfigPrecedence(context, options) {
  6359. try {
  6360. switch (context.argv.configPrecedence) {
  6361. case "cli-override":
  6362. return parseArgsToOptions(context, options);
  6363. case "file-override":
  6364. return { ...parseArgsToOptions(context), ...options };
  6365. case "prefer-file":
  6366. return options || parseArgsToOptions(context);
  6367. }
  6368. } catch (error) {
  6369. context.logger.error(error.toString());
  6370. process.exit(2);
  6371. }
  6372. }
  6373. async function getOptionsForFile(context, filepath) {
  6374. const options = await getOptionsOrDie(context, filepath);
  6375. const hasPlugins = options == null ? void 0 : options.plugins;
  6376. if (hasPlugins) {
  6377. await context.pushContextPlugins(options.plugins);
  6378. }
  6379. const appliedOptions = {
  6380. filepath,
  6381. ...applyConfigPrecedence(
  6382. context,
  6383. options && normalizeOptions(options, context.supportOptions, {
  6384. logger: context.logger
  6385. })
  6386. )
  6387. };
  6388. context.logger.debug(
  6389. `applied config-precedence (${context.argv.configPrecedence}): ${JSON.stringify(appliedOptions)}`
  6390. );
  6391. if (hasPlugins) {
  6392. context.popContextPlugins();
  6393. }
  6394. return appliedOptions;
  6395. }
  6396. var get_options_for_file_default = getOptionsForFile;
  6397. // src/cli/is-tty.js
  6398. import mockable from "./internal.mjs";
  6399. function isTTY() {
  6400. return process.stdout.isTTY && !mockable.isCI();
  6401. }
  6402. // src/cli/find-cache-file.js
  6403. import fs4 from "fs/promises";
  6404. import os2 from "os";
  6405. import path7 from "path";
  6406. // node_modules/find-cache-dir/index.js
  6407. var import_common_path_prefix = __toESM(require_common_path_prefix(), 1);
  6408. import process4 from "process";
  6409. import path6 from "path";
  6410. import fs3 from "fs";
  6411. // node_modules/pkg-dir/index.js
  6412. import path5 from "path";
  6413. // node_modules/pkg-dir/node_modules/find-up/index.js
  6414. import path4 from "path";
  6415. import { fileURLToPath as fileURLToPath2 } from "url";
  6416. // node_modules/pkg-dir/node_modules/locate-path/index.js
  6417. import process3 from "process";
  6418. import path3 from "path";
  6419. import fs2, { promises as fsPromises } from "fs";
  6420. import { fileURLToPath } from "url";
  6421. // node_modules/pkg-dir/node_modules/yocto-queue/index.js
  6422. var Node = class {
  6423. value;
  6424. next;
  6425. constructor(value) {
  6426. this.value = value;
  6427. }
  6428. };
  6429. var _head, _tail, _size;
  6430. var Queue = class {
  6431. constructor() {
  6432. __privateAdd(this, _head, void 0);
  6433. __privateAdd(this, _tail, void 0);
  6434. __privateAdd(this, _size, void 0);
  6435. this.clear();
  6436. }
  6437. enqueue(value) {
  6438. const node = new Node(value);
  6439. if (__privateGet(this, _head)) {
  6440. __privateGet(this, _tail).next = node;
  6441. __privateSet(this, _tail, node);
  6442. } else {
  6443. __privateSet(this, _head, node);
  6444. __privateSet(this, _tail, node);
  6445. }
  6446. __privateWrapper(this, _size)._++;
  6447. }
  6448. dequeue() {
  6449. const current = __privateGet(this, _head);
  6450. if (!current) {
  6451. return;
  6452. }
  6453. __privateSet(this, _head, __privateGet(this, _head).next);
  6454. __privateWrapper(this, _size)._--;
  6455. return current.value;
  6456. }
  6457. clear() {
  6458. __privateSet(this, _head, void 0);
  6459. __privateSet(this, _tail, void 0);
  6460. __privateSet(this, _size, 0);
  6461. }
  6462. get size() {
  6463. return __privateGet(this, _size);
  6464. }
  6465. *[Symbol.iterator]() {
  6466. let current = __privateGet(this, _head);
  6467. while (current) {
  6468. yield current.value;
  6469. current = current.next;
  6470. }
  6471. }
  6472. };
  6473. _head = new WeakMap();
  6474. _tail = new WeakMap();
  6475. _size = new WeakMap();
  6476. // node_modules/pkg-dir/node_modules/locate-path/index.js
  6477. var typeMappings = {
  6478. directory: "isDirectory",
  6479. file: "isFile"
  6480. };
  6481. function checkType(type) {
  6482. if (Object.hasOwnProperty.call(typeMappings, type)) {
  6483. return;
  6484. }
  6485. throw new Error(`Invalid type specified: ${type}`);
  6486. }
  6487. var matchType = (type, stat) => stat[typeMappings[type]]();
  6488. var toPath = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
  6489. function locatePathSync(paths, {
  6490. cwd: cwd2 = process3.cwd(),
  6491. type = "file",
  6492. allowSymlinks = true
  6493. } = {}) {
  6494. checkType(type);
  6495. cwd2 = toPath(cwd2);
  6496. const statFunction = allowSymlinks ? fs2.statSync : fs2.lstatSync;
  6497. for (const path_ of paths) {
  6498. try {
  6499. const stat = statFunction(path3.resolve(cwd2, path_), {
  6500. throwIfNoEntry: false
  6501. });
  6502. if (!stat) {
  6503. continue;
  6504. }
  6505. if (matchType(type, stat)) {
  6506. return path_;
  6507. }
  6508. } catch {
  6509. }
  6510. }
  6511. }
  6512. // node_modules/pkg-dir/node_modules/find-up/index.js
  6513. var toPath2 = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath2(urlOrPath) : urlOrPath;
  6514. var findUpStop = Symbol("findUpStop");
  6515. function findUpMultipleSync(name, options = {}) {
  6516. let directory = path4.resolve(toPath2(options.cwd) || "");
  6517. const { root } = path4.parse(directory);
  6518. const stopAt = options.stopAt || root;
  6519. const limit = options.limit || Number.POSITIVE_INFINITY;
  6520. const paths = [name].flat();
  6521. const runMatcher = (locateOptions) => {
  6522. if (typeof name !== "function") {
  6523. return locatePathSync(paths, locateOptions);
  6524. }
  6525. const foundPath = name(locateOptions.cwd);
  6526. if (typeof foundPath === "string") {
  6527. return locatePathSync([foundPath], locateOptions);
  6528. }
  6529. return foundPath;
  6530. };
  6531. const matches = [];
  6532. while (true) {
  6533. const foundPath = runMatcher({ ...options, cwd: directory });
  6534. if (foundPath === findUpStop) {
  6535. break;
  6536. }
  6537. if (foundPath) {
  6538. matches.push(path4.resolve(directory, foundPath));
  6539. }
  6540. if (directory === stopAt || matches.length >= limit) {
  6541. break;
  6542. }
  6543. directory = path4.dirname(directory);
  6544. }
  6545. return matches;
  6546. }
  6547. function findUpSync(name, options = {}) {
  6548. const matches = findUpMultipleSync(name, { ...options, limit: 1 });
  6549. return matches[0];
  6550. }
  6551. // node_modules/pkg-dir/index.js
  6552. function packageDirectorySync({ cwd: cwd2 } = {}) {
  6553. const filePath = findUpSync("package.json", { cwd: cwd2 });
  6554. return filePath && path5.dirname(filePath);
  6555. }
  6556. // node_modules/find-cache-dir/index.js
  6557. var { env: env2, cwd } = process4;
  6558. var isWritable = (path10) => {
  6559. try {
  6560. fs3.accessSync(path10, fs3.constants.W_OK);
  6561. return true;
  6562. } catch {
  6563. return false;
  6564. }
  6565. };
  6566. function useDirectory(directory, options) {
  6567. if (options.create) {
  6568. fs3.mkdirSync(directory, { recursive: true });
  6569. }
  6570. if (options.thunk) {
  6571. return (...arguments_) => path6.join(directory, ...arguments_);
  6572. }
  6573. return directory;
  6574. }
  6575. function getNodeModuleDirectory(directory) {
  6576. const nodeModules = path6.join(directory, "node_modules");
  6577. if (!isWritable(nodeModules) && (fs3.existsSync(nodeModules) || !isWritable(path6.join(directory)))) {
  6578. return;
  6579. }
  6580. return nodeModules;
  6581. }
  6582. function findCacheDirectory(options = {}) {
  6583. if (env2.CACHE_DIR && !["true", "false", "1", "0"].includes(env2.CACHE_DIR)) {
  6584. return useDirectory(path6.join(env2.CACHE_DIR, options.name), options);
  6585. }
  6586. let { cwd: directory = cwd() } = options;
  6587. if (options.files) {
  6588. directory = (0, import_common_path_prefix.default)(options.files.map((file) => path6.resolve(directory, file)));
  6589. }
  6590. directory = packageDirectorySync({ cwd: directory });
  6591. if (!directory) {
  6592. return;
  6593. }
  6594. const nodeModules = getNodeModuleDirectory(directory);
  6595. if (!nodeModules) {
  6596. return;
  6597. }
  6598. return useDirectory(path6.join(directory, "node_modules", ".cache", options.name), options);
  6599. }
  6600. // src/cli/find-cache-file.js
  6601. function findDefaultCacheFile() {
  6602. const cacheDir = findCacheDirectory({ name: "prettier", create: true }) || os2.tmpdir();
  6603. const cacheFilePath = path7.join(cacheDir, ".prettier-cache");
  6604. return cacheFilePath;
  6605. }
  6606. async function findCacheFileFromOption(cacheLocation) {
  6607. const cacheFile = path7.resolve(cacheLocation);
  6608. const stat = await statSafe(cacheFile);
  6609. if (stat) {
  6610. if (stat.isDirectory()) {
  6611. throw new Error(
  6612. `Resolved --cache-location '${cacheFile}' is a directory`
  6613. );
  6614. }
  6615. const data = await fs4.readFile(cacheFile, "utf8");
  6616. if (!isJson(data)) {
  6617. throw new Error(`'${cacheFile}' isn't a valid JSON file`);
  6618. }
  6619. }
  6620. return cacheFile;
  6621. }
  6622. async function findCacheFile(cacheLocation) {
  6623. if (!cacheLocation) {
  6624. return findDefaultCacheFile();
  6625. }
  6626. const cacheFile = await findCacheFileFromOption(cacheLocation);
  6627. return cacheFile;
  6628. }
  6629. var find_cache_file_default = findCacheFile;
  6630. // src/cli/format-results-cache.js
  6631. var import_file_entry_cache = __toESM(require_cache2(), 1);
  6632. var import_fast_json_stable_stringify = __toESM(require_fast_json_stable_stringify(), 1);
  6633. import { version as prettierVersion } from "../index.mjs";
  6634. var optionsHashCache = /* @__PURE__ */ new WeakMap();
  6635. var nodeVersion = process.version;
  6636. function getHashOfOptions(options) {
  6637. if (optionsHashCache.has(options)) {
  6638. return optionsHashCache.get(options);
  6639. }
  6640. const hash = createHash(
  6641. `${prettierVersion}_${nodeVersion}_${(0, import_fast_json_stable_stringify.default)(options)}`
  6642. );
  6643. optionsHashCache.set(options, hash);
  6644. return hash;
  6645. }
  6646. function getMetadataFromFileDescriptor(fileDescriptor) {
  6647. return fileDescriptor.meta;
  6648. }
  6649. var _fileEntryCache;
  6650. var FormatResultsCache = class {
  6651. /**
  6652. * @param {string} cacheFileLocation The path of cache file location. (default: `node_modules/.cache/prettier/.prettier-cache`)
  6653. * @param {string} cacheStrategy
  6654. */
  6655. constructor(cacheFileLocation, cacheStrategy) {
  6656. __privateAdd(this, _fileEntryCache, void 0);
  6657. const useChecksum = cacheStrategy === "content";
  6658. __privateSet(this, _fileEntryCache, import_file_entry_cache.default.create(
  6659. /* cacheId */
  6660. cacheFileLocation,
  6661. /* directory */
  6662. void 0,
  6663. useChecksum
  6664. ));
  6665. }
  6666. /**
  6667. * @param {string} filePath
  6668. * @param {any} options
  6669. */
  6670. existsAvailableFormatResultsCache(filePath, options) {
  6671. const fileDescriptor = __privateGet(this, _fileEntryCache).getFileDescriptor(filePath);
  6672. if (fileDescriptor.notFound) {
  6673. return false;
  6674. }
  6675. const hashOfOptions = getHashOfOptions(options);
  6676. const meta = getMetadataFromFileDescriptor(fileDescriptor);
  6677. const changed = fileDescriptor.changed || meta.hashOfOptions !== hashOfOptions;
  6678. return !changed;
  6679. }
  6680. /**
  6681. * @param {string} filePath
  6682. * @param {any} options
  6683. */
  6684. setFormatResultsCache(filePath, options) {
  6685. const fileDescriptor = __privateGet(this, _fileEntryCache).getFileDescriptor(filePath);
  6686. const meta = getMetadataFromFileDescriptor(fileDescriptor);
  6687. if (fileDescriptor && !fileDescriptor.notFound) {
  6688. meta.hashOfOptions = getHashOfOptions(options);
  6689. }
  6690. }
  6691. /**
  6692. * @param {string} filePath
  6693. */
  6694. removeFormatResultsCache(filePath) {
  6695. __privateGet(this, _fileEntryCache).removeEntry(filePath);
  6696. }
  6697. reconcile() {
  6698. __privateGet(this, _fileEntryCache).reconcile();
  6699. }
  6700. };
  6701. _fileEntryCache = new WeakMap();
  6702. var format_results_cache_default = FormatResultsCache;
  6703. // src/cli/format.js
  6704. var { getStdin, writeFormattedFile } = mockable2;
  6705. function diff(a, b) {
  6706. return (0, import_diff.createTwoFilesPatch)("", "", a, b, "", "", { context: 2 });
  6707. }
  6708. var DebugError = class extends Error {
  6709. name = "DebugError";
  6710. };
  6711. function handleError(context, filename, error, printedFilename) {
  6712. const errorIsUndefinedParseError = error instanceof errors.UndefinedParserError;
  6713. if (printedFilename) {
  6714. if ((context.argv.write || context.argv.ignoreUnknown) && errorIsUndefinedParseError) {
  6715. printedFilename.clear();
  6716. } else {
  6717. process.stdout.write("\n");
  6718. }
  6719. }
  6720. if (errorIsUndefinedParseError) {
  6721. if (context.argv.ignoreUnknown) {
  6722. return;
  6723. }
  6724. if (!context.argv.check && !context.argv.listDifferent) {
  6725. process.exitCode = 2;
  6726. }
  6727. context.logger.error(error.message);
  6728. return;
  6729. }
  6730. const isParseError = Boolean(error == null ? void 0 : error.loc);
  6731. const isValidationError = /^Invalid \S+ value\./.test(error == null ? void 0 : error.message);
  6732. if (isParseError) {
  6733. context.logger.error(`${filename}: ${String(error)}`);
  6734. } else if (isValidationError || error instanceof errors.ConfigError) {
  6735. context.logger.error(error.message);
  6736. process.exit(1);
  6737. } else if (error instanceof DebugError) {
  6738. context.logger.error(`${filename}: ${error.message}`);
  6739. } else {
  6740. context.logger.error(filename + ": " + (error.stack || error));
  6741. }
  6742. process.exitCode = 2;
  6743. }
  6744. function writeOutput(context, result, options) {
  6745. process.stdout.write(
  6746. context.argv.debugCheck ? result.filepath : result.formatted
  6747. );
  6748. if (options && options.cursorOffset >= 0) {
  6749. process.stderr.write(result.cursorOffset + "\n");
  6750. }
  6751. }
  6752. async function listDifferent(context, input, options, filename) {
  6753. if (!context.argv.check && !context.argv.listDifferent) {
  6754. return;
  6755. }
  6756. try {
  6757. if (!await prettier.check(input, options) && !context.argv.write) {
  6758. context.logger.log(filename);
  6759. process.exitCode = 1;
  6760. }
  6761. } catch (error) {
  6762. context.logger.error(error.message);
  6763. }
  6764. return true;
  6765. }
  6766. async function format2(context, input, opt) {
  6767. if (context.argv.debugPrintDoc) {
  6768. const doc = await prettier.__debug.printToDoc(input, opt);
  6769. return { formatted: await prettier.__debug.formatDoc(doc) + "\n" };
  6770. }
  6771. if (context.argv.debugPrintComments) {
  6772. return {
  6773. formatted: await prettier.format(
  6774. JSON.stringify(
  6775. (await prettier.formatWithCursor(input, opt)).comments || []
  6776. ),
  6777. { parser: "json" }
  6778. )
  6779. };
  6780. }
  6781. if (context.argv.debugPrintAst) {
  6782. const { ast } = await prettier.__debug.parse(input, opt);
  6783. return {
  6784. formatted: JSON.stringify(ast)
  6785. };
  6786. }
  6787. if (context.argv.debugCheck) {
  6788. const pp = await prettier.format(input, opt);
  6789. const pppp = await prettier.format(pp, opt);
  6790. if (pp !== pppp) {
  6791. throw new DebugError(
  6792. "prettier(input) !== prettier(prettier(input))\n" + diff(pp, pppp)
  6793. );
  6794. } else {
  6795. const stringify4 = (obj) => JSON.stringify(obj, null, 2);
  6796. const ast = stringify4(
  6797. (await prettier.__debug.parse(input, opt, { massage: true })).ast
  6798. );
  6799. const past = stringify4(
  6800. (await prettier.__debug.parse(pp, opt, { massage: true })).ast
  6801. );
  6802. if (ast !== past) {
  6803. const MAX_AST_SIZE = 2097152;
  6804. const astDiff = ast.length > MAX_AST_SIZE || past.length > MAX_AST_SIZE ? "AST diff too large to render" : diff(ast, past);
  6805. throw new DebugError(
  6806. "ast(input) !== ast(prettier(input))\n" + astDiff + "\n" + diff(input, pp)
  6807. );
  6808. }
  6809. }
  6810. return { formatted: pp, filepath: opt.filepath || "(stdin)\n" };
  6811. }
  6812. const { performanceTestFlag } = context;
  6813. if (performanceTestFlag == null ? void 0 : performanceTestFlag.debugBenchmark) {
  6814. let benchmark;
  6815. try {
  6816. ({ default: benchmark } = await import("benchmark"));
  6817. } catch {
  6818. context.logger.debug(
  6819. "'--debug-benchmark' requires the 'benchmark' package to be installed."
  6820. );
  6821. process.exit(2);
  6822. }
  6823. context.logger.debug(
  6824. "'--debug-benchmark' option found, measuring formatWithCursor with 'benchmark' module."
  6825. );
  6826. const suite = new benchmark.Suite();
  6827. suite.add("format", {
  6828. defer: true,
  6829. async fn(deferred) {
  6830. await prettier.formatWithCursor(input, opt);
  6831. deferred.resolve();
  6832. }
  6833. });
  6834. const result = await new Promise((resolve) => {
  6835. suite.on("complete", (event) => {
  6836. resolve({
  6837. benchmark: String(event.target),
  6838. hz: event.target.hz,
  6839. ms: event.target.times.cycle * 1e3
  6840. });
  6841. }).run({ async: false });
  6842. });
  6843. context.logger.debug(
  6844. "'--debug-benchmark' measurements for formatWithCursor: " + JSON.stringify(result, null, 2)
  6845. );
  6846. } else if (performanceTestFlag == null ? void 0 : performanceTestFlag.debugRepeat) {
  6847. const repeat = performanceTestFlag.debugRepeat;
  6848. context.logger.debug(
  6849. `'${performanceTestFlag.name}' found, running formatWithCursor ${repeat} times.`
  6850. );
  6851. let totalMs = 0;
  6852. for (let i = 0; i < repeat; ++i) {
  6853. const startMs = Date.now();
  6854. await prettier.formatWithCursor(input, opt);
  6855. totalMs += Date.now() - startMs;
  6856. }
  6857. const averageMs = totalMs / repeat;
  6858. const results = {
  6859. repeat,
  6860. hz: 1e3 / averageMs,
  6861. ms: averageMs
  6862. };
  6863. context.logger.debug(
  6864. `'${performanceTestFlag.name}' measurements for formatWithCursor: ${JSON.stringify(
  6865. results,
  6866. null,
  6867. 2
  6868. )}`
  6869. );
  6870. }
  6871. return prettier.formatWithCursor(input, opt);
  6872. }
  6873. async function createIsIgnoredFromContextOrDie(context) {
  6874. try {
  6875. return await createIsIgnoredFunction(
  6876. context.argv.ignorePath,
  6877. context.argv.withNodeModules
  6878. );
  6879. } catch (e) {
  6880. context.logger.error(e.message);
  6881. process.exit(2);
  6882. }
  6883. }
  6884. async function formatStdin(context) {
  6885. const { filepath } = context.argv;
  6886. try {
  6887. const input = await getStdin();
  6888. let isFileIgnored = false;
  6889. if (filepath) {
  6890. const isIgnored = await createIsIgnoredFromContextOrDie(context);
  6891. isFileIgnored = isIgnored(filepath);
  6892. }
  6893. if (isFileIgnored) {
  6894. writeOutput(context, { formatted: input });
  6895. return;
  6896. }
  6897. const options = await get_options_for_file_default(
  6898. context,
  6899. filepath ? path8.resolve(process.cwd(), filepath) : process.cwd()
  6900. );
  6901. if (await listDifferent(context, input, options, "(stdin)")) {
  6902. return;
  6903. }
  6904. const formatted = await format2(context, input, options);
  6905. const { performanceTestFlag } = context;
  6906. if (performanceTestFlag) {
  6907. context.logger.log(
  6908. `'${performanceTestFlag.name}' option found, skipped print code to screen.`
  6909. );
  6910. return;
  6911. }
  6912. writeOutput(context, formatted, options);
  6913. } catch (error) {
  6914. handleError(context, filepath || "stdin", error);
  6915. }
  6916. }
  6917. async function formatFiles(context) {
  6918. const isIgnored = await createIsIgnoredFromContextOrDie(context);
  6919. const cwd2 = process.cwd();
  6920. let numberOfUnformattedFilesFound = 0;
  6921. const { performanceTestFlag } = context;
  6922. if (context.argv.check && !performanceTestFlag) {
  6923. context.logger.log("Checking formatting...");
  6924. }
  6925. let formatResultsCache;
  6926. const cacheFilePath = await find_cache_file_default(context.argv.cacheLocation);
  6927. if (context.argv.cache) {
  6928. formatResultsCache = new format_results_cache_default(
  6929. cacheFilePath,
  6930. context.argv.cacheStrategy || "content"
  6931. );
  6932. } else {
  6933. if (context.argv.cacheStrategy) {
  6934. context.logger.error(
  6935. "`--cache-strategy` cannot be used without `--cache`."
  6936. );
  6937. process.exit(2);
  6938. }
  6939. if (!context.argv.cacheLocation) {
  6940. const stat = await statSafe(cacheFilePath);
  6941. if (stat) {
  6942. await fs5.unlink(cacheFilePath);
  6943. }
  6944. }
  6945. }
  6946. for await (const pathOrError of expandPatterns(context)) {
  6947. if (typeof pathOrError === "object") {
  6948. context.logger.error(pathOrError.error);
  6949. process.exitCode = 2;
  6950. continue;
  6951. }
  6952. const filename = pathOrError;
  6953. const isFileIgnored = isIgnored(filename);
  6954. if (isFileIgnored && (context.argv.debugCheck || context.argv.write || context.argv.check || context.argv.listDifferent)) {
  6955. continue;
  6956. }
  6957. const options = {
  6958. ...await get_options_for_file_default(context, filename),
  6959. filepath: filename
  6960. };
  6961. const fileNameToDisplay = normalizeToPosix(path8.relative(cwd2, filename));
  6962. let printedFilename;
  6963. if (isTTY()) {
  6964. printedFilename = context.logger.log(fileNameToDisplay, {
  6965. newline: false,
  6966. clearable: true
  6967. });
  6968. }
  6969. let input;
  6970. try {
  6971. input = await fs5.readFile(filename, "utf8");
  6972. } catch (error) {
  6973. context.logger.log("");
  6974. context.logger.error(
  6975. `Unable to read file "${fileNameToDisplay}":
  6976. ${error.message}`
  6977. );
  6978. process.exitCode = 2;
  6979. continue;
  6980. }
  6981. if (isFileIgnored) {
  6982. printedFilename == null ? void 0 : printedFilename.clear();
  6983. writeOutput(context, { formatted: input }, options);
  6984. continue;
  6985. }
  6986. const start = Date.now();
  6987. const isCacheExists = formatResultsCache == null ? void 0 : formatResultsCache.existsAvailableFormatResultsCache(
  6988. filename,
  6989. options
  6990. );
  6991. let result;
  6992. let output;
  6993. try {
  6994. if (isCacheExists) {
  6995. result = { formatted: input };
  6996. } else {
  6997. result = await format2(context, input, options);
  6998. }
  6999. output = result.formatted;
  7000. } catch (error) {
  7001. handleError(context, fileNameToDisplay, error, printedFilename);
  7002. continue;
  7003. }
  7004. const isDifferent = output !== input;
  7005. let shouldSetCache = !isDifferent;
  7006. printedFilename == null ? void 0 : printedFilename.clear();
  7007. if (performanceTestFlag) {
  7008. context.logger.log(
  7009. `'${performanceTestFlag.name}' option found, skipped print code or write files.`
  7010. );
  7011. return;
  7012. }
  7013. if (context.argv.write) {
  7014. if (isDifferent) {
  7015. if (!context.argv.check && !context.argv.listDifferent) {
  7016. context.logger.log(`${fileNameToDisplay} ${Date.now() - start}ms`);
  7017. }
  7018. try {
  7019. await writeFormattedFile(filename, output);
  7020. shouldSetCache = true;
  7021. } catch (error) {
  7022. context.logger.error(
  7023. `Unable to write file "${fileNameToDisplay}":
  7024. ${error.message}`
  7025. );
  7026. process.exitCode = 2;
  7027. }
  7028. } else if (!context.argv.check && !context.argv.listDifferent) {
  7029. const message = `${source_default.grey(fileNameToDisplay)} ${Date.now() - start}ms`;
  7030. if (isCacheExists) {
  7031. context.logger.log(`${message} (cached)`);
  7032. } else {
  7033. context.logger.log(message);
  7034. }
  7035. }
  7036. } else if (context.argv.debugCheck) {
  7037. if (result.filepath) {
  7038. context.logger.log(fileNameToDisplay);
  7039. } else {
  7040. process.exitCode = 2;
  7041. }
  7042. } else if (!context.argv.check && !context.argv.listDifferent) {
  7043. writeOutput(context, result, options);
  7044. }
  7045. if (shouldSetCache) {
  7046. formatResultsCache == null ? void 0 : formatResultsCache.setFormatResultsCache(filename, options);
  7047. } else {
  7048. formatResultsCache == null ? void 0 : formatResultsCache.removeFormatResultsCache(filename);
  7049. }
  7050. if (isDifferent) {
  7051. if (context.argv.check) {
  7052. context.logger.warn(fileNameToDisplay);
  7053. } else if (context.argv.listDifferent) {
  7054. context.logger.log(fileNameToDisplay);
  7055. }
  7056. numberOfUnformattedFilesFound += 1;
  7057. }
  7058. }
  7059. formatResultsCache == null ? void 0 : formatResultsCache.reconcile();
  7060. if (context.argv.check) {
  7061. if (numberOfUnformattedFilesFound === 0) {
  7062. context.logger.log("All matched files use Prettier code style!");
  7063. } else {
  7064. const files = numberOfUnformattedFilesFound === 1 ? "the above file" : `${numberOfUnformattedFilesFound} files`;
  7065. context.logger.warn(
  7066. context.argv.write ? `Code style issues fixed in ${files}.` : `Code style issues found in ${files}. Run Prettier to fix.`
  7067. );
  7068. }
  7069. }
  7070. if ((context.argv.check || context.argv.listDifferent) && numberOfUnformattedFilesFound > 0 && !process.exitCode && !context.argv.write) {
  7071. process.exitCode = 1;
  7072. }
  7073. }
  7074. // src/cli/file-info.js
  7075. var import_fast_json_stable_stringify2 = __toESM(require_fast_json_stable_stringify(), 1);
  7076. import { format as format3, getFileInfo } from "../index.mjs";
  7077. async function logFileInfoOrDie(context) {
  7078. const {
  7079. fileInfo: file,
  7080. ignorePath,
  7081. withNodeModules,
  7082. plugins,
  7083. config
  7084. } = context.argv;
  7085. const fileInfo = await getFileInfo(file, {
  7086. ignorePath,
  7087. withNodeModules,
  7088. plugins,
  7089. resolveConfig: config !== false
  7090. });
  7091. printToScreen(await format3((0, import_fast_json_stable_stringify2.default)(fileInfo), { parser: "json" }));
  7092. }
  7093. var file_info_default = logFileInfoOrDie;
  7094. // src/cli/find-config-path.js
  7095. import path9 from "path";
  7096. import { resolveConfigFile } from "../index.mjs";
  7097. async function logResolvedConfigPathOrDie(context) {
  7098. const file = context.argv.findConfigPath;
  7099. const configFile = await resolveConfigFile(file);
  7100. if (configFile) {
  7101. printToScreen(normalizeToPosix(path9.relative(process.cwd(), configFile)));
  7102. } else {
  7103. throw new Error(`Can not find configure file for "${file}".`);
  7104. }
  7105. }
  7106. var find_config_path_default = logResolvedConfigPathOrDie;
  7107. // src/cli/print-support-info.js
  7108. var import_fast_json_stable_stringify3 = __toESM(require_fast_json_stable_stringify(), 1);
  7109. import { getSupportInfo as getSupportInfo2, format as format4 } from "../index.mjs";
  7110. var sortByName = (array2) => array2.sort((a, b) => a.name.localeCompare(b.name));
  7111. async function printSupportInfo() {
  7112. const { languages, options } = await getSupportInfo2();
  7113. const supportInfo = {
  7114. languages: sortByName(languages),
  7115. options: sortByName(options).map(
  7116. (option) => omit(option, ["cliName", "cliCategory", "cliDescription"])
  7117. )
  7118. };
  7119. printToScreen(await format4((0, import_fast_json_stable_stringify3.default)(supportInfo), { parser: "json" }));
  7120. }
  7121. var print_support_info_default = printSupportInfo;
  7122. // src/cli/index.js
  7123. async function run(rawArguments) {
  7124. let logger = logger_default();
  7125. try {
  7126. const { logLevel } = parseArgvWithoutPlugins(
  7127. rawArguments,
  7128. logger,
  7129. "log-level"
  7130. );
  7131. if (logLevel !== logger.logLevel) {
  7132. logger = logger_default(logLevel);
  7133. }
  7134. const context = new context_default({ rawArguments, logger });
  7135. await context.init();
  7136. if (logger.logLevel !== "debug" && context.performanceTestFlag) {
  7137. context.logger = logger_default("debug");
  7138. }
  7139. await main(context);
  7140. } catch (error) {
  7141. logger.error(error.message);
  7142. process.exitCode = 1;
  7143. }
  7144. }
  7145. async function main(context) {
  7146. context.logger.debug(`normalized argv: ${JSON.stringify(context.argv)}`);
  7147. if (context.argv.check && context.argv.listDifferent) {
  7148. throw new Error("Cannot use --check and --list-different together.");
  7149. }
  7150. if (context.argv.write && context.argv.debugCheck) {
  7151. throw new Error("Cannot use --write and --debug-check together.");
  7152. }
  7153. if (context.argv.findConfigPath && context.filePatterns.length > 0) {
  7154. throw new Error("Cannot use --find-config-path with multiple files");
  7155. }
  7156. if (context.argv.fileInfo && context.filePatterns.length > 0) {
  7157. throw new Error("Cannot use --file-info with multiple files");
  7158. }
  7159. if (context.argv.version) {
  7160. printToScreen(prettier2.version);
  7161. return;
  7162. }
  7163. if (context.argv.help !== void 0) {
  7164. printToScreen(
  7165. typeof context.argv.help === "string" && context.argv.help !== "" ? createDetailedUsage(context, context.argv.help) : createUsage(context)
  7166. );
  7167. return;
  7168. }
  7169. if (context.argv.supportInfo) {
  7170. return print_support_info_default();
  7171. }
  7172. const hasFilePatterns = context.filePatterns.length > 0;
  7173. const useStdin = !hasFilePatterns && (!process.stdin.isTTY || context.argv.filePath);
  7174. if (context.argv.findConfigPath) {
  7175. await find_config_path_default(context);
  7176. } else if (context.argv.fileInfo) {
  7177. await file_info_default(context);
  7178. } else if (useStdin) {
  7179. if (context.argv.cache) {
  7180. context.logger.error("`--cache` cannot be used with stdin.");
  7181. process.exit(2);
  7182. }
  7183. await formatStdin(context);
  7184. } else if (hasFilePatterns) {
  7185. await formatFiles(context);
  7186. } else {
  7187. process.exitCode = 1;
  7188. printToScreen(createUsage(context));
  7189. }
  7190. }
  7191. export {
  7192. run
  7193. };