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

Commit

Permalink
Add showProgress and showStats flags to enable logging during rsync
Browse files Browse the repository at this point in the history
  • Loading branch information
utkarsh-dixit committed Jul 8, 2019
1 parent 7a5b1aa commit 2ff4417
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
9 changes: 9 additions & 0 deletions packages/shipit-cli/src/Shipit.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ class Shipit extends Orchestrator {
this.options = { ...defaultOptions, ...options }
this.environment = options.environment

this.show_progress = false;
this.show_stats = false;

this.initializeEvents()

if (this.options.stdout === process.stdout)
Expand Down Expand Up @@ -227,6 +230,8 @@ class Shipit extends Orchestrator {
const defaultOptions = {
ignores: this.config && this.config.ignores ? this.config.ignores : [],
rsync: this.config && this.config.rsync ? this.config.rsync : [],
show_progress: this.show_progress,
show_stats: this.show_stats,
}
const copyOptions = { ...defaultOptions, ...options }

Expand All @@ -251,6 +256,8 @@ class Shipit extends Orchestrator {
const defaultOptions = {
ignores: this.config && this.config.ignores ? this.config.ignores : [],
rsync: this.config && this.config.rsync ? this.config.rsync : [],
show_progress: this.show_progress,
show_stats: this.show_stats,
}
const copyOptions = { ...defaultOptions, ...options }
return this.pool.copyToRemote(src, dest, copyOptions)
Expand All @@ -273,6 +280,8 @@ class Shipit extends Orchestrator {
const defaultOptions = {
ignores: this.config && this.config.ignores ? this.config.ignores : [],
rsync: this.config && this.config.rsync ? this.config.rsync : [],
show_progress: this.show_progress,
show_stats: this.show_stats,
}
const copyOptions = { ...defaultOptions, ...options }
return this.pool.copyFromRemote(src, dest, copyOptions)
Expand Down
17 changes: 17 additions & 0 deletions packages/shipit-cli/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ program
.option('--require <files...>', 'Script required before launching Shipit')
.option('--tasks', 'List available tasks')
.option('--environments', 'List available environments')
.option('-p, --showProgress', 'Show rsync Progress')
.option('-s, --showStats', 'Show rsync Stats')

program.parse(process.argv)

Expand All @@ -49,6 +51,14 @@ function logEnvironments(shipit) {
)
}

function logProgress(shipit) {
shipit.show_progress = true;
}

function logStats(shipit) {
shipit.show_stats = true;
}

async function asyncInvoke(env) {
if (!env.configPath) {
console.error(chalk.red('shipitfile not found'))
Expand All @@ -71,6 +81,13 @@ async function asyncInvoke(env) {
throw error
}

if(program.showProgress) {
logProgress(shipit);
}
if(program.showStats){
logStats(shipit);
}

if (program.tasks === true) {
logTasks(shipit)
} else if (program.environments === true) {
Expand Down
10 changes: 9 additions & 1 deletion packages/ssh-pool/src/Connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,19 @@ class Connection {
tty: this.options.tty,
})

let additionalArgs = (typeof rsync === 'string' ? [rsync] : rsync);
if(cmdOptions.show_progress){
additionalArgs.push("--progress");
}
if(cmdOptions.show_stats){
additionalArgs.push("--stats");
}

const cmd = formatRsyncCommand({
src,
dest,
remoteShell: sshCommand,
additionalArgs: typeof rsync === 'string' ? [rsync] : rsync,
additionalArgs: additionalArgs,
excludes: ignores,
})

Expand Down

0 comments on commit 2ff4417

Please sign in to comment.