Skip to content

Commit 46eec2b

Browse files
committed
packing and uploading in progress message
1 parent 4456e19 commit 46eec2b

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

bin/dropstack-deploy

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ program
3434
deploy(Object.assign(program.opts(), {folder: program.args.length === 0 ? process.cwd() : program.args[0] }));
3535

3636
function deploy({folder, token, variables, instances, alias, https, type, url, environment, aliveEndpoint, verbose, excludes}){
37+
process.stderr.write('\x1B[?25l'); //hide terminal cursor
3738
configuration = configurationSettings(`.dropstack${environment ? '.' + environment + '.' : '.'}json`);
3839

3940
const args = path.resolve(folder);
@@ -58,20 +59,27 @@ function deploy({folder, token, variables, instances, alias, https, type, url, e
5859
}));
5960

6061
configuration
61-
.load()
62-
.then(settings => {
63-
fstream.Reader({ path: args, type: 'Directory', follow: false, filter: x => tarFileFilter(x, settings.excludes)})
64-
.on('error', err => console.error(chalk.red(`\nAn unexpected error occurred!\nMessage: ${chalk.gray(err.message)}`)))
65-
.pipe(packer)
66-
.pipe(dirDest);
67-
});
62+
.load()
63+
.then(settings => {
64+
console.log(`Deploying ${chalk.green.underline(settings.alias || settings.name || '-')} for ${chalk.green.underline(settings.username || '-')} on ${chalk.green.underline(settings.url || '-')}`);
65+
if(verbose) {
66+
console.log(chalk.gray(`${settings.name || '--------'} packing ... please wait!`));
67+
} else {
68+
process.stdout.cursorTo(0);
69+
process.stdout.clearLine();
70+
process.stdout.write(chalk.gray(' Packing ... please wait!'));
71+
}
72+
fstream.Reader({ path: args, type: 'Directory', follow: false, filter: x => tarFileFilter(x, settings.excludes)})
73+
.on('error', err => console.error(chalk.red(`\nAn unexpected error occurred!\nMessage: ${chalk.gray(err.message)}`)))
74+
.pipe(packer)
75+
.pipe(dirDest);
76+
});
6877
}
6978

7079
function sync({tarPath, token, variables, instances, alias, type, https, url, aliveEndpoint, verbose, excludes}){
7180
configuration
7281
.load({variables, tarPath, instances, token, alias, type, https, url, aliveEndpoint, excludes})
7382
.then(settings => Boolean(!(settings.token && settings.username)) ? Promise.reject(new Error('Sign in failed. Use `dropstack login` to log in with your credentials.')) : settings)
74-
.then(settings => { console.log(`Deploying ${chalk.green.underline(settings.alias || settings.name || '-')} for ${chalk.green.underline(settings.username || '-')} on ${chalk.green.underline(settings.url || '-')}`); return settings;})
7583
.then(settings => {
7684
if(settings.message) return Promise.reject(new Error(settings.message));
7785
return settings;
@@ -114,6 +122,15 @@ function sync({tarPath, token, variables, instances, alias, type, https, url, al
114122
function deployment(settings, verbose) {
115123
const pathObj = path.parse(settings.tarPath);
116124
const form = new FormData();
125+
const startDate = new Date();
126+
127+
if(verbose) {
128+
console.log(chalk.gray(`${settings.name || '--------'} uploading ... please wait!`))
129+
} else {
130+
process.stdout.cursorTo(0);
131+
process.stdout.clearLine();
132+
process.stdout.write(chalk.gray(` Uploading ... please wait!`))
133+
};
117134

118135
if(settings.name) form.append('serviceName', settings.name);
119136
if(settings.alias) form.append('serviceAlias', settings.alias);
@@ -129,7 +146,6 @@ function deployment(settings, verbose) {
129146
const startDate = new Date();
130147
let n = 1;
131148
const es = new EventSource(`${settings.url}/deploys/live`, {headers: {connection: 'keep-alive', 'cache-control': 'no-cache', authorization: `Bearer ${settings.token}`}});
132-
process.stderr.write('\x1B[?25l'); //hide terminal cursor
133149

134150
es.onerror = () => {
135151
process.stderr.write('\x1B[?25h'); //show terminal cursor

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dropstack-cli",
3-
"version": "2.3.9",
3+
"version": "2.3.10",
44
"description": "A CLI to simplify continuous deployments into hybrid clouds.",
55
"author": "Mike Bild <mike@codecommission.com>",
66
"homepage": "https://github.com/codecommission/dropstack-cli#readme",

0 commit comments

Comments
 (0)