Skip to content

Commit

Permalink
Fixed most lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dallonf committed Sep 6, 2012
1 parent 6ffdbdf commit db24dce
Show file tree
Hide file tree
Showing 53 changed files with 517 additions and 876 deletions.
9 changes: 8 additions & 1 deletion .jshintignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
node_modules
lib/util/uuid.js
clib/socket.io.js
clib/socket.io.min.js

test-app/node_modules/request
test-app/public/mocha.js
test-app/public/jquery.js
test-app/public/chai.js

lib/resources/dashboard/js/lib
lib/resources/collection/dashboard/js/lib
lib/resources/dashboard/bootstrap
lib/resources/dashboard/bootstrap

# TODO: We don't really want to ignore this, but the minified socket.io in the beginning throws it off so we need to find another way
clib/dpd.js
6 changes: 5 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"laxcomma": true
"laxcomma": true,
"expr": true,
"proto": true,
"lastsemic": true,
"laxbreak": true
}
2 changes: 2 additions & 0 deletions clib/dpd.js

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions lib/client/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function Deployment(appPath, user, subdomain) {
if(~key.indexOf(remote)) {
subdomain = config[key].subdomain;
}
})
});
}

this.name = this.sanitize(subdomain || path.basename(this.path));
Expand All @@ -43,7 +43,7 @@ Deployment.prototype.sanitize = function (name) {
name = name.trim().toLowerCase();
name = name.replace(/ +/g, '-');
name = name.replace(/\.+/g, '-');
name = name.replace(/[^0-9a-z-]/g, '');
name = name.replace(/[^0-9a-z\-]/g, '');

if(name.length === 0) error();
if(name === '-') error();
Expand All @@ -56,7 +56,7 @@ Deployment.prototype.sanitize = function (name) {
} else {
error();
}
}
};

Deployment.prototype.package = function (tarball, callback) {
function filter(info) {
Expand All @@ -79,7 +79,7 @@ Deployment.prototype.package = function (tarball, callback) {
.on('error', callback)
.pipe(fstream.Writer({ type: "File", path: tarball }))
.on('close', callback);
}
};

Deployment.prototype.publish = function (url, tar, key, callback) {
function done(err, res, body) {
Expand All @@ -100,8 +100,8 @@ Deployment.prototype.publish = function (url, tar, key, callback) {
'X-App-User': this.user,
'X-App-Subdomain': this.subdomain
}
}, done))
}
}, done));
};

Deployment.prototype.getConfig = function(key) {
var cur;
Expand All @@ -113,7 +113,7 @@ Deployment.prototype.getConfig = function(key) {
}

return key ? cur[key] : cur;
}
};


Deployment.prototype.setConfig = function(key, val) {
Expand All @@ -122,4 +122,4 @@ Deployment.prototype.setConfig = function(key, val) {
cur[key] = val;

fs.writeFileSync(this.path + '/.dpd/deployments.json', JSON.stringify(cur));
}
};
56 changes: 28 additions & 28 deletions lib/client/remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,42 @@
*/

var http = require('http')
, util = require('util')
, request = require('request')
, Keys = require('../keys')
, debug = require('debug')('remote')
, httpProxy = require('http-proxy')
, url = require('url');
, util = require('util')
, request = require('request')
, Keys = require('../keys')
, debug = require('debug')('remote')
, httpProxy = require('http-proxy')
, url = require('url');

/*!
* Create a remote and host it at the given port.
*/

exports.createRemote = function(remote, port) {
debug('proxying to %s', remote);
debug('proxying to %s', remote);

if(remote.substr(0,7) !== 'http://') remote = 'http://' + remote;
if(remote.substr(0,7) !== 'http://') remote = 'http://' + remote;

var remoteUrl = url.parse(remote);
var keys = new Keys();
var remoteUrl = url.parse(remote);
var keys = new Keys();
var server = httpProxy.createServer(function(req, res, proxy) {
var buffer = httpProxy.buffer(req);
var buffer = httpProxy.buffer(req);

debug('[%s] %s', req.method, req.url);
keys.getLocal(function(err, key) {
debug('key [%s]', key);
if(err) return res.end('error reading .dpd/keys.json: ' + err.message);
req.headers['dpd-ssh-key'] = key;
req.headers.host = remoteUrl.hostname;
proxy.proxyRequest(req, res, {
host: remoteUrl.hostname,
port: remoteUrl.port || 80,
buffer: buffer
});
});
});
server.listen(port || 2403);
server.on('listening', function() {
console.log('remote dashboard is available at http://localhost:%s/dashboard', port || 2403)
})
debug('[%s] %s', req.method, req.url);
keys.getLocal(function(err, key) {
debug('key [%s]', key);
if(err) return res.end('error reading .dpd/keys.json: ' + err.message);
req.headers['dpd-ssh-key'] = key;
req.headers.host = remoteUrl.hostname;
proxy.proxyRequest(req, res, {
host: remoteUrl.hostname,
port: remoteUrl.port || 80,
buffer: buffer
});
});
});
server.listen(port || 2403);
server.on('listening', function() {
console.log('remote dashboard is available at http://localhost:%s/dashboard', port || 2403);
});
};
26 changes: 14 additions & 12 deletions lib/client/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ var server;
module.exports = function (dpd) {
console.log('type help for a list of commands');
var repl = require("repl")
, context = repl.start("dpd > ", null, replEval, true, true).context
, context = repl.start("dpd > ", null, replEval, true, true).context;
server = dpd;

context.dpd = buildReplClient(dpd);

return commands;
}
};

function replEval(src, ctx, name, fn) {
/*jshint evil:true*/
var result;

// first try to match a command
Expand Down Expand Up @@ -57,7 +58,7 @@ var commands = {
resources: function () {
server.resources && server.resources.forEach(function (r) {
if(r.settings.type) console.log('\t' + r.settings.path, '(' + r.settings.type + ')');
})
});
},

dashboard: function () {
Expand All @@ -67,7 +68,7 @@ var commands = {
open: function () {
open();
}
}
};

function open(url) {
url = url || '';
Expand All @@ -78,7 +79,7 @@ var help = {
dashboard: 'open the resource editor in a browser',
dpd: 'the server object',
resources: 'list your resources'
}
};

function tryCommand(cmd) {
console.info(cmd);
Expand All @@ -94,20 +95,21 @@ function buildReplClient(dpd) {
Object.keys(client[key]).forEach(function(k) {
var orig = client[key][k];
client[key][k] = function () {
if(typeof arguments[arguments.length - 1] != 'function') {
arguments[arguments.length] = function (res, err) {
var args = Array.protoype.slice.call(arguments);
if(typeof args[args.length - 1] !== 'function') {
args[args.length] = function(res, err) {
if(err) {
console.log('Error', err);
} else {
console.log(res);
}
}
arguments.length++;
};
args.length++;
}
orig.apply(client[key], arguments);
}
orig.apply(client[key], args);
};
});
})
});

return client;
}
4 changes: 2 additions & 2 deletions lib/config-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ module.exports.loadConfig = function(basepath, server, fn) {

debug('done, adding internals');

var clientLib = new ClientLib('dpd.js', { config: { resources: resources }, server: server})
var clientLib = new ClientLib('dpd.js', { config: { resources: resources }, server: server});

clientLib.load(function(err) {
if (err) return fn(err);
resources.push(new Files('', { config: { public: './public' }, server: server }));
resources.push(new Files('', { config: { 'public': './public' }, server: server }));
resources.push(clientLib);
resources.push(new InternalResources('__resources', {config: {configPath: basepath}, server: server}));
resources.push(new Dashboard('dashboard', {server: server}));
Expand Down
4 changes: 2 additions & 2 deletions lib/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function Context(resource, req, res, server) {
var done = this.done;
this.done = function() {
done.apply(ctx, arguments);
}
};

if ((this.query && typeof this.query.$limitRecursion !== 'undefined') || (this.body && typeof this.body.$limitRecursion !== 'undefined')) {
var recursionLimit = this.query.$limitRecursion || this.body.$limitRecursion || 0;
Expand Down Expand Up @@ -110,6 +110,6 @@ Context.prototype.done = function(err, res) {
} catch(e) {
console.error(e);
}
}
};

module.exports = Context;
12 changes: 6 additions & 6 deletions lib/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ db.connect = function (options, fn) {
var db = new Db(options);
db.open(fn);
return db;
}
};

/**
* A `Db` abstracts a driver implementation of the database. This allows for
Expand Down Expand Up @@ -86,7 +86,7 @@ Db.prototype.open = function (fn) {
debug('opened connection');
self.emit('connected');
});
}
};

/**
* Drop the underlying database.
Expand All @@ -97,7 +97,7 @@ Db.prototype.open = function (fn) {

Db.prototype.drop = function (fn) {
this._mdb.dropDatabase(fn);
}
};

/**
* Create a new database store (eg. a collection).
Expand All @@ -115,7 +115,7 @@ Db.prototype.drop = function (fn) {

Db.prototype.createStore = function (namespace) {
return new Store(namespace, this);
}
};

/**
* Initialize a space in the database (eg. a collection).
Expand Down Expand Up @@ -151,7 +151,7 @@ function collection(store, fn) {
} else {
execute();
}
};
}

/**
* Change public IDs to private IDs.
Expand Down Expand Up @@ -390,7 +390,7 @@ Store.prototype.update = function (query, object, fn) {
command.$set = object;
}

var multi = query._id ? false : true;
multi = query._id ? false : true;

debug('update - query', query);
debug('update - object', object);
Expand Down
4 changes: 2 additions & 2 deletions lib/internal-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function joinPath() {
return normalizePath(paths.filter(function(p, index) {
return p && typeof p === 'string';
}).join('/'));
};
}



Expand Down Expand Up @@ -116,7 +116,7 @@ exports.build = function(server, session, stack) {

baseMethods.get = function(options, fn) {
return baseMethods.request("GET", options, fn);
}
};

baseMethods.post = function(options, fn) {
return baseMethods.request("POST", options, fn);
Expand Down
Loading

0 comments on commit db24dce

Please sign in to comment.