Skip to content

Commit

Permalink
Change: readme, workflow and update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
NobleMajo committed May 14, 2024
1 parent 98c254e commit 10c7809
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 66 deletions.
25 changes: 15 additions & 10 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: NPM Publish

on:
Expand All @@ -25,8 +22,12 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build
- run: npm test --if-present
- run: npm run build --if-present
- run: npm run test --if-present
- uses: actions/download-artifact@v4
with:
name: build-artifacts
path: dist

# publish-gpr:
# needs: build
Expand All @@ -40,8 +41,10 @@ jobs:
# with:
# node-version: 20
# registry-url: https://npm.pkg.github.com/
# - run: npm ci
# - run: npm run build
# - uses: actions/download-artifact@v4
# with:
# name: build-artifacts
# path: dist
# - run: npm publish
# env:
# NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
Expand All @@ -50,13 +53,15 @@ jobs:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@
- uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm run build
- uses: actions/download-artifact@v4
with:
name: build-artifacts
path: dist
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@
![](https://img.shields.io/badge/dynamic/json?color=darkred&label=open%20issues&query=open_issues&suffix=x&url=https%3A%2F%2Fapi.github.com%2Frepos%2Fnoblemajo%2Fhivessh)

# Table of Contents
- [HiveSsh](#hivessh)
- [Table of Contents](#table-of-contents)
- [About](#about)
- [Key Features](#key-features)
- [Requirements](#requirements)
- [Getting started](#getting-started)
- [Promisified](#promisified)
- [AbstractPackageManager](#abstractpackagemanager)
- [Technologies](#technologies)
- [License](#license)
- [Contributing](#contributing)
- [License](#license)
- [Disclaimer](#disclaimer)

# About
Expand All @@ -32,6 +35,7 @@ HiveSsh is a library designed to streamline SSH2 connections and task execution
HiveSsh offers the following key features:
- __All-Distributions__: SSH2 and SFTP operations for all Linux servers
- __Promisified__: Promise-based functions for ease of use

- __AbstractPackageManager__: Built-in abstract package manager with support for apt, dnf, and yum, with additional configurability
- __Exec__: Command execution utilities for event or promise-based error handling and output parsing, filtering, and mapping

Expand Down Expand Up @@ -64,15 +68,34 @@ const myHost = await SshHost.connect({
//privateKeyPath:"/home/user/.ssh/id_rsa",
//passphrase: "123456789"
})
```

Here are some using examples:

## Promisified
After connecting an `SshHost`, you can leverage the promised 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)

// check if a command exists
const gitExist = await myHost.exists("git")
console.log("Git exists: ", gitExist)
```

You can also use the promised SFTP features via `SshHost.sftp`.
```ts
const myBinary: Buffer = await myHost.sftp.readFile("/home/tester/my-binary")

const exampleConfig: string = await myHost.sftp.readFile("/etc/example/config.yml", "utf8")
```

## AbstractPackageManager
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.

```ts
// upgrade all packages using the abstract package manager
const apm = await myHost.getApm()
await apm.updateCache()
Expand All @@ -86,7 +109,7 @@ await apm.install("git")
HiveSsh is built using the following technologies:
- **TypeScript**
- **Node.js**
- **SSH2**
- **SSH2** ([NPM Package](https://www.npmjs.com/package/ssh2) & Protocol)

# Contributing
Contributions to HiveSsh are welcome!
Expand Down
47 changes: 13 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hivessh",
"version": "0.1.5",
"version": "0.1.6",
"description": "HiveSsh simplifies SSH2 connections via promise-based task execution on Linux servers with built-in server utilities and powerful command execution functions",
"main": "dist/index.js",
"type": "module",
Expand Down
20 changes: 1 addition & 19 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,4 @@ export * from "./utils/base.js"

import { SshHost } from "./SshHost.js"

export default SshHost

// or import SshHost from "hivelib" (SshHost is also the default export)

//connect
const myHost = await SshHost.connect({
host: "127.0.0.1",
//port: 22, (default 22)
//user: "root", (default root)

//password: "123456789",
// or
//privateKey: "..."
// or
//privateKeyPath:"/home/user/.ssh/id_rsa",
//passphrase: "123456789"
})

myHost.sftp.readFile("/etc/example/config.yml", "utf8")
export default SshHost

0 comments on commit 10c7809

Please sign in to comment.