Skip to content

Commit 41a0d9c

Browse files
committed
Better upload logs
1 parent 8ab973b commit 41a0d9c

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

bin/dropstack-deploy

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,18 @@ function deployment(settings, verbose) {
123123
const pathObj = path.parse(settings.tarPath);
124124
const form = new FormData();
125125
const startDate = new Date();
126+
const tarStream = fs.createReadStream(settings.tarPath);
127+
const stat = fs.statSync(settings.tarPath);
128+
const fileSize = (stat.size / (1024 * 1024)).toFixed(2);
129+
const spin = ' ⢹⢺⢼⣸⣇⡧⡗⡏'.split('');
130+
let n = 1;
126131

127132
if(verbose) {
128-
console.log(chalk.gray(`${settings.name || '--------'} uploading`))
133+
console.log(chalk.gray(`${settings.name || '--------'} uploading [${fileSize} MB]`))
129134
} else {
130135
process.stdout.cursorTo(0);
131136
process.stdout.clearLine();
132-
process.stdout.write(chalk.gray(` Uploading`))
137+
process.stdout.write(chalk.gray(`${chalk.white(spin[n++])} Uploading [${fileSize} MB]`))
133138
};
134139

135140
if(settings.name) form.append('serviceName', settings.name);
@@ -139,31 +144,24 @@ function deployment(settings, verbose) {
139144
if(settings.instances) form.append('serviceInstances', settings.instances);
140145
if(settings.aliveEndpoint) form.append('serviceAliveEndpoint', settings.aliveEndpoint);
141146
if(settings.variables) form.append('serviceVariables', settings.variables);
142-
const tarStream = fs.createReadStream(settings.tarPath);
143-
const stat = fs.statSync(settings.tarPath);
144147
let uploadedSize = 0;
145148
tarStream.on('data', buffer => {
146149
uploadedSize += buffer.length;
147150
if(verbose) {
148-
console.log(chalk.gray(`${settings.name || '--------'} ${(uploadedSize/stat.size*100).toFixed(2)}% uploaded`));
151+
console.log(chalk.gray(`${settings.name || '--------'} ${(uploadedSize/stat.size*100).toFixed(2)}% uploaded [${(uploadedSize / (1024 * 1024)).toFixed(2)} MB]`));
149152
} else {
153+
if(n === 8) n = 1;
150154
process.stdout.cursorTo(0);
151155
process.stdout.clearLine();
152-
process.stdout.write(chalk.gray(` ${(uploadedSize/stat.size*100).toFixed(2)}% uploaded`));
156+
process.stdout.write(chalk.gray(`${chalk.white(spin[n++])} ${(uploadedSize/stat.size*100).toFixed(2)}% uploaded [${(uploadedSize / (1024 * 1024)).toFixed(2)} MB]`));
153157
}
154158
});
155159
form.append(pathObj.name, tarStream);
156160

157161
return new Promise((resolve, reject) => {
158-
const spin = ' ⢹⢺⢼⣸⣇⡧⡗⡏'.split('');
159162
const startDate = new Date();
160-
let n = 1;
161163
const es = new EventSource(`${settings.url}/deploys/live`, {headers: {connection: 'keep-alive', 'cache-control': 'no-cache', authorization: `Bearer ${settings.token}`}});
162164

163-
es.onerror = () => {
164-
process.stderr.write('\x1B[?25h'); //show terminal cursor
165-
reject(new Error('Deployment error occurred'));
166-
};
167165
es.onmessage = e => {
168166
let progressState = {};
169167
try {

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.11",
3+
"version": "2.3.12",
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)