17 Commits

Author SHA1 Message Date
a9820a9e98 update description 2024-05-29 14:16:27 +02:00
7037cee3d8 update tsconfig 2024-04-14 18:22:42 +02:00
f7661e3133 update tsconfig 2024-04-01 21:41:15 +02:00
cfcaa5b059 update npmextra.json: githost 2024-04-01 19:59:45 +02:00
ac048b7025 update npmextra.json: githost 2024-03-30 21:48:46 +01:00
dcd32e2dd2 2.0.2 2024-02-09 18:21:33 +01:00
9a10f83bb6 fix(core): update 2024-02-09 18:21:33 +01:00
9fc03e8504 2.0.1 2023-07-27 15:52:02 +02:00
9a32b156fe fix(core): update 2023-07-27 15:52:01 +02:00
a319e54d60 2.0.0 2022-10-11 13:18:35 +02:00
6a2577cde6 BREAKING CHANGE(core): switch to esm 2022-10-11 13:18:35 +02:00
1f1bf7c21f 1.2.7 2022-10-11 13:18:04 +02:00
c652d0bf07 fix(core): update 2022-10-11 13:18:04 +02:00
eccc6294a8 1.2.6 2022-10-11 13:13:14 +02:00
f8a75a8d42 fix(core): update 2022-10-11 13:13:14 +02:00
d5c2bc1b53 1.2.5 2022-10-11 13:05:30 +02:00
d577a82a7b fix(core): update 2022-10-11 13:05:29 +02:00
25 changed files with 6250 additions and 2488 deletions

View File

@ -0,0 +1,66 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@ -0,0 +1,124 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @git.zone/tsdoc
npmci command tsdoc
continue-on-error: true

4
.gitignore vendored
View File

@ -15,8 +15,6 @@ node_modules/
# builds
dist/
dist_web/
dist_serve/
dist_ts_web/
dist_*/
# custom

View File

@ -1,117 +0,0 @@
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: "$CI_BUILD_STAGE"
stages:
- security
- test
- release
- metadata
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci git mirror
tags:
- docker
- notpriv
snyk:
stage: security
script:
- npmci npm prepare
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command snyk test
tags:
- docker
- notpriv
# ====================
# test stage
# ====================
testLTS:
stage: test
script:
- npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
release:
stage: release
script:
- npmci node install lts
- npmci npm publish
only:
- tags
tags:
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
script:
- npmci command npm install -g tslint typescript
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- docker
- priv
trigger:
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- docker
- notpriv
pages:
image: hosttoday/ht-docker-node:npmci
stage: metadata
script:
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
tags:
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
allow_failure: true

11
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"type": "node-terminal"
}
]
}

26
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

View File

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2016 Lossless GmbH
Copyright (c) 2016 Task Venture Capital GmbH
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,56 +0,0 @@
# @pushrocks/smartssh
setups SSH quickly and in a painless manner
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartssh)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartssh)
* [github.com (source mirror)](https://github.com/pushrocks/smartssh)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartssh/)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartssh/badges/master/build.svg)](https://gitlab.com/pushrocks/smartssh/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartssh/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartssh/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartssh.svg)](https://www.npmjs.com/package/@pushrocks/smartssh)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartssh/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartssh)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
## Usage
```javascript
var smartssh = require('smartssh');
var sshInstance = new smartssh.sshInstance({
sshDir: '/some/path/.ssh', // the standard ssh directory, optional, defaults to "~./.ssh"
sshSync: true // sync ssh this instance will represent the status of an ssh dir if set to true;
});
sshInstance.addKey(
new smartssh.sshKey({
private: 'somestring',
public: 'somestring', // optional
host: 'github.com',
encoding: 'base64' // optional, defaults to "utf8", can be "utf8" or "base64", useful for reading ssh keys from environment variables
})
);
sshInstance.removeKey(sshInstance.getKey('github.com')); // removes key for host "github.com" is present
sshInstance.createKey({
host: 'gitlab.com' // returns new key in the form sshKey, read more about the sshKey class below
});
sshInstance.getKey({
// returns ssh key in the form sshKey, read more about the sshKey class below
host: 'github.com'
});
sshInstance.getKeys(); // returns array of all available getKeys. Each key is in form of class sshKey
```
For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com)

View File

