famous-cli
Advanced tools
Comparing version 0.2.7 to 0.2.8
@@ -24,7 +24,2 @@ #!/usr/bin/env node | ||
.version(require('../package').version); | ||
// .command('user <cmd>', 'famous hub user CLI') | ||
// .command('container <cmd>', 'famous hub container CLI') | ||
// .command('widget <cmd>', 'famous hub widget CLI') | ||
// .command('analytics <cmd>', 'famous hub analytics CLI') | ||
// .command('project <cmd>', 'famous hub project CLI'); | ||
@@ -31,0 +26,0 @@ program |
'use strict'; | ||
var spawn = require('child_process').spawn; | ||
var spawn = require('win-spawn'); | ||
var pkg = require('../package'); | ||
@@ -20,2 +20,33 @@ var chalk = require('chalk'); | ||
/** | ||
* checkTracking | ||
*/ | ||
var checkTracking = function (callback) { | ||
async.waterfall([ | ||
storage.getGlobal, | ||
function (config, callback) { | ||
if (!config) { | ||
config = {}; | ||
} | ||
if (config.tracking) { | ||
return callback('already answered'); | ||
} | ||
return inquirer.prompt(trackingPrompt, function (answers) { | ||
if (!answers) { | ||
return callback("invalid answers from prompt"); | ||
} | ||
return metrics.setTracking(answers.tracking, callback) | ||
}); | ||
} | ||
], | ||
function (error) { | ||
if (error === 'already answered') { | ||
error = null; | ||
} | ||
return callback(error); | ||
}); | ||
}; | ||
/** | ||
* autoupdate | ||
@@ -26,36 +57,17 @@ * check for update and execute if the current version in package.json is behind the latest version published in npm | ||
*/ | ||
function checkTracking(callback) { | ||
async.waterfall([ | ||
storage.getGlobal, | ||
function (config, done) { | ||
if (config.tracking !== undefined) { | ||
return done('already answered'); | ||
} | ||
return inquirer.prompt(trackingPrompt, function (answers) { | ||
return metrics.setTracking(answers.tracking, done) | ||
}); | ||
} | ||
], function (err) { | ||
if (err === 'already answered') return callback(null); | ||
return callback(err); | ||
}); | ||
} | ||
var autoupdate = function (callback) { | ||
var current = pkg.version; | ||
checkTracking(function (err) { | ||
if (err) return callback(err); | ||
checkTracking(function (error) { | ||
if (error) { | ||
return callback(error); | ||
} | ||
ver('famous-cli', function(err, version) { | ||
if (current < version) { | ||
console.log(chalk.bold('Famous'), 'CLI version', current, 'is out of date.', 'Updating to', version); | ||
return update(callback); | ||
} | ||
return callback(); | ||
}); | ||
ver('famous-cli', function(err, version) { | ||
if (current < version) { | ||
console.log(chalk.bold('Famous'), 'CLI version', current, 'is out of date.', 'Updating to', version); | ||
return update(callback); | ||
} | ||
return callback(); | ||
}); | ||
}); | ||
@@ -62,0 +74,0 @@ }; |
@@ -5,3 +5,3 @@ 'use strict' | ||
var path = require('path'); | ||
var spawn = require('child_process').spawn; | ||
var spawn = require('win-spawn'); | ||
var chalk = require('chalk'); | ||
@@ -8,0 +8,0 @@ |
@@ -20,2 +20,3 @@ 'use strict'; | ||
var config = require('../../res/sdk-bundle.js').config; | ||
var file = require('../util/file'); | ||
@@ -42,2 +43,10 @@ | ||
}, | ||
function(files, callback) { | ||
file.getTotalSizeInBytes(files, function(err, size) { | ||
if (err || size > 75000000) { | ||
return callback(new Error('space-limt'), { status: 666, errors: ['Your project must be less than 75MB'] }) | ||
} | ||
return callback(null, files) | ||
}); | ||
}, | ||
// Turn the files into a manifest object | ||
@@ -44,0 +53,0 @@ function(files, callback) { |
'use strict'; | ||
var spawn = require('child_process').spawn; | ||
var spawn = require('win-spawn'); | ||
var fs = require('fs'); | ||
@@ -5,0 +5,0 @@ var path = require('path'); |
{ | ||
"name": "famous-cli", | ||
"version": "0.2.7", | ||
"description": "CLI interface for Famous Industries Web Services", | ||
"main": "index.js", | ||
"repository": "https://github.famo.us/hub/famous-cli.git", | ||
"preferGlobal": "true", | ||
"bin": { | ||
"famous": "bin/famous.js" | ||
}, | ||
"scripts": { | ||
"test": "tap spec", | ||
"name": "famous-cli", | ||
"version": "0.2.8", | ||
"description": "CLI interface for Famous Industries Web Services", | ||
"main": "index.js", | ||
"repository": "https://github.famo.us/hub/famous-cli.git", | ||
"preferGlobal": "true", | ||
"bin": { | ||
"famous": "bin/famous.js" | ||
}, | ||
"scripts": { | ||
"test": "tap spec", | ||
"lint": "eslint bin/ lib/", | ||
@@ -38,3 +38,4 @@ "debug": "node --debug server.js" | ||
"recursive-readdir": "1.2.1", | ||
"tar": "^2.1.1" | ||
"tar": "^2.1.1", | ||
"win-spawn": "^2.0.0" | ||
}, | ||
@@ -45,4 +46,4 @@ "devDependencies": { | ||
"sinon": "1.14.1", | ||
"tap": "0.7.1" | ||
"tap": "1.1.4" | ||
} | ||
} |
@@ -26,3 +26,3 @@ var test = require('tap').test; | ||
t.plan(3); | ||
t.plan(5); | ||
@@ -35,6 +35,8 @@ t.type(autoupdate, 'function', 'autoupdate module should export a function'); | ||
autoupdate.__set__('update', sinon.stub().callsArgWith(0, 0)); | ||
var reset = autoupdate.__set__('checkTracking', sinon.stub().callsArgWith(0,null)); | ||
autoupdate(function(code) { | ||
t.ok(true, "calling autoupdate should execute the provided callback"); | ||
t.equal(code, 0, "autoupdate return code should match expectation (pass)"); | ||
t.ok(!code, "autoupdate return code should match expectation (pass)"); | ||
reset(); | ||
}); | ||
@@ -52,2 +54,60 @@ }); | ||
}); | ||
// checktracking, returns garbage from global config | ||
t.test(function(t) { | ||
var autoupdate = rewire('../../lib/autoupdate'); | ||
var storageMock = { | ||
getGlobal: sinon.stub().callsArgWith(0, null, null) | ||
} | ||
var metricsMock = { | ||
setTracking: sinon.stub().callsArgWith(1, null) | ||
} | ||
var inquirerMock = { | ||
prompt: sinon.stub().callsArgWith(1, {tracking:false}) | ||
} | ||
t.plan(4); | ||
autoupdate.__set__('storage', storageMock); | ||
autoupdate.__set__('inquirer', inquirerMock); | ||
autoupdate.__set__('metrics', metricsMock); | ||
checkTracking = autoupdate.__get__('checkTracking'); | ||
checkTracking(function (error) { | ||
t.ok(true, "callback provided to autoupdate should be executed"); | ||
t.ok(storageMock.getGlobal.called, "storage.getGlobal should be called as part of checkTracking"); | ||
t.ok(inquirerMock.prompt.called, "inquirer.prompt should be called as part of checkTracking if getGlobal returns non-valid data"); | ||
t.equal(error, null, "return value should be null in success case"); | ||
}); | ||
}); | ||
// checktracking | ||
t.test(function(t) { | ||
var autoupdate = rewire('../../lib/autoupdate'); | ||
var storageMock = { | ||
getGlobal: sinon.stub().callsArgWith(0, null, {}) | ||
} | ||
var metricsMock = { | ||
setTracking: sinon.stub().callsArgWith(1, null) | ||
} | ||
var inquirerMock = { | ||
prompt: sinon.stub().callsArgWith(1, {tracking:false}) | ||
} | ||
t.plan(4); | ||
autoupdate.__set__('storage', storageMock); | ||
autoupdate.__set__('inquirer', inquirerMock); | ||
autoupdate.__set__('metrics', metricsMock); | ||
checkTracking = autoupdate.__get__('checkTracking'); | ||
checkTracking(function (error) { | ||
t.ok(true, "callback provided to autoupdate should be executed"); | ||
t.ok(storageMock.getGlobal.called, "storage.getGlobal should be called as part of checkTracking"); | ||
t.ok(inquirerMock.prompt.called, "inquirer.prompt should be called as part of checkTracking if getGlobal returns non-valid data"); | ||
t.equal(error, null, "return value should be null in success case"); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4
70382
17
41
13
+ Addedwin-spawn@^2.0.0
+ Addedwin-spawn@2.0.0(transitive)