UNPKG

@currents/playwright

Version:

Playwright integration and reporter for [Currents](https://currents.dev/playwright) - a cloud dashboard for debugging, troubleshooting and analysing parallel CI tests supporting Cypress and Playwright.

64 lines (53 loc) 40.7 kB
#! /usr/bin/env node "use strict";var yo=Object.create;var B=Object.defineProperty;var wo=Object.getOwnPropertyDescriptor;var Ro=Object.getOwnPropertyNames;var xo=Object.getPrototypeOf,bo=Object.prototype.hasOwnProperty;var c=(e,t)=>()=>(e&&(t=e(e=0)),t);var ae=(e,t)=>{for(var r in t)B(e,r,{get:t[r],enumerable:!0})},ht=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ro(t))!bo.call(e,s)&&s!==r&&B(e,s,{get:()=>t[s],enumerable:!(o=wo(t,s))||o.enumerable});return e};var p=(e,t,r)=>(r=e!=null?yo(xo(e)):{},ht(t||!e||!e.__esModule?B(r,"default",{value:e,enumerable:!0}):r,e)),Co=e=>ht(B({},"__esModule",{value:!0}),e);var n=c(()=>{"use strict"});var q,yt=c(()=>{"use strict";n();q=class extends Error{}});var wt,Rt=c(()=>{"use strict";n();wt={guide:{ciBuildId:"https://docs.currents.dev/guides/ci-build-id",integration:"https://docs.currents.dev/integration-with-playwright/currents-playwright"}}});function xt(e){So.push(e)}var So,ce=c(()=>{"use strict";n();So=[]});var bt,Ct,St=c(()=>{"use strict";n();bt=[],Ct=[]});var R,G,ue,y,d,x,z,Io,U,yn,wn,Rn,xn,bn,Cn,Sn,In,vn,l,Tn,It=c(()=>{"use strict";n();R=p(require("chalk")),G=p(require("util"));h();ce();St();ue=(...e)=>{let t=G.default.format(...e);xt(t),console.log(t)},y=ue,d=(...e)=>{let t=G.default.format(...e);return Ct.push(t),u("WARNING: ",t),ue(R.default.bgYellow.black(" WARNING "),t)},x=(...e)=>{let t=G.default.format(...e);return bt.push(t),u("ERROR: ",t),ue(R.default.bgRed.white(" ERROR "),t)},z=()=>console.log(` `+Io()+` `),Io=()=>R.default.dim(Array(64).fill("=").join("")),U=(e=2)=>console.log(Array(e).fill("").join(` `)),yn=R.default.cyan,wn=R.default.blueBright,Rn=R.default.red,xn=R.default.yellow,bn=R.default.green,Cn=R.default.gray,Sn=R.default.white,In=R.default.black,vn=R.default.magenta,l=R.default.dim,Tn=R.default.bold});var b=c(()=>{"use strict";n();ce();It()});function H(e){if(!e)return;if(e==="false")return!1;let t=parseInt(e,10);if(isNaN(t)||t<1)throw new pe.CommanderError(255,"Invalid argument provided.","--pwc-cancel-after-failures must be a positive integer or 'false', provided: "+e);return t}function Tt(e){if(!e)return;let t=["SIGUSR1","SIGUSR2"];if(!t.includes(e.toUpperCase().trim()))throw new pe.CommanderError(255,"Invalid argument provided.","--pwc-reset-signal must be one of ("+t.join(", ")+"), provided: "+e);return e.toUpperCase().trim()}var pe,le=c(()=>{"use strict";n();pe=require("commander")});function S(e){return C[e]?.env}function Et(e){return C[e].cli}function Ot(e){return C[e].name}function kt(){return{projectId:process.env[C.projectId.env],recordKey:process.env[C.recordKey.env],ciBuildId:process.env[C.ciBuildId.env],tag:process.env[C.tag.env]?process.env[C.tag.env]?.split(",").map(e=>e.trim()):void 0,cancelAfterFailures:H(process.env[C.cancelAfterFailures.env]),disableTitleTags:process.env[C.disableTitleTags.env],testSuiteFile:process.env[C.testSuiteFile.env],machineId:process.env[C.machineId.env],orchestrationId:process.env[C.orchestrationId.env]}}var C,de=c(()=>{"use strict";n();le();C={currentsConfigFile:{name:"Currents Config File Path",env:"CURRENTS_CONFIG_FILE_PATH",cli:"--pwc-config"},ciBuildId:{name:"CI Build ID",env:"CURRENTS_CI_BUILD_ID",cli:"--ci-build-id"},recordKey:{name:"Record Key",env:"CURRENTS_RECORD_KEY",cli:"--key"},projectId:{name:"Project ID",env:"CURRENTS_PROJECT_ID",cli:"--project-id"},tag:{name:"Currents Tag",env:"CURRENTS_TAG",cli:"--tag"},cancelAfterFailures:{name:"Currents Cancel After Failures",env:"CURRENTS_CANCEL_AFTER_FAILURES",cli:"--pwc-cancel-after-failures"},disableTitleTags:{name:"Disable Title Tags",env:"CURRENTS_DISABLE_TITLE_TAGS",cli:"--pwc-disable-title-tags"},testSuiteFile:{name:"Test Suite File",env:"CURRENTS_TEST_SUITE_FILE",cli:"--pwc-test-suite-file"},machineId:{name:"Machine ID",env:"CURRENTS_MACHINE_ID",cli:"--pwc-machine-id"},orchestrationId:{name:"Orchestration ID",env:"CURRENTS_ORCHESTRATION_ID",cli:"--pwc-orchestration-id"},outputFile:{name:"Output File",env:"CURRENTS_OUTPUT_FILE",cli:"--pwc-output-file"},batchSize:{name:"Batch Size",env:"CURRENTS_BATCH_SIZE",cli:"--pwc-batch-size"}}});function Dt(e){return{ciBuildId:e.ciBuildId,projectId:e.projectId,recordKey:e.key,tag:e.tag,removeTitleTags:e.pwcRemoveTitleTags,cancelAfterFailures:e.pwcCancelAfterFailures,disableTitleTags:e.pwcDisableTitleTags,testSuiteFile:e.pwcTestSuiteFile,machineId:e.pwcMachineId,outputFile:e.pwcOutputFile,pwcConfigPath:e.pwcConfig,orchestration:{resetSignal:e.pwcResetSignal,skipReporterInjection:e.pwcSkipReporterInjection,batchSize:e.pwcBatchSize},coverage:{projects:e.pwcCoverage,dir:e.pwcCoverageDir}}}function J(){if(ge)return ge;if(process.env.CURRENTS_PWC_CLI_CONFIG_PATH)try{let e=JSON.parse(Nt.default.readFileSync(process.env.CURRENTS_PWC_CLI_CONFIG_PATH).toString());return _t("Options from serialized CLI config file: %o",e),ge=e,e}catch(e){return _t("Could not read CLI config file: %o",e),{}}return{}}var Nt,_t,ge,me=c(()=>{"use strict";n();Nt=p(require("fs"));h();_t=u.extend("cli-options-serializer");ge=null});function Pt(e,t,r={validationFn:To}){fe("reporter options: %o",e),fe("config file options: %o",t);let o={...I(he),...I(t),...I(e),...I(J()),...I(kt()),orchestration:{...I(he.orchestration),...I(t?.orchestration),...I(e?.orchestration),...I(J().orchestration)},coverage:{...I(he.coverage),...I(t?.coverage),...I(e?.coverage),...I(J().coverage)}};r.validationFn(o),ye=o,fe("resolved currents config: %o",ye)}function To(e){vo.forEach(t=>{if(!e[t])throw x(`${Ot(t)} is required for Currents Reporter. Use the following methods: - environment variable: ${l(S(t))} - CLI flag: ${l(Et(t))} - reporter configuration option ${l(t)} in ${l("playwright.config.ts")} \u{1F4D6} ${wt.guide.integration}`),new q("Missing required config variable")})}function I(e){return Object.entries(e??{}).reduce((t,[r,o])=>o===void 0?t:{...t,[r]:o},{})}function T(){return ye}var fe,vo,he,ye,Ft=c(()=>{"use strict";n();h();yt();Rt();b();de();me();fe=u.extend("config"),vo=["projectId","recordKey"],he={removeTitleTags:!1,disableTitleTags:!1,orchestration:{skipReporterInjection:!1},coverage:{projects:!1}},ye=null});function Ut(e,t){return e.reduceRight(([r,o],s)=>(o.includes(s,-1)?o.splice(o.lastIndexOf(s)):r.unshift(s),[r,o]),[[],[...t]])[0]}var Eo,At=c(()=>{"use strict";n();Eo=require("lodash");b()});var E=c(()=>{"use strict";n();Ft();de();me();At()});var jt,Lt=c(()=>{jt={name:"@currents/playwright",version:"1.14.1",main:"./dist/index.js",author:{name:"Currents Software Inc",email:"hello@currents.dev",url:"https://currents.dev"},license:"MIT",homepage:"https://currents.dev",repository:{type:"git",url:"https://github.com/currents-dev/currents-playwright-changelog.git"},scripts:{test:"vitest",rm:"rimraf dist",lint:'TIMING=1 eslint "**/*.ts*"',build:"tsup-node --minify --dts",dev:"tsup-node --watch --dts",release:"release-it --verbose","publish:npm":"npm run rm && npm run build && ./publish.js","release-ci":"npm run rm && npm run build && ./publish.js -t latest"},bin:{pwc:"./dist/bin/pwc.js","pwc-p":"./dist/bin/pwc-p.js"},devDependencies:{"@playwright/test":"^1.44.0","@release-it/conventional-changelog":"^7.0.2","@types/async-retry":"^1.4.5","@types/babel__code-frame":"^7.0.3","@types/debug":"^4.1.12","@types/getos":"^3.0.4","@types/json-stringify-safe":"^5.0.3","@types/lodash":"^4.17.15","@types/pluralize":"^0.0.33","@types/proxy-from-env":"^1.0.4","@types/randomstring":"^1.3.0","@types/regexp.escape":"^2.0.0","@types/shelljs":"^0.8.16","@types/stack-utils":"^2.0.3","@types/tmp":"^0.2.6","@types/ws":"^8.18.1",eslint:"^9.23.0","eslint-config-custom":"*",msw:"^2.8.2","release-it":"^19.0.3",rimraf:"^6.0.1",tsconfig:"*",tsup:"^8.5.0",typescript:"^5.8.3",vitest:"^3.2.3",wtfnode:"^0.10.0"},dependencies:{"@babel/code-frame":"^7.27.1","@commander-js/extra-typings":"^12.1.0","@currents/commit-info":"1.0.1-beta.0","async-retry":"^1.3.3",axios:"^1.9.0","axios-retry":"^4.5.0",c12:"^1.11.2",chalk:"^4.1.2",commander:"^12.1.0","date-fns":"^4.1.0",debug:"^4.3.7",dotenv:"^16.5.0",execa:"^9.5.3",getos:"^3.2.1","https-proxy-agent":"^7.0.5","istanbul-lib-coverage":"^3.2.2","json-stringify-safe":"^5.0.1","lil-http-terminator":"^1.2.3",lodash:"^4.17.21",nanoid:"^3.3.8","object-sizeof":"^2.6.5","p-debounce":"^2.1.0","p-map":"^4.0.0","p-queue":"6.6.2",pino:"^9.6.0",pluralize:"^8.0.0","pretty-ms":"^7.0.1","proxy-from-env":"^1.1.0","regexp.escape":"^2.0.1","source-map-support":"^0.5.21","stack-utils":"^2.0.6",tmp:"^0.2.3","tmp-promise":"^3.0.3","ts-pattern":"^5.7.1",ws:"^8.18.2"},files:["dist","!**/*.map","!**/*/*.map","**/*.LEGAL.txt","LICENSE.md","README.md","CHANGELOG.md"],keywords:["playwright","playwright dashboard","cloud dashboard","reporter","currents","tests reporter","sorry cypress","ci"],exports:{".":{import:"./dist/index.js",require:"./dist/index.js"},"./discovery":{import:"./dist/reporters/discovery.js",require:"./dist/reporters/discovery.js"},"./orchestration":{import:"./dist/orchestration/index.js",require:"./dist/orchestration/index.js"},"./package.json":"./package.json"},publishConfig:{access:"public",registry:"https://registry.npmjs.org"},"release-it":{npm:{publish:!1},github:{release:!0},plugins:{"@release-it/conventional-changelog":{preset:"angular",header:"# Changelog",ignoreVersion:!0,infile:"../../CHANGELOG.md"}},git:{commitMessage:"chore: release v${version}",tagName:"v${version}"},hooks:{"before:github:release":"npm run --prefix ../../ update-public-changelog"}}}});var K,we=c(()=>{"use strict";n();Lt();K=jt.version});function X(e={}){let t=$t.default.create(e);return t.interceptors.request.use(r=>{let o={...r},s=t.getUri(r),a=Wt.default.getProxyForUrl(s);return a&&(ko("Using HTTP proxy %s for %s ",a,s),o.proxy=!1,o.httpsAgent=_o(a)),o}),t}function _o(e){return V||(V=new Mt.HttpsProxyAgent(e),V)}var $t,Mt,Wt,ko,V,Re=c(()=>{"use strict";n();$t=p(require("axios")),Mt=require("https-proxy-agent"),Wt=p(require("proxy-from-env"));h();ko=u.extend("axios");V=null});var xe,Bt,qt=c(()=>{"use strict";n();xe=()=>process.env.CURRENTS_API_URL??"https://cy.currents.dev",Bt=()=>3e4});var Gt,zt,Ht=c(()=>{"use strict";n();Gt=p(require("events"));h();be();zt=new Gt.default});var Ce,Kt,Jt,Vt,Xt=c(()=>{"use strict";n();b();Ht();Ce={cancellationReason:null},Kt=e=>{Ce.cancellationReason||(Ce.cancellationReason=e)},Jt=()=>Ce.cancellationReason,Vt=({showWarning:e=!0}={})=>{let t=Jt();t&&(e&&d("%s",t),zt.emit("runCancelled",t))}});var be=c(()=>{"use strict";n();Xt()});var Yt,A,Se=c(()=>{"use strict";n();Yt=require("nanoid"),A=(0,Yt.customAlphabet)("abcdefghijklmnopqrstuvwxyz",10)});var Zt,No,Qt,er=c(()=>{"use strict";n();Zt=require("ts-pattern"),No={outcome:null,scannerConfig:null,currentsConfig:null,internalConfig:null},Qt=()=>No});function sr(e){(0,w.match)(e).when(rr.isAxiosError,Do).otherwise(()=>{d("Unexpected error while sending network request: %s",e)})}function Do(e){return(0,w.match)(e).with({code:"ECONNABORTED"},()=>{d("Network connection aborted")}).with({code:"ECONNREFUSED"},()=>{d("Network connection aborted")}).with({code:"ECONNRESET"},()=>{d("Network connection reset")}).with({code:"ETIMEDOUT"},()=>{d("Network connection timeout")}).with({response:w.P.not(w.P.nullish)},t=>{Po(t,{status:t.response.status,data:t.response.data})}).otherwise(t=>{d(`[currents] Unexpected network error: %s %O`,e.message,{method:e.response?.config.method,url:e.response?.config.url,status:e.response?.status,payload:e.response?.config.data,requestId:L(e)})})}function Po(e,{status:t,data:r}){(0,w.match)(t).with(401,()=>{d(`[currents] ${e.response?.config.method} ${e.response?.config.url}} - 401 Unauthorized Request from cloud service`)}).with(400,()=>{d(`[currents] ${e.response?.config.method} ${e.response?.config.url} - 400 Bad Request from cloud service: %o`,r)}).with(429,()=>{d(`[currents] ${e.response?.config.method} ${e.response?.config.url} - 429 Too Many Requests from cloud service`)}).with(422,()=>{Fo(e,r)}).otherwise(()=>{d(`[currents] Unexpected network response: %s %O`,e.message,{method:e.response?.config.method,url:e.response?.config.url,status:e.response?.status,requestId:L(e)})})}function Fo(e,t){(0,w.match)(t).with({code:Ie.MISSING_SUITE,message:w.P.string,errors:w.P.array(w.P.string)},async r=>{let{message:o,errors:s}=r;U(1),x(...tr(o,s)),Y({id:A(),text:(0,or.default)(Qt(),null,2)}).then(a=>{x(`Please share this URL with Currents support for further investigation: ${a}`)}).catch(a=>{d("Failed to upload debug artifact: %s",a)}),U(1)}).with({code:Ie.RUN_CANCELLED,message:w.P.string},r=>{Kt(r.message),Vt()}).with({code:Ie.RUN_EXPIRED,message:w.P.string},r=>{d(r.message)}).with({message:w.P.string,errors:w.P.array(w.P.string)},r=>{let{message:o,errors:s}=r;U(1),d(...tr(o,s)),U(1)}).otherwise(()=>{d(`[currents] Unexpected network response: %s %O`,e.message,{method:e.response?.config.method,url:e.response?.config.url,status:e.response?.status,requestId:L(e)})})}function tr(e,t){return nr.default.isString(e)?t?.length===0?[e]:[e,` ${(t??[]).map(r=>` - ${r}`).join(` `)} `]:["Unexpected network error"]}function L(e){return e?.response?.headers["apigw-requestid"]}var rr,or,nr,w,Ie,ve=c(()=>{"use strict";n();rr=require("axios"),or=p(require("json-stringify-safe")),nr=p(require("lodash")),w=require("ts-pattern");be();Se();b();Te();er();Ie={RUN_CANCELLED:"RUN_CANCELLED",RUN_EXPIRED:"RUN_EXPIRED",MISSING_SUITE:"MISSING_SUITE"}});function ur(e,t,r){let o=r.method?.toUpperCase(),s=r.url,a=L(t),m=(0,ir.default)(Oe(e)),g=`Network request '${o} ${s}' failed: '${t.message}'.${a?` Request ID: ${a}.`:""} Next attempt is in ${m} (${e}/${r["axios-retry"]?.retries||ke()}).`;ar(g),d(g)}var Ee,ir,ar,Oe,cr,ke,pr=c(()=>{"use strict";n();Ee=require("axios"),ir=p(require("pretty-ms"));h();b();ve();ar=u.extend("http"),Oe=e=>[3*1e3,15*1e3,30*1e3][e-1],cr=e=>(ar("isRetriableError: %o",{message:e.message,code:"code"in e?e.code:void 0,status:"response"in e?e.response?.status:void 0,headers:"response"in e?e.response?.headers:void 0,data:"response"in e?e.response?.data:void 0,isAxiosError:(0,Ee.isAxiosError)(e)}),"code"in e&&e.code&&["ECONNABORTED","ECONNREFUSED","ECONNRESET","ETIMEDOUT","ENETRESET","ENOTFOUND","EAI_AGAIN"].includes(e.code)?!0:(0,Ee.isAxiosError)(e)?[429,500,502,503,504].includes(e.response?.status??0):!1),ke=()=>3});function $o(){let e=X({baseURL:xe(),timeout:Bt(),transitional:{clarifyTimeoutError:!0}});return e.interceptors.request.use(async t=>{let{currentsOptions:r}=t,o={...jo,...r};return o.enableCompression&&(0,yr.default)(t.data)>o.compressThresholdBytes?(t.headers["Content-Encoding"]="gzip",{...t,data:await Lo((0,mr.default)(t.data))}):t}),e.interceptors.request.use(t=>{let r=t["axios-retry"]?.retryCount??0,o=T();t.headers.set({...Ao,"Accept-Encoding":"gzip, deflate, br","x-currents-idempotency-key":t.headers["x-currents-idempotency-key"]??(0,hr.nanoid)(),"x-pwc-request-attempt":r,"x-currents-key":o?.recordKey??null}),o?.orchestrationId&&t.headers.set("x-currents-orchestration-id",o.orchestrationId),o?.machineId&&t.headers.set("x-currents-machine-id",o.machineId),t.headers.get("Content-Type")||t.headers.set("Content-Type","application/json");let s={...fr.default.pick(t,"method","url","headers"),data:Buffer.isBuffer(t.data)?"buffer":t.data};return r?lr("network request retry: %o",dr({...s,isRetry:!0})):lr("network request: %o",dr(s)),t}),(0,gr.default)(e,{retries:ke(),retryCondition:cr,retryDelay:Oe,shouldResetTimeout:!0,onRetry:ur}),e}function xr(){return Z||(Z=$o(),Z)}function dr(e){return{method:e.method,baseUrl:xe(),url:e.url,data:e.isRetry?"<retry>":Mo(e.data),headers:{...e.headers,"x-currents-key":"***"}}}function Mo(e){return e?.results?.raw?{...e,results:{...e.results,raw:"***"}}:e}var gr,mr,fr,hr,yr,wr,Rr,lr,Uo,Ao,Lo,Z,jo,br=c(()=>{"use strict";n();gr=p(require("axios-retry")),mr=p(require("json-stringify-safe")),fr=p(require("lodash")),hr=require("nanoid"),yr=p(require("object-sizeof")),wr=require("util"),Rr=p(require("zlib"));E();h();we();Re();qt();pr();lr=u.extend("http"),Uo=1024*1024*1,Ao={"x-pw-version":"0.0.0","x-pwc-version":K},Lo=(0,wr.promisify)(Rr.default.gzip),Z=null,jo={enableCompression:!1,compressThresholdBytes:Uo}});async function N(e,t=xr){try{let r=await t().request(e);return Cr("network response: %o",{...Sr.default.omit(r,"request","config"),url:r.config.url,method:r.config.method}),r}catch(r){let o=r;throw Cr("network error: %o",{code:o.code,message:o.message,url:o.config?.url,method:o.config?.method,status:o.response?.status,headers:o.response?.headers,data:o.response?.data}),sr(o),o}}var Sr,Cr,Ir=c(()=>{"use strict";n();Sr=p(require("lodash"));h();br();ve();Cr=u.extend("http")});var _e=c(()=>{"use strict";n();Ir()});var vr={};ae(vr,{getDebugUrl:()=>Wo});var Wo,Tr=c(()=>{"use strict";n();_e();Wo=({runId:e,type:t})=>N({method:"POST",url:"runs/debug-logs",data:{type:t,runId:e}}).then(r=>r.data)});function Bo(e,t){return _r({path:e,name:null,uploadUrl:t,contentType:"text/plain"},"text/plain",void 0)}async function _r(e,t,r){let o=await Or.default.readFile(e.path);return Ne("Uploading file %s",e.uploadUrl,{buffer:Buffer.byteLength(o)}),Nr(o,e.uploadUrl,t,r)}async function qo(e,t,r){return Ne("Uploading buffer %s",e.name,{buffer:Buffer.byteLength(e.buffer)}),Nr(e.buffer,e.uploadUrl,t,r)}async function Go(e,t,r,o){return X().request({method:"put",url:t,data:e,onUploadProgress:o,headers:{"Content-Disposition":"inline","Content-Type":r}})}async function Nr(...e){await(0,Er.default)(async()=>{await Go(...e)},{retries:5,onRetry:(t,r)=>{if(Ne(`Upload failed %d out of 5 attempts: %s %o`,r,t.message,t.response?.data),r===5){x(`Cannot upload after ${r} times: ${t.message}`);return}d(`Upload failed ${r} out of 5 attempts: ${t.message}`)}})}var Er,Or,Ne,kr,Dr=c(()=>{"use strict";n();Er=p(require("async-retry")),Or=p(require("fs/promises"));h();Re();b();Ne=u.extend("upload"),kr=(s=>(s.PNG="image/png",s.WEBM="video/webm",s.TEXT="text/plain",s.ZIP="application/zip",s))(kr||{})});var Pr={};ae(Pr,{ContentType:()=>kr,sendBuffer:()=>qo,sendPath:()=>_r,uploadText:()=>Bo});var Fr=c(()=>{"use strict";n();Dr()});async function Y(e){let{getDebugUrl:t}=await Promise.resolve().then(()=>(Tr(),vr));try{let{readUrl:r,uploadUrl:o}=await t({runId:e.id,type:"pw-debug"}),{uploadText:s,sendBuffer:a}=await Promise.resolve().then(()=>(Fr(),Pr));return"text"in e&&await a({name:`${e.id}-discovery-debug.log`,buffer:Buffer.from(e.text,"utf-8"),contentType:"text/plain",uploadUrl:o},"text/plain",void 0),"path"in e&&await s(e.path,o),r}catch{return null}}var De,Pe=c(()=>{"use strict";n();De=p(require("debug"))});function zo(e){return e==="false"?!1:e==="remote"?"remote":e==="full"?"full":!!e}var Ur,D,Fe=c(()=>{"use strict";n();Ur=require("@commander-js/extra-typings"),D=new Ur.Option("--pwc-debug [boolean | 'remote' | 'full']","enable debug logs for the reporter. Specify 'remote' to upload logs to Currents. Specify 'full' to dump the debug logs to stdout and upload to Currents.").argParser(zo).env("CURRENTS_DEBUG")});var Ar,Lr,jr=c(()=>{"use strict";n();Ar=require("@commander-js/extra-typings");Fe();Lr=()=>new Ar.Command().allowUnknownOption().addOption(D).helpOption(!1)});var O,$r,Ae,Mr,Wr,Ue,k,j=c(()=>{"use strict";n();O=p(require("debug")),$r=p(require("fs")),Ae=p(require("path")),Mr=p(require("util")),Wr=require("fs/promises");Se();b();jr();Pe();O.default.useColors=function(){return!1};Ue=O.default.log,k=class e{constructor(t="core"){this.source=t;this.pipelines={};if(this.mode=Lr().parse().opts().pwcDebug??!1,this.debug=(0,O.default)(`currents:remote-debug:${this.source}`),!this.mode)return this;if(!this.shouldEnableDebug())return this;let r=process.env.DEBUG?`${process.env.DEBUG},currents*`:"currents*";if(O.default.enable(r),!this.shouldUploadRemoteDebug())return this;let o=A(),s=Ae.default.resolve(".currents-debug"),a=Ae.default.resolve(s,`${o}.log`);(0,Wr.mkdir)(s,{recursive:!0}),y(l(`\u{1F47E} Initiated remote ${this.source} debug log collection:`),l(a));let m=$r.default.createWriteStream(a,{flags:"a"});return O.default.log=(...g)=>{this.mode&&(m.write(`${Mr.default.formatWithOptions({colors:!1},...g)} `),this.shouldMuteLocalStdout()||Ue(...g))},this.pipelines[o]={id:o,writeStream:m,type:this.source,tempFilePath:a},this}static factory(t="core"){return this.instance||(this.instance=new e(t)),this.instance}getDebugMode(){return this.mode}async finalize({runId:t}={runId:void 0}){try{let r=Object.keys(this.pipelines);r.length===0&&(this.debug("No debug pipelines found"),O.default.log=Ue);for(let o of r)await this.uploadDebug(o,t??A())}catch{}finally{O.default.log=Ue}}async uploadDebug(t,r){let o=this.pipelines[t];if(!o){this.debug("No debug pipeline found for id %s",t);return}y(l(`\u{1F47E} ${o.type} debug log written:`),l(o?.tempFilePath));try{let s=await Y({id:r,path:o.tempFilePath});o?.writeStream.end(),y(l(`\u{1F47E} ${o.type} debug log uploaded:`),l(s))}catch(s){d(`Failed to upload ${o.type}} debug log ${l(o.tempFilePath)}: ${s.message}`)}}shouldEnableDebug(){return this.mode==="full"||this.mode==="remote"||this.mode===!0}shouldUploadRemoteDebug(){return this.mode==="full"||this.mode==="remote"}shouldMuteLocalStdout(){return this.mode==="remote"}}});var Te=c(()=>{"use strict";n();Pe();j()});var u,h=c(()=>{"use strict";n();Te();u=(0,De.default)("currents")});var en={};ae(en,{runScript:()=>ho});module.exports=Co(en);n();var xc=require("source-map-support/register"),ft=require("commander");h();b();j();n();var dt=require("ts-pattern");E();n();var Br=require("c12");function qr(e){return(0,Br.loadConfig)({name:"currents",configFile:e})}h();n();n();var Gr={resetSignalReceived:null},zr=({resetSignalReceived:e})=>{Gr.resetSignalReceived=e},Hr=()=>Gr;b();n();var qe=require("ts-pattern");E();h();n();var Le;async function Q(){if(Le)return Le;let{execa:e}=await import("execa");return Le=e,e}j();n();n();var Ho=p(require("ws"));h();var Ji=u.extend("ws");n();var Jr=p(require("http"));h();var Kr=p(require("lil-http-terminator")),ee=require("ts-pattern"),Vr=p(require("ws")),P=u.extend("wss"),M=null,$=null,je=null,_=()=>(0,ee.match)(M?.address()).with({port:ee.P.number},e=>e.port).otherwise(()=>0),Xr=async()=>{if(P("terminating wss server: %d",_()),!je){P("no wss server");return}let{success:e,code:t,message:r,error:o}=await je.terminate();e||(t==="TIMED_OUT"&&o(r),t==="SERVER_ERROR"&&o(r,o),t==="INTERNAL_ERROR"&&o(r,o)),P("terminated wss server: %d",_())},Yr=e=>{$||(M=Jr.default.createServer().on("listening",()=>{if(!M)throw new Error("Server not initialized");$=new Vr.WebSocketServer({server:M});let t=`wss://localhost:${_()}`;P("starting wss",t),$.on("connection",function(o){o.on("message",function(a){P("received %s: %o",t,JSON.parse(a.toString())?.type),e.forEach(m=>m(a.toString()))})}),$.on("close",()=>{P("wss closed"),$=null})}).listen(),je=(0,Kr.default)({server:M}))};n();var ro=p(require("fs")),re=require("lodash"),Be=p(require("tmp")),oo=p(require("regexp.escape"));E();h();n();var eo=p(require("fs")),Jo=require("path");E();h();n();var $e=p(require("fs")),Zr=require("tmp-promise"),Qr=async()=>{let{path:e}=await(0,Zr.file)();return e};var F=u.extend("last-failed");function to({suite:e,groupId:t,specFiles:r,lastRunData:o}){let s=Ko({suite:e,groupId:t,specFiles:r,lastRunData:o});if(!s)return F("No updated data generated for task %s",t),!1;try{return Vo(s),F("Successfully updated last run file for task %s",t),!0}catch(a){return F("Failed to update last run file for task %s: %O",t,a),!1}}function Ko({suite:e,groupId:t,specFiles:r,lastRunData:o}){let s=e.find(g=>g.name===t);if(!s)return F("No group suite found for task %s",t),null;let a=o.find(g=>g.project===t);if(!a?.data)return F("No last run data found for group %s",t),null;let m=s.tests.filter(g=>r.includes(g.spec)&&a.data.failedTests.includes(g.testId)).map(g=>g.testId);return m.length?{data:{status:a.data.status,failedTests:m},path:a.path,project:a.project}:(F("No failed test IDs found for task %s",t),null)}function Vo(e){return eo.default.writeFileSync(e.path,JSON.stringify(e.data,null,2))}n();var Me={OR8N_SUITE_FILE_PREFIX:"currents-or8n-",FIXTURES_DIR_PREFIX:"currents-fixtures-",FIXTURES_CONFIG_ERR_FILE:"config_fixture_error.log",FIXTURES_WARNING_FILE_PREFIX:"config_fixture_warning"};b();j();n();_e();var W=class{async create(t){return N({url:"/orchestration-v1",method:"POST",data:JSON.stringify(t)})}async createTask(t){return N({url:`/orchestration-v1/${t.id}/task`,method:"POST",data:JSON.stringify({machineId:t.machineId,runId:t.runId})})}async resetRun(t){return N({url:`/runs/v1/${t.runId}/reset`,method:"PUT",data:JSON.stringify({...t,isBatchedOr8n:!0})})}};var We=u.extend("or8n-task-executor"),te=class{constructor(t,r,o,s,a,m,g=null,v,tn,rn=new W){this.cliManager=t;this.or8nId=r;this.runId=o;this.machineId=s;this.cliArgs=a;this.suite=m;this.lastRunData=g;this.resolve=v;this.reject=tn;this.batchedOrchestrationAPI=rn;this.suiteFile=null;this.fixturesDir=null;this.taskResultList=[];this.taskResultPromiseList=[];this.orchestrationStatus=Xo;this.runInEventMode=!0;this.lastRunData?this.runInEventMode=!1:"CURRENTS_OR8N_EVENT_MODE"in process.env&&(this.runInEventMode=process.env.CURRENTS_OR8N_EVENT_MODE==="true")}runOrchestrationLoop(){return this.suiteFile||(this.suiteFile=Be.default.fileSync({prefix:Me.OR8N_SUITE_FILE_PREFIX,postfix:".json"}),ro.default.writeFileSync(this.suiteFile.name,JSON.stringify(this.suite,null,2))),this.fixturesDir||(this.fixturesDir=Be.default.dirSync({prefix:Me.FIXTURES_DIR_PREFIX,unsafeCleanup:!0})),this.batchTaskLoopImpl()}async batchTaskLoopImpl(){try{if(Hr().resetSignalReceived){z(),y(`\u{1F6A5} Machine ${l(this.machineId)} has stopped processing tasks due to a reset signal.`),this.resolveTaskLoop();return}let{data:t}=await this.batchedOrchestrationAPI.createTask({machineId:this.machineId,id:this.or8nId,runId:this.runId});if(t.run&&(this.orchestrationStatus.specs=t.run.progress.specs,this.orchestrationStatus.tests=t.run.progress.tests,z(),y([` Orchestration progress: ${l(`${t.run?.progress?.specs?.completed??"-"}/${t.run?.progress?.specs?.overall??"-"} spec files completed`)}`].join(` `))),!t.batch){await this.gracefullyResolveTaskLoop(),z(),y("\u{1F3C1} Orchestration session finished");return}let r=t.batch.groupId,o=(0,re.orderBy)(t.batch.tasks,"score","desc"),s=t.batch?.tasks?.[0]?.batchSize;y(["",`\u{1F310} Executing orchestrated task: ${l(`[${r}] ${o.map(v=>v.spec).join(", ")} `)}`,`\u2139\uFE0F Batch size: ${s}`].join(` `));let a=this.lastRunData?to({suite:this.suite,groupId:r,specFiles:o.map(v=>v.spec),lastRunData:this.lastRunData??[]}):!1;We('"Last failed" flag: %o',a);let m=this.runPWTask({task:{spec:o.map(v=>({spec:v.spec,workerIndex:v.workerIndex})),groupId:r},suiteFilePath:this.suiteFile.name,fixturesDir:this.fixturesDir.name,isLastFailed:a});this.taskResultPromiseList.push(m);let g=await m;o.forEach(v=>{this.taskResultList.push({task:{spec:v.spec,groupId:r},exitStatus:g.exitCode??1})})}catch(t){this.reject(t)}this.runInEventMode||(We("Running in loop mode, executing the orchestration loop again"),this.runOrchestrationLoop())}async runPWTask({task:t,suiteFilePath:r,fixturesDir:o,isLastFailed:s=!1}){let a=T(),m=["test",...a?.orchestration?.skipReporterInjection?[]:["--reporter",[...this.cliManager.getCLIReporters(),"@currents/playwright"].join(",")],`--project=${t.groupId}`,...Ut(this.cliManager.program.args,this.cliArgs),...s?["--last-failed"]:[],"--",...this.orderSpecsByWorkerIndex(t.spec).map(v=>(0,oo.default)(v))],g={...process.env,CURRENTS_PWCP_WSS_PORT:_().toString(),CURRENTS_MACHINE_ID:this.machineId,CURRENTS_ORCHESTRATION_ID:this.or8nId,CURRENTS_PWC_CLI_CONFIG_PATH:await this.cliManager.getConfigFilePath(),CURRENTS_TEST_SUITE_FILE:r,CURRENTS_FIXTURES_TMP_DIR:o,CURRENTS_CI_BUILD_ID:a?.ciBuildId,CURRENTS_DEBUG:String(k.factory("pwc-p").getDebugMode()),CURRENTS_OR8N_EVENT_MODE:this.runInEventMode};return a?.outputFile&&(g.CURRENTS_OR8N_SEND_RESULTS_TO_WSS="true"),We("Running task %o",m),(await Q())("playwright",m,{stdio:"inherit",reject:!1,env:g})}orderSpecsByWorkerIndex(t){let r=(0,re.groupBy)(t,o=>o.workerIndex.toString());return Object.keys(r).sort().map(o=>r[o]).flat().map(o=>o.spec)}async gracefullyResolveTaskLoop(){await Promise.all(this.taskResultPromiseList),this.resolveTaskLoop()}resolveTaskLoop(){this.resolve({runId:this.runId,machineId:this.machineId,orchestrationId:this.or8nId,orchestrationStatus:this.orchestrationStatus,taskResultList:this.taskResultList})}async machineReset(){let t=new W;try{y(`\u{1F6A5} Resetting tests: ${l(`machineId: ${this.machineId}, runId: ${this.runId}`)}`),await t.resetRun({machineId:this.machineId,runId:this.runId}),y(`\u{1F6A5} Success resetting tests: ${l(`machineId: ${this.machineId}, runId: ${this.runId}`)}`)}catch{d("Reset request failed.")}}},Xo={specs:{overall:-1,claimed:-1,completed:-1,passes:-1,failures:-1},tests:{overall:-1,failures:-1,passes:-1,ignored:-1,flaky:-1}};var oe=u.extend("or8n-manager"),ne=class{constructor(t){this.cliManager=t;this.CREATE_TIMEOUT_MS=60*1e3;this.orchestrationSessionProgress=new Promise((r,o)=>{this.resolveOrchestrationSession=r,this.rejectOrchestrationSession=o})}eventsHandler(t){let r=JSON.parse(t);oe("Received ws event",r),(0,qe.match)(r.type).when(o=>o.startsWith("discovery")||o.startsWith("orchestration"),o=>(0,qe.match)(o).with("discovery:creation-success",()=>{(this.taskExecutor=new te(this.cliManager,r.payload.id,r.payload.runId,r.payload.machineId,r.payload.cliArgs??[],r.payload.suite,r.payload.lastRunData,this.resolveOrchestrationSession,this.rejectOrchestrationSession)).runOrchestrationLoop()}).with("discovery:creation-failure",()=>{this.rejectOrchestrationSession(new Error("Failed to create orchestration session"))}).with("orchestration:task-finished",()=>{this.taskExecutor.runOrchestrationLoop()}).otherwise(()=>{this.rejectOrchestrationSession(new Error(`Unknown discovery event ${r.type} received from orchestration service`))})).otherwise(()=>{})}async initOrchestration(t){let r=["test","--list","--reporter","@currents/playwright/orchestration",...t.cliOptions.lastFailed?["--last-failed"]:[],...t.program.args];oe("Orchestration discovery args: %o",r),oe(`Debug discovery command: %s`,`DEBUG=*,-babel* CURRENTS_PWCP_DRY_RUN=1 CURRENTS_CI_BUILD_ID=debug CURRENTS_PROJECT_ID=debug CURRENTS_RECORD_KEY=debug npx playwright ${r.join(" ")}`);let s=await(await Q())("playwright",r,{stdio:"inherit",reject:!1,timeout:this.CREATE_TIMEOUT_MS,env:{CURRENTS_CI_BUILD_ID:T()?.ciBuildId,CURRENTS_PWC_CLI_CONFIG_PATH:await t.getConfigFilePath(),CURRENTS_PWCP_WSS_PORT:_().toString(),...process.env,CURRENTS_DEBUG:String(k.factory("pwc-p").getDebugMode())}});if(oe("Orchestration discovery result: %O",s),s.timedOut)throw new Error(`Failed to start orchestration within ${this.CREATE_TIMEOUT_MS}ms`);if(!s||s.exitCode!==0)throw new Error("Failed discovery for orchestration session");return s}};n();var no=p(require("fs"));h();b();var Ba=u.extend("output");async function so(e){let t=" ".repeat(e.options?.ident??2);y(`${t}\u{1F4BE} JSON output file: ${l(e.outputFile)}`);try{no.default.writeFileSync(e.outputFile,JSON.stringify(e.summary,null,2))}catch(r){x("Error writing JSON summary",r.message)}}n();var go=p(require("fs"));E();h();n();var at=require("@commander-js/extra-typings"),ct=p(require("chalk"));we();b();n();var f=require("@commander-js/extra-typings"),io=require("commander");E();le();Fe();var Ge=new f.Option("--pwc-config <path>","path to currents config file (currents.config.[ts|js])").env(S("currentsConfigFile")),ze=new f.Option("--ci-build-id <id>","the unique identifier for a run").env(S("ciBuildId")),He=new f.Option("-k, --key <record-key>","your secret Record Key obtained from Currents").env(S("recordKey")),Je=new f.Option("-p, --project-id <project>","the project ID for results reporting obtained from Currents").env(S("projectId")),Ke=new f.Option("-t, --tag <tag>","comma-separated tag(s) for recorded runs in Currents").argParser(nt),Ve=new f.Option("--pwc-remove-title-tags","remove tags from test names in Currents, e.g. `Test name @smoke` becomes `Test name` in the dashboard"),Xe=new f.Option("--pwc-disable-title-tags","disable parsing tags from test title, e.g. `Test name @smoke` would not be tagged with `smoke` in the dashboard"),Ye=new f.Option("--pwc-cancel-after-failures <number | false>","abort the cloud run after the specified number of failed tests detected. Overrides the default Currents Project settings. If set, must be a positive integer or 'false' to disable automatic cancellations").env(S("cancelAfterFailures")).argParser(H),Ze=new f.Option("--pwc-output-file <string>","path to the file where the run summary output will be written.").env(S("outputFile")),Qe=new f.Option("--pwc-test-suite-file <path>","path to the full test suite file for orchestration and reporting").env(S("testSuiteFile")).hideHelp(),et=new f.Option("--pwc-machine-id <string>","unique identifier of the machine running the tests. If not provided, it will be generated automatically. See: https://docs.currents.dev/?q=machineId").env(S("machineId")),tt=new f.Option("--pwc-orchestration-id <string>","unique identifier of the orchestration session this run belongs to. See: https://docs.currents.dev/?q=orchestrationId").env(S("orchestrationId")).hideHelp();var rt=new f.Option("--pwc-inspect","enable inspect mode, run playwright with --inspect-brk flag or developments and debugging").default(!1).hideHelp(),ao=new f.Option("--pwc-reset-signal <'SIGUSR1' | 'SIGUSR2'>","specify a process signal to listen for to trigger a reset of the current in progress tests. Only avaiable on OSes with POSIX signal support.").argParser(Tt),ot=new f.Option("--reporter <reporter>","Reporter to use, comma-separated").argParser(nt).hideHelp(),co=new f.Option("--last-failed","Run last failed tests").default(!1).hideHelp(),uo=new f.Option("--pwc-skip-reporter-injection","Do not inject @currents/playwright reporter via CLI, use the reporter specified in the playwright config");function nt(e,t=[]){return e?t.concat(e.split(",").map(r=>r.trim())):t}var st=new f.Option("--pwc-coverage [projects...]","Comma-separated list of projects to collect coverage for, e.g. `project1,project2`. If no projects are specified, coverage will be collected for all projects.").argParser(nt),it=new f.Option("--pwc-coverage-dir <path>","Path to the directory where coverage reports will be read from"),po=new f.Option("--pwc-batch-size <'auto' | number>","Set the number of parallel workers for orchestration. Use 'auto' to match the number of Playwright workers. If a number is provided, it must be a positive integer.").default("auto").env(S("batchSize")).argParser(e=>{if(e==="auto")return e;let t=Number(e);if(!isNaN(t)&&Number.isInteger(t)&&t>0)return t;throw new io.InvalidArgumentError('Provide either "auto" or a positive integer.')});var ut=(e=pt())=>e.version(K),Yo=` ---------------------------------------------------- \u{1F4D6} Documentation: https://docs.currents.dev \u{1F919} Support: support@currents.dev ---------------------------------------------------- ${ct.default.bold("Examples")} Run all tests in the current directory: ${l("pwc --key <record-key> --project-id <id> --ci-build-id <build-id>")} Run only tests filtered by the tag "@smoke": ${l("pwc --key <record-key> --project-id <id> --ci-build-id <build-id> --grep smoke")} Run playwright tests and add tags "tagA", "tagB" to the recorded run: ${l("pwc --key <record-key> --project-id <id> --ci-build-id <build-id> --tag tagA --tag tagB")} Provide playwright arguments and flags: ${l("pwc --key <record-key> --project-id <id> --ci-build-id <build-id> -- --workers 2 --timeout 10000 --shard 1/2")} `,Zo=` ---------------------------------------------------- \u{1F4D6} Documentation: https://docs.currents.dev \u{1F919} Support: support@currents.dev ---------------------------------------------------- ${ct.default.bold("Examples")} Orchestrate all tests in the current directory: ${l("pwc-p --key <record-key> --project-id <id> --ci-build-id <build-id>")} Orchestrate only tests filtered by the tag "@smoke": ${l("pwc-p --key <record-key> --project-id <id> --ci-build-id <build-id> --grep smoke")} Orchestrate playwright tests and add tags "tagA", "tagB" to the recorded run: ${l("pwc-p --key <record-key> --project-id <id> --ci-build-id <build-id> --tag tagA --tag tagB")} Add additional playwright arguments and flags: ${l("pwc-p --key <record-key> --project-id <id> --ci-build-id <build-id> -- --workers 2 --timeout 10000")} `,pt=()=>new at.Command().name("pwc").usage("[options] [playwright arguments and flags]").allowUnknownOption().showHelpAfterError("(add --help for additional information)").description(`\u{1F3AD} Run Playwright tests on CI using https://currents.dev ${Yo}`).addOption(ze).addOption(He).addOption(Je).addOption(Ke).addOption(Ge).addOption(Ve).addOption(Xe).addOption(Ye).addOption(Ze).addOption(Qe).addOption(et).addOption(tt).addOption(rt).addOption(D).addOption(st).addOption(it).addOption(ot),lo=()=>new at.Command().name("pwc-p").usage("[options] [playwright arguments and flags]").allowUnknownOption().showHelpAfterError("(add --help for additional information)").description(`\u2728 Orchestrate \u{1F3AD} Playwright tests on CI using https://currents.dev ${Zo}`).addOption(ze).addOption(He).addOption(Je).addOption(Ke).addOption(Ge).addOption(Ve).addOption(Xe).addOption(Ye).addOption(Ze).addOption(Qe).addOption(et).addOption(tt).addOption(ao).addOption(rt).addOption(D).addOption(ot).addOption(co).addOption(uo).addOption(st).addOption(it).addOption(po);var lt=u.extend("cli-manager"),se=class{constructor(t={isOrchestration:!1}){this.configFilePath=null;this.program=t.isOrchestration?ut(lo()):ut(pt()),this.cliOptions=this.program.parse().opts(),lt("CLI options: %o",this.cliOptions),this.parsedConfig=Dt(this.cliOptions),lt("Parsed config from CLI options: %o",this.parsedConfig)}getCLIReporters(){return this.cliOptions.reporter?.filter(t=>!/@currents/.test(t))||[]}async getConfigFilePath(){if(this.configFilePath)return this.configFilePath;let t=await Qr();return go.default.writeFileSync(t,JSON.stringify(this.parsedConfig)),lt("CLI options temp file path: %s",t),this.configFilePath=t,t}};var Qo=u.extend("pwc-p-runner");async function mo(){try{let e=new se({isOrchestration:!0}),t=await qr(e.cliOptions.pwcConfig);Object.keys(t.config).length>0&&y(" Using config file:",l(t.configFile)),Pt(e.parsedConfig,t.config);let r=T(),o=new ne(e),s=new gt,a=r?.orchestration?.resetSignal;a&&(y(`\u{1F6A5} Will reset tests on ${a}. PID: ${process.pid}`),process.on(a,async()=>{y(`\u{1F6A5} Received ${a}`),zr({resetSignalReceived:!0}),o.taskExecutor?await o.taskExecutor.machineReset():y("\u{1F6A5} Reset signal acknowledged.")})),await Yr([o.eventsHandler.bind(o),s.eventsHandler.bind(s)]);let[m]=await Promise.all([o.orchestrationSessionProgress,o.initOrchestration(e)]);if(r?.outputFile&&await so({outputFile:r?.outputFile,summary:s.getSummary(),options:{ident:0}}),Qo("orchestration session raw result: %o",m),typeof r?.orchestration?.onFinish=="function")try{await r.orchestration.onFinish(m.orchestrationStatus)}catch{}return{...m,success:m.taskResultList.every(g=>g.exitStatus===0)}}finally{await Xr()}}var gt=class{constructor(){this.results=[]}eventsHandler(t){let r=JSON.parse(t);(0,dt.match)(r.type).when(o=>o.startsWith("execution:"),o=>(0,dt.match)(o).with("execution:summary",s=>{this.results.push(r.payload)}).otherwise(()=>{d("Unknown execution event received from orchestrated task",{event:r})})).otherwise(()=>{})}getSummary(){if(!this.results.length)return{runId:null,ciBuildId:null,url:null,results:{tests:{passed:0,failed:0,skipped:0,overall:0,flaky:0}},details:[]};let t=this.results.flatMap(o=>o.details),r=this.results.reduce((o,s)=>({passed:o.passed+s.results.tests.passed,failed:o.failed+s.results.tests.failed,skipped:o.skipped+s.results.tests.skipped,overall:o.overall+s.results.tests.overall,flaky:o.flaky+s.results.tests.flaky}),{passed:0,failed:0,skipped:0,overall:0,flaky:0});return{...this.results[0],results:{tests:r},details:t}}};var fo=require("axios"),ie=u.extend("pwc-p");require("dotenv").config();var mt=k.factory("pwc-p");async function ho(){try{let e=await mo();return ie("orchestration session result: %o",e),await mt.finalize({runId:e.runId}),{exitCode:e.success===!0?0:1}}catch(e){return ie("orchestration session error: %o",e),e instanceof ft.CommanderError?(x(e.message),{exitCode:e.exitCode}):(0,fo.isAxiosError)(e)?{exitCode:1}:(x(e),{exitCode:1})}}ho().then(e=>{ie("execa result: %o",e),process.exit(e.exitCode??0)}).catch(async e=>{e instanceof ft.CommanderError&&(x(e.message),await mt.finalize(),process.exit(e.exitCode)),ie("execa failed: %o",e),x(e),await mt.finalize(),process.exit(1)});0&&(module.exports={runScript}); //# sourceMappingURL=pwc-p.js.map