Skip to main content

Plugin

GitDocumentDB extends its functions with Plugin System. A plugin adds a new feature to GitDocumentDB Class or changes the way to sync and merge repositories.

git-documentdb-plugin-remote-nodegit#

This tutorial describes 'git-documentdb-plugin-remote-nodegit' plugin. It is a NodeGit remote engine. It supports SSH keys and PATs for authentication to GitHub.

Install plugin#

npm i git-documentdb-plugin-remote-nodegit

If you get an error while installing the plugin, see the build section.

Load NodeGit remote engine plugin before creating a GitDocumentDB instance.

GitDocumentDB.plugin(require('git-documentdb-plugin-remote-nodegit'));
// The plugin is loaded in the constructor.
const gitDDB = new GitDocumentDB({
dbName: 'db_with_plugin', // Input your db name
});
await gitDDB.open();

Now you can select 'nodegit' engine to connect to a remote repository.

const remoteOptions: RemoteOptions = {
remoteUrl: github_repository, // Your GitHub repository.
connection: {
live: true,
type: 'github',
personalAccessToken: your_github_personal_access_token, // Your PATs.
engine: 'nodegit', // If omitted, the default is 'isomorphic-git'.
},
};
await gitDDB.sync(remoteOptions);

NodeGit plugin also allows SSH authentication type.

const remoteOptionsSSH: RemoteOptions = {
remoteUrl: github_repository, // Your GitHub repository.
connection: {
live: true,
type: 'ssh',
privateKeyPath: '/foo/bar/baz.key', // Your private key.
publicKeyPath: '/foo/bar/baz.pub', // Your public key.
passPhrase: '',
engine: 'nodegit',
},
};
await gitDDB.sync(remoteOptionsSSH);
note