From 231ad689346aa89a5535caeb85d8cddfd91fbd69 Mon Sep 17 00:00:00 2001 From: Tony Kovanen Date: Sun, 24 Apr 2016 01:51:16 +0300 Subject: [PATCH 1/4] Show url instead of deployment id in confirmation --- bin/now-remove | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bin/now-remove b/bin/now-remove index 8071e78..b5f1482 100755 --- a/bin/now-remove +++ b/bin/now-remove @@ -43,9 +43,9 @@ const hard = argv.hard || false; const config = cfg.read(); -function readConfirmation () { +function readConfirmation (url) { return new Promise((resolve, reject) => { - process.stdout.write(`${chalk.bold.red('> Are you sure?')} ${chalk.bold(deploymentId)} will be removed permanently ${chalk.gray('[yN] ')}`); + process.stdout.write(`${chalk.bold.red('> Are you sure?')} ${chalk.bold(url)} will be removed permanently ${chalk.gray('[yN] ')}`); process.stdin.on('data', (d) => { process.stdin.pause(); resolve(d.toString().trim()); @@ -70,9 +70,12 @@ Promise.resolve(config.token || login(apiUrl)) async function remove (token) { const now = new Now(apiUrl, token, { debug }); + const deployments = await now.list(); + const url = deployments.find((d) => d.uid === deploymentId).url; + try { - const confirmation = (await readConfirmation()).toLowerCase(); - if ('y' !== confirmation || 'yes' !== confirmation) { + const confirmation = (await readConfirmation(url)).toLowerCase(); + if ('y' !== confirmation && 'yes' !== confirmation) { console.log('> Aborted'); return; } From e8ff848e3b51bdddea0fc975f0cc11519ca09f8b Mon Sep 17 00:00:00 2001 From: Tony Kovanen Date: Sun, 24 Apr 2016 01:56:09 +0300 Subject: [PATCH 2/4] Add `https://` to displayed url for cmd + click --- bin/now-remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/now-remove b/bin/now-remove index b5f1482..3815667 100755 --- a/bin/now-remove +++ b/bin/now-remove @@ -45,7 +45,7 @@ const config = cfg.read(); function readConfirmation (url) { return new Promise((resolve, reject) => { - process.stdout.write(`${chalk.bold.red('> Are you sure?')} ${chalk.bold(url)} will be removed permanently ${chalk.gray('[yN] ')}`); + process.stdout.write(`${chalk.bold.red('> Are you sure?')} ${chalk.bold('https://' + url)} will be removed permanently ${chalk.gray('[yN] ')}`); process.stdin.on('data', (d) => { process.stdin.pause(); resolve(d.toString().trim()); From f3591dedf60b51c6c8f22a50a2eab1979e755e30 Mon Sep 17 00:00:00 2001 From: Tony Kovanen Date: Sun, 24 Apr 2016 01:59:06 +0300 Subject: [PATCH 3/4] Remove double space --- bin/now-remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/now-remove b/bin/now-remove index 3815667..ef0097a 100755 --- a/bin/now-remove +++ b/bin/now-remove @@ -83,7 +83,7 @@ async function remove (token) { const start = new Date(); await now.remove(deploymentId, { hard }); const elapsed = ms(new Date() - start); - console.log(`${chalk.cyan('> Deployment ')} ${chalk.bold(deploymentId)} ${chalk.cyan('removed')} [${elapsed}]`); + console.log(`${chalk.cyan('> Deployment')} ${chalk.bold(deploymentId)} ${chalk.cyan('removed')} [${elapsed}]`); } catch (err) { handleError(err); process.exit(1); From 95a0263295759f940b4f9fe9a338205f761c427e Mon Sep 17 00:00:00 2001 From: Tony Kovanen Date: Sun, 24 Apr 2016 02:15:42 +0300 Subject: [PATCH 4/4] Parity of output with `now ls` --- bin/now-remove | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/bin/now-remove b/bin/now-remove index ef0097a..055140d 100755 --- a/bin/now-remove +++ b/bin/now-remove @@ -3,6 +3,7 @@ import minimist from 'minimist'; import chalk from 'chalk'; import ms from 'ms'; +import table from 'text-table'; import Now from '../lib'; import login from '../lib/login'; import * as cfg from '../lib/cfg'; @@ -43,9 +44,18 @@ const hard = argv.hard || false; const config = cfg.read(); -function readConfirmation (url) { +function readConfirmation (app) { return new Promise((resolve, reject) => { - process.stdout.write(`${chalk.bold.red('> Are you sure?')} ${chalk.bold('https://' + url)} will be removed permanently ${chalk.gray('[yN] ')}`); + const time = chalk.gray(ms(new Date() - app.created) + ' ago'); + const tbl = table( + [[app.uid, time, `https://${app.url}`]], + { align: ['l', 'r', 'l'], hsep: ' '.repeat(6) } + ); + + process.stdout.write('> The following deployment will be removed permanently\n'); + process.stdout.write(' ' + tbl + '\n'); + process.stdout.write(` ${chalk.bold.red('> Are you sure?')} ${chalk.gray('[yN] ')}`); + process.stdin.on('data', (d) => { process.stdin.pause(); resolve(d.toString().trim()); @@ -71,10 +81,10 @@ async function remove (token) { const now = new Now(apiUrl, token, { debug }); const deployments = await now.list(); - const url = deployments.find((d) => d.uid === deploymentId).url; + const app = deployments.find((d) => d.uid === deploymentId); try { - const confirmation = (await readConfirmation(url)).toLowerCase(); + const confirmation = (await readConfirmation(app)).toLowerCase(); if ('y' !== confirmation && 'yes' !== confirmation) { console.log('> Aborted'); return;