Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bumping version to 0.3.11 and publishing to npm.

* Updated jquery init template to support the new plugins.jquery.com manifest spec
* Added dynamic jquery loader to jquery init template.
* Reworked jquery init task README "contributing" section.
* Other minor init task tweaks.
  • Loading branch information...
commit 882e5d155d0f1498836d98ed8aea1a3ec58c2da0 1 parent 4f3b664
@cowboy authored
View
2  package.json
@@ -1,7 +1,7 @@
{
"name": "grunt",
"description": "A task-based command line build tool for JavaScript projects.",
- "version": "0.3.10",
+ "version": "0.3.11",
"author": "\"Cowboy\" Ben Alman (http://benalman.com/)",
"homepage": "http://github.com/cowboy/grunt",
"repository": {
View
32 tasks/init.js
@@ -182,18 +182,25 @@ module.exports = function(grunt) {
if (prop in props) { pkg[prop] = props[prop]; }
});
// Author.
- pkg.author = {};
- ['name', 'email', 'url'].forEach(function(prop) {
- if (props['author_' + prop]) {
- pkg.author[prop] = props['author_' + prop];
- }
+ var hasAuthor = Object.keys(props).some(function(prop) {
+ return (/^author_/).test(prop);
});
+ if (hasAuthor) {
+ pkg.author = {};
+ ['name', 'email', 'url'].forEach(function(prop) {
+ if (props['author_' + prop]) {
+ pkg.author[prop] = props['author_' + prop];
+ }
+ });
+ }
// Other stuff.
if ('repository' in props) { pkg.repository = {type: 'git', url: props.repository}; }
if ('bugs' in props) { pkg.bugs = {url: props.bugs}; }
- pkg.licenses = props.licenses.map(function(license) {
- return {type: license, url: props.homepage + '/blob/master/LICENSE-' + license};
- });
+ if (props.licenses) {
+ pkg.licenses = props.licenses.map(function(license) {
+ return {type: license, url: props.homepage + '/blob/master/LICENSE-' + license};
+ });
+ }
// Node/npm-specific (?)
if (props.main) { pkg.main = props.main; }
@@ -207,11 +214,9 @@ module.exports = function(grunt) {
}
}
- pkg.dependencies = {};
if (props.dependencies) { pkg.dependencies = props.dependencies; }
if (props.devDependencies) { pkg.devDependencies = props.devDependencies; }
-
- pkg.keywords = props.keywords || [];
+ if (props.keywords) { pkg.keywords = props.keywords; }
// Allow final tweaks to the pkg object.
if (callback) { pkg = callback(pkg, props); }
@@ -519,12 +524,13 @@ module.exports = function(grunt) {
},
jquery_version: {
message: 'Required jQuery version',
- default: '~1.5',
+ default: '>= 1.6',
warning: 'Must be a valid semantic version range descriptor.'
},
node_version: {
message: 'What versions of node does it run on?',
- default: '~' + process.versions.node,
+ // TODO: pull from grunt's package.json
+ default: '>= 0.6.0',
warning: 'Must be a valid semantic version range descriptor.'
},
main: {
View
2  tasks/init/commonjs.js
@@ -35,6 +35,8 @@ exports.template = function(grunt, init, done) {
grunt.helper('prompt_for', 'main'),
grunt.helper('prompt_for', 'npm_test')
], function(err, props) {
+ props.keywords = [];
+
// Files to copy (and process).
var files = init.filesToCopy(props);
View
42 tasks/init/jquery.js
@@ -11,30 +11,23 @@
exports.description = 'Create a jQuery plugin, including QUnit unit tests.';
// Template-specific notes to be displayed before question prompts.
-exports.notes = '_Project name_ must start with "jquery." and should be a ' +
- 'unique ID not already in use at plugins.jquery.com. _Project title_ ' +
- 'should be a human-readable title, and doesn\'t need to contain the word ' +
- '"jQuery", although it may. For example, a plugin titled "Awesome Plugin" ' +
- 'might have the name "jquery.awesome-plugin".';
+exports.notes = '_Project name_ should not contain "jquery" or "js" and ' +
+ 'should be a unique ID not already in use at plugins.jquery.com. _Project ' +
+ 'title_ should be a human-readable title, and doesn\'t need to contain ' +
+ 'the word "jQuery", although it may. For example, a plugin titled "Awesome ' +
+ 'jQuery Plugin" might have the name "awesome-plugin". For more information ' +
+ 'please see the documentation at ' +
+ 'https://github.com/jquery/plugins.jquery.com/blob/master/docs/jquery.json.md';
// Any existing file or directory matching this wildcard will cause a warning.
exports.warnOn = '*';
// The actual init template.
exports.template = function(grunt, init, done) {
- // Change validation to require that name starts with "jquery."
- var prompts = grunt.helper('prompt_for_obj');
- prompts.name.validator = /^jquery\.[\w\-\.]+$/;
- prompts.name.warning = 'Must begin with "jquery." and be only letters, ' +
- 'numbers, dashes, dots or underscores.';
grunt.helper('prompt', {type: 'jquery'}, [
// Prompt for these values.
- grunt.helper('prompt_for', 'name', function(value, data, done) {
- // Prepend "jquery." to current name.
- value = data.full_name = 'jquery.' + value;
- done(null, value);
- }),
+ grunt.helper('prompt_for', 'name'),
grunt.helper('prompt_for', 'title', function(value, data, done) {
// Fix jQuery capitalization.
value = value.replace(/jquery/gi, 'jQuery');
@@ -51,6 +44,11 @@ exports.template = function(grunt, init, done) {
grunt.helper('prompt_for', 'author_url'),
grunt.helper('prompt_for', 'jquery_version')
], function(err, props) {
+ // A few additional properties.
+ props.jqueryjson = props.name + '.jquery.json';
+ props.dependencies = {jquery: props.jquery_version || '>= 1'};
+ props.keywords = [];
+
// Files to copy (and process).
var files = init.filesToCopy(props);
@@ -60,11 +58,17 @@ exports.template = function(grunt, init, done) {
// Actually copy (and process) files.
init.copyAndProcess(files, props, {noProcess: 'libs/**'});
- // jQuery plugins depend on jQuery!
- props.dependencies = {jquery: props.jquery_version || '1'};
+ // Generate package.json file, used by npm and grunt.
+ init.writePackageJSON('package.json', {
+ name: 'jquery-plugin',
+ version: '0.0.0-ignored',
+ npm_test: 'grunt qunit',
+ // TODO: pull from grunt's package.json
+ node_version: '>= 0.6.0',
+ });
- // Generate package.json file.
- init.writePackageJSON('package.json', props);
+ // Generate jquery.json file.
+ init.writePackageJSON(props.jqueryjson, props);
// All done!
done();
View
35 tasks/init/jquery/root/README.md
@@ -26,14 +26,39 @@ _(Coming soon)_
## Examples
_(Coming soon)_
-## Contributing
-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](https://github.com/cowboy/grunt).
-
-_Also, please don't edit files in the "dist" subdirectory as they are generated via grunt. You'll find source code in the "src" subdirectory!_
-
## Release History
_(Nothing yet)_
## License
Copyright (c) {%= grunt.template.today('yyyy') %} {%= author_name %}
Licensed under the {%= licenses.join(', ') %} license{%= licenses.length === 1 ? '' : 's' %}.
+
+## Contributing
+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](https://github.com/cowboy/grunt).
+
+### Important notes
+Please don't edit files in the `dist` subdirectory as they are generated via grunt. You'll find source code in the `src` subdirectory!
+
+While grunt can run the included unit tests via PhantomJS, this shouldn't be considered a substitute for the real thing. Please be sure to test the `test/*.html` unit test file(s) in _actual_ browsers.
+
+### Installing grunt
+_This assumes you have [node.js](http://nodejs.org/) and [npm](http://npmjs.org/) installed already._
+
+1. Test that grunt is installed globally by running `grunt --version` at the command-line.
+1. If grunt isn't installed globally, run `npm install -g grunt` to install the latest version. _You may need to run `sudo npm install -g grunt`._
+1. From the root directory of this project, run `npm install` to install the project's dependencies.
+
+### Installing PhantomJS
+
+In order for the qunit task to work properly, [PhantomJS](http://www.phantomjs.org/) must be installed and in the system PATH (if you can run "phantomjs" at the command line, this task should work).
+
+Unfortunately, PhantomJS cannot be installed automatically via npm or grunt, so you need to install it yourself. There are a number of ways to install PhantomJS.
+
+* [PhantomJS and Mac OS X](http://ariya.ofilabs.com/2012/02/phantomjs-and-mac-os-x.html)
+* [PhantomJS Installation](http://code.google.com/p/phantomjs/wiki/Installation) (PhantomJS wiki)
+
+Note that the `phantomjs` executable needs to be in the system `PATH` for grunt to see it.
+
+* [How to set the path and environment variables in Windows](http://www.computerhope.com/issues/ch000549.htm)
+* [Where does $PATH get set in OS X 10.6 Snow Leopard?](http://superuser.com/questions/69130/where-does-path-get-set-in-os-x-10-6-snow-leopard)
+* [How do I change the PATH variable in Linux](https://www.google.com/search?q=How+do+I+change+the+PATH+variable+in+Linux)
View
2  tasks/init/jquery/root/grunt.js
@@ -3,7 +3,7 @@ module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
- pkg: '<json:package.json>',
+ pkg: '<json:{%= jqueryjson %}>',
meta: {
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
View
14 tasks/init/jquery/root/libs/jquery-loader.js
@@ -0,0 +1,14 @@
+(function() {
+ // Get any jquery=___ param from the query string.
+ var jqversion = location.search.match(/[?&]jquery=(.*?)(?=&|$)/);
+ var path;
+ if (jqversion) {
+ // A version was specified, load that version from code.jquery.com.
+ path = 'http://code.jquery.com/jquery-' + jqversion[1] + '.js';
+ } else {
+ // No version was specified, load the local version.
+ path = '../libs/jquery/jquery.js';
+ }
+ // This is the only time I'll ever use document.write, I promise!
+ document.write('<script src="' + path + '"></script>');
+}());
View
9 tasks/init/jquery/root/test/name.html
@@ -3,15 +3,18 @@
<head>
<meta charset="utf-8">
<title>{%= title || name %} Test Suite</title>
- <!-- Load local jQuery, removing access to $ (use jQuery, not $). -->
- <script src="../libs/jquery/jquery.js"></script>
- <script>jQuery.noConflict()</script>
+ <!-- Load local jQuery. This can be overridden with a ?jquery=___ param. -->
+ <script src="../libs/jquery-loader.js"></script>
<!-- Load local QUnit (grunt requires v1.0.0 or newer). -->
<link rel="stylesheet" href="../libs/qunit/qunit.css" media="screen">
<script src="../libs/qunit/qunit.js"></script>
<!-- Load local lib and tests. -->
<script src="../src/{%= name %}.js"></script>
<script src="{%= name %}_test.js"></script>
+ <!-- Removing access to jQuery and $. But it'll still be available as _$, if
+ you REALLY want to mess around with jQuery in the console. REMEMBER WE
+ ARE TESTING YOUR PLUGIN HERE -->
+ <script>window._$ = jQuery.noConflict(true);</script>
</head>
<body>
<h1 id="qunit-header">{%= title || name %} Test Suite</h1>
View
2  tasks/init/node.js
@@ -36,6 +36,8 @@ exports.template = function(grunt, init, done) {
grunt.helper('prompt_for', 'main'),
grunt.helper('prompt_for', 'npm_test')
], function(err, props) {
+ props.keywords = [];
+
// Files to copy (and process).
var files = init.filesToCopy(props);
Please sign in to comment.
Something went wrong with that request. Please try again.