New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mercury-bot

Package Overview
Dependencies
Maintainers
5
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mercury-bot

Mercury is a bot for managing in-code static translations

3.3.0
latest
Source
npm
Version published
Weekly downloads
0
-100%
Maintainers
5
Weekly downloads
 
Created
Source


Mercury

Mercury is a bot for handling in-code static translations. Developed at OpenTable, it takes care of dozens of codebases by making automated Pull Requests to keep the code up to date with our translations.

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 by using its API and making Pull Requests. Please refer to the Mercury consumer integration runbook and FAQ.

Mercury screenshot

How to setup the bot in your organization

Mercury is available as npm module and needs to be configured to run with github and smartling API tokens.

Here is a code example:

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:

nametypemandatorydescription
githubobjectyesGithub config
github.apiTokensobjectyesGithub API Tokens. You need at least one read token and one write token
github.apiTokens[index].operationstringyesCan be either read or write
github.apiTokens[index].valuestringyesThe token
github.ownerstringyesThe github user associated with the token
github.branchstringyesThe branch that the bot will use to make Pull Requests on his fork
repositoriesobjectyesThe repositories mercury needs to watch and manage
repositories[index]array of stringsyesThe github org that contains the repos to watch
repositories[index][item]stringyesThe github repo to watch
smartlingobjectyesThe smartling config
smartling.userIdentifierstringyesThe smartling UserId
smartling.userSecretstringyesThe smartling UserSecret
bucketsCountnumbernoBuckets 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:

namepayload object propsdescription
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

Keywords

translation

FAQs

Package last updated on 02 Dec 2022

Did you know?

Socket

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