@ -4,13 +4,27 @@
"npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "pushrocks",
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "smartssh",
"shortDescription": "setups SSH quickly and in a painless manner",
"npmPackagename": "@pushrocks/smartssh",
"license": "MIT"
"description": "A library for setting up SSH configuration quickly and painlessly.",
"npmPackagename": "@push.rocks/smartssh",
"license": "MIT",
"keywords": [
"SSH",
"SSH configuration",
"SSH keys management",
"automation",
"development tools",
"node.js",
"security",
"server management"
]
}
},
"tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
}
}

2204
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,57 +1,70 @@
{
"name": "@pushrocks/smartssh",
"version": "1.2.4",
"name": "@push.rocks/smartssh",
"version": "2.0.2",
"private": false,
"description": "setups SSH quickly and in a painless manner",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"description": "A library for setting up SSH configuration quickly and painlessly.",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"scripts": {
"test": "(tstest test/)",
"testDocker": "tsdocker",
"build": "(tsbuild)"
"build": "(tsbuild --allowimplicitany)",
"buildDocs": "tsdoc"
},
"repository": {
"type": "git",
"url": "git+https://gitlab.com/pushrocks/smartssh.git"
"url": "https://code.foss.global/push.rocks/smartssh.git"
},
"keywords": [
"SSH",
"ENV",
"base64"
"SSH configuration",
"SSH keys management",
"automation",
"development tools",
"node.js",
"security",
"server management"
],
"author": "Lossless GmbH",
"license": "MIT",
"bugs": {
"url": "https://gitlab.com/pushrocks/smartssh/issues"
},
"homepage": "https://gitlab.com/pushrocks/smartssh#readme",
"homepage": "https://code.foss.global/push.rocks/smartssh",
"dependencies": {
"@pushrocks/smartfile": "^7.0.4",
"@pushrocks/smartpath": "^4.0.1",
"@pushrocks/smartpromise": "^3.0.2",
"@pushrocks/smartshell": "^2.0.23",
"@pushrocks/smartstring": "^3.0.10",
"@types/fs-extra": "^8.0.0",
"@types/minimatch": "^3.0.3",
"fs-extra": "^8.1.0",
"minimatch": "^3.0.4"
"@push.rocks/smartcrypto": "^2.0.5",
"@push.rocks/smartfile": "^11.0.4",
"@push.rocks/smartjson": "^5.0.10",
"@push.rocks/smartpath": "^5.0.11",
"@push.rocks/smartpromise": "^4.0.3",
"@push.rocks/smartshell": "^3.0.3",
"@push.rocks/smartstring": "^4.0.13",
"@types/fs-extra": "^11.0.4",
"fs-extra": "^11.2.0",
"minimatch": "^9.0.3",
"node-ssh": "^13.1.0"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.11",
"@gitzone/tsdocker": "^1.2.39",
"@gitzone/tsrun": "^1.2.6",
"@gitzone/tstest": "^1.0.24",
"@pushrocks/tapbundle": "^3.0.11",
"@types/node": "^12.6.6"
"@git.zone/tsbuild": "^2.1.72",
"@git.zone/tsrun": "^1.2.46",
"@git.zone/tstest": "^1.0.86",
"@push.rocks/tapbundle": "^5.0.15",
"@types/node": "^20.11.17"
},
"files": [
"ts/*",
"ts_web/*",
"dist/*",
"dist_web/*",
"assets/*",
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
]
}
}

5727
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

1
readme.hints.md Normal file
View File

@ -0,0 +1 @@

134
readme.md Normal file
View File

