mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
refactor(benchmark): Use kebab-case for file and directory names (#10787)
This commit is contained in:
37
packages/@n8n/benchmark/scripts/clients/ssh-client.mjs
Normal file
37
packages/@n8n/benchmark/scripts/clients/ssh-client.mjs
Normal file
@@ -0,0 +1,37 @@
|
||||
// @ts-check
|
||||
import { $ } from 'zx';
|
||||
|
||||
export class SshClient {
|
||||
/**
|
||||
*
|
||||
* @param {{ privateKeyPath: string; ip: string; username: string; verbose?: boolean }} param0
|
||||
*/
|
||||
constructor({ privateKeyPath, ip, username, verbose = false }) {
|
||||
this.verbose = verbose;
|
||||
this.privateKeyPath = privateKeyPath;
|
||||
this.ip = ip;
|
||||
this.username = username;
|
||||
|
||||
this.$$ = $({
|
||||
verbose,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} command
|
||||
* @param {{ verbose?: boolean }} [options]
|
||||
*/
|
||||
async ssh(command, options = {}) {
|
||||
const $$ = options?.verbose ? $({ verbose: true }) : this.$$;
|
||||
|
||||
const target = `${this.username}@${this.ip}`;
|
||||
|
||||
await $$`ssh -i ${this.privateKeyPath} -o StrictHostKeyChecking=accept-new ${target} ${command}`;
|
||||
}
|
||||
|
||||
async scp(source, destination) {
|
||||
const target = `${this.username}@${this.ip}:${destination}`;
|
||||
await this
|
||||
.$$`scp -i ${this.privateKeyPath} -o StrictHostKeyChecking=accept-new ${source} ${target}`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user