Skip to content
This repository has been archived by the owner on Mar 14, 2023. It is now read-only.

Commit

Permalink
feat(ssh-pool): add SSH Verbosity Levels (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchtreece authored and gregberge committed Apr 27, 2018
1 parent a764fff commit 327c63e
Show file tree
Hide file tree
Showing 7 changed files with 851 additions and 977 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,12 @@ Type: `String`

If `shallowClone` is set to `false`, this directory will be used to clone the repository before deploying it.

#### verboseSSHLevel

Type: `Number`, default `0`

SSH verbosity level to use when connecting to remote servers. **0** (none), **1** (-v), **2** (-vv), **3** (-vvv).

### API

#### shipit.task(name, [deps], fn)
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"dev": "lerna bootstrap && yarn build && lerna-watch",
"format": "prettier --write \"packages/*/src/**/*.js\"",
"lint": "eslint --cache .",
"release":
"yarn build && lerna publish --conventional-commits && conventional-github-releaser -p angular",
"release": "yarn build && lerna publish --conventional-commits && conventional-github-releaser -p angular",
"test": "jest --runInBand --coverage && codecov"
},
"devDependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/shipit-cli/src/Shipit.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ class Shipit extends Orchestrator {
...this.options,
key: this.config.key,
strict: this.config.strict,
verbosityLevel: (this.config.verboseSSHLevel === undefined) ? 0 : this.config.verboseSSHLevel
}

this.pool = new ConnectionPool(servers, options)
Expand Down
1 change: 1 addition & 0 deletions packages/ssh-pool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Create a new connection to run command on a remote server.
@param {string} [options.key] SSH key
@param {function} [options.log] Log method
@param {boolean} [options.asUser] Use a custom user to run command
@param {number} [options.verbosityLevel] SSH verbosity level: 0 (none), 1 (-v), 2 (-vv), 3+ (-vvv)
```

The remote can use the shorthand syntax or an object:
Expand Down
2 changes: 2 additions & 0 deletions packages/ssh-pool/src/Connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class Connection {
* @param {string} [options.key] SSH key
* @param {function} [options.log] Log method
* @param {boolean} [options.asUser] Use a custom user to run command
* @param {number} [options.verbosityLevel] The SSH verbosity level: 0 (none), 1 (-v), 2 (-vv), 3+ (-vvv)
*/
constructor(options = {}) {
this.options = options
Expand Down Expand Up @@ -300,6 +301,7 @@ class Connection {
key: this.options.key,
strict: this.options.strict,
tty: this.options.tty,
verbosityLevel: this.options.verbosityLevel,
remote: formatRemote(this.remote),
command: formatRawCommand({ command, asUser: this.options.asUser }),
...options,
Expand Down
9 changes: 9 additions & 0 deletions packages/ssh-pool/src/commands/ssh.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,17 @@ export function formatSshCommand({
remote,
cwd,
command,
verbosityLevel,
}) {
let args = ['ssh']
if (verbosityLevel) {
switch (verbosityLevel) {
case verbosityLevel <= 0: break
case 1: args = [...args, '-v']; break
case 2: args = [...args, '-vv']; break
default: args = [...args, '-vvv']; break
}
}
if (tty) args = [...args, '-tt']
if (port) args = [...args, '-p', port]
if (key) args = [...args, '-i', key]
Expand Down
Loading

0 comments on commit 327c63e

Please sign in to comment.