@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.
54 lines (44 loc) • 26.9 kB
JavaScript
;var gr=Object.create;var L=Object.defineProperty;var mr=Object.getOwnPropertyDescriptor;var fr=Object.getOwnPropertyNames;var hr=Object.getPrototypeOf,yr=Object.prototype.hasOwnProperty;var s=(e,t)=>()=>(e&&(t=e(e=0)),t);var je=(e,t)=>{for(var o in t)L(e,o,{get:t[o],enumerable:!0})},br=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of fr(t))!yr.call(e,a)&&a!==o&&L(e,a,{get:()=>t[a],enumerable:!(n=mr(t,a))||n.enumerable});return e};var p=(e,t,o)=>(o=e!=null?gr(hr(e)):{},br(t||!e||!e.__esModule?L(o,"default",{value:e,enumerable:!0}):o,e));var r=s(()=>{"use strict"});var Fe=s(()=>{"use strict";r()});var _e=s(()=>{"use strict";r()});function Le(e){wr.push(e)}var wr,$=s(()=>{"use strict";r();wr=[]});var $e,qe,Be=s(()=>{"use strict";r();$e=[],qe=[]});var f,T,q,S,c,w,v,io,so,ao,po,co,uo,lo,go,mo,d,fo,Me=s(()=>{"use strict";r();f=p(require("chalk")),T=p(require("util"));h();$();Be();q=(...e)=>{let t=T.default.format(...e);Le(t),console.log(t)},S=q,c=(...e)=>{let t=T.default.format(...e);return qe.push(t),u("WARNING: ",t),q(f.default.bgYellow.black(" WARNING "),t)},w=(...e)=>{let t=T.default.format(...e);return $e.push(t),u("ERROR: ",t),q(f.default.bgRed.white(" ERROR "),t)},v=(e=2)=>console.log(Array(e).fill("").join(`
`)),io=f.default.cyan,so=f.default.blueBright,ao=f.default.red,po=f.default.yellow,co=f.default.green,uo=f.default.gray,lo=f.default.white,go=f.default.black,mo=f.default.magenta,d=f.default.dim,fo=f.default.bold});var b=s(()=>{"use strict";r();$();Me()});function M(e){if(!e)return;if(e==="false")return!1;let t=parseInt(e,10);if(isNaN(t)||t<1)throw new B.CommanderError(255,"Invalid argument provided.","--pwc-cancel-after-failures must be a positive integer or 'false', provided: "+e);return t}function Ge(e){if(!e)return;let t=["SIGUSR1","SIGUSR2"];if(!t.includes(e.toUpperCase().trim()))throw new B.CommanderError(255,"Invalid argument provided.","--pwc-reset-signal must be one of ("+t.join(", ")+"), provided: "+e);return e.toUpperCase().trim()}var B,G=s(()=>{"use strict";r();B=require("commander")});function y(e){return Cr[e]?.env}var Cr,z=s(()=>{"use strict";r();G();Cr={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 ze(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}}}var Rr,To,W=s(()=>{"use strict";r();Rr=p(require("fs"));h();To=u.extend("cli-options-serializer")});function We(){return vr}var Mo,vr,He=s(()=>{"use strict";r();h();Fe();_e();b();z();W();Mo=u.extend("config"),vr=null});var Er,Ke=s(()=>{"use strict";r();Er=require("lodash");b()});var k=s(()=>{"use strict";r();He();z();W();Ke()});var Je,Ve=s(()=>{Je={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 P,H=s(()=>{"use strict";r();Ve();P=Je.version});function A(e={}){let t=Xe.default.create(e);return t.interceptors.request.use(o=>{let n={...o},a=t.getUri(o),g=Ze.default.getProxyForUrl(a);return g&&(Or("Using HTTP proxy %s for %s ",g,a),n.proxy=!1,n.httpsAgent=Tr(g)),n}),t}function Tr(e){return D||(D=new Ye.HttpsProxyAgent(e),D)}var Xe,Ye,Ze,Or,D,K=s(()=>{"use strict";r();Xe=p(require("axios")),Ye=require("https-proxy-agent"),Ze=p(require("proxy-from-env"));h();Or=u.extend("axios");D=null});var V,Qe,et=s(()=>{"use strict";r();V=()=>process.env.CURRENTS_API_URL??"https://cy.currents.dev",Qe=()=>3e4});var tt,rt,ot=s(()=>{"use strict";r();tt=p(require("events"));h();J();rt=new tt.default});var X,it,nt,st,at=s(()=>{"use strict";r();b();ot();X={cancellationReason:null},it=e=>{X.cancellationReason||(X.cancellationReason=e)},nt=()=>X.cancellationReason,st=({showWarning:e=!0}={})=>{let t=nt();t&&(e&&c("%s",t),rt.emit("runCancelled",t))}});var J=s(()=>{"use strict";r();at()});var pt,E,Y=s(()=>{"use strict";r();pt=require("nanoid"),E=(0,pt.customAlphabet)("abcdefghijklmnopqrstuvwxyz",10)});var ct,Sr,ut,lt=s(()=>{"use strict";r();ct=require("ts-pattern"),Sr={outcome:null,scannerConfig:null,currentsConfig:null,internalConfig:null},ut=()=>Sr});function ht(e){(0,m.match)(e).when(gt.isAxiosError,kr).otherwise(()=>{c("Unexpected error while sending network request: %s",e)})}function kr(e){return(0,m.match)(e).with({code:"ECONNABORTED"},()=>{c("Network connection aborted")}).with({code:"ECONNREFUSED"},()=>{c("Network connection aborted")}).with({code:"ECONNRESET"},()=>{c("Network connection reset")}).with({code:"ETIMEDOUT"},()=>{c("Network connection timeout")}).with({response:m.P.not(m.P.nullish)},t=>{Pr(t,{status:t.response.status,data:t.response.data})}).otherwise(t=>{c(`[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:I(e)})})}function Pr(e,{status:t,data:o}){(0,m.match)(t).with(401,()=>{c(`[currents] ${e.response?.config.method} ${e.response?.config.url}} - 401 Unauthorized Request from cloud service`)}).with(400,()=>{c(`[currents] ${e.response?.config.method} ${e.response?.config.url} - 400 Bad Request from cloud service:
%o`,o)}).with(429,()=>{c(`[currents] ${e.response?.config.method} ${e.response?.config.url} - 429 Too Many Requests from cloud service`)}).with(422,()=>{Dr(e,o)}).otherwise(()=>{c(`[currents] Unexpected network response: %s
%O`,e.message,{method:e.response?.config.method,url:e.response?.config.url,status:e.response?.status,requestId:I(e)})})}function Dr(e,t){(0,m.match)(t).with({code:Z.MISSING_SUITE,message:m.P.string,errors:m.P.array(m.P.string)},async o=>{let{message:n,errors:a}=o;v(1),w(...dt(n,a)),N({id:E(),text:(0,mt.default)(ut(),null,2)}).then(g=>{w(`Please share this URL with Currents support for further investigation:
${g}`)}).catch(g=>{c("Failed to upload debug artifact: %s",g)}),v(1)}).with({code:Z.RUN_CANCELLED,message:m.P.string},o=>{it(o.message),st()}).with({code:Z.RUN_EXPIRED,message:m.P.string},o=>{c(o.message)}).with({message:m.P.string,errors:m.P.array(m.P.string)},o=>{let{message:n,errors:a}=o;v(1),c(...dt(n,a)),v(1)}).otherwise(()=>{c(`[currents] Unexpected network response: %s
%O`,e.message,{method:e.response?.config.method,url:e.response?.config.url,status:e.response?.status,requestId:I(e)})})}function dt(e,t){return ft.default.isString(e)?t?.length===0?[e]:[e,`
${(t??[]).map(o=>` - ${o}`).join(`
`)}
`]:["Unexpected network error"]}function I(e){return e?.response?.headers["apigw-requestid"]}var gt,mt,ft,m,Z,Q=s(()=>{"use strict";r();gt=require("axios"),mt=p(require("json-stringify-safe")),ft=p(require("lodash")),m=require("ts-pattern");J();Y();b();ee();lt();Z={RUN_CANCELLED:"RUN_CANCELLED",RUN_EXPIRED:"RUN_EXPIRED",MISSING_SUITE:"MISSING_SUITE"}});function xt(e,t,o){let n=o.method?.toUpperCase(),a=o.url,g=I(t),O=(0,yt.default)(re(e)),R=`Network request '${n} ${a}' failed: '${t.message}'.${g?` Request ID: ${g}.`:""} Next attempt is in ${O} (${e}/${o["axios-retry"]?.retries||oe()}).`;bt(R),c(R)}var te,yt,bt,re,wt,oe,Ct=s(()=>{"use strict";r();te=require("axios"),yt=p(require("pretty-ms"));h();b();Q();bt=u.extend("http"),re=e=>[3*1e3,15*1e3,30*1e3][e-1],wt=e=>(bt("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,te.isAxiosError)(e)}),"code"in e&&e.code&&["ECONNABORTED","ECONNREFUSED","ECONNRESET","ETIMEDOUT","ENETRESET","ENOTFOUND","EAI_AGAIN"].includes(e.code)?!0:(0,te.isAxiosError)(e)?[429,500,502,503,504].includes(e.response?.status??0):!1),oe=()=>3});function Fr(){let e=A({baseURL:V(),timeout:Qe(),transitional:{clarifyTimeoutError:!0}});return e.interceptors.request.use(async t=>{let{currentsOptions:o}=t,n={...jr,...o};return n.enableCompression&&(0,St.default)(t.data)>n.compressThresholdBytes?(t.headers["Content-Encoding"]="gzip",{...t,data:await Ur((0,It.default)(t.data))}):t}),e.interceptors.request.use(t=>{let o=t["axios-retry"]?.retryCount??0,n=We();t.headers.set({...Nr,"Accept-Encoding":"gzip, deflate, br","x-currents-idempotency-key":t.headers["x-currents-idempotency-key"]??(0,Tt.nanoid)(),"x-pwc-request-attempt":o,"x-currents-key":n?.recordKey??null}),n?.orchestrationId&&t.headers.set("x-currents-orchestration-id",n.orchestrationId),n?.machineId&&t.headers.set("x-currents-machine-id",n.machineId),t.headers.get("Content-Type")||t.headers.set("Content-Type","application/json");let a={...Ot.default.pick(t,"method","url","headers"),data:Buffer.isBuffer(t.data)?"buffer":t.data};return o?Rt("network request retry: %o",vt({...a,isRetry:!0})):Rt("network request: %o",vt(a)),t}),(0,Et.default)(e,{retries:oe(),retryCondition:wt,retryDelay:re,shouldResetTimeout:!0,onRetry:xt}),e}function Dt(){return U||(U=Fr(),U)}function vt(e){return{method:e.method,baseUrl:V(),url:e.url,data:e.isRetry?"<retry>":_r(e.data),headers:{...e.headers,"x-currents-key":"***"}}}function _r(e){return e?.results?.raw?{...e,results:{...e.results,raw:"***"}}:e}var Et,It,Ot,Tt,St,kt,Pt,Rt,Ar,Nr,Ur,U,jr,At=s(()=>{"use strict";r();Et=p(require("axios-retry")),It=p(require("json-stringify-safe")),Ot=p(require("lodash")),Tt=require("nanoid"),St=p(require("object-sizeof")),kt=require("util"),Pt=p(require("zlib"));k();h();H();K();et();Ct();Rt=u.extend("http"),Ar=1024*1024*1,Nr={"x-pw-version":"0.0.0","x-pwc-version":P},Ur=(0,kt.promisify)(Pt.default.gzip),U=null,jr={enableCompression:!1,compressThresholdBytes:Ar}});async function jt(e,t=Dt){try{let o=await t().request(e);return Nt("network response: %o",{...Ut.default.omit(o,"request","config"),url:o.config.url,method:o.config.method}),o}catch(o){let n=o;throw Nt("network error: %o",{code:n.code,message:n.message,url:n.config?.url,method:n.config?.method,status:n.response?.status,headers:n.response?.headers,data:n.response?.data}),ht(n),n}}var Ut,Nt,Ft=s(()=>{"use strict";r();Ut=p(require("lodash"));h();At();Q();Nt=u.extend("http")});var _t=s(()=>{"use strict";r();Ft()});var Lt={};je(Lt,{getDebugUrl:()=>Lr});var Lr,$t=s(()=>{"use strict";r();_t();Lr=({runId:e,type:t})=>jt({method:"POST",url:"runs/debug-logs",data:{type:t,runId:e}}).then(o=>o.data)});function $r(e,t){return Gt({path:e,name:null,uploadUrl:t,contentType:"text/plain"},"text/plain",void 0)}async function Gt(e,t,o){let n=await Bt.default.readFile(e.path);return ne("Uploading file %s",e.uploadUrl,{buffer:Buffer.byteLength(n)}),zt(n,e.uploadUrl,t,o)}async function qr(e,t,o){return ne("Uploading buffer %s",e.name,{buffer:Buffer.byteLength(e.buffer)}),zt(e.buffer,e.uploadUrl,t,o)}async function Br(e,t,o,n){return A().request({method:"put",url:t,data:e,onUploadProgress:n,headers:{"Content-Disposition":"inline","Content-Type":o}})}async function zt(...e){await(0,qt.default)(async()=>{await Br(...e)},{retries:5,onRetry:(t,o)=>{if(ne(`Upload failed %d out of 5 attempts: %s
%o`,o,t.message,t.response?.data),o===5){w(`Cannot upload after ${o} times: ${t.message}`);return}c(`Upload failed ${o} out of 5 attempts: ${t.message}`)}})}var qt,Bt,ne,Mt,Wt=s(()=>{"use strict";r();qt=p(require("async-retry")),Bt=p(require("fs/promises"));h();K();b();ne=u.extend("upload"),Mt=(a=>(a.PNG="image/png",a.WEBM="video/webm",a.TEXT="text/plain",a.ZIP="application/zip",a))(Mt||{})});var Ht={};je(Ht,{ContentType:()=>Mt,sendBuffer:()=>qr,sendPath:()=>Gt,uploadText:()=>$r});var Kt=s(()=>{"use strict";r();Wt()});async function N(e){let{getDebugUrl:t}=await Promise.resolve().then(()=>($t(),Lt));try{let{readUrl:o,uploadUrl:n}=await t({runId:e.id,type:"pw-debug"}),{uploadText:a,sendBuffer:g}=await Promise.resolve().then(()=>(Kt(),Ht));return"text"in e&&await g({name:`${e.id}-discovery-debug.log`,buffer:Buffer.from(e.text,"utf-8"),contentType:"text/plain",uploadUrl:n},"text/plain",void 0),"path"in e&&await a(e.path,n),o}catch{return null}}var ie,se=s(()=>{"use strict";r();ie=p(require("debug"))});function Mr(e){return e==="false"?!1:e==="remote"?"remote":e==="full"?"full":!!e}var Vt,C,ae=s(()=>{"use strict";r();Vt=require("@commander-js/extra-typings"),C=new Vt.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(Mr).env("CURRENTS_DEBUG")});var Jt,Xt,Yt=s(()=>{"use strict";r();Jt=require("@commander-js/extra-typings");ae();Xt=()=>new Jt.Command().allowUnknownOption().addOption(C).helpOption(!1)});var x,Zt,ce,Qt,er,pe,j,ue=s(()=>{"use strict";r();x=p(require("debug")),Zt=p(require("fs")),ce=p(require("path")),Qt=p(require("util")),er=require("fs/promises");Y();b();Yt();se();x.default.useColors=function(){return!1};pe=x.default.log,j=class e{constructor(t="core"){this.source=t;this.pipelines={};if(this.mode=Xt().parse().opts().pwcDebug??!1,this.debug=(0,x.default)(`currents:remote-debug:${this.source}`),!this.mode)return this;if(!this.shouldEnableDebug())return this;let o=process.env.DEBUG?`${process.env.DEBUG},currents*`:"currents*";if(x.default.enable(o),!this.shouldUploadRemoteDebug())return this;let n=E(),a=ce.default.resolve(".currents-debug"),g=ce.default.resolve(a,`${n}.log`);(0,er.mkdir)(a,{recursive:!0}),S(d(`\u{1F47E} Initiated remote ${this.source} debug log collection:`),d(g));let O=Zt.default.createWriteStream(g,{flags:"a"});return x.default.log=(...R)=>{this.mode&&(O.write(`${Qt.default.formatWithOptions({colors:!1},...R)}
`),this.shouldMuteLocalStdout()||pe(...R))},this.pipelines[n]={id:n,writeStream:O,type:this.source,tempFilePath:g},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 o=Object.keys(this.pipelines);o.length===0&&(this.debug("No debug pipelines found"),x.default.log=pe);for(let n of o)await this.uploadDebug(n,t??E())}catch{}finally{x.default.log=pe}}async uploadDebug(t,o){let n=this.pipelines[t];if(!n){this.debug("No debug pipeline found for id %s",t);return}S(d(`\u{1F47E} ${n.type} debug log written:`),d(n?.tempFilePath));try{let a=await N({id:o,path:n.tempFilePath});n?.writeStream.end(),S(d(`\u{1F47E} ${n.type} debug log uploaded:`),d(a))}catch(a){c(`Failed to upload ${n.type}} debug log ${d(n.tempFilePath)}: ${a.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 ee=s(()=>{"use strict";r();se();ue()});var u,h=s(()=>{"use strict";r();ee();u=(0,ie.default)("currents")});r();var os=require("source-map-support/register"),dr=require("commander");h();r();var le;async function tr(){if(le)return le;let{execa:e}=await import("execa");return le=e,e}b();ue();r();var ur=p(require("fs"));k();h();r();var de=p(require("fs")),rr=require("tmp-promise"),or=async()=>{let{path:e}=await(0,rr.file)();return e};r();var Pe=require("@commander-js/extra-typings"),De=p(require("chalk"));H();b();r();var l=require("@commander-js/extra-typings"),nr=require("commander");k();G();ae();var ge=new l.Option("--pwc-config <path>","path to currents config file (currents.config.[ts|js])").env(y("currentsConfigFile")),me=new l.Option("--ci-build-id <id>","the unique identifier for a run").env(y("ciBuildId")),fe=new l.Option("-k, --key <record-key>","your secret Record Key obtained from Currents").env(y("recordKey")),he=new l.Option("-p, --project-id <project>","the project ID for results reporting obtained from Currents").env(y("projectId")),ye=new l.Option("-t, --tag <tag>","comma-separated tag(s) for recorded runs in Currents").argParser(Te),be=new l.Option("--pwc-remove-title-tags","remove tags from test names in Currents, e.g. `Test name @smoke` becomes `Test name` in the dashboard"),we=new l.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"),xe=new l.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(y("cancelAfterFailures")).argParser(M),Ce=new l.Option("--pwc-output-file <string>","path to the file where the run summary output will be written.").env(y("outputFile")),Re=new l.Option("--pwc-test-suite-file <path>","path to the full test suite file for orchestration and reporting").env(y("testSuiteFile")).hideHelp(),ve=new l.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(y("machineId")),Ee=new l.Option("--pwc-orchestration-id <string>","unique identifier of the orchestration session this run belongs to. See: https://docs.currents.dev/?q=orchestrationId").env(y("orchestrationId")).hideHelp();var Ie=new l.Option("--pwc-inspect","enable inspect mode, run playwright with --inspect-brk flag or developments and debugging").default(!1).hideHelp(),ir=new l.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(Ge),Oe=new l.Option("--reporter <reporter>","Reporter to use, comma-separated").argParser(Te).hideHelp(),sr=new l.Option("--last-failed","Run last failed tests").default(!1).hideHelp(),ar=new l.Option("--pwc-skip-reporter-injection","Do not inject @currents/playwright reporter via CLI, use the reporter specified in the playwright config");function Te(e,t=[]){return e?t.concat(e.split(",").map(o=>o.trim())):t}var Se=new l.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(Te),ke=new l.Option("--pwc-coverage-dir <path>","Path to the directory where coverage reports will be read from"),pr=new l.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(y("batchSize")).argParser(e=>{if(e==="auto")return e;let t=Number(e);if(!isNaN(t)&&Number.isInteger(t)&&t>0)return t;throw new nr.InvalidArgumentError('Provide either "auto" or a positive integer.')});var Ae=(e=Ne())=>e.version(P),Gr=`
----------------------------------------------------
\u{1F4D6} Documentation: https://docs.currents.dev
\u{1F919} Support: support@currents.dev
----------------------------------------------------
${De.default.bold("Examples")}
Run all tests in the current directory:
${d("pwc --key <record-key> --project-id <id> --ci-build-id <build-id>")}
Run only tests filtered by the tag "@smoke":
${d("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:
${d("pwc --key <record-key> --project-id <id> --ci-build-id <build-id> --tag tagA --tag tagB")}
Provide playwright arguments and flags:
${d("pwc --key <record-key> --project-id <id> --ci-build-id <build-id> -- --workers 2 --timeout 10000 --shard 1/2")}
`,zr=`
----------------------------------------------------
\u{1F4D6} Documentation: https://docs.currents.dev
\u{1F919} Support: support@currents.dev
----------------------------------------------------
${De.default.bold("Examples")}
Orchestrate all tests in the current directory:
${d("pwc-p --key <record-key> --project-id <id> --ci-build-id <build-id>")}
Orchestrate only tests filtered by the tag "@smoke":
${d("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:
${d("pwc-p --key <record-key> --project-id <id> --ci-build-id <build-id> --tag tagA --tag tagB")}
Add additional playwright arguments and flags:
${d("pwc-p --key <record-key> --project-id <id> --ci-build-id <build-id> -- --workers 2 --timeout 10000")}
`,Ne=()=>new Pe.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
${Gr}`).addOption(me).addOption(fe).addOption(he).addOption(ye).addOption(ge).addOption(be).addOption(we).addOption(xe).addOption(Ce).addOption(Re).addOption(ve).addOption(Ee).addOption(Ie).addOption(C).addOption(Se).addOption(ke).addOption(Oe),cr=()=>new Pe.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
${zr}`).addOption(me).addOption(fe).addOption(he).addOption(ye).addOption(ge).addOption(be).addOption(we).addOption(xe).addOption(Ce).addOption(Re).addOption(ve).addOption(Ee).addOption(ir).addOption(Ie).addOption(C).addOption(Oe).addOption(sr).addOption(ar).addOption(Se).addOption(ke).addOption(pr);var Ue=u.extend("cli-manager"),F=class{constructor(t={isOrchestration:!1}){this.configFilePath=null;this.program=t.isOrchestration?Ae(cr()):Ae(Ne()),this.cliOptions=this.program.parse().opts(),Ue("CLI options: %o",this.cliOptions),this.parsedConfig=ze(this.cliOptions),Ue("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 or();return ur.default.writeFileSync(t,JSON.stringify(this.parsedConfig)),Ue("CLI options temp file path: %s",t),this.configFilePath=t,t}};var lr=u.extend("pwc");require("dotenv").config();var _=j.factory("pwc");async function Wr(){let e=new F;return await(await tr())("playwright",["test","--reporter",["@currents/playwright",...e.getCLIReporters()].join(","),...e.program.args],{stdio:"inherit",reject:!1,env:{...process.env,CURRENTS_DEBUG:String(_.getDebugMode()),CURRENTS_PWC_CLI_CONFIG_PATH:await e.getConfigFilePath()}})}Wr().then(async e=>{lr("execa result: %o",e),await _.finalize(),process.exit(e.exitCode??0)}).catch(async e=>{e instanceof dr.CommanderError&&(w(e.message),await _.finalize(),process.exit(e.exitCode)),lr("execa failed: %o",e),await _.finalize(),process.exit(1)});
//# sourceMappingURL=pwc.js.map