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): make the scan command npx compatible #92

Merged
merged 3 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ npm i

### Running a local scan

To run a scan on a host, a command line script `scan` is available. It returns the a JSON of the form described below. For example, to scan `mdn.dev`:
To run a scan on a host, a command line script is available. It returns the a JSON of the form described below. For example, to scan `mdn.dev`:

```sh
./scan mdn.dev
npx mdn-http-observatory-scan mdn.dev

{
"scan": {
Expand All @@ -47,9 +47,10 @@ To run a scan on a host, a command line script `scan` is available. It returns t
...
}
}

```

To install the CLI script globally on your machine, run `npm install -g .` from the project root. `mdn-http-observatory-scan` is then available in your shell.

### Running a local API server

This needs a [postgres](https://www.postgresql.org/) database for the API to use as a persistence layer. All scans and results initiated via the API are stored in the database.
Expand Down
18 changes: 9 additions & 9 deletions src/cli/index.js → bin/scan.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/usr/bin/env node

import { Command } from "commander";
import { scan } from "../scanner/index.js";
const program = new Command();
import { scan } from "../src/scanner/index.js";

program
.name("observatory")
.description("CLI for the MDN HTTP Observatory")
.version("1.0.0");
const name = "mdn-http-observatory-scan";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps const NAME = as it's a constant?

const program = new Command();

program
.command("scan")
.description("Scan a host")
.argument("<string>", "hostname to scan")
.name(name)
.description("CLI for the MDN HTTP Observatory scan functionality")
.version("1.0.0")
.argument("<hostname>", "hostname to scan")
.action(async (hostname, _options) => {
try {
const result = await scan(hostname);
Expand Down
Loading
Loading