Compile CouchDB design documents from Couchapp like directory tree.
This plugin requires Grunt ~0.4.0
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-couch --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-couch');
In your project's Gruntfile, add a section named couch
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
couch: {
app: {
files: 'app.json': 'ddoc'
}
}
})
This will load the Couchapp like directory tree from ddoc and creates an app.json document.
See Configuring tasks: Files for more information about possible source and target configurations.
is quiet self-explanatory. For example:
ddoc
├── _attachments
│ ├── a
│ │ └── nested
│ │ └── file.txt
│ └── index.html
├── _id
├── language
├── lists
│ └── docs.js
├── rewrites.json
├── shows
│ ├── doc.js
│ └── hello.js
├── validate_doc_update.js
└── views
├── names
│ └── map.js
└── numbers
├── map.js
└── reduce
The output JSON follows the Bulk Document API:
{
"docs": [
{ "_id": "adoc" },
{ "_id": "anotherdoc" }
]
}
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.