Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
davglass committed Feb 25, 2013
0 parents commit 692054a
Show file tree
Hide file tree
Showing 14 changed files with 1,009 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
**/node_modules/
**/npm-debug.log
node_modules/
.DS_Store
.*.swp
.svn
*~
coverage

25 changes: 25 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Copyright 2013 Yahoo! Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Yahoo! Inc. nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL YAHOO! INC. BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Grunt YUI Contrib
=================

Various Grunt tasks used to within the YUI Project.

Usage
-----

```
>>
>> Showing YUI specific help commands
>>
build Build the entire library (and npm package) locally with yogi
release Build a release (dist, cdn and npm)
build-test Build and test the entire library
test Test the library with yogi
test-cli Test the library via CLI with yogi
travis Perform a travis build and test (uses enviroment vars to determine tests)
help Show this stuffs
>> Options:
--release-version=<VERSION> Pass to set the version of the release (required for a release build)
--release-build=<BUILD> Pass to set the build number of the release, if not passed the git sha will be used.
--cache-build Cache the shifter build.
```

Build Status
------------

[![Build Status](https://secure.travis-ci.org/yui/grunt-yui-contrib.png?branch=master)](http://travis-ci.org/yui/grunt-yui-contrib)
38 changes: 38 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "grunt-yui-contrib",
"description": "YUI Build Tasks",
"version": "0.0.1",
"dependencies": {
"cpr": "~0.0.6",
"timethat": "~0.0.2",
"rimraf": "~2.1.4",
"cssproc": "~0.0.1"
},
"peerDependencies": {
"grunt": "~0.4.0"
},
"devDependencies": {
"vows": "*",
"yui-lint": "~0.1.1",
"jshint": "~0.9.0",
"istanbul": "~0.1.8"
},
"keywords": [
"yui", "grunt"
],
"scripts": {
"pretest": "jshint --config ./node_modules/yui-lint/jshint.json ./tasks/*.js",
"test": "istanbul cover --print both vows -- --spec ./tests/*.js"
},
"bugs": { "url" : "http://github.com/yui/grunt-yui-contrib/issues" },
"licenses":[
{
"type" : "BSD",
"url" : "https://github.com/yui/grunt-yui-contrib/blob/master/LICENSE"
}
],
"repository": {
"type":"git",
"url":"http://github.com/yui/grunt-yui-contrib.git"
}
}
9 changes: 9 additions & 0 deletions tasks/boot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
Copyright (c) 2013, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://yuilibrary.com/license/
*/

module.exports = function(grunt) {
grunt.registerTask('boot', 'Booting YUI with Grunt', ['help']);
};
12 changes: 12 additions & 0 deletions tasks/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
Copyright (c) 2013, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://yuilibrary.com/license/
*/

module.exports = function(grunt) {
grunt.registerTask('build', 'Building YUI', ['yogi-build', 'npm']);
grunt.registerTask('build-test', 'Building and testing YUI', ['yogi-build', 'npm', 'test']);
grunt.registerTask('all', 'Building and testing YUI', ['build-test']);
};

230 changes: 230 additions & 0 deletions tasks/dist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
/*
Copyright (c) 2013, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://yuilibrary.com/license/
*/


var path = require('path'),
fs = require('fs'),
exists = fs.existsSync || path.existsSync,
exec = require('child_process').spawn,
cpr = require('cpr').cpr;

module.exports = function(grunt) {

var VERSION = grunt.option('release-version'),
STAMP = [
'/*',
'<%= buildtag %>',
'<%= copyright %>',
'<%= license %>',
'*/',
'',
''
].join('\n'),
start = path.join(process.cwd(), 'release', VERSION);


grunt.config.set('version', VERSION);

grunt.registerTask('dist', 'Create a YUI Dist Release', [
'dist-tag',
'dist-docs',
'dist-api',
'dist-releasenotes',
'dist-tests',
'dist-skins',
'dist-extras'
]);

grunt.registerTask('dist-tag', 'Tag files with copyright stamp', function() {
var stamp = grunt.template.process(STAMP),
count = 0;
grunt.log.ok('Adding build stamp and copyright');
grunt.log.ok('Adding the following stamp to all JS and CSS files');
grunt.log.writeln('\n' + stamp);
grunt.file.recurse(path.join(start, 'dist', 'build'), function(abs, root, part, file) {
if (path.extname(file) === '.js' || path.extname(file) === '.css') {
count++;
grunt.verbose.writeln(abs);
var data = grunt.file.read(abs);
grunt.file.write(abs, stamp + data);
}
});
grunt.log.ok('Finished processing ' + count + ' files.');
});

grunt.registerTask('dist-api', 'Dist Release API Docs', function() {
grunt.log.writeln('Using YUIDoc to generate docs');
var done = this.async(),
base = path.join(start, 'dist', 'api'),
yuidoc = path.join(process.cwd(), 'node_modules/yogi/node_modules/yuidocjs/lib/cli.js'),
fakeJSON = grunt.file.readJSON(path.join(process.cwd(), 'src/common/api/dist.json')),
docJSON = path.join(start, 'yuidoc-dist.json'),
child;

fakeJSON.version = VERSION;

grunt.file.write(docJSON, JSON.stringify(fakeJSON, null, 4) + '\n');

child = exec(process.execPath, [
yuidoc,
'--config',
docJSON,
'--outdir',
base
], {
cwd: path.join(process.cwd(), 'src'),
env: process.env
});

child.on('exit', function(code) {
if (code) {
grunt.fail.fatal('YUIDoc exited with code ' + code, code);
}
grunt.log.ok('YUIDoc API Docs Complete');
fs.unlinkSync(docJSON);
done();
});
});

grunt.registerTask('dist-docs', 'Dist Release Docs', function() {

grunt.log.writeln('Using Selleck to generate docs');
var done = this.async(),
base = path.join(start, 'dist', 'docs'),
selleck = path.join(process.cwd(), 'node_modules/yogi/node_modules/selleck/bin/selleck'),
fakeJSON = grunt.file.readJSON(path.join(process.cwd(), 'src/common/docs/dist.json')),
selleckJSON = path.join(start, 'selleck-dist.json'),
child;

fakeJSON.yuiVersion = VERSION;
grunt.file.write(selleckJSON, JSON.stringify(fakeJSON, null, 4) + '\n');

child = exec(process.execPath, [
selleck,
'--meta',
selleckJSON,
'--out',
base
], {
cwd: path.join(process.cwd(), 'src'),
env: process.env
});

child.on('exit', function(code) {
if (code) {
grunt.fail.fatal('Selleck exited with code ' + code, code);
}
grunt.log.ok('Selleck docs complete');
fs.unlinkSync(selleckJSON);
done();
});

});

grunt.registerTask('dist-extras', 'Adding extras to release', function() {
grunt.log.writeln('Adding extras to release');

var RM = path.join(process.cwd(), 'README.md'),
RRM = path.join(start, 'dist', 'README.md');
L = path.join(process.cwd(), 'LICENSE.md'),
RL = path.join(start, 'dist', 'LICENSE.md');

grunt.file.copy(RM, RRM);
grunt.file.copy(L, RL);

});

grunt.registerTask('dist-skins', 'Munging skins', function() {
grunt.log.writeln('Munging skins into the dist');
var done = this.async(),
base = path.join(start, 'dist', 'build'),
skinSrc = {};

grunt.log.writeln('Creating rollup skins');

cpr(path.join(process.cwd(), 'src/common/assets'),
path.join(base, 'assets'),
function() {
grunt.file.recurse(base, function(abs, root, part, file) {
var skinName, parts, dest;
if (grunt.file.isMatch('*/assets/skins/'+'*', part)) {
if (file.indexOf('-skin.css') > -1) {
skinName = path.basename(part);
skinSrc[skinName] = skinSrc[skinName] || [];
skinSrc[skinName].push(grunt.file.read(abs));
} else {
parts = part.split(path.sep);
parts.shift();
dest = path.resolve(root, parts.join(path.sep), file);
grunt.file.copy(abs, dest);
}
}
});

Object.keys(skinSrc).forEach(function(dir) {
var skinFile = path.join(base, 'assets/skin/', dir, 'skin.css');
grunt.log.ok('Writing compiled skin:' + skinFile);
grunt.file.write(skinFile, skinSrc[dir].join('\n'));
});
done();
});


});

grunt.registerTask('dist-releasenotes', 'Preparing Dist Release', function() {
grunt.log.writeln('Copying Release Notes for release');
var base = path.join(start, 'dist', 'releasenotes'),
root, dirs, count;

grunt.file.mkdir(base);
root = path.join(process.cwd(), 'src');
dirs = fs.readdirSync(root);
count = 0;
dirs.forEach(function(f) {
var history = path.join(root, f, 'HISTORY.md'),
newHist;
if (exists(history)) {
count++;
newHist = path.join(base, 'HISTORY.' + f + '.md');
grunt.file.copy(history, newHist);
}
});
grunt.log.writeln('Copied ' + count + ' history files.');
});

grunt.registerTask('dist-tests', 'Dist Release Tests', function() {
grunt.log.writeln('Copying tests for release');
var base = path.join(start, 'dist', 'tests'),
done = this.async(),
root = path.join(process.cwd(), 'src'),
dirs = fs.readdirSync(root),
count = 0,
complete = 0,
check = function() {
if (count === complete) {
grunt.log.writeln('Copied ' + count + ' test dirs.');
done();
}
};

grunt.file.mkdir(base);

dirs.forEach(function(f) {
var tests = path.join(root, f, 'tests'),
newTests;
if (exists(tests)) {
count++;
newTests = path.join(base, f, 'tests');
cpr(tests, newTests, function() {
complete++;
check();
});
}
});
});

};
Loading

0 comments on commit 692054a

Please sign in to comment.