Skip to content

Commit

Permalink
Merge branch 'grunt-bower' of github.com:ericf/pure into ericf-grunt-…
Browse files Browse the repository at this point in the history
…bower
  • Loading branch information
ericf committed Aug 27, 2013
2 parents a2421cc + f9bbf6f commit 9ab35b7
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 1,403 deletions.
122 changes: 46 additions & 76 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,15 @@ module.exports = function (grunt) {

grunt.initConfig({

pkg : grunt.file.readJSON('package.json'),
normalize: grunt.file.readJSON('src/base/bower.json'),

// -- Constants ------------------------------------------------------------

BUILD_COMMENT: 'THIS FILE IS GENERATED BY A BUILD SCRIPT - DO NOT EDIT!',
pkg : grunt.file.readJSON('package.json'),
bower: grunt.file.readJSON('bower.json'),

// -- Clean Config ---------------------------------------------------------

clean: {
build : ['build/'],
build_res: ['build/*-r.css'],
release : ['release/<%= pkg.version %>/'],
base : ['src/base/css/', 'src/base/bower.json', 'src/base/LICENSE.md']
release : ['release/<%= pkg.version %>/']
},

// -- Copy Config ----------------------------------------------------------
Expand All @@ -28,43 +23,20 @@ grunt.initConfig({
build: {
expand : true,
flatten: true,
src : 'src/**/css/*.css',
dest : 'build/',

src: [
'bower_components/normalize-css/normalize.css',
'src/**/css/*.css'
],

rename: function (dest, src) {
// normalize -> base
src = src.replace(/^normalize(-.+\.css|\.css)$/, 'base$1');
return path.join(dest, src);
}
},

normalize: {
expand : true,
flatten: true,
cwd : 'bower_components/normalize-css/',
src : '{bower.json,LICENSE.md,normalize.css}',
dest : 'src/base/',

rename: function (dest, file) {
if (grunt.file.isMatch('*.css', file)) {
return path.join(dest, 'css', file);
if (src === 'normalize.css') {
src = 'base.css';
}

return path.join(dest, file);
},

options: {
processContent: function (content, file) {
var comment = grunt.config('BUILD_COMMENT');

if (grunt.file.isMatch({matchBase: true}, '*.css', file)) {
content = '/* ' + comment + ' */\n' + content;
} else if (grunt.file.isMatch({matchBase: true}, '*.html', file)) {
content = '<!-- ' + comment + ' -->\n' + content;
}

return content;
}
return path.join(dest, src);
}
}
},
Expand All @@ -80,7 +52,6 @@ grunt.initConfig({
]},

{'build/forms-nr.css': [
'build/forms-core.css',
'build/forms.css'
]},

Expand Down Expand Up @@ -141,11 +112,7 @@ grunt.initConfig({
},

src: {
src: [
'src/**/css/*.css',
'!src/base/css/*',
'!src/forms/css/forms-core.css'
]
src: 'src/**/css/*.css'
}
},

Expand Down Expand Up @@ -173,8 +140,12 @@ grunt.initConfig({

expand : true,
flatten: true,
src : 'build/*.css',
dest : '<%= pkg.name %>/<%= pkg.version %>/'
dest : '<%= pkg.name %>/<%= pkg.version %>/',

src: [
'{bower.json,LICENSE.md,README.md,HISTORY.md}',
'build/*.css'
]
}
},

Expand All @@ -185,15 +156,15 @@ grunt.initConfig({
options: {
banner: [
'/*!',
'normalize.css v<%= normalize.version %> | MIT License | git.io/normalize',
'normalize.css v<%= bower.devDependencies["normalize-css"] %> | MIT License | git.io/normalize',
'Copyright (c) Nicolas Gallagher and Jonathan Neal',
'*/\n'
].join('\n')
},

expand: true,
cwd : 'build/',
src : ['base*.css', 'forms*.css', 'tables*.css', '<%= pkg.name %>*.css']
src : ['base*.css', '<%= pkg.name %>*.css']
},

yahoo: {
Expand All @@ -217,12 +188,11 @@ grunt.initConfig({

contextualize: {
normalize: {
src : 'src/base/css/normalize.css',
dest: 'src/base/css/normalize-context.css',
src : 'bower_components/normalize-css/normalize.css',
dest: 'build/base-context.css',

options: {
prefix: '.pure',
banner: '/* <%= BUILD_COMMENT %> */\n'
prefix: '.pure'
}
}
},
Expand All @@ -232,7 +202,7 @@ grunt.initConfig({
observe: {
src: {
files: 'src/**/css/*.css',
tasks: ['test', 'suppress', 'default'],
tasks: ['test', 'suppress', 'build'],

options: {
interrupt: true
Expand All @@ -251,30 +221,24 @@ grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-contrib-watch');

grunt.registerTask('default', [
grunt.registerTask('default', ['import', 'test', 'build']);
grunt.registerTask('import', ['bower-install']);
grunt.registerTask('test', ['csslint']);
grunt.registerTask('build', [
'clean:build',
'copy:build',
'contextualize:normalize',
'concat:build',
'clean:build_res',
'cssmin',
'license'
]);

grunt.registerTask('test', [
'csslint'
]);

// Makes the `watch` task run a build first.
grunt.renameTask('watch', 'observe');
grunt.registerTask('watch', ['default', 'observe']);

grunt.registerTask('import', [
'bower-install',
'import-normalize'
]);

grunt.registerTask('release', [
'test',
'default',
'clean:release',
'compress:release'
Expand All @@ -300,23 +264,24 @@ grunt.registerTask('suppress', function () {
});
});

// -- Import Tasks -------------------------------------------------------------

grunt.registerTask('import-normalize', [
'clean:base',
'copy:normalize',
'contextualize:normalize'
]);

// -- Bower Task ---------------------------------------------------------------
// -- Bower Tasks --------------------------------------------------------------

grunt.registerTask('bower-install', 'Installs Bower dependencies.', function () {
var bower = require('bower'),
done = this.async();

bower.commands.install()
.on('data', function (data) { grunt.log.write(data); })
.on('end', done);
.on('log', function (data) {
if (data.id !== 'install') { return; }
grunt.log.writeln('bower ' + data.id.cyan + ' ' + data.message);
})
.on('end', function (results) {
if (!Object.keys(results).length) {
grunt.log.writeln('No bower packages to install.');
}

done();
});
});

// -- License Task -------------------------------------------------------------
Expand Down Expand Up @@ -352,6 +317,11 @@ grunt.registerMultiTask('contextualize', 'Makes Contextualized CSS files.', func
}

this.files.forEach(function (filePair) {
if (!filePair.src.length) {
processing += 1;
return oneDone();
}

filePair.src.forEach(function (file) {
var src = grunt.file.read(file),
contextual = banner,
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"name": "pure",
"version": "0.3.0-pre",
"devDependencies": {
"normalize-css": "1.x"
"normalize-css": "1.1.2"
}
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
"private": true,
"repository": "git://github.com/yui/pure.git",
"devDependencies": {
"bower": "~0.9.2",
"bower": "~1.1.0",
"grunt": "~0.4.1",
"grunt-contrib-cssmin": "~0.6.0",
"grunt-contrib-clean": "~0.4.1",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-compress": "~0.5.0",
"grunt-contrib-csslint": "~0.1.2",
"grunt-contrib-watch": "~0.3.1",
"grunt-contrib-watch": "~0.5.1",
"parserlib": "~0.2.2"
}
}
19 changes: 0 additions & 19 deletions src/base/LICENSE.md

This file was deleted.

17 changes: 0 additions & 17 deletions src/base/README.md

This file was deleted.

23 changes: 0 additions & 23 deletions src/base/bower.json

This file was deleted.

Loading

0 comments on commit 9ab35b7

Please sign in to comment.