Socket
Socket
Sign inDemoInstall

buddy

Package Overview
Dependencies
11
Maintainers
1
Versions
180
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.5.1 to 0.5.2

lib/livereload.js

211

lib/builder.js
// Generated by CoffeeScript 1.4.0
var Builder, CSS, CSSFile, CSSTarget, Configuration, Depedencies, Filelog, HTML, JS, JSFile, JSTarget, RE_IGNORE_FILE, existsSync, fs, notify, path, plugins, readdir, rimraf, _ref;
var Builder, CSS, CSSFile, CSSTarget, Configuration, Depedencies, Filelog, HTML, JS, JSFile, JSTarget, RE_IGNORE_FILE, RE_WATCH_IGNORE_FILE, Watcher, existsSync, fs, notify, path, plugins, readdir, rimraf, _ref,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

@@ -14,2 +15,4 @@ fs = require('fs');

Watcher = require('./watcher');
Filelog = require('./filelog');

@@ -31,4 +34,6 @@

RE_IGNORE_FILE = /^[\._~]|[-\.]min[-\.]|svn$/;
RE_IGNORE_FILE = /^[\._~]|[-\.]min[-\.]|svn|~$/;
RE_WATCH_IGNORE_FILE = /^[\.~]|[-\.]min[-\.]|svn|~$/;
JS = 'js';

@@ -43,6 +48,15 @@

