index.js 155 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378
  1. require('./sourcemap-register.js');/******/ (() => { // webpackBootstrap
  2. /******/ var __webpack_modules__ = ({
  3. /***/ 572:
  4. /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
  5. "use strict";
  6. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  7. if (k2 === undefined) k2 = k;
  8. var desc = Object.getOwnPropertyDescriptor(m, k);
  9. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  10. desc = { enumerable: true, get: function() { return m[k]; } };
  11. }
  12. Object.defineProperty(o, k2, desc);
  13. }) : (function(o, m, k, k2) {
  14. if (k2 === undefined) k2 = k;
  15. o[k2] = m[k];
  16. }));
  17. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  18. Object.defineProperty(o, "default", { enumerable: true, value: v });
  19. }) : function(o, v) {
  20. o["default"] = v;
  21. });
  22. var __importStar = (this && this.__importStar) || function (mod) {
  23. if (mod && mod.__esModule) return mod;
  24. var result = {};
  25. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  26. __setModuleDefault(result, mod);
  27. return result;
  28. };
  29. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  30. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  31. return new (P || (P = Promise))(function (resolve, reject) {
  32. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  33. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  34. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  35. step((generator = generator.apply(thisArg, _arguments || [])).next());
  36. });
  37. };
  38. Object.defineProperty(exports, "__esModule", ({ value: true }));
  39. exports.getInputs = void 0;
  40. const core = __importStar(__nccwpck_require__(93));
  41. const shells_1 = __nccwpck_require__(824);
  42. function parseIntOrThrow(input) {
  43. const result = parseInt(input);
  44. if (isNaN(result)) {
  45. throw new Error(`'${input}' is not a number.`);
  46. }
  47. return result;
  48. }
  49. function getInputs() {
  50. return __awaiter(this, void 0, void 0, function* () {
  51. return {
  52. commands: core.getMultilineInput('commands', { required: true }),
  53. shell: yield (0, shells_1.getShell)(core.getInput('shell')),
  54. working_directory: core.getInput('working-directory'),
  55. timeout_minutes: parseIntOrThrow(core.getInput('timeout-minutes', { required: true })),
  56. max_retries: parseIntOrThrow(core.getInput('max-retries')),
  57. retry_codes: core
  58. .getInput('retry-codes', { required: true })
  59. .split(',')
  60. .map(x => parseIntOrThrow(x))
  61. };
  62. });
  63. }
  64. exports.getInputs = getInputs;
  65. /***/ }),
  66. /***/ 234:
  67. /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
  68. "use strict";
  69. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  70. if (k2 === undefined) k2 = k;
  71. var desc = Object.getOwnPropertyDescriptor(m, k);
  72. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  73. desc = { enumerable: true, get: function() { return m[k]; } };
  74. }
  75. Object.defineProperty(o, k2, desc);
  76. }) : (function(o, m, k, k2) {
  77. if (k2 === undefined) k2 = k;
  78. o[k2] = m[k];
  79. }));
  80. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  81. Object.defineProperty(o, "default", { enumerable: true, value: v });
  82. }) : function(o, v) {
  83. o["default"] = v;
  84. });
  85. var __importStar = (this && this.__importStar) || function (mod) {
  86. if (mod && mod.__esModule) return mod;
  87. var result = {};
  88. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  89. __setModuleDefault(result, mod);
  90. return result;
  91. };
  92. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  93. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  94. return new (P || (P = Promise))(function (resolve, reject) {
  95. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  96. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  97. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  98. step((generator = generator.apply(thisArg, _arguments || [])).next());
  99. });
  100. };
  101. Object.defineProperty(exports, "__esModule", ({ value: true }));
  102. const core = __importStar(__nccwpck_require__(93));
  103. const inputs_1 = __nccwpck_require__(572);
  104. const run_1 = __nccwpck_require__(893);
  105. function run() {
  106. return __awaiter(this, void 0, void 0, function* () {
  107. try {
  108. core.debug('Getting inputs...');
  109. const inputs = yield (0, inputs_1.getInputs)();
  110. core.debug('Running unstable command function...');
  111. const result = yield (0, run_1.runUnstableCommand)(inputs.commands, inputs.shell, inputs.working_directory, inputs.timeout_minutes, inputs.max_retries, inputs.retry_codes);
  112. if (result !== null && result !== 0) {
  113. core.setFailed(`Child process exited with code: ${result}`);
  114. return;
  115. }
  116. core.info('Successfully completed unstable command!');
  117. }
  118. catch (error) {
  119. if (error instanceof Error)
  120. core.setFailed(error.message);
  121. }
  122. });
  123. }
  124. run();
  125. /***/ }),
  126. /***/ 893:
  127. /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
  128. "use strict";
  129. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  130. if (k2 === undefined) k2 = k;
  131. var desc = Object.getOwnPropertyDescriptor(m, k);
  132. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  133. desc = { enumerable: true, get: function() { return m[k]; } };
  134. }
  135. Object.defineProperty(o, k2, desc);
  136. }) : (function(o, m, k, k2) {
  137. if (k2 === undefined) k2 = k;
  138. o[k2] = m[k];
  139. }));
  140. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  141. Object.defineProperty(o, "default", { enumerable: true, value: v });
  142. }) : function(o, v) {
  143. o["default"] = v;
  144. });
  145. var __importStar = (this && this.__importStar) || function (mod) {
  146. if (mod && mod.__esModule) return mod;
  147. var result = {};
  148. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  149. __setModuleDefault(result, mod);
  150. return result;
  151. };
  152. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  153. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  154. return new (P || (P = Promise))(function (resolve, reject) {
  155. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  156. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  157. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  158. step((generator = generator.apply(thisArg, _arguments || [])).next());
  159. });
  160. };
  161. var __importDefault = (this && this.__importDefault) || function (mod) {
  162. return (mod && mod.__esModule) ? mod : { "default": mod };
  163. };
  164. Object.defineProperty(exports, "__esModule", ({ value: true }));
  165. exports.runUnstableCommand = void 0;
  166. const core = __importStar(__nccwpck_require__(93));
  167. const child_process_1 = __nccwpck_require__(81);
  168. const promises_1 = __importDefault(__nccwpck_require__(292));
  169. const path_1 = __importDefault(__nccwpck_require__(822));
  170. const os_1 = __importDefault(__nccwpck_require__(37));
  171. function runUnstableCommand(commands, shell, workingDirectory, timeoutMinutes, maxRetries, retryCodes) {
  172. var _a, _b, _c;
  173. return __awaiter(this, void 0, void 0, function* () {
  174. const filepath = path_1.default.join(os_1.default.tmpdir(), `unstable-command${shell.scriptSuffix}`);
  175. if (shell.args.filter(x => x.includes('{0}')).length === 0) {
  176. throw new Error("Shell does not contain the required argument: '{0}'");
  177. }
  178. core.debug(`Writing commands to temporary file: ${filepath}`);
  179. yield promises_1.default.writeFile(filepath, commands.join(os_1.default.EOL));
  180. core.debug('File was written successfully!');
  181. const shellArgs = [];
  182. for (const arg of shell.args) {
  183. if (arg.includes('{0}')) {
  184. shellArgs.push(arg.replace('{0}', filepath));
  185. continue;
  186. }
  187. shellArgs.push(arg);
  188. }
  189. let result = null;
  190. for (let i = 1; i <= maxRetries; i++) {
  191. result = yield core.group(`Attempt ${i}/${maxRetries}`, () => __awaiter(this, void 0, void 0, function* () {
  192. core.debug('Executing temporary script...');
  193. const process = (0, child_process_1.spawnSync)(shell.executable, shellArgs, {
  194. cwd: workingDirectory,
  195. killSignal: 'SIGKILL',
  196. timeout: timeoutMinutes * 60 * 1000,
  197. stdio: 'inherit'
  198. });
  199. core.debug('Child process exited.');
  200. const unstableResult = {
  201. exitCode: process.status
  202. };
  203. if (process.error !== undefined) {
  204. unstableResult.error = process.error;
  205. }
  206. return unstableResult;
  207. }));
  208. if (result.exitCode === null || retryCodes.includes(result.exitCode)) {
  209. if (result.exitCode === null) {
  210. core.warning(`Process was killed due to a timeout.`);
  211. core.debug(`${(_a = result.error) === null || _a === void 0 ? void 0 : _a.name}: ${(_b = result.error) === null || _b === void 0 ? void 0 : _b.message}`);
  212. }
  213. else {
  214. core.warning(`Process exited with code '${result.exitCode}' which is part of the specified retry-codes.`);
  215. }
  216. }
  217. else {
  218. core.info(`Process exited with code '${result.exitCode}'.`);
  219. return result.exitCode;
  220. }
  221. }
  222. core.error(`Aborting after ${maxRetries} attempts.`);
  223. core.setFailed((_c = result === null || result === void 0 ? void 0 : result.error) !== null && _c !== void 0 ? _c : `Child process never returned with a good exit code. Giving up after ${maxRetries} attempts.`);
  224. return null;
  225. });
  226. }
  227. exports.runUnstableCommand = runUnstableCommand;
  228. /***/ }),
  229. /***/ 824:
  230. /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
  231. "use strict";
  232. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  233. if (k2 === undefined) k2 = k;
  234. var desc = Object.getOwnPropertyDescriptor(m, k);
  235. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  236. desc = { enumerable: true, get: function() { return m[k]; } };
  237. }
  238. Object.defineProperty(o, k2, desc);
  239. }) : (function(o, m, k, k2) {
  240. if (k2 === undefined) k2 = k;
  241. o[k2] = m[k];
  242. }));
  243. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  244. Object.defineProperty(o, "default", { enumerable: true, value: v });
  245. }) : function(o, v) {
  246. o["default"] = v;
  247. });
  248. var __importStar = (this && this.__importStar) || function (mod) {
  249. if (mod && mod.__esModule) return mod;
  250. var result = {};
  251. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  252. __setModuleDefault(result, mod);
  253. return result;
  254. };
  255. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  256. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  257. return new (P || (P = Promise))(function (resolve, reject) {
  258. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  259. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  260. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  261. step((generator = generator.apply(thisArg, _arguments || [])).next());
  262. });
  263. };
  264. var __importDefault = (this && this.__importDefault) || function (mod) {
  265. return (mod && mod.__esModule) ? mod : { "default": mod };
  266. };
  267. Object.defineProperty(exports, "__esModule", ({ value: true }));
  268. exports.getShell = void 0;
  269. const os_1 = __importDefault(__nccwpck_require__(37));
  270. const process_1 = __nccwpck_require__(282);
  271. const io = __importStar(__nccwpck_require__(826));
  272. const toolrunner_1 = __nccwpck_require__(374);
  273. // Define shells as GitHub Actions specifies for the shell keyword
  274. // See: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell
  275. function getDefaultShell() {
  276. return __awaiter(this, void 0, void 0, function* () {
  277. const default_shell = {
  278. executable: '',
  279. args: [],
  280. scriptSuffix: ''
  281. };
  282. let shell_path = '';
  283. switch (os_1.default.platform()) {
  284. case 'linux':
  285. case 'darwin':
  286. default_shell.args = ['-e', '{0}'];
  287. shell_path = yield io.which('bash');
  288. if (shell_path.length > 0) {
  289. default_shell.executable = shell_path;
  290. return default_shell;
  291. }
  292. shell_path = yield io.which('sh', true);
  293. default_shell.executable = shell_path;
  294. return default_shell;
  295. case 'win32':
  296. default_shell.args = ['-command', ". '{0}'"];
  297. default_shell.scriptSuffix = '.ps1';
  298. shell_path = yield io.which('pwsh');
  299. if (shell_path.length > 0) {
  300. default_shell.executable = shell_path;
  301. return default_shell;
  302. }
  303. shell_path = yield io.which('powershell', true);
  304. default_shell.executable = shell_path;
  305. return default_shell;
  306. default:
  307. throw new Error(`Couldn't find default shell for OS: ${os_1.default.platform()}`);
  308. }
  309. });
  310. }
  311. function getShell(shellInput) {
  312. var _a;
  313. return __awaiter(this, void 0, void 0, function* () {
  314. if (shellInput.length === 0 || shellInput === 'default-shell') {
  315. return getDefaultShell();
  316. }
  317. const shell = {
  318. executable: '',
  319. args: [],
  320. scriptSuffix: ''
  321. };
  322. const customShellSplit = shellInput.split(' ');
  323. switch (shellInput) {
  324. case 'bash':
  325. shell.executable = yield io.which('bash', true);
  326. shell.args = ['--noprofile', '--norc', '-eo', 'pipefail', '{0}'];
  327. break;
  328. case 'pwsh':
  329. shell.executable = yield io.which('pwsh', true);
  330. shell.args = ['-command', ". '{0}'"];
  331. shell.scriptSuffix = '.ps1';
  332. break;
  333. case 'python':
  334. shell.executable = yield io.which('python', true);
  335. shell.args = ['{0}'];
  336. break;
  337. case 'sh':
  338. shell.executable = yield io.which('sh', true);
  339. shell.args = ['-e', '{0}'];
  340. break;
  341. case 'cmd':
  342. shell.executable = (_a = process_1.env.COMSPEC) !== null && _a !== void 0 ? _a : (yield io.which('cmd', true));
  343. shell.args = ['/D', '/E:ON', '/V:OFF', '/S', '/C', 'CALL "{0}"'];
  344. shell.scriptSuffix = '.cmd';
  345. break;
  346. case 'powershell':
  347. shell.executable = yield io.which('powershell', true);
  348. shell.args = ['-command', ". '{0}'"];
  349. shell.scriptSuffix = '.ps1';
  350. break;
  351. default:
  352. // Custom shell
  353. // See: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#custom-shell
  354. if (customShellSplit.length >= 2) {
  355. shell.executable = yield io.which(customShellSplit[0], true);
  356. customShellSplit.shift();
  357. shell.args = (0, toolrunner_1.argStringToArray)(customShellSplit.join(' '));
  358. break;
  359. }
  360. throw new Error("Custom shell needs to have at least one argument: '{0}'");
  361. }
  362. return shell;
  363. });
  364. }
  365. exports.getShell = getShell;
  366. /***/ }),
  367. /***/ 513:
  368. /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
  369. "use strict";
  370. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  371. if (k2 === undefined) k2 = k;
  372. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  373. }) : (function(o, m, k, k2) {
  374. if (k2 === undefined) k2 = k;
  375. o[k2] = m[k];
  376. }));
  377. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  378. Object.defineProperty(o, "default", { enumerable: true, value: v });
  379. }) : function(o, v) {
  380. o["default"] = v;
  381. });
  382. var __importStar = (this && this.__importStar) || function (mod) {
  383. if (mod && mod.__esModule) return mod;
  384. var result = {};
  385. if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  386. __setModuleDefault(result, mod);
  387. return result;
  388. };
  389. Object.defineProperty(exports, "__esModule", ({ value: true }));
  390. exports.issue = exports.issueCommand = void 0;
  391. const os = __importStar(__nccwpck_require__(37));
  392. const utils_1 = __nccwpck_require__(120);
  393. /**
  394. * Commands
  395. *
  396. * Command Format:
  397. * ::name key=value,key=value::message
  398. *
  399. * Examples:
  400. * ::warning::This is the message
  401. * ::set-env name=MY_VAR::some value
  402. */
  403. function issueCommand(command, properties, message) {
  404. const cmd = new Command(command, properties, message);
  405. process.stdout.write(cmd.toString() + os.EOL);
  406. }
  407. exports.issueCommand = issueCommand;
  408. function issue(name, message = '') {
  409. issueCommand(name, {}, message);
  410. }
  411. exports.issue = issue;
  412. const CMD_STRING = '::';
  413. class Command {
  414. constructor(command, properties, message) {
  415. if (!command) {
  416. command = 'missing.command';
  417. }
  418. this.command = command;
  419. this.properties = properties;
  420. this.message = message;
  421. }
  422. toString() {
  423. let cmdStr = CMD_STRING + this.command;
  424. if (this.properties && Object.keys(this.properties).length > 0) {
  425. cmdStr += ' ';
  426. let first = true;
  427. for (const key in this.properties) {
  428. if (this.properties.hasOwnProperty(key)) {
  429. const val = this.properties[key];
  430. if (val) {
  431. if (first) {
  432. first = false;
  433. }
  434. else {
  435. cmdStr += ',';
  436. }
  437. cmdStr += `${key}=${escapeProperty(val)}`;
  438. }
  439. }
  440. }
  441. }
  442. cmdStr += `${CMD_STRING}${escapeData(this.message)}`;
  443. return cmdStr;
  444. }
  445. }
  446. function escapeData(s) {
  447. return utils_1.toCommandValue(s)
  448. .replace(/%/g, '%25')
  449. .replace(/\r/g, '%0D')
  450. .replace(/\n/g, '%0A');
  451. }
  452. function escapeProperty(s) {
  453. return utils_1.toCommandValue(s)
  454. .replace(/%/g, '%25')
  455. .replace(/\r/g, '%0D')
  456. .replace(/\n/g, '%0A')
  457. .replace(/:/g, '%3A')
  458. .replace(/,/g, '%2C');
  459. }
  460. //# sourceMappingURL=command.js.map
  461. /***/ }),
  462. /***/ 93:
  463. /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
  464. "use strict";
  465. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  466. if (k2 === undefined) k2 = k;
  467. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  468. }) : (function(o, m, k, k2) {
  469. if (k2 === undefined) k2 = k;
  470. o[k2] = m[k];
  471. }));
  472. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  473. Object.defineProperty(o, "default", { enumerable: true, value: v });
  474. }) : function(o, v) {
  475. o["default"] = v;
  476. });
  477. var __importStar = (this && this.__importStar) || function (mod) {
  478. if (mod && mod.__esModule) return mod;
  479. var result = {};
  480. if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  481. __setModuleDefault(result, mod);
  482. return result;
  483. };
  484. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  485. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  486. return new (P || (P = Promise))(function (resolve, reject) {
  487. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  488. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  489. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  490. step((generator = generator.apply(thisArg, _arguments || [])).next());
  491. });
  492. };
  493. Object.defineProperty(exports, "__esModule", ({ value: true }));
  494. exports.getIDToken = exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.notice = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;
  495. const command_1 = __nccwpck_require__(513);
  496. const file_command_1 = __nccwpck_require__(17);
  497. const utils_1 = __nccwpck_require__(120);
  498. const os = __importStar(__nccwpck_require__(37));
  499. const path = __importStar(__nccwpck_require__(822));
  500. const oidc_utils_1 = __nccwpck_require__(141);
  501. /**
  502. * The code to exit an action
  503. */
  504. var ExitCode;
  505. (function (ExitCode) {
  506. /**
  507. * A code indicating that the action was successful
  508. */
  509. ExitCode[ExitCode["Success"] = 0] = "Success";
  510. /**
  511. * A code indicating that the action was a failure
  512. */
  513. ExitCode[ExitCode["Failure"] = 1] = "Failure";
  514. })(ExitCode = exports.ExitCode || (exports.ExitCode = {}));
  515. //-----------------------------------------------------------------------
  516. // Variables
  517. //-----------------------------------------------------------------------
  518. /**
  519. * Sets env variable for this action and future actions in the job
  520. * @param name the name of the variable to set
  521. * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
  522. */
  523. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  524. function exportVariable(name, val) {
  525. const convertedVal = utils_1.toCommandValue(val);
  526. process.env[name] = convertedVal;
  527. const filePath = process.env['GITHUB_ENV'] || '';
  528. if (filePath) {
  529. return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val));
  530. }
  531. command_1.issueCommand('set-env', { name }, convertedVal);
  532. }
  533. exports.exportVariable = exportVariable;
  534. /**
  535. * Registers a secret which will get masked from logs
  536. * @param secret value of the secret
  537. */
  538. function setSecret(secret) {
  539. command_1.issueCommand('add-mask', {}, secret);
  540. }
  541. exports.setSecret = setSecret;
  542. /**
  543. * Prepends inputPath to the PATH (for this action and future actions)
  544. * @param inputPath
  545. */
  546. function addPath(inputPath) {
  547. const filePath = process.env['GITHUB_PATH'] || '';
  548. if (filePath) {
  549. file_command_1.issueFileCommand('PATH', inputPath);
  550. }
  551. else {
  552. command_1.issueCommand('add-path', {}, inputPath);
  553. }
  554. process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
  555. }
  556. exports.addPath = addPath;
  557. /**
  558. * Gets the value of an input.
  559. * Unless trimWhitespace is set to false in InputOptions, the value is also trimmed.
  560. * Returns an empty string if the value is not defined.
  561. *
  562. * @param name name of the input to get
  563. * @param options optional. See InputOptions.
  564. * @returns string
  565. */
  566. function getInput(name, options) {
  567. const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';
  568. if (options && options.required && !val) {
  569. throw new Error(`Input required and not supplied: ${name}`);
  570. }
  571. if (options && options.trimWhitespace === false) {
  572. return val;
  573. }
  574. return val.trim();
  575. }
  576. exports.getInput = getInput;
  577. /**
  578. * Gets the values of an multiline input. Each value is also trimmed.
  579. *
  580. * @param name name of the input to get
  581. * @param options optional. See InputOptions.
  582. * @returns string[]
  583. *
  584. */
  585. function getMultilineInput(name, options) {
  586. const inputs = getInput(name, options)
  587. .split('\n')
  588. .filter(x => x !== '');
  589. if (options && options.trimWhitespace === false) {
  590. return inputs;
  591. }
  592. return inputs.map(input => input.trim());
  593. }
  594. exports.getMultilineInput = getMultilineInput;
  595. /**
  596. * Gets the input value of the boolean type in the YAML 1.2 "core schema" specification.
  597. * Support boolean input list: `true | True | TRUE | false | False | FALSE` .
  598. * The return value is also in boolean type.
  599. * ref: https://yaml.org/spec/1.2/spec.html#id2804923
  600. *
  601. * @param name name of the input to get
  602. * @param options optional. See InputOptions.
  603. * @returns boolean
  604. */
  605. function getBooleanInput(name, options) {
  606. const trueValue = ['true', 'True', 'TRUE'];
  607. const falseValue = ['false', 'False', 'FALSE'];
  608. const val = getInput(name, options);
  609. if (trueValue.includes(val))
  610. return true;
  611. if (falseValue.includes(val))
  612. return false;
  613. throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}\n` +
  614. `Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
  615. }
  616. exports.getBooleanInput = getBooleanInput;
  617. /**
  618. * Sets the value of an output.
  619. *
  620. * @param name name of the output to set
  621. * @param value value to store. Non-string values will be converted to a string via JSON.stringify
  622. */
  623. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  624. function setOutput(name, value) {
  625. const filePath = process.env['GITHUB_OUTPUT'] || '';
  626. if (filePath) {
  627. return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value));
  628. }
  629. process.stdout.write(os.EOL);
  630. command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value));
  631. }
  632. exports.setOutput = setOutput;
  633. /**
  634. * Enables or disables the echoing of commands into stdout for the rest of the step.
  635. * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
  636. *
  637. */
  638. function setCommandEcho(enabled) {
  639. command_1.issue('echo', enabled ? 'on' : 'off');
  640. }
  641. exports.setCommandEcho = setCommandEcho;
  642. //-----------------------------------------------------------------------
  643. // Results
  644. //-----------------------------------------------------------------------
  645. /**
  646. * Sets the action status to failed.
  647. * When the action exits it will be with an exit code of 1
  648. * @param message add error issue message
  649. */
  650. function setFailed(message) {
  651. process.exitCode = ExitCode.Failure;
  652. error(message);
  653. }
  654. exports.setFailed = setFailed;
  655. //-----------------------------------------------------------------------
  656. // Logging Commands
  657. //-----------------------------------------------------------------------
  658. /**
  659. * Gets whether Actions Step Debug is on or not
  660. */
  661. function isDebug() {
  662. return process.env['RUNNER_DEBUG'] === '1';
  663. }
  664. exports.isDebug = isDebug;
  665. /**
  666. * Writes debug message to user log
  667. * @param message debug message
  668. */
  669. function debug(message) {
  670. command_1.issueCommand('debug', {}, message);
  671. }
  672. exports.debug = debug;
  673. /**
  674. * Adds an error issue
  675. * @param message error issue message. Errors will be converted to string via toString()
  676. * @param properties optional properties to add to the annotation.
  677. */
  678. function error(message, properties = {}) {
  679. command_1.issueCommand('error', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
  680. }
  681. exports.error = error;
  682. /**
  683. * Adds a warning issue
  684. * @param message warning issue message. Errors will be converted to string via toString()
  685. * @param properties optional properties to add to the annotation.
  686. */
  687. function warning(message, properties = {}) {
  688. command_1.issueCommand('warning', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
  689. }
  690. exports.warning = warning;
  691. /**
  692. * Adds a notice issue
  693. * @param message notice issue message. Errors will be converted to string via toString()
  694. * @param properties optional properties to add to the annotation.
  695. */
  696. function notice(message, properties = {}) {
  697. command_1.issueCommand('notice', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
  698. }
  699. exports.notice = notice;
  700. /**
  701. * Writes info to log with console.log.
  702. * @param message info message
  703. */
  704. function info(message) {
  705. process.stdout.write(message + os.EOL);
  706. }
  707. exports.info = info;
  708. /**
  709. * Begin an output group.
  710. *
  711. * Output until the next `groupEnd` will be foldable in this group
  712. *
  713. * @param name The name of the output group
  714. */
  715. function startGroup(name) {
  716. command_1.issue('group', name);
  717. }
  718. exports.startGroup = startGroup;
  719. /**
  720. * End an output group.
  721. */
  722. function endGroup() {
  723. command_1.issue('endgroup');
  724. }
  725. exports.endGroup = endGroup;
  726. /**
  727. * Wrap an asynchronous function call in a group.
  728. *
  729. * Returns the same type as the function itself.
  730. *
  731. * @param name The name of the group
  732. * @param fn The function to wrap in the group
  733. */
  734. function group(name, fn) {
  735. return __awaiter(this, void 0, void 0, function* () {
  736. startGroup(name);
  737. let result;
  738. try {
  739. result = yield fn();
  740. }
  741. finally {
  742. endGroup();
  743. }
  744. return result;
  745. });
  746. }
  747. exports.group = group;
  748. //-----------------------------------------------------------------------
  749. // Wrapper action state
  750. //-----------------------------------------------------------------------
  751. /**
  752. * Saves state for current action, the state can only be retrieved by this action's post job execution.
  753. *
  754. * @param name name of the state to store
  755. * @param value value to store. Non-string values will be converted to a string via JSON.stringify
  756. */
  757. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  758. function saveState(name, value) {
  759. const filePath = process.env['GITHUB_STATE'] || '';
  760. if (filePath) {
  761. return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value));
  762. }
  763. command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value));
  764. }
  765. exports.saveState = saveState;
  766. /**
  767. * Gets the value of an state set by this action's main execution.
  768. *
  769. * @param name name of the state to get
  770. * @returns string
  771. */
  772. function getState(name) {
  773. return process.env[`STATE_${name}`] || '';
  774. }
  775. exports.getState = getState;
  776. function getIDToken(aud) {
  777. return __awaiter(this, void 0, void 0, function* () {
  778. return yield oidc_utils_1.OidcClient.getIDToken(aud);
  779. });
  780. }
  781. exports.getIDToken = getIDToken;
  782. /**
  783. * Summary exports
  784. */
  785. var summary_1 = __nccwpck_require__(276);
  786. Object.defineProperty(exports, "summary", ({ enumerable: true, get: function () { return summary_1.summary; } }));
  787. /**
  788. * @deprecated use core.summary
  789. */
  790. var summary_2 = __nccwpck_require__(276);
  791. Object.defineProperty(exports, "markdownSummary", ({ enumerable: true, get: function () { return summary_2.markdownSummary; } }));
  792. /**
  793. * Path exports
  794. */
  795. var path_utils_1 = __nccwpck_require__(670);
  796. Object.defineProperty(exports, "toPosixPath", ({ enumerable: true, get: function () { return path_utils_1.toPosixPath; } }));
  797. Object.defineProperty(exports, "toWin32Path", ({ enumerable: true, get: function () { return path_utils_1.toWin32Path; } }));
  798. Object.defineProperty(exports, "toPlatformPath", ({ enumerable: true, get: function () { return path_utils_1.toPlatformPath; } }));
  799. //# sourceMappingURL=core.js.map
  800. /***/ }),
  801. /***/ 17:
  802. /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
  803. "use strict";
  804. // For internal use, subject to change.
  805. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  806. if (k2 === undefined) k2 = k;
  807. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  808. }) : (function(o, m, k, k2) {
  809. if (k2 === undefined) k2 = k;
  810. o[k2] = m[k];
  811. }));
  812. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  813. Object.defineProperty(o, "default", { enumerable: true, value: v });
  814. }) : function(o, v) {
  815. o["default"] = v;
  816. });
  817. var __importStar = (this && this.__importStar) || function (mod) {
  818. if (mod && mod.__esModule) return mod;
  819. var result = {};
  820. if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  821. __setModuleDefault(result, mod);
  822. return result;
  823. };
  824. Object.defineProperty(exports, "__esModule", ({ value: true }));
  825. exports.prepareKeyValueMessage = exports.issueFileCommand = void 0;
  826. // We use any as a valid input type
  827. /* eslint-disable @typescript-eslint/no-explicit-any */
  828. const fs = __importStar(__nccwpck_require__(147));
  829. const os = __importStar(__nccwpck_require__(37));
  830. const uuid_1 = __nccwpck_require__(338);
  831. const utils_1 = __nccwpck_require__(120);
  832. function issueFileCommand(command, message) {
  833. const filePath = process.env[`GITHUB_${command}`];
  834. if (!filePath) {
  835. throw new Error(`Unable to find environment variable for file command ${command}`);
  836. }
  837. if (!fs.existsSync(filePath)) {
  838. throw new Error(`Missing file at path: ${filePath}`);
  839. }
  840. fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {
  841. encoding: 'utf8'
  842. });
  843. }
  844. exports.issueFileCommand = issueFileCommand;
  845. function prepareKeyValueMessage(key, value) {
  846. const delimiter = `ghadelimiter_${uuid_1.v4()}`;
  847. const convertedValue = utils_1.toCommandValue(value);
  848. // These should realistically never happen, but just in case someone finds a
  849. // way to exploit uuid generation let's not allow keys or values that contain
  850. // the delimiter.
  851. if (key.includes(delimiter)) {
  852. throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
  853. }
  854. if (convertedValue.includes(delimiter)) {
  855. throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
  856. }
  857. return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`;
  858. }
  859. exports.prepareKeyValueMessage = prepareKeyValueMessage;
  860. //# sourceMappingURL=file-command.js.map
  861. /***/ }),
  862. /***/ 141:
  863. /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
  864. "use strict";
  865. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  866. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  867. return new (P || (P = Promise))(function (resolve, reject) {
  868. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  869. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  870. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  871. step((generator = generator.apply(thisArg, _arguments || [])).next());
  872. });
  873. };
  874. Object.defineProperty(exports, "__esModule", ({ value: true }));
  875. exports.OidcClient = void 0;
  876. const http_client_1 = __nccwpck_require__(503);
  877. const auth_1 = __nccwpck_require__(267);
  878. const core_1 = __nccwpck_require__(93);
  879. class OidcClient {
  880. static createHttpClient(allowRetry = true, maxRetry = 10) {
  881. const requestOptions = {
  882. allowRetries: allowRetry,
  883. maxRetries: maxRetry
  884. };
  885. return new http_client_1.HttpClient('actions/oidc-client', [new auth_1.BearerCredentialHandler(OidcClient.getRequestToken())], requestOptions);
  886. }
  887. static getRequestToken() {
  888. const token = process.env['ACTIONS_ID_TOKEN_REQUEST_TOKEN'];
  889. if (!token) {
  890. throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable');
  891. }
  892. return token;
  893. }
  894. static getIDTokenUrl() {
  895. const runtimeUrl = process.env['ACTIONS_ID_TOKEN_REQUEST_URL'];
  896. if (!runtimeUrl) {
  897. throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable');
  898. }
  899. return runtimeUrl;
  900. }
  901. static getCall(id_token_url) {
  902. var _a;
  903. return __awaiter(this, void 0, void 0, function* () {
  904. const httpclient = OidcClient.createHttpClient();
  905. const res = yield httpclient
  906. .getJson(id_token_url)
  907. .catch(error => {
  908. throw new Error(`Failed to get ID Token. \n
  909. Error Code : ${error.statusCode}\n
  910. Error Message: ${error.message}`);
  911. });
  912. const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value;
  913. if (!id_token) {
  914. throw new Error('Response json body do not have ID Token field');
  915. }
  916. return id_token;
  917. });
  918. }
  919. static getIDToken(audience) {
  920. return __awaiter(this, void 0, void 0, function* () {
  921. try {
  922. // New ID Token is requested from action service
  923. let id_token_url = OidcClient.getIDTokenUrl();
  924. if (audience) {
  925. const encodedAudience = encodeURIComponent(audience);
  926. id_token_url = `${id_token_url}&audience=${encodedAudience}`;
  927. }
  928. core_1.debug(`ID token url is ${id_token_url}`);
  929. const id_token = yield OidcClient.getCall(id_token_url);
  930. core_1.setSecret(id_token);
  931. return id_token;
  932. }
  933. catch (error) {
  934. throw new Error(`Error message: ${error.message}`);
  935. }
  936. });
  937. }
  938. }
  939. exports.OidcClient = OidcClient;
  940. //# sourceMappingURL=oidc-utils.js.map
  941. /***/ }),
  942. /***/ 670:
  943. /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
  944. "use strict";
  945. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  946. if (k2 === undefined) k2 = k;
  947. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  948. }) : (function(o, m, k, k2) {
  949. if (k2 === undefined) k2 = k;
  950. o[k2] = m[k];
  951. }));
  952. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  953. Object.defineProperty(o, "default", { enumerable: true, value: v });
  954. }) : function(o, v) {
  955. o["default"] = v;
  956. });
  957. var __importStar = (this && this.__importStar) || function (mod) {
  958. if (mod && mod.__esModule) return mod;
  959. var result = {};
  960. if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  961. __setModuleDefault(result, mod);
  962. return result;
  963. };
  964. Object.defineProperty(exports, "__esModule", ({ value: true }));
  965. exports.toPlatformPath = exports.toWin32Path = exports.toPosixPath = void 0;
  966. const path = __importStar(__nccwpck_require__(822));
  967. /**
  968. * toPosixPath converts the given path to the posix form. On Windows, \\ will be
  969. * replaced with /.
  970. *
  971. * @param pth. Path to transform.
  972. * @return string Posix path.
  973. */
  974. function toPosixPath(pth) {
  975. return pth.replace(/[\\]/g, '/');
  976. }
  977. exports.toPosixPath = toPosixPath;
  978. /**
  979. * toWin32Path converts the given path to the win32 form. On Linux, / will be
  980. * replaced with \\.
  981. *
  982. * @param pth. Path to transform.
  983. * @return string Win32 path.
  984. */
  985. function toWin32Path(pth) {
  986. return pth.replace(/[/]/g, '\\');
  987. }
  988. exports.toWin32Path = toWin32Path;
  989. /**
  990. * toPlatformPath converts the given path to a platform-specific path. It does
  991. * this by replacing instances of / and \ with the platform-specific path
  992. * separator.
  993. *
  994. * @param pth The path to platformize.
  995. * @return string The platform-specific path.
  996. */
  997. function toPlatformPath(pth) {
  998. return pth.replace(/[/\\]/g, path.sep);
  999. }
  1000. exports.toPlatformPath = toPlatformPath;
  1001. //# sourceMappingURL=path-utils.js.map
  1002. /***/ }),
  1003. /***/ 276:
  1004. /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
  1005. "use strict";
  1006. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  1007. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  1008. return new (P || (P = Promise))(function (resolve, reject) {
  1009. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  1010. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  1011. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  1012. step((generator = generator.apply(thisArg, _arguments || [])).next());
  1013. });
  1014. };
  1015. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1016. exports.summary = exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0;
  1017. const os_1 = __nccwpck_require__(37);
  1018. const fs_1 = __nccwpck_require__(147);
  1019. const { access, appendFile, writeFile } = fs_1.promises;
  1020. exports.SUMMARY_ENV_VAR = 'GITHUB_STEP_SUMMARY';
  1021. exports.SUMMARY_DOCS_URL = 'https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary';
  1022. class Summary {
  1023. constructor() {
  1024. this._buffer = '';
  1025. }
  1026. /**
  1027. * Finds the summary file path from the environment, rejects if env var is not found or file does not exist
  1028. * Also checks r/w permissions.
  1029. *
  1030. * @returns step summary file path
  1031. */
  1032. filePath() {
  1033. return __awaiter(this, void 0, void 0, function* () {
  1034. if (this._filePath) {
  1035. return this._filePath;
  1036. }
  1037. const pathFromEnv = process.env[exports.SUMMARY_ENV_VAR];
  1038. if (!pathFromEnv) {
  1039. throw new Error(`Unable to find environment variable for $${exports.SUMMARY_ENV_VAR}. Check if your runtime environment supports job summaries.`);
  1040. }
  1041. try {
  1042. yield access(pathFromEnv, fs_1.constants.R_OK | fs_1.constants.W_OK);
  1043. }
  1044. catch (_a) {
  1045. throw new Error(`Unable to access summary file: '${pathFromEnv}'. Check if the file has correct read/write permissions.`);
  1046. }
  1047. this._filePath = pathFromEnv;
  1048. return this._filePath;
  1049. });
  1050. }
  1051. /**
  1052. * Wraps content in an HTML tag, adding any HTML attributes
  1053. *
  1054. * @param {string} tag HTML tag to wrap
  1055. * @param {string | null} content content within the tag
  1056. * @param {[attribute: string]: string} attrs key-value list of HTML attributes to add
  1057. *
  1058. * @returns {string} content wrapped in HTML element
  1059. */
  1060. wrap(tag, content, attrs = {}) {
  1061. const htmlAttrs = Object.entries(attrs)
  1062. .map(([key, value]) => ` ${key}="${value}"`)
  1063. .join('');
  1064. if (!content) {
  1065. return `<${tag}${htmlAttrs}>`;
  1066. }
  1067. return `<${tag}${htmlAttrs}>${content}</${tag}>`;
  1068. }
  1069. /**
  1070. * Writes text in the buffer to the summary buffer file and empties buffer. Will append by default.
  1071. *
  1072. * @param {SummaryWriteOptions} [options] (optional) options for write operation
  1073. *
  1074. * @returns {Promise<Summary>} summary instance
  1075. */
  1076. write(options) {
  1077. return __awaiter(this, void 0, void 0, function* () {
  1078. const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite);
  1079. const filePath = yield this.filePath();
  1080. const writeFunc = overwrite ? writeFile : appendFile;
  1081. yield writeFunc(filePath, this._buffer, { encoding: 'utf8' });
  1082. return this.emptyBuffer();
  1083. });
  1084. }
  1085. /**
  1086. * Clears the summary buffer and wipes the summary file
  1087. *
  1088. * @returns {Summary} summary instance
  1089. */
  1090. clear() {
  1091. return __awaiter(this, void 0, void 0, function* () {
  1092. return this.emptyBuffer().write({ overwrite: true });
  1093. });
  1094. }
  1095. /**
  1096. * Returns the current summary buffer as a string
  1097. *
  1098. * @returns {string} string of summary buffer
  1099. */
  1100. stringify() {
  1101. return this._buffer;
  1102. }
  1103. /**
  1104. * If the summary buffer is empty
  1105. *
  1106. * @returns {boolen} true if the buffer is empty
  1107. */
  1108. isEmptyBuffer() {
  1109. return this._buffer.length === 0;
  1110. }
  1111. /**
  1112. * Resets the summary buffer without writing to summary file
  1113. *
  1114. * @returns {Summary} summary instance
  1115. */
  1116. emptyBuffer() {
  1117. this._buffer = '';
  1118. return this;
  1119. }
  1120. /**
  1121. * Adds raw text to the summary buffer
  1122. *
  1123. * @param {string} text content to add
  1124. * @param {boolean} [addEOL=false] (optional) append an EOL to the raw text (default: false)
  1125. *
  1126. * @returns {Summary} summary instance
  1127. */
  1128. addRaw(text, addEOL = false) {
  1129. this._buffer += text;
  1130. return addEOL ? this.addEOL() : this;
  1131. }
  1132. /**
  1133. * Adds the operating system-specific end-of-line marker to the buffer
  1134. *
  1135. * @returns {Summary} summary instance
  1136. */
  1137. addEOL() {
  1138. return this.addRaw(os_1.EOL);
  1139. }
  1140. /**
  1141. * Adds an HTML codeblock to the summary buffer
  1142. *
  1143. * @param {string} code content to render within fenced code block
  1144. * @param {string} lang (optional) language to syntax highlight code
  1145. *
  1146. * @returns {Summary} summary instance
  1147. */
  1148. addCodeBlock(code, lang) {
  1149. const attrs = Object.assign({}, (lang && { lang }));
  1150. const element = this.wrap('pre', this.wrap('code', code), attrs);
  1151. return this.addRaw(element).addEOL();
  1152. }
  1153. /**
  1154. * Adds an HTML list to the summary buffer
  1155. *
  1156. * @param {string[]} items list of items to render
  1157. * @param {boolean} [ordered=false] (optional) if the rendered list should be ordered or not (default: false)
  1158. *
  1159. * @returns {Summary} summary instance
  1160. */
  1161. addList(items, ordered = false) {
  1162. const tag = ordered ? 'ol' : 'ul';
  1163. const listItems = items.map(item => this.wrap('li', item)).join('');
  1164. const element = this.wrap(tag, listItems);
  1165. return this.addRaw(element).addEOL();
  1166. }
  1167. /**
  1168. * Adds an HTML table to the summary buffer
  1169. *
  1170. * @param {SummaryTableCell[]} rows table rows
  1171. *
  1172. * @returns {Summary} summary instance
  1173. */
  1174. addTable(rows) {
  1175. const tableBody = rows
  1176. .map(row => {
  1177. const cells = row
  1178. .map(cell => {
  1179. if (typeof cell === 'string') {
  1180. return this.wrap('td', cell);
  1181. }
  1182. const { header, data, colspan, rowspan } = cell;
  1183. const tag = header ? 'th' : 'td';
  1184. const attrs = Object.assign(Object.assign({}, (colspan && { colspan })), (rowspan && { rowspan }));
  1185. return this.wrap(tag, data, attrs);
  1186. })
  1187. .join('');
  1188. return this.wrap('tr', cells);
  1189. })
  1190. .join('');
  1191. const element = this.wrap('table', tableBody);
  1192. return this.addRaw(element).addEOL();
  1193. }
  1194. /**
  1195. * Adds a collapsable HTML details element to the summary buffer
  1196. *
  1197. * @param {string} label text for the closed state
  1198. * @param {string} content collapsable content
  1199. *
  1200. * @returns {Summary} summary instance
  1201. */
  1202. addDetails(label, content) {
  1203. const element = this.wrap('details', this.wrap('summary', label) + content);
  1204. return this.addRaw(element).addEOL();
  1205. }
  1206. /**
  1207. * Adds an HTML image tag to the summary buffer
  1208. *
  1209. * @param {string} src path to the image you to embed
  1210. * @param {string} alt text description of the image
  1211. * @param {SummaryImageOptions} options (optional) addition image attributes
  1212. *
  1213. * @returns {Summary} summary instance
  1214. */
  1215. addImage(src, alt, options) {
  1216. const { width, height } = options || {};
  1217. const attrs = Object.assign(Object.assign({}, (width && { width })), (height && { height }));
  1218. const element = this.wrap('img', null, Object.assign({ src, alt }, attrs));
  1219. return this.addRaw(element).addEOL();
  1220. }
  1221. /**
  1222. * Adds an HTML section heading element
  1223. *
  1224. * @param {string} text heading text
  1225. * @param {number | string} [level=1] (optional) the heading level, default: 1
  1226. *
  1227. * @returns {Summary} summary instance
  1228. */
  1229. addHeading(text, level) {
  1230. const tag = `h${level}`;
  1231. const allowedTag = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(tag)
  1232. ? tag
  1233. : 'h1';
  1234. const element = this.wrap(allowedTag, text);
  1235. return this.addRaw(element).addEOL();
  1236. }
  1237. /**
  1238. * Adds an HTML thematic break (<hr>) to the summary buffer
  1239. *
  1240. * @returns {Summary} summary instance
  1241. */
  1242. addSeparator() {
  1243. const element = this.wrap('hr', null);
  1244. return this.addRaw(element).addEOL();
  1245. }
  1246. /**
  1247. * Adds an HTML line break (<br>) to the summary buffer
  1248. *
  1249. * @returns {Summary} summary instance
  1250. */
  1251. addBreak() {
  1252. const element = this.wrap('br', null);
  1253. return this.addRaw(element).addEOL();
  1254. }
  1255. /**
  1256. * Adds an HTML blockquote to the summary buffer
  1257. *
  1258. * @param {string} text quote text
  1259. * @param {string} cite (optional) citation url
  1260. *
  1261. * @returns {Summary} summary instance
  1262. */
  1263. addQuote(text, cite) {
  1264. const attrs = Object.assign({}, (cite && { cite }));
  1265. const element = this.wrap('blockquote', text, attrs);
  1266. return this.addRaw(element).addEOL();
  1267. }
  1268. /**
  1269. * Adds an HTML anchor tag to the summary buffer
  1270. *
  1271. * @param {string} text link text/content
  1272. * @param {string} href hyperlink
  1273. *
  1274. * @returns {Summary} summary instance
  1275. */
  1276. addLink(text, href) {
  1277. const element = this.wrap('a', text, { href });
  1278. return this.addRaw(element).addEOL();
  1279. }
  1280. }
  1281. const _summary = new Summary();
  1282. /**
  1283. * @deprecated use `core.summary`
  1284. */
  1285. exports.markdownSummary = _summary;
  1286. exports.summary = _summary;
  1287. //# sourceMappingURL=summary.js.map
  1288. /***/ }),
  1289. /***/ 120:
  1290. /***/ ((__unused_webpack_module, exports) => {
  1291. "use strict";
  1292. // We use any as a valid input type
  1293. /* eslint-disable @typescript-eslint/no-explicit-any */
  1294. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1295. exports.toCommandProperties = exports.toCommandValue = void 0;
  1296. /**
  1297. * Sanitizes an input into a string so it can be passed into issueCommand safely
  1298. * @param input input to sanitize into a string
  1299. */
  1300. function toCommandValue(input) {
  1301. if (input === null || input === undefined) {
  1302. return '';
  1303. }
  1304. else if (typeof input === 'string' || input instanceof String) {
  1305. return input;
  1306. }
  1307. return JSON.stringify(input);
  1308. }
  1309. exports.toCommandValue = toCommandValue;
  1310. /**
  1311. *
  1312. * @param annotationProperties
  1313. * @returns The command properties to send with the actual annotation command
  1314. * See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646
  1315. */
  1316. function toCommandProperties(annotationProperties) {
  1317. if (!Object.keys(annotationProperties).length) {
  1318. return {};
  1319. }
  1320. return {
  1321. title: annotationProperties.title,
  1322. file: annotationProperties.file,
  1323. line: annotationProperties.startLine,
  1324. endLine: annotationProperties.endLine,
  1325. col: annotationProperties.startColumn,
  1326. endColumn: annotationProperties.endColumn
  1327. };
  1328. }
  1329. exports.toCommandProperties = toCommandProperties;
  1330. //# sourceMappingURL=utils.js.map
  1331. /***/ }),
  1332. /***/ 374:
  1333. /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
  1334. "use strict";
  1335. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  1336. if (k2 === undefined) k2 = k;
  1337. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  1338. }) : (function(o, m, k, k2) {
  1339. if (k2 === undefined) k2 = k;
  1340. o[k2] = m[k];
  1341. }));
  1342. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  1343. Object.defineProperty(o, "default", { enumerable: true, value: v });
  1344. }) : function(o, v) {
  1345. o["default"] = v;
  1346. });
  1347. var __importStar = (this && this.__importStar) || function (mod) {
  1348. if (mod && mod.__esModule) return mod;
  1349. var result = {};
  1350. if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  1351. __setModuleDefault(result, mod);
  1352. return result;
  1353. };
  1354. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  1355. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  1356. return new (P || (P = Promise))(function (resolve, reject) {
  1357. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  1358. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  1359. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  1360. step((generator = generator.apply(thisArg, _arguments || [])).next());
  1361. });
  1362. };
  1363. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1364. exports.argStringToArray = exports.ToolRunner = void 0;
  1365. const os = __importStar(__nccwpck_require__(37));
  1366. const events = __importStar(__nccwpck_require__(361));
  1367. const child = __importStar(__nccwpck_require__(81));
  1368. const path = __importStar(__nccwpck_require__(822));
  1369. const io = __importStar(__nccwpck_require__(826));
  1370. const ioUtil = __importStar(__nccwpck_require__(446));
  1371. const timers_1 = __nccwpck_require__(512);
  1372. /* eslint-disable @typescript-eslint/unbound-method */
  1373. const IS_WINDOWS = process.platform === 'win32';
  1374. /*
  1375. * Class for running command line tools. Handles quoting and arg parsing in a platform agnostic way.
  1376. */
  1377. class ToolRunner extends events.EventEmitter {
  1378. constructor(toolPath, args, options) {
  1379. super();
  1380. if (!toolPath) {
  1381. throw new Error("Parameter 'toolPath' cannot be null or empty.");
  1382. }
  1383. this.toolPath = toolPath;
  1384. this.args = args || [];
  1385. this.options = options || {};
  1386. }
  1387. _debug(message) {
  1388. if (this.options.listeners && this.options.listeners.debug) {
  1389. this.options.listeners.debug(message);
  1390. }
  1391. }
  1392. _getCommandString(options, noPrefix) {
  1393. const toolPath = this._getSpawnFileName();
  1394. const args = this._getSpawnArgs(options);
  1395. let cmd = noPrefix ? '' : '[command]'; // omit prefix when piped to a second tool
  1396. if (IS_WINDOWS) {
  1397. // Windows + cmd file
  1398. if (this._isCmdFile()) {
  1399. cmd += toolPath;
  1400. for (const a of args) {
  1401. cmd += ` ${a}`;
  1402. }
  1403. }
  1404. // Windows + verbatim
  1405. else if (options.windowsVerbatimArguments) {
  1406. cmd += `"${toolPath}"`;
  1407. for (const a of args) {
  1408. cmd += ` ${a}`;
  1409. }
  1410. }
  1411. // Windows (regular)
  1412. else {
  1413. cmd += this._windowsQuoteCmdArg(toolPath);
  1414. for (const a of args) {
  1415. cmd += ` ${this._windowsQuoteCmdArg(a)}`;
  1416. }
  1417. }
  1418. }
  1419. else {
  1420. // OSX/Linux - this can likely be improved with some form of quoting.
  1421. // creating processes on Unix is fundamentally different than Windows.
  1422. // on Unix, execvp() takes an arg array.
  1423. cmd += toolPath;
  1424. for (const a of args) {
  1425. cmd += ` ${a}`;
  1426. }
  1427. }
  1428. return cmd;
  1429. }
  1430. _processLineBuffer(data, strBuffer, onLine) {
  1431. try {
  1432. let s = strBuffer + data.toString();
  1433. let n = s.indexOf(os.EOL);
  1434. while (n > -1) {
  1435. const line = s.substring(0, n);
  1436. onLine(line);
  1437. // the rest of the string ...
  1438. s = s.substring(n + os.EOL.length);
  1439. n = s.indexOf(os.EOL);
  1440. }
  1441. return s;
  1442. }
  1443. catch (err) {
  1444. // streaming lines to console is best effort. Don't fail a build.
  1445. this._debug(`error processing line. Failed with error ${err}`);
  1446. return '';
  1447. }
  1448. }
  1449. _getSpawnFileName() {
  1450. if (IS_WINDOWS) {
  1451. if (this._isCmdFile()) {
  1452. return process.env['COMSPEC'] || 'cmd.exe';
  1453. }
  1454. }
  1455. return this.toolPath;
  1456. }
  1457. _getSpawnArgs(options) {
  1458. if (IS_WINDOWS) {
  1459. if (this._isCmdFile()) {
  1460. let argline = `/D /S /C "${this._windowsQuoteCmdArg(this.toolPath)}`;
  1461. for (const a of this.args) {
  1462. argline += ' ';
  1463. argline += options.windowsVerbatimArguments
  1464. ? a
  1465. : this._windowsQuoteCmdArg(a);
  1466. }
  1467. argline += '"';
  1468. return [argline];
  1469. }
  1470. }
  1471. return this.args;
  1472. }
  1473. _endsWith(str, end) {
  1474. return str.endsWith(end);
  1475. }
  1476. _isCmdFile() {
  1477. const upperToolPath = this.toolPath.toUpperCase();
  1478. return (this._endsWith(upperToolPath, '.CMD') ||
  1479. this._endsWith(upperToolPath, '.BAT'));
  1480. }
  1481. _windowsQuoteCmdArg(arg) {
  1482. // for .exe, apply the normal quoting rules that libuv applies
  1483. if (!this._isCmdFile()) {
  1484. return this._uvQuoteCmdArg(arg);
  1485. }
  1486. // otherwise apply quoting rules specific to the cmd.exe command line parser.
  1487. // the libuv rules are generic and are not designed specifically for cmd.exe
  1488. // command line parser.
  1489. //
  1490. // for a detailed description of the cmd.exe command line parser, refer to
  1491. // http://stackoverflow.com/questions/4094699/how-does-the-windows-command-interpreter-cmd-exe-parse-scripts/7970912#7970912
  1492. // need quotes for empty arg
  1493. if (!arg) {
  1494. return '""';
  1495. }
  1496. // determine whether the arg needs to be quoted
  1497. const cmdSpecialChars = [
  1498. ' ',
  1499. '\t',
  1500. '&',
  1501. '(',
  1502. ')',
  1503. '[',
  1504. ']',
  1505. '{',
  1506. '}',
  1507. '^',
  1508. '=',
  1509. ';',
  1510. '!',
  1511. "'",
  1512. '+',
  1513. ',',
  1514. '`',
  1515. '~',
  1516. '|',
  1517. '<',
  1518. '>',
  1519. '"'
  1520. ];
  1521. let needsQuotes = false;
  1522. for (const char of arg) {
  1523. if (cmdSpecialChars.some(x => x === char)) {
  1524. needsQuotes = true;
  1525. break;
  1526. }
  1527. }
  1528. // short-circuit if quotes not needed
  1529. if (!needsQuotes) {
  1530. return arg;
  1531. }
  1532. // the following quoting rules are very similar to the rules that by libuv applies.
  1533. //
  1534. // 1) wrap the string in quotes
  1535. //
  1536. // 2) double-up quotes - i.e. " => ""
  1537. //
  1538. // this is different from the libuv quoting rules. libuv replaces " with \", which unfortunately
  1539. // doesn't work well with a cmd.exe command line.
  1540. //
  1541. // note, replacing " with "" also works well if the arg is passed to a downstream .NET console app.
  1542. // for example, the command line:
  1543. // foo.exe "myarg:""my val"""
  1544. // is parsed by a .NET console app into an arg array:
  1545. // [ "myarg:\"my val\"" ]
  1546. // which is the same end result when applying libuv quoting rules. although the actual
  1547. // command line from libuv quoting rules would look like:
  1548. // foo.exe "myarg:\"my val\""
  1549. //
  1550. // 3) double-up slashes that precede a quote,
  1551. // e.g. hello \world => "hello \world"
  1552. // hello\"world => "hello\\""world"
  1553. // hello\\"world => "hello\\\\""world"
  1554. // hello world\ => "hello world\\"
  1555. //
  1556. // technically this is not required for a cmd.exe command line, or the batch argument parser.
  1557. // the reasons for including this as a .cmd quoting rule are:
  1558. //
  1559. // a) this is optimized for the scenario where the argument is passed from the .cmd file to an
  1560. // external program. many programs (e.g. .NET console apps) rely on the slash-doubling rule.
  1561. //
  1562. // b) it's what we've been doing previously (by deferring to node default behavior) and we
  1563. // haven't heard any complaints about that aspect.
  1564. //
  1565. // note, a weakness of the quoting rules chosen here, is that % is not escaped. in fact, % cannot be
  1566. // escaped when used on the command line directly - even though within a .cmd file % can be escaped
  1567. // by using %%.
  1568. //
  1569. // the saving grace is, on the command line, %var% is left as-is if var is not defined. this contrasts
  1570. // the line parsing rules within a .cmd file, where if var is not defined it is replaced with nothing.
  1571. //
  1572. // one option that was explored was replacing % with ^% - i.e. %var% => ^%var^%. this hack would
  1573. // often work, since it is unlikely that var^ would exist, and the ^ character is removed when the
  1574. // variable is used. the problem, however, is that ^ is not removed when %* is used to pass the args
  1575. // to an external program.
  1576. //
  1577. // an unexplored potential solution for the % escaping problem, is to create a wrapper .cmd file.
  1578. // % can be escaped within a .cmd file.
  1579. let reverse = '"';
  1580. let quoteHit = true;
  1581. for (let i = arg.length; i > 0; i--) {
  1582. // walk the string in reverse
  1583. reverse += arg[i - 1];
  1584. if (quoteHit && arg[i - 1] === '\\') {
  1585. reverse += '\\'; // double the slash
  1586. }
  1587. else if (arg[i - 1] === '"') {
  1588. quoteHit = true;
  1589. reverse += '"'; // double the quote
  1590. }
  1591. else {
  1592. quoteHit = false;
  1593. }
  1594. }
  1595. reverse += '"';
  1596. return reverse
  1597. .split('')
  1598. .reverse()
  1599. .join('');
  1600. }
  1601. _uvQuoteCmdArg(arg) {
  1602. // Tool runner wraps child_process.spawn() and needs to apply the same quoting as
  1603. // Node in certain cases where the undocumented spawn option windowsVerbatimArguments
  1604. // is used.
  1605. //
  1606. // Since this function is a port of quote_cmd_arg from Node 4.x (technically, lib UV,
  1607. // see https://github.com/nodejs/node/blob/v4.x/deps/uv/src/win/process.c for details),
  1608. // pasting copyright notice from Node within this function:
  1609. //
  1610. // Copyright Joyent, Inc. and other Node contributors. All rights reserved.
  1611. //
  1612. // Permission is hereby granted, free of charge, to any person obtaining a copy
  1613. // of this software and associated documentation files (the "Software"), to
  1614. // deal in the Software without restriction, including without limitation the
  1615. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  1616. // sell copies of the Software, and to permit persons to whom the Software is
  1617. // furnished to do so, subject to the following conditions:
  1618. //
  1619. // The above copyright notice and this permission notice shall be included in
  1620. // all copies or substantial portions of the Software.
  1621. //
  1622. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1623. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1624. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1625. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1626. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  1627. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  1628. // IN THE SOFTWARE.
  1629. if (!arg) {
  1630. // Need double quotation for empty argument
  1631. return '""';
  1632. }
  1633. if (!arg.includes(' ') && !arg.includes('\t') && !arg.includes('"')) {
  1634. // No quotation needed
  1635. return arg;
  1636. }
  1637. if (!arg.includes('"') && !arg.includes('\\')) {
  1638. // No embedded double quotes or backslashes, so I can just wrap
  1639. // quote marks around the whole thing.
  1640. return `"${arg}"`;
  1641. }
  1642. // Expected input/output:
  1643. // input : hello"world
  1644. // output: "hello\"world"
  1645. // input : hello""world
  1646. // output: "hello\"\"world"
  1647. // input : hello\world
  1648. // output: hello\world
  1649. // input : hello\\world
  1650. // output: hello\\world
  1651. // input : hello\"world
  1652. // output: "hello\\\"world"
  1653. // input : hello\\"world
  1654. // output: "hello\\\\\"world"
  1655. // input : hello world\
  1656. // output: "hello world\\" - note the comment in libuv actually reads "hello world\"
  1657. // but it appears the comment is wrong, it should be "hello world\\"
  1658. let reverse = '"';
  1659. let quoteHit = true;
  1660. for (let i = arg.length; i > 0; i--) {
  1661. // walk the string in reverse
  1662. reverse += arg[i - 1];
  1663. if (quoteHit && arg[i - 1] === '\\') {
  1664. reverse += '\\';
  1665. }
  1666. else if (arg[i - 1] === '"') {
  1667. quoteHit = true;
  1668. reverse += '\\';
  1669. }
  1670. else {
  1671. quoteHit = false;
  1672. }
  1673. }
  1674. reverse += '"';
  1675. return reverse
  1676. .split('')
  1677. .reverse()
  1678. .join('');
  1679. }
  1680. _cloneExecOptions(options) {
  1681. options = options || {};
  1682. const result = {
  1683. cwd: options.cwd || process.cwd(),
  1684. env: options.env || process.env,
  1685. silent: options.silent || false,
  1686. windowsVerbatimArguments: options.windowsVerbatimArguments || false,
  1687. failOnStdErr: options.failOnStdErr || false,
  1688. ignoreReturnCode: options.ignoreReturnCode || false,
  1689. delay: options.delay || 10000
  1690. };
  1691. result.outStream = options.outStream || process.stdout;
  1692. result.errStream = options.errStream || process.stderr;
  1693. return result;
  1694. }
  1695. _getSpawnOptions(options, toolPath) {
  1696. options = options || {};
  1697. const result = {};
  1698. result.cwd = options.cwd;
  1699. result.env = options.env;
  1700. result['windowsVerbatimArguments'] =
  1701. options.windowsVerbatimArguments || this._isCmdFile();
  1702. if (options.windowsVerbatimArguments) {
  1703. result.argv0 = `"${toolPath}"`;
  1704. }
  1705. return result;
  1706. }
  1707. /**
  1708. * Exec a tool.
  1709. * Output will be streamed to the live console.
  1710. * Returns promise with return code
  1711. *
  1712. * @param tool path to tool to exec
  1713. * @param options optional exec options. See ExecOptions
  1714. * @returns number
  1715. */
  1716. exec() {
  1717. return __awaiter(this, void 0, void 0, function* () {
  1718. // root the tool path if it is unrooted and contains relative pathing
  1719. if (!ioUtil.isRooted(this.toolPath) &&
  1720. (this.toolPath.includes('/') ||
  1721. (IS_WINDOWS && this.toolPath.includes('\\')))) {
  1722. // prefer options.cwd if it is specified, however options.cwd may also need to be rooted
  1723. this.toolPath = path.resolve(process.cwd(), this.options.cwd || process.cwd(), this.toolPath);
  1724. }
  1725. // if the tool is only a file name, then resolve it from the PATH
  1726. // otherwise verify it exists (add extension on Windows if necessary)
  1727. this.toolPath = yield io.which(this.toolPath, true);
  1728. return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
  1729. this._debug(`exec tool: ${this.toolPath}`);
  1730. this._debug('arguments:');
  1731. for (const arg of this.args) {
  1732. this._debug(` ${arg}`);
  1733. }
  1734. const optionsNonNull = this._cloneExecOptions(this.options);
  1735. if (!optionsNonNull.silent && optionsNonNull.outStream) {
  1736. optionsNonNull.outStream.write(this._getCommandString(optionsNonNull) + os.EOL);
  1737. }
  1738. const state = new ExecState(optionsNonNull, this.toolPath);
  1739. state.on('debug', (message) => {
  1740. this._debug(message);
  1741. });
  1742. if (this.options.cwd && !(yield ioUtil.exists(this.options.cwd))) {
  1743. return reject(new Error(`The cwd: ${this.options.cwd} does not exist!`));
  1744. }
  1745. const fileName = this._getSpawnFileName();
  1746. const cp = child.spawn(fileName, this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(this.options, fileName));
  1747. let stdbuffer = '';
  1748. if (cp.stdout) {
  1749. cp.stdout.on('data', (data) => {
  1750. if (this.options.listeners && this.options.listeners.stdout) {
  1751. this.options.listeners.stdout(data);
  1752. }
  1753. if (!optionsNonNull.silent && optionsNonNull.outStream) {
  1754. optionsNonNull.outStream.write(data);
  1755. }
  1756. stdbuffer = this._processLineBuffer(data, stdbuffer, (line) => {
  1757. if (this.options.listeners && this.options.listeners.stdline) {
  1758. this.options.listeners.stdline(line);
  1759. }
  1760. });
  1761. });
  1762. }
  1763. let errbuffer = '';
  1764. if (cp.stderr) {
  1765. cp.stderr.on('data', (data) => {
  1766. state.processStderr = true;
  1767. if (this.options.listeners && this.options.listeners.stderr) {
  1768. this.options.listeners.stderr(data);
  1769. }
  1770. if (!optionsNonNull.silent &&
  1771. optionsNonNull.errStream &&
  1772. optionsNonNull.outStream) {
  1773. const s = optionsNonNull.failOnStdErr
  1774. ? optionsNonNull.errStream
  1775. : optionsNonNull.outStream;
  1776. s.write(data);
  1777. }
  1778. errbuffer = this._processLineBuffer(data, errbuffer, (line) => {
  1779. if (this.options.listeners && this.options.listeners.errline) {
  1780. this.options.listeners.errline(line);
  1781. }
  1782. });
  1783. });
  1784. }
  1785. cp.on('error', (err) => {
  1786. state.processError = err.message;
  1787. state.processExited = true;
  1788. state.processClosed = true;
  1789. state.CheckComplete();
  1790. });
  1791. cp.on('exit', (code) => {
  1792. state.processExitCode = code;
  1793. state.processExited = true;
  1794. this._debug(`Exit code ${code} received from tool '${this.toolPath}'`);
  1795. state.CheckComplete();
  1796. });
  1797. cp.on('close', (code) => {
  1798. state.processExitCode = code;
  1799. state.processExited = true;
  1800. state.processClosed = true;
  1801. this._debug(`STDIO streams have closed for tool '${this.toolPath}'`);
  1802. state.CheckComplete();
  1803. });
  1804. state.on('done', (error, exitCode) => {
  1805. if (stdbuffer.length > 0) {
  1806. this.emit('stdline', stdbuffer);
  1807. }
  1808. if (errbuffer.length > 0) {
  1809. this.emit('errline', errbuffer);
  1810. }
  1811. cp.removeAllListeners();
  1812. if (error) {
  1813. reject(error);
  1814. }
  1815. else {
  1816. resolve(exitCode);
  1817. }
  1818. });
  1819. if (this.options.input) {
  1820. if (!cp.stdin) {
  1821. throw new Error('child process missing stdin');
  1822. }
  1823. cp.stdin.end(this.options.input);
  1824. }
  1825. }));
  1826. });
  1827. }
  1828. }
  1829. exports.ToolRunner = ToolRunner;
  1830. /**
  1831. * Convert an arg string to an array of args. Handles escaping
  1832. *
  1833. * @param argString string of arguments
  1834. * @returns string[] array of arguments
  1835. */
  1836. function argStringToArray(argString) {
  1837. const args = [];
  1838. let inQuotes = false;
  1839. let escaped = false;
  1840. let arg = '';
  1841. function append(c) {
  1842. // we only escape double quotes.
  1843. if (escaped && c !== '"') {
  1844. arg += '\\';
  1845. }
  1846. arg += c;
  1847. escaped = false;
  1848. }
  1849. for (let i = 0; i < argString.length; i++) {
  1850. const c = argString.charAt(i);
  1851. if (c === '"') {
  1852. if (!escaped) {
  1853. inQuotes = !inQuotes;
  1854. }
  1855. else {
  1856. append(c);
  1857. }
  1858. continue;
  1859. }
  1860. if (c === '\\' && escaped) {
  1861. append(c);
  1862. continue;
  1863. }
  1864. if (c === '\\' && inQuotes) {
  1865. escaped = true;
  1866. continue;
  1867. }
  1868. if (c === ' ' && !inQuotes) {
  1869. if (arg.length > 0) {
  1870. args.push(arg);
  1871. arg = '';
  1872. }
  1873. continue;
  1874. }
  1875. append(c);
  1876. }
  1877. if (arg.length > 0) {
  1878. args.push(arg.trim());
  1879. }
  1880. return args;
  1881. }
  1882. exports.argStringToArray = argStringToArray;
  1883. class ExecState extends events.EventEmitter {
  1884. constructor(options, toolPath) {
  1885. super();
  1886. this.processClosed = false; // tracks whether the process has exited and stdio is closed
  1887. this.processError = '';
  1888. this.processExitCode = 0;
  1889. this.processExited = false; // tracks whether the process has exited
  1890. this.processStderr = false; // tracks whether stderr was written to
  1891. this.delay = 10000; // 10 seconds
  1892. this.done = false;
  1893. this.timeout = null;
  1894. if (!toolPath) {
  1895. throw new Error('toolPath must not be empty');
  1896. }
  1897. this.options = options;
  1898. this.toolPath = toolPath;
  1899. if (options.delay) {
  1900. this.delay = options.delay;
  1901. }
  1902. }
  1903. CheckComplete() {
  1904. if (this.done) {
  1905. return;
  1906. }
  1907. if (this.processClosed) {
  1908. this._setResult();
  1909. }
  1910. else if (this.processExited) {
  1911. this.timeout = timers_1.setTimeout(ExecState.HandleTimeout, this.delay, this);
  1912. }
  1913. }
  1914. _debug(message) {
  1915. this.emit('debug', message);
  1916. }
  1917. _setResult() {
  1918. // determine whether there is an error
  1919. let error;
  1920. if (this.processExited) {
  1921. if (this.processError) {
  1922. error = new Error(`There was an error when attempting to execute the process '${this.toolPath}'. This may indicate the process failed to start. Error: ${this.processError}`);
  1923. }
  1924. else if (this.processExitCode !== 0 && !this.options.ignoreReturnCode) {
  1925. error = new Error(`The process '${this.toolPath}' failed with exit code ${this.processExitCode}`);
  1926. }
  1927. else if (this.processStderr && this.options.failOnStdErr) {
  1928. error = new Error(`The process '${this.toolPath}' failed because one or more lines were written to the STDERR stream`);
  1929. }
  1930. }
  1931. // clear the timeout
  1932. if (this.timeout) {
  1933. clearTimeout(this.timeout);
  1934. this.timeout = null;
  1935. }
  1936. this.done = true;
  1937. this.emit('done', error, this.processExitCode);
  1938. }
  1939. static HandleTimeout(state) {
  1940. if (state.done) {
  1941. return;
  1942. }
  1943. if (!state.processClosed && state.processExited) {
  1944. const message = `The STDIO streams did not close within ${state.delay /
  1945. 1000} seconds of the exit event from process '${state.toolPath}'. This may indicate a child process inherited the STDIO streams and has not yet exited.`;
  1946. state._debug(message);
  1947. }
  1948. state._setResult();
  1949. }
  1950. }
  1951. //# sourceMappingURL=toolrunner.js.map
  1952. /***/ }),
  1953. /***/ 267:
  1954. /***/ (function(__unused_webpack_module, exports) {
  1955. "use strict";
  1956. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  1957. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  1958. return new (P || (P = Promise))(function (resolve, reject) {
  1959. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  1960. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  1961. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  1962. step((generator = generator.apply(thisArg, _arguments || [])).next());
  1963. });
  1964. };
  1965. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1966. exports.PersonalAccessTokenCredentialHandler = exports.BearerCredentialHandler = exports.BasicCredentialHandler = void 0;
  1967. class BasicCredentialHandler {
  1968. constructor(username, password) {
  1969. this.username = username;
  1970. this.password = password;
  1971. }
  1972. prepareRequest(options) {
  1973. if (!options.headers) {
  1974. throw Error('The request has no headers');
  1975. }
  1976. options.headers['Authorization'] = `Basic ${Buffer.from(`${this.username}:${this.password}`).toString('base64')}`;
  1977. }
  1978. // This handler cannot handle 401
  1979. canHandleAuthentication() {
  1980. return false;
  1981. }
  1982. handleAuthentication() {
  1983. return __awaiter(this, void 0, void 0, function* () {
  1984. throw new Error('not implemented');
  1985. });
  1986. }
  1987. }
  1988. exports.BasicCredentialHandler = BasicCredentialHandler;
  1989. class BearerCredentialHandler {
  1990. constructor(token) {
  1991. this.token = token;
  1992. }
  1993. // currently implements pre-authorization
  1994. // TODO: support preAuth = false where it hooks on 401
  1995. prepareRequest(options) {
  1996. if (!options.headers) {
  1997. throw Error('The request has no headers');
  1998. }
  1999. options.headers['Authorization'] = `Bearer ${this.token}`;
  2000. }
  2001. // This handler cannot handle 401
  2002. canHandleAuthentication() {
  2003. return false;
  2004. }
  2005. handleAuthentication() {
  2006. return __awaiter(this, void 0, void 0, function* () {
  2007. throw new Error('not implemented');
  2008. });
  2009. }
  2010. }
  2011. exports.BearerCredentialHandler = BearerCredentialHandler;
  2012. class PersonalAccessTokenCredentialHandler {
  2013. constructor(token) {
  2014. this.token = token;
  2015. }
  2016. // currently implements pre-authorization
  2017. // TODO: support preAuth = false where it hooks on 401
  2018. prepareRequest(options) {
  2019. if (!options.headers) {
  2020. throw Error('The request has no headers');
  2021. }
  2022. options.headers['Authorization'] = `Basic ${Buffer.from(`PAT:${this.token}`).toString('base64')}`;
  2023. }
  2024. // This handler cannot handle 401
  2025. canHandleAuthentication() {
  2026. return false;
  2027. }
  2028. handleAuthentication() {
  2029. return __awaiter(this, void 0, void 0, function* () {
  2030. throw new Error('not implemented');
  2031. });
  2032. }
  2033. }
  2034. exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler;
  2035. //# sourceMappingURL=auth.js.map
  2036. /***/ }),
  2037. /***/ 503:
  2038. /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
  2039. "use strict";
  2040. /* eslint-disable @typescript-eslint/no-explicit-any */
  2041. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  2042. if (k2 === undefined) k2 = k;
  2043. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  2044. }) : (function(o, m, k, k2) {
  2045. if (k2 === undefined) k2 = k;
  2046. o[k2] = m[k];
  2047. }));
  2048. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  2049. Object.defineProperty(o, "default", { enumerable: true, value: v });
  2050. }) : function(o, v) {
  2051. o["default"] = v;
  2052. });
  2053. var __importStar = (this && this.__importStar) || function (mod) {
  2054. if (mod && mod.__esModule) return mod;
  2055. var result = {};
  2056. if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  2057. __setModuleDefault(result, mod);
  2058. return result;
  2059. };
  2060. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  2061. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  2062. return new (P || (P = Promise))(function (resolve, reject) {
  2063. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  2064. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  2065. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  2066. step((generator = generator.apply(thisArg, _arguments || [])).next());
  2067. });
  2068. };
  2069. Object.defineProperty(exports, "__esModule", ({ value: true }));
  2070. exports.HttpClient = exports.isHttps = exports.HttpClientResponse = exports.HttpClientError = exports.getProxyUrl = exports.MediaTypes = exports.Headers = exports.HttpCodes = void 0;
  2071. const http = __importStar(__nccwpck_require__(685));
  2072. const https = __importStar(__nccwpck_require__(687));
  2073. const pm = __importStar(__nccwpck_require__(602));
  2074. const tunnel = __importStar(__nccwpck_require__(225));
  2075. var HttpCodes;
  2076. (function (HttpCodes) {
  2077. HttpCodes[HttpCodes["OK"] = 200] = "OK";
  2078. HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices";
  2079. HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently";
  2080. HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved";
  2081. HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther";
  2082. HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified";
  2083. HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy";
  2084. HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy";
  2085. HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect";
  2086. HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect";
  2087. HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest";
  2088. HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized";
  2089. HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired";
  2090. HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden";
  2091. HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound";
  2092. HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed";
  2093. HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable";
  2094. HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
  2095. HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout";
  2096. HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict";
  2097. HttpCodes[HttpCodes["Gone"] = 410] = "Gone";
  2098. HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests";
  2099. HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError";
  2100. HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented";
  2101. HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway";
  2102. HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable";
  2103. HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout";
  2104. })(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {}));
  2105. var Headers;
  2106. (function (Headers) {
  2107. Headers["Accept"] = "accept";
  2108. Headers["ContentType"] = "content-type";
  2109. })(Headers = exports.Headers || (exports.Headers = {}));
  2110. var MediaTypes;
  2111. (function (MediaTypes) {
  2112. MediaTypes["ApplicationJson"] = "application/json";
  2113. })(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {}));
  2114. /**
  2115. * Returns the proxy URL, depending upon the supplied url and proxy environment variables.
  2116. * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
  2117. */
  2118. function getProxyUrl(serverUrl) {
  2119. const proxyUrl = pm.getProxyUrl(new URL(serverUrl));
  2120. return proxyUrl ? proxyUrl.href : '';
  2121. }
  2122. exports.getProxyUrl = getProxyUrl;
  2123. const HttpRedirectCodes = [
  2124. HttpCodes.MovedPermanently,
  2125. HttpCodes.ResourceMoved,
  2126. HttpCodes.SeeOther,
  2127. HttpCodes.TemporaryRedirect,
  2128. HttpCodes.PermanentRedirect
  2129. ];
  2130. const HttpResponseRetryCodes = [
  2131. HttpCodes.BadGateway,
  2132. HttpCodes.ServiceUnavailable,
  2133. HttpCodes.GatewayTimeout
  2134. ];
  2135. const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD'];
  2136. const ExponentialBackoffCeiling = 10;
  2137. const ExponentialBackoffTimeSlice = 5;
  2138. class HttpClientError extends Error {
  2139. constructor(message, statusCode) {
  2140. super(message);
  2141. this.name = 'HttpClientError';
  2142. this.statusCode = statusCode;
  2143. Object.setPrototypeOf(this, HttpClientError.prototype);
  2144. }
  2145. }
  2146. exports.HttpClientError = HttpClientError;
  2147. class HttpClientResponse {
  2148. constructor(message) {
  2149. this.message = message;
  2150. }
  2151. readBody() {
  2152. return __awaiter(this, void 0, void 0, function* () {
  2153. return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
  2154. let output = Buffer.alloc(0);
  2155. this.message.on('data', (chunk) => {
  2156. output = Buffer.concat([output, chunk]);
  2157. });
  2158. this.message.on('end', () => {
  2159. resolve(output.toString());
  2160. });
  2161. }));
  2162. });
  2163. }
  2164. }
  2165. exports.HttpClientResponse = HttpClientResponse;
  2166. function isHttps(requestUrl) {
  2167. const parsedUrl = new URL(requestUrl);
  2168. return parsedUrl.protocol === 'https:';
  2169. }
  2170. exports.isHttps = isHttps;
  2171. class HttpClient {
  2172. constructor(userAgent, handlers, requestOptions) {
  2173. this._ignoreSslError = false;
  2174. this._allowRedirects = true;
  2175. this._allowRedirectDowngrade = false;
  2176. this._maxRedirects = 50;
  2177. this._allowRetries = false;
  2178. this._maxRetries = 1;
  2179. this._keepAlive = false;
  2180. this._disposed = false;
  2181. this.userAgent = userAgent;
  2182. this.handlers = handlers || [];
  2183. this.requestOptions = requestOptions;
  2184. if (requestOptions) {
  2185. if (requestOptions.ignoreSslError != null) {
  2186. this._ignoreSslError = requestOptions.ignoreSslError;
  2187. }
  2188. this._socketTimeout = requestOptions.socketTimeout;
  2189. if (requestOptions.allowRedirects != null) {
  2190. this._allowRedirects = requestOptions.allowRedirects;
  2191. }
  2192. if (requestOptions.allowRedirectDowngrade != null) {
  2193. this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade;
  2194. }
  2195. if (requestOptions.maxRedirects != null) {
  2196. this._maxRedirects = Math.max(requestOptions.maxRedirects, 0);
  2197. }
  2198. if (requestOptions.keepAlive != null) {
  2199. this._keepAlive = requestOptions.keepAlive;
  2200. }
  2201. if (requestOptions.allowRetries != null) {
  2202. this._allowRetries = requestOptions.allowRetries;
  2203. }
  2204. if (requestOptions.maxRetries != null) {
  2205. this._maxRetries = requestOptions.maxRetries;
  2206. }
  2207. }
  2208. }
  2209. options(requestUrl, additionalHeaders) {
  2210. return __awaiter(this, void 0, void 0, function* () {
  2211. return this.request('OPTIONS', requestUrl, null, additionalHeaders || {});
  2212. });
  2213. }
  2214. get(requestUrl, additionalHeaders) {
  2215. return __awaiter(this, void 0, void 0, function* () {
  2216. return this.request('GET', requestUrl, null, additionalHeaders || {});
  2217. });
  2218. }
  2219. del(requestUrl, additionalHeaders) {
  2220. return __awaiter(this, void 0, void 0, function* () {
  2221. return this.request('DELETE', requestUrl, null, additionalHeaders || {});
  2222. });
  2223. }
  2224. post(requestUrl, data, additionalHeaders) {
  2225. return __awaiter(this, void 0, void 0, function* () {
  2226. return this.request('POST', requestUrl, data, additionalHeaders || {});
  2227. });
  2228. }
  2229. patch(requestUrl, data, additionalHeaders) {
  2230. return __awaiter(this, void 0, void 0, function* () {
  2231. return this.request('PATCH', requestUrl, data, additionalHeaders || {});
  2232. });
  2233. }
  2234. put(requestUrl, data, additionalHeaders) {
  2235. return __awaiter(this, void 0, void 0, function* () {
  2236. return this.request('PUT', requestUrl, data, additionalHeaders || {});
  2237. });
  2238. }
  2239. head(requestUrl, additionalHeaders) {
  2240. return __awaiter(this, void 0, void 0, function* () {
  2241. return this.request('HEAD', requestUrl, null, additionalHeaders || {});
  2242. });
  2243. }
  2244. sendStream(verb, requestUrl, stream, additionalHeaders) {
  2245. return __awaiter(this, void 0, void 0, function* () {
  2246. return this.request(verb, requestUrl, stream, additionalHeaders);
  2247. });
  2248. }
  2249. /**
  2250. * Gets a typed object from an endpoint
  2251. * Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
  2252. */
  2253. getJson(requestUrl, additionalHeaders = {}) {
  2254. return __awaiter(this, void 0, void 0, function* () {
  2255. additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
  2256. const res = yield this.get(requestUrl, additionalHeaders);
  2257. return this._processResponse(res, this.requestOptions);
  2258. });
  2259. }
  2260. postJson(requestUrl, obj, additionalHeaders = {}) {
  2261. return __awaiter(this, void 0, void 0, function* () {
  2262. const data = JSON.stringify(obj, null, 2);
  2263. additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
  2264. additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
  2265. const res = yield this.post(requestUrl, data, additionalHeaders);
  2266. return this._processResponse(res, this.requestOptions);
  2267. });
  2268. }
  2269. putJson(requestUrl, obj, additionalHeaders = {}) {
  2270. return __awaiter(this, void 0, void 0, function* () {
  2271. const data = JSON.stringify(obj, null, 2);
  2272. additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
  2273. additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
  2274. const res = yield this.put(requestUrl, data, additionalHeaders);
  2275. return this._processResponse(res, this.requestOptions);
  2276. });
  2277. }
  2278. patchJson(requestUrl, obj, additionalHeaders = {}) {
  2279. return __awaiter(this, void 0, void 0, function* () {
  2280. const data = JSON.stringify(obj, null, 2);
  2281. additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
  2282. additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
  2283. const res = yield this.patch(requestUrl, data, additionalHeaders);
  2284. return this._processResponse(res, this.requestOptions);
  2285. });
  2286. }
  2287. /**
  2288. * Makes a raw http request.
  2289. * All other methods such as get, post, patch, and request ultimately call this.
  2290. * Prefer get, del, post and patch
  2291. */
  2292. request(verb, requestUrl, data, headers) {
  2293. return __awaiter(this, void 0, void 0, function* () {
  2294. if (this._disposed) {
  2295. throw new Error('Client has already been disposed.');
  2296. }
  2297. const parsedUrl = new URL(requestUrl);
  2298. let info = this._prepareRequest(verb, parsedUrl, headers);
  2299. // Only perform retries on reads since writes may not be idempotent.
  2300. const maxTries = this._allowRetries && RetryableHttpVerbs.includes(verb)
  2301. ? this._maxRetries + 1
  2302. : 1;
  2303. let numTries = 0;
  2304. let response;
  2305. do {
  2306. response = yield this.requestRaw(info, data);
  2307. // Check if it's an authentication challenge
  2308. if (response &&
  2309. response.message &&
  2310. response.message.statusCode === HttpCodes.Unauthorized) {
  2311. let authenticationHandler;
  2312. for (const handler of this.handlers) {
  2313. if (handler.canHandleAuthentication(response)) {
  2314. authenticationHandler = handler;
  2315. break;
  2316. }
  2317. }
  2318. if (authenticationHandler) {
  2319. return authenticationHandler.handleAuthentication(this, info, data);
  2320. }
  2321. else {
  2322. // We have received an unauthorized response but have no handlers to handle it.
  2323. // Let the response return to the caller.
  2324. return response;
  2325. }
  2326. }
  2327. let redirectsRemaining = this._maxRedirects;
  2328. while (response.message.statusCode &&
  2329. HttpRedirectCodes.includes(response.message.statusCode) &&
  2330. this._allowRedirects &&
  2331. redirectsRemaining > 0) {
  2332. const redirectUrl = response.message.headers['location'];
  2333. if (!redirectUrl) {
  2334. // if there's no location to redirect to, we won't
  2335. break;
  2336. }
  2337. const parsedRedirectUrl = new URL(redirectUrl);
  2338. if (parsedUrl.protocol === 'https:' &&
  2339. parsedUrl.protocol !== parsedRedirectUrl.protocol &&
  2340. !this._allowRedirectDowngrade) {
  2341. throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.');
  2342. }
  2343. // we need to finish reading the response before reassigning response
  2344. // which will leak the open socket.
  2345. yield response.readBody();
  2346. // strip authorization header if redirected to a different hostname
  2347. if (parsedRedirectUrl.hostname !== parsedUrl.hostname) {
  2348. for (const header in headers) {
  2349. // header names are case insensitive
  2350. if (header.toLowerCase() === 'authorization') {
  2351. delete headers[header];
  2352. }
  2353. }
  2354. }
  2355. // let's make the request with the new redirectUrl
  2356. info = this._prepareRequest(verb, parsedRedirectUrl, headers);
  2357. response = yield this.requestRaw(info, data);
  2358. redirectsRemaining--;
  2359. }
  2360. if (!response.message.statusCode ||
  2361. !HttpResponseRetryCodes.includes(response.message.statusCode)) {
  2362. // If not a retry code, return immediately instead of retrying
  2363. return response;
  2364. }
  2365. numTries += 1;
  2366. if (numTries < maxTries) {
  2367. yield response.readBody();
  2368. yield this._performExponentialBackoff(numTries);
  2369. }
  2370. } while (numTries < maxTries);
  2371. return response;
  2372. });
  2373. }
  2374. /**
  2375. * Needs to be called if keepAlive is set to true in request options.
  2376. */
  2377. dispose() {
  2378. if (this._agent) {
  2379. this._agent.destroy();
  2380. }
  2381. this._disposed = true;
  2382. }
  2383. /**
  2384. * Raw request.
  2385. * @param info
  2386. * @param data
  2387. */
  2388. requestRaw(info, data) {
  2389. return __awaiter(this, void 0, void 0, function* () {
  2390. return new Promise((resolve, reject) => {
  2391. function callbackForResult(err, res) {
  2392. if (err) {
  2393. reject(err);
  2394. }
  2395. else if (!res) {
  2396. // If `err` is not passed, then `res` must be passed.
  2397. reject(new Error('Unknown error'));
  2398. }
  2399. else {
  2400. resolve(res);
  2401. }
  2402. }
  2403. this.requestRawWithCallback(info, data, callbackForResult);
  2404. });
  2405. });
  2406. }
  2407. /**
  2408. * Raw request with callback.
  2409. * @param info
  2410. * @param data
  2411. * @param onResult
  2412. */
  2413. requestRawWithCallback(info, data, onResult) {
  2414. if (typeof data === 'string') {
  2415. if (!info.options.headers) {
  2416. info.options.headers = {};
  2417. }
  2418. info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8');
  2419. }
  2420. let callbackCalled = false;
  2421. function handleResult(err, res) {
  2422. if (!callbackCalled) {
  2423. callbackCalled = true;
  2424. onResult(err, res);
  2425. }
  2426. }
  2427. const req = info.httpModule.request(info.options, (msg) => {
  2428. const res = new HttpClientResponse(msg);
  2429. handleResult(undefined, res);
  2430. });
  2431. let socket;
  2432. req.on('socket', sock => {
  2433. socket = sock;
  2434. });
  2435. // If we ever get disconnected, we want the socket to timeout eventually
  2436. req.setTimeout(this._socketTimeout || 3 * 60000, () => {
  2437. if (socket) {
  2438. socket.end();
  2439. }
  2440. handleResult(new Error(`Request timeout: ${info.options.path}`));
  2441. });
  2442. req.on('error', function (err) {
  2443. // err has statusCode property
  2444. // res should have headers
  2445. handleResult(err);
  2446. });
  2447. if (data && typeof data === 'string') {
  2448. req.write(data, 'utf8');
  2449. }
  2450. if (data && typeof data !== 'string') {
  2451. data.on('close', function () {
  2452. req.end();
  2453. });
  2454. data.pipe(req);
  2455. }
  2456. else {
  2457. req.end();
  2458. }
  2459. }
  2460. /**
  2461. * Gets an http agent. This function is useful when you need an http agent that handles
  2462. * routing through a proxy server - depending upon the url and proxy environment variables.
  2463. * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
  2464. */
  2465. getAgent(serverUrl) {
  2466. const parsedUrl = new URL(serverUrl);
  2467. return this._getAgent(parsedUrl);
  2468. }
  2469. _prepareRequest(method, requestUrl, headers) {
  2470. const info = {};
  2471. info.parsedUrl = requestUrl;
  2472. const usingSsl = info.parsedUrl.protocol === 'https:';
  2473. info.httpModule = usingSsl ? https : http;
  2474. const defaultPort = usingSsl ? 443 : 80;
  2475. info.options = {};
  2476. info.options.host = info.parsedUrl.hostname;
  2477. info.options.port = info.parsedUrl.port
  2478. ? parseInt(info.parsedUrl.port)
  2479. : defaultPort;
  2480. info.options.path =
  2481. (info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');
  2482. info.options.method = method;
  2483. info.options.headers = this._mergeHeaders(headers);
  2484. if (this.userAgent != null) {
  2485. info.options.headers['user-agent'] = this.userAgent;
  2486. }
  2487. info.options.agent = this._getAgent(info.parsedUrl);
  2488. // gives handlers an opportunity to participate
  2489. if (this.handlers) {
  2490. for (const handler of this.handlers) {
  2491. handler.prepareRequest(info.options);
  2492. }
  2493. }
  2494. return info;
  2495. }
  2496. _mergeHeaders(headers) {
  2497. if (this.requestOptions && this.requestOptions.headers) {
  2498. return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers || {}));
  2499. }
  2500. return lowercaseKeys(headers || {});
  2501. }
  2502. _getExistingOrDefaultHeader(additionalHeaders, header, _default) {
  2503. let clientHeader;
  2504. if (this.requestOptions && this.requestOptions.headers) {
  2505. clientHeader = lowercaseKeys(this.requestOptions.headers)[header];
  2506. }
  2507. return additionalHeaders[header] || clientHeader || _default;
  2508. }
  2509. _getAgent(parsedUrl) {
  2510. let agent;
  2511. const proxyUrl = pm.getProxyUrl(parsedUrl);
  2512. const useProxy = proxyUrl && proxyUrl.hostname;
  2513. if (this._keepAlive && useProxy) {
  2514. agent = this._proxyAgent;
  2515. }
  2516. if (this._keepAlive && !useProxy) {
  2517. agent = this._agent;
  2518. }
  2519. // if agent is already assigned use that agent.
  2520. if (agent) {
  2521. return agent;
  2522. }
  2523. const usingSsl = parsedUrl.protocol === 'https:';
  2524. let maxSockets = 100;
  2525. if (this.requestOptions) {
  2526. maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets;
  2527. }
  2528. // This is `useProxy` again, but we need to check `proxyURl` directly for TypeScripts's flow analysis.
  2529. if (proxyUrl && proxyUrl.hostname) {
  2530. const agentOptions = {
  2531. maxSockets,
  2532. keepAlive: this._keepAlive,
  2533. proxy: Object.assign(Object.assign({}, ((proxyUrl.username || proxyUrl.password) && {
  2534. proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`
  2535. })), { host: proxyUrl.hostname, port: proxyUrl.port })
  2536. };
  2537. let tunnelAgent;
  2538. const overHttps = proxyUrl.protocol === 'https:';
  2539. if (usingSsl) {
  2540. tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp;
  2541. }
  2542. else {
  2543. tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp;
  2544. }
  2545. agent = tunnelAgent(agentOptions);
  2546. this._proxyAgent = agent;
  2547. }
  2548. // if reusing agent across request and tunneling agent isn't assigned create a new agent
  2549. if (this._keepAlive && !agent) {
  2550. const options = { keepAlive: this._keepAlive, maxSockets };
  2551. agent = usingSsl ? new https.Agent(options) : new http.Agent(options);
  2552. this._agent = agent;
  2553. }
  2554. // if not using private agent and tunnel agent isn't setup then use global agent
  2555. if (!agent) {
  2556. agent = usingSsl ? https.globalAgent : http.globalAgent;
  2557. }
  2558. if (usingSsl && this._ignoreSslError) {
  2559. // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process
  2560. // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options
  2561. // we have to cast it to any and change it directly
  2562. agent.options = Object.assign(agent.options || {}, {
  2563. rejectUnauthorized: false
  2564. });
  2565. }
  2566. return agent;
  2567. }
  2568. _performExponentialBackoff(retryNumber) {
  2569. return __awaiter(this, void 0, void 0, function* () {
  2570. retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber);
  2571. const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber);
  2572. return new Promise(resolve => setTimeout(() => resolve(), ms));
  2573. });
  2574. }
  2575. _processResponse(res, options) {
  2576. return __awaiter(this, void 0, void 0, function* () {
  2577. return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
  2578. const statusCode = res.message.statusCode || 0;
  2579. const response = {
  2580. statusCode,
  2581. result: null,
  2582. headers: {}
  2583. };
  2584. // not found leads to null obj returned
  2585. if (statusCode === HttpCodes.NotFound) {
  2586. resolve(response);
  2587. }
  2588. // get the result from the body
  2589. function dateTimeDeserializer(key, value) {
  2590. if (typeof value === 'string') {
  2591. const a = new Date(value);
  2592. if (!isNaN(a.valueOf())) {
  2593. return a;
  2594. }
  2595. }
  2596. return value;
  2597. }
  2598. let obj;
  2599. let contents;
  2600. try {
  2601. contents = yield res.readBody();
  2602. if (contents && contents.length > 0) {
  2603. if (options && options.deserializeDates) {
  2604. obj = JSON.parse(contents, dateTimeDeserializer);
  2605. }
  2606. else {
  2607. obj = JSON.parse(contents);
  2608. }
  2609. response.result = obj;
  2610. }
  2611. response.headers = res.message.headers;
  2612. }
  2613. catch (err) {
  2614. // Invalid resource (contents not json); leaving result obj null
  2615. }
  2616. // note that 3xx redirects are handled by the http layer.
  2617. if (statusCode > 299) {
  2618. let msg;
  2619. // if exception/error in body, attempt to get better error
  2620. if (obj && obj.message) {
  2621. msg = obj.message;
  2622. }
  2623. else if (contents && contents.length > 0) {
  2624. // it may be the case that the exception is in the body message as string
  2625. msg = contents;
  2626. }
  2627. else {
  2628. msg = `Failed request: (${statusCode})`;
  2629. }
  2630. const err = new HttpClientError(msg, statusCode);
  2631. err.result = response.result;
  2632. reject(err);
  2633. }
  2634. else {
  2635. resolve(response);
  2636. }
  2637. }));
  2638. });
  2639. }
  2640. }
  2641. exports.HttpClient = HttpClient;
  2642. const lowercaseKeys = (obj) => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
  2643. //# sourceMappingURL=index.js.map
  2644. /***/ }),
  2645. /***/ 602:
  2646. /***/ ((__unused_webpack_module, exports) => {
  2647. "use strict";
  2648. Object.defineProperty(exports, "__esModule", ({ value: true }));
  2649. exports.checkBypass = exports.getProxyUrl = void 0;
  2650. function getProxyUrl(reqUrl) {
  2651. const usingSsl = reqUrl.protocol === 'https:';
  2652. if (checkBypass(reqUrl)) {
  2653. return undefined;
  2654. }
  2655. const proxyVar = (() => {
  2656. if (usingSsl) {
  2657. return process.env['https_proxy'] || process.env['HTTPS_PROXY'];
  2658. }
  2659. else {
  2660. return process.env['http_proxy'] || process.env['HTTP_PROXY'];
  2661. }
  2662. })();
  2663. if (proxyVar) {
  2664. return new URL(proxyVar);
  2665. }
  2666. else {
  2667. return undefined;
  2668. }
  2669. }
  2670. exports.getProxyUrl = getProxyUrl;
  2671. function checkBypass(reqUrl) {
  2672. if (!reqUrl.hostname) {
  2673. return false;
  2674. }
  2675. const reqHost = reqUrl.hostname;
  2676. if (isLoopbackAddress(reqHost)) {
  2677. return true;
  2678. }
  2679. const noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';
  2680. if (!noProxy) {
  2681. return false;
  2682. }
  2683. // Determine the request port
  2684. let reqPort;
  2685. if (reqUrl.port) {
  2686. reqPort = Number(reqUrl.port);
  2687. }
  2688. else if (reqUrl.protocol === 'http:') {
  2689. reqPort = 80;
  2690. }
  2691. else if (reqUrl.protocol === 'https:') {
  2692. reqPort = 443;
  2693. }
  2694. // Format the request hostname and hostname with port
  2695. const upperReqHosts = [reqUrl.hostname.toUpperCase()];
  2696. if (typeof reqPort === 'number') {
  2697. upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);
  2698. }
  2699. // Compare request host against noproxy
  2700. for (const upperNoProxyItem of noProxy
  2701. .split(',')
  2702. .map(x => x.trim().toUpperCase())
  2703. .filter(x => x)) {
  2704. if (upperNoProxyItem === '*' ||
  2705. upperReqHosts.some(x => x === upperNoProxyItem ||
  2706. x.endsWith(`.${upperNoProxyItem}`) ||
  2707. (upperNoProxyItem.startsWith('.') &&
  2708. x.endsWith(`${upperNoProxyItem}`)))) {
  2709. return true;
  2710. }
  2711. }
  2712. return false;
  2713. }
  2714. exports.checkBypass = checkBypass;
  2715. function isLoopbackAddress(host) {
  2716. const hostLower = host.toLowerCase();
  2717. return (hostLower === 'localhost' ||
  2718. hostLower.startsWith('127.') ||
  2719. hostLower.startsWith('[::1]') ||
  2720. hostLower.startsWith('[0:0:0:0:0:0:0:1]'));
  2721. }
  2722. //# sourceMappingURL=proxy.js.map
  2723. /***/ }),
  2724. /***/ 446:
  2725. /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
  2726. "use strict";
  2727. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  2728. if (k2 === undefined) k2 = k;
  2729. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  2730. }) : (function(o, m, k, k2) {
  2731. if (k2 === undefined) k2 = k;
  2732. o[k2] = m[k];
  2733. }));
  2734. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  2735. Object.defineProperty(o, "default", { enumerable: true, value: v });
  2736. }) : function(o, v) {
  2737. o["default"] = v;
  2738. });
  2739. var __importStar = (this && this.__importStar) || function (mod) {
  2740. if (mod && mod.__esModule) return mod;
  2741. var result = {};
  2742. if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  2743. __setModuleDefault(result, mod);
  2744. return result;
  2745. };
  2746. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  2747. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  2748. return new (P || (P = Promise))(function (resolve, reject) {
  2749. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  2750. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  2751. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  2752. step((generator = generator.apply(thisArg, _arguments || [])).next());
  2753. });
  2754. };
  2755. var _a;
  2756. Object.defineProperty(exports, "__esModule", ({ value: true }));
  2757. exports.getCmdPath = exports.tryGetExecutablePath = exports.isRooted = exports.isDirectory = exports.exists = exports.READONLY = exports.UV_FS_O_EXLOCK = exports.IS_WINDOWS = exports.unlink = exports.symlink = exports.stat = exports.rmdir = exports.rm = exports.rename = exports.readlink = exports.readdir = exports.open = exports.mkdir = exports.lstat = exports.copyFile = exports.chmod = void 0;
  2758. const fs = __importStar(__nccwpck_require__(147));
  2759. const path = __importStar(__nccwpck_require__(822));
  2760. _a = fs.promises
  2761. // export const {open} = 'fs'
  2762. , exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.open = _a.open, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rm = _a.rm, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink;
  2763. // export const {open} = 'fs'
  2764. exports.IS_WINDOWS = process.platform === 'win32';
  2765. // See https://github.com/nodejs/node/blob/d0153aee367422d0858105abec186da4dff0a0c5/deps/uv/include/uv/win.h#L691
  2766. exports.UV_FS_O_EXLOCK = 0x10000000;
  2767. exports.READONLY = fs.constants.O_RDONLY;
  2768. function exists(fsPath) {
  2769. return __awaiter(this, void 0, void 0, function* () {
  2770. try {
  2771. yield exports.stat(fsPath);
  2772. }
  2773. catch (err) {
  2774. if (err.code === 'ENOENT') {
  2775. return false;
  2776. }
  2777. throw err;
  2778. }
  2779. return true;
  2780. });
  2781. }
  2782. exports.exists = exists;
  2783. function isDirectory(fsPath, useStat = false) {
  2784. return __awaiter(this, void 0, void 0, function* () {
  2785. const stats = useStat ? yield exports.stat(fsPath) : yield exports.lstat(fsPath);
  2786. return stats.isDirectory();
  2787. });
  2788. }
  2789. exports.isDirectory = isDirectory;
  2790. /**
  2791. * On OSX/Linux, true if path starts with '/'. On Windows, true for paths like:
  2792. * \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases).
  2793. */
  2794. function isRooted(p) {
  2795. p = normalizeSeparators(p);
  2796. if (!p) {
  2797. throw new Error('isRooted() parameter "p" cannot be empty');
  2798. }
  2799. if (exports.IS_WINDOWS) {
  2800. return (p.startsWith('\\') || /^[A-Z]:/i.test(p) // e.g. \ or \hello or \\hello
  2801. ); // e.g. C: or C:\hello
  2802. }
  2803. return p.startsWith('/');
  2804. }
  2805. exports.isRooted = isRooted;
  2806. /**
  2807. * Best effort attempt to determine whether a file exists and is executable.
  2808. * @param filePath file path to check
  2809. * @param extensions additional file extensions to try
  2810. * @return if file exists and is executable, returns the file path. otherwise empty string.
  2811. */
  2812. function tryGetExecutablePath(filePath, extensions) {
  2813. return __awaiter(this, void 0, void 0, function* () {
  2814. let stats = undefined;
  2815. try {
  2816. // test file exists
  2817. stats = yield exports.stat(filePath);
  2818. }
  2819. catch (err) {
  2820. if (err.code !== 'ENOENT') {
  2821. // eslint-disable-next-line no-console
  2822. console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
  2823. }
  2824. }
  2825. if (stats && stats.isFile()) {
  2826. if (exports.IS_WINDOWS) {
  2827. // on Windows, test for valid extension
  2828. const upperExt = path.extname(filePath).toUpperCase();
  2829. if (extensions.some(validExt => validExt.toUpperCase() === upperExt)) {
  2830. return filePath;
  2831. }
  2832. }
  2833. else {
  2834. if (isUnixExecutable(stats)) {
  2835. return filePath;
  2836. }
  2837. }
  2838. }
  2839. // try each extension
  2840. const originalFilePath = filePath;
  2841. for (const extension of extensions) {
  2842. filePath = originalFilePath + extension;
  2843. stats = undefined;
  2844. try {
  2845. stats = yield exports.stat(filePath);
  2846. }
  2847. catch (err) {
  2848. if (err.code !== 'ENOENT') {
  2849. // eslint-disable-next-line no-console
  2850. console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
  2851. }
  2852. }
  2853. if (stats && stats.isFile()) {
  2854. if (exports.IS_WINDOWS) {
  2855. // preserve the case of the actual file (since an extension was appended)
  2856. try {
  2857. const directory = path.dirname(filePath);
  2858. const upperName = path.basename(filePath).toUpperCase();
  2859. for (const actualName of yield exports.readdir(directory)) {
  2860. if (upperName === actualName.toUpperCase()) {
  2861. filePath = path.join(directory, actualName);
  2862. break;
  2863. }
  2864. }
  2865. }
  2866. catch (err) {
  2867. // eslint-disable-next-line no-console
  2868. console.log(`Unexpected error attempting to determine the actual case of the file '${filePath}': ${err}`);
  2869. }
  2870. return filePath;
  2871. }
  2872. else {
  2873. if (isUnixExecutable(stats)) {
  2874. return filePath;
  2875. }
  2876. }
  2877. }
  2878. }
  2879. return '';
  2880. });
  2881. }
  2882. exports.tryGetExecutablePath = tryGetExecutablePath;
  2883. function normalizeSeparators(p) {
  2884. p = p || '';
  2885. if (exports.IS_WINDOWS) {
  2886. // convert slashes on Windows
  2887. p = p.replace(/\//g, '\\');
  2888. // remove redundant slashes
  2889. return p.replace(/\\\\+/g, '\\');
  2890. }
  2891. // remove redundant slashes
  2892. return p.replace(/\/\/+/g, '/');
  2893. }
  2894. // on Mac/Linux, test the execute bit
  2895. // R W X R W X R W X
  2896. // 256 128 64 32 16 8 4 2 1
  2897. function isUnixExecutable(stats) {
  2898. return ((stats.mode & 1) > 0 ||
  2899. ((stats.mode & 8) > 0 && stats.gid === process.getgid()) ||
  2900. ((stats.mode & 64) > 0 && stats.uid === process.getuid()));
  2901. }
  2902. // Get the path of cmd.exe in windows
  2903. function getCmdPath() {
  2904. var _a;
  2905. return (_a = process.env['COMSPEC']) !== null && _a !== void 0 ? _a : `cmd.exe`;
  2906. }
  2907. exports.getCmdPath = getCmdPath;
  2908. //# sourceMappingURL=io-util.js.map
  2909. /***/ }),
  2910. /***/ 826:
  2911. /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
  2912. "use strict";
  2913. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  2914. if (k2 === undefined) k2 = k;
  2915. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  2916. }) : (function(o, m, k, k2) {
  2917. if (k2 === undefined) k2 = k;
  2918. o[k2] = m[k];
  2919. }));
  2920. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  2921. Object.defineProperty(o, "default", { enumerable: true, value: v });
  2922. }) : function(o, v) {
  2923. o["default"] = v;
  2924. });
  2925. var __importStar = (this && this.__importStar) || function (mod) {
  2926. if (mod && mod.__esModule) return mod;
  2927. var result = {};
  2928. if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  2929. __setModuleDefault(result, mod);
  2930. return result;
  2931. };
  2932. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  2933. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  2934. return new (P || (P = Promise))(function (resolve, reject) {
  2935. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  2936. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  2937. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  2938. step((generator = generator.apply(thisArg, _arguments || [])).next());
  2939. });
  2940. };
  2941. Object.defineProperty(exports, "__esModule", ({ value: true }));
  2942. exports.findInPath = exports.which = exports.mkdirP = exports.rmRF = exports.mv = exports.cp = void 0;
  2943. const assert_1 = __nccwpck_require__(491);
  2944. const path = __importStar(__nccwpck_require__(822));
  2945. const ioUtil = __importStar(__nccwpck_require__(446));
  2946. /**
  2947. * Copies a file or folder.
  2948. * Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js
  2949. *
  2950. * @param source source path
  2951. * @param dest destination path
  2952. * @param options optional. See CopyOptions.
  2953. */
  2954. function cp(source, dest, options = {}) {
  2955. return __awaiter(this, void 0, void 0, function* () {
  2956. const { force, recursive, copySourceDirectory } = readCopyOptions(options);
  2957. const destStat = (yield ioUtil.exists(dest)) ? yield ioUtil.stat(dest) : null;
  2958. // Dest is an existing file, but not forcing
  2959. if (destStat && destStat.isFile() && !force) {
  2960. return;
  2961. }
  2962. // If dest is an existing directory, should copy inside.
  2963. const newDest = destStat && destStat.isDirectory() && copySourceDirectory
  2964. ? path.join(dest, path.basename(source))
  2965. : dest;
  2966. if (!(yield ioUtil.exists(source))) {
  2967. throw new Error(`no such file or directory: ${source}`);
  2968. }
  2969. const sourceStat = yield ioUtil.stat(source);
  2970. if (sourceStat.isDirectory()) {
  2971. if (!recursive) {
  2972. throw new Error(`Failed to copy. ${source} is a directory, but tried to copy without recursive flag.`);
  2973. }
  2974. else {
  2975. yield cpDirRecursive(source, newDest, 0, force);
  2976. }
  2977. }
  2978. else {
  2979. if (path.relative(source, newDest) === '') {
  2980. // a file cannot be copied to itself
  2981. throw new Error(`'${newDest}' and '${source}' are the same file`);
  2982. }
  2983. yield copyFile(source, newDest, force);
  2984. }
  2985. });
  2986. }
  2987. exports.cp = cp;
  2988. /**
  2989. * Moves a path.
  2990. *
  2991. * @param source source path
  2992. * @param dest destination path
  2993. * @param options optional. See MoveOptions.
  2994. */
  2995. function mv(source, dest, options = {}) {
  2996. return __awaiter(this, void 0, void 0, function* () {
  2997. if (yield ioUtil.exists(dest)) {
  2998. let destExists = true;
  2999. if (yield ioUtil.isDirectory(dest)) {
  3000. // If dest is directory copy src into dest
  3001. dest = path.join(dest, path.basename(source));
  3002. destExists = yield ioUtil.exists(dest);
  3003. }
  3004. if (destExists) {
  3005. if (options.force == null || options.force) {
  3006. yield rmRF(dest);
  3007. }
  3008. else {
  3009. throw new Error('Destination already exists');
  3010. }
  3011. }
  3012. }
  3013. yield mkdirP(path.dirname(dest));
  3014. yield ioUtil.rename(source, dest);
  3015. });
  3016. }
  3017. exports.mv = mv;
  3018. /**
  3019. * Remove a path recursively with force
  3020. *
  3021. * @param inputPath path to remove
  3022. */
  3023. function rmRF(inputPath) {
  3024. return __awaiter(this, void 0, void 0, function* () {
  3025. if (ioUtil.IS_WINDOWS) {
  3026. // Check for invalid characters
  3027. // https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
  3028. if (/[*"<>|]/.test(inputPath)) {
  3029. throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows');
  3030. }
  3031. }
  3032. try {
  3033. // note if path does not exist, error is silent
  3034. yield ioUtil.rm(inputPath, {
  3035. force: true,
  3036. maxRetries: 3,
  3037. recursive: true,
  3038. retryDelay: 300
  3039. });
  3040. }
  3041. catch (err) {
  3042. throw new Error(`File was unable to be removed ${err}`);
  3043. }
  3044. });
  3045. }
  3046. exports.rmRF = rmRF;
  3047. /**
  3048. * Make a directory. Creates the full path with folders in between
  3049. * Will throw if it fails
  3050. *
  3051. * @param fsPath path to create
  3052. * @returns Promise<void>
  3053. */
  3054. function mkdirP(fsPath) {
  3055. return __awaiter(this, void 0, void 0, function* () {
  3056. assert_1.ok(fsPath, 'a path argument must be provided');
  3057. yield ioUtil.mkdir(fsPath, { recursive: true });
  3058. });
  3059. }
  3060. exports.mkdirP = mkdirP;
  3061. /**
  3062. * Returns path of a tool had the tool actually been invoked. Resolves via paths.
  3063. * If you check and the tool does not exist, it will throw.
  3064. *
  3065. * @param tool name of the tool
  3066. * @param check whether to check if tool exists
  3067. * @returns Promise<string> path to tool
  3068. */
  3069. function which(tool, check) {
  3070. return __awaiter(this, void 0, void 0, function* () {
  3071. if (!tool) {
  3072. throw new Error("parameter 'tool' is required");
  3073. }
  3074. // recursive when check=true
  3075. if (check) {
  3076. const result = yield which(tool, false);
  3077. if (!result) {
  3078. if (ioUtil.IS_WINDOWS) {
  3079. throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`);
  3080. }
  3081. else {
  3082. throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`);
  3083. }
  3084. }
  3085. return result;
  3086. }
  3087. const matches = yield findInPath(tool);
  3088. if (matches && matches.length > 0) {
  3089. return matches[0];
  3090. }
  3091. return '';
  3092. });
  3093. }
  3094. exports.which = which;
  3095. /**
  3096. * Returns a list of all occurrences of the given tool on the system path.
  3097. *
  3098. * @returns Promise<string[]> the paths of the tool
  3099. */
  3100. function findInPath(tool) {
  3101. return __awaiter(this, void 0, void 0, function* () {
  3102. if (!tool) {
  3103. throw new Error("parameter 'tool' is required");
  3104. }
  3105. // build the list of extensions to try
  3106. const extensions = [];
  3107. if (ioUtil.IS_WINDOWS && process.env['PATHEXT']) {
  3108. for (const extension of process.env['PATHEXT'].split(path.delimiter)) {
  3109. if (extension) {
  3110. extensions.push(extension);
  3111. }
  3112. }
  3113. }
  3114. // if it's rooted, return it if exists. otherwise return empty.
  3115. if (ioUtil.isRooted(tool)) {
  3116. const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions);
  3117. if (filePath) {
  3118. return [filePath];
  3119. }
  3120. return [];
  3121. }
  3122. // if any path separators, return empty
  3123. if (tool.includes(path.sep)) {
  3124. return [];
  3125. }
  3126. // build the list of directories
  3127. //
  3128. // Note, technically "where" checks the current directory on Windows. From a toolkit perspective,
  3129. // it feels like we should not do this. Checking the current directory seems like more of a use
  3130. // case of a shell, and the which() function exposed by the toolkit should strive for consistency
  3131. // across platforms.
  3132. const directories = [];
  3133. if (process.env.PATH) {
  3134. for (const p of process.env.PATH.split(path.delimiter)) {
  3135. if (p) {
  3136. directories.push(p);
  3137. }
  3138. }
  3139. }
  3140. // find all matches
  3141. const matches = [];
  3142. for (const directory of directories) {
  3143. const filePath = yield ioUtil.tryGetExecutablePath(path.join(directory, tool), extensions);
  3144. if (filePath) {
  3145. matches.push(filePath);
  3146. }
  3147. }
  3148. return matches;
  3149. });
  3150. }
  3151. exports.findInPath = findInPath;
  3152. function readCopyOptions(options) {
  3153. const force = options.force == null ? true : options.force;
  3154. const recursive = Boolean(options.recursive);
  3155. const copySourceDirectory = options.copySourceDirectory == null
  3156. ? true
  3157. : Boolean(options.copySourceDirectory);
  3158. return { force, recursive, copySourceDirectory };
  3159. }
  3160. function cpDirRecursive(sourceDir, destDir, currentDepth, force) {
  3161. return __awaiter(this, void 0, void 0, function* () {
  3162. // Ensure there is not a run away recursive copy
  3163. if (currentDepth >= 255)
  3164. return;
  3165. currentDepth++;
  3166. yield mkdirP(destDir);
  3167. const files = yield ioUtil.readdir(sourceDir);
  3168. for (const fileName of files) {
  3169. const srcFile = `${sourceDir}/${fileName}`;
  3170. const destFile = `${destDir}/${fileName}`;
  3171. const srcFileStat = yield ioUtil.lstat(srcFile);
  3172. if (srcFileStat.isDirectory()) {
  3173. // Recurse
  3174. yield cpDirRecursive(srcFile, destFile, currentDepth, force);
  3175. }
  3176. else {
  3177. yield copyFile(srcFile, destFile, force);
  3178. }
  3179. }
  3180. // Change the mode for the newly created directory
  3181. yield ioUtil.chmod(destDir, (yield ioUtil.stat(sourceDir)).mode);
  3182. });
  3183. }
  3184. // Buffered file copy
  3185. function copyFile(srcFile, destFile, force) {
  3186. return __awaiter(this, void 0, void 0, function* () {
  3187. if ((yield ioUtil.lstat(srcFile)).isSymbolicLink()) {
  3188. // unlink/re-link it
  3189. try {
  3190. yield ioUtil.lstat(destFile);
  3191. yield ioUtil.unlink(destFile);
  3192. }
  3193. catch (e) {
  3194. // Try to override file permission
  3195. if (e.code === 'EPERM') {
  3196. yield ioUtil.chmod(destFile, '0666');
  3197. yield ioUtil.unlink(destFile);
  3198. }
  3199. // other errors = it doesn't exist, no work to do
  3200. }
  3201. // Copy over symlink
  3202. const symlinkFull = yield ioUtil.readlink(srcFile);
  3203. yield ioUtil.symlink(symlinkFull, destFile, ioUtil.IS_WINDOWS ? 'junction' : null);
  3204. }
  3205. else if (!(yield ioUtil.exists(destFile)) || force) {
  3206. yield ioUtil.copyFile(srcFile, destFile);
  3207. }
  3208. });
  3209. }
  3210. //# sourceMappingURL=io.js.map
  3211. /***/ }),
  3212. /***/ 225:
  3213. /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
  3214. module.exports = __nccwpck_require__(30);
  3215. /***/ }),
  3216. /***/ 30:
  3217. /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
  3218. "use strict";
  3219. var net = __nccwpck_require__(808);
  3220. var tls = __nccwpck_require__(404);
  3221. var http = __nccwpck_require__(685);
  3222. var https = __nccwpck_require__(687);
  3223. var events = __nccwpck_require__(361);
  3224. var assert = __nccwpck_require__(491);
  3225. var util = __nccwpck_require__(837);
  3226. exports.httpOverHttp = httpOverHttp;
  3227. exports.httpsOverHttp = httpsOverHttp;
  3228. exports.httpOverHttps = httpOverHttps;
  3229. exports.httpsOverHttps = httpsOverHttps;
  3230. function httpOverHttp(options) {
  3231. var agent = new TunnelingAgent(options);
  3232. agent.request = http.request;
  3233. return agent;
  3234. }
  3235. function httpsOverHttp(options) {
  3236. var agent = new TunnelingAgent(options);
  3237. agent.request = http.request;
  3238. agent.createSocket = createSecureSocket;
  3239. agent.defaultPort = 443;
  3240. return agent;
  3241. }
  3242. function httpOverHttps(options) {
  3243. var agent = new TunnelingAgent(options);
  3244. agent.request = https.request;
  3245. return agent;
  3246. }
  3247. function httpsOverHttps(options) {
  3248. var agent = new TunnelingAgent(options);
  3249. agent.request = https.request;
  3250. agent.createSocket = createSecureSocket;
  3251. agent.defaultPort = 443;
  3252. return agent;
  3253. }
  3254. function TunnelingAgent(options) {
  3255. var self = this;
  3256. self.options = options || {};
  3257. self.proxyOptions = self.options.proxy || {};
  3258. self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets;
  3259. self.requests = [];
  3260. self.sockets = [];
  3261. self.on('free', function onFree(socket, host, port, localAddress) {
  3262. var options = toOptions(host, port, localAddress);
  3263. for (var i = 0, len = self.requests.length; i < len; ++i) {
  3264. var pending = self.requests[i];
  3265. if (pending.host === options.host && pending.port === options.port) {
  3266. // Detect the request to connect same origin server,
  3267. // reuse the connection.
  3268. self.requests.splice(i, 1);
  3269. pending.request.onSocket(socket);
  3270. return;
  3271. }
  3272. }
  3273. socket.destroy();
  3274. self.removeSocket(socket);
  3275. });
  3276. }
  3277. util.inherits(TunnelingAgent, events.EventEmitter);
  3278. TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) {
  3279. var self = this;
  3280. var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress));
  3281. if (self.sockets.length >= this.maxSockets) {
  3282. // We are over limit so we'll add it to the queue.
  3283. self.requests.push(options);
  3284. return;
  3285. }
  3286. // If we are under maxSockets create a new one.
  3287. self.createSocket(options, function(socket) {
  3288. socket.on('free', onFree);
  3289. socket.on('close', onCloseOrRemove);
  3290. socket.on('agentRemove', onCloseOrRemove);
  3291. req.onSocket(socket);
  3292. function onFree() {
  3293. self.emit('free', socket, options);
  3294. }
  3295. function onCloseOrRemove(err) {
  3296. self.removeSocket(socket);
  3297. socket.removeListener('free', onFree);
  3298. socket.removeListener('close', onCloseOrRemove);
  3299. socket.removeListener('agentRemove', onCloseOrRemove);
  3300. }
  3301. });
  3302. };
  3303. TunnelingAgent.prototype.createSocket = function createSocket(options, cb) {
  3304. var self = this;
  3305. var placeholder = {};
  3306. self.sockets.push(placeholder);
  3307. var connectOptions = mergeOptions({}, self.proxyOptions, {
  3308. method: 'CONNECT',
  3309. path: options.host + ':' + options.port,
  3310. agent: false,
  3311. headers: {
  3312. host: options.host + ':' + options.port
  3313. }
  3314. });
  3315. if (options.localAddress) {
  3316. connectOptions.localAddress = options.localAddress;
  3317. }
  3318. if (connectOptions.proxyAuth) {
  3319. connectOptions.headers = connectOptions.headers || {};
  3320. connectOptions.headers['Proxy-Authorization'] = 'Basic ' +
  3321. new Buffer(connectOptions.proxyAuth).toString('base64');
  3322. }
  3323. debug('making CONNECT request');
  3324. var connectReq = self.request(connectOptions);
  3325. connectReq.useChunkedEncodingByDefault = false; // for v0.6
  3326. connectReq.once('response', onResponse); // for v0.6
  3327. connectReq.once('upgrade', onUpgrade); // for v0.6
  3328. connectReq.once('connect', onConnect); // for v0.7 or later
  3329. connectReq.once('error', onError);
  3330. connectReq.end();
  3331. function onResponse(res) {
  3332. // Very hacky. This is necessary to avoid http-parser leaks.
  3333. res.upgrade = true;
  3334. }
  3335. function onUpgrade(res, socket, head) {
  3336. // Hacky.
  3337. process.nextTick(function() {
  3338. onConnect(res, socket, head);
  3339. });
  3340. }
  3341. function onConnect(res, socket, head) {
  3342. connectReq.removeAllListeners();
  3343. socket.removeAllListeners();
  3344. if (res.statusCode !== 200) {
  3345. debug('tunneling socket could not be established, statusCode=%d',
  3346. res.statusCode);
  3347. socket.destroy();
  3348. var error = new Error('tunneling socket could not be established, ' +
  3349. 'statusCode=' + res.statusCode);
  3350. error.code = 'ECONNRESET';
  3351. options.request.emit('error', error);
  3352. self.removeSocket(placeholder);
  3353. return;
  3354. }
  3355. if (head.length > 0) {
  3356. debug('got illegal response body from proxy');
  3357. socket.destroy();
  3358. var error = new Error('got illegal response body from proxy');
  3359. error.code = 'ECONNRESET';
  3360. options.request.emit('error', error);
  3361. self.removeSocket(placeholder);
  3362. return;
  3363. }
  3364. debug('tunneling connection has established');
  3365. self.sockets[self.sockets.indexOf(placeholder)] = socket;
  3366. return cb(socket);
  3367. }
  3368. function onError(cause) {
  3369. connectReq.removeAllListeners();
  3370. debug('tunneling socket could not be established, cause=%s\n',
  3371. cause.message, cause.stack);
  3372. var error = new Error('tunneling socket could not be established, ' +
  3373. 'cause=' + cause.message);
  3374. error.code = 'ECONNRESET';
  3375. options.request.emit('error', error);
  3376. self.removeSocket(placeholder);
  3377. }
  3378. };
  3379. TunnelingAgent.prototype.removeSocket = function removeSocket(socket) {
  3380. var pos = this.sockets.indexOf(socket)
  3381. if (pos === -1) {
  3382. return;
  3383. }
  3384. this.sockets.splice(pos, 1);
  3385. var pending = this.requests.shift();
  3386. if (pending) {
  3387. // If we have pending requests and a socket gets closed a new one
  3388. // needs to be created to take over in the pool for the one that closed.
  3389. this.createSocket(pending, function(socket) {
  3390. pending.request.onSocket(socket);
  3391. });
  3392. }
  3393. };
  3394. function createSecureSocket(options, cb) {
  3395. var self = this;
  3396. TunnelingAgent.prototype.createSocket.call(self, options, function(socket) {
  3397. var hostHeader = options.request.getHeader('host');
  3398. var tlsOptions = mergeOptions({}, self.options, {
  3399. socket: socket,
  3400. servername: hostHeader ? hostHeader.replace(/:.*$/, '') : options.host
  3401. });
  3402. // 0 is dummy port for v0.6
  3403. var secureSocket = tls.connect(0, tlsOptions);
  3404. self.sockets[self.sockets.indexOf(socket)] = secureSocket;
  3405. cb(secureSocket);
  3406. });
  3407. }
  3408. function toOptions(host, port, localAddress) {
  3409. if (typeof host === 'string') { // since v0.10
  3410. return {
  3411. host: host,
  3412. port: port,
  3413. localAddress: localAddress
  3414. };
  3415. }
  3416. return host; // for v0.11 or later
  3417. }
  3418. function mergeOptions(target) {
  3419. for (var i = 1, len = arguments.length; i < len; ++i) {
  3420. var overrides = arguments[i];
  3421. if (typeof overrides === 'object') {
  3422. var keys = Object.keys(overrides);
  3423. for (var j = 0, keyLen = keys.length; j < keyLen; ++j) {
  3424. var k = keys[j];
  3425. if (overrides[k] !== undefined) {
  3426. target[k] = overrides[k];
  3427. }
  3428. }
  3429. }
  3430. }
  3431. return target;
  3432. }
  3433. var debug;
  3434. if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) {
  3435. debug = function() {
  3436. var args = Array.prototype.slice.call(arguments);
  3437. if (typeof args[0] === 'string') {
  3438. args[0] = 'TUNNEL: ' + args[0];
  3439. } else {
  3440. args.unshift('TUNNEL:');
  3441. }
  3442. console.error.apply(console, args);
  3443. }
  3444. } else {
  3445. debug = function() {};
  3446. }
  3447. exports.debug = debug; // for test
  3448. /***/ }),
  3449. /***/ 338:
  3450. /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
  3451. "use strict";
  3452. Object.defineProperty(exports, "__esModule", ({
  3453. value: true
  3454. }));
  3455. Object.defineProperty(exports, "v1", ({
  3456. enumerable: true,
  3457. get: function () {
  3458. return _v.default;
  3459. }
  3460. }));
  3461. Object.defineProperty(exports, "v3", ({
  3462. enumerable: true,
  3463. get: function () {
  3464. return _v2.default;
  3465. }
  3466. }));
  3467. Object.defineProperty(exports, "v4", ({
  3468. enumerable: true,
  3469. get: function () {
  3470. return _v3.default;
  3471. }
  3472. }));
  3473. Object.defineProperty(exports, "v5", ({
  3474. enumerable: true,
  3475. get: function () {
  3476. return _v4.default;
  3477. }
  3478. }));
  3479. Object.defineProperty(exports, "NIL", ({
  3480. enumerable: true,
  3481. get: function () {
  3482. return _nil.default;
  3483. }
  3484. }));
  3485. Object.defineProperty(exports, "version", ({
  3486. enumerable: true,
  3487. get: function () {
  3488. return _version.default;
  3489. }
  3490. }));
  3491. Object.defineProperty(exports, "validate", ({
  3492. enumerable: true,
  3493. get: function () {
  3494. return _validate.default;
  3495. }
  3496. }));
  3497. Object.defineProperty(exports, "stringify", ({
  3498. enumerable: true,
  3499. get: function () {
  3500. return _stringify.default;
  3501. }
  3502. }));
  3503. Object.defineProperty(exports, "parse", ({
  3504. enumerable: true,
  3505. get: function () {
  3506. return _parse.default;
  3507. }
  3508. }));
  3509. var _v = _interopRequireDefault(__nccwpck_require__(101));
  3510. var _v2 = _interopRequireDefault(__nccwpck_require__(456));
  3511. var _v3 = _interopRequireDefault(__nccwpck_require__(71));
  3512. var _v4 = _interopRequireDefault(__nccwpck_require__(57));
  3513. var _nil = _interopRequireDefault(__nccwpck_require__(448));
  3514. var _version = _interopRequireDefault(__nccwpck_require__(530));
  3515. var _validate = _interopRequireDefault(__nccwpck_require__(324));
  3516. var _stringify = _interopRequireDefault(__nccwpck_require__(284));
  3517. var _parse = _interopRequireDefault(__nccwpck_require__(67));
  3518. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3519. /***/ }),
  3520. /***/ 612:
  3521. /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
  3522. "use strict";
  3523. Object.defineProperty(exports, "__esModule", ({
  3524. value: true
  3525. }));
  3526. exports["default"] = void 0;
  3527. var _crypto = _interopRequireDefault(__nccwpck_require__(113));
  3528. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3529. function md5(bytes) {
  3530. if (Array.isArray(bytes)) {
  3531. bytes = Buffer.from(bytes);
  3532. } else if (typeof bytes === 'string') {
  3533. bytes = Buffer.from(bytes, 'utf8');
  3534. }
  3535. return _crypto.default.createHash('md5').update(bytes).digest();
  3536. }
  3537. var _default = md5;
  3538. exports["default"] = _default;
  3539. /***/ }),
  3540. /***/ 448:
  3541. /***/ ((__unused_webpack_module, exports) => {
  3542. "use strict";
  3543. Object.defineProperty(exports, "__esModule", ({
  3544. value: true
  3545. }));
  3546. exports["default"] = void 0;
  3547. var _default = '00000000-0000-0000-0000-000000000000';
  3548. exports["default"] = _default;
  3549. /***/ }),
  3550. /***/ 67:
  3551. /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
  3552. "use strict";
  3553. Object.defineProperty(exports, "__esModule", ({
  3554. value: true
  3555. }));
  3556. exports["default"] = void 0;
  3557. var _validate = _interopRequireDefault(__nccwpck_require__(324));
  3558. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3559. function parse(uuid) {
  3560. if (!(0, _validate.default)(uuid)) {
  3561. throw TypeError('Invalid UUID');
  3562. }
  3563. let v;
  3564. const arr = new Uint8Array(16); // Parse ########-....-....-....-............
  3565. arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
  3566. arr[1] = v >>> 16 & 0xff;
  3567. arr[2] = v >>> 8 & 0xff;
  3568. arr[3] = v & 0xff; // Parse ........-####-....-....-............
  3569. arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
  3570. arr[5] = v & 0xff; // Parse ........-....-####-....-............
  3571. arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
  3572. arr[7] = v & 0xff; // Parse ........-....-....-####-............
  3573. arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
  3574. arr[9] = v & 0xff; // Parse ........-....-....-....-############
  3575. // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
  3576. arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
  3577. arr[11] = v / 0x100000000 & 0xff;
  3578. arr[12] = v >>> 24 & 0xff;
  3579. arr[13] = v >>> 16 & 0xff;
  3580. arr[14] = v >>> 8 & 0xff;
  3581. arr[15] = v & 0xff;
  3582. return arr;
  3583. }
  3584. var _default = parse;
  3585. exports["default"] = _default;
  3586. /***/ }),
  3587. /***/ 610:
  3588. /***/ ((__unused_webpack_module, exports) => {
  3589. "use strict";
  3590. Object.defineProperty(exports, "__esModule", ({
  3591. value: true
  3592. }));
  3593. exports["default"] = void 0;
  3594. var _default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
  3595. exports["default"] = _default;
  3596. /***/ }),
  3597. /***/ 750:
  3598. /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
  3599. "use strict";
  3600. Object.defineProperty(exports, "__esModule", ({
  3601. value: true
  3602. }));
  3603. exports["default"] = rng;
  3604. var _crypto = _interopRequireDefault(__nccwpck_require__(113));
  3605. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3606. const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate
  3607. let poolPtr = rnds8Pool.length;
  3608. function rng() {
  3609. if (poolPtr > rnds8Pool.length - 16) {
  3610. _crypto.default.randomFillSync(rnds8Pool);
  3611. poolPtr = 0;
  3612. }
  3613. return rnds8Pool.slice(poolPtr, poolPtr += 16);
  3614. }
  3615. /***/ }),
  3616. /***/ 920:
  3617. /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
  3618. "use strict";
  3619. Object.defineProperty(exports, "__esModule", ({
  3620. value: true
  3621. }));
  3622. exports["default"] = void 0;
  3623. var _crypto = _interopRequireDefault(__nccwpck_require__(113));
  3624. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3625. function sha1(bytes) {
  3626. if (Array.isArray(bytes)) {
  3627. bytes = Buffer.from(bytes);
  3628. } else if (typeof bytes === 'string') {
  3629. bytes = Buffer.from(bytes, 'utf8');
  3630. }
  3631. return _crypto.default.createHash('sha1').update(bytes).digest();
  3632. }
  3633. var _default = sha1;
  3634. exports["default"] = _default;
  3635. /***/ }),
  3636. /***/ 284:
  3637. /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
  3638. "use strict";
  3639. Object.defineProperty(exports, "__esModule", ({
  3640. value: true
  3641. }));
  3642. exports["default"] = void 0;
  3643. var _validate = _interopRequireDefault(__nccwpck_require__(324));
  3644. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3645. /**
  3646. * Convert array of 16 byte values to UUID string format of the form:
  3647. * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
  3648. */
  3649. const byteToHex = [];
  3650. for (let i = 0; i < 256; ++i) {
  3651. byteToHex.push((i + 0x100).toString(16).substr(1));
  3652. }
  3653. function stringify(arr, offset = 0) {
  3654. // Note: Be careful editing this code! It's been tuned for performance
  3655. // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
  3656. const uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
  3657. // of the following:
  3658. // - One or more input array values don't map to a hex octet (leading to
  3659. // "undefined" in the uuid)
  3660. // - Invalid input values for the RFC `version` or `variant` fields
  3661. if (!(0, _validate.default)(uuid)) {
  3662. throw TypeError('Stringified UUID is invalid');
  3663. }
  3664. return uuid;
  3665. }
  3666. var _default = stringify;
  3667. exports["default"] = _default;
  3668. /***/ }),
  3669. /***/ 101:
  3670. /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
  3671. "use strict";
  3672. Object.defineProperty(exports, "__esModule", ({
  3673. value: true
  3674. }));
  3675. exports["default"] = void 0;
  3676. var _rng = _interopRequireDefault(__nccwpck_require__(750));
  3677. var _stringify = _interopRequireDefault(__nccwpck_require__(284));
  3678. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3679. // **`v1()` - Generate time-based UUID**
  3680. //
  3681. // Inspired by https://github.com/LiosK/UUID.js
  3682. // and http://docs.python.org/library/uuid.html
  3683. let _nodeId;
  3684. let _clockseq; // Previous uuid creation time
  3685. let _lastMSecs = 0;
  3686. let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details
  3687. function v1(options, buf, offset) {
  3688. let i = buf && offset || 0;
  3689. const b = buf || new Array(16);
  3690. options = options || {};
  3691. let node = options.node || _nodeId;
  3692. let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not
  3693. // specified. We do this lazily to minimize issues related to insufficient
  3694. // system entropy. See #189
  3695. if (node == null || clockseq == null) {
  3696. const seedBytes = options.random || (options.rng || _rng.default)();
  3697. if (node == null) {
  3698. // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
  3699. node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
  3700. }
  3701. if (clockseq == null) {
  3702. // Per 4.2.2, randomize (14 bit) clockseq
  3703. clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
  3704. }
  3705. } // UUID timestamps are 100 nano-second units since the Gregorian epoch,
  3706. // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
  3707. // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
  3708. // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
  3709. let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock
  3710. // cycle to simulate higher resolution clock
  3711. let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs)
  3712. const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression
  3713. if (dt < 0 && options.clockseq === undefined) {
  3714. clockseq = clockseq + 1 & 0x3fff;
  3715. } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
  3716. // time interval
  3717. if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
  3718. nsecs = 0;
  3719. } // Per 4.2.1.2 Throw error if too many uuids are requested
  3720. if (nsecs >= 10000) {
  3721. throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
  3722. }
  3723. _lastMSecs = msecs;
  3724. _lastNSecs = nsecs;
  3725. _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
  3726. msecs += 12219292800000; // `time_low`
  3727. const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
  3728. b[i++] = tl >>> 24 & 0xff;
  3729. b[i++] = tl >>> 16 & 0xff;
  3730. b[i++] = tl >>> 8 & 0xff;
  3731. b[i++] = tl & 0xff; // `time_mid`
  3732. const tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
  3733. b[i++] = tmh >>> 8 & 0xff;
  3734. b[i++] = tmh & 0xff; // `time_high_and_version`
  3735. b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
  3736. b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
  3737. b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low`
  3738. b[i++] = clockseq & 0xff; // `node`
  3739. for (let n = 0; n < 6; ++n) {
  3740. b[i + n] = node[n];
  3741. }
  3742. return buf || (0, _stringify.default)(b);
  3743. }
  3744. var _default = v1;
  3745. exports["default"] = _default;
  3746. /***/ }),
  3747. /***/ 456:
  3748. /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
  3749. "use strict";
  3750. Object.defineProperty(exports, "__esModule", ({
  3751. value: true
  3752. }));
  3753. exports["default"] = void 0;
  3754. var _v = _interopRequireDefault(__nccwpck_require__(390));
  3755. var _md = _interopRequireDefault(__nccwpck_require__(612));
  3756. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3757. const v3 = (0, _v.default)('v3', 0x30, _md.default);
  3758. var _default = v3;
  3759. exports["default"] = _default;
  3760. /***/ }),
  3761. /***/ 390:
  3762. /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
  3763. "use strict";
  3764. Object.defineProperty(exports, "__esModule", ({
  3765. value: true
  3766. }));
  3767. exports["default"] = _default;
  3768. exports.URL = exports.DNS = void 0;
  3769. var _stringify = _interopRequireDefault(__nccwpck_require__(284));
  3770. var _parse = _interopRequireDefault(__nccwpck_require__(67));
  3771. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3772. function stringToBytes(str) {
  3773. str = unescape(encodeURIComponent(str)); // UTF8 escape
  3774. const bytes = [];
  3775. for (let i = 0; i < str.length; ++i) {
  3776. bytes.push(str.charCodeAt(i));
  3777. }
  3778. return bytes;
  3779. }
  3780. const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
  3781. exports.DNS = DNS;
  3782. const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
  3783. exports.URL = URL;
  3784. function _default(name, version, hashfunc) {
  3785. function generateUUID(value, namespace, buf, offset) {
  3786. if (typeof value === 'string') {
  3787. value = stringToBytes(value);
  3788. }
  3789. if (typeof namespace === 'string') {
  3790. namespace = (0, _parse.default)(namespace);
  3791. }
  3792. if (namespace.length !== 16) {
  3793. throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
  3794. } // Compute hash of namespace and value, Per 4.3
  3795. // Future: Use spread syntax when supported on all platforms, e.g. `bytes =
  3796. // hashfunc([...namespace, ... value])`
  3797. let bytes = new Uint8Array(16 + value.length);
  3798. bytes.set(namespace);
  3799. bytes.set(value, namespace.length);
  3800. bytes = hashfunc(bytes);
  3801. bytes[6] = bytes[6] & 0x0f | version;
  3802. bytes[8] = bytes[8] & 0x3f | 0x80;
  3803. if (buf) {
  3804. offset = offset || 0;
  3805. for (let i = 0; i < 16; ++i) {
  3806. buf[offset + i] = bytes[i];
  3807. }
  3808. return buf;
  3809. }
  3810. return (0, _stringify.default)(bytes);
  3811. } // Function#name is not settable on some platforms (#270)
  3812. try {
  3813. generateUUID.name = name; // eslint-disable-next-line no-empty
  3814. } catch (err) {} // For CommonJS default export support
  3815. generateUUID.DNS = DNS;
  3816. generateUUID.URL = URL;
  3817. return generateUUID;
  3818. }
  3819. /***/ }),
  3820. /***/ 71:
  3821. /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
  3822. "use strict";
  3823. Object.defineProperty(exports, "__esModule", ({
  3824. value: true
  3825. }));
  3826. exports["default"] = void 0;
  3827. var _rng = _interopRequireDefault(__nccwpck_require__(750));
  3828. var _stringify = _interopRequireDefault(__nccwpck_require__(284));
  3829. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3830. function v4(options, buf, offset) {
  3831. options = options || {};
  3832. const rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
  3833. rnds[6] = rnds[6] & 0x0f | 0x40;
  3834. rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
  3835. if (buf) {
  3836. offset = offset || 0;
  3837. for (let i = 0; i < 16; ++i) {
  3838. buf[offset + i] = rnds[i];
  3839. }
  3840. return buf;
  3841. }
  3842. return (0, _stringify.default)(rnds);
  3843. }
  3844. var _default = v4;
  3845. exports["default"] = _default;
  3846. /***/ }),
  3847. /***/ 57:
  3848. /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
  3849. "use strict";
  3850. Object.defineProperty(exports, "__esModule", ({
  3851. value: true
  3852. }));
  3853. exports["default"] = void 0;
  3854. var _v = _interopRequireDefault(__nccwpck_require__(390));
  3855. var _sha = _interopRequireDefault(__nccwpck_require__(920));
  3856. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3857. const v5 = (0, _v.default)('v5', 0x50, _sha.default);
  3858. var _default = v5;
  3859. exports["default"] = _default;
  3860. /***/ }),
  3861. /***/ 324:
  3862. /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
  3863. "use strict";
  3864. Object.defineProperty(exports, "__esModule", ({
  3865. value: true
  3866. }));
  3867. exports["default"] = void 0;
  3868. var _regex = _interopRequireDefault(__nccwpck_require__(610));
  3869. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3870. function validate(uuid) {
  3871. return typeof uuid === 'string' && _regex.default.test(uuid);
  3872. }
  3873. var _default = validate;
  3874. exports["default"] = _default;
  3875. /***/ }),
  3876. /***/ 530:
  3877. /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
  3878. "use strict";
  3879. Object.defineProperty(exports, "__esModule", ({
  3880. value: true
  3881. }));
  3882. exports["default"] = void 0;
  3883. var _validate = _interopRequireDefault(__nccwpck_require__(324));
  3884. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3885. function version(uuid) {
  3886. if (!(0, _validate.default)(uuid)) {
  3887. throw TypeError('Invalid UUID');
  3888. }
  3889. return parseInt(uuid.substr(14, 1), 16);
  3890. }
  3891. var _default = version;
  3892. exports["default"] = _default;
  3893. /***/ }),
  3894. /***/ 491:
  3895. /***/ ((module) => {
  3896. "use strict";
  3897. module.exports = require("assert");
  3898. /***/ }),
  3899. /***/ 81:
  3900. /***/ ((module) => {
  3901. "use strict";
  3902. module.exports = require("child_process");
  3903. /***/ }),
  3904. /***/ 113:
  3905. /***/ ((module) => {
  3906. "use strict";
  3907. module.exports = require("crypto");
  3908. /***/ }),
  3909. /***/ 361:
  3910. /***/ ((module) => {
  3911. "use strict";
  3912. module.exports = require("events");
  3913. /***/ }),
  3914. /***/ 147:
  3915. /***/ ((module) => {
  3916. "use strict";
  3917. module.exports = require("fs");
  3918. /***/ }),
  3919. /***/ 292:
  3920. /***/ ((module) => {
  3921. "use strict";
  3922. module.exports = require("fs/promises");
  3923. /***/ }),
  3924. /***/ 685:
  3925. /***/ ((module) => {
  3926. "use strict";
  3927. module.exports = require("http");
  3928. /***/ }),
  3929. /***/ 687:
  3930. /***/ ((module) => {
  3931. "use strict";
  3932. module.exports = require("https");
  3933. /***/ }),
  3934. /***/ 808:
  3935. /***/ ((module) => {
  3936. "use strict";
  3937. module.exports = require("net");
  3938. /***/ }),
  3939. /***/ 37:
  3940. /***/ ((module) => {
  3941. "use strict";
  3942. module.exports = require("os");
  3943. /***/ }),
  3944. /***/ 822:
  3945. /***/ ((module) => {
  3946. "use strict";
  3947. module.exports = require("path");
  3948. /***/ }),
  3949. /***/ 282:
  3950. /***/ ((module) => {
  3951. "use strict";
  3952. module.exports = require("process");
  3953. /***/ }),
  3954. /***/ 512:
  3955. /***/ ((module) => {
  3956. "use strict";
  3957. module.exports = require("timers");
  3958. /***/ }),
  3959. /***/ 404:
  3960. /***/ ((module) => {
  3961. "use strict";
  3962. module.exports = require("tls");
  3963. /***/ }),
  3964. /***/ 837:
  3965. /***/ ((module) => {
  3966. "use strict";
  3967. module.exports = require("util");
  3968. /***/ })
  3969. /******/ });
  3970. /************************************************************************/
  3971. /******/ // The module cache
  3972. /******/ var __webpack_module_cache__ = {};
  3973. /******/
  3974. /******/ // The require function
  3975. /******/ function __nccwpck_require__(moduleId) {
  3976. /******/ // Check if module is in cache
  3977. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  3978. /******/ if (cachedModule !== undefined) {
  3979. /******/ return cachedModule.exports;
  3980. /******/ }
  3981. /******/ // Create a new module (and put it into the cache)
  3982. /******/ var module = __webpack_module_cache__[moduleId] = {
  3983. /******/ // no module.id needed
  3984. /******/ // no module.loaded needed
  3985. /******/ exports: {}
  3986. /******/ };
  3987. /******/
  3988. /******/ // Execute the module function
  3989. /******/ var threw = true;
  3990. /******/ try {
  3991. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __nccwpck_require__);
  3992. /******/ threw = false;
  3993. /******/ } finally {
  3994. /******/ if(threw) delete __webpack_module_cache__[moduleId];
  3995. /******/ }
  3996. /******/
  3997. /******/ // Return the exports of the module
  3998. /******/ return module.exports;
  3999. /******/ }
  4000. /******/
  4001. /************************************************************************/
  4002. /******/ /* webpack/runtime/compat */
  4003. /******/
  4004. /******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
  4005. /******/
  4006. /************************************************************************/
  4007. /******/
  4008. /******/ // startup
  4009. /******/ // Load entry module and return exports
  4010. /******/ // This entry module is referenced by other modules so it can't be inlined
  4011. /******/ var __webpack_exports__ = __nccwpck_require__(234);
  4012. /******/ module.exports = __webpack_exports__;
  4013. /******/
  4014. /******/ })()
  4015. ;
  4016. //# sourceMappingURL=index.js.map