Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds --show option to list files being built on run/push #92

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions bin/tessel-push.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ var argv = require("nomnom")
flag: true,
help: '[Tessel] Hide tessel deployment messages.'
})
.option('verbose', {
abbr: 'v',
flag: true,
help: '[Tessel] Show debug messages (such as which files are being bundled).'
})
.option('messages', {
abbr: 'm',
flag: true,
Expand All @@ -47,6 +52,10 @@ var argv = require("nomnom")
flag: true,
help: '[Tessel] Stay connected and print logs.'
})
.option('show', {
flag: true,
help: 'Lists which files are being bundled during the push'
})
.option('single', {
abbr: 's',
flag: true,
Expand All @@ -59,7 +68,10 @@ var argv = require("nomnom")
})
.parse();

argv.verbose = !argv.quiet;
if (argv.verbose && argv.quiet) {
argv.quiet = false;
logs.warn("Both --verbose and --quiet were specified. Defaulting to --verbose");
}

function usage () {
console.error(require('nomnom').getUsage());
Expand Down Expand Up @@ -114,15 +126,18 @@ common.controller(true, function (err, client) {
});

function pushCode(){
client.run(pushpath, ['tessel', pushpath].concat(argv.arguments || []), {
flash: true,
single: argv.single
}, function (err) {
client.run(pushpath, ['tessel', pushpath].concat(argv.arguments || [])
, { flash: true
, single: argv.single
, verbose: argv.verbose
, quiet : argv.quiet
}
, function (err) {

logs.info("Finished deployment");
if (!argv.quiet) logs.info("Finished deployment");

function exit(code) {
logs.info("Run \"tessel logs\" or \"tessel push <script.js> -l\" to see logged output.");
if (!argv.quiet) logs.info("Run \"tessel logs\" or \"tessel push <script.js> -l\" to see logged output.");
client.close(function () {
process.exit(code || 0);
});
Expand Down
37 changes: 22 additions & 15 deletions bin/tessel-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ var argv = require("nomnom")
list: true,
help: 'Arguments to pass in as process.argv.'
})
.option('version', {
abbr: 'v',
flag: true,
help: 'Print tessel-node\'s version.',
callback: function() {
return require('./package.json').version.replace(/^v?/, 'v');
}
})
.option('interactive', {
abbr: 'i',
flag: true,
Expand All @@ -63,6 +55,10 @@ var argv = require("nomnom")
// flag: true,
// help: '[Tessel] Push code to a Tessel by IP address.'
// })
.option('show', {
flag: true,
help: 'Lists which files are being bundled during the push'
})
.option('listen', {
abbr: 'l',
help: 'Listen and display specific logs. "--listen all" outputs all logs.'
Expand All @@ -72,6 +68,11 @@ var argv = require("nomnom")
flag: true,
help: '[Tessel] Hide tessel deployment messages.'
})
.option('verbose', {
abbr: 'v',
flag: true,
help: '[Tessel] Show debug messages (such as which files are being bundled).'
})
.option('single', {
abbr: 's',
flag: true,
Expand All @@ -84,7 +85,10 @@ var argv = require("nomnom")
})
.parse();

argv.verbose = !argv.quiet;
if (argv.verbose && argv.quiet) {
argv.quiet = false;
logs.warn("Both --verbose and --quiet were specified. Defaulting to --verbose");
}

function usage () {
console.error(require('nomnom').getUsage());
Expand Down Expand Up @@ -186,11 +190,14 @@ common.controller(true, function (err, client) {
});

function pushCode(){
client.run(pushpath, ['tessel', pushpath].concat(argv.arguments || []), {
single: argv.single
}, function () {
client.run(pushpath, ['tessel', pushpath].concat(argv.arguments || [])
, { single: argv.single
, verbose : argv.verbose
, quiet : argv.quiet
}
, function () {
// script-start emitted.
logs.info('Running script...');
if (!argv.quiet) logs.info('Running script...');

// Forward pipes.
if (!('listen' in argv)) {
Expand All @@ -206,7 +213,7 @@ common.controller(true, function (err, client) {
process.on('SIGINT', function() {
setTimeout(function () {
// timeout :|
logs.info('Script aborted');
if (!argv.quiet) logs.info('Script aborted');
process.exit(131);
}, 200);
client.stop();
Expand All @@ -228,7 +235,7 @@ common.controller(true, function (err, client) {
try {
var packet = require('structured-clone').deserialize(data);
fs.writeFileSync(path.resolve(upload_dir, path.basename(packet.filename)), packet.buffer);
logs.info(util.format(packet.filename, 'saved to', upload_dir));
if (!argv.quiet) logs.info(util.format(packet.filename, 'saved to', upload_dir));
} catch (e) {
logs.err('invalid sendfile packet received.');
}
Expand Down
8 changes: 7 additions & 1 deletion src/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var path = require('path')
}
})();

exports.bundleFiles = function (startpath, args, files, next)
exports.bundleFiles = function (startpath, args, files, bundleopts, next)
{
temp.mkdir('colony', function (err, dirpath) {
var mkdirp = require('mkdirp');
Expand Down Expand Up @@ -63,6 +63,9 @@ exports.bundleFiles = function (startpath, args, files, next)
var f = _f[0], fullpath = _f[1];

debug('compiling', f);
if (bundleopts.show && !bundleopts.quiet) {
logs.info('compiling', f);
}

try {
var source = fs.readFileSync(fullpath, 'utf-8');
Expand Down Expand Up @@ -92,6 +95,9 @@ exports.bundleFiles = function (startpath, args, files, next)
try {
colonyCompiler.toBytecode(res, '/' + f.split(path.sep).join('/'), function (err, bytecode) {
debug('writing', f);
if (bundleopts.show && !bundleopts.quiet) {
logs.info('writing', f);
}
!err && fs.writeFileSync(fullpath, bytecode);
next(err);
});
Expand Down
9 changes: 4 additions & 5 deletions src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,15 @@ tessel.bundleScript = function (pushpath, argv, bundleopts, next)
next = bundleopts;
bundleopts = {};
}
var verbose = !bundleopts.quiet;

var ret = analyzeScript(pushpath, bundleopts);
if (ret.warning) {
verbose && logs.warn(ret.warning);
bundleopts.verbose && logs.warn(ret.warning);
}
verbose && logs.info('Bundling directory ' + ret.pushdir + ' (~' + humanize.filesize(ret.size) + ')');

if (!bundleopts.quiet) logs.info('Bundling directory ' + ret.pushdir );

// Create archive and deploy it to tessel.
tessel.bundleFiles(ret.relpath, argv, ret.files, next);
tessel.bundleFiles(ret.relpath, argv, ret.files, bundleopts, next);
}

// client#run(pushpath, args, next(err))
Expand Down
2 changes: 1 addition & 1 deletion test/test_symlinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var tar = require('tar');
console.log('1..1')
tessel.bundleFiles('index.js', [], {
'sym/sym2/index.js': __dirname + '/sym/sym2/index.js'
}, function (err, bundle) {
}, {}, function (err, bundle) {
tar.Parse()
.on('entry', function (data) {
if (data.path == 'app/sym/sym2/index.js') {
Expand Down