From aae74144023c09b1e128959b04df5aaec7674920 Mon Sep 17 00:00:00 2001 From: "Elf M. Sternberg" Date: Mon, 13 Apr 2015 11:59:38 -0700 Subject: [PATCH] Updated, after cleaning files with JSCS, and using more recent versions. --- .gitignore | 1 + grunt.js => Gruntfile.js | 24 ++++++++++++------------ demo/app.js | 26 ++++++++++++++------------ package.json | 9 +++------ tasks/couchapp.js | 32 +++++++++++++++++--------------- test/couchapp_test.js | 9 +++++---- 6 files changed, 52 insertions(+), 49 deletions(-) rename grunt.js => Gruntfile.js (67%) diff --git a/.gitignore b/.gitignore index db3f887..bcd881b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ *~ npm-debug.log node_modules/* +package.yml diff --git a/grunt.js b/Gruntfile.js similarity index 67% rename from grunt.js rename to Gruntfile.js index cf738b7..42204aa 100644 --- a/grunt.js +++ b/Gruntfile.js @@ -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: '', - tasks: 'default' + 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"); }; diff --git a/demo/app.js b/demo/app.js index 09a6391..2ebe402 100644 --- a/demo/app.js +++ b/demo/app.js @@ -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; diff --git a/package.json b/package.json index 8fb8f01..5151390 100644 --- a/package.json +++ b/package.json @@ -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" ] -} \ No newline at end of file +} diff --git a/tasks/couchapp.js b/tasks/couchapp.js index 6b7811f..73831c7 100644 --- a/tasks/couchapp.js +++ b/tasks/couchapp.js @@ -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); diff --git a/test/couchapp_test.js b/test/couchapp_test.js index d1a4f62..7f07cfe 100644 --- a/test/couchapp_test.js +++ b/test/couchapp_test.js @@ -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(); + } };