Socket
Socket
Sign inDemoInstall

buddy

Package Overview
Dependencies
Maintainers
1
Versions
180
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

buddy - npm Package Compare versions

Comparing version 0.5.0 to 0.5.1

lib/Filelog.js

38

lib/builder.js
// Generated by CoffeeScript 1.4.0
var Builder, CSS, CSSFile, CSSTarget, Configuration, Depedencies, HTML, JS, JSFile, JSTarget, RE_IGNORE_FILE, existsSync, fs, notify, path, plugins, readdir, _ref;
var Builder, CSS, CSSFile, CSSTarget, Configuration, Depedencies, Filelog, HTML, JS, JSFile, JSTarget, RE_IGNORE_FILE, existsSync, fs, notify, path, plugins, readdir, rimraf, _ref;

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

Filelog = require('./filelog');
JSFile = require('./jsfile');

@@ -23,2 +25,4 @@

rimraf = require('rimraf');
_ref = require('./utils'), notify = _ref.notify, readdir = _ref.readdir;

@@ -42,3 +46,3 @@

this.dependencies = null;
this.watchers = [];
this.filelog;
this.jsSources = {

@@ -73,2 +77,3 @@ locations: [],

}
this.filelog = new Filelog;
this.initialized = true;

@@ -80,6 +85,8 @@ }

Builder.prototype.install = function() {
var _this = this;
if (this.dependencies) {
notify.print('installing dependencies...', 2);
return this.dependencies.install(function(err) {
return err && notify.error(err);
return this.dependencies.install(function(err, files) {
files && _this.filelog.add(files);
return err && notify.error(err, 2);
});

@@ -100,3 +107,6 @@ } else {

return _this[type + 'Targets'].forEach(function(target) {
return target.run(compress, lint);
return target.run(compress, lint, function(err, files) {
files && _this.filelog.add(files);
return err && notify.error(err, 2);
});
});

@@ -111,2 +121,16 @@ }

Builder.prototype.clean = function() {
var _ref1,
_this = this;
notify.print('cleaning files...', 2);
this.filelog.files.forEach(function(file) {
notify.print("" + (notify.colour('deleted', notify.GREEN)) + " " + (notify.strong(path.relative(process.cwd(), file))), 3);
return rimraf.sync(file);
});
this.filelog.clean();
return (_ref1 = this.dependencies) != null ? _ref1.clean(function(err) {
return err && notify.error(err, 2);
}) : void 0;
};
Builder.prototype._validSource = function(type, filename) {

@@ -179,4 +203,4 @@ var compiler, extension, name, _ref1;

var dir, inSources, inputpath, location, options, outputpath, _i, _len, _ref1;
inputpath = path.resolve(process.cwd(), props.input);
outputpath = path.resolve(process.cwd(), props.output);
inputpath = path.resolve(props.input);
outputpath = path.resolve(props.output);
if (!existsSync(inputpath)) {

@@ -183,0 +207,0 @@ notify.error("" + (notify.strong(props.input)) + " not found in project path", 2);

42

lib/CSSTarget.js

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

CSSTarget.prototype._build = function(compress, lint) {
var _this = this;
CSSTarget.prototype._build = function(compress, lint, fn) {
var n,
_this = this;
n = this.sources.length;
return this.sources.forEach(function(file, idx) {

@@ -32,13 +34,19 @@ var filepath, opts;

return file.getContents(opts, function(err, content) {
err && notify.error(err);
if (lint) {
_this._lint(content, filepath);
}
if (compress) {
return _this._compress(content, filepath, function(err, content) {
err && notify.error(err);
return _this._writeFile(content, filepath);
});
if (err) {
return fn(err);
} else {
return _this._writeFile(content, filepath);
if (lint) {
_this._lint(content, filepath);
}
if (compress) {
return _this._compress(content, filepath, function(err, content) {
if (err) {
return fn(err);
} else {
return _this._writeFile(content, filepath, fn, idx + 1 === n);
}
});
} else {
return _this._writeFile(content, filepath, fn, idx + 1 === n);
}
}

@@ -49,6 +57,10 @@ });

CSSTarget.prototype._writeFile = function(content, filepath) {
CSSTarget.prototype._writeFile = function(content, filepath, fn, exit) {
mkdir(filepath);
notify.print("" + (notify.colour('built', notify.GREEN)) + " " + (notify.strong(path.basename(filepath))), 3);
return fs.writeFileSync(filepath, content, 'utf8');
fs.writeFileSync(filepath, content, 'utf8');
this.files.push(filepath);
notify.print("" + (notify.colour('built', notify.GREEN)) + " " + (notify.strong(path.relative(process.cwd(), filepath))), 3);
if (exit) {
return fn(null, this.files);
}
};

@@ -55,0 +67,0 @@

// Generated by CoffeeScript 1.4.0
var Dependencies, RE_ID, bower, cat, cp, existsSync, fs, mkdir, mv, notify, path, rimraf, _ref;
var Dependencies, RE_FETCHING, RE_ID, RE_LOCAL, RE_SOURCE_PATH, bower, cat, cp, existsSync, fs, mkdir, mv, notify, path, rimraf, _ref;

@@ -16,4 +16,10 @@ path = require('path');

RE_ID = /\D\[\d{2}m([\w-_]+)\D\[\d{2}m$/;
RE_ID = /\D\[\d{2}m([\w-_\.]+)\D\[\d{2}m$/;
RE_LOCAL = /^[\.\/~]/;
RE_SOURCE_PATH = /@/;
RE_FETCHING = /fetching/;
module.exports = Dependencies = (function() {

@@ -28,2 +34,3 @@

this.dependencies = [];
this.files = [];
_ref1 = this.options;

@@ -33,9 +40,10 @@ for (destination in _ref1) {

data.sources.forEach(function(source) {
var id, items, local, sourcePath;
if (/^[\.\/~]/.test(source)) {
var id, items, keep, local, sourcePath;
if (RE_LOCAL.test(source)) {
id = source;
source = path.resolve(source);
local = true;
keep = source.indexOf(path.resolve(destination)) !== -1;
}
if (/@/.test(source)) {
if (RE_SOURCE_PATH.test(source)) {
items = source.split('@');

@@ -51,2 +59,3 @@ source = items[0];

local: local || false,
keep: keep || false,
id: id,

@@ -73,3 +82,3 @@ filepath: ''

var _ref1;
if (/fetching/.test(data)) {
if (RE_FETCHING.test(data)) {
return (_ref1 = dependency.id) != null ? _ref1 : dependency.id = RE_ID.exec(data)[1];

@@ -89,2 +98,10 @@ }

Dependencies.prototype.clean = function(fn) {
return bower.commands['cache-clean']().on('end', function() {
return fn();
}).on('error', function(err) {
return fn(err);
});
};
Dependencies.prototype._moveSource = function(dependency) {

@@ -94,4 +111,4 @@ var component, filepath;

if (dependency.local) {
filepath = dependency.source;
cp(filepath, path.resolve(dependency.destination));
dependency.filepath = path.resolve(dependency.destination, path.basename(dependency.source));
cp(dependency.source, path.resolve(dependency.destination));
} else {

@@ -101,5 +118,8 @@ filepath = path.resolve(process.cwd(), 'components', dependency.id);

filepath = path.resolve(filepath, dependency.sourcePath || component.main || '');
dependency.filepath = path.resolve(process.cwd(), dependency.destination, path.basename(filepath));
dependency.filepath = path.resolve(dependency.destination, path.basename(filepath));
mv(filepath, path.resolve(dependency.destination));
}
if (!dependency.keep) {
this.files.push(dependency.filepath);
}
return notify.print("" + (notify.colour('installed', notify.GREEN)) + " " + (notify.strong(dependency.id)) + " to " + (notify.strong(dependency.destination)), 3);

@@ -116,14 +136,15 @@ };

props = data[item];
dependency = _this.dependencies.filter(function(d) {
if (dependency = _this.dependencies.filter(function(d) {
return d.id === item;
})[0];
if (props.dependencies) {
for (depItem in props.dependencies) {
dependant = {
destination: dependency.destination,
output: dependency.output,
id: depItem
};
_this._moveSource(dependant);
_this.dependencies.splice(_this.dependencies.indexOf(dependency), 0, dependant);
})[0]) {
if (props.dependencies) {
for (depItem in props.dependencies) {
dependant = {
destination: dependency.destination,
output: dependency.output,
id: depItem
};
_this._moveSource(dependant);
_this.dependencies.splice(_this.dependencies.indexOf(dependency), 0, dependant);
}
}

@@ -144,3 +165,4 @@ }

Dependencies.prototype._pack = function(fn) {
var content, contents, files, output, outputable, outputs, _results;
var content, contents, files, i, n, output, outputable, outputs, _results,
_this = this;
outputs = {};

@@ -158,8 +180,9 @@ outputable = this.dependencies.filter(function(dependency) {

});
n = Object.keys(outputs).length;
i = 0;
_results = [];
for (output in outputs) {
files = outputs[output];
contents = [];
files.forEach(function(file) {
return contents.push(fs.readFileSync(file));
contents = files.map(function(file) {
return fs.readFileSync(file);
});

@@ -170,7 +193,10 @@ content = contents.join('\n');

if (err) {
return fn(err);
return fn(err, _this.files);
} else {
notify.print("" + (notify.colour('compressed', notify.GREEN)) + " " + (notify.strong(path.basename(output))), 3);
notify.print("" + (notify.colour('compressed', notify.GREEN)) + " " + (notify.strong(path.relative(process.cwd(), output))), 3);
fs.writeFileSync(output, content);
return fn(null);
_this.files.push(output);
if (++i === n) {
return fn(null, _this.files);
}
}

@@ -181,3 +207,3 @@ }));

} else {
return fn(null);
return fn(null, this.files);
}

@@ -184,0 +210,0 @@ };

@@ -49,4 +49,4 @@ // Generated by CoffeeScript 1.4.0

JSTarget.prototype._build = function(compress, lint) {
var contents, opts,
JSTarget.prototype._build = function(compress, lint, fn) {
var contents, n, opts,
_this = this;

@@ -59,18 +59,24 @@ opts = {};

return file.getContents(opts, function(err, content) {
err && notify.error(err);
contents.push(content);
if (contents.length === _this.sources.length) {
content = contents.join('\n');
content = _this._wrapContent(_this._optimizeContent(content));
if (lint) {
_this._lint(content, _this.output);
if (err) {
return fn(err);
} else {
contents.push(content);
if (contents.length === _this.sources.length) {
content = contents.join('\n');
content = _this._wrapContent(_this._optimizeContent(content));
if (lint) {
_this._lint(content, _this.output);
}
if (compress) {
return _this._compress(content, _this.output, function(err, content) {
if (err) {
return fn(err);
} else {
return _this._writeFile(content, _this.output, true, fn, true);
}
});
} else {
return _this._writeFile(content, _this.output, true, fn, true);
}
}
if (compress) {
return _this._compress(content, _this.output, function(err, content) {
err && notify.error(err);
return _this._writeFile(content, _this.output, true);
});
} else {
return _this._writeFile(content, _this.output, true);
}
}

@@ -80,2 +86,3 @@ });

} else {
n = this.sources.length;
return this.sources.forEach(function(file, idx) {

@@ -85,13 +92,19 @@ var filepath;

return file.getContents(opts, function(err, content) {
err && notify.error(err);
if (lint) {
_this._lint(content, filepath);
}
if (compress) {
return _this._compress(content, filepath, function(err, content) {
err && notify.error(err);
return _this._writeFile(content, filepath, false);
});
if (err) {
return fn(err);
} else {
return _this._writeFile(content, filepath, false);
if (lint) {
_this._lint(content, filepath);
}
if (compress) {
return _this._compress(content, filepath, function(err, content) {
if (err) {
return fn(err);
} else {
return _this._writeFile(content, filepath, false, fn, idx + 1 === n);
}
});
} else {
return _this._writeFile(content, filepath, false, fn, idx + 1 === n);
}
}

@@ -126,9 +139,13 @@ });

JSTarget.prototype._writeFile = function(content, filepath, withHeader) {
JSTarget.prototype._writeFile = function(content, filepath, withHeader, fn, exit) {
mkdir(filepath);
notify.print("" + (notify.colour('built', notify.GREEN)) + " " + (notify.strong(path.basename(filepath))), 3);
if (withHeader) {
content = "" + BUILT_HEADER + (new Date().toString()) + "*/\n" + content;
}
return fs.writeFileSync(filepath, content, 'utf8');
fs.writeFileSync(filepath, content, 'utf8');
this.files.push(filepath);
notify.print("" + (notify.colour('built', notify.GREEN)) + " " + (notify.strong(path.relative(process.cwd(), filepath))), 3);
if (exit) {
return fn(null, this.files);
}
};

@@ -135,0 +152,0 @@

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

wrapModuleContents: function(contents, id) {
RE_MODULE.lastIndex = 0;
if (!RE_MODULE.test(contents)) {

@@ -59,0 +60,0 @@ contents = "require.register('" + id + "', function(module, exports, require) {\n" + (indent(contents, 2)) + "\n});";

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

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

@@ -25,0 +26,0 @@ this.output = path.join(this.output, path.basename(this.input)).replace(path.extname(this.input), "." + this.type);

@@ -80,3 +80,5 @@ // Generated by CoffeeScript 1.4.0

dir = path.extname(filepath) ? path.dirname(filepath) : filepath;
return mkdirp.sync(dir);
if (!existsSync(dir)) {
return mkdirp.sync(dir);
}
};

@@ -83,0 +85,0 @@

{
"name": "buddy",
"description": "A build framework 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.0",
"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",
"author": "popeindustries <alex@pope-industries.com>",

@@ -42,4 +42,4 @@ "keywords": ["build", "modules", "javascript", "coffeescript", "css", "styus", "less"],

"readme": "./README.md",
"_id": "buddy@0.5.0",
"_id": "buddy@0.5.1",
"_from": "buddy@~0.5"
}
# Buddy
**buddy(1)** is a build framework 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.
**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.0
*[this version is not backwards compatible with earlier versions. See Change Log below for more details]*
**Current version:** 0.5.1
*[the 0.5.x branch is not backwards compatible with earlier versions. See Change Log below for more details]*

@@ -348,6 +348,15 @@ ## Installation

**0.5.1** - Novemver 14, 2012
* added *clean* command to remove all generated files
* added hidden *.buddy-filelog* file for tracking files changes between sessions
* fix for false-negative module wrapping test
**0.5.0** - November 13, 2012
* *compile* command renamed to *build* **[breaking change]**
* changed module naming for compatibility with recent versions of Node.js (camel case no longer converted to underscores) **[breaking change]**
* changed configuration file type to 'js' from 'json'; added *dependencies* and *settings* **[breaking change]**
* changed configuration *target* parameters to *input/output* from *in/out* **[breaking change]**
* changed configuration *target* parameter to *modular* from *nodejs* **[breaking change]**
* concatenated js modules no longer self-booting; need to ```require('main');``` manually **[breaking change]**
* *require* boilerplate no longer included in generated source; install *git://github.com/popeindustries/browser-require.git* or equivalent **[breaking change]**
* removed *watch* command (temporarily) **[breaking change]**

@@ -354,0 +363,0 @@ * added *install* command and project dependency management

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc