Skip to content

Commit

Permalink
fix(cli): make the scan command npx compatible (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
argl authored Sep 16, 2024
1 parent db5dbd5 commit 6d66d0e
Show file tree
Hide file tree
Showing 4 changed files with 552 additions and 531 deletions.
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";
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

0 comments on commit 6d66d0e

Please sign in to comment.