function Builder() {
this._onWatchDelete = __bind(this._onWatchDelete, this);
this._onWatchChange = __bind(this._onWatchChange, this);
this._onWatchCreate = __bind(this._onWatchCreate, this);
this.config = null;
this.plugins = null;
this.dependencies = null;
this.filelog;
this.filelog = null;
this.compress = false;
this.lint = false;
this.watching = false;
this.watchers = [];
this.jsSources = {

@@ -101,10 +115,7 @@ locations: [],

_this.config.build[type].sources.forEach(function(source) {
return _this._parseSourceDirectory(path.resolve(process.cwd(), source), null, _this[type + 'Sources']);
return _this._parseSourceDirectory(path.resolve(source), null, _this[type + 'Sources']);
});
_this._parseTargets(_this.config.build[type].targets, type);
return _this[type + 'Targets'].forEach(function(target) {
return target.run(compress, lint, function(err, files) {
files && _this.filelog.add(files);
return err && notify.error(err, 2);
});
return _this._runTarget(target, compress, lint);
});

@@ -115,2 +126,22 @@ }

Builder.prototype.watch = function(compress) {
var _this = this;
this.compress = compress;
this.build(this.compress, false);
this.watching = true;
return [JS, CSS].forEach(function(type) {
if (_this[type + 'Sources'].count) {
notify.print("watching [" + (notify.strong(_this.config.build[type].sources.join(', '))) + "]...", 2);
return _this[type + 'Sources'].locations.forEach(function(source) {
var watcher;
_this.watchers.push(watcher = new Watcher(RE_WATCH_IGNORE_FILE));
watcher.on('create', _this._onWatchCreate);
watcher.on('change', _this._onWatchChange);
watcher.on('delete', _this._onWatchDelete);
return watcher.watch(source);
});
}
});
};
Builder.prototype.deploy = function() {

@@ -125,3 +156,3 @@ return this.build(true, false);

this.filelog.files.forEach(function(file) {
notify.print("" + (notify.colour('deleted', notify.GREEN)) + " " + (notify.strong(path.relative(process.cwd(), file))), 3);
notify.print("" + (notify.colour('deleted', notify.GREEN)) + " " + (notify.strong(path.relative(file))), 3);
return rimraf.sync(file);

@@ -135,3 +166,3 @@ });

Builder.prototype._validSource = function(type, filename) {
Builder.prototype._validFileType = function(type, filename) {
var compiler, extension, name, _ref1;

@@ -157,2 +188,34 @@ extension = path.extname(filename).slice(1);

Builder.prototype._getFileType = function(filename) {
var compiler, extension, name, type, _i, _len, _ref1, _ref2;
extension = path.extname(filename).slice(1);
_ref1 = [JS, CSS];
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
type = _ref1[_i];
if (extension === type) {
return type;
}
_ref2 = this.plugins[type].compilers;
for (name in _ref2) {
compiler = _ref2[name];
if (extension === compiler.extension) {
return type;
}
}
}
return '';
};
Builder.prototype._getSourceLocation = function(filename, type) {
var source, _i, _len, _ref1;
_ref1 = this[type + 'Sources'].locations;
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
source = _ref1[_i];
if (filename.indexOf(source) !== -1) {
return source;
}
}
return '';
};
Builder.prototype._parseSourceDirectory = function(dir, root, cache) {

@@ -164,9 +227,5 @@ var _this = this;

return readdir(dir, RE_IGNORE_FILE).forEach(function(item) {
var f;
if (f = _this._fileFactory(path.resolve(dir, item), root)) {
cache.count++;
if (f.moduleId != null) {
cache.byModule[f.moduleId] = f;
}
return cache.byPath[f.filepath] = f;
var file;
if (file = _this._fileFactory(path.resolve(dir, item), root)) {
return _this._cacheFile(file, cache);
}

@@ -177,5 +236,5 @@ });

Builder.prototype._fileFactory = function(filepath, base) {
if (this._validSource(JS, filepath)) {
if (this._validFileType(JS, filepath)) {
return new JSFile(filepath, base, this.plugins[JS].compilers, this.plugins[JS].module);
} else if (this._validSource(CSS, filepath)) {
} else if (this._validFileType(CSS, filepath)) {
return new CSSFile(filepath, base, this.plugins[CSS].compilers);

@@ -187,2 +246,21 @@ } else {

Builder.prototype._cacheFile = function(file, cache) {
if (!cache.byPath[file.filepath]) {
cache.count++;
if (cache.byModule) {
cache.byModule[file.moduleId] = file;
}
return cache.byPath[file.filepath] = file;
}
};
Builder.prototype._uncacheFile = function(file, cache) {
cache.count--;
if (file.moduleId) {
delete cache.byModule[file.moduleId];
}
delete cache.byPath[file.filepath];
return file.destroy();
};
Builder.prototype._parseTargets = function(targets, type, parentTarget) {

@@ -244,65 +322,42 @@ var _this = this;

return Builder;
Builder.prototype._runTarget = function(target, compress, lint, fn) {
var _this = this;
return target.run(compress, lint, function(err, files) {
files && _this.filelog.add(files);
fn && fn(files);
return err && notify.error(err, 2);
});
};
})();
Builder.prototype._onWatchCreate = function(filename, stats) {
var file, type;
type = this._getFileType(filename);
if (type && (file = this._fileFactory(filename, this._getSourceLocation(filename, type)))) {
notify.print("[" + (new Date().toLocaleTimeString()) + "] " + (notify.colour('added', notify.GREEN)) + " " + (notify.strong(path.basename(filename))), 3);
return this._cacheFile(file, this[type + 'Sources']);
}
};
/*
watch: (compress, lint) ->
# @build(compress, lint)
# console.log(@jsSources.count, @cssSources.count)
Builder.prototype._onWatchChange = function(filename, stats) {
var type,
_this = this;
notify.print("[" + (new Date().toLocaleTimeString()) + "] " + (notify.colour('changed', notify.YELLOW)) + " " + (notify.strong(path.basename(filename))), 3);
type = this._getFileType(filename);
return this[type + 'Targets'].forEach(function(target) {
target.watching = true;
return _this._runTarget(target, _this.compress, false);
});
};
# for type in [@JS, @CSS]
# notify.print("watching for changes in #{notify.strong('['+@config.build[type].sources.join(', ')+']')}...", 2)
# for s in @[type + 'Sources'].locations
# watcher = chokidar.watch(s, {ignored: @RE_IGNORE_FILE, persistent: true})
# watcher.on('add', @_onWatchAdd)
# watcher.on('change', @_onWatchChange)
# watcher.on('unlink', @_onWatchUnlink)
# @watchers.push(watcher)
Builder.prototype._onWatchDelete = function(filename) {
var file, type;
type = this._getFileType(filename);
if (type && (file = this[type + 'Sources'].byPath[filename])) {
notify.print("[" + (new Date().toLocaleTimeString()) + "] " + (notify.colour('removed', notify.RED)) + " " + (notify.strong(path.basename(filename))), 3);
return this._uncacheFile(file, this[type + 'Sources']);
}
};
_onWatchAdd: (filepath) =>
unless (@jsSources.byPath[filepath] or @cssSources.byPath[filepath]) and not path.basename(filepath).match(RE_IGNORE_FILE)
# Find base source directory
for loc in @jsSources.locations.concat(@cssSources.locations)
# Create file instance and store
if filepath.indexOf(loc) is 0 and f = @_fileFactory(filepath, loc)
cache = @[f.type + 'Sources']
cache.count++
cache.byModule[f.moduleId] = f if f.moduleId?
cache.byPath[f.filepath] = f
console.log('add', filepath, cache.count, path.basename(filepath).match(RE_IGNORE_FILE))
return
# notify.print("[#{new Date().toLocaleTimeString()}] change detected in #{notify.strong(path)}", 0)
return Builder;
_onWatchChange: (filepath) =>
# notify.print("[#{new Date().toLocaleTimeString()}] change detected in #{notify.strong(path)}", 0)
_onWatchUnlink: (filepath) =>
# notify.print("[#{new Date().toLocaleTimeString()}] change detected in #{notify.strong(path)}", 0)
_watchFile: (file, compress) ->
# Store initial time and size
stat = fs.statSync(file.filepath)
file.lastChange = +stat.mtime
file.lastSize = stat.size
watcher = fs.watch file.filepath, callback = (event) =>
# Clear old and create new on rename
if event is 'rename'
watcher.close()
try # if source no longer exists, never mind
watcher = fs.watch(file.filepath, callback)
if event is 'change'
# Compare time to the last second
# This should prevent double watch execusion bug
nstat = fs.statSync(file.filepath)
last = +nstat.mtime / 1000
if last isnt file.lastChange
# Store new time
file.lastChange = last
term.out("[#{new Date().toLocaleTimeString()}] change detected in #{term.colour(file.filename, term.GREY)}", 0)
# Update contents
file.updateContents(fs.readFileSync(file.filepath, 'utf8'))
# TODO: re-initialize targets
@compile(compress, [file.type])
*/
})();

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

this.files.push(filepath);
notify.print("" + (notify.colour('built', notify.GREEN)) + " " + (notify.strong(path.relative(process.cwd(), filepath))), 3);
notify.print("" + (notify.colour('built', notify.GREEN)) + " " + (notify.strong(path.relative(process.cwd(), filepath))), this.watching ? 4 : 3);
if (exit) {

@@ -62,0 +62,0 @@ return fn(null, this.files);

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

} else {
filepath = path.resolve(process.cwd(), 'components', dependency.id);
filepath = path.resolve('components', dependency.id);
component = JSON.parse(fs.readFileSync(path.resolve(filepath, 'component.json'), 'utf8'));

@@ -185,3 +185,3 @@ filepath = path.resolve(filepath, dependency.sourcePath || component.main || '');

} else {
notify.print("" + (notify.colour('compressed', notify.GREEN)) + " " + (notify.strong(path.relative(process.cwd(), output))), 3);
notify.print("" + (notify.colour('compressed', notify.GREEN)) + " " + (notify.strong(path.relative(output))), 3);
fs.writeFileSync(output, content);

@@ -188,0 +188,0 @@ _this.files.push(output);

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

this.needsCompile = this.extension !== this.type;
this.lastChange = null;
this._contents = '';

@@ -53,2 +52,7 @@ if (this.needsCompile) {

File.prototype.destroy = function() {
this.dependencies = null;
return this.compiler = null;
};
File.prototype._compile = function(options, fn) {

@@ -55,0 +59,0 @@ var _this = this;

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

this.moduleId = (_ref = this.module) != null ? _ref.getModuleId(this.qualifiedFilename) : void 0;
this.dependencies = [];
}

@@ -20,0 +19,0 @@

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

this.files.push(filepath);
notify.print("" + (notify.colour('built', notify.GREEN)) + " " + (notify.strong(path.relative(process.cwd(), filepath))), 3);
notify.print("" + (notify.colour('built', notify.GREEN)) + " " + (notify.strong(path.relative(process.cwd(), filepath))), this.watching ? 4 : 3);
if (exit) {

@@ -145,0 +145,0 @@ return fn(null, this.files);

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

var pluginPath;
pluginPath = path.resolve(process.cwd(), plugin);
pluginPath = path.resolve(plugin);
if (!existsSync(pluginPath + '.js')) {

@@ -34,0 +34,0 @@ pluginPath = path.resolve(__dirname, 'plugins', type, plugin);

@@ -22,4 +22,5 @@ // Generated by CoffeeScript 1.4.0

this.sources = [];
this.files = [];
this.concat = false;
this.files = [];
this.watching = false;
if (!path.extname(this.output).length && fs.statSync(this.input).isFile()) {

@@ -32,5 +33,8 @@ this.output = path.join(this.output, path.basename(this.input)).replace(path.extname(this.input), "." + this.type);

this.sources = [];
this.files = [];
this._parseSources(this.input);
if (this.sources.length) {
notify.print("building " + (notify.strong(path.basename(this.input))) + " to " + (notify.strong(path.basename(this.output))), 2);
if (!this.watching) {
notify.print("building " + (notify.strong(path.basename(this.input))) + " to " + (notify.strong(path.basename(this.output))), 2);
}
return this._build(compress, lint, fn);

@@ -37,0 +41,0 @@ } else {

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

if (ignore == null) {
ignore = /(?:)/;
ignore = /^\./;
}

@@ -66,3 +66,3 @@ if (files == null) {

var itempath;
if (!item.match(ignore)) {
if (!ignore.test(path.basename(item))) {
itempath = path.resolve(dir, item);

@@ -96,3 +96,3 @@ if (fs.statSync(itempath).isDirectory()) {

exports.cp = cp = function(source, destination, base) {
var dir,
var contentsOnly, dir,
_this = this;

@@ -105,5 +105,4 @@ if (base == null) {

} else {
if (base == null) {
base = path.dirname(source);
}
contentsOnly = source.charAt(source.length - 1) === '/' && !base ? true : false;
base = contentsOnly ? path.resolve(source) : path.dirname(path.resolve(source));
dir = path.resolve(destination, source.replace(base, destination));

@@ -125,1 +124,8 @@ if (!existsSync(dir)) {

};
exports.wait = function(time, fn) {
if (time == null) {
time = 25;
}
return setTimeout(fn, time);
};
{
"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.5.1",
"version": "0.5.2",
"author": "popeindustries <alex@pope-industries.com>",

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

},
"readme": "./README.md",
"_id": "buddy@0.5.1",
"_from": "buddy@~0.5"
"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.5.2\n*[the 0.5.x branch is not backwards compatible with earlier versions. See [#changelog](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# watch and build on source changes\n$ buddy watch\n# build and compress for production\n$ buddy deploy\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 git url.\n // Install the 'browser-require' source when using Node modules.\n 'git://github.com/popeindustries/browser-require.git',\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 git url.\n // Will use the 'main' property of package.json to identify the file to install.\n 'git://github.com/username/project.git',\n // A git url with a specific file or directory identifier.\n 'git://github.com/username/project.git@a/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 // 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**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**: Each 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\nor 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 *git://github.com/popeindustries/browser-require.git*.\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 'git://github.com/popeindustries/browser-require.git',\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 'git://github.com/visionmedia/nib.git@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.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\nCopyright (c) 2011 Pope-Industries &lt;alex@pope-industries.com&gt;\n\nPermission is hereby granted to do whatever you want with this software, but I won't be held responsible if something bad happens."
}

@@ -1,7 +0,7 @@

# Buddy
# buddy(1)
**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.
**Current version:** 0.5.1
*[the 0.5.x branch is not backwards compatible with earlier versions. See Change Log below for more details]*
**Current version:** 0.5.2
*[the 0.5.x branch is not backwards compatible with earlier versions. See [#changelog](Change Log) below for more details]*

@@ -55,2 +55,4 @@ ## Installation

$ buddy -l build
# watch and build on source changes
$ buddy watch
# build and compress for production

@@ -70,3 +72,3 @@ $ buddy deploy

The only requirement for adding **buddy(1)** support to a project is the presence of a **buddy.js** file in your project root:
The only requirement for adding **buddy** support to a project is the presence of a **buddy.js** file in your project root:

@@ -203,3 +205,3 @@ ```js

**Modules**: Each 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:
**Modules**: Each 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:

@@ -240,5 +242,5 @@ ```javascript

Each module is provided with a ***module***, ***exports***, and ***require*** reference.
Each module is provided with a ```module```, ```exports```, and ```require``` reference.
When *require*-ing a module, keep in mind that the module id is resolved based on the following rules:
When ```require()```-ing a module, keep in mind that the module id is resolved based on the following rules:

@@ -256,2 +258,4 @@ * packages begin at the root folder specified in *buddy.js > js > sources*:

***NOTE***: ```require``` boilerplate needs to be included on the page to enable module loading. It's recommended to ```install``` a library like *git://github.com/popeindustries/browser-require.git*.
## Examples

@@ -306,15 +310,15 @@

js: {
sources: ["libs/src/coffee", "libs/js", "src"],
sources: ['libs/src/coffee', 'libs/js', 'src'],
targets: [
{
// a folder of coffee files (including nested folders)
input: "libs/src/coffee",
input: 'libs/src/coffee',
// a folder of compiled js files
output: "libs/js"
output: 'libs/js'
},
{
// the application entry point referencing library dependencies
input: "src/main.js",
input: 'src/main.js',
// a concatenation of referenced dependencies
output: "js/main.js"
output: 'js/main.js'
}

@@ -331,15 +335,15 @@ ]

js: {
sources: ["src/coffee"],
sources: ['src/coffee'],
targets: [
{
// the application entry point
input: "src/coffee/main.coffee",
input: 'src/coffee/main.coffee',
// output to main.js (includes all referenced dependencies)
output: "js",
output: 'js',
targets: [
{
// references some of the same sources as main.coffee
input: "src/coffee/widget.coffee",
input: 'src/coffee/widget.coffee',
// includes only referenced dependencies not in main.js
output: "js"
output: 'js'
}

@@ -353,4 +357,7 @@ ]

## Change Log ##
## Changelog
**0.5.2** - Novemver 20, 2012
* added *watch* command; handle add, remove, and change of source files
**0.5.1** - Novemver 14, 2012

@@ -357,0 +364,0 @@ * added *clean* command to remove all generated files

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc