Skip to content
Browse files

Initial commit

  • Loading branch information...
0 parents commit 57b685c6d83b1df8a69c9f1d637c7a28aaa7ffbd @czukowski committed
1 .npmignore
@@ -0,0 +1 @@
+/node_modules/
25 LICENSE.md
@@ -0,0 +1,25 @@
+The MIT License
+===============
+
+Copyright (c) 2012 Korney Czukowski <carbofos@seznam.cz>
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
34 README.md
@@ -0,0 +1,34 @@
+MooTools plugin template
+========================
+
+Boilerplate to generate MooTools plugins using [Grunt][1].
+
+This work is based on [Grunt init template generator][2] from [Rodrigo Valerio][3] and borrows a lot from [Grunt][1]'s own init templates.
+
+Getting Started
+---------------
+
+ 1. Install this [Grunt][1] plugin with:
+
+ ```bash
+ $ npm install -g grunt-init-mootools
+ ```
+
+ 2. Create a new grunt MooTools plugin stub in an empty directory
+
+ ```bash
+ $ grunt-init-mootools init
+ ```
+
+ 3. Answer some questions.
+
+ 4. Now you have your new plugin stub ready. Just add code, specs and API docs into the prepared template files.
+
+License
+-------
+
+Copyright (c) 2012 Korney Czukowski Licensed under the MIT license.
+
+ [1]: http://gruntjs.com/
+ [2]: https://npmjs.org/package/grunt-init-plugin
+ [3]: https://github.com/rsvalerio
10 bin/grunt-init-mootools
@@ -0,0 +1,10 @@
+#!/usr/bin/env node
+var grunt = require("grunt");
+
+// Preload all custom tasks.
+grunt.npmTasks([
+ "grunt-init-mootools"
+]);
+
+// Otherwise, invoke the CLI.
+grunt.cli();
46 grunt.js
@@ -0,0 +1,46 @@
+'use strict';
+
+module.exports = function(grunt) {
+
+ // Project configuration.
+ grunt.initConfig({
+ test: {
+ files: ["test/**/*.js"]
+ },
+
+ lint: {
+ files: ["grunt.js", "tasks/**/*.js", "test/**/*.js"]
+ },
+
+ watch: {
+ files: "<config:lint.files>",
+ tasks: "default"
+ },
+
+ jshint: {
+ options: {
+ curly: true,
+ eqeqeq: true,
+ immed: true,
+ latedef: true,
+ newcap: true,
+ noarg: true,
+ sub: true,
+ undef: true,
+ boss: true,
+ eqnull: true,
+ node: true,
+ es5: true,
+ globalstrict: true
+ },
+ globals: {}
+ }
+ });
+
+ // Load local tasks.
+ grunt.loadTasks("tasks");
+
+ // Default task.
+ grunt.registerTask("default", "lint test");
+
+};
46 package.json
@@ -0,0 +1,46 @@
+{
+ "name": "grunt-init-mootools",
+ "description": "Grunt plugin to generate Mootools plugin stub.",
+ "version": "0.1.0",
+ "homepage": "https://github.com/czukowski/grunt-init-mootools",
+ "author": {
+ "name": "Korney Czukowski",
+ "email": "carbofos@seznam.cz"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/czukowski/grunt-init-mootools.git"
+ },
+ "bugs": {
+ "url": "https://github.com/czukowski/grunt-init-mootools/issues"
+ },
+ "licenses": [
+ {
+ "type": "MIT",
+ "url": "https://github.com/czukowski/grunt-init-mootools/blob/master/LICENSE.md"
+ }
+ ],
+ "main": "grunt.js",
+ "bin": {
+ "grunt-init-mootools": "bin/grunt-init-mootools"
+ },
+ "engines": {
+ "node": "*"
+ },
+ "scripts": {
+ "test": "grunt test"
+ },
+ "devDependencies": {
+ "grunt": "~0.3.15"
+ },
+ "keywords": [
+ "gruntplugin",
+ "mootools"
+ ],
+ "readme": "# grunt-init-mootools\r\n\r\nGrunt plugin to generate Mootools plugin stub.\r\n\r\nBoilerplate to generate grunt init plugins that will generate grunt projects.\r\n\r\nThis work is based in [Backbone Boilerplate framework tool](https://github.com/backbone-boilerplate/grunt-bbb) from [Tim Branyen](https://github.com/tbranyen)\r\n\r\n## Getting Started ##\r\n\r\n#### Install this [Grunt](https://github.com/cowboy/grunt) plugin with: ####\r\n``` bash\r\n$ npm install -g grunt-init-mootools\r\n```\r\n\r\n#### Create a new grunt init template ####\r\n``` bash\r\n$ grunt-init-mootools init\r\n```\r\nAnswer some questions\r\n\r\n#### Add some file in ####\r\n``` bash\r\n$ /tasks/init/grunt-init-mootools/root\r\n```\r\n\r\n#### To run in development environment ####\r\n``` bash\r\n$ npm link\r\n```\r\n\r\n``` bash\r\n$ grunt-init-mootools init\r\n```\r\n\r\n## License\r\n\r\nCopyright (c) 2012 Korney Czukowski Licensed under the MIT license.",
+ "_id": "grunt-init-mootools@0.1.0",
+ "dist": {
+ "shasum": "674e086f13a7f44f551de21490d1abb69d715931"
+ },
+ "_from": "."
+}
79 tasks/init/grunt-init-mootools.js
@@ -0,0 +1,79 @@
+/**
+ * grunt-init-mootools.js
+ *
+ * Copyright (c) 2012 Korney Czukowski
+ * Licensed under the MIT license.
+ */
+'use strict';
+
+// Basic template description.
+exports.description = "Create a MooTools plugin stub, including specs and API docs.";
+
+// Template-specific notes to be displayed before question prompts
+exports.notes = "After you initialize the project, install the grunt-mocha module to this dir:\n"+
+ "npm install grunt-mocha";
+
+// Any existing file or directory matching this wildcard will cause a warning
+exports.warnOn = "*";
+
+// The actual init template
+exports.template = function(grunt, init, done) {
+
+ // File names of the license files are altered compared to default grunt logic:
+ // If only one license is used, the file is LICENSE.md, else they are LICENSE-<name>.md
+ var getLicenseFilePath = function(license) {
+ var fileobj = grunt.task.expandFiles('init/licenses/LICENSE-'+license)[0];
+ return fileobj ? fileobj.rel : null;
+ };
+ init.addLicenseFiles = function(files, licenses) {
+ if (licenses.length > 1) {
+ licenses.forEach(function(license) {
+ files['LICENSE-'+license+'.md'] = getLicenseFilePath(license);
+ });
+ }
+ else if (licenses.length === 1) {
+ files['LICENSE.md'] = getLicenseFilePath(licenses[0]);
+ }
+ };
+
+ grunt.helper('prompt', {}, [
+ // Prompt for these values
+ grunt.helper('prompt_for', 'name', 'Test'),
+ grunt.helper('prompt_for', 'title', function(value, data, done) {
+ // Fix MooTools capitalization
+ value = value.replace(/mootools/gi, 'MooTools');
+ done(null, value);
+ }),
+ grunt.helper('prompt_for', 'description', 'The best MooTools plugin ever'),
+ grunt.helper('prompt_for', 'version'),
+ grunt.helper('prompt_for', 'repository'),
+ grunt.helper('prompt_for', 'homepage'),
+ grunt.helper('prompt_for', 'bugs'),
+ grunt.helper('prompt_for', 'licenses', 'MIT'),
+ grunt.helper('prompt_for', 'author_name'),
+ grunt.helper('prompt_for', 'author_email'),
+ grunt.helper('prompt_for', 'author_url'),
+ {
+ name: 'mootools_version',
+ message: 'Required MooTools version',
+ default: '>= 1.4',
+ warning: 'Must be a valid semantic version range descriptor.'
+ }
+ ], function(err, props) {
+ // A few additional properties
+ props.dependencies = {mootools: props.mootools_version || '>= 1.4'};
+ props.keywords = [];
+
+ // Files to copy (and process)
+ var files = init.filesToCopy(props);
+
+ // Add properly-named license files
+ init.addLicenseFiles(files, props.licenses);
+
+ // Actually copy (and process) files
+ init.copyAndProcess(files, props);
+
+ // All done!
+ done();
+ });
+};
8 tasks/init/grunt-init-mootools/rename.json
@@ -0,0 +1,8 @@
+{
+ "Docs/Name.md": "Docs/{%= name %}.md",
+ "Source/Name.js": "Source/{%= name %}.js",
+ "Specs/Name.js": "Specs/{%= name %}.js",
+ ".gitignore": ".gitignore",
+ ".npmignore": false,
+ ".DS_Store": false
+}
2 tasks/init/grunt-init-mootools/root/.gitignore
@@ -0,0 +1,2 @@
+/node_modules/
+/.npmignore
7 tasks/init/grunt-init-mootools/root/Docs/Name.md
@@ -0,0 +1,7 @@
+# Object: {%= name %}
+
+{%= description %}.
+
+## {%= name %}.method
+
+_(Coming soon)_
35 tasks/init/grunt-init-mootools/root/README.md
@@ -0,0 +1,35 @@
+# {%= title || name %}
+
+{%= description %}
+
+## Getting started
+
+Download the latest stable release version:
+
+[![Zipball](http://github.com/images/modules/download/zip.png)](https://github.com/{%= git_user %}/{%= git_repo %}/archive/tag-name.zip)
+[![Tarball](http://github.com/images/modules/download/tar.png)](https://github.com/{%= git_user %}/{%= git_repo %}/archive/tag-name.tar.gz)
+
+In your web page:
+
+```html
+<script src="mootools.js"></script>
+<script src="Source/{%= name %}.js"></script>
+<script>
+document.addEvent('ready', function() {
+ // Initialize here
+});
+</script>
+```
+
+## Documentation
+
+[API Docs](blob/master/Docs/{%= name %}.md)
+
+## Examples
+
+_(Coming soon)_
+
+## License
+
+Copyright (c) {%= grunt.template.today('yyyy') %} {%= author_name %}
+Licensed under the {%= licenses.join(', ') %} license{%= licenses.length === 1 ? '' : 's' %}.
21 tasks/init/grunt-init-mootools/root/Source/Name.js
@@ -0,0 +1,21 @@
+/*
+---
+name: {%= name %}
+description: {%= description %}.
+license: {%= licenses.join(', ') %} license{%= licenses.length === 1 ? '' : 's' %}.
+authors:
+ - {%= author_name %}
+requires:
+provides: {%= name %}
+...
+*/
+
+var {%= name %} = new Class({
+
+ // Put your code here
+
+ initialize: function() {
+
+ }
+
+});
20 tasks/init/grunt-init-mootools/root/Specs/Name.js
@@ -0,0 +1,20 @@
+/*
+---
+name: {%= name %} Specs
+description: n/a
+requires: [{%= name %}]
+provides: [{%= name %}.Specs]
+...
+*/
+
+describe('{%= name %}', function() {
+
+ // Put your specs here
+
+ describe('Constructor test', function() {
+ it('should export constructor', function() {
+ {%= name %}.should.be.a('function');
+ });
+ });
+
+});
52 tasks/init/grunt-init-mootools/root/Specs/Tests.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+ <title>Testing {%= name %} Specs</title>
+ <link rel="stylesheet" href="../node_modules/grunt-mocha/example/test/css/mocha.css" type="text/css" charset="utf-8" />
+ <script src="http://ajax.googleapis.com/ajax/libs/mootools/1.4.5/mootools-yui-compressed.js"></script>
+ </head>
+ <body>
+ <!-- Required for browser reporter -->
+ <div id="mocha"></div>
+
+ <!-- mocha -->
+ <script src="../node_modules/grunt-mocha/example/test/js/mocha.js" type="text/javascript" charset="utf-8"></script>
+ <script type="text/javascript" charset="utf-8">
+ // This will be overridden by mocha-helper if you run with grunt
+ mocha.setup('bdd');
+ </script>
+
+ <!--
+ IMPORTANT
+ If you are not using AMD, you must include the mocha-helper.js file
+ included in the tasks/mocha folder after you include mocha.js
+
+ Unfortunately, I can't figure out a reliable way to inject the grunt
+ runner after mocha.js but before mocha.run in PhantomJS
+ -->
+ <script src="../node_modules/grunt-mocha/tasks/mocha/mocha-helper.js" type="text/javascript" charset="utf-8"></script>
+
+ <!-- Include your assertion lib of choice -->
+ <script src="../node_modules/grunt-mocha/example/test/js/chai.js" type="text/javascript" charset="utf-8"></script>
+ <script type="text/javascript" charset="utf-8">
+ // Setup chai
+ var should = chai.should();
+ </script>
+
+ <!-- Include anything you want to test -->
+ <script src="../Source/{%= name %}.js" type="text/javascript" charset="utf-8"></script>
+
+ <!-- Spec files -->
+ <script src="{%= name %}.js" type="text/javascript" charset="utf-8"></script>
+
+ <!-- run mocha -->
+ <script type="text/javascript" charset="utf-8">
+ mocha
+ .globals(['{%= name %}']) // acceptable globals
+ .run();
+ </script>
+
+ </body>
+</html>
+
68 tasks/init/grunt-init-mootools/root/grunt.js
@@ -0,0 +1,68 @@
+/*global module:false*/
+module.exports = function(grunt) {
+
+ // Project configuration
+ grunt.initConfig({
+ meta: {
+ banner: '/**\n' +
+ ' * {%= title || name %} - v{%= version %} - {%= grunt.template.today("yyyy-mm-dd") %}\n' +
+ '{%= homepage ? " * " + homepage + "\n" : "" %}' +
+ ' * Copyright (c) {%= grunt.template.today("yyyy") %} {%= author_name %};\n' +
+ ' * License: {%= licenses.join(", ") %}\n' +
+ ' */'
+ },
+ concat: {
+ dist: {
+ src: ['<banner:meta.banner>', '<file_strip_banner:Source/{%= name %}.js>'],
+ dest: 'Dist/{%= name %}.js'
+ }
+ },
+ min: {
+ dist: {
+ src: ['<banner:meta.banner>', '<config:concat.dist.dest>'],
+ dest: 'Dist/{%= name %}-min.js'
+ }
+ },
+ mocha: {
+ all: ['Specs/**/*.html']
+ },
+ lint: {
+ files: ['grunt.js', 'Source/**/*.js', 'Specs/**/*.js']
+ },
+ watch: {
+ files: '<config:lint.files>',
+ tasks: 'lint mocha'
+ },
+ jshint: {
+ options: {
+ curly: true,
+ eqeqeq: true,
+ immed: true,
+ latedef: true,
+ newcap: true,
+ noarg: true,
+ sub: true,
+ undef: true,
+ boss: true,
+ eqnull: true,
+ browser: true
+ },
+ globals: {
+ // For MooTools
+ Class: true,
+ {%= name %}: true,
+ // For specs
+ describe: true,
+ it: true
+ }
+ },
+ uglify: {}
+ });
+
+ // Load mocha module - install to your project dir with: `npm install grunt-mocha`
+ grunt.loadNpmTasks('grunt-mocha');
+
+ // Default task
+ grunt.registerTask('default', 'lint mocha concat min');
+
+};

0 comments on commit 57b685c

Please sign in to comment.
Something went wrong with that request. Please try again.