Skip to content

Commit

Permalink
feat(baremetal): Add verbose output to ssh exec (#10525)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe authored Apr 29, 2024
1 parent f097a41 commit 39b385c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
17 changes: 17 additions & 0 deletions .changesets/10525.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
- feat(baremetal): Add verbose output to ssh exec (#10525) by @Tobbe

Passing `--verbose` to the baremetal deploy command is supposed to give you
more detailed info about what's happening. Previously however passing
`--verbose` didn't actually provide any extra information. This PR adds logging
to the new SshExecutor class so that you can see exactly what SSH commands are
being run, and in what path.

Standard output (this stays the same before and after)
![image](https://github.com/redwoodjs/redwood/assets/30793/588fcf3d-b059-42d2-a1af-d2fff8b3e4bd)

## Before (verbose output)
![image](https://github.com/redwoodjs/redwood/assets/30793/65fdfe46-2e82-4c87-897b-99a438e16149)
Doesn't really help much compared to the standard output 😅

## After (verbose output)
![image](https://github.com/redwoodjs/redwood/assets/30793/4a87bde4-072f-4bae-a84e-50ac72afe964)
2 changes: 1 addition & 1 deletion packages/cli/src/commands/deploy/baremetal.js
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ export const handler = async (yargs) => {
verbose: yargs.verbose,
})

const ssh = new SshExecutor()
const ssh = new SshExecutor(yargs.verbose)

try {
const tasks = new Listr(commands(yargs, ssh), {
Expand Down
9 changes: 8 additions & 1 deletion packages/cli/src/commands/deploy/baremetal/SshExecutor.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export class SshExecutor {
constructor() {
constructor(verbose) {
const { NodeSSH } = require('node-ssh')
this.ssh = new NodeSSH()
this.verbose = verbose
}

/**
Expand All @@ -15,6 +16,12 @@ export class SshExecutor {
sshCommand += ` ${args.join(' ')}`
}

if (this.verbose) {
console.log(
`SshExecutor::exec running command \`${command} ${args.join(' ')}\` in ${path}`,
)
}

const result = await this.ssh.execCommand(sshCommand, {
cwd: path,
})
Expand Down

0 comments on commit 39b385c

Please sign in to comment.