@ -0,0 +1,134 @@
# @push.rocks/smartssh
setup SSH quickly and in a painless manner
## Install
To begin using `@push.rocks/smartssh` in your project, you'll need to install it via npm or yarn. You can do so by running one of the following commands:
```bash
npm install @push.rocks/smartssh --save
```
or
```bash
yarn add @push.rocks/smartssh
```
## Usage
`@push.rocks/smartssh` is a powerful package designed to simplify SSH configurations, key management, and interaction in a Typescript environment, using ESM syntax. This guide will cover how to utilize the primary functionalities provided by the package.
#### Setting Up an SSH Instance
An SSH instance represents your SSH configurations, including the keys and the SSH directory. Here's how to create an instance:
```typescript
import { SshInstance } from '@push.rocks/smartssh';
const mySshInstance = new SshInstance({
sshDirPath: '/path/to/.ssh', // Optional: specify SSH directory path
sshSync: true, // Optional: keep the instance in sync with the SSH directory automatically
});
```
#### Working with SSH Keys
SSH keys can be managed using the `SshKey` class. You can add, remove, or retrieve keys from your SSH instance.
```typescript
import { SshKey } from '@push.rocks/smartssh';
// Creating a new SSH key
const mySshKey = new SshKey({
host: 'github.com', // Hostname
private: 'privateKeyString', // Private key string
public: 'publicKeyString', // Optional: public key string
authorized: false // Optional: Is this key authorized? Defaults to false
});
// Adding the SSH key to the instance
mySshInstance.addKey(mySshKey);
// Getting an SSH key by host
const githubKey = mySshInstance.getKey('github.com');
// Removing an SSH key by instance
mySshInstance.removeKey(githubKey);
```
#### Syncing Keys with the File System
`@push.rocks/smartssh` makes it easy to synchronize your SSH keys with the file system, keeping your actual SSH configuration and your program state in alignment.
```typescript
// To write the current state to the SSH directory
mySshInstance.writeToDisk();
// To read and synchronize the state from the SSH directory
mySshInstance.readFromDisk();
```
#### Advanced Key Management
- **Encoding and Decoding**: Keys can be encoded in `base64` for easier environment variable storage.
- **Key Type Detection**: The package can detect and handle private, public, or both keys present scenarios (`duplex`).
- **Custom SSH Directory**: Support for custom SSH directory locations.
- **Automatic Syncing**: Optionally keep the SSH instance automatically synced with the SSH directory on modifications.
### Comprehensive Example
Below is a comprehensive example demonstrating SSH instance creation, adding a new SSH key, and syncing with the filesystem.
```typescript
import { SshInstance, SshKey } from '@push.rocks/smartssh';
async function setupSsh() {
// Initialize the SSH instance
const sshInstance = new SshInstance({
sshDirPath: '/custom/path/to/.ssh',
sshSync: true,
});
// Create a new SSH key
const newSshKey = new SshKey({
host: 'my.custom.server.com',
private: 'myPrivateKeyInBase64',
public: 'myPublicKeyInBase64',
});
// Add the new key to the instance
sshInstance.addKey(newSshKey);
// Optionally, write to disk immediately
sshInstance.writeToDisk();
}
// Running the SSH setup
setupSsh().then(() => {
console.log('SSH setup complete.');
}).catch((error) => {
console.error('SSH setup failed:', error);
});
```
This guide should provide a robust start to managing SSH configurations using `@push.rocks/smartssh`. Whether for individual projects or shared across a team, this package offers a streamlined approach to handling SSH keys, config synchronization, and more, all within a TypeScript project.
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.

View File

