Socket
Socket
Sign inDemoInstall

@foo-software/binoculars

Package Overview
Dependencies
7
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @foo-software/binoculars

A tool to measure web page SEO friendliness


Version published
Weekly downloads
23
increased by109.09%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

@foo-software/binoculars

Binoculars Logo

A tool to measure web page SEO friendliness. Binoculars extends Google's Lighthouse to provide a more opinionated, SEO specific audit.

  • Choice of programmatic usage or CLI.
  • Run a single audit or multiple audits at once.
  • Upload reports to S3 via simple configuration.
  • Automatically post results as comments in GitHub via commits or pull requests (see options).
  • Automatically post results in Slack (see options).

Meaningful Content

Binoculars extends Lighthouse by adding the following audits in a custom group named "Meaningful Content".

  • Title Length: Title should be between 50 - 70 characters.
  • Description Length: Descriptions should be between 100 - 160 characters.
  • Keywords: Keyword phrases of at least 2 words should exist in the title, description and at least twice in the content of the page.
  • Headings: Has at least 1 <h1> tag and 1 <h2> tag.
  • Meaningful Text: Has sufficient textual content (300 characters).
  • Meaningful Tag Structure: Has at least 2 different informational HTML tags of the following types: <p>, <li>, <img>, <table>.

Metrics

Binoculars accounts for metrics from Lighthouse SEO and accessibility categories and weights them accordingly. It combines metrics from these categories with the "Meaningful Content" group detailed above. See the complete list of audits and weighting here.

Usage

Use programmatically or via CLI.

npm i @foo-software/binoculars

or

yarn @foo-software/binoculars

Programmatic Usage

const path = require('path');
const binoculars = require('@foo-software/binoculars').default;

(async () => {
  const results = await binoculars({
    url: 'https://www.foo.software',
 
    // example if you have an "artifacts" directory in your root directory
    outputDirectory: path.resolve('./artifacts'),
 
    // any other options go here
  });
 
  console.log('local report', results[0].localReport);
  // local report ./reports/report-1602194942162.html

  console.log('score', results[0].result.categories.binocularsSeo.score);
  // score 0.96
})();

CLI Usage

Arguments are represented in the options section. Any array type relies on the pipe symbol as shown with urls in the second example below.

binoculars --url https://www.foo.software --outputDirectory ./artifacts

Use a | when auditing multiple URLs like so:

binoculars --urls "https://www.foo.software|https://www.foo.software/register"

Options

NameDescriptionTypeDefaultRequired
authorFor Slack notifications: A user handle, typically from GitHub.stringundefinedno
awsAccessKeyIdThe AWS accessKeyId for an S3 bucket.stringundefinedno
awsBucketThe AWS Bucket for an S3 bucket.stringundefinedno
awsRegionThe AWS region for an S3 bucket.stringundefinedno
awsSecretAccessKeyThe AWS secretAccessKey for an S3 bucket.stringundefinedno
branchFor Slack notifications: A version control branch, typically from GitHub.stringundefinedno
commentAccessTokenAccess token of a user to post PR comments.stringundefinedno
commentUrlAn endpoint to post comments to. Typically this will be from GitHub's API. Example: https://api.github.com/repos/:owner/:repo/pulls/:pull_number/reviewsstringundefinedno
enableCommentsIf true and commentAccessToken is set along with commentUrl, scores will be posted as comments.booleantrueno
finalScreenshotAwsBucketThe AWS Bucket for an S3 bucket. If this is defined, the final screenshot will be uploaded herestringundefinedno
minScoreThe required minimum score. If score is lower an error will throw.numberundefinedno
outputDirectoryAn absolute directory path to output report. You can do this an an alternative or combined with an S3 upload.stringundefinedno
prFor Slack notifications: A version control pull request URL, typically from GitHub.stringundefinedno
slackWebhookUrlA Slack Incoming Webhook URL to send notifications to.stringundefinedno
shaFor Slack notifications: A version control sha, typically from GitHub.stringundefinedno
urlA URL to run Binoculars against.stringundefinedyes
urlsAn array of URLs. In the CLI this value should be a pipe separated list (|).string[]undefinedyes

Return Payload

binoculars is a promise that resolves an array. The reason it resolves with an array is because options allow url or urls. Because a consistent return is ideal, we return an array regardless if there is only one result or more. Each array item is an object with the below payload.

NameDescriptionType
finalScreenshotA URL to the final screenshot image. This will only be defined if finalScreenshotAwsBucket parameter was.string
localReportA local path to the report (if applicable).string
resultA comprehensive result - the equivalent of what is returned when using the lighthouse module directly.object
reportA URL to the report HTML file.string

Environment Variables

You can optionally provide environment variables as detailed below.

NameDescriptionTypeDefault
BINOCULARS_CHROME_PORTThe port for Chrome to run audits on.number4000
BINOCULARS_INTEGRATION_SERVER_DOMAINDomain of the integration server.stringlocalhost
BINOCULARS_INTEGRATION_SERVER_PORTPort to run the integration server on.number3000
BINOCULARS_INTEGRATION_SERVER_PROTOCOLProtocol of the integration server.stringhttp
LOG_LEVELThe Winston log level (use "off" to run without logging).stringinfo

Credits

This package was brought to you by Foo - a website quality monitoring tool. Automatically test and monitor website performance, SEO and accessibility with Lighthouse. Analyze historical records of Lighthouse tests with automated monitoring. Report with confidence about SEO and performance improvements to stay on top of changes when they happen!

Keywords

FAQs

Last updated on 28 Dec 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc