mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-29 15:44:26 +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
|
||||
|
||||
### Added
|
||||
|
||||
- Fix issue when using resin deploy with non-standard stdin (e.g. git bash on windows)
|
||||
|
||||
## [6.0.0] - 2017-06-26
|
||||
|
||||
### Added
|
||||
|
@ -1,5 +1,5 @@
|
||||
// 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');
|
||||
|
||||
@ -51,36 +51,24 @@ parseInput = Promise.method(function(params, options) {
|
||||
return [appName, options.build, source, image];
|
||||
});
|
||||
|
||||
renderProgress = function(percentage, stepCount) {
|
||||
var _, bar, barCount, spaceCount;
|
||||
if (stepCount == null) {
|
||||
stepCount = 50;
|
||||
}
|
||||
_ = require('lodash');
|
||||
percentage = Math.max(0, Math.min(percentage, 100));
|
||||
barCount = Math.floor(stepCount * percentage / 100);
|
||||
spaceCount = stepCount - barCount;
|
||||
bar = "[" + (_.repeat('=', barCount)) + ">" + (_.repeat(' ', spaceCount)) + "]";
|
||||
return bar + " " + (percentage.toFixed(1)) + "%";
|
||||
showPushProgress = function() {
|
||||
var progressBar, visuals;
|
||||
visuals = require('resin-cli-visuals');
|
||||
progressBar = new visuals.Progress('Deploying');
|
||||
progressBar.update({
|
||||
percentage: 0
|
||||
});
|
||||
return progressBar;
|
||||
};
|
||||
|
||||
showPushProgress = function(logStreams) {
|
||||
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');
|
||||
updatePushProgress = function(percentage, eta, progressBar) {
|
||||
if (percentage >= 100) {
|
||||
percentage = 100;
|
||||
}
|
||||
process.stdout.write(ansiEscapes.cursorUp(1));
|
||||
process.stdout.clearLine();
|
||||
process.stdout.cursorTo(0);
|
||||
return logging.logInfo(logStreams, renderProgress(percentage));
|
||||
return progressBar.update({
|
||||
percentage: percentage,
|
||||
eta: eta
|
||||
});
|
||||
};
|
||||
|
||||
getBundleInfo = function(options) {
|
||||
@ -92,18 +80,21 @@ getBundleInfo = function(options) {
|
||||
};
|
||||
|
||||
performUpload = function(imageStream, token, username, url, appName, logStreams) {
|
||||
var progressStream, request, streamWithProgress, uploadRequest, zlib;
|
||||
var progressBar, progressStream, request, streamWithProgress, uploadRequest, zlib;
|
||||
request = require('request');
|
||||
progressStream = require('progress-stream');
|
||||
zlib = require('zlib');
|
||||
showPushProgress(logStreams);
|
||||
progressBar = showPushProgress();
|
||||
streamWithProgress = imageStream.pipe(progressStream({
|
||||
time: 500,
|
||||
length: imageStream.length
|
||||
}, function(arg) {
|
||||
var percentage;
|
||||
percentage = arg.percentage;
|
||||
return updatePushProgress(percentage, logStreams);
|
||||
var eta, percentage;
|
||||
percentage = arg.percentage, eta = arg.eta;
|
||||
return progressBar.update({
|
||||
percentage: Math.min(percentage, 100),
|
||||
eta: eta
|
||||
});
|
||||
}));
|
||||
uploadRequest = request.post({
|
||||
url: getBuilderPushEndpoint(url, username, appName),
|
||||
|
@ -31,30 +31,17 @@ parseInput = Promise.method (params, options) ->
|
||||
|
||||
return [appName, options.build, source, image]
|
||||
|
||||
# Builds and returns a Docker-like progress bar like this:
|
||||
# [==================================> ] 64%
|
||||
renderProgress = (percentage, stepCount = 50) ->
|
||||
_ = require('lodash')
|
||||
percentage = Math.max(0, Math.min(percentage, 100))
|
||||
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')
|
||||
showPushProgress = ->
|
||||
visuals = require('resin-cli-visuals')
|
||||
progressBar = new visuals.Progress('Deploying')
|
||||
progressBar.update({ percentage: 0 })
|
||||
return progressBar
|
||||
|
||||
updatePushProgress = (percentage, eta, progressBar) ->
|
||||
if percentage >= 100
|
||||
percentage = 100
|
||||
process.stdout.write(ansiEscapes.cursorUp(1))
|
||||
process.stdout.clearLine()
|
||||
process.stdout.cursorTo(0)
|
||||
logging.logInfo(logStreams, renderProgress(percentage))
|
||||
|
||||
progressBar.update({ percentage, eta })
|
||||
|
||||
getBundleInfo = (options) ->
|
||||
helpers = require('../utils/helpers')
|
||||
@ -68,11 +55,14 @@ performUpload = (imageStream, token, username, url, appName, logStreams) ->
|
||||
progressStream = require('progress-stream')
|
||||
zlib = require('zlib')
|
||||
|
||||
showPushProgress(logStreams)
|
||||
streamWithProgress = imageStream.pipe(progressStream({
|
||||
progressBar = showPushProgress()
|
||||
streamWithProgress = imageStream.pipe progressStream
|
||||
time: 500,
|
||||
length: imageStream.length
|
||||
}, ({ percentage }) -> updatePushProgress(percentage, logStreams)))
|
||||
, ({ percentage, eta }) ->
|
||||
progressBar.update
|
||||
percentage: Math.min(percentage, 100)
|
||||
eta: eta
|
||||
|
||||
uploadRequest = request.post
|
||||
url: getBuilderPushEndpoint(url, username, appName)
|
||||
|
Loading…
x
Reference in New Issue
Block a user