@xbrowser/cli 1.7.9 → 1.8.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/dist/cli.js +26 -9
- package/dist/index.js +26 -9
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -10253,13 +10253,29 @@ async function handleSession(args, options, mode, _cdpEndpoint) {
|
|
|
10253
10253
|
const sub = args[0];
|
|
10254
10254
|
switch (sub) {
|
|
10255
10255
|
case "close": {
|
|
10256
|
-
|
|
10257
|
-
|
|
10258
|
-
|
|
10259
|
-
|
|
10256
|
+
if (options.all) {
|
|
10257
|
+
let count = 0;
|
|
10258
|
+
try {
|
|
10259
|
+
const sessions2 = await forwardSessionList();
|
|
10260
|
+
for (const s of sessions2) {
|
|
10261
|
+
try {
|
|
10262
|
+
await forwardSessionClose(s.name);
|
|
10263
|
+
count++;
|
|
10264
|
+
} catch {
|
|
10265
|
+
}
|
|
10266
|
+
}
|
|
10267
|
+
} catch {
|
|
10268
|
+
}
|
|
10269
|
+
outputResult({ ok: true, closed: count, all: true }, mode);
|
|
10270
|
+
} else {
|
|
10271
|
+
const name = options.session || options.name || process.env.XBROWSER_SESSION || "default";
|
|
10272
|
+
try {
|
|
10273
|
+
await forwardSessionClose(name);
|
|
10274
|
+
} catch {
|
|
10275
|
+
}
|
|
10276
|
+
await closeSession(name);
|
|
10277
|
+
outputResult({ ok: true, name }, mode);
|
|
10260
10278
|
}
|
|
10261
|
-
await closeSession(name);
|
|
10262
|
-
outputResult({ ok: true, name }, mode);
|
|
10263
10279
|
break;
|
|
10264
10280
|
}
|
|
10265
10281
|
case "list":
|
|
@@ -11316,12 +11332,13 @@ async function handleRun(filePath, options) {
|
|
|
11316
11332
|
async function handleViewer(_args, options, mode, _cdpEndpoint) {
|
|
11317
11333
|
const name = options.name || process.env.XBROWSER_SESSION || "default";
|
|
11318
11334
|
const selector = options.selector;
|
|
11335
|
+
const userPort = options.port ? Number(options.port) : void 0;
|
|
11319
11336
|
let status = getDaemonProcessStatus();
|
|
11320
11337
|
if (!status.running) {
|
|
11321
|
-
await startDaemonProcess();
|
|
11338
|
+
await startDaemonProcess(userPort || 9224);
|
|
11322
11339
|
status = getDaemonProcessStatus();
|
|
11323
11340
|
}
|
|
11324
|
-
const port = status.port || getDaemonConfig().basePort;
|
|
11341
|
+
const port = userPort || status.port || getDaemonConfig().basePort;
|
|
11325
11342
|
let url = `http://localhost:${port}/preview/${name}`;
|
|
11326
11343
|
if (selector) {
|
|
11327
11344
|
try {
|
|
@@ -12660,7 +12677,7 @@ async function routeCommand(argvIn, stdinCommands) {
|
|
|
12660
12677
|
const hasJsonFlag = argv.some((a) => a === "--json" || a.startsWith("--json="));
|
|
12661
12678
|
const hasYamlFlag = argv.some((a) => a === "--yaml" || a.startsWith("--yaml="));
|
|
12662
12679
|
const cleanArgv = argv.filter((a) => a !== "--json" && a !== "--yaml");
|
|
12663
|
-
const parsed = parseArgs(cleanArgv);
|
|
12680
|
+
const parsed = parseArgs(cleanArgv, { booleanFlags: ["json", "yaml"] });
|
|
12664
12681
|
const { positional, options } = parsed;
|
|
12665
12682
|
if (hasJsonFlag) options.json = true;
|
|
12666
12683
|
if (hasYamlFlag) options.yaml = true;
|
package/dist/index.js
CHANGED
|
@@ -10576,13 +10576,29 @@ async function handleSession(args, options, mode, _cdpEndpoint) {
|
|
|
10576
10576
|
const sub = args[0];
|
|
10577
10577
|
switch (sub) {
|
|
10578
10578
|
case "close": {
|
|
10579
|
-
|
|
10580
|
-
|
|
10581
|
-
|
|
10582
|
-
|
|
10579
|
+
if (options.all) {
|
|
10580
|
+
let count = 0;
|
|
10581
|
+
try {
|
|
10582
|
+
const sessions2 = await forwardSessionList();
|
|
10583
|
+
for (const s of sessions2) {
|
|
10584
|
+
try {
|
|
10585
|
+
await forwardSessionClose(s.name);
|
|
10586
|
+
count++;
|
|
10587
|
+
} catch {
|
|
10588
|
+
}
|
|
10589
|
+
}
|
|
10590
|
+
} catch {
|
|
10591
|
+
}
|
|
10592
|
+
outputResult({ ok: true, closed: count, all: true }, mode);
|
|
10593
|
+
} else {
|
|
10594
|
+
const name = options.session || options.name || process.env.XBROWSER_SESSION || "default";
|
|
10595
|
+
try {
|
|
10596
|
+
await forwardSessionClose(name);
|
|
10597
|
+
} catch {
|
|
10598
|
+
}
|
|
10599
|
+
await closeSession(name);
|
|
10600
|
+
outputResult({ ok: true, name }, mode);
|
|
10583
10601
|
}
|
|
10584
|
-
await closeSession(name);
|
|
10585
|
-
outputResult({ ok: true, name }, mode);
|
|
10586
10602
|
break;
|
|
10587
10603
|
}
|
|
10588
10604
|
case "list":
|
|
@@ -11639,12 +11655,13 @@ async function handleRun(filePath, options) {
|
|
|
11639
11655
|
async function handleViewer(_args, options, mode, _cdpEndpoint) {
|
|
11640
11656
|
const name = options.name || process.env.XBROWSER_SESSION || "default";
|
|
11641
11657
|
const selector = options.selector;
|
|
11658
|
+
const userPort = options.port ? Number(options.port) : void 0;
|
|
11642
11659
|
let status = getDaemonProcessStatus();
|
|
11643
11660
|
if (!status.running) {
|
|
11644
|
-
await startDaemonProcess();
|
|
11661
|
+
await startDaemonProcess(userPort || 9224);
|
|
11645
11662
|
status = getDaemonProcessStatus();
|
|
11646
11663
|
}
|
|
11647
|
-
const port = status.port || getDaemonConfig().basePort;
|
|
11664
|
+
const port = userPort || status.port || getDaemonConfig().basePort;
|
|
11648
11665
|
let url = `http://localhost:${port}/preview/${name}`;
|
|
11649
11666
|
if (selector) {
|
|
11650
11667
|
try {
|
|
@@ -12983,7 +13000,7 @@ async function routeCommand(argvIn, stdinCommands) {
|
|
|
12983
13000
|
const hasJsonFlag = argv.some((a) => a === "--json" || a.startsWith("--json="));
|
|
12984
13001
|
const hasYamlFlag = argv.some((a) => a === "--yaml" || a.startsWith("--yaml="));
|
|
12985
13002
|
const cleanArgv = argv.filter((a) => a !== "--json" && a !== "--yaml");
|
|
12986
|
-
const parsed = parseArgs(cleanArgv);
|
|
13003
|
+
const parsed = parseArgs(cleanArgv, { booleanFlags: ["json", "yaml"] });
|
|
12987
13004
|
const { positional, options } = parsed;
|
|
12988
13005
|
if (hasJsonFlag) options.json = true;
|
|
12989
13006
|
if (hasYamlFlag) options.yaml = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xbrowser/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"description": "Browser automation CLI for web scraping, headless browsing, SEO analysis, and AI agent workflows. A command-line alternative to Playwright, Puppeteer, and Selenium.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"prepare": "husky"
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
|
-
"@dyyz1993/xcli-core": "^0.
|
|
87
|
+
"@dyyz1993/xcli-core": "^0.18.0",
|
|
88
88
|
"@types/react-syntax-highlighter": "^15.5.13",
|
|
89
89
|
"@types/turndown": "^5.0.6",
|
|
90
90
|
"cheerio": "^1.2.0",
|