# mercury-bot

> Mercury is a bot for managing in-code static translations

Latest version **3.3.1** (published 2025-04-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install mercury-bot
pnpm add mercury-bot
yarn add mercury-bot
bun add mercury-bot
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.3.1 |
| Published | 2025-04-09 |
| First published | 2018-04-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=12.0.0 |
| Dependencies | 14 |
| Unpacked size | 55.7 KB |
| Known vulnerabilities | 0 (+14 in 5 direct dependencies) |
| Install scripts | no |
| GitHub stars | 20 |
| Author | Federico Maffei |
| Maintainers | arnoldzokas, acolchado, matteofigus, federicomaffei, nickbalestra |
| Keywords | translation, mercury, bot |

## Links

- npm: https://www.npmjs.com/package/mercury-bot
- Repository: https://github.com/opentable/mercury-bot
- Homepage: https://github.com/opentable/mercury-bot#readme
- Issues: https://github.com/opentable/mercury-bot/issues
- npm.io page: https://npm.io/package/mercury-bot

## Dependencies (14)

- [joi](https://npm.io/package/joi.md) 10.6.0
- [utf8](https://npm.io/package/utf8.md) 2.1.2
- [async](https://npm.io/package/async.md) 2.6.3
- [config](https://npm.io/package/config.md) 1.31.0
- [lodash](https://npm.io/package/lodash.md) 4.17.15
- [needle](https://npm.io/package/needle.md) 1.6.0
- [xml-js](https://npm.io/package/xml-js.md) 1.6.11
- [base-64](https://npm.io/package/base-64.md) 0.1.0
- [js-yaml](https://npm.io/package/js-yaml.md) 3.13.1
- [deep-diff](https://npm.io/package/deep-diff.md) 0.3.8
- [micromatch](https://npm.io/package/micromatch.md) 4.0.2
- [parse-glob](https://npm.io/package/parse-glob.md) 3.0.4
- [@octokit/rest](https://npm.io/package/@octokit/rest.md) ^16.43.2
- [string-to-template](https://npm.io/package/string-to-template.md) 1.0.0

## Alternatives

- [messageformat](https://npm.io/package/messageformat.md) — 329.7K weekly downloads
- [@mintlify/scraping](https://npm.io/package/@mintlify/scraping.md) — 294.8K weekly downloads
- [@mintlify/previewing](https://npm.io/package/@mintlify/previewing.md) — 209.5K weekly downloads
- [@mintlify/prebuild](https://npm.io/package/@mintlify/prebuild.md) — 209.5K weekly downloads
- [@mintlify/link-rot](https://npm.io/package/@mintlify/link-rot.md) — 206.3K weekly downloads

## Recent versions

- 3.3.1 (latest) — 2025-04-09
- 3.3.0 — 2022-12-02
- 3.2.0 — 2022-12-01
- 3.1.0 — 2022-05-27
- 3.0.3 — 2020-09-29
- 3.0.2 — 2020-09-29
- 2.0.0 — 2019-09-18
- 1.3.0 — 2019-05-09
- 1.2.0 — 2019-03-21
- 1.1.1 — 2019-02-06
- 1.1.0 — 2019-01-23
- 1.0.0 — 2018-04-06

## README

<div align="center">
    <img width="200" height="200" src="docs/mercury-logo.png">

<br>
<br>
<h1>Mercury</h1>
<p>Mercury is a bot for handling in-code static translations. Developed at <a href="https://www.opentable.com">OpenTable</a>, it takes care of dozens of codebases by making automated Pull Requests to keep the code up to date with our translations.</p>
</div>

***

### How Mercury works

The bot looks for a `mercury.json` manifest file in a repository's root. It then locates the source files and keeps them updated with [Smartling](https://smartling.com/) by using its API and making Pull Requests. Please refer to the [Mercury consumer integration runbook](https://github.com/opentable/mercury-bot/blob/master/docs/integration-runbook.md) and [FAQ](https://github.com/opentable/mercury-bot/blob/master/docs/faq.md).

![Mercury screenshot](docs/screenshot.png)

### How to setup the bot in your organization

Mercury is available as [npm module](https://www.npmjs.com/package/mercury-bot) and needs to be configured to run with github and smartling API tokens.

Here is a code example:

```js
const mercury = require('mercury-bot');

const config = {
  github: {
    apiTokens: [
      { operation: 'read', value: 'token-1234567890' },
      { operation: 'write', value: 'token-0987654321' }
    ],
    owner: 'mercurybot',
    branch: 'mercury'
  },
  smartling: {
    userIdentifier: 'userId-1234567890',
    userSecret: 'userSecret-0987654321'
  },
  repositories: {
    'github-org': ['repo1', 'repo2']
  }
};

const app = mercury({ config });

// Optional event handlers
app.on('error', console.log);
app.on('action', console.log);
app.on('result', console.log);

// Run
app.run(() => process.exit(0));
```

#### API

##### Init mercury({ config })

`config` is an object that requires the following structure:

|name|type|mandatory|description|
|----|----|---------|-----------|
|`github`|`object`|`yes`|Github config|
|`github.apiTokens`|`object`|`yes`|Github API Tokens. You need at least one read token and one write token|
|`github.apiTokens[index].operation`|`string`|`yes`|Can be either `read` or `write`|
|`github.apiTokens[index].value`|`string`|`yes`|The token|
|`github.owner`|`string`|`yes`|The github user associated with the token|
|`github.branch`|`string`|`yes`|The branch that the bot will use to make Pull Requests on his fork|
|`repositories`|`object`|`yes`|The repositories mercury needs to watch and manage|
|`repositories[index]`|`array of strings`|`yes`|The github org that contains the repos to watch|
|`repositories[index][item]`|`string`|`yes`|The github repo to watch|
|`smartling`|`object`|`yes`|The smartling config|
|`smartling.userIdentifier`|`string`|`yes`|The smartling UserId|
|`smartling.userSecret`|`string`|`yes`|The smartling UserSecret|
|`bucketsCount`|`number`|`no`|Buckets count. The current bucket is selected based on the current UTC hour. The value must be between 1 and 24. The default value is 1|

##### mercury.on(eventName, payload)

Event handler for connecting to a logger. The following events are emitted:

|name|payload object props|description|
|----|--------------------|-----------|
|`action`|`{ message}`|The message contains a description of the performed action|
|`error`|`{ error, errorType, details }`|The error is a javascript `Error` object containing the whole stacktrace. The errorType is a string identifier for the error, and the details contains all the state of the performed actions for the current repository for further investigation|
|`result`|`{ message, resultType }`|The message contains a description of the performed action, the resultType is an identifier for the current action|

#### License

MIT

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