diff --git a/CHANGELOG.md b/CHANGELOG.md index 6db1de98..48ac3385 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Added - Add uploading of build logs when present with resin deploy +- Highlight cache usage in a local build ### Fixed diff --git a/build/utils/docker.js b/build/utils/docker.js index 63bf8d2a..92443602 100644 --- a/build/utils/docker.js +++ b/build/utils/docker.js @@ -1,5 +1,5 @@ // Generated by CoffeeScript 1.12.5 -var generateConnectOpts, tarDirectory; +var cacheHighlightStream, generateConnectOpts, tarDirectory; exports.appendOptions = function(opts) { return opts.concat([ @@ -98,6 +98,30 @@ exports.tarDirectory = tarDirectory = function(dir) { }); }; +cacheHighlightStream = function() { + var EOL, colors, es, extractArrowMessage; + colors = require('colors/safe'); + es = require('event-stream'); + EOL = require('os').EOL; + extractArrowMessage = function(message) { + var arrowTest, match; + arrowTest = /^\s*-+>\s*(.+)/i; + if ((match = arrowTest.exec(message))) { + return match[1]; + } else { + return void 0; + } + }; + return es.mapSync(function(data) { + var msg; + msg = extractArrowMessage(data); + if ((msg != null) && msg.toLowerCase() === 'using cache') { + data = colors.bgGreen.black(msg); + } + return data + EOL; + }); +}; + exports.runBuild = function(params, options, getBundleInfo, logStreams) { var Promise, dockerBuild, doodles, es, logging, logs, resolver; Promise = require('bluebird'); @@ -115,15 +139,17 @@ exports.runBuild = function(params, options, getBundleInfo, logStreams) { var builder, connectOpts, hooks, opts; hooks = { buildSuccess: function(image) { + var doodle; if (options.tag != null) { console.log("Tagging image as " + options.tag); } + doodle = doodles.getDoodle(); console.log(); - console.log(doodles.getDoodle()); + console.log(doodle); console.log(); return resolve({ image: image, - log: logs + log: logs + '\n' + doodle + '\n' }); }, buildFailure: reject, @@ -147,7 +173,7 @@ exports.runBuild = function(params, options, getBundleInfo, logStreams) { logs += data.toString(); return this.emit('data', data); }); - return stream.pipe(es.pipe(throughStream, logStreams.build)); + return stream.pipe(throughStream).pipe(cacheHighlightStream()).pipe(logStreams.build); } }; connectOpts = generateConnectOpts(options); diff --git a/lib/utils/docker.coffee b/lib/utils/docker.coffee index ea7a2e09..b1fe9804 100644 --- a/lib/utils/docker.coffee +++ b/lib/utils/docker.coffee @@ -110,6 +110,24 @@ exports.tarDirectory = tarDirectory = (dir) -> pack.finalize() return pack +cacheHighlightStream = -> + colors = require('colors/safe') + es = require('event-stream') + { EOL } = require('os') + + extractArrowMessage = (message) -> + arrowTest = /^\s*-+>\s*(.+)/i + if (match = arrowTest.exec(message)) + match[1] + else + undefined + + es.mapSync (data) -> + msg = extractArrowMessage(data) + if msg? and msg.toLowerCase() == 'using cache' + data = colors.bgGreen.black(msg) + return data + EOL + # Pass in the command line parameters and options and also # a function which will return the information about the bundle exports.runBuild = (params, options, getBundleInfo, logStreams) -> @@ -136,11 +154,12 @@ exports.runBuild = (params, options, getBundleInfo, logStreams) -> console.log("Tagging image as #{options.tag}") # Show charlie. In the interest of cloud parity, # use console.log, not the standard logging streams + doodle = doodles.getDoodle() console.log() - console.log(doodles.getDoodle()) + console.log(doodle) console.log() - resolve({ image, log: logs } ) + resolve({ image, log: logs + '\n' + doodle + '\n' } ) buildFailure: reject buildStream: (stream) -> @@ -168,7 +187,10 @@ exports.runBuild = (params, options, getBundleInfo, logStreams) -> logs += data.toString() this.emit('data', data) - stream.pipe(es.pipe(throughStream, logStreams.build)) + stream + .pipe(throughStream) + .pipe(cacheHighlightStream()) + .pipe(logStreams.build) # Create a builder connectOpts = generateConnectOpts(options)