# searchbox-cli

> A backend-less website search built on top of lunr.js

Latest version **0.1.1** (published 2022-05-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install searchbox-cli
pnpm add searchbox-cli
yarn add searchbox-cli
bun add searchbox-cli
```

Provides the command `searchbox`.

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2022-05-21 |
| First published | 2022-05-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=14 |
| Dependencies | 11 |
| Unpacked size | 27.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Privian.io; https://about.privian.io/ |
| Maintainers | ovx |
| Keywords | search, searchbox, cli, lunr |

## Links

- npm: https://www.npmjs.com/package/searchbox-cli
- Repository: https://github.com/privian/searchbox-cli
- Issues: https://github.com/privian/searchbox-cli/issues
- npm.io page: https://npm.io/package/searchbox-cli

## Dependencies (11)

- [got](https://npm.io/package/got.md) ^12.0.3
- [glob](https://npm.io/package/glob.md) ^8.0.1
- [sade](https://npm.io/package/sade.md) ^1.8.1
- [fastq](https://npm.io/package/fastq.md) ^1.13.0
- [marked](https://npm.io/package/marked.md) ^4.0.14
- [cheerio](https://npm.io/package/cheerio.md) ^1.0.0-rc.10
- [entities](https://npm.io/package/entities.md) ^4.3.0
- [inquirer](https://npm.io/package/inquirer.md) ^8.2.2
- [just-extend](https://npm.io/package/just-extend.md) ^6.0.1
- [bytes-formatter](https://npm.io/package/bytes-formatter.md) ^21.6.12
- [humanize-duration](https://npm.io/package/humanize-duration.md) ^3.27.1

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2022-05-21
- 0.1.0 — 2022-05-16

## README

<h1 align="center">
  <br>
  <img src="https://raw.githubusercontent.com/privian/searchbox/master/public/searchbox.svg" alt="Searchbox" width="200">
  <br>
  Searchbox CLI
  <br>
</h1>

<h4 align="center">A CLI utility to crawl and index websites for <a href="https://github.com/privian/searchbox">Searchbox</a>.</h4>

<p align="center">
  <a href="https://badge.fury.io/js/searchbox-cli">
    <img src="https://badge.fury.io/js/searchbox-cli.svg"
         alt="npm.js">
  </a>
</p>

<p align="center">
  <a href="#what">What</a> •
  <a href="#features">Features</a> •
  <a href="#install">Install</a> •
  <a href="#usage">Usage</a> •
  <a href="#manifest">Manifest</a> •
  <a href="#related">Related</a> •
  <a href="#sponsors">Sponsors</a> •
  <a href="#license">License</a>
</p>

## Status

Searchbox is currently in Beta.

Your help and contributions are very much appreciated.

## What

This a repo for a CLI utility that helps you build a [Searchbox](https://github.com/privian/searchbox) index from a live website or build files.

## Features

- Filesystem and HTTP support
- HTML and Markdown parsing
- Automatically follows links

## Install

```shell
npm install searchbox-cli
```

## Usage

1. Create a new file `searchbox.manifest.json` (see specification below)
2. Execute `searchbox`:

```shell
searchbox crawl https://example.com
```

Or run `searchbox --help` for options.

## Manifest

Basic manifest example (`searchbox.manifest.json`):

```json
{
	"baseUrl": "https://example.com/",
	"data": "searchbox.index.json",
	"fields": [{
		"name": "id",
		"search": false
	}, {
		"name": "title",
		"suggestions": true
	}, {
		"name": "snippet"
	}, {
		"name": "link",
		"search": false
	}]
}
```

### Manifest specification

```ts
export interface IManifestField {
  /**
   * Boost score (integer, 0..)
  */
  boost?: number;

  /**
   * Field name, see "Supported fields"
  */
  name: string;

  /**
   * Whether this field is searchable
  */
  search?: boolean;

  /**
   * Whether to use this field for suggestions
   */
  suggestions?: boolean;
}

export interface IManifest {
  /**
   * Website's base URL
   */
  baseUrl?: string;

  /**
   * An array of fields in the index
  */
  fields: IManifestField[];

  /**
   * URL or a relative path to the data file (index)
  */
  data: string;

  /**
   * Manifest version (default: v1)
  */
  version?: string;
}
```

### Supported fields

- `id`: unique ID of the item
- `title`: the title
- `snippet`: (optional) the description or a snippet of the item
- `category`: (optional) the category for the item
- `link`: target URL of the item

## Config file

To apply more advanced configuration options, use a custom `searchbox.config.js` file that exports your configuration options:

For example config files, see [examples](/blob/master/examples).

```js
export default {
  manifest: 'searchbox.manifest.json',
  adapter: {
    http: {
      // skip `/legal/**` pages
      checkUrl: (url) => {
        if (url.includes('/legal/')) {
          return null;
        }
        return url;
      },
    },
  },
  parser: {
    html: {
      // parse only H1-H3 as items
      headings: 'h1, h2, h3',
    },
  },
};
```

### Config specification

See [src/types.ts](/blob/maste/src/types.ts) for more details.

## Related

- [Searchbox](https://github.com/privian/searchbox) - UI component for website search

## Sponsors

This project is sponspored by [Privian.io](https://about.privian.io) - privacy-friendly, ad-free web search and analytics.

## License

MIT

---
_Source: https://npm.io/package/searchbox-cli · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