@ -1,6 +1,6 @@
import { expect, tap } from '@pushrocks/tapbundle';
import smartssh = require('../ts/index');
import path = require('path');
import { expect, tap } from '@push.rocks/tapbundle';
import * as smartssh from '../ts/index.js';
import * as path from 'path';
let testSshInstance: smartssh.SshInstance;
let testSshKey: smartssh.SshKey;
@ -8,18 +8,18 @@ tap.test('should create a valid SshKey object', async () => {
testSshKey = new smartssh.SshKey({
host: 'example.com',
private: 'someExamplePrivateKey',
public: 'someExamplePublicKey'
public: 'someExamplePublicKey',
});
expect(testSshKey).to.be.instanceof(smartssh.SshKey);
expect(testSshKey).toBeInstanceOf(smartssh.SshKey);
});
tap.test('.type should be a valid type', async () => {
expect(testSshKey.type).equal('duplex');
expect(testSshKey.type).toEqual('duplex');
});
tap.test('.publicKey should be public key', async () => {
expect(testSshKey.pubKey).equal('someExamplePublicKey');
expect(testSshKey.pubKey).toEqual('someExamplePublicKey');
});
tap.test('.privateKey should be private key', async () => {
expect(testSshKey.privKey).equal('someExamplePrivateKey');
expect(testSshKey.privKey).toEqual('someExamplePrivateKey');
});
tap.test('.publicKeyBase64 should be public key base 64 encoded', async () => {
// tslint:disable-next-line:no-unused-expression
@ -32,49 +32,49 @@ tap.test('.store() should store the file to disk', async () => {
// SSH INstance
tap.test("'new' keyword should create a new SshInstance object from class", async () => {
testSshInstance = new smartssh.SshInstance({
sshDirPath: path.join(process.cwd(), 'test/temp/')
sshDirPath: path.join(process.cwd(), 'test/temp/'),
});
expect(testSshInstance).be.instanceof(smartssh.SshInstance);
expect(testSshInstance).toBeInstanceOf(smartssh.SshInstance);
});
tap.test('.addKey() should accept a new SshKey object', async () => {
testSshInstance.addKey(
new smartssh.SshKey({
public: 'somePublicKey',
private: 'somePrivateKey',
host: 'gitlab.com'
host: 'gitlab.com',
})
);
testSshInstance.addKey(
new smartssh.SshKey({
public: 'somePublicKey',
private: 'somePrivateKey',
host: 'bitbucket.org'
host: 'bitbucket.org',
})
);
testSshInstance.addKey(
new smartssh.SshKey({
public: 'someGitHubPublicKey',
private: 'someGitHubPrivateKey',
host: 'github.com'
host: 'github.com',
})
);
});
tap.test('.sshKeys should point to an array of sshKeys', async () => {
let sshKeyArray = testSshInstance.sshKeys;
expect(sshKeyArray).be.instanceOf(Array);
expect(sshKeyArray[0].host).equal('gitlab.com');
expect(sshKeyArray[1].host).equal('bitbucket.org');
expect(sshKeyArray[2].host).equal('github.com');
expect(sshKeyArray).toBeInstanceOf(Array);
expect(sshKeyArray[0].host).toEqual('gitlab.com');
expect(sshKeyArray[1].host).toEqual('bitbucket.org');
expect(sshKeyArray[2].host).toEqual('github.com');
});
tap.test('.getKey() should get a specific key selected by host', async () => {
expect(testSshInstance.getKey('github.com').pubKey).equal('someGitHubPublicKey');
expect(testSshInstance.getKey('github.com').pubKey).toEqual('someGitHubPublicKey');
});
tap.test('.removeKey() should remove a key', async () => {
testSshInstance.removeKey(testSshInstance.getKey('bitbucket.org'));
expect(testSshInstance.sshKeys[1].host).equal('github.com');
expect(testSshInstance.sshKeys[1].host).toEqual('github.com');
});
tap.test('it should store to disk', async () => {

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/smartssh',
version: '2.0.2',
description: 'setups SSH quickly and in a painless manner'
}

View File

@ -1,6 +1,6 @@
import * as plugins from './smartssh.plugins';
import * as plugins from './smartssh.plugins.js';
export { SshInstance } from './smartssh.classes.sshinstance';
export { SshKey } from './smartssh.classes.sshkey';
export { SshDir } from './smartssh.classes.sshdir';
export { SshConfig } from './smartssh.classes.sshconfig';
export { SshInstance } from './smartssh.classes.sshinstance.js';
export { SshKey } from './smartssh.classes.sshkey.js';
export { SshDir } from './smartssh.classes.sshdir.js';
export { SshConfig } from './smartssh.classes.sshconfig.js';

View File

@ -1,7 +1,7 @@
import * as plugins from './smartssh.plugins';
import { SshKey } from './smartssh.classes.sshkey';
import * as plugins from './smartssh.plugins.js';
import { SshKey } from './smartssh.classes.sshkey.js';
export let sshKeyArrayFromDir = function(dirArg: string): SshKey[] {
export let sshKeyArrayFromDir = function (dirArg: string): SshKey[] {
let sshKeyArray = []; // TODO
return sshKeyArray;
};

View File

@ -1,6 +1,6 @@
import * as plugins from './smartssh.plugins';
import * as helpers from './smartssh.classes.helpers';
import { SshKey } from './smartssh.classes.sshkey';
import * as plugins from './smartssh.plugins.js';
import * as helpers from './smartssh.classes.helpers.js';
import { SshKey } from './smartssh.classes.sshkey.js';
export class SshConfig {
private _sshKeyArray: SshKey[];
@ -34,7 +34,7 @@ export class SshConfig {
configArray.push({
configString: configString,
authorized: sshKey.authorized,
sshKey: sshKey
sshKey: sshKey,
});
}
let configFile: string = '';

View File

@ -1,8 +1,8 @@
import * as plugins from './smartssh.plugins';
import * as helpers from './smartssh.classes.helpers';
import { SshInstance } from './smartssh.classes.sshinstance';
import { SshKey } from './smartssh.classes.sshkey';
import { SshConfig } from './smartssh.classes.sshconfig';
import * as plugins from './smartssh.plugins.js';
import * as helpers from './smartssh.classes.helpers.js';
import { SshInstance } from './smartssh.classes.sshinstance.js';
import { SshKey } from './smartssh.classes.sshkey.js';
import { SshConfig } from './smartssh.classes.sshconfig.js';
export class SshDir {
// sshDir class -> NOT EXPORTED, ONLY FOR INTERNAL USE
@ -23,7 +23,7 @@ export class SshDir {
// syncs sshInstance to directory
let path = this._path;
if (dirPathArg) path = dirPathArg;
this._sshKeyArray.forEach(sshKeyArg => {
this._sshKeyArray.forEach((sshKeyArg) => {
sshKeyArg.store(path);
});
this._sshConfig.store(path);

View File

@ -1,9 +1,9 @@
import * as plugins from './smartssh.plugins';
import * as helpers from './smartssh.classes.helpers';
import * as plugins from './smartssh.plugins.js';
import * as helpers from './smartssh.classes.helpers.js';
import { SshDir } from './smartssh.classes.sshdir';
import { SshConfig } from './smartssh.classes.sshconfig';
import { SshKey } from './smartssh.classes.sshkey';
import { SshDir } from './smartssh.classes.sshdir.js';
import { SshConfig } from './smartssh.classes.sshconfig.js';
import { SshKey } from './smartssh.classes.sshkey.js';
/**
* SshInstance is the main class dealing with ssh management
@ -45,7 +45,7 @@ export class SshInstance {
// non altering methods
getKey(hostArg: string): SshKey {
this._syncAuto('from');
let filteredArray = this._sshKeyArray.filter(function(keyArg) {
let filteredArray = this._sshKeyArray.filter(function (keyArg) {
return keyArg.host === hostArg;
});
if (filteredArray.length > 0) {

View File

@ -1,5 +1,5 @@
import * as plugins from './smartssh.plugins';
import * as helpers from './smartssh.classes.helpers';
import * as plugins from './smartssh.plugins.js';
import * as helpers from './smartssh.classes.helpers.js';
export class SshKey {
private _privKey: string;
@ -7,8 +7,8 @@ export class SshKey {
private _hostVar: string;
private _authorized: boolean;
private _smarthshellInstance = new plugins.shelljs.Smartshell({
executor: 'bash'
private _smarthshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash',
});
/**

View File

@ -1,10 +1,30 @@
// node native
import * as fs from 'fs-extra';
import * as minimatch from 'minimatch';
import * as path from 'path';
import * as smartpromise from '@pushrocks/smartpromise';
import * as shelljs from '@pushrocks/smartshell';
import * as smartfile from '@pushrocks/smartfile';
import * as smartpath from '@pushrocks/smartpath';
import * as smartstring from '@pushrocks/smartstring';
export { fs, minimatch, path, smartpromise, shelljs, smartfile, smartpath, smartstring };
export { fs, path };
// @push.rocks scope
import * as smartjson from '@push.rocks/smartjson';
import * as smartfile from '@push.rocks/smartfile';
import * as smartcrypto from '@push.rocks/smartcrypto';
import * as smartpath from '@push.rocks/smartpath';
import * as smartpromise from '@push.rocks/smartpromise';
import * as smartshell from '@push.rocks/smartshell';
import * as smartstring from '@push.rocks/smartstring';
export {
smartjson,
smartfile,
smartcrypto,
smartpath,
smartpromise,
smartshell,
smartstring,
};
// third party scope
import * as minimatch from 'minimatch';
import * as nodeSsh from 'node-ssh';
export { minimatch, nodeSsh };

14
tsconfig.json Normal file
View File

@ -0,0 +1,14 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"verbatimModuleSyntax": true
},
"exclude": [
"dist_*/**/*.d.ts"
]
}

View File

@ -1,17 +0,0 @@
{
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}