summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Metson <metson@apache.org>2013-03-28 20:12:09 +0000
committerSimon Metson <metson@apache.org>2013-03-28 20:12:09 +0000
commit5fcc173a38fa6286e859399e31e1ed7c793ddef8 (patch)
tree382294add68e32f91cddc3177ddf890605c9d2c8
parentfe44c6ef56c928725896182fa813c3b44ae8a54f (diff)
downloadcouchdb-1720-move-to-backbone-1.0.tar.gz
fix broken addon task1720-move-to-backbone-1.0
-rw-r--r--license.skip1
-rw-r--r--src/fauxton/package.json49
-rw-r--r--src/fauxton/tasks/addon/rename.json5
-rw-r--r--src/fauxton/tasks/addon/root/base.js.underscore (renamed from src/fauxton/tasks/templates/base.js.underscore)6
-rw-r--r--src/fauxton/tasks/addon/root/resources.js.underscore (renamed from src/fauxton/tasks/templates/resources.js.underscore)4
-rw-r--r--src/fauxton/tasks/addon/root/route.js.underscore (renamed from src/fauxton/tasks/templates/route.js.underscore)10
-rw-r--r--src/fauxton/tasks/addon/template.js67
-rw-r--r--src/fauxton/tasks/fauxton.js78
-rw-r--r--src/fauxton/writing_addons.md14
9 files changed, 98 insertions, 136 deletions
diff --git a/license.skip b/license.skip
index 7c1f783f9..291e51dcd 100644
--- a/license.skip
+++ b/license.skip
@@ -113,6 +113,7 @@
^src/fauxton/TODO.md
^src/fauxton/settings.json.*
^src/fauxton/test/.*
+^src/fauxton/tasks/rename.json
^src/ibrowse/.*
^src/mochiweb/.*
^src/snappy/.*
diff --git a/src/fauxton/package.json b/src/fauxton/package.json
index 75d7c639f..a6d746c7f 100644
--- a/src/fauxton/package.json
+++ b/src/fauxton/package.json
@@ -1,42 +1,9 @@
{
- "name": "fauxton",
- "version": "0.1.0",
- "description": "Fauxton is a modular CouchDB dashboard and Futon replacement.",
- "main": "grunt.js",
- "directories": {
- "test": "test"
- },
- "dependencies": {
- "async": "~0.2.6",
- "grunt": "~0.4.1",
- "grunt-cli": "~0.1.6",
- "couchapp": "~0.9.1",
- "grunt-contrib": "~0.5.0",
- "grunt-contrib-cssmin": "~0.5.0",
- "grunt-contrib-uglify": "~0.2.0",
- "grunt-couchapp": "~0.1.0",
- "grunt-exec": "~0.4.0",
- "grunt-jasmine-task": "~0.2.3",
- "grunt-requirejs": "~0.3.3",
- "underscore": "~1.4.2",
- "url": "~0.7.9",
- "urls": "~0.0.3",
- "express": "~3.0.6",
- "http-proxy": "~0.9.1"
- },
- "devDependencies": {},
- "scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
- },
- "repository": {
- "type": "git",
- "url": "https://git-wip-us.apache.org/repos/asf/couchdb.git"
- },
- "keywords": [
- "couchdb",
- "futon",
- "fauxton"
- ],
- "author": "",
- "license": "Apache V2"
-}
+ "name": "WickedCool",
+ "licenses": [
+ {
+ "type": "Apache",
+ "url": "undefined/blob/master/LICENSE-Apache"
+ }
+ ]
+} \ No newline at end of file
diff --git a/src/fauxton/tasks/addon/rename.json b/src/fauxton/tasks/addon/rename.json
new file mode 100644
index 000000000..1f326e948
--- /dev/null
+++ b/src/fauxton/tasks/addon/rename.json
@@ -0,0 +1,5 @@
+{
+ "route.js.underscore": "{%= path %}/{%= name.toLowerCase() %}/route.js",
+ "resources.js.underscore": "{%= path %}/{%= name.toLowerCase() %}/resources.js",
+ "base.js.underscore": "{%= path %}/{%= name.toLowerCase() %}/base.js"
+} \ No newline at end of file
diff --git a/src/fauxton/tasks/templates/base.js.underscore b/src/fauxton/tasks/addon/root/base.js.underscore
index cf7afa7ee..d002cd535 100644
--- a/src/fauxton/tasks/templates/base.js.underscore
+++ b/src/fauxton/tasks/addon/root/base.js.underscore
@@ -13,9 +13,9 @@
define([
"app",
"api",
- "addons/<%= module.toLowerCase() %>/routes"
+ "addons/{%= name.toLowerCase() %}/routes"
],
-function(app, FauxtonAPI, <%= module %>) {
- return <%= module %>;
+function(app, FauxtonAPI, {%= name %}) {
+ return {%= name %};
});
diff --git a/src/fauxton/tasks/templates/resources.js.underscore b/src/fauxton/tasks/addon/root/resources.js.underscore
index 0aa37f8bc..8d0ef3297 100644
--- a/src/fauxton/tasks/templates/resources.js.underscore
+++ b/src/fauxton/tasks/addon/root/resources.js.underscore
@@ -16,6 +16,6 @@ define([
],
function (app, FauxtonAPI) {
- var <%= module %> = FauxtonAPI.addon();
- return <%= module %>;
+ var {%= name %} = FauxtonAPI.addon();
+ return {%= name %};
});
diff --git a/src/fauxton/tasks/templates/route.js.underscore b/src/fauxton/tasks/addon/root/route.js.underscore
index 9256766d3..859e5bb93 100644
--- a/src/fauxton/tasks/templates/route.js.underscore
+++ b/src/fauxton/tasks/addon/root/route.js.underscore
@@ -12,10 +12,10 @@
define([
"app",
- "api",
- "addons/<%= module.toLowerCase() %>/resources"
+ "api",
+ "addons/{%= name.toLowerCase() %}/resources"
],
-function(app, FauxtonAPI, <%= module %>) {
- <%= module %>.Routes = {};
- return <%= module %>;
+function(app, FauxtonAPI, {%= name %}) {
+ {%= name %}.Routes = {};
+ return {%= name %};
});
diff --git a/src/fauxton/tasks/addon/template.js b/src/fauxton/tasks/addon/template.js
new file mode 100644
index 000000000..cdbd281aa
--- /dev/null
+++ b/src/fauxton/tasks/addon/template.js
@@ -0,0 +1,67 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+'use strict';
+
+exports.description = 'Generate a skeleton for an addon.';
+
+exports.notes = '';
+
+exports.after = "Created your addon! Don't forget to update your"+
+ " settings.json for it to be compiled and deployed";
+
+// Any existing file or directory matching this wildcard will cause a warning.
+// exports.warnOn = '*';
+
+// The actual init template.
+exports.template = function(grunt, init, done) {
+
+ // destpath
+ init.process(
+ {},
+ [
+ {
+ name: "name",
+ message: "Add on Name",
+ validator: /^[\w\-\.]+$/,
+ default: "WickedCool"
+ },
+ {
+ name: "path",
+ message: "Location of add ons",
+ default: "app/addons"
+ },
+ {
+ name: "assets",
+ message: "Do you need an assets folder? (for .less)",
+ default: 'y/N'
+ }
+ ],
+ function (err, props) {
+ // Files to copy (and process).
+ var files = init.filesToCopy(props);
+
+ // Actually copy and process (apply the template props) files.
+ init.copyAndProcess(files, props);
+
+ // Make the assets dir if requested
+ if (props.assets == "y"){
+ var asspath = props.path + "/" + props.name.toLowerCase() + "/assets";
+ grunt.file.mkdir(asspath);
+ grunt.log.writeln("Created " + asspath);
+ }
+
+ // All done!
+ done();
+ }
+ )
+}; \ No newline at end of file
diff --git a/src/fauxton/tasks/fauxton.js b/src/fauxton/tasks/fauxton.js
index b718fea95..a26f9f8c8 100644
--- a/src/fauxton/tasks/fauxton.js
+++ b/src/fauxton/tasks/fauxton.js
@@ -10,86 +10,8 @@
// License for the specific language governing permissions and limitations under
// the License.
-// var prompt = require('prompt');
-
module.exports = function(grunt) {
var _ = grunt.util._;
- var prompts = [
- {
- name: "name",
- message: "Add on Name",
- validator: /^[\w\-\.]+$/,
- default: "WickedCool"
- },
- {
- name: "path",
- message: "Location of add ons",
- default: "app/addons"
- },
- {
- name: "assets",
- message: "Do you need an assets folder? (for .less)",
- default: 'y/N'
- }
- ];
-
- addonTemplates = [
- {
- name: 'base',
- filename: 'base.js',
- template: grunt.file.read('./tasks/templates/base.js.underscore')
- },
- {
- name: 'resources',
- filename: 'resources.js',
- template: grunt.file.read('./tasks/templates/resources.js.underscore')
- },
- {
- name: 'routes',
- filename: 'routes.js',
- template: grunt.file.read('./tasks/templates/route.js.underscore')
- }
- ];
-
- // Create a new task.
- grunt.registerInitTask('addon', 'Generate a skeleton for an addon"', function() {
- var done = this.async();
- grunt.helper('prompt', {}, prompts, function (err, result) {
- if (err) { return onErr(err); }
- grunt.log.writeln(result.assets);
- var module = result.name,
- assets = result.assets;
- if (assets == 'y') {
- //if you need an assets folder
- filepath = result.path + '/' + module.toLowerCase() + '/assets/less';
- grunt.file.mkdir(filepath);
- lessfile = {
- name: 'less',
- filename: module.toLowerCase()+'.less',
- template: '//<%= module %> styles'
- };
- lessfile.module = module.charAt(0).toUpperCase() + module.substr(1);
- var content = grunt.template.process(lessfile.template, lessfile);
- grunt.file.write(filepath + '/' + lessfile.filename, content);
- }
- filepath = result.path + '/' + module.toLowerCase() + '/templates';
- grunt.file.mkdir(filepath);
- filepath = result.path + '/' + module.toLowerCase();
- _.each(addonTemplates, function(file){
- file.module = module.charAt(0).toUpperCase() + module.substr(1);
- var content = grunt.template.process(file.template, file);
- grunt.file.write(filepath + '/' + file.filename, content);
- });
- grunt.log.writeln('Created addon ' + result.name + ' in ' + result.path);
- grunt.log.writeln('\n\nAdd ' + result.name + ' to settings.json for it to be compiled and deployed');
- done();
- });
- function onErr(err) {
- grunt.log.writeln(err);
- done();
- return 1;
- }
- });
grunt.registerMultiTask('template', 'generates an html file from a specified template', function(){
var data = this.data;
diff --git a/src/fauxton/writing_addons.md b/src/fauxton/writing_addons.md
index ccd09af3c..e0a85fae0 100644
--- a/src/fauxton/writing_addons.md
+++ b/src/fauxton/writing_addons.md
@@ -11,14 +11,14 @@ have the following structure:
[optional]
* assets/less
- * my_addon.less
+ * my_addon.less
## Generating an addon
-We have a grunt task that lets you create a skeleton addon, including all the
-boiler plate code. Run `bbb addon` and answer the questions it asks to create
-an addon:
+We have a `grunt-init` template that lets you create a skeleton addon,
+including all the boiler plate code. Run `grunt-init tasks/addon` and answer
+the questions it asks to create an addon:
- ± bbb addon
+ ± grunt-init tasks/addon
path.existsSync is now called `fs.existsSync`.
Running "addon" task
@@ -32,8 +32,8 @@ an addon:
Done, without errors.
-Once the addon is created add the name to the settings.json file to get it compiled
-and added on the next install.
+Once the addon is created add the name to the settings.json file to get it
+compiled and added on the next install.
## Routes and hooks
An addon can insert itself into fauxton in two ways; via a route or via a hook.