Skip to content

Commit 67042a6

Browse files
authored
feat: add obey robots flag (#6)
* feat: add obey robots flag * chore: upgrade tooling packages * docs(changeset): *Features* - (#5) Add obey_robots option *Misc* - Upgrade tooling packages * RELEASING: Releasing 1 package(s) Releases: @lightpanda/browser@1.1.0 [skip ci]
1 parent 1999828 commit 67042a6

6 files changed

Lines changed: 298 additions & 313 deletions

File tree

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
"publish-packages": "turbo run build lint && changeset version && changeset publish"
2525
},
2626
"devDependencies": {
27-
"@changesets/changelog-github": "^0.5.1",
28-
"@changesets/cli": "^2.29.5",
29-
"turbo": "^2.5.4"
27+
"@changesets/changelog-github": "^0.5.2",
28+
"@changesets/cli": "^2.29.8",
29+
"turbo": "^2.8.5"
3030
},
3131
"engines": {
3232
"node": "22.16",

packages/browser/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# @lightpanda/browser
22

3+
## 1.1.0
4+
5+
### Minor Changes
6+
7+
- [#6](https://github.com/lightpanda-io/node-packages/pull/6) [`f64ce54`](https://github.com/lightpanda-io/node-packages/commit/f64ce54c8bbc4b7dd11d02c727f19281af705d1c) Thanks [@nrigaudiere](https://github.com/nrigaudiere)! - _Features_
8+
9+
- (#5) Add obey_robots option
10+
11+
_Misc_
12+
13+
- Upgrade tooling packages
14+
315
## 1.0.1
416

517
### Patch Changes

packages/browser/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lightpanda/browser",
3-
"version": "1.0.1",
3+
"version": "1.1.0",
44
"description": "Lightpanda for Node.js",
55
"main": "./dist/index.js",
66
"module": "./dist/index.mjs",
@@ -38,10 +38,10 @@
3838
"devDependencies": {
3939
"@biomejs/biome": "^1.9.4",
4040
"@types/node": "22.15.32",
41-
"@types/yargs": "^17.0.33",
42-
"terser": "^5.43.1",
43-
"tsup": "^8.5.0",
44-
"typescript": "^5.8.3"
41+
"@types/yargs": "^17.0.35",
42+
"terser": "^5.46.0",
43+
"tsup": "^8.5.1",
44+
"typescript": "^5.9.3"
4545
},
4646
"dependencies": {
4747
"yargs": "^18.0.0"

packages/browser/src/fetch.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ import { getExecutablePath, validateUrl } from './utils'
2121
* @type {object}
2222
* @property {boolean} dump - Export fetched output as string
2323
* @property {boolean} disableHostVerification - Disables host verification on all HTTP requests
24+
* @property {boolean} obeyRobots - Fetches and obeys the robots.txt (if available) of the web pages we make requests towards.
2425
* @property {string} httpProxy - The HTTP proxy to use for all HTTP requests
2526
*/
2627
export type LightpandaFetchOptions = {
2728
dump?: boolean
2829
disableHostVerification?: boolean
30+
obeyRobots?: boolean
2931
httpProxy?: string
3032
}
3133

@@ -40,7 +42,7 @@ const defaultOptions: LightpandaFetchOptions = {
4042
* @returns {Promise<Buffer | string>}
4143
*/
4244
export const fetch = (url: string, options: LightpandaFetchOptions = defaultOptions) => {
43-
const { dump, disableHostVerification, httpProxy } = options
45+
const { dump, disableHostVerification, obeyRobots, httpProxy } = options
4446
validateUrl(url)
4547

4648
if (httpProxy) {
@@ -53,6 +55,7 @@ export const fetch = (url: string, options: LightpandaFetchOptions = defaultOpti
5355
const flags = [
5456
{ flag: '--dump', condition: dump },
5557
{ flag: '--insecure_disable_tls_host_verification', condition: disableHostVerification },
58+
{ flag: '--obey_robots', condition: obeyRobots },
5659
{ flag: `--http_proxy ${httpProxy}`, condition: httpProxy },
5760
]
5861
.map(f => (f.condition ? f.flag : ''))

packages/browser/src/serve.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ import { getExecutablePath, validatePort, validateUrl } from './utils'
2323
* @property {string} port - Port of the CDP server
2424
* @property {number} timeout - Inactivity timeout in seconds before disconnecting clients
2525
* @property {boolean} disableHostVerification - Disables host verification on all HTTP requests
26+
* @property {boolean} obeyRobots - Fetches and obeys the robots.txt (if available) of the web pages we make requests towards.
2627
* @property {string} httpProxy - The HTTP proxy to use for all HTTP requests
2728
*/
2829
export type LightpandaServeOptions = {
2930
host?: string
3031
port?: number
3132
timeout?: number
3233
disableHostVerification?: boolean
34+
obeyRobots?: boolean
3335
httpProxy?: string
3436
}
3537

@@ -44,7 +46,7 @@ const defaultOptions: LightpandaServeOptions = {
4446
* @returns {Promise<ChildProcessWithoutNullStreams>}
4547
*/
4648
export const serve = (options: LightpandaServeOptions = defaultOptions) => {
47-
const { host, port, timeout, disableHostVerification, httpProxy } = options
49+
const { host, port, timeout, disableHostVerification, obeyRobots, httpProxy } = options
4850

4951
if (port) {
5052
validatePort(port)
@@ -64,6 +66,11 @@ export const serve = (options: LightpandaServeOptions = defaultOptions) => {
6466
value: disableHostVerification,
6567
flagOnly: true,
6668
},
69+
{
70+
flag: '--obey_robots',
71+
value: obeyRobots,
72+
flagOnly: true,
73+
},
6774
{ flag: '--http_proxy', value: httpProxy },
6875
]
6976
.flatMap(f => (f.value ? [f.flag, !f.flagOnly ? f.value.toString() : ''] : ''))

0 commit comments

Comments
 (0)