@browserless/cli 10.9.17 → 10.10.0
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/README.md +54 -6
- package/package.json +13 -11
- package/src/colors.js +17 -0
- package/src/commands/lighthouse.js +14 -1
- package/src/commands/screenshot.js +1 -1
- package/src/help.js +1 -1
- package/src/spinner.js +1 -1
package/README.md
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<br>
|
|
3
2
|
<img style="width: 500px; margin:3rem 0 1.5rem;" src="https://github.com/microlinkhq/browserless/raw/master/static/logo-banner.png#gh-light-mode-only" alt="browserless">
|
|
4
3
|
<img style="width: 500px; margin:3rem 0 1.5rem;" src="https://github.com/microlinkhq/browserless/raw/master/static/logo-banner-light.png#gh-dark-mode-only" alt="browserless">
|
|
5
|
-
<br>
|
|
6
|
-
<
|
|
7
|
-
<
|
|
8
|
-
<
|
|
9
|
-
<
|
|
4
|
+
<br><br>
|
|
5
|
+
<a href="https://microlink.io"><img src="https://img.shields.io/badge/powered_by-microlink.io-blue?style=flat-square&color=%23EA407B" alt="Powered by microlink.io"></a>
|
|
6
|
+
<img src="https://img.shields.io/github/tag/microlinkhq/browserless.svg?style=flat-square" alt="Last version">
|
|
7
|
+
<a href="https://coveralls.io/github/microlinkhq/browserless"><img src="https://img.shields.io/coveralls/microlinkhq/browserless.svg?style=flat-square" alt="Coverage Status"></a>
|
|
8
|
+
<a href="https://www.npmjs.org/package/browserless"><img src="https://img.shields.io/npm/dm/browserless.svg?style=flat-square" alt="NPM Status"></a>
|
|
9
|
+
<br><br>
|
|
10
10
|
</div>
|
|
11
11
|
|
|
12
|
+
> @browserless/cli: CLI to interact with Browserless capabilities.
|
|
13
|
+
|
|
14
|
+
See [CLI section](https://browserless.js.org/#/?id=cli) our website for more information.
|
|
15
|
+
|
|
12
16
|
## Install
|
|
13
17
|
|
|
14
18
|
Using npm:
|
|
@@ -17,6 +21,50 @@ Using npm:
|
|
|
17
21
|
npm install @browserless/cli -g
|
|
18
22
|
```
|
|
19
23
|
|
|
24
|
+
## About
|
|
25
|
+
|
|
26
|
+
This package provides a **command-line interface** for interacting with browserless capabilities directly from your terminal. It exposes the `browserless` binary that wraps the core browserless API into easy-to-use shell commands.
|
|
27
|
+
|
|
28
|
+
### What this package does
|
|
29
|
+
|
|
30
|
+
The `@browserless/cli` package allows you to:
|
|
31
|
+
|
|
32
|
+
- **Take screenshots** from URLs with gradient backgrounds, browser overlays, and device emulation
|
|
33
|
+
- **Generate PDFs** from web pages
|
|
34
|
+
- **Extract content** as HTML or plain text
|
|
35
|
+
- **Run Lighthouse audits** for performance analysis
|
|
36
|
+
- **Analyze page weight** (network requests, transfer size, resource size)
|
|
37
|
+
- **Check URL status** and response information (redirects, headers, status codes)
|
|
38
|
+
|
|
39
|
+
### Available commands
|
|
40
|
+
|
|
41
|
+
| Command | Description |
|
|
42
|
+
|---------|-------------|
|
|
43
|
+
| `screenshot <url>` | Capture a screenshot with optional overlay and background |
|
|
44
|
+
| `pdf <url>` | Generate a PDF document from a web page |
|
|
45
|
+
| `html <url>` | Serialize the page content to HTML |
|
|
46
|
+
| `text <url>` | Extract plain text content from the page |
|
|
47
|
+
| `lighthouse <url>` | Run a Google Lighthouse audit and output JSON report |
|
|
48
|
+
| `page-weight <url>` | Analyze network requests and resource sizes |
|
|
49
|
+
| `ping <url>` | Get response info: status code, redirects, headers |
|
|
50
|
+
| `status <url>` | Get the HTTP status code |
|
|
51
|
+
| `goto <url>` | Navigate to a URL and return page/response info |
|
|
52
|
+
|
|
53
|
+
> **Note:** The `lighthouse` command requires an extra installation.
|
|
54
|
+
>
|
|
55
|
+
> Please make sure to install the standalone package by running:<br>
|
|
56
|
+
> <kbd>npm install -g @browserless/lighthouse</kbd>
|
|
57
|
+
|
|
58
|
+
### How it fits in the monorepo
|
|
59
|
+
This package depends on:
|
|
60
|
+
|
|
61
|
+
| Dependency | Purpose |
|
|
62
|
+
|---------------------------|---------------------------------------------------------|
|
|
63
|
+
| browserless | Core API for all browser automation operations |
|
|
64
|
+
| @browserless/lighthouse | Lighthouse audit integration (used by lighthouse command) |
|
|
65
|
+
|
|
66
|
+
The CLI acts as a thin wrapper that parses command-line arguments, initializes a browserless instance, and delegates to the appropriate command handler.
|
|
67
|
+
|
|
20
68
|
## License
|
|
21
69
|
|
|
22
70
|
**@browserless/cli** © [Microlink](https://microlink.io), released under the [MIT](https://github.com/microlinkhq/browserless/blob/master/LICENSE.md) License.<br>
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@browserless/cli",
|
|
3
|
-
"description": "
|
|
3
|
+
"description": "Command-line interface for headless browser automation. Take screenshots, generate PDFs, and extract content from websites.",
|
|
4
4
|
"homepage": "https://browserless.js.org",
|
|
5
|
-
"version": "10.
|
|
5
|
+
"version": "10.10.0",
|
|
6
6
|
"bin": {
|
|
7
7
|
"browserless": "src/index.js"
|
|
8
8
|
},
|
|
@@ -20,25 +20,27 @@
|
|
|
20
20
|
"url": "https://github.com/microlinkhq/browserless/issues"
|
|
21
21
|
},
|
|
22
22
|
"keywords": [
|
|
23
|
-
"browser",
|
|
24
23
|
"browserless",
|
|
25
|
-
"chrome",
|
|
26
|
-
"chromeless",
|
|
27
24
|
"cli",
|
|
28
|
-
"
|
|
29
|
-
"examples",
|
|
25
|
+
"command-line",
|
|
30
26
|
"headless",
|
|
31
|
-
"
|
|
27
|
+
"chrome",
|
|
28
|
+
"puppeteer",
|
|
29
|
+
"screenshot",
|
|
30
|
+
"pdf",
|
|
31
|
+
"automation",
|
|
32
|
+
"web-scraping",
|
|
33
|
+
"terminal",
|
|
34
|
+
"tool"
|
|
32
35
|
],
|
|
33
36
|
"dependencies": {
|
|
34
37
|
"beauty-error": "~1.2.21",
|
|
35
|
-
"browserless": "^10.
|
|
38
|
+
"browserless": "^10.10.0",
|
|
36
39
|
"dark-mode": "~3.0.0",
|
|
37
40
|
"dset": "~3.1.4",
|
|
38
41
|
"mri": "~1.2.0",
|
|
39
42
|
"nanospinner": "~1.2.2",
|
|
40
43
|
"nestie": "~1.0.3",
|
|
41
|
-
"picocolors": "~1.1.1",
|
|
42
44
|
"pretty-bytes": "~5.6.0",
|
|
43
45
|
"process-stats": "~3.7.16",
|
|
44
46
|
"restore-cursor": "~3.1.0",
|
|
@@ -57,5 +59,5 @@
|
|
|
57
59
|
"test": "exit 0"
|
|
58
60
|
},
|
|
59
61
|
"license": "MIT",
|
|
60
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "9b80e677418f2defb804d39043680fe65e3e277b"
|
|
61
63
|
}
|
package/src/colors.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { styleText } = require('node:util')
|
|
4
|
+
|
|
5
|
+
const gray = str => styleText('gray', str)
|
|
6
|
+
|
|
7
|
+
const white = str => styleText('white', str)
|
|
8
|
+
|
|
9
|
+
const green = str => styleText('green', str)
|
|
10
|
+
|
|
11
|
+
const red = str => styleText('red', str)
|
|
12
|
+
|
|
13
|
+
const yellow = str => styleText('yellow', str)
|
|
14
|
+
|
|
15
|
+
const label = (text, color) => styleText(['inverse', 'bold', color], ` ${text.toUpperCase()} `)
|
|
16
|
+
|
|
17
|
+
module.exports = { gray, white, green, red, yellow, label }
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const { existsSync } = require('fs')
|
|
4
|
+
const { resolve } = require('path')
|
|
5
|
+
|
|
6
|
+
const lighthousePath = resolve(__dirname, '../../../lighthouse/src')
|
|
7
|
+
|
|
8
|
+
let createLighthouse
|
|
9
|
+
|
|
10
|
+
if (existsSync(lighthousePath)) {
|
|
11
|
+
createLighthouse = require(lighthousePath)
|
|
12
|
+
} else {
|
|
13
|
+
console.error('The @browserless/lighthouse package is not installed.')
|
|
14
|
+
console.error('Please install it by running: npm install -g @browserless/lighthouse')
|
|
15
|
+
process.exit(1)
|
|
16
|
+
}
|
|
4
17
|
|
|
5
18
|
module.exports = async ({ url, browserless, opts }) => {
|
|
6
19
|
const lighthouse = createLighthouse(async teardown => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const uniqueRandomArray = require('unique-random-array')
|
|
4
|
-
const { gray, yellow } = require('
|
|
4
|
+
const { gray, yellow } = require('../colors')
|
|
5
5
|
const darkMode = require('dark-mode')
|
|
6
6
|
const termImg = require('term-img')
|
|
7
7
|
const { dset } = require('dset')
|
package/src/help.js
CHANGED
package/src/spinner.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const createProcStats = require('process-stats')
|
|
4
4
|
const { createSpinner } = require('nanospinner')
|
|
5
5
|
const prettyBytes = require('pretty-bytes')
|
|
6
|
-
const { gray } = require('
|
|
6
|
+
const { gray } = require('./colors')
|
|
7
7
|
|
|
8
8
|
const TICK_INTERVAL = 50
|
|
9
9
|
const procStats = createProcStats({ tick: TICK_INTERVAL })
|