Skip to content

Commit

Permalink
feat(cli): add --disallow-urls option (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed May 10, 2023
1 parent affcc89 commit 58f141f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
41 changes: 21 additions & 20 deletions docs/content/2.integrations/0.cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,27 @@ See the [Configuration](#configuration) section for more details and the guides.

### CLI Options

| Options | |
|------------------------|-------------------------------------------------------------------------------------------------------------------------------------|
| `-v, --version` | Display version number. |
| `--site <url>` | Host URL to scan. |
| `--root <path>` | Define the project root. |
| `--config-file <path>` | Path to config file. |
| `--output-path <path>` | Path to save the contents of the client and reports to. |
| `--cache` | Enable the caching. |
| `--no-cache` | Disable the caching. |
| `--desktop` | Simulate device as desktop. |
| `--mobile` | Simulate device as mobile. |
| `--throttle` | Enable the throttling. |
| `--samples` | Specify the amount of samples to run. |
| `--urls` | Specify explicit relative URLs as a comma-seperated list.<br>e.g. `unlighthouse --site unlighthouse.dev --urls /guide,/api,/config` |
| `--enable-javascript` | When inspecting the HTML wait for the javascript to execute. Useful for SPAs. |
| `--disable-javascript` | When inspecting the HTML, don't wait for the javascript to execute. |
| `--enable-i18n-pages` | Enable scanning pages which use x-default. |
| `--disable-i18n-pages` | Disable scanning pages which use x-default. |
| `-d, --debug` | Debug. Enable debugging in the logger. |
| `-h, --help` | Display available CLI options |
| Options | |
|------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `-v, --version` | Display version number. |
| `--site <url>` | Host URL to scan. |
| `--root <path>` | Define the project root. |
| `--config-file <path>` | Path to config file. |
| `--output-path <path>` | Path to save the contents of the client and reports to. |
| `--cache` | Enable the caching. |
| `--no-cache` | Disable the caching. |
| `--desktop` | Simulate device as desktop. |
| `--mobile` | Simulate device as mobile. |
| `--throttle` | Enable the throttling. |
| `--samples` | Specify the amount of samples to run. |
| `--urls` | Specify explicit relative paths as a comma-seperated list.<br>e.g. `unlighthouse --site unlighthouse.dev --urls /guide,/api,/config` |
| `--disallow-urls` | Specify explicit relative paths (string or regex) to disallow as a comma-seperated list. <br>e.g. `unlighthouse --site unlighthouse.dev --exclude-urls /guide/.*,/api/.*` |
| `--enable-javascript` | When inspecting the HTML wait for the javascript to execute. Useful for SPAs. |
| `--disable-javascript` | When inspecting the HTML, don't wait for the javascript to execute. |
| `--enable-i18n-pages` | Enable scanning pages which use x-default. |
| `--disable-i18n-pages` | Disable scanning pages which use x-default. |
| `-d, --debug` | Debug. Enable debugging in the logger. |
| `-h, --help` | Display available CLI options |


### Config File
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/createCli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default function createCli() {
cli.option('--enable-i18n-pages', 'Enable scanning pages which use x-default.')
cli.option('--disable-i18n-pages', 'Disable scanning pages which use x-default.')
cli.option('--urls <urls>', 'Specify explicit relative URLs as a comma-seperated list.')
cli.option('--disallow-urls <urls>', 'Specify explicit relative URLs to disallow as a comma-seperated list.')
cli.option('--disable-robots-txt', 'Disables the robots.txt crawling.')
cli.option('--disable-sitemap', 'Disables the sitemap.xml crawling.')
cli.option('-d, --debug', 'Debug. Enable debugging in the logger.')
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export interface CliOptions {
host?: string
help?: boolean
urls?: string
disallowUrls?: string
site?: string
throttle?: boolean
desktop?: boolean
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ export function pickOptions(options: CiOptions | CliOptions): UserConfig {
if (options.urls)
picked.urls = options.urls.split(',')

if (options.disallowUrls)
picked.scanner.exclude = options.disallowUrls.split(',')

const config = pick(options, [
// root level options
'samples',
Expand Down

0 comments on commit 58f141f

Please sign in to comment.