browser-commander 0.21.1 → 0.21.2
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 +6 -0
- package/package.json +3 -2
- package/src/browser/real-browser.js +25 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.21.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 917d611: Keep the real-browser launcher under the ESLint complexity limit, fail `npm run lint` on any warning, and record that `node-pty`'s install script (pulled in by `command-stream`) stays blocked.
|
|
8
|
+
|
|
3
9
|
## 0.21.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "browser-commander",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.2",
|
|
4
4
|
"description": "Universal browser automation library that supports both Playwright and Puppeteer with a unified API",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"test:e2e:api-coverage": "node scripts/run-tests.mjs --env RUN_E2E=true tests/e2e/api-coverage.e2e.test.js",
|
|
28
28
|
"test:e2e:google-probe": "node scripts/run-tests.mjs --env RUN_E2E=true --env RUN_GOOGLE_PROBE=true tests/e2e/google-signin-probe.e2e.test.js",
|
|
29
29
|
"test:all": "npm run test:unit && npm run test:e2e",
|
|
30
|
-
"lint": "eslint .",
|
|
30
|
+
"lint": "eslint . --max-warnings 0",
|
|
31
31
|
"lint:fix": "eslint . --fix",
|
|
32
32
|
"format": "prettier --write .",
|
|
33
33
|
"format:check": "prettier --check .",
|
|
@@ -103,6 +103,7 @@
|
|
|
103
103
|
},
|
|
104
104
|
"allowScripts": {
|
|
105
105
|
"better-sqlite3@13.0.3": true,
|
|
106
|
+
"node-pty": false,
|
|
106
107
|
"puppeteer": false
|
|
107
108
|
}
|
|
108
109
|
}
|
|
@@ -527,6 +527,22 @@ function mergeSeedCookies(seedCookies, migratedCookies) {
|
|
|
527
527
|
: seedCookies;
|
|
528
528
|
}
|
|
529
529
|
|
|
530
|
+
// Runs a launch step and, if it throws, removes the profile this launch
|
|
531
|
+
// created before rethrowing. A caller-supplied profile is never removed.
|
|
532
|
+
async function removingTemporaryProfileOnError(
|
|
533
|
+
{ userDataDir, temporaryProfile },
|
|
534
|
+
step
|
|
535
|
+
) {
|
|
536
|
+
try {
|
|
537
|
+
return await step();
|
|
538
|
+
} catch (error) {
|
|
539
|
+
if (temporaryProfile) {
|
|
540
|
+
await removeUserDataDir(userDataDir);
|
|
541
|
+
}
|
|
542
|
+
throw error;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
|
|
530
546
|
export async function launchAndConnectRealBrowserWithDependencies(
|
|
531
547
|
options = {},
|
|
532
548
|
dependencies = {}
|
|
@@ -602,23 +618,18 @@ export async function launchAndConnectRealBrowserWithDependencies(
|
|
|
602
618
|
|
|
603
619
|
// Migration and snapshot attach can copy a preference that enables the
|
|
604
620
|
// default-browser infobar, so apply launch settings after either copy.
|
|
605
|
-
|
|
606
|
-
|
|
621
|
+
const profile = { userDataDir, temporaryProfile };
|
|
622
|
+
await removingTemporaryProfileOnError(profile, () =>
|
|
623
|
+
configureUserDataDir(userDataDir, {
|
|
607
624
|
defaultBrowserCheck,
|
|
608
625
|
preferences,
|
|
609
626
|
localState,
|
|
610
627
|
profileDirectory: attach?.profile ?? 'Default',
|
|
611
|
-
})
|
|
612
|
-
|
|
613
|
-
if (temporaryProfile) {
|
|
614
|
-
await removeUserDataDir(userDataDir);
|
|
615
|
-
}
|
|
616
|
-
throw error;
|
|
617
|
-
}
|
|
628
|
+
})
|
|
629
|
+
);
|
|
618
630
|
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
launched = await spawnOnFreePort({
|
|
631
|
+
const launched = await removingTemporaryProfileOnError(profile, () =>
|
|
632
|
+
spawnOnFreePort({
|
|
622
633
|
requestedPort: remoteDebuggingPort,
|
|
623
634
|
portAttempts,
|
|
624
635
|
executablePath,
|
|
@@ -628,13 +639,8 @@ export async function launchAndConnectRealBrowserWithDependencies(
|
|
|
628
639
|
userDataDir,
|
|
629
640
|
startupTimeout,
|
|
630
641
|
dependencies,
|
|
631
|
-
})
|
|
632
|
-
|
|
633
|
-
if (temporaryProfile) {
|
|
634
|
-
await removeUserDataDir(userDataDir);
|
|
635
|
-
}
|
|
636
|
-
throw error;
|
|
637
|
-
}
|
|
642
|
+
})
|
|
643
|
+
);
|
|
638
644
|
const { browserProcess, cdpEndpoint: resolvedCdpEndpoint } = launched;
|
|
639
645
|
if (temporaryProfile) {
|
|
640
646
|
// The profile goes away with the browser, also when the user closes the
|