@browserless.io/cli 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +10 -8
- package/build/auth/disclaimer.js +1 -1
- package/build/capture/copy-profile.js +1 -1
- package/build/capture/index.js +1 -1
- package/build/capture/profile-lock.js +5 -0
- package/build/cli-utils/capture-runner.js +25 -24
- package/build/version.js +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.5.1](https://github.com/browserless/browserless-cli/compare/v0.5.0...v0.5.1) (2026-10-22)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* AUTO-640 detect the Windows cookie-file lock during profile capture ([#134](https://github.com/browserless/browserless-cli/issues/134)) ([3a2ca62](https://github.com/browserless/browserless-cli/commit/3a2ca628558976e3444362d368bab2b27dc8ff8d))
|
|
9
|
+
|
|
3
10
|
## [0.5.0](https://github.com/browserless/browserless-cli/compare/v0.4.2...v0.5.0) (2026-10-16)
|
|
4
11
|
|
|
5
12
|
|
package/README.md
CHANGED
|
@@ -96,6 +96,8 @@ browserless profile upload \
|
|
|
96
96
|
--browser chrome --profile Default --name my-chrome
|
|
97
97
|
```
|
|
98
98
|
|
|
99
|
+
> **Windows:** quit the browser completely before capturing — including its icon in the taskbar notification area. Windows keeps the browser's cookie database locked while it runs. If it is still running, the CLI says so; in an interactive terminal it waits up to 2 minutes and continues once the browser has closed.
|
|
100
|
+
|
|
99
101
|
**✅ Success!** Any Browserless cloud session can now start _already
|
|
100
102
|
authenticated_ by attaching `?profile=my-chrome` to its launch URL.
|
|
101
103
|
|
|
@@ -390,14 +392,14 @@ DO_NOT_TRACK=1 ... # per-run (cross-tool standard)
|
|
|
390
392
|
|
|
391
393
|
## 🚦 Exit Codes
|
|
392
394
|
|
|
393
|
-
| Code | Meaning
|
|
394
|
-
| ---- |
|
|
395
|
-
| 0 | Success
|
|
396
|
-
| 1 | Internal bug — prints a stack trace
|
|
397
|
-
| 2 | Bad arguments (`UsageError`)
|
|
398
|
-
| 3 | Precondition failed — no token, disclaimer declined, profile busy, corrupt config (`PreconditionError`)
|
|
399
|
-
| 4 | Local capture pipeline failed — copy / browser launch / CDP (`CaptureError`)
|
|
400
|
-
| 5 | Server returned a non-2xx response (`ApiError`)
|
|
395
|
+
| Code | Meaning |
|
|
396
|
+
| ---- | --------------------------------------------------------------------------------------------------------------------------- |
|
|
397
|
+
| 0 | Success |
|
|
398
|
+
| 1 | Internal bug — prints a stack trace |
|
|
399
|
+
| 2 | Bad arguments (`UsageError`) |
|
|
400
|
+
| 3 | Precondition failed — no token, disclaimer declined, profile busy, corrupt config (`PreconditionError`) |
|
|
401
|
+
| 4 | Local capture pipeline failed — copy (including a browser still running on Windows) / browser launch / CDP (`CaptureError`) |
|
|
402
|
+
| 5 | Server returned a non-2xx response (`ApiError`) |
|
|
401
403
|
|
|
402
404
|
## 💡 Why use the CLI?
|
|
403
405
|
|
package/build/auth/disclaimer.js
CHANGED
|
@@ -13,4 +13,4 @@ Heads up \u2014 uploading a profile sends authentication state to Browserless:
|
|
|
13
13
|
By continuing you confirm you understand the above and accept responsibility
|
|
14
14
|
for the contents of the upload. Privacy policy: https://www.browserless.io/privacy-policy
|
|
15
15
|
`,l="I accept",y=o(()=>!!process.env.CI,"isCi"),h=o((t,e)=>{if(!t||e<=0)return!1;const r=Date.parse(t);if(!Number.isFinite(r))return!1;const a=Date.now()-r;return a>=0&&a<e*24*60*60*1e3},"isWithinTtl"),S=o(async t=>{s.write(t);const e=u.createInterface({input:n,output:s});try{return await e.question(`
|
|
16
|
-
Type "${l}" to continue: `)}finally{e.close()}},"defaultPrompt"),R=o(async(t,e={})=>{const r=await m(),a=t.ttlDaysOverride??r.terms_ttl_days??f;if(h(r.accepted_terms_at,a))return;if(t.acceptViaFlag||process.env.BROWSERLESS_ACCEPT_TERMS==="1"){await c(i=>{i.accepted_terms_at=new Date().toISOString()});return}if(!(e.isInteractive??(n.isTTY&&!y())))throw new p("Liability disclaimer must be acknowledged before uploading. Re-run with `--accept-terms` or set BROWSERLESS_ACCEPT_TERMS=1 in non-interactive environments.","terms-not-accepted");if((await(e.prompt??S)(w)).trim()!==l)throw new p("Disclaimer not accepted \u2014 aborting.","terms-not-accepted");await c(i=>{i.accepted_terms_at=new Date().toISOString()})},"ensureTermsAccepted");export{w as DISCLAIMER_TEXT,R as ensureTermsAccepted};
|
|
16
|
+
Type "${l}" to continue: `)}finally{e.close()}},"defaultPrompt"),R=o(async(t,e={})=>{const r=await m(),a=t.ttlDaysOverride??r.terms_ttl_days??f;if(h(r.accepted_terms_at,a))return;if(t.acceptViaFlag||process.env.BROWSERLESS_ACCEPT_TERMS==="1"){await c(i=>{i.accepted_terms_at=new Date().toISOString()});return}if(!(e.isInteractive??(n.isTTY&&!y())))throw new p("Liability disclaimer must be acknowledged before uploading. Re-run with `--accept-terms` or set BROWSERLESS_ACCEPT_TERMS=1 in non-interactive environments.","terms-not-accepted");if((await(e.prompt??S)(w)).trim()!==l)throw new p("Disclaimer not accepted \u2014 aborting.","terms-not-accepted");await c(i=>{i.accepted_terms_at=new Date().toISOString()})},"ensureTermsAccepted");export{w as DISCLAIMER_TEXT,R as ensureTermsAccepted,y as isCi};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var S=Object.defineProperty;var c=(o,i)=>S(o,"name",{value:i,configurable:!0});import a from"node:fs/promises";import r from"node:path";import h from"node:os";import{CaptureError as l}from"../errors.js";import{COOKIE_DB_FILES as m,createLockGate as w,isWindowsLockError as p}from"./profile-lock.js";const g=new Set(["Cache","Code Cache","GPUCache","GraphiteDawnCache","ShaderCache","Service Worker","Crashpad","optimization_guide_model_store","Default Cache"]),k=new Set(["History","History-journal","History Provider Cache","Top Sites","Top Sites-journal","Visited Links","Favicons","Favicons-journal","Shortcuts","Shortcuts-journal","Network Action Predictor","Network Action Predictor-journal","Login Data","Login Data-journal","Login Data For Account","Login Data For Account-journal","Web Data","Web Data-journal","Account Web Data","Account Web Data-journal","Affiliation Database","Affiliation Database-journal","AutofillStrikeDatabase","AutofillAiModelCache","passkey_enclave_state","trusted_vault.pb","Bookmarks","Bookmarks.bak","BookmarkMergedSurfaceOrdering","DIPS","DIPS-shm","DIPS-wal","Trust Tokens","Trust Tokens-journal","BrowsingTopicsState","BrowsingTopicsSiteData","BrowsingTopicsSiteData-journal","Reporting and NEL","Reporting and NEL-journal","SCT Auditing Pending Reports","Extensions","Extension Cookies","Extension Cookies-journal","Extension Rules","Extension Scripts","Extension State","Local Extension Settings","Managed Extension Settings","Sync Extension Settings","Sessions","Sync Data","Sync App Settings","Web Applications","Platform Notifications","Download Service","chrome_cart_db","commerce_subscription_db","discount_infos_db","discounts_db","parcel_tracking_db","heavy_ad_intervention_opt_out.db","heavy_ad_intervention_opt_out.db-journal","Safe Browsing Cookies","Safe Browsing Cookies-journal"]),_=["SingletonLock","SingletonSocket","SingletonCookie"],v=c(async(o,i={interactive:!1})=>{const e=w(o,i),s=i.platform??process.platform;for(const u of m)await e.ensureReadable(r.join(o.profilePath,u));return e.retryOnLock(()=>D(o,s))},"buildTempUserDataDir"),D=c(async(o,i)=>{const e=await a.mkdtemp(r.join(h.tmpdir(),"browserless-cli-")),s=r.join(o.userDataDir,"Local State"),u=r.join(e,"Local State");try{await a.copyFile(s,u)}catch(t){const n=t?.code;if(n!=="ENOENT")throw await a.rm(e,{recursive:!0,force:!0}).catch(()=>{}),p(t,i)?t:new l(`Failed to copy ${s} (${n??"unknown error"}): ${t.message}`,"profile-copy-failed")}try{await a.writeFile(r.join(e,"First Run"),"")}catch(t){throw await a.rm(e,{recursive:!0,force:!0}).catch(()=>{}),new l(`Failed to write First Run marker in ${e}: ${t.message}`,"profile-copy-failed")}const d=r.join(e,o.profileDirName);try{await a.cp(o.profilePath,d,{recursive:!0,force:!0,filter:c(t=>{const n=r.relative(o.profilePath,t);if(!n)return!0;const f=n.split(r.sep)[0];return!(g.has(f)||k.has(f))},"filter")})}catch(t){throw await a.rm(e,{recursive:!0,force:!0}).catch(()=>{}),p(t,i)?t:new l(`Failed to copy profile from ${o.profilePath}: ${t?.message??t}`,"profile-copy-failed")}return await Promise.all(_.flatMap(t=>[a.unlink(r.join(e,t)).catch(()=>{}),a.unlink(r.join(d,t)).catch(()=>{})])),e},"copyOnce");export{v as buildTempUserDataDir};
|
package/build/capture/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var p=Object.defineProperty;var
|
|
1
|
+
var p=Object.defineProperty;var n=(i,t)=>p(i,"name",{value:t,configurable:!0});import g from"node:fs/promises";import{buildTempUserDataDir as m}from"./copy-profile.js";import{killBrowser as f,launchBrowser as D,pickFreePort as h,waitForDebuggerEndpoint as w}from"./launch.js";import{captureViaCdp as y}from"./cdp.js";const k=n(()=>process.hrtime.bigint(),"startTime"),C=n(i=>Number((process.hrtime.bigint()-i)/1000000n),"elapsedMs"),b=n(async i=>{const t=k(),o=i.onProgress;o?.({phase:"copying"});const c=await m(i.profile,{interactive:i.interactive??!1,onWait:n(r=>o?.({phase:"waiting-for-unlock",...r}),"onWait")}),a=await h();let s=null,l;try{o?.({phase:"launching"});const r=await D({profile:i.profile,userDataDir:c,port:a,passwordStoreOverride:i.passwordStoreOverride});s=r.child,l=r.passwordStoreDefaulted,o?.({phase:"waiting-for-debugger"}),await w(a,void 0,r.diagnostics),o?.({phase:"capturing-origins",attempted:0,total:0,origin:""});const e=await y(i.profile,a,i.excludedDomains??[],u=>o?.({phase:"capturing-origins",...u}),i.onlyDomains??[]);o?.({phase:"done"});const d=JSON.stringify(e.state);return{state:e.state,diagnostics:{cookieCountBeforeExclusion:e.cookieCountTotal,cookieCountExcluded:e.cookieCountExcluded,originCountBeforeExclusion:e.state.origins.length+e.originCountSkippedByExclusion+e.originCountSkippedByOnlyDomain,originCountExcluded:e.originCountSkippedByExclusion,originCountSkippedByOnlyDomain:e.originCountSkippedByOnlyDomain,excludedDomains:i.excludedDomains??[],onlyDomains:i.onlyDomains??[],durationMs:C(t),failedOrigins:e.failedOrigins},capHit:e.capHit,passwordStoreDefaulted:l,serialized:d}}finally{s&&await f(s),await g.rm(c,{recursive:!0,force:!0}).catch(()=>{})}},"captureFromProfile");export{b as captureFromProfile};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var M=Object.defineProperty;var o=(e,n)=>M(e,"name",{value:n,configurable:!0});import y from"node:fs/promises";import l from"node:path";import{checkProfileLock as C}from"../browsers/lock.js";import{CaptureError as D}from"../errors.js";const b=12e4,R=1e3,x=1500,I=[l.join("Network","Cookies"),l.join("Network","Cookies-journal"),"Cookies","Cookies-journal"],p=o((e,n=process.platform)=>n==="win32"&&typeof e=="object"&&e!==null&&"code"in e&&(e.code==="EBUSY"||e.code==="EPERM"),"isWindowsLockError"),_=o(async e=>{try{return await((await y.stat(e)).isDirectory()?await y.opendir(e):await y.open(e,"r")).close(),null}catch(n){return n.code==="ENOENT"?null:n}},"probeReadable"),L=o((e,n,a,u=b)=>{const i=e.browserDisplayName,c=e.profileDisplayName,{relativePath:s,code:f,browserRunning:m}=n,h=l.win32.basename(e.binaryPath),w=Math.round(u/6e4);return a==="wait"?m?[`${i} is still running, so Windows keeps ${s} locked.`,`Quit ${i} completely now (menu \u2192 Exit, or right-click its icon in the taskbar notification area \u2192 Exit). The capture continues automatically once it has closed \u2014 waiting up to ${w} minutes (Ctrl+C to cancel).`].join(`
|
|
2
|
+
`):`${s} is locked by another program. Waiting up to ${w} minutes for it to be released (Ctrl+C to cancel).`:m?[`Can't capture ${i} / ${c}: ${s} is locked (${f}) because ${i} is still running.`,`On Windows, ${i} keeps its cookie database locked while it runs, including in the background after its last window is closed.`,`Quit ${i} completely (menu \u2192 Exit, or right-click its icon in the taskbar notification area \u2192 Exit; end any leftover ${h} processes in Task Manager), then re-run this command.`,'To stop it running in the background, turn off "Continue running background apps" under Settings \u2192 System.'].join(`
|
|
3
|
+
`):[`Can't capture ${i} / ${c}: ${s} is locked (${f}) by another program.`,`${i} is not running, but antivirus, backup or cloud-sync software can hold browser files open for a while. Wait a few seconds and re-run this command; if it keeps failing, restart Windows and try again.`].join(`
|
|
4
|
+
`)},"formatProfileLockedMessage"),W=o((e,n)=>[`Can't capture ${e.browserDisplayName} / ${e.profileDisplayName}: Windows denied access to ${n} (EPERM).`,`Either your Windows account can't read this file, or another program is holding it (antivirus, backup or cloud-sync software, or ${e.browserDisplayName} itself if it is still running).`,`Quit ${e.browserDisplayName} completely, wait a few seconds and re-run this command. If it keeps failing, check that your Windows account can read the files in this browser profile.`].join(`
|
|
5
|
+
`),"formatAccessDeniedMessage"),P=o((e,n)=>{const a=n.platform??process.platform,u=n.probe??_,i=n.isBrowserRunning??(async r=>(await C(r)).locked),c=n.sleep??(r=>new Promise(t=>setTimeout(t,r))),s=n.now??Date.now,f=n.timeoutMs??b,m=n.pollMs??R,h=n.retryDelayMs??x;let w,g=!1;const d=o(async(r,t)=>t==="EPERM"?new D(W(e,l.relative(e.userDataDir,r)),"profile-copy-failed"):new D(L(e,{relativePath:l.relative(e.userDataDir,r),browserRunning:await i(e.userDataDir),code:t},"fail"),"profile-file-locked"),"fileError"),k=o(async r=>{let t=await u(r);if(t?.code==="EPERM"&&(await c(h),t=await u(r),t?.code==="EPERM"))throw await d(r,t.code);return t},"probeWithPermissionRetry"),E=o(async r=>{if(a!=="win32")return;let t=await k(r);if(!p(t,a))return;const $=await i(e.userDataDir);if(!n.interactive){if($)throw await d(r,t.code);if(await c(h),t=await u(r),p(t,a))throw await d(r,t.code);return}for(w??=s()+f,g||(n.onWait?.({relativePath:l.relative(e.userDataDir,r),browserRunning:$,code:t.code}),g=!0);s()<w;)if(await c(m),t=await k(r),!p(t,a))return;throw await d(r,t.code)},"ensureReadable");return{ensureReadable:E,retryOnLock:o(async r=>{try{return await r()}catch(t){if(!p(t,a))throw t;await E(t.path??e.profilePath)}try{return await r()}catch(t){throw p(t,a)?await d(t.path??e.profilePath,t.code):t}},"retryOnLock")}},"createLockGate");export{I as COOKIE_DB_FILES,R as LOCK_POLL_MS,x as LOCK_RETRY_DELAY_MS,b as LOCK_WAIT_TIMEOUT_MS,P as createLockGate,W as formatAccessDeniedMessage,L as formatProfileLockedMessage,p as isWindowsLockError,_ as probeReadable};
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)},"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
`)}
|
|
6
|
-
`),"
|
|
7
|
-
`);const
|
|
8
|
-
`)
|
|
9
|
-
`))}const
|
|
10
|
-
`)
|
|
11
|
-
`)
|
|
12
|
-
`)
|
|
13
|
-
`)
|
|
14
|
-
`)
|
|
15
|
-
`)
|
|
16
|
-
`)
|
|
17
|
-
`);
|
|
18
|
-
`)
|
|
19
|
-
`)
|
|
20
|
-
`);
|
|
21
|
-
`)
|
|
22
|
-
`)
|
|
23
|
-
`)
|
|
1
|
+
var _=Object.defineProperty;var p=(t,e)=>_(t,"name",{value:e,configurable:!0});import{resolveProfile as v}from"../browsers/discover.js";import{captureFromProfile as C}from"../capture/index.js";import{applyOnlyFilter as F,mergeExclusionPatterns as B,normalizeExclusion as y}from"../capture/exclusion.js";import{readConfig as A}from"../config/store.js";import{ensureTermsAccepted as I,isCi as R}from"../auth/disclaimer.js";import{formatProfileLockedMessage as P}from"../capture/profile-lock.js";import{UsageError as T}from"../errors.js";import{version as L}from"../version.js";import{collectRepeated as b,parseNonNegativeInt as z}from"./client.js";import{formatBytes as u,measureOriginSizes as G,SERVER_ARTIFACT_CAP_BYTES as x,trimStateToFit as M}from"./trim-state.js";const j=p((t,e)=>t===!0&&!e,"captureIsInteractive"),H=p((t,e)=>{const o={copying:"copying profile data\u2026",launching:"launching headless browser\u2026","waiting-for-debugger":"waiting for browser to be ready\u2026"};let s="",d=0;return r=>{if(r.phase!=="done"){if(r.phase==="waiting-for-unlock"){P(t,r,"wait").split(`
|
|
2
|
+
`).forEach(e);return}if(r.phase==="capturing-origins"){if(r.attempted===0){s!=="capturing-origins"&&(s="capturing-origins",e("capturing per-origin storage\u2026"));return}if(!(r.attempted===r.total)&&r.attempted-d<5)return;d=r.attempted;const i=r.origin.length>50?r.origin.slice(0,47)+"\u2026":r.origin;e(` ${r.attempted}/${r.total} ${i}`);return}r.phase!==s&&(s=r.phase,e(o[r.phase]??r.phase))}}},"createProgressRenderer"),ae=p((t,e={})=>{const l=e.sourceOptional?t.option.bind(t):t.requiredOption.bind(t),o=e.sourceOptional?". Optional here \u2014 read from the profile's stored settings when omitted":"";return l("--browser <key>",`Source browser key (chrome / brave / edge / ...) or display name${o}`),l("--profile <name>",`Source profile display name or directory (e.g. "Personal", "Default")${o}`),t.option("--exclude-domain <domain>","Append a domain to the exclusion list for this run (repeatable)",b).option("--no-default-excludes","Skip the persistent exclusion list for this run").option("--accept-terms","Pre-accept the liability disclaimer").option("--terms-ttl-days <n>","Override the disclaimer re-prompt TTL for this run").option("--password-store <store>","Linux only: --password-store value to pass through to the headless launch (basic / gnome-libsecret / kwallet5 / ...)").option("--auto-fit","If the captured artifact exceeds the 2 MB server cap, drop the heaviest origins (largest serialized contribution first) until it fits").option("--keep-domain <domain>","Domain that --auto-fit must never drop (suffix-match, same syntax as --exclude-domain; repeatable)",b).option("--only-domain <domain>","Capture only cookies / origins matching this domain \u2014 discard everything else (suffix-match; repeatable; applies after --exclude-domain)",b)},"addCaptureFlags"),U=p(t=>{if(t.length>0&&!t.some(e=>y(e)!==null))throw new T(`--only-domain: no valid domain pattern in ${JSON.stringify(t)}. Use a hostname like "example.com" or "*.example.com".`)},"validateOnlyDomain"),D=100,Y=253,O=255,N=8*1024,J=/[$`\\!\u0000-\u001f\u007f]/,K=/^[A-Za-z0-9*._-]+$/,$=p((t,e)=>{process.stderr.write(` \u2192 Not storing ${t} for refresh (${e}); a later flagless \`profile refresh\` of this profile will not replay it
|
|
3
|
+
`)},"warnDropped"),X=p(t=>{const e=`they serialize past the server's ${N}-byte limit`;process.stderr.write(t==="upload"?` \u2192 Not storing any capture settings (${e}); a later flagless \`profile refresh\` of this profile will have nothing to replay
|
|
4
|
+
`:` \u2192 Not updating the stored capture settings (${e}); whatever this profile already had is left as it was, so it no longer matches this run and a later flagless \`profile refresh\` will not reflect these filters. Shorten the domain lists to update them
|
|
5
|
+
`)},"warnOverCap"),E=p((t,e)=>{const l=e?.trim();if(l){if(J.test(l)){$(`--${t}`,"it contains characters a shell would interpret");return}if(l.length>O){$(`--${t}`,`it exceeds ${O} characters`);return}return l}},"safeScalar"),k=p((t,e,l=!1)=>{const o=[...new Set((e??[]).map(d=>y(d)).filter(d=>d!==null))],s=o.filter(d=>d.length<=Y&&K.test(d));return s.length<o.length&&$(`${o.length-s.length} of ${o.length} --${t} patterns`,"the server only stores plain hostname patterns"),s.length?(s.length>D&&$(`${s.length-D} of ${s.length} --${t} patterns`,`the server stores at most ${D}`),s.slice(0,D)):l&&!(e??[]).length?[]:void 0},"safeDomains"),m=p((t,e)=>e===void 0?{}:{[t]:e},"withKey"),le={browser:"browser",profile:"profile",excludeDomains:"excludeDomain",onlyDomains:"onlyDomain",keepDomains:"keepDomain",autoFit:"autoFit",passwordStore:"passwordStore"},de=p((t,e,l)=>{const o={...m("browser",E("browser",t.browser)),...m("profile",E("profile",t.profile)),...m("excludeDomains",k("exclude-domain",e.excludedDomains,t.defaultExcludes===!1)),...m("onlyDomains",k("only-domain",t.onlyDomain)),...m("keepDomains",k("keep-domain",t.keepDomain)),...t.autoFit?{autoFit:!0}:{},...m("passwordStore",E("password-store",t.passwordStore)),cliVersion:L};if(Buffer.byteLength(JSON.stringify(o),"utf8")>N){X(l);return}return o},"buildCaptureSettings"),q=p(t=>{(t??[]).filter(e=>y(e)===null).forEach(e=>{process.stderr.write(` ! --exclude-domain ${JSON.stringify(e)} is not a usable domain pattern \u2014 nothing was excluded for it
|
|
6
|
+
`)})},"warnUnusableExcludes"),pe=p((t,e)=>{if(!e)return t;const l=t.defaultExcludes===!1,o=(t.excludeDomain??[]).some(d=>y(d)!==null),s=!o&&e.excludeDomains!==void 0;return{...t,browser:t.browser??e.browser,profile:t.profile??e.profile,passwordStore:t.passwordStore??e.passwordStore,excludeDomain:o?t.excludeDomain:l?[]:e.excludeDomains,onlyDomain:t.onlyDomain??e.onlyDomains,keepDomain:t.keepDomain??e.keepDomains,autoFit:t.autoFit??e.autoFit,defaultExcludes:s?!1:t.defaultExcludes}},"mergeStoredSettings"),ce=p((t,e,l={})=>{if(!e)return;const o=p(i=>process.stderr.write(`${i}
|
|
7
|
+
`),"w"),s=l.userOptedOut===!0;o("> Refreshing with these effective settings:"),t.browser&&o(` --browser ${t.browser}`),t.profile&&o(` --profile ${t.profile}`);const d=(t.excludeDomain??[]).filter(i=>y(i)!==null);d.length&&o(` --exclude-domain ${d.join(", ")}`),t.onlyDomain?.length&&(o(` --only-domain ${t.onlyDomain.join(", ")}`),o(" ! only these domains are captured \u2014 everything else in the saved"),o(" profile is replaced, not kept")),t.keepDomain?.length&&o(` --keep-domain ${t.keepDomain.join(", ")}`),t.autoFit&&o(" --auto-fit (only acts if the capture exceeds the 2 MB cap)"),t.passwordStore&&o(` --password-store ${t.passwordStore}`),s&&o(" --no-default-excludes");const r=s&&!d.length,f=e.excludeDomains?.length;r&&f&&(o(` ! --no-default-excludes drops the ${f} stored exclusion pattern(s) for this run,`),o(" and re-pass --exclude-domain if you want to keep them.")),r?(o(" ! Unless the settings exceed the 8 KB cap (reported after the capture), the"),o(" refreshed profile is stored with NO exclusion list, so later flagless refreshes"),o(" replay 'exclude nothing' and stop applying this machine's config.")):s?(o(" ! --no-default-excludes is in force: ONLY the --exclude-domain patterns above"),o(" are excluded, and this machine's own config is not applied.")):f===void 0&&(o(" (no stored exclusion list \u2014 this machine's own config applies)"),o(" This run stores the effective list on the profile, so later flagless refreshes"),o(" replay that snapshot instead of re-reading this config.")),o(" Pass --browser, --profile, --password-store or a domain flag to override."),s||(o(f===void 0?" --exclude-domain adds to this machine's config for this run; there is no stored list to replace.":" --exclude-domain replaces the stored list and re-applies this machine's config."),f&&o(" --no-default-excludes drops the stored list for good."))},"printEffectiveSettings"),fe=p(async t=>{const{flags:e,requiresDisclaimer:l}=t;if(!e.browser||!e.profile){const a=[e.browser?null:"--browser",e.profile?null:"--profile"].filter(Boolean);throw new T(`${a.join(" and ")} ${a.length>1?"are":"is"} required: this profile has no stored capture settings to read them from (it was not created by the CLI, or this server does not return them yet)`)}const o=await v(e.browser,e.profile);l&&await I({acceptViaFlag:!!e.acceptTerms,ttlDaysOverride:e.termsTtlDays!==void 0?z("--terms-ttl-days",e.termsTtlDays):void 0});const s=await A(),d=B(s.excluded_domains,e.excludeDomain,e.defaultExcludes===!1);U(e.onlyDomain??[]),q(e.excludeDomain),process.stderr.write(`> Capturing ${o.browserDisplayName} / ${o.profileDisplayName}
|
|
8
|
+
`);const r=p(a=>{process.stderr.write(` ${a}
|
|
9
|
+
`)},"writeLine"),f={profile:o,excludedDomains:d,onlyDomains:e.onlyDomain??[],passwordStoreOverride:e.passwordStore,interactive:j(process.stdin.isTTY,R()),onProgress:H(o,r)},i=await C(f);if(e.onlyDomain&&e.onlyDomain.length>0){const a=F(i.state,e.onlyDomain),h=i.state.cookies.length-a.state.cookies.length,n=i.diagnostics.originCountSkippedByOnlyDomain+a.originsDropped;(h>0||n>0)&&(i.state=a.state,i.serialized=JSON.stringify(a.state),process.stderr.write(` \u2192 --only-domain kept ${i.state.cookies.length} cookies / ${i.state.origins.length} origins; dropped ${h} cookies / ${n} origins not matching: ${e.onlyDomain.join(", ")}
|
|
10
|
+
`))}const c=i.diagnostics,S=Buffer.byteLength(i.serialized,"utf-8");if(process.stderr.write(`> Captured ${c.cookieCountBeforeExclusion} cookies, ${c.originCountBeforeExclusion} origins in ${c.durationMs}ms (artifact: ${u(S)})
|
|
11
|
+
`),c.cookieCountExcluded>0||c.originCountExcluded>0){const a=c.excludedDomains.length?c.excludedDomains.join(", "):"(none)";process.stderr.write(` \u2192 Excluded ${c.cookieCountExcluded} cookies / ${c.originCountExcluded} origins matching: ${a}
|
|
12
|
+
`)}if(i.capHit&&process.stderr.write(` ! Hit the per-capture origin cap \u2014 some origins may be missing
|
|
13
|
+
`),c.failedOrigins.length>0){process.stderr.write(` ! ${c.failedOrigins.length} origin(s) failed to capture \u2014 their localStorage / IndexedDB is missing from the upload:
|
|
14
|
+
`);for(const a of c.failedOrigins)process.stderr.write(` - ${a.origin}: ${a.error}
|
|
15
|
+
`)}if(i.passwordStoreDefaulted&&process.stderr.write(` ! Linux password-store could not be detected \u2014 defaulted to "basic". If decryption failed, re-run with --password-store=<your store>
|
|
16
|
+
`),S>x){const a=G(i.state),g=10;process.stderr.write(` ! artifact size ${u(S)} exceeds the ${u(x)} server cap \u2014 heaviest origins:
|
|
17
|
+
`);for(const{origin:h,bytes:n}of a.slice(0,g))process.stderr.write(` ${u(n).padStart(10)} ${h}
|
|
18
|
+
`);if(a.length>g&&process.stderr.write(` \u2026 and ${a.length-g} more origins below ${u(a[g].bytes)}
|
|
19
|
+
`),e.autoFit){const h=e.keepDomain??[],n=M(i.state,x,h);if(n.dropped.length===0&&n.finalBytes<=x)process.stderr.write(` ! --auto-fit had nothing to drop \u2014 artifact unchanged
|
|
20
|
+
`);else{if(i.state=n.state,i.serialized=n.serialized,c.failedOrigins=[...c.failedOrigins,...n.dropped.map(w=>({origin:w,error:"dropped by --auto-fit to fit under the server cap",kind:"unknown"}))],n.dropped.length>0){process.stderr.write(` --auto-fit: dropped ${n.dropped.length} origin(s), now ${u(n.finalBytes)}:
|
|
21
|
+
`);for(const w of n.dropped)process.stderr.write(` - ${w}
|
|
22
|
+
`)}if(n.protectedFromDrop.length>0){process.stderr.write(` --auto-fit: ${n.protectedFromDrop.length} heavy origin(s) protected by --keep-domain:
|
|
23
|
+
`);for(const w of n.protectedFromDrop)process.stderr.write(` - ${w}
|
|
24
|
+
`)}n.finalBytes>x&&(n.protectedFromDrop.length>0?process.stderr.write(` ! Still ${u(n.finalBytes)} after the trim \u2014 the --keep-domain origins alone exceed the cap. Remove one or more --keep-domain entries, or accept the upload will be rejected.
|
|
24
25
|
`):process.stderr.write(` ! Even after dropping every droppable origin the artifact is still over cap. The cookies alone may be too heavy.
|
|
25
26
|
`))}}else process.stderr.write(` Re-run with --auto-fit to drop the heaviest origins automatically (combine with --keep-domain <domain> to protect specific sites; or --only-domain <domain> to capture just those), or pass --exclude-domain <host> for each you want removed.
|
|
26
|
-
`)}return
|
|
27
|
+
`)}return i},"runCapture");export{le as SETTINGS_REPLAY_SOURCE,ae as addCaptureFlags,de as buildCaptureSettings,j as captureIsInteractive,H as createProgressRenderer,pe as mergeStoredSettings,ce as printEffectiveSettings,fe as runCapture,U as validateOnlyDomain,q as warnUnusableExcludes};
|
package/build/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const o="0.5.
|
|
1
|
+
const o="0.5.1";export{o as version};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@browserless.io/cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Browserless CLI — manage authentication profiles, sessions, and other Browserless features from your terminal.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"ws": "^8.22.0"
|
|
51
51
|
},
|
|
52
52
|
"optionalDependencies": {
|
|
53
|
-
"@napi-rs/keyring": "^2.1.
|
|
53
|
+
"@napi-rs/keyring": "^2.1.2"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@eslint/js": "^10.0.1",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"@types/ws": "^8.18.2",
|
|
63
63
|
"chai": "^6.3.0",
|
|
64
64
|
"esbuild": "^0.28.2",
|
|
65
|
-
"eslint": "^10.
|
|
65
|
+
"eslint": "^10.13.0",
|
|
66
66
|
"globals": "^17.13.0",
|
|
67
67
|
"husky": "^9.1.7",
|
|
68
68
|
"lint-staged": "^17.6.0",
|