Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): add --sitemaps option #116

Merged
merged 3 commits into from
May 22, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: use --sitemaps option
harlan-zw committed May 22, 2023

Verified

This commit was signed with the committer’s verified signature.
chenrui333 Rui Chen
commit 192b10d67947a85c1a0ba484b0611800a1bd8920
1 change: 1 addition & 0 deletions docs/content/2.integrations/0.cli.md
Original file line number Diff line number Diff line change
@@ -51,6 +51,7 @@ See the [Configuration](#configuration) section for more details and the guides.
| `--mobile` | Simulate device as mobile. |
| `--throttle` | Enable the throttling. |
| `--samples` | Specify the amount of samples to run. |
| `--sitemaps` | Comma seperated list of sitemaps to use for scanning. |
| `--urls` | Specify explicit relative paths as a comma-seperated list.<br>e.g. `unlighthouse --site unlighthouse.dev --urls /guide,/api,/config` |
| `--exclude-urls` | Specify relative paths (string or regex) to exclude from scanning as a comma-seperated list. <br>e.g. `unlighthouse --site unlighthouse.dev --exclude-urls /guide/.*,/api/.*` |
| `--include-urls` | Specify relative paths (string or regex) to include as a comma-seperated list. <br>e.g. `unlighthouse --site unlighthouse.dev --include-urls /guide/.*` |
2 changes: 1 addition & 1 deletion packages/cli/src/createCli.ts
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ export default function createCli() {

cli.option('--site <site>', 'Host URL to scan.')
cli.option('--router-prefix <site>', 'The URL path prefix for the client and API to run from.')
cli.option('--sitemap-path <sitemap-path>', 'Sitemap path to use for scanning.')
cli.option('--sitemaps <sitemaps>', 'Comma seperated list of sitemaps to use for scanning.')
cli.option('--samples <samples>', 'Specify the amount of samples to run.')
cli.option('--throttle', 'Enable the throttling')
cli.option('--enable-javascript', 'When inspecting the HTML wait for the javascript to execute. Useful for SPAs.')
2 changes: 1 addition & 1 deletion packages/cli/src/types.ts
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ export interface CliOptions {
disableRobotsTxt?: boolean
disableSitemap?: boolean
disableDynamicSampling?: boolean
sitemapPath?: string
sitemaps?: string
}

export interface CiOptions extends CliOptions {
10 changes: 7 additions & 3 deletions packages/cli/src/util.ts
Original file line number Diff line number Diff line change
@@ -61,12 +61,16 @@ export function pickOptions(options: CiOptions | CliOptions): UserConfig {
if (options.throttle)
picked.scanner.throttle = true

if (options.sitemaps) {
picked.scanner.sitemap = picked.scanner.sitemap || []
options.sitemaps.split(',').forEach((path) => {
Array.isArray(picked.scanner.sitemap) && picked.scanner.sitemap.push(path)
})
}

if (options.enableJavascript)
picked.scanner.skipJavascript = false

if (options.sitemapPath)
picked.scanner.sitemapPath = options.sitemapPath

else if (options.disableJavascript)
picked.scanner.skipJavascript = true

6 changes: 0 additions & 6 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
@@ -426,12 +426,6 @@ export interface ResolvedUserConfig {
* @default true
*/
robotsTxt: boolean
/**
* Path where get the sitemap.
*
* @default undefined
*/
sitemapPath?: string
/**
* Alias to switch the device used for scanning.
* Set to false if you want to manually configure it.