Socket
Socket
Sign inDemoInstall

buddy

Package Overview
Dependencies
157
Maintainers
1
Versions
180
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.6.5 to 0.6.6

lib/utils/livereload.js

61

lib/builder.js

@@ -106,3 +106,3 @@ // Generated by CoffeeScript 1.4.0

_this.targets[type] = instances;
return _this._buildTargets(type, compress, lint, function(err) {
return _this._buildTargets(type, compress, lint, false, function(err) {
if (err) {

@@ -132,3 +132,7 @@ return cb(err);

if (test && _this.config.settings.test) {
return _this._executeTest();
return _this._executeTest(function(err) {
if (err) {
return error(err, 2);
}
});
}

@@ -139,3 +143,3 @@ });

Builder.prototype.watch = function(configpath, compress, test, verbose) {
Builder.prototype.watch = function(configpath, compress, reload, test, verbose) {
var _this = this;

@@ -151,14 +155,23 @@ return this.build(configpath, compress, false, test, verbose, function(err) {

if (source) {
return source.watch(function(err, file) {
return source.watch(reload, function(err, file) {
if (err) {
error(err, 2, false);
return error(err, 2, false);
} else {
start = new Date();
file.content = '';
return _this._buildTargets(source.type, compress, false, reload, function(err) {
if (err) {
return error(err, 2, false);
} else {
print("completed build in " + (colour((+(new Date) - start) / 1000 + 's', notify.CYAN)), 3);
if (test && _this.config.settings.test) {
return _this._executeTest(function(err) {
if (err) {
return error(err, 2);
}
});
}
}
});
}
return _this._buildTargets(source.type, compress, false, function(err) {
if (err) {
error(err, 2, false);
}
if (test && _this.config.settings.test) {
return _this._executeTest();
}
});
});

@@ -212,3 +225,3 @@ }

filelog.load(function() {});
return processors.load(_this.config.settings && _this.config.settings.processors, function(err, installed) {
processors.load(_this.config.settings && _this.config.settings.processors, function(err, installed) {
if (err) {

@@ -221,2 +234,10 @@ return fn(err);

});
return process.on('uncaughtException', function(err) {
dependencies.clean();
return [_this.sources.js, _this.sources.css].forEach(function(source) {
if (source) {
return source.clean();
}
});
});
});

@@ -266,3 +287,3 @@ } else {

Builder.prototype._buildTargets = function(type, compress, lint, fn) {
Builder.prototype._buildTargets = function(type, compress, lint, reload, fn) {
var _this = this;

@@ -279,2 +300,5 @@ debug('BUILD', 1);

}
if (reload) {
target.source.refresh(path.basename(files[0]));
}
return cb();

@@ -290,3 +314,3 @@ });

Builder.prototype._executeTest = function() {
Builder.prototype._executeTest = function(fn) {
print('executing test script...', 2);

@@ -296,6 +320,7 @@ debug("execute: " + (strong(this.config.settings.test)), 3);

if (err) {
error(err, 2);
return fn(err);
}
stdout && console.log(stdout);
return stderr && console.log(stderr);
stderr && console.log(stderr);
return fn();
});

@@ -302,0 +327,0 @@ };

@@ -31,7 +31,2 @@ // Generated by CoffeeScript 1.4.0

process.on('uncaughtException', function(err) {
_clear();
throw err;
});
exports.install = function(options, fn) {

@@ -72,2 +67,6 @@ var data, destination,

exports.clean = function() {
return _clear();
};
_installDependency = function(dependency, fn) {

@@ -74,0 +73,0 @@ return dependency.install(function(err, dependencies) {

// Generated by CoffeeScript 1.4.0
var Source, Watcher, colour, debug, existsSync, file, ignored, indir, notify, path, print, readdir, strong, _ref, _ref1;
var Source, Watcher, colour, debug, existsSync, file, ignored, indir, notify, path, print, readdir, reloader, strong, _ref, _ref1;

@@ -8,2 +8,4 @@ path = require('path');

reloader = require('../utils/reloader');
Watcher = require('../utils/watcher');

@@ -25,2 +27,3 @@

this._watchers = [];
this.reload = false;
this.byPath = {};

@@ -85,7 +88,8 @@ this.byModule = {};

Source.prototype.watch = function(fn) {
Source.prototype.watch = function(reload, fn) {
var _this = this;
this.reload = reload;
return this.locations.forEach(function(location) {
var watcher;
print("watching [" + (strong(path.relative(process.cwd(), location))) + "]...", 3);
print("watching " + (strong(path.relative(process.cwd(), location))) + "...", 3);
_this._watchers.push(watcher = new Watcher(ignored));

@@ -103,3 +107,2 @@ watcher.on('create', function(filepath, stats) {

file = _this.byPath[filepath];
file.content = '';
return fn(null, file);

@@ -110,6 +113,21 @@ });

});
return watcher.watch(location);
watcher.watch(location);
if (_this.reload) {
return reloader.start('com.popeindustries.buddy', 'buddy', '1.0', function(err) {
return fn(err);
});
}
});
};
Source.prototype.refresh = function(file) {
if (this.reload) {
return reloader.refresh(file);
}
};
Source.prototype.clean = function() {
return reloader.stop();
};
Source.prototype._getBasepath = function(filepath) {

@@ -116,0 +134,0 @@ var location, _i, _len, _ref2;

@@ -59,3 +59,2 @@ // Generated by CoffeeScript 1.4.0

this.isDir = isDir;
this.options = options;
this.processors = processors;

@@ -74,10 +73,13 @@ this._write = __bind(this._write, this);

debug("created " + this.type + " Target instance with input: " + (strong(this.options.input)) + " and output: " + (strong(this.options.output)), 2);
this.input = path.resolve(this.options.input);
this.output = path.resolve(this.options.output);
debug("created " + this.type + " Target instance with input: " + (strong(options.input)) + " and output: " + (strong(options.output)), 2);
this.input = path.resolve(options.input);
this.output = path.resolve(options.output);
this.source = options.source;
this.modular = options.modular;
this.sources = [];
this.files = [];
this._modified = [];
this.hasChildren = !!this.options.targets;
this.hasParent = !!this.options.parent;
this.parent = options.parent;
this.hasChildren = !!options.targets;
this.hasParent = !!this.parent;
this.watching = false;

@@ -88,3 +90,3 @@ this.compress = false;

if (!this.isDir) {
this.concat = this.options.modular;
this.concat = this.modular;
if (!path.extname(this.output).length) {

@@ -106,3 +108,3 @@ this.output = path.join(this.output, path.basename(this.input)).replace(path.extname(this.input), "." + this.type);

if (!this.watching) {
print("building " + (strong(path.basename(this.options.input))) + " to " + (strong(path.basename(this.options.output))), 2);
print("building " + (strong(path.basename(this.input))) + " to " + (strong(path.basename(this.output))), 2);
}

@@ -121,3 +123,3 @@ return this._parse(function(err) {

} else {
warn("no sources to build in " + (strong(_this.options.input)), 3);
warn("no sources to build in " + (strong(_this.input)), 3);
return fn(null, _this.files);

@@ -129,3 +131,3 @@ }

Target.prototype.hasSource = function(file) {
return __indexOf.call(this.sources, file) >= 0 || this.hasParent && this.options.parent.hasSource(file);
return __indexOf.call(this.sources, file) >= 0 || this.hasParent && this.parent.hasSource(file);
};

@@ -139,3 +141,3 @@

if (this.hasParent) {
return this.options.parent.reset();
return this.parent.reset();
}

@@ -157,3 +159,3 @@ };

var dep;
if (dep = _this.options.source.byModule[dependency] || _this.options.source.byModule["" + dependency + "/index"]) {
if (dep = _this.source.byModule[dependency] || _this.source.byModule["" + dependency + "/index"]) {
if (!dep.isDependency) {

@@ -181,3 +183,3 @@ _this._modified.push(dep);

var file;
if (file = _this.options.source.byPath[filepath]) {
if (file = _this.source.byPath[filepath]) {
if (!_this.hasSource(file)) {

@@ -206,3 +208,3 @@ _this.sources.push(file);

} else {
if (file = this.options.source.byPath[this.input]) {
if (file = this.source.byPath[this.input]) {
if (!this.hasSource(file)) {

@@ -224,5 +226,5 @@ this.sources.push(file);

content = file.module.concat(file);
debug("concat: " + (strong(path.relative(process.cwd(), file.filepath))), 3);
debug("concatenated: " + (strong(path.relative(process.cwd(), file.filepath))), 3);
} else {
content = this.options.modular ? file.module.wrapModuleContents(file.content, file.moduleID) : file.content;
content = this.modular ? file.module.wrapModuleContents(file.content, file.moduleID) : file.content;
}

@@ -258,3 +260,23 @@ filepath = path.extname(this.output).length ? this.output : path.join(this.output, file.qualifiedName) + '.' + this.type;

Target.prototype._lint = function(content, filepath, fn) {
return fn(null, content, filepath);
var _this = this;
if (this.lint && this.processors.linter) {
return this.processors.linter.lint(content, function(err) {
if (err) {
warn('failed linting', 3);
err.items.forEach(function(item) {
if (item) {
print("[" + (colour(item.line, notify.CYAN)) + ":" + (colour(item.col, notify.CYAN)) + "] " + item.reason + ":", 4);
if (item.evidence) {
return print("" + (strong(item.evidence)), 5);
}
}
});
} else {
print("" + (colour('linted', GREEN)) + " " + (strong(path.relative(process.cwd(), filepath))), 3);
}
return fn(null, content, filepath);
});
} else {
return fn(null, content, filepath);
}
};

@@ -261,0 +283,0 @@

// Generated by CoffeeScript 1.4.0
var csslint;
var RE_TRIM, csslint;
csslint = require('csslint').CSSLint;
RE_TRIM = /^\s+|\s+$/;
module.exports = {

@@ -15,6 +17,8 @@ name: 'csslint',

items = result.messages.map(function(error) {
var _ref;
return {
line: error.line,
col: error.col,
reason: error.message
reason: error.message,
evidence: (_ref = error.evidence) != null ? _ref.replace(RE_TRIM, '') : void 0
};

@@ -21,0 +25,0 @@ });

// Generated by CoffeeScript 1.4.0
var jshint;
var RE_TRIM, jshint;
jshint = require('jshint').JSHINT;
RE_TRIM = /^\s+|\s+$/;
module.exports = {

@@ -12,3 +14,3 @@ name: 'jshint',

curly: true,
eqeqeq: true,
eqeqeq: false,
immed: true,

@@ -19,21 +21,29 @@ latedef: true,

undef: true,
unused: true,
eqnull: true,
es5: true,
esnext: true,
es5: false,
esnext: false,
bitwise: true,
strict: false,
trailing: true,
trailing: false,
smarttabs: true,
node: true
node: true,
boss: true
},
lint: function(data, fn) {
var items, result;
result = jshint(data, this.options, {});
result = jshint(data, exports.options, {});
if (!result) {
items = jshint.errors.map(function(error) {
return {
line: error.line,
col: error.character,
reason: error.reason
};
var _ref;
if (error) {
return {
line: error.line,
col: error.character,
reason: error.reason,
evidence: (_ref = error.evidence) != null ? _ref.replace(RE_TRIM, '') : void 0
};
} else {
return null;
}
});

@@ -40,0 +50,0 @@ return fn({

// Generated by CoffeeScript 1.4.0
var LRServer, fs, onSocketClose, onSocketMessage, path, ready, server;
var ReloadServer, debug, fs, path, ready, server, strong, _ref;

@@ -8,4 +8,6 @@ path = require('path');

LRServer = require('livereload-server');
ReloadServer = require('./reloadserver');
_ref = require('./notify'), debug = _ref.debug, strong = _ref.strong;
server = null;

@@ -15,65 +17,47 @@

onSocketMessage = function(msg) {
return console.log(msg);
exports.start = function() {
if (!server) {
server = new ReloadServer();
server.on('connected', function(connection) {
return debug("live-reload client connected: " + connection.id, 4);
});
server.on('disconnected', function(connection) {
return debug("live-reload client disconnected: " + connection.id, 4);
});
server.on('command', function(message) {
return debug("received live-reload command '" + message.command + "': " + message.url, 4);
});
server.on('error', function(err) {
return fn(err);
});
return server.listen(function(err) {
if (!err) {
debug("started live-reload server on port: " + server.port, 3);
return ready = true;
}
});
}
};
onSocketClose = function() {
return console.log('closed');
exports.stop = function() {
if (server) {
server.close();
server = null;
return ready = false;
}
};
exports.start = function(options) {
server = new LRServer({
id: "com.example.acme",
name: "Acme",
version: "1.0",
protocols: {
monitoring: 7,
saving: 1
}
});
server.on('connected', function(connection) {
return console.log("Client connected (%s)", connection.id);
});
server.on('disconnected', function(connection) {
return console.log("Client disconnected (%s)", connection.id);
});
server.on('command', function(connection, message) {
return console.log("Received command %s: %j", message.command, message);
});
server.on('error', function(err, connection) {
return console.log("Error (%s): %s", connection.id, err.message);
});
server.on('livereload.js', function(request, response) {
return fs.readFile(path.join(__dirname, 'livereload.js'), 'utf8', function(err, data) {
err && (function() {
throw err;
})();
response.writeHead(200, {
'Content-Length': data.length,
'Content-Type': 'text/javascript'
});
return response.end(data);
});
});
return server.listen(function(err) {
if (err) {
console.error("Listening failed: %s", err.message);
return;
}
console.log("Listening on port %d.", server.port);
return ready = true;
});
};
exports.refresh = function(files) {
exports.refresh = function(file) {
var msg;
console.log(files);
if (ready) {
msg = {
command: 'reload',
path: files[0],
path: file,
liveCSS: true
};
return server.emit('command', msg);
debug("sending " + (strong('reload')) + " command to live-reload clients", 4);
return server.activeConnections().forEach(function(connection) {
return connection.send(msg);
});
}
};

@@ -31,3 +31,3 @@ // Generated by CoffeeScript 1.4.0

return fs.stat(source, function(err, stats) {
var lastChange, lastSize;
var lastChange;
if (err) {

@@ -37,7 +37,6 @@ return _this.emit('error', err);

lastChange = stats.mtime.getTime();
lastSize = stats.size;
if (stats.isDirectory()) {
fs.readdir(source, function(err, files) {
if (err) {
return _this._throttleEvent('error', err);
return _this.emit('error', err);
} else {

@@ -57,3 +56,3 @@ return files.forEach(function(file) {

if (stats.isFile()) {
if (stats.mtime.getTime() !== lastChange && stats.size !== lastSize) {
if (stats.mtime.getTime() !== lastChange) {
_this._throttleEvent('change', source, stats);

@@ -60,0 +59,0 @@ }

{
"name": "buddy",
"description": "A build tool for js/css projects. Manages third-party dependencies, compiles source code, automatically modularizes js sources, statically resolves module dependencies, and lints/concatenates/compresses output.",
"version": "0.6.5",
"version": "0.6.6",
"author": "popeindustries <alex@pope-industries.com>",

@@ -22,3 +22,5 @@ "keywords": ["build", "buildtool", "modules", "javascript", "coffeescript", "css", "styus", "less"],

"semver": "1.1.1",
"async": "0.1.22"
"async": "0.1.22",
"livereload-protocol": "0.2.2",
"websocket.io": "0.2.1"
},

@@ -47,3 +49,3 @@ "devDependencies": {

"readmeFilename": "README.md",
"readme": "# buddy(1)\n\n**buddy(1)** is a build tool for js/css projects. It helps you manage third-party dependencies, compiles source code from higher order js/css languages (coffeescript/stylus/less), automatically wraps js files in module definitions, statically resolves module dependencies, and concatenates (and optionally compresses) all souces into a single file for more efficient delivery to the browser.\n\n**Current version:** 0.6.1\n*[the 0.5.x+ branch is not backwards compatible with earlier versions. See __Change Log__ below for more details]*\n\n## Installation\n\nUse the *-g* global flag to make the **buddy(1)** command available system-wide:\n\n```bash\n$ npm -g install buddy\n```\n\nOr, optionally, add **buddy** as a dependency in your project's *package.json* file:\n\n```json\n{\n \"name\": \"myproject\",\n \"description\": \"This is my web project\",\n \"version\": \"0.0.1\",\n \"dependencies\": {\n \"buddy\": \"0.5.0\"\n },\n \"scripts\": {\n \"install\": \"buddy install\",\n \"build\": \"buddy build\",\n \"deploy\": \"buddy deploy\"\n }\n}\n```\n\n...then install:\n\n```bash\n$ cd path/to/project\n$ npm install\n```\n\n## Usage\n\n```bash\n$ cd path/to/project\n\n# When buddy is installed globally:\n# install dependencies\n$ buddy install\n# build all source files\n$ buddy build\n# build and compress all source files\n$ buddy -c build\n# build and lint all source files\n$ buddy -l build\n# build all source files and execute\n# the 'test' command defined in config\n$ buddy -t build\n# build all source files with verbose notifications\n$ buddy -v build\n# watch and build on source changes\n$ buddy watch\n# build and compress for production\n$ buddy deploy\n# list all generated files\n$ buddy ls\n# remove all generated files\n$ buddy clean\n# view usage, examples, and options\n$ buddy --help\n\n# When buddy is installed locally:\n# ...if scripts parameter defined in package.json\n$ npm run-script install\n# ...if called directly\n$ ./node_modules/buddy/bin/buddy install\n```\n\n### Configuration\n\nThe only requirement for adding **buddy** support to a project is the presence of a **buddy.js** file in your project root:\n\n```js\n// Project build configuration.\nexports.build = {\n js: {\n // Directories containing potential js source files for this project.\n sources: ['a/coffeescript/source/directory', 'a/js/source/directory'],\n // One or more js build targets.\n targets: [\n {\n // An entrypoint js (or equivalent) file to be wrapped in a module definition,\n // concatenated with all it's resolved dependencies.\n input: 'a/coffeescript/or/js/file',\n // A destination in which to save the processed input.\n // If a directory is specified, the input file name will be used.\n output: 'a/js/file/or/directory',\n // Targets can have children.\n // Any sources included in the parent target will NOT be included in the child.\n targets: [\n {\n input: 'a/coffeescript/or/js/file',\n output: 'a/js/file/or/directory'\n }\n ]\n },\n {\n // Files are batch processed when a directory is used as input.\n input: 'a/coffeescript/or/js/directory',\n output: 'a/js/directory',\n // Skips module wrapping (ex: for use in server environments).\n modular: false\n }\n ]\n },\n css: {\n // Directories containing potential css source files for this project.\n sources: ['a/stylus/directory', 'a/less/directory', 'a/css/directory'],\n // One or more css build targets\n targets: [\n {\n // An entrypoint css (or equivalent) file to be processed,\n // concatenated with all it's resolved dependencies.\n input: 'a/stylus/less/or/css/file',\n // A destination in which to save the processed input.\n // If a directory is specified, the input file name will be used.\n output: 'a/css/file/or/directory'\n },\n {\n // Files are batch processed when a directory is used as input.\n input: 'a/stylus/less/or/css/directory',\n output: 'a/css/directory'\n }\n ]\n }\n}\n\n// Project dependency configuration.\nexports.dependencies = {\n // A destination directory in which to place third-party library dependencies.\n 'a/vendor/directory': {\n // An ordered list of dependencies\n sources: [\n // A github user/repo.\n // Install the 'browser-require' source when using Node-style modules.\n 'popeindustries/browser-require',\n // A named library with or without version (ex: jquery@latest, backbone, backbone@1.0.0).\n // Version identifiers follow the npm semantic versioning rules.\n 'library@version'\n ],\n // Dependencies can be packaged and minified to a destination file\n output: 'a/js/file'\n },\n // A destination directory in which to place source library dependencies.\n 'a/source/directory': {\n sources: [\n // A github user/repo.\n // Will use the 'main' or 'scripts' properties of\n // components.json or package.json to identify the file to install.\n 'username/repo',\n // A github user/repo with specific file or directory locations.\n 'username/repo#a/file/or/directory|another/file/or/directory',\n // A local file or directory to copy and install.\n 'a/file/or/directory'\n ]\n }\n}\n\n// Project settings configuration.\nexports.settings = {\n // Run a command after build\n test: 'command --flags',\n // Override the default plugins, and/or include custom plugins.\n plugins: {\n js: {\n // Append one or more js compilers to the default 'coffeescript'.\n compilers: ['a/file', 'another/file'],\n // Change the default 'uglifyjs' compressor to a custom specification.\n compressor: 'a/file',\n // Change the default 'jshint' linter to a custom specification.\n linter: 'a/file',\n // Change the default 'node' module type to 'amd' or a custom specification.\n module: 'amd'\n },\n css: {\n // Append one or more css compilers to the default 'stylus' and 'less'.\n compilers: ['a/file', 'another/file'],\n // Change the default 'cleancss' compressor to a custom specification.\n compressor: 'a/file',\n // Change the default 'csslint' linter to a custom specification.\n linter: 'a/file'\n }\n }\n}\n```\n\n## Concepts\n\n### BUILD\n\n**Project Root**: The directory from which all paths resolve to. Determined by location of the *buddy.js* configuration file.\n\n**Sources**: An array of directories from which all referenced files are retrieved from. ***Note:*** A *js* module's id is derived from it's relative path to it's source directory.\n\n**Targets**: Objects that specify the *input* and *output* files or directories for each build. Targets are built in sequence, allowing builds to be chained together. ***Note:*** A *js* target can also have nested child targets, ensuring that dependencies are not duplicated across related builds.\n\n**Target parameters**:\n\n- *input*: file or directory to build. If js (or equivalent) file, all dependencies referenced will be concatenated together for output.\nIf directory, all compileable files will be compiled, wrapped in module definitions (js), and output to individual js/css files.\n\n- *output*: file or directory to output to.\n\n- *targets*: a nested target that prevents the duplication of source code with it's parent target.\n\n- *modular*: a flag to prevent js files from being wrapped with a module definition.\n\n### MODULES\n\nEach js file is wrapped in a module declaration based on the file's location. Dependencies (and concatenation order) are determined by the use of ```require()``` statements:\n\n```javascript\nvar lib = require('./my/lib'); // in current package\nvar SomeClass = require('../someclass'); // in parent package\nvar util = require('utils/util'); // from root package\n\nlib.doSomething();\nvar something = new SomeClass();\nutil.log('hey');\n```\n\nSpecifying a module's public behaviour is achieved by decorating an ```exports``` object:\n\n```javascript\nvar myModuleVar = 'my module';\n\nexports.myModuleMethod = function() {\n return myModuleVar;\n};\n```\n\n...or overwriting the ```exports``` object completely:\n\n```javascript\nfunction MyModule() {\n this.myVar = 'my instance var';\n};\n\nMyModule.prototype.myMethod = function() {\n return this.myVar;\n};\n\nmodule.exports = MyModule;\n```\n\nEach module is provided with a ```module```, ```exports```, and ```require``` reference.\n\nWhen ```require()```-ing a module, keep in mind that the module id is resolved based on the following rules:\n\n * packages begin at the root folder specified in *buddy.js > js > sources*:\n```\n'Users/alex/project/src/package/main.js' > 'package/main'\n```\n * uppercase filenames are converted to lowercase module ids:\n```\n'my/package/Class.js' > 'my/package/class'\n```\n\nSee [node.js modules](http://nodejs.org/docs/v0.8.0/api/modules.html) for more info on modules.\n\n***NOTE***: ```require``` boilerplate needs to be included on the page to enable module loading. It's recommended to ```install``` a library like *popeindustries/browser-require*.\n\n### DEPENDENCIES\n\nDependency resources are installed from local locations or remotely from Github.\n\n**Sources**: An array of local or remote resource locations.\n\n- **destination**: each group of sources will be installed to the project relative location specified.\n\n- **identifier**: github ```username/repo``` identifiers are preferred, but it is also possible to use identifiers from the [bower](https://github.com/twitter/bower) package manager: ```'jquery', 'backbone', 'underscore'```\n\n- **versioning**: github sources can specify a version by appending ```@``` and a npm-style symantic version: ```'*', '1.2.3', '1.x', '~1.2.0', '>=1.2.3'```\n\n- **resources**: specific resources can be specified by appending ```#``` and a list of ```|``` separated relative file or directory locations: ```'username/repo#a/file/or/directory|another/file/or/directory'```\n\n**Output**: A file destination to concatenate and compress the source contents. The order of *sources* determines the content order.\n\n## Examples\n\nCopy project boilerplate from a local directory:\n\n```js\nexports.dependencies = {\n '.': {\n sources: ['../../boilerplate/project']\n }\n}\n```\n\nGrab js dependencies to be installed and packaged for inclusion in html:\n\n```js\nexports.dependencies = {\n // install location\n 'libs/vendor': {\n sources: [\n // library for require boilerplate\n 'popeindustries/browser-require',\n // jquery at specific version\n 'jquery@1.8.2'\n ],\n // packaged and compressed\n output: 'www/assets/js/libs.js'\n }\n}\n```\n\nGrab sources to be referenced in your builds:\n\n```js\nexports.dependencies = {\n // install location\n 'libs/src/css': {\n sources: [\n // reference the lib/nib directory for installation\n 'visionmedia/nib#lib/nib'\n ]\n }\n}\n```\n\nCompile a library, then reference some library files in your project:\n\n```js\nexports.build = {\n js: {\n sources: ['libs/src/coffee', 'libs/js', 'src'],\n targets: [\n {\n // a folder of coffee files (including nested folders)\n input: 'libs/src/coffee',\n // a folder of compiled js files\n output: 'libs/js'\n },\n {\n // the application entry point referencing library dependencies\n input: 'src/main.js',\n // a concatenation of referenced dependencies\n output: 'js/main.js'\n }\n ]\n }\n}\n```\n\nCompile a site with an additional widget using shared sources:\n\n```js\nexports.build = {\n js: {\n sources: ['src/coffee'],\n targets: [\n {\n // the application entry point\n input: 'src/coffee/main.coffee',\n // output to main.js (includes all referenced dependencies)\n output: 'js',\n targets: [\n {\n // references some of the same sources as main.coffee\n input: 'src/coffee/widget.coffee',\n // includes only referenced dependencies not in main.js\n output: 'js'\n }\n ]\n }\n ]\n }\n}\n```\n\n## Changelog\n\n**0.6.5** - December 5, 2012\n* fix for *watch* command firing repeated change events\n* fix for *watch* command not properly building targets on change\n* fix for child target building shared resources\n\n**0.6.4** - December 4, 2012\n* fix for *--test* not displaying both stdout and stderr\n* added wrapping of batch files in module definitions if *options.modular* is not false\n* fix for building targets that contain no source\n\n**0.6.3** - December 4, 2012\n* fix for *watch* command attempting to watch a source that doesn't exist\n* added support for default json config file type\n\n**0.6.2** - December 4, 2012\n* fix for css '@import' inlining\n\n**0.6.1** - December 3, 2012\n* added *--test* to watch command\n\n**0.6.0** - December 3, 2012\n* complete rewrite for async file operations\n* added *--test* flag for executing a command after build\n* added *--verbose* flag for outputting detailed notifications during build\n* added *ls* command to list all generated files\n* simplified dependency resource parsing on install; only parse 'main' field in component.json/package.json\n\n**0.5.4** - November 23, 2012\n* regression fix for *clean* command\n* improved *.buddy-filelog* force clean\n* improved notifications for *install* and *clean* commands\n\n**0.5.3** - November 23, 2012\n* refactored *install* command behaviour; no longer uses git operations, changed syntax for specifying version ('@') and resources ('#'), added ability to list several resources **[breaking change]**\n* *.buddy-filelog* now stores relative paths for compatibility on different systems\n* file deletions limited to resources under the project root\n\n**0.5.2** - Novemver 20, 2012\n* added *watch* command; handle add, remove, and change of source files\n\n**0.5.1** - Novemver 14, 2012\n* added *clean* command to remove all generated files\n* added hidden *.buddy-filelog* file for tracking files changes between sessions\n* fix for false-negative module wrapping test\n\n**0.5.0** - November 13, 2012\n* *compile* command renamed to *build* **[breaking change]**\n* changed module naming for compatibility with recent versions of Node.js (camel case no longer converted to underscores) **[breaking change]**\n* changed configuration file type to 'js' from 'json'; added *dependencies* and *settings* **[breaking change]**\n* changed configuration *target* parameters to *input/output* from *in/out* **[breaking change]**\n* changed configuration *target* parameter to *modular* from *nodejs* **[breaking change]**\n* concatenated js modules no longer self-booting; need to ```require('main');``` manually **[breaking change]**\n* *require* boilerplate no longer included in generated source; install *git://github.com/popeindustries/browser-require.git* or equivalent **[breaking change]**\n* removed *watch* command (temporarily) **[breaking change]**\n* added *install* command and project dependency management\n* added plugin support for compilers, compressors, linters, and modules; added support for custom plugins\n* added code linting\n* all errors now throw\n* complete code base refactor\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2011 Pope-Industries &lt;alex@pope-industries.com&gt;\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."
"readme": "# buddy(1)\n\n**buddy(1)** is a build tool for js/css projects. It helps you manage third-party dependencies, compiles source code from higher order js/css languages (coffeescript/stylus/less), automatically wraps js files in module definitions, statically resolves module dependencies, and concatenates (and optionally compresses) all souces into a single file for more efficient delivery to the browser.\n\n**Current version:** 0.6.1\n*[the 0.5.x+ branch is not backwards compatible with earlier versions. See __Change Log__ below for more details]*\n\n## Installation\n\nUse the *-g* global flag to make the **buddy(1)** command available system-wide:\n\n```bash\n$ npm -g install buddy\n```\n\nOr, optionally, add **buddy** as a dependency in your project's *package.json* file:\n\n```json\n{\n \"name\": \"myproject\",\n \"description\": \"This is my web project\",\n \"version\": \"0.0.1\",\n \"dependencies\": {\n \"buddy\": \"0.5.0\"\n },\n \"scripts\": {\n \"install\": \"buddy install\",\n \"build\": \"buddy build\",\n \"deploy\": \"buddy deploy\"\n }\n}\n```\n\n...then install:\n\n```bash\n$ cd path/to/project\n$ npm install\n```\n\n## Usage\n\n```bash\n$ cd path/to/project\n\n# When buddy is installed globally:\n# install dependencies\n$ buddy install\n# build all source files\n$ buddy build\n# build and compress all source files\n$ buddy -c build\n# build and lint all source files\n$ buddy -l build\n# build all source files and execute\n# the 'test' command defined in config\n$ buddy -t build\n# build all source files with verbose notifications\n$ buddy -v build\n# watch and build on source changes\n$ buddy watch\n# build and compress for production\n$ buddy deploy\n# list all generated files\n$ buddy ls\n# remove all generated files\n$ buddy clean\n# view usage, examples, and options\n$ buddy --help\n\n# When buddy is installed locally:\n# ...if scripts parameter defined in package.json\n$ npm run-script install\n# ...if called directly\n$ ./node_modules/buddy/bin/buddy install\n```\n\n### Configuration\n\nThe only requirement for adding **buddy** support to a project is the presence of a **buddy.js** file in your project root:\n\n```js\n// Project build configuration.\nexports.build = {\n js: {\n // Directories containing potential js source files for this project.\n sources: ['a/coffeescript/source/directory', 'a/js/source/directory'],\n // One or more js build targets.\n targets: [\n {\n // An entrypoint js (or equivalent) file to be wrapped in a module definition,\n // concatenated with all it's resolved dependencies.\n input: 'a/coffeescript/or/js/file',\n // A destination in which to save the processed input.\n // If a directory is specified, the input file name will be used.\n output: 'a/js/file/or/directory',\n // Targets can have children.\n // Any sources included in the parent target will NOT be included in the child.\n targets: [\n {\n input: 'a/coffeescript/or/js/file',\n output: 'a/js/file/or/directory'\n }\n ]\n },\n {\n // Files are batch processed when a directory is used as input.\n input: 'a/coffeescript/or/js/directory',\n output: 'a/js/directory',\n // Skips module wrapping (ex: for use in server environments).\n modular: false\n }\n ]\n },\n css: {\n // Directories containing potential css source files for this project.\n sources: ['a/stylus/directory', 'a/less/directory', 'a/css/directory'],\n // One or more css build targets\n targets: [\n {\n // An entrypoint css (or equivalent) file to be processed,\n // concatenated with all it's resolved dependencies.\n input: 'a/stylus/less/or/css/file',\n // A destination in which to save the processed input.\n // If a directory is specified, the input file name will be used.\n output: 'a/css/file/or/directory'\n },\n {\n // Files are batch processed when a directory is used as input.\n input: 'a/stylus/less/or/css/directory',\n output: 'a/css/directory'\n }\n ]\n }\n}\n\n// Project dependency configuration.\nexports.dependencies = {\n // A destination directory in which to place third-party library dependencies.\n 'a/vendor/directory': {\n // An ordered list of dependencies\n sources: [\n // A github user/repo.\n // Install the 'browser-require' source when using Node-style modules.\n 'popeindustries/browser-require',\n // A named library with or without version (ex: jquery@latest, backbone, backbone@1.0.0).\n // Version identifiers follow the npm semantic versioning rules.\n 'library@version'\n ],\n // Dependencies can be packaged and minified to a destination file\n output: 'a/js/file'\n },\n // A destination directory in which to place source library dependencies.\n 'a/source/directory': {\n sources: [\n // A github user/repo.\n // Will use the 'main' or 'scripts' properties of\n // components.json or package.json to identify the file to install.\n 'username/repo',\n // A github user/repo with specific file or directory locations.\n 'username/repo#a/file/or/directory|another/file/or/directory',\n // A local file or directory to copy and install.\n 'a/file/or/directory'\n ]\n }\n}\n\n// Project settings configuration.\nexports.settings = {\n // Run a command after build\n test: 'command --flags',\n // Override the default plugins, and/or include custom plugins.\n plugins: {\n js: {\n // Append one or more js compilers to the default 'coffeescript'.\n compilers: ['a/file', 'another/file'],\n // Change the default 'uglifyjs' compressor to a custom specification.\n compressor: 'a/file',\n // Change the default 'jshint' linter to a custom specification.\n linter: 'a/file',\n // Change the default 'node' module type to 'amd' or a custom specification.\n module: 'amd'\n },\n css: {\n // Append one or more css compilers to the default 'stylus' and 'less'.\n compilers: ['a/file', 'another/file'],\n // Change the default 'cleancss' compressor to a custom specification.\n compressor: 'a/file',\n // Change the default 'csslint' linter to a custom specification.\n linter: 'a/file'\n }\n }\n}\n```\n\n## Concepts\n\n### BUILD\n\n**Project Root**: The directory from which all paths resolve to. Determined by location of the *buddy.js* configuration file.\n\n**Sources**: An array of directories from which all referenced files are retrieved from. ***Note:*** A *js* module's id is derived from it's relative path to it's source directory.\n\n**Targets**: Objects that specify the *input* and *output* files or directories for each build. Targets are built in sequence, allowing builds to be chained together. ***Note:*** A *js* target can also have nested child targets, ensuring that dependencies are not duplicated across related builds.\n\n**Target parameters**:\n\n- *input*: file or directory to build. If js (or equivalent) file, all dependencies referenced will be concatenated together for output.\nIf directory, all compileable files will be compiled, wrapped in module definitions (js), and output to individual js/css files.\n\n- *output*: file or directory to output to.\n\n- *targets*: a nested target that prevents the duplication of source code with it's parent target.\n\n- *modular*: a flag to prevent js files from being wrapped with a module definition.\n\n### MODULES\n\nEach js file is wrapped in a module declaration based on the file's location. Dependencies (and concatenation order) are determined by the use of ```require()``` statements:\n\n```javascript\nvar lib = require('./my/lib'); // in current package\nvar SomeClass = require('../someclass'); // in parent package\nvar util = require('utils/util'); // from root package\n\nlib.doSomething();\nvar something = new SomeClass();\nutil.log('hey');\n```\n\nSpecifying a module's public behaviour is achieved by decorating an ```exports``` object:\n\n```javascript\nvar myModuleVar = 'my module';\n\nexports.myModuleMethod = function() {\n return myModuleVar;\n};\n```\n\n...or overwriting the ```exports``` object completely:\n\n```javascript\nfunction MyModule() {\n this.myVar = 'my instance var';\n};\n\nMyModule.prototype.myMethod = function() {\n return this.myVar;\n};\n\nmodule.exports = MyModule;\n```\n\nEach module is provided with a ```module```, ```exports```, and ```require``` reference.\n\nWhen ```require()```-ing a module, keep in mind that the module id is resolved based on the following rules:\n\n * packages begin at the root folder specified in *buddy.js > js > sources*:\n```\n'Users/alex/project/src/package/main.js' > 'package/main'\n```\n * uppercase filenames are converted to lowercase module ids:\n```\n'my/package/Class.js' > 'my/package/class'\n```\n\nSee [node.js modules](http://nodejs.org/docs/v0.8.0/api/modules.html) for more info on modules.\n\n***NOTE***: ```require``` boilerplate needs to be included on the page to enable module loading. It's recommended to ```install``` a library like *popeindustries/browser-require*.\n\n### DEPENDENCIES\n\nDependency resources are installed from local locations or remotely from Github.\n\n**Sources**: An array of local or remote resource locations.\n\n- **destination**: each group of sources will be installed to the project relative location specified.\n\n- **identifier**: github ```username/repo``` identifiers are preferred, but it is also possible to use identifiers from the [bower](https://github.com/twitter/bower) package manager: ```'jquery', 'backbone', 'underscore'```\n\n- **versioning**: github sources can specify a version by appending ```@``` and a npm-style symantic version: ```'*', '1.2.3', '1.x', '~1.2.0', '>=1.2.3'```\n\n- **resources**: specific resources can be specified by appending ```#``` and a list of ```|``` separated relative file or directory locations: ```'username/repo#a/file/or/directory|another/file/or/directory'```\n\n**Output**: A file destination to concatenate and compress the source contents. The order of *sources* determines the content order.\n\n## Examples\n\nCopy project boilerplate from a local directory:\n\n```js\nexports.dependencies = {\n '.': {\n sources: ['../../boilerplate/project']\n }\n}\n```\n\nGrab js dependencies to be installed and packaged for inclusion in html:\n\n```js\nexports.dependencies = {\n // install location\n 'libs/vendor': {\n sources: [\n // library for require boilerplate\n 'popeindustries/browser-require',\n // jquery at specific version\n 'jquery@1.8.2'\n ],\n // packaged and compressed\n output: 'www/assets/js/libs.js'\n }\n}\n```\n\nGrab sources to be referenced in your builds:\n\n```js\nexports.dependencies = {\n // install location\n 'libs/src/css': {\n sources: [\n // reference the lib/nib directory for installation\n 'visionmedia/nib#lib/nib'\n ]\n }\n}\n```\n\nCompile a library, then reference some library files in your project:\n\n```js\nexports.build = {\n js: {\n sources: ['libs/src/coffee', 'libs/js', 'src'],\n targets: [\n {\n // a folder of coffee files (including nested folders)\n input: 'libs/src/coffee',\n // a folder of compiled js files\n output: 'libs/js'\n },\n {\n // the application entry point referencing library dependencies\n input: 'src/main.js',\n // a concatenation of referenced dependencies\n output: 'js/main.js'\n }\n ]\n }\n}\n```\n\nCompile a site with an additional widget using shared sources:\n\n```js\nexports.build = {\n js: {\n sources: ['src/coffee'],\n targets: [\n {\n // the application entry point\n input: 'src/coffee/main.coffee',\n // output to main.js (includes all referenced dependencies)\n output: 'js',\n targets: [\n {\n // references some of the same sources as main.coffee\n input: 'src/coffee/widget.coffee',\n // includes only referenced dependencies not in main.js\n output: 'js'\n }\n ]\n }\n ]\n }\n}\n```\n\n## Changelog\n\n**0.6.6** - December 6, 2012\n* added live-reload support for *watch* command with **-r/--reload**\n* re-enabled linting support\n\n**0.6.5** - December 5, 2012\n* fix for *watch* command firing repeated change events\n* fix for *watch* command not properly building targets on change\n* fix for child target building shared resources\n\n**0.6.4** - December 4, 2012\n* fix for *--test* not displaying both stdout and stderr\n* added wrapping of batch files in module definitions if *options.modular* is not false\n* fix for building targets that contain no source\n\n**0.6.3** - December 4, 2012\n* fix for *watch* command attempting to watch a source that doesn't exist\n* added support for default json config file type\n\n**0.6.2** - December 4, 2012\n* fix for css '@import' inlining\n\n**0.6.1** - December 3, 2012\n* added *--test* to watch command\n\n**0.6.0** - December 3, 2012\n* complete rewrite for async file operations\n* added *--test* flag for executing a command after build\n* added *--verbose* flag for outputting detailed notifications during build\n* added *ls* command to list all generated files\n* simplified dependency resource parsing on install; only parse 'main' field in component.json/package.json\n\n**0.5.4** - November 23, 2012\n* regression fix for *clean* command\n* improved *.buddy-filelog* force clean\n* improved notifications for *install* and *clean* commands\n\n**0.5.3** - November 23, 2012\n* refactored *install* command behaviour; no longer uses git operations, changed syntax for specifying version ('@') and resources ('#'), added ability to list several resources **[breaking change]**\n* *.buddy-filelog* now stores relative paths for compatibility on different systems\n* file deletions limited to resources under the project root\n\n**0.5.2** - Novemver 20, 2012\n* added *watch* command; handle add, remove, and change of source files\n\n**0.5.1** - Novemver 14, 2012\n* added *clean* command to remove all generated files\n* added hidden *.buddy-filelog* file for tracking files changes between sessions\n* fix for false-negative module wrapping test\n\n**0.5.0** - November 13, 2012\n* *compile* command renamed to *build* **[breaking change]**\n* changed module naming for compatibility with recent versions of Node.js (camel case no longer converted to underscores) **[breaking change]**\n* changed configuration file type to 'js' from 'json'; added *dependencies* and *settings* **[breaking change]**\n* changed configuration *target* parameters to *input/output* from *in/out* **[breaking change]**\n* changed configuration *target* parameter to *modular* from *nodejs* **[breaking change]**\n* concatenated js modules no longer self-booting; need to ```require('main');``` manually **[breaking change]**\n* *require* boilerplate no longer included in generated source; install *git://github.com/popeindustries/browser-require.git* or equivalent **[breaking change]**\n* removed *watch* command (temporarily) **[breaking change]**\n* added *install* command and project dependency management\n* added plugin support for compilers, compressors, linters, and modules; added support for custom plugins\n* added code linting\n* all errors now throw\n* complete code base refactor\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2011 Pope-Industries &lt;alex@pope-industries.com&gt;\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."
}

@@ -5,4 +5,4 @@ # buddy(1)

**Current version:** 0.6.5
*[the 0.5.x+ branch is not backwards compatible with earlier versions. See __Change Log__ below for more details]*
**Current version:** 0.6.6
*[the 0.5.x+ branch is not backwards compatible with earlier versions. See [Change Log](#a1) below for more details]*

@@ -63,2 +63,5 @@ ## Installation

$ buddy watch
# watch and build on source changes
# reloading open browsers
$ buddy watch -r
# build and compress for production

@@ -384,4 +387,9 @@ $ buddy deploy

<a name="a1"/>
## Changelog
**0.6.6** - December 6, 2012
* added live-reload support for *watch* command with **-r/--reload**
* re-enabled linting
**0.6.5** - December 5, 2012

@@ -388,0 +396,0 @@ * fix for *watch* command firing repeated change events

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

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc