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.3.9 to 0.4.0

131

lib/builder.js

@@ -0,1 +1,2 @@

// Generated by CoffeeScript 1.3.1
var Builder, CONFIG, file, fs, log, path, target, term, trace;

@@ -19,2 +20,4 @@

Builder.name = 'Builder';
Builder.prototype.JS = 'js';

@@ -28,3 +31,3 @@

Builder.prototype.RE_IGNORE_FILE = /^\.|[-|\.]min\.|svn|~$/;
Builder.prototype.RE_IGNORE_FILE = /^[\.|_]|[-|\.]min\.|svn|~$/;

@@ -55,5 +58,5 @@ Builder.prototype.RE_BUILT_HEADER = /^\/\*BUILT/g;

Builder.prototype.initialize = function(configpath) {
var source, type, _i, _j, _len, _len2, _ref, _ref2;
var source, type, _i, _j, _len, _len1, _ref, _ref1;
if (!this.initialized) {
if (this._loadConfig(configpath)) {
if (this._loadConfig(this._locateConfig(configpath))) {
_ref = [this.JS, this.CSS];

@@ -63,6 +66,6 @@ for (_i = 0, _len = _ref.length; _i < _len; _i++) {

if (this._validBuildType(type)) {
_ref2 = this.config[type].sources;
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
source = _ref2[_j];
this._parseSourceFolder(path.resolve(this.base, source), null, this[type + 'Sources']);
_ref1 = this.config[type].sources;
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
source = _ref1[_j];
this._parseSourceDirectory(path.resolve(this.base, source), null, this[type + 'Sources']);
}

@@ -72,5 +75,5 @@ this._parseTargets(this.config[type].targets, type);

}
this.initialized = true;
}
}
this.initialized = true;
return this;

@@ -81,3 +84,5 @@ };

var t, type, _i, _len, _results;
if (types == null) types = [this.JS, this.CSS];
if (types == null) {
types = [this.JS, this.CSS];
}
_results = [];

@@ -88,10 +93,10 @@ for (_i = 0, _len = types.length; _i < _len; _i++) {

_results.push((function() {
var _j, _len2, _ref, _results2;
var _j, _len1, _ref, _results1;
_ref = this[type + 'Targets'];
_results2 = [];
for (_j = 0, _len2 = _ref.length; _j < _len2; _j++) {
_results1 = [];
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
t = _ref[_j];
_results2.push(t.run(compress, this.watching));
_results1.push(t.run(compress));
}
return _results2;
return _results1;
}).call(this));

@@ -107,3 +112,5 @@ } else {

var file, path, type, _i, _len, _ref, _results;
if (!fs.watch) return;
if (!fs.watch) {
return;
}
this.watching = true;

@@ -118,10 +125,10 @@ this.compile(compress);

_results.push((function() {
var _ref2, _results2;
_ref2 = this[type + 'Sources'].byPath;
_results2 = [];
for (path in _ref2) {
file = _ref2[path];
_results2.push(this._watchFile(file, compress));
var _ref1, _results1;
_ref1 = this[type + 'Sources'].byPath;
_results1 = [];
for (path in _ref1) {
file = _ref1[path];
_results1.push(this._watchFile(file, compress));
}
return _results2;
return _results1;
}).call(this));

@@ -139,3 +146,3 @@ } else {

Builder.prototype._loadConfig = function(configpath) {
Builder.prototype._locateConfig = function(configpath) {
var dir, exists;

@@ -152,3 +159,3 @@ if (configpath) {

term.out("" + (term.colour('error', term.RED)) + " " + (term.colour(path.basename(configpath), term.GREY)) + " not found in " + (term.colour(path.dirname(configpath), term.GREY)), 2);
return false;
return null;
}

@@ -159,25 +166,36 @@ } else {

configpath = path.join(dir, CONFIG);
if (path.existsSync(configpath)) break;
if (path.existsSync(configpath)) {
break;
}
if (this.RE_ROOT.test(dir)) {
term.out("" + (term.colour('error', term.RED)) + " " + (term.colour(CONFIG, term.GREY)) + " not found on this path", 2);
return false;
return null;
}
}
}
term.out("loading config " + (term.colour(configpath, term.GREY)), 2);
try {
this.config = JSON.parse(fs.readFileSync(configpath, 'utf8'));
} catch (e) {
term.out("" + (term.colour('error', term.RED)) + " error parsing " + (term.colour(configpath, term.GREY)), 2);
return configpath;
};
Builder.prototype._loadConfig = function(configpath) {
if (configpath) {
term.out("loading config " + (term.colour(configpath, term.GREY)), 2);
try {
this.config = JSON.parse(fs.readFileSync(configpath, 'utf8'));
} catch (e) {
term.out("" + (term.colour('error', term.RED)) + " error parsing " + (term.colour(configpath, term.GREY)), 2);
return false;
}
this.base = path.dirname(configpath);
return true;
} else {
return false;
}
this.base = path.dirname(configpath);
return true;
};
Builder.prototype._validBuildType = function(type) {
return this.config[type] && this.config[type].sources && this.config[type].sources.length && this.config[type].targets && this.config[type].targets.length;
var _ref;
return (((_ref = this.config[type]) != null ? _ref.sources : void 0) != null) && this.config[type].sources.length >= 1 && (this.config[type].targets != null) && this.config[type].targets.length >= 1;
};
Builder.prototype._parseSourceFolder = function(dir, root, cache) {
Builder.prototype._parseSourceDirectory = function(dir, root, cache) {
var f, item, itempath, _i, _len, _ref, _results;

@@ -195,7 +213,9 @@ if (root === null) {

if (fs.statSync(itempath).isDirectory()) {
this._parseSourceFolder(itempath, root, cache);
this._parseSourceDirectory(itempath, root, cache);
}
if (f = this._fileFactory(itempath, root)) {
cache.byPath[f.filepath] = f;
if (f.module != null) cache.byModule[f.module] = f;
if (f.module != null) {
cache.byModule[f.module] = f;
}
_results.push(cache.count++);

@@ -212,5 +232,22 @@ } else {

Builder.prototype._fileFactory = function(filepath, base) {
var contents;
if (filepath.match(this.RE_JS_SRC_EXT)) {
contents = fs.readFileSync(filepath, 'utf8');
if (contents.match(this.RE_BUILT_HEADER)) {
return null;
}
return new file.JSFile(this.JS, filepath, base, contents);
} else if (filepath.match(this.RE_CSS_SRC_EXT)) {
return new file.CSSFile(this.CSS, filepath, base);
} else {
return null;
}
};
Builder.prototype._parseTargets = function(targets, type, parentTarget) {
var item, t, _i, _len, _results;
if (parentTarget == null) parentTarget = null;
if (parentTarget == null) {
parentTarget = null;
}
_results = [];

@@ -221,2 +258,3 @@ for (_i = 0, _len = targets.length; _i < _len; _i++) {

if (t = this._targetFactory(type, item)) {
t.initialize();
this[type + 'Targets'].push(t);

@@ -235,15 +273,2 @@ if (item.targets) {

Builder.prototype._fileFactory = function(filepath, base) {
var contents;
if (filepath.match(this.RE_JS_SRC_EXT)) {
contents = fs.readFileSync(filepath, 'utf8');
if (contents.match(this.RE_BUILT_HEADER)) return null;
return new file.JSFile(this.JS, filepath, base, contents);
} else if (filepath.match(this.RE_CSS_SRC_EXT)) {
return new file.CSSFile(this.CSS, filepath, base);
} else {
return null;
}
};
Builder.prototype._targetFactory = function(type, options) {

@@ -262,3 +287,5 @@ var dir, inSources, inputpath, location, outputpath, _i, _len, _ref;

inSources = dir.indexOf(location) >= 0;
if (inSources) break;
if (inSources) {
break;
}
}

@@ -265,0 +292,0 @@ if (!inSources) {

@@ -0,3 +1,4 @@

// Generated by CoffeeScript 1.3.1
var CSSFile, File, JSFile, fs, log, path,
__hasProp = Object.prototype.hasOwnProperty,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };

@@ -13,2 +14,4 @@

File.name = 'File';
function File(type, filepath, base) {

@@ -37,2 +40,4 @@ this.type = type;

JSFile.name = 'JSFile';
JSFile.prototype.RE_COFFEE_EXT = /\.coffee$/;

@@ -42,8 +47,2 @@

JSFile.prototype.RE_INDENT_WHITESPACE = /(^\t|^ +)\S/m;
JSFile.prototype.RE_LINE_BEGIN = /^/gm;
JSFile.prototype.RE_UPPERCASE = /[A-Z]/;
JSFile.prototype.RE_COMMENT_LINES = /^\s*(?:\/\/|#).+$/gm;

@@ -53,3 +52,3 @@

JSFile.prototype.RE_MODULE = /^(?:require\.)?module\s*\(?\s*['|"].+module, ?exports, ?require\s*\)/gm;
JSFile.prototype.RE_MODULE = /^require\.module\(.+function *\( *module *, *exports *, *require *\) *{/gm;

@@ -62,8 +61,9 @@ JSFile.prototype.RE_WIN_SEPARATOR = /\\\\?/g;

this.module = this._getModuleName();
this.dependencies = [];
this.main = false;
this.updateContents(contents) || fs.readFileSync(this.filepath, 'utf8');
this.updateContents(contents || fs.readFileSync(this.filepath, 'utf8'));
}
JSFile.prototype.updateContents = function(contents) {
this.contents = contents;
JSFile.__super__.updateContents.call(this, contents);
return this.dependencies = this._getModuleDependencies();

@@ -74,4 +74,7 @@ };

if (!this.RE_MODULE.test(contents)) {
contents = "require.module('" + this.module + "', function(module, exports, require) {\n" + contents + "\n});\n\n" + (this.main ? "require('" + this.module + "');" : '');
contents = "require.module('" + this.module + "', function(module, exports, require) {\n" + contents + "\n});";
}
if (this.main) {
contents += "\nrequire('" + this.module + "');";
}
return contents;

@@ -83,9 +86,9 @@ };

_this = this;
module = path.relative(this.base, this.filepath).replace(path.extname(this.filename), '');
module = this.name;
if (process.platform === 'win32') {
module = module.replace(this.RE_WIN_SEPARATOR, '/');
}
if (this.RE_UPPERCASE.test(this.name)) {
if (/[A-Z]/g.test(module)) {
letters = Array.prototype.map.call(module, function(l, i, arr) {
if (_this.RE_UPPERCASE.test(l)) {
if (/[A-Z]/g.test(l)) {
return (i > 0 && arr[i - 1] !== '/' ? '_' : '') + l.toLowerCase();

@@ -134,2 +137,4 @@ } else {

CSSFile.name = 'CSSFile';
CSSFile.prototype.RE_STYLUS_EXT = /\.styl$/;

@@ -136,0 +141,0 @@

@@ -0,1 +1,2 @@

// Generated by CoffeeScript 1.3.1

@@ -7,3 +8,5 @@ (function() {

m = require.modules[path] || require.modules[path += '/index'];
if (!m) throw "Couldn't find module for: " + path;
if (!m) {
throw "Couldn't find module for: " + path;
}
if (!m.exports) {

@@ -20,3 +23,5 @@ m.exports = {};

var part, paths, _i, _len, _ref;
if (p.charAt(0) !== '.') return require(p);
if (p.charAt(0) !== '.') {
return require(p);
}
paths = path.split('/');

@@ -23,0 +28,0 @@ paths.pop();

@@ -0,4 +1,5 @@

// Generated by CoffeeScript 1.3.1
var CSSTarget, JSTarget, Target, coffee, file, fs, growl, less, log, path, stylus, term, uglify,
__indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
__hasProp = Object.prototype.hasOwnProperty,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };

@@ -28,3 +29,3 @@

Target.prototype.RE_PARTIAL = /^_/;
Target.name = 'Target';

@@ -35,18 +36,26 @@ function Target(input, output, cache) {

this.cache = cache;
this.compress = false;
this.batch = null;
this.sources = [];
this.compress = false;
this.batch = fs.statSync(this.input).isDirectory();
if (!path.extname(this.output).length && fs.statSync(this.input).isFile()) {
this.output = path.join(this.output, path.basename(this.input)).replace(path.extname(this.input), this.EXTENSION);
}
this._parseSources(this.input);
}
Target.prototype.run = function(compress, clean) {
Target.prototype.initialize = function() {
if (this._validInput(this.input)) {
this.sources = [];
if (this.batch === null) {
this.batch = fs.statSync(this.input).isDirectory();
}
if (!path.extname(this.output).length && fs.statSync(this.input).isFile()) {
this.output = path.join(this.output, path.basename(this.input)).replace(path.extname(this.input), this.EXTENSION);
}
this._parseInput(this.input);
} else {
term.out("" + (term.colour('warning', term.YELLOW)) + " input location does not exist " + (term.colour(this.input, term.GREY)), 2);
}
return this;
};
Target.prototype.run = function(compress) {
this.compress = compress;
if (this.sources.length) {
if (clean) {
this.sources = [];
this._parseSources(this.input);
}
term.out("building " + (term.colour(path.basename(this.input), term.GREY)) + " to " + (term.colour(path.basename(this.output), term.GREY)), 2);

@@ -63,16 +72,20 @@ return this._build();

Target.prototype._parseSources = function(input) {
Target.prototype._validInput = function(input) {
return path.existsSync(input);
};
Target.prototype._parseInput = function(input) {
var f, item, _i, _len, _ref, _results;
if (path.existsSync(input)) {
if (fs.statSync(input).isFile()) {
if (f = this.cache.byPath[input]) return this._addSource(f);
} else {
_ref = fs.readdirSync(input);
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
item = _ref[_i];
_results.push(this._parseSources(path.join(input, item)));
}
return _results;
if (fs.statSync(input).isFile()) {
if (f = this.cache.byPath[input]) {
return this._addSource(f);
}
} else {
_ref = fs.readdirSync(input);
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
item = _ref[_i];
_results.push(this._parseInput(path.join(input, item)));
}
return _results;
}

@@ -82,3 +95,3 @@ };

Target.prototype._addSource = function(file) {
if (__indexOf.call(this.sources, file) < 0 && !this.RE_PARTIAL.test(file.filename)) {
if (__indexOf.call(this.sources, file) < 0) {
return this.sources.push(file);

@@ -97,3 +110,3 @@ }

this._makeDirectory(dir);
return fs.mkdirSync(dir, 0777);
return fs.mkdirSync(dir);
}

@@ -121,2 +134,4 @@ }

JSTarget.name = 'JSTarget';
JSTarget.prototype.BUILT_HEADER = '/*BUILT ';

@@ -138,12 +153,20 @@

JSTarget.__super__.constructor.call(this, input, output, cache);
if (this.nodejs) this.batch = true;
}
JSTarget.prototype.initialize = function() {
if (this.nodejs) {
this.batch = true;
}
return JSTarget.__super__.initialize.call(this);
};
JSTarget.prototype._addSource = function(file, dependantFile) {
var dep, dependency, _i, _len, _ref, _ref2;
if ((_ref = this.parentTarget) != null ? _ref.hasSource(file) : void 0) return;
var dep, dependency, _i, _len, _ref, _ref1;
if ((_ref = this.parentTarget) != null ? _ref.hasSource(file) : void 0) {
return;
}
if (file.dependencies.length) {
_ref2 = file.dependencies;
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
dependency = _ref2[_i];
_ref1 = file.dependencies;
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
dependency = _ref1[_i];
if ((dependantFile != null ? dependantFile.module : void 0) !== dependency) {

@@ -158,3 +181,5 @@ if (dep = this.cache.byModule[dependency] || this.cache.byModule["" + dependency + "/index"]) {

}
if (file.filepath === this.input && !this.batch) file.main = true;
if (file.filepath === this.input && !this.batch) {
file.main = true;
}
return JSTarget.__super__._addSource.call(this, file);

@@ -164,3 +189,3 @@ };

JSTarget.prototype._build = function() {
var c, content, contents, f, filepath, _i, _j, _len, _len2, _ref, _ref2;
var c, content, contents, f, filepath, _i, _j, _len, _len1, _ref, _ref1;
if (this.batch) {

@@ -173,3 +198,5 @@ _ref = this.sources;

if (content != null) {
if (!this.nodejs) content = f.wrap(content, true, false);
if (!this.nodejs) {
content = f.wrap(content);
}
this._writeFile(content, filepath, false);

@@ -181,12 +208,12 @@ }

contents = [];
_ref2 = this.sources;
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
f = _ref2[_j];
_ref1 = this.sources;
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
f = _ref1[_j];
c = f.compile ? this._compile(f.contents, f.filepath) : f.contents;
contents.push(f.wrap(c, true, false));
contents.push(f.wrap(c));
}
content = contents.join('\n\n');
content = contents.join('\n');
if (content != null) {
if (!(this.nodejs || this.parentTarget)) {
content = "" + (fs.readFileSync(path.join(__dirname, this.REQUIRE), 'utf8')) + "\n\n" + content;
content = "" + (fs.readFileSync(path.join(__dirname, this.REQUIRE), 'utf8')) + "\n" + content;
}

@@ -235,3 +262,5 @@ this._writeFile(this._optimizeAndWrap(content), this.output, true);

} else {
if (header) content = this._addHeader(content);
if (header) {
content = this._addHeader(content);
}
fs.writeFileSync(filepath, content, 'utf8');

@@ -250,3 +279,5 @@ }

compressed = pro.gen_code(ast);
if (header) compressed = this._addHeader(compressed);
if (header) {
compressed = this._addHeader(compressed);
}
fs.writeFileSync(filepath, compressed);

@@ -287,2 +318,4 @@ return term.out("" + (term.colour('compressed', term.GREEN)) + " " + (term.colour(path.basename(filepath), term.GREY)), 4);

CSSTarget.name = 'CSSTarget';
CSSTarget.prototype.EXTENSION = '.css';

@@ -319,3 +352,5 @@

stylc = stylus(content).set('paths', this.cache.locations.concat());
if (this.compress) stylc.set('compress', true);
if (this.compress) {
stylc.set('compress', true);
}
return stylc.render(function(error, css) {

@@ -322,0 +357,0 @@ if (error) {

@@ -0,1 +1,2 @@

// Generated by CoffeeScript 1.3.1

@@ -10,3 +11,5 @@ module.exports = {

out: function(string, indentLevel) {
if (indentLevel == null) indentLevel = 1;
if (indentLevel == null) {
indentLevel = 1;
}
if (!this.silent) {

@@ -20,5 +23,5 @@ return console.log(("" + ((new Array(indentLevel)).join(' '))) + string);

} else {
return "\033[" + colourCode + "m" + string + "\033[0m";
return '\033[' + colourCode + 'm' + string + '\033[0m';
}
}
};
{
"name": "buddy",
"description": "A build framework for the compilation of higher order js/css languages (coffeescript/stylus/less).",
"version": "0.3.9",
"version": "0.4.0",
"author": "popeindustries <alex@pope-industries.com>",

@@ -16,3 +16,5 @@ "keywords": ["javascript", "coffeescript", "styus", "less"],

"devDependencies": {
"vows": ">=0.5.13"
"rimraf": "*",
"should": "*",
"mocha": "1.x.x"
},

@@ -27,3 +29,3 @@ "directories": {

"scripts": {
"test": "vows --spec"
"test": "mocha --compilers coffee:coffee-script --reporter spec --require should"
},

@@ -30,0 +32,0 @@ "engines": {

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