mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-30 08:03:55 +00:00
Fix issue when using resin deploy with non-standard stdin
This fixes issues when piping `resin deploy` to a non-TTY, and should solve issues on Windows too. Connects-To: #539
This commit is contained in:
parent
8d3987fc70
commit
5ccde3db8e
@ -7,6 +7,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
|
|
||||||
- Fix issue where emulated builds broke Docker `ARG` commands
|
- Fix issue where emulated builds broke Docker `ARG` commands
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Fix issue when using resin deploy with non-standard stdin (e.g. git bash on windows)
|
||||||
|
|
||||||
## [6.0.0] - 2017-06-26
|
## [6.0.0] - 2017-06-26
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Generated by CoffeeScript 1.12.6
|
// Generated by CoffeeScript 1.12.6
|
||||||
var Promise, dockerUtils, formatImageName, getBuilderLogPushEndpoint, getBuilderPushEndpoint, getBundleInfo, parseInput, performUpload, renderProgress, showPushProgress, updatePushProgress, uploadLogs, uploadToPromise;
|
var Promise, dockerUtils, formatImageName, getBuilderLogPushEndpoint, getBuilderPushEndpoint, getBundleInfo, parseInput, performUpload, showPushProgress, updatePushProgress, uploadLogs, uploadToPromise;
|
||||||
|
|
||||||
Promise = require('bluebird');
|
Promise = require('bluebird');
|
||||||
|
|
||||||
@ -51,36 +51,24 @@ parseInput = Promise.method(function(params, options) {
|
|||||||
return [appName, options.build, source, image];
|
return [appName, options.build, source, image];
|
||||||
});
|
});
|
||||||
|
|
||||||
renderProgress = function(percentage, stepCount) {
|
showPushProgress = function() {
|
||||||
var _, bar, barCount, spaceCount;
|
var progressBar, visuals;
|
||||||
if (stepCount == null) {
|
visuals = require('resin-cli-visuals');
|
||||||
stepCount = 50;
|
progressBar = new visuals.Progress('Deploying');
|
||||||
}
|
progressBar.update({
|
||||||
_ = require('lodash');
|
percentage: 0
|
||||||
percentage = Math.max(0, Math.min(percentage, 100));
|
});
|
||||||
barCount = Math.floor(stepCount * percentage / 100);
|
return progressBar;
|
||||||
spaceCount = stepCount - barCount;
|
|
||||||
bar = "[" + (_.repeat('=', barCount)) + ">" + (_.repeat(' ', spaceCount)) + "]";
|
|
||||||
return bar + " " + (percentage.toFixed(1)) + "%";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
showPushProgress = function(logStreams) {
|
updatePushProgress = function(percentage, eta, progressBar) {
|
||||||
var logging;
|
|
||||||
logging = require('../utils/logging');
|
|
||||||
return logging.logInfo(logStreams, renderProgress(0));
|
|
||||||
};
|
|
||||||
|
|
||||||
updatePushProgress = function(percentage, logStreams) {
|
|
||||||
var ansiEscapes, logging;
|
|
||||||
logging = require('../utils/logging');
|
|
||||||
ansiEscapes = require('ansi-escapes');
|
|
||||||
if (percentage >= 100) {
|
if (percentage >= 100) {
|
||||||
percentage = 100;
|
percentage = 100;
|
||||||
}
|
}
|
||||||
process.stdout.write(ansiEscapes.cursorUp(1));
|
return progressBar.update({
|
||||||
process.stdout.clearLine();
|
percentage: percentage,
|
||||||
process.stdout.cursorTo(0);
|
eta: eta
|
||||||
return logging.logInfo(logStreams, renderProgress(percentage));
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
getBundleInfo = function(options) {
|
getBundleInfo = function(options) {
|
||||||
@ -92,18 +80,21 @@ getBundleInfo = function(options) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
performUpload = function(imageStream, token, username, url, appName, logStreams) {
|
performUpload = function(imageStream, token, username, url, appName, logStreams) {
|
||||||
var progressStream, request, streamWithProgress, uploadRequest, zlib;
|
var progressBar, progressStream, request, streamWithProgress, uploadRequest, zlib;
|
||||||
request = require('request');
|
request = require('request');
|
||||||
progressStream = require('progress-stream');
|
progressStream = require('progress-stream');
|
||||||
zlib = require('zlib');
|
zlib = require('zlib');
|
||||||
showPushProgress(logStreams);
|
progressBar = showPushProgress();
|
||||||
streamWithProgress = imageStream.pipe(progressStream({
|
streamWithProgress = imageStream.pipe(progressStream({
|
||||||
time: 500,
|
time: 500,
|
||||||
length: imageStream.length
|
length: imageStream.length
|
||||||
}, function(arg) {
|
}, function(arg) {
|
||||||
var percentage;
|
var eta, percentage;
|
||||||
percentage = arg.percentage;
|
percentage = arg.percentage, eta = arg.eta;
|
||||||
return updatePushProgress(percentage, logStreams);
|
return progressBar.update({
|
||||||
|
percentage: Math.min(percentage, 100),
|
||||||
|
eta: eta
|
||||||
|
});
|
||||||
}));
|
}));
|
||||||
uploadRequest = request.post({
|
uploadRequest = request.post({
|
||||||
url: getBuilderPushEndpoint(url, username, appName),
|
url: getBuilderPushEndpoint(url, username, appName),
|
||||||
|
@ -31,30 +31,17 @@ parseInput = Promise.method (params, options) ->
|
|||||||
|
|
||||||
return [appName, options.build, source, image]
|
return [appName, options.build, source, image]
|
||||||
|
|
||||||
# Builds and returns a Docker-like progress bar like this:
|
showPushProgress = ->
|
||||||
# [==================================> ] 64%
|
visuals = require('resin-cli-visuals')
|
||||||
renderProgress = (percentage, stepCount = 50) ->
|
progressBar = new visuals.Progress('Deploying')
|
||||||
_ = require('lodash')
|
progressBar.update({ percentage: 0 })
|
||||||
percentage = Math.max(0, Math.min(percentage, 100))
|
return progressBar
|
||||||
barCount = stepCount * percentage // 100
|
|
||||||
spaceCount = stepCount - barCount
|
|
||||||
bar = "[#{_.repeat('=', barCount)}>#{_.repeat(' ', spaceCount)}]"
|
|
||||||
return "#{bar} #{percentage.toFixed(1)}%"
|
|
||||||
|
|
||||||
showPushProgress = (logStreams) ->
|
|
||||||
logging = require('../utils/logging')
|
|
||||||
logging.logInfo(logStreams, renderProgress(0))
|
|
||||||
|
|
||||||
updatePushProgress = (percentage, logStreams) ->
|
|
||||||
logging = require('../utils/logging')
|
|
||||||
ansiEscapes = require('ansi-escapes')
|
|
||||||
|
|
||||||
|
updatePushProgress = (percentage, eta, progressBar) ->
|
||||||
if percentage >= 100
|
if percentage >= 100
|
||||||
percentage = 100
|
percentage = 100
|
||||||
process.stdout.write(ansiEscapes.cursorUp(1))
|
|
||||||
process.stdout.clearLine()
|
progressBar.update({ percentage, eta })
|
||||||
process.stdout.cursorTo(0)
|
|
||||||
logging.logInfo(logStreams, renderProgress(percentage))
|
|
||||||
|
|
||||||
getBundleInfo = (options) ->
|
getBundleInfo = (options) ->
|
||||||
helpers = require('../utils/helpers')
|
helpers = require('../utils/helpers')
|
||||||
@ -68,11 +55,14 @@ performUpload = (imageStream, token, username, url, appName, logStreams) ->
|
|||||||
progressStream = require('progress-stream')
|
progressStream = require('progress-stream')
|
||||||
zlib = require('zlib')
|
zlib = require('zlib')
|
||||||
|
|
||||||
showPushProgress(logStreams)
|
progressBar = showPushProgress()
|
||||||
streamWithProgress = imageStream.pipe(progressStream({
|
streamWithProgress = imageStream.pipe progressStream
|
||||||
time: 500,
|
time: 500,
|
||||||
length: imageStream.length
|
length: imageStream.length
|
||||||
}, ({ percentage }) -> updatePushProgress(percentage, logStreams)))
|
, ({ percentage, eta }) ->
|
||||||
|
progressBar.update
|
||||||
|
percentage: Math.min(percentage, 100)
|
||||||
|
eta: eta
|
||||||
|
|
||||||
uploadRequest = request.post
|
uploadRequest = request.post
|
||||||
url: getBuilderPushEndpoint(url, username, appName)
|
url: getBuilderPushEndpoint(url, username, appName)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user