Updated, after cleaning files with JSCS, and using more recent versions.

This commit is contained in:
Elf M. Sternberg 2015-04-13 11:59:38 -07:00
parent 0b295a3e15
commit aae7414402
6 changed files with 52 additions and 49 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
*~
npm-debug.log
node_modules/*
package.yml

View File

@ -1,21 +1,20 @@
var DEMO_COUCH_DB = 'http://localhost:5984/grunt-couchapp-demo';
"use strict";
var DEMO_COUCH_DB = "http://localhost:5984/grunt-couchapp-demo";
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
test: {
files: ['test/**/*.js']
},
lint: {
files: ['grunt.js', 'tasks/**/*.js', 'test/**/*.js']
files: ["test/**/*.js"]
},
watch: {
files: '<config:lint.files>',
tasks: 'default'
files: "<config:lint.files>",
tasks: "default"
},
jshint: {
files: ["grunt.js", "tasks/**/*.js", "test/**/*.js"],
options: {
curly: true,
eqeqeq: true,
@ -48,15 +47,16 @@ module.exports = function(grunt) {
couchapp: {
demo: {
db: DEMO_COUCH_DB,
app: './demo/app.js'
app: "./demo/app.js"
}
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
// Load local tasks.
grunt.loadTasks('tasks');
grunt.loadTasks("tasks");
// Default task.
grunt.registerTask('default', 'lint test');
grunt.registerTask('demo', 'rmcouchdb:demo mkcouchdb:demo couchapp:demo');
grunt.registerTask("default", ["jshint", "test"]);
grunt.registerTask("demo", "rmcouchdb:demo mkcouchdb:demo couchapp:demo");
};

View File

@ -1,22 +1,24 @@
"use strict";
var couchapp, ddoc, path;
couchapp = require('couchapp');
couchapp = require("couchapp");
path = require('path');
path = require("path");
ddoc = {
_id: '_design/app',
rewrites: {},
views: {},
shows: {},
lists: {},
validate_doc_update: function(newDoc, oldDoc, userCtx) {
if (newDoc._deleted === true && userCtx.roles.indexOf('_admin') === -1) {
throw "Only admin can delete documents on this database.";
_id: "_design/app",
rewrites: {},
views: {},
shows: {},
lists: {},
validate_doc_update: function(newDoc, oldDoc, userCtx) {
if (newDoc._deleted === true && userCtx.roles.indexOf("_admin") === -1) {
throw "Only admin can delete documents on this database.";
}
}
}
};
couchapp.loadAttachments(ddoc, path.join(__dirname, 'attachments'));
couchapp.loadAttachments(ddoc, path.join(__dirname, "attachments"));
module.exports = ddoc;

View File

@ -30,14 +30,11 @@
"test": "grunt test"
},
"dependencies": {
"couchapp": "0.9.1",
"couchapp": "~0.11.0",
"grunt": "~0.3.12",
"nano": "3.3.0"
},
"devDependencies": {
"grunt": "~0.3.12"
"nano": "~5"
},
"keywords": [
"gruntplugin"
]
}
}

View File

@ -1,3 +1,5 @@
"use strict";
/*
* grunt-couchapp https://github.com/elf/grunt-couchapp
*
@ -7,16 +9,16 @@
var path, couchapp, nanolib, urls;
path = require('path');
couchapp = require('couchapp');
urls = require('url');
path = require("path");
couchapp = require("couchapp");
urls = require("url");
module.exports = function(grunt) {
// ==========================================================================
// TASKS
// ==========================================================================
// ==========================================================================
// TASKS
// ==========================================================================
grunt.registerMultiTask("couchapp", "Install Couchapp", function() {
var appobj, done;
done = this.async();
@ -25,15 +27,15 @@ module.exports = function(grunt) {
return app.push(done);
});
});
grunt.registerMultiTask("rmcouchdb", "Delete a Couch Database", function() {
var done, parts, nano, dbname, _this;
_this = this;
done = this.async();
parts = urls.parse(this.data.db);
dbname = parts.pathname.replace(/^\//, '');
dbname = parts.pathname.replace(/^\//, "");
try {
nano = require('nano')(parts.protocol + '//' + parts.host);
nano = require("nano")(parts.protocol + "//" + parts.host);
nano.db.destroy(dbname, function(err) {
if (err) {
if (err.status_code && err.status_code === 404) {
@ -60,17 +62,17 @@ module.exports = function(grunt) {
_this = this;
done = this.async();
parts = urls.parse(this.data.db);
dbname = parts.pathname.replace(/^\//, '');
dbname = parts.pathname.replace(/^\//, "");
try {
nano = require('nano')(parts.protocol + '//' + parts.host);
nano = require("nano")(parts.protocol + "//" + parts.host);
nano.db.create(dbname, function(err) {
if (_this.data.options && _this.data.options.okay_if_exists) {
if (err){
if (err) {
grunt.log.writeln("Database " + dbname + " exists, skipping");
}
return done(null, null);
} else {
if (err){
if (err) {
grunt.warn(err);
}
return done(err, null);

View File

@ -1,4 +1,5 @@
var grunt = require('grunt');
"use strict";
var grunt = require("grunt");
/*
======== A Handy Little Nodeunit Reference ========
@ -21,7 +22,7 @@ var grunt = require('grunt');
*/
exports.couchapp = {
setUp: function(done) {
done();
}
setUp: function(done) {
done();
}
};