Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(baremetal): Add verbose output to ssh exec #10525

Merged
merged 4 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading