buddy-cli
Advanced tools
Comparing version 3.0.0 to 4.0.0-beta
136
index.js
@@ -1,67 +0,65 @@ | ||
var find = require('./lib/find') | ||
, program = require('commander') | ||
'use strict'; | ||
, useCli = ~require.main.filename.indexOf('buddy-cli') | ||
, builder; | ||
const find = require('./lib/find') | ||
, program = require('commander') | ||
, useCli = ~require.main.filename.indexOf('buddy-cli'); | ||
// Register for uncaught errors and clean up | ||
process.on('uncaughtException', function(err) { | ||
console.log(err.stack ? err.stack : err); | ||
// Ding! | ||
console.log('\x07'); | ||
if (builder) builder.exceptionalCleanup(); | ||
process.exit(1); | ||
process.on('uncaughtException', (err) => { | ||
console.log(err.stack ? err.stack : err); | ||
// Ding! | ||
console.log('\x07'); | ||
if (builder) builder.exceptionalCleanup(); | ||
process.exit(1); | ||
}); | ||
find(useCli, function (err, Builder, version) { | ||
if (err) throw err; | ||
find(useCli, (err, Builder, version) => { | ||
if (err) throw err; | ||
program | ||
.version(version) | ||
.usage('[options] <command> [path-to-config]') | ||
.option('-c, --compress', 'compress output for production deployment') | ||
.option('-g, --grep <pattern>', 'only run build targets matching <pattern>') | ||
.option('-i, --invert', 'inverts grep matches') | ||
.option('-L, --lazy', 'convert js modules for lazy evaluation') | ||
.option('-l, --lint', 'check output for syntax and logic errors') | ||
.option('-r, --reload', 'reload all connected live-reload clients on file change during watch [ADD-ON buddy-server]') | ||
.option('-s, --serve', 'create a webserver to serve static files during watch [ADD-ON buddy-server]') | ||
.option('-S, --script', 'run script on build completion') | ||
.option('-v, --verbose', 'print all messages for debugging'); | ||
program | ||
.version(version) | ||
.usage('[options] <command> [path-to-config]') | ||
.option('-c, --compress', 'compress output for production deployment') | ||
.option('-g, --grep <pattern>', 'only run build targets matching <pattern>') | ||
.option('-i, --invert', 'inverts grep matches') | ||
.option('-r, --reload', 'reload all connected live-reload clients on file change during watch [ADD-ON buddy-server]') | ||
.option('-s, --serve', 'create a webserver to serve static files during watch [ADD-ON buddy-server]') | ||
.option('-S, --script', 'run script on build completion') | ||
.option('-v, --verbose', 'print all messages for debugging'); | ||
program | ||
.command('build [config]') | ||
.description('build js, css, and html sources') | ||
.action(function(config){ | ||
builder = new Builder(); | ||
builder.build(config, getOptions()); | ||
}); | ||
program | ||
.command('build [config]') | ||
.description('build js, css, and html sources') | ||
.action((config) => { | ||
(new Builder()).build(config, getOptions()); | ||
}); | ||
program | ||
.command('watch [config]') | ||
.description('watch js, css, html source files and build changes') | ||
.action(function(config){ | ||
var opts = getOptions(); | ||
opts.watch = true; | ||
builder = new Builder(); | ||
builder.watch(config, opts); | ||
}); | ||
program | ||
.command('watch [config]') | ||
.description('watch js, css, html source files and build changes') | ||
.action((config) => { | ||
let options = getOptions(); | ||
program | ||
.command('deploy [config]') | ||
.description('build compressed js, css, and html sources') | ||
.action(function(config){ | ||
var opts = getOptions(); | ||
opts.deploy = true; | ||
builder = new Builder(); | ||
builder.deploy(config, opts); | ||
}); | ||
options.watch = true; | ||
(new Builder()).watch(config, options); | ||
}); | ||
program.parse(process.argv); | ||
program | ||
.command('deploy [config]') | ||
.description('build compressed js, css, and html sources') | ||
.action((config) => { | ||
const options = getOptions(); | ||
// Show help if no arguments or no command | ||
if (!program.args.length | ||
|| !program.args.filter(function (arg) { return 'string' != typeof arg }).length) { | ||
program.help(); | ||
} | ||
options.deploy = true; | ||
(new Builder()).deploy(config, options); | ||
}); | ||
program.parse(process.argv); | ||
// Show help if no arguments or no command | ||
if (!program.args.length | ||
|| !program.args.filter((arg) => { return 'string' != typeof arg }).length) { | ||
program.help(); | ||
} | ||
}); | ||
@@ -75,18 +73,14 @@ | ||
function getOptions () { | ||
var options = { | ||
compress: program.compress, | ||
deploy: false, | ||
grep: program.grep, | ||
invert: program.invert, | ||
lazy: program.lazy, | ||
lint: program.lint, | ||
reload: program.reload, | ||
// Backwards compat | ||
script: program.script || program.test, | ||
serve: program.serve, | ||
watch: false, | ||
verbose: program.verbose | ||
}; | ||
return options; | ||
return { | ||
compress: program.compress, | ||
deploy: false, | ||
grep: program.grep, | ||
invert: program.invert, | ||
reload: program.reload, | ||
// Backwards compat | ||
script: program.script || program.test, | ||
serve: program.serve, | ||
watch: false, | ||
verbose: program.verbose | ||
}; | ||
} |
'use strict'; | ||
var fs = require('fs') | ||
, path = require('path') | ||
, walk = require('recur-fs').walk; | ||
const fs = require('fs') | ||
, path = require('path') | ||
, walk = require('recur-fs').walk; | ||
@@ -13,47 +13,47 @@ /** | ||
module.exports = function find (useCli, fn) { | ||
function load (buddy) { | ||
try { | ||
var Builder = require(buddy) | ||
// Get version number | ||
, version = require(path.join(buddy, 'package.json')).version; | ||
function load (buddy) { | ||
try { | ||
const Builder = require(buddy) | ||
// Get version number | ||
, version = require(path.join(buddy, 'package.json')).version; | ||
fn(null, Builder, version); | ||
} catch (err) { | ||
if (err.message == 'missing path') { | ||
fn(new Error(useCli ? 'a local version of buddy wasn\'t found on this path' : 'buddy(1) tool not found')); | ||
} else { | ||
fn(err); | ||
} | ||
} | ||
} | ||
fn(null, Builder, version); | ||
} catch (err) { | ||
if (err.message == 'missing path') { | ||
fn(new Error(useCli ? 'a local version of buddy wasn\'t found on this path' : 'buddy(1) tool not found')); | ||
} else { | ||
fn(err); | ||
} | ||
} | ||
} | ||
// Loaded via buddy-cli | ||
if (useCli) { | ||
var stop = false | ||
, buddy; | ||
// Loaded via buddy-cli | ||
if (useCli) { | ||
let stop = false | ||
, buddy; | ||
walk(process.cwd(), function (resource, stat, next) { | ||
if (stat.isDirectory()) { | ||
if (path.basename(resource) == 'buddy') { | ||
buddy = resource; | ||
stop = true; | ||
} else if (path.basename(resource) == 'node_modules') { | ||
resource = path.join(resource, 'buddy'); | ||
if (fs.existsSync(resource)) { | ||
buddy = resource; | ||
stop = true; | ||
} | ||
} | ||
} | ||
next(stop); | ||
}, function (err) { | ||
if (err) return fn(err); | ||
load(buddy); | ||
}); | ||
walk(process.cwd(), (resource, stat, next) => { | ||
if (stat.isDirectory()) { | ||
if (path.basename(resource) == 'buddy') { | ||
buddy = resource; | ||
stop = true; | ||
} else if (path.basename(resource) == 'node_modules') { | ||
resource = path.join(resource, 'buddy'); | ||
if (fs.existsSync(resource)) { | ||
buddy = resource; | ||
stop = true; | ||
} | ||
} | ||
} | ||
next(stop); | ||
}, (err) => { | ||
if (err) return fn(err); | ||
load(buddy); | ||
}); | ||
// Loaded as buddy dependency | ||
} else { | ||
// main is buddy/bin/buddy | ||
load(path.join(path.dirname(require.main.filename), '..')); | ||
} | ||
// Loaded as buddy dependency | ||
} else { | ||
// main is buddy/bin/buddy | ||
load(path.join(path.dirname(require.main.filename), '..')); | ||
} | ||
} |
{ | ||
"name": "buddy-cli", | ||
"version": "3.0.0", | ||
"version": "4.0.0-beta", | ||
"description": "The command-line bootstrapper for buddy", | ||
@@ -8,8 +8,7 @@ "author": "popeindustries <alex@pope-industries.com>", | ||
"dependencies": { | ||
"commander": "2.8.1", | ||
"promptly": "0.2.1", | ||
"commander": "2.9.0", | ||
"recur-fs": "2.2.x" | ||
}, | ||
"devDependencies": { | ||
"should": "3.3.2", | ||
"expect.js": "*", | ||
"mocha": "*" | ||
@@ -22,12 +21,11 @@ }, | ||
"engines": { | ||
"node": ">=0.10.0" | ||
"node": ">=4.0.0" | ||
}, | ||
"scripts": { | ||
"test": "NODE_ENV=test mocha --reporter spec --require should", | ||
"test-windows": "set NODE_ENV=test&&node.exe ./node_modules/mocha/bin/mocha --reporter spec --require should" | ||
"test": "NODE_ENV=test mocha --reporter spec", | ||
"test-windows": "set NODE_ENV=test&&node.exe ./node_modules/mocha/bin/mocha --reporter spec" | ||
}, | ||
"repository": "https://github.com/popeindustries/buddy-cli.git", | ||
"readmeFilename": "README.md", | ||
"readme": "[![NPM Version](https://img.shields.io/npm/v/buddy-cli.svg?style=flat)](https://npmjs.org/package/buddy-cli)\n\n# buddy-cli\n\nThe **buddy-cli** allows local versions of the **buddy** command to be run directly from the command line without any additional setup. This allows different versions of the **buddy** tool to be run from different projects, without any conflict.\n\n## Installation\n\n```bash\n# If necessary, first uninstall your existing buddy global install\n$ npm -g uninstall buddy\n\n$ npm -g install buddy-cli\n```\n\n## Usage\n\n```text\nUsage: buddy [options] <command> [path/to/package.json || path/to/buddy.js || path/to/buddy.json]\n\nCommands:\n\n build [config] build js and css sources\n watch [config] watch js and css source files and build changes\n deploy [config] build compressed js and css sources\n\nOptions:\n\n -h, --help output usage information\n -V, --version output the version number\n -t, --targets [types] optional comma separated list of target(s) to build [js,css,html]\n -c, --compress compress output for production deployment\n -l, --lint check output for syntax and logic errors\n -r, --reload reload all connected live-reload clients on file change during watch [ADD-ON buddy-server]\n -s, --serve create a webserver to serve static files during watch [ADD-ON buddy-server]\n -S, --script run script on build completion\n -L, --lazy convert js modules for lazy evaluation\n -v, --verbose print all messages for debugging\n```\n\nOnce installed, run **buddy** as described [here](https://github.com/popeindustries/buddy#readme)\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2011-2015 Pope-Industries <alex@pope-industries.com>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n", | ||
"license": "MIT" | ||
} |
@@ -33,22 +33,8 @@ [![NPM Version](https://img.shields.io/npm/v/buddy-cli.svg?style=flat)](https://npmjs.org/package/buddy-cli) | ||
-c, --compress compress output for production deployment | ||
-l, --lint check output for syntax and logic errors | ||
-r, --reload reload all connected live-reload clients on file change during watch [ADD-ON buddy-server] | ||
-s, --serve create a webserver to serve static files during watch [ADD-ON buddy-server] | ||
-S, --script run script on build completion | ||
-L, --lazy convert js modules for lazy evaluation | ||
-v, --verbose print all messages for debugging | ||
``` | ||
Once installed, run **buddy** as described [here](https://github.com/popeindustries/buddy#readme) | ||
## License | ||
(The MIT License) | ||
Copyright (c) 2011-2015 Pope-Industries <alex@pope-industries.com> | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
Once installed, run **buddy** as described [here](https://github.com/popeindustries/buddy#readme) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
2
7384
121
2
39
+ Addedcommander@2.9.0(transitive)
- Removedpromptly@0.2.1
- Removedcommander@2.8.1(transitive)
- Removedmute-stream@0.0.8(transitive)
- Removedpromptly@0.2.1(transitive)
- Removedread@1.0.7(transitive)
Updatedcommander@2.9.0