r2bot

infrastructure as code in pure javascript

Usage no npm install needed!

<script type="module">
  import r2bot from 'https://cdn.skypack.dev/r2bot';
</script>

README

r2bot(r2-d2)

Infrastructure as code in pure javascript.

Warning

This project is still in its very early stage.

Installation

To install the package, run this inside your project's folder.

$ npm i -D r2bot

Usage

import { ssh } from "r2bot";

// setup ssh connection
const r2 = await ssh("<host name or ip>", "<user name>", "<password>");

// run commands
const { code, message } = await r2.exec("uptime");
console.log(`code: ${code}, message: ${message}`);

// run commands when root permission is needed, i.e. sudo apt update
// please make sure the user must have sudo permission
await r2.sudoExec("apt update");

// close the connection
r2.close();