Updated, after cleaning files with JSCS, and using more recent versions.
This commit is contained in:
parent
0b295a3e15
commit
aae7414402
|
@ -3,3 +3,4 @@
|
||||||
*~
|
*~
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
node_modules/*
|
node_modules/*
|
||||||
|
package.yml
|
||||||
|
|
|
@ -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) {
|
module.exports = function(grunt) {
|
||||||
// Project configuration.
|
// Project configuration.
|
||||||
|
|
||||||
grunt.initConfig({
|
grunt.initConfig({
|
||||||
|
|
||||||
test: {
|
test: {
|
||||||
files: ['test/**/*.js']
|
files: ["test/**/*.js"]
|
||||||
},
|
|
||||||
lint: {
|
|
||||||
files: ['grunt.js', 'tasks/**/*.js', 'test/**/*.js']
|
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
files: '<config:lint.files>',
|
files: "<config:lint.files>",
|
||||||
tasks: 'default'
|
tasks: "default"
|
||||||
},
|
},
|
||||||
jshint: {
|
jshint: {
|
||||||
|
files: ["grunt.js", "tasks/**/*.js", "test/**/*.js"],
|
||||||
options: {
|
options: {
|
||||||
curly: true,
|
curly: true,
|
||||||
eqeqeq: true,
|
eqeqeq: true,
|
||||||
|
@ -48,15 +47,16 @@ module.exports = function(grunt) {
|
||||||
couchapp: {
|
couchapp: {
|
||||||
demo: {
|
demo: {
|
||||||
db: DEMO_COUCH_DB,
|
db: DEMO_COUCH_DB,
|
||||||
app: './demo/app.js'
|
app: "./demo/app.js"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
grunt.loadNpmTasks('grunt-contrib-jshint');
|
||||||
// Load local tasks.
|
// Load local tasks.
|
||||||
grunt.loadTasks('tasks');
|
grunt.loadTasks("tasks");
|
||||||
|
|
||||||
// Default task.
|
// Default task.
|
||||||
grunt.registerTask('default', 'lint test');
|
grunt.registerTask("default", ["jshint", "test"]);
|
||||||
grunt.registerTask('demo', 'rmcouchdb:demo mkcouchdb:demo couchapp:demo');
|
grunt.registerTask("demo", "rmcouchdb:demo mkcouchdb:demo couchapp:demo");
|
||||||
};
|
};
|
26
demo/app.js
26
demo/app.js
|
@ -1,22 +1,24 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
var couchapp, ddoc, path;
|
var couchapp, ddoc, path;
|
||||||
|
|
||||||
couchapp = require('couchapp');
|
couchapp = require("couchapp");
|
||||||
|
|
||||||
path = require('path');
|
path = require("path");
|
||||||
|
|
||||||
ddoc = {
|
ddoc = {
|
||||||
_id: '_design/app',
|
_id: "_design/app",
|
||||||
rewrites: {},
|
rewrites: {},
|
||||||
views: {},
|
views: {},
|
||||||
shows: {},
|
shows: {},
|
||||||
lists: {},
|
lists: {},
|
||||||
validate_doc_update: function(newDoc, oldDoc, userCtx) {
|
validate_doc_update: function(newDoc, oldDoc, userCtx) {
|
||||||
if (newDoc._deleted === true && userCtx.roles.indexOf('_admin') === -1) {
|
if (newDoc._deleted === true && userCtx.roles.indexOf("_admin") === -1) {
|
||||||
throw "Only admin can delete documents on this database.";
|
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;
|
module.exports = ddoc;
|
||||||
|
|
|
@ -30,14 +30,11 @@
|
||||||
"test": "grunt test"
|
"test": "grunt test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"couchapp": "0.9.1",
|
"couchapp": "~0.11.0",
|
||||||
"grunt": "~0.3.12",
|
"grunt": "~0.3.12",
|
||||||
"nano": "3.3.0"
|
"nano": "~5"
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"grunt": "~0.3.12"
|
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"gruntplugin"
|
"gruntplugin"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* grunt-couchapp https://github.com/elf/grunt-couchapp
|
* grunt-couchapp https://github.com/elf/grunt-couchapp
|
||||||
*
|
*
|
||||||
|
@ -7,16 +9,16 @@
|
||||||
|
|
||||||
var path, couchapp, nanolib, urls;
|
var path, couchapp, nanolib, urls;
|
||||||
|
|
||||||
path = require('path');
|
path = require("path");
|
||||||
couchapp = require('couchapp');
|
couchapp = require("couchapp");
|
||||||
urls = require('url');
|
urls = require("url");
|
||||||
|
|
||||||
module.exports = function(grunt) {
|
module.exports = function(grunt) {
|
||||||
|
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
// TASKS
|
// TASKS
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
||||||
grunt.registerMultiTask("couchapp", "Install Couchapp", function() {
|
grunt.registerMultiTask("couchapp", "Install Couchapp", function() {
|
||||||
var appobj, done;
|
var appobj, done;
|
||||||
done = this.async();
|
done = this.async();
|
||||||
|
@ -25,15 +27,15 @@ module.exports = function(grunt) {
|
||||||
return app.push(done);
|
return app.push(done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
grunt.registerMultiTask("rmcouchdb", "Delete a Couch Database", function() {
|
grunt.registerMultiTask("rmcouchdb", "Delete a Couch Database", function() {
|
||||||
var done, parts, nano, dbname, _this;
|
var done, parts, nano, dbname, _this;
|
||||||
_this = this;
|
_this = this;
|
||||||
done = this.async();
|
done = this.async();
|
||||||
parts = urls.parse(this.data.db);
|
parts = urls.parse(this.data.db);
|
||||||
dbname = parts.pathname.replace(/^\//, '');
|
dbname = parts.pathname.replace(/^\//, "");
|
||||||
try {
|
try {
|
||||||
nano = require('nano')(parts.protocol + '//' + parts.host);
|
nano = require("nano")(parts.protocol + "//" + parts.host);
|
||||||
nano.db.destroy(dbname, function(err) {
|
nano.db.destroy(dbname, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
if (err.status_code && err.status_code === 404) {
|
if (err.status_code && err.status_code === 404) {
|
||||||
|
@ -60,17 +62,17 @@ module.exports = function(grunt) {
|
||||||
_this = this;
|
_this = this;
|
||||||
done = this.async();
|
done = this.async();
|
||||||
parts = urls.parse(this.data.db);
|
parts = urls.parse(this.data.db);
|
||||||
dbname = parts.pathname.replace(/^\//, '');
|
dbname = parts.pathname.replace(/^\//, "");
|
||||||
try {
|
try {
|
||||||
nano = require('nano')(parts.protocol + '//' + parts.host);
|
nano = require("nano")(parts.protocol + "//" + parts.host);
|
||||||
nano.db.create(dbname, function(err) {
|
nano.db.create(dbname, function(err) {
|
||||||
if (_this.data.options && _this.data.options.okay_if_exists) {
|
if (_this.data.options && _this.data.options.okay_if_exists) {
|
||||||
if (err){
|
if (err) {
|
||||||
grunt.log.writeln("Database " + dbname + " exists, skipping");
|
grunt.log.writeln("Database " + dbname + " exists, skipping");
|
||||||
}
|
}
|
||||||
return done(null, null);
|
return done(null, null);
|
||||||
} else {
|
} else {
|
||||||
if (err){
|
if (err) {
|
||||||
grunt.warn(err);
|
grunt.warn(err);
|
||||||
}
|
}
|
||||||
return done(err, null);
|
return done(err, null);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
var grunt = require('grunt');
|
"use strict";
|
||||||
|
var grunt = require("grunt");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
======== A Handy Little Nodeunit Reference ========
|
======== A Handy Little Nodeunit Reference ========
|
||||||
|
@ -21,7 +22,7 @@ var grunt = require('grunt');
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.couchapp = {
|
exports.couchapp = {
|
||||||
setUp: function(done) {
|
setUp: function(done) {
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue