Comparing version 0.2.1 to 0.2.2
@@ -11,2 +11,2 @@ export * from "./HostHop.js"; | ||
export default SshHost; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsY0FBYyxjQUFjLENBQUE7QUFDNUIsY0FBYyxhQUFhLENBQUE7QUFDM0IsY0FBYyxjQUFjLENBQUE7QUFDNUIsY0FBYyxjQUFjLENBQUE7QUFDNUIsY0FBYyxxQkFBcUIsQ0FBQTtBQUNuQyxjQUFjLHlCQUF5QixDQUFBO0FBQ3ZDLGNBQWMsb0NBQW9DLENBQUE7QUFFbEQsY0FBYyxpQkFBaUIsQ0FBQTtBQUUvQixPQUFPLEVBQUUsT0FBTyxFQUFFLE1BQU0sY0FBYyxDQUFBO0FBRXRDLGVBQWUsT0FBTyxDQUFBIiwic291cmNlc0NvbnRlbnQiOlsiXG5leHBvcnQgKiBmcm9tIFwiLi9Ib3N0SG9wLmpzXCJcbmV4cG9ydCAqIGZyb20gXCIuL0hvc3RJZC5qc1wiXG5leHBvcnQgKiBmcm9tIFwiLi9Tc2hFeGVjLmpzXCJcbmV4cG9ydCAqIGZyb20gXCIuL1NzaEhvc3QuanNcIlxuZXhwb3J0ICogZnJvbSBcIi4vU3NoSG9zdE9wdGlvbnMuanNcIlxuZXhwb3J0ICogZnJvbSBcIi4vYXBtL1BhY2thZ2VNYW5hZ2VyLmpzXCJcbmV4cG9ydCAqIGZyb20gXCIuL2Vzc2VudGlhbHMvU2Z0cFByb21pc2VXcmFwcGVyLmpzXCJcblxuZXhwb3J0ICogZnJvbSBcIi4vdXRpbHMvYmFzZS5qc1wiXG5cbmltcG9ydCB7IFNzaEhvc3QgfSBmcm9tIFwiLi9Tc2hIb3N0LmpzXCJcblxuZXhwb3J0IGRlZmF1bHQgU3No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version": "0.2.2", | ||
"description": "HiveSsh simplifies SSH2 connections via promise-based task execution on Linux servers with built-in server utilities and powerful command execution functions", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -23,2 +23,4 @@ # HiveSsh | ||
- [Promisified](#promisified) | ||
- [Execute and assets](#execute-and-assets) | ||
- [Sftp](#sftp) | ||
- [AbstractPackageManager](#abstractpackagemanager) | ||
@@ -77,14 +79,56 @@ - [Technologies](#technologies) | ||
## Promisified | ||
After connecting an `SshHost`, you can leverage the promised execution (and other asset features) directly on the `SshHost` instance. | ||
### Execute and assets | ||
After connecting an `SshHost`, you can use the promisified execution (and other asset features) directly on the `SshHost` instance. | ||
```ts | ||
// check files in user home dir | ||
const result = await myHost.exec("ls -al") | ||
console.log("Result: ", result.out) | ||
const homeDirFiles = await myHost.exec("ls -al") | ||
console.log("Home dir files:\n", homeDirFiles.out) | ||
``` | ||
// check if a command exists | ||
Get the hosts public ip address: | ||
```ts | ||
// check if curl command exists | ||
const curlExists = await myHost.exists("curl ifconfig.me") | ||
if(!curlExists){ | ||
myHost.close() | ||
throw new Error("Curl is not installed on: " + myHost.settings.id) | ||
} | ||
const myIp = await myHost.exec("curl ifconfig.me") | ||
console.log("Host public ip: " + myIp.out) | ||
//other sources: `api.ipify.org`, `ipinfo.io/ip` or `ipecho.net/plain` | ||
``` | ||
You can also execute commands on absolut path: | ||
```ts | ||
const homeDirFiles = await myHost.exec( | ||
"ls -al", | ||
{ pwd: "/etc" } | ||
) | ||
console.log("Etc files: ", homeDirFiles.out) | ||
``` | ||
Also a git example: | ||
```ts | ||
// check if git command exists | ||
const gitExist = await myHost.exists("git") | ||
console.log("Git exists: ", gitExist) | ||
if(!curlExists){ | ||
myHost.close() | ||
throw new Error("Git is not installed on: " + myHost.settings.id) | ||
} | ||
// get git status | ||
const gitStatus = await myHost.exec( | ||
"git status", | ||
{ | ||
pwd: "/home/tester/myrepo" | ||
} | ||
) | ||
console.log("Git status:\n", gitStatus.out) | ||
``` | ||
You can also use the promised SFTP features via `SshHost.sftp`. | ||
### Sftp | ||
You can also use the promisified SFTP features via `SshHost.sftp`. | ||
```ts | ||
@@ -97,3 +141,3 @@ const myBinary: Buffer = await myHost.sftp.readFile("/home/tester/my-binary") | ||
## AbstractPackageManager | ||
With the abstract package manager (`apm`) you can use apt, dnf, yum or a custom implemented package manager via one interface. | ||
With the abstract package manager (`apm`) you can use `apt`, `dnf`, `yum` or a `custom implemented package manager` via one interface. | ||
The apm features are limited and general, but you can update your system and install, delete and list your packages. | ||
@@ -100,0 +144,0 @@ |
284410
168