From 5fcc173a38fa6286e859399e31e1ed7c793ddef8 Mon Sep 17 00:00:00 2001 From: Simon Metson Date: Thu, 28 Mar 2013 20:12:09 +0000 Subject: fix broken addon task --- license.skip | 1 + src/fauxton/package.json | 49 +++----------- src/fauxton/tasks/addon/rename.json | 5 ++ src/fauxton/tasks/addon/root/base.js.underscore | 21 ++++++ .../tasks/addon/root/resources.js.underscore | 21 ++++++ src/fauxton/tasks/addon/root/route.js.underscore | 21 ++++++ src/fauxton/tasks/addon/template.js | 67 +++++++++++++++++++ src/fauxton/tasks/fauxton.js | 78 ---------------------- src/fauxton/tasks/templates/base.js.underscore | 21 ------ .../tasks/templates/resources.js.underscore | 21 ------ src/fauxton/tasks/templates/route.js.underscore | 21 ------ src/fauxton/writing_addons.md | 14 ++-- 12 files changed, 151 insertions(+), 189 deletions(-) create mode 100644 src/fauxton/tasks/addon/rename.json create mode 100644 src/fauxton/tasks/addon/root/base.js.underscore create mode 100644 src/fauxton/tasks/addon/root/resources.js.underscore create mode 100644 src/fauxton/tasks/addon/root/route.js.underscore create mode 100644 src/fauxton/tasks/addon/template.js delete mode 100644 src/fauxton/tasks/templates/base.js.underscore delete mode 100644 src/fauxton/tasks/templates/resources.js.underscore delete mode 100644 src/fauxton/tasks/templates/route.js.underscore 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/addon/root/base.js.underscore b/src/fauxton/tasks/addon/root/base.js.underscore new file mode 100644 index 000000000..d002cd535 --- /dev/null +++ b/src/fauxton/tasks/addon/root/base.js.underscore @@ -0,0 +1,21 @@ +// 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. + +define([ + "app", + "api", + "addons/{%= name.toLowerCase() %}/routes" +], + +function(app, FauxtonAPI, {%= name %}) { + return {%= name %}; +}); diff --git a/src/fauxton/tasks/addon/root/resources.js.underscore b/src/fauxton/tasks/addon/root/resources.js.underscore new file mode 100644 index 000000000..8d0ef3297 --- /dev/null +++ b/src/fauxton/tasks/addon/root/resources.js.underscore @@ -0,0 +1,21 @@ +// 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. + +define([ + "app", + "api" +], + +function (app, FauxtonAPI) { + var {%= name %} = FauxtonAPI.addon(); + return {%= name %}; +}); diff --git a/src/fauxton/tasks/addon/root/route.js.underscore b/src/fauxton/tasks/addon/root/route.js.underscore new file mode 100644 index 000000000..859e5bb93 --- /dev/null +++ b/src/fauxton/tasks/addon/root/route.js.underscore @@ -0,0 +1,21 @@ +// 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. + +define([ + "app", + "api", + "addons/{%= name.toLowerCase() %}/resources" +], +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/tasks/templates/base.js.underscore b/src/fauxton/tasks/templates/base.js.underscore deleted file mode 100644 index cf7afa7ee..000000000 --- a/src/fauxton/tasks/templates/base.js.underscore +++ /dev/null @@ -1,21 +0,0 @@ -// 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. - -define([ - "app", - "api", - "addons/<%= module.toLowerCase() %>/routes" -], - -function(app, FauxtonAPI, <%= module %>) { - return <%= module %>; -}); diff --git a/src/fauxton/tasks/templates/resources.js.underscore b/src/fauxton/tasks/templates/resources.js.underscore deleted file mode 100644 index 0aa37f8bc..000000000 --- a/src/fauxton/tasks/templates/resources.js.underscore +++ /dev/null @@ -1,21 +0,0 @@ -// 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. - -define([ - "app", - "api" -], - -function (app, FauxtonAPI) { - var <%= module %> = FauxtonAPI.addon(); - return <%= module %>; -}); diff --git a/src/fauxton/tasks/templates/route.js.underscore b/src/fauxton/tasks/templates/route.js.underscore deleted file mode 100644 index 9256766d3..000000000 --- a/src/fauxton/tasks/templates/route.js.underscore +++ /dev/null @@ -1,21 +0,0 @@ -// 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. - -define([ - "app", - "api", - "addons/<%= module.toLowerCase() %>/resources" -], -function(app, FauxtonAPI, <%= module %>) { - <%= module %>.Routes = {}; - return <%= module %>; -}); 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. -- cgit v1.2.1