Skip to content

Commit

Permalink
Update meta stuff. grunt, package, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
kswedberg committed Feb 20, 2013
1 parent 40abcad commit b66b67f
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 67 deletions.
151 changes: 103 additions & 48 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
/*global module:false*/

module.exports = function(grunt) {

// Path to private settings (used here for user/pwd to rsync to remote site)


// Because I'm lazy
var _ = grunt.util._;

// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('smooth-scroll.jquery.json'),
component: './component.json',
pkg: grunt.file.readJSON('smooth-scroll.jquery.json'),
meta: {
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
banner: '/*!<%= "\\n" %>' +
' * <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") + "\\n" %>' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */' +
'<%= "\\n\\n" %>',
version: '\\n \\nvar version = <%= pkg.version %>;\\n'
'<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' +
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>' +
'<%= "\\n" %>' +
' * Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %>' +
' (<%= _.pluck(pkg.licenses, "url").join(", ") %>)' +
'<%= "\\n" %>' + ' */' +
'<%= "\\n\\n" %>'
},
concat: {
all: {
Expand All @@ -30,17 +40,30 @@ module.exports = function(grunt) {
'jquery.<%= pkg.name %>.min.js': ['<%= concat.all.dest %>']
},
options: {
preserveComments: false,
banner: '<%= meta.banner %>'
preserveComments: 'some'
}
}
},
watch: {
files: '<config:lint.files>',
tasks: 'lint'
scripts: {
files: '<%= jshint.all %>',
tasks: ['jshint:all']
}
},
shell: {
rsync: {
// command is set by setshell:rsync.
stdout: true
}
},
setshell: {
rsync: {
file: 'gitignore/settings.json',
cmdAppend: '<%= pkg.name %>/'
}
},
jshint: {
files: ['grunt.js', 'src/**/*.js'],
all: ['Gruntfile.js', 'src/**/*.js'],
options: {
curly: true,
// eqeqeq: true,
Expand All @@ -57,60 +80,92 @@ module.exports = function(grunt) {
jQuery: true
}
}
},
version: {
patch: {
src: [
'<%= pkg.name %>.jquery.json',
'package.json',
'src/jquery.<%= pkg.name %>.js',
'jquery.<%= pkg.name %>.js'
],
options: {
release: 'patch'
}
},
same: {
src: ['package.json', 'src/jquery.<%= pkg.name %>.js', 'jquery.<%= pkg.name %>.js']
},
bannerPatch: {
src: ['jquery.<%= pkg.name %>.js'],
options: {
prefix: '- v',
release: 'patch'
}
}
}
});

// Default task.
grunt.registerTask('build', ['jshint', 'concat', 'version', 'component', 'uglify']);
grunt.registerMultiTask( 'setshell', 'Set grunt shell commands', function() {
var settings, cmd,
tgt = this.target,
cmdLabel = 'shell.' + tgt + '.command',
file = this.data.file,
append = this.data.cmdAppend || '';

grunt.registerTask( 'component', 'update component.json', function() {
if ( !grunt.file.exists(file) ) {
grunt.warn('File does not exist: ' + file);
}

settings = grunt.file.readJSON(file);
if (!settings[tgt]) {
grunt.warn('No ' + tgt + ' property found in ' + file);
}

cmd = settings[tgt] + append;
grunt.config(cmdLabel, cmd);
grunt.log.writeln( ('Setting ' + cmdLabel + ' to:').cyan );

grunt.log.writeln(cmd);

});

grunt.registerTask( 'deploy', ['setshell:rsync', 'shell:rsync']);

grunt.registerTask( 'component', 'Update component.json', function() {
var comp = grunt.config('component'),
pkg = grunt.config("pkg"),
pkgName = grunt.config('pkg').name,
pkg = grunt.file.readJSON(pkgName + '.jquery.json'),
json = {};



['name', 'version', 'dependencies'].forEach(function(el) {
json[el] = pkg[el];
});

json.main = grunt.config('concat.all.dest');
json.ignore = [
'demo/',
'lib/',
'src/',
'*.json'
];
_.extend(json, {
main: grunt.config('concat.all.dest'),
ignore: [
'demo/',
'lib/',
'src/',
'*.json'
]
});
json.name = 'jquery.' + json.name;

grunt.file.write( comp, JSON.stringify(json, null, 2) );

grunt.log.writeln( "File '" + comp + "' updated." );
});

grunt.registerTask( 'version', 'insert version', function() {
// Concat specified files.
var name = grunt.config('concat.all.dest'),
pkg = grunt.config("pkg"),
compiled = grunt.file.read(name),
version = "version = '" + pkg.version + "'";

// compiled = '/* concatenated files:\n' + this.file.src.join(', ') + '\n*/\n\n' + compiled;

// Embed Version
compiled = compiled.replace( /version = '[^']+'/, version );
// Write concatenated source to file
grunt.file.write( name, compiled );

// Fail task if errors were logged.
if ( this.errorCount ) {
return false;
}

// Otherwise, print a success message.
grunt.log.writeln( "File '" + name + "' created." );

});
grunt.registerTask('build', ['jshint', 'concat', 'version:same', 'component', 'uglify']);
grunt.registerTask('patch', ['jshint', 'concat', 'version:bannerPatch', 'version:patch', 'component', 'uglify']);
grunt.registerTask('default', ['build']);

grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');

grunt.loadNpmTasks('grunt-version');
grunt.loadNpmTasks('grunt-shell');
};
2 changes: 0 additions & 2 deletions LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Copyright (c) 2012 Karl Swedberg

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
Expand Down
15 changes: 14 additions & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
{"name":"smooth-scroll","title":"Smooth Scroll","description":"Easy implementation of smooth scrolling for same-page links","version":"1.4.9","homepage":"https://github.com/kswedberg/jquery-smooth-scroll","author":{"name":"Karl Swedberg","email":"[email protected]","url":"http://www.learningjquery.com/"},"repository":{"type":"git","url":"https://github.com/kswedberg/jquery-smooth-scroll"},"bugs":{"url":"https://github.com/kswedberg/jquery-smooth-scroll/issues"},"licenses":[{"type":"MIT","url":"/blob/master/LICENSE-MIT"}],"dependencies":{"jquery":"~1.3"},"keywords":["scroll","animation"]}
{
"name": "jquery.smooth-scroll",
"version": "1.4.10",
"dependencies": {
"jquery": ">=1.3"
},
"main": "jquery.smooth-scroll.js",
"ignore": [
"demo/",
"lib/",
"src/",
"*.json"
]
}
11 changes: 7 additions & 4 deletions jquery.smooth-scroll.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
/*! Smooth Scroll - v1.4.9 - 2013-01-21
* https://github.com/kswedberg/jquery-smooth-scroll
* Copyright (c) 2013 Karl Swedberg; Licensed MIT */
/*!
* Smooth Scroll - v1.4.10 - 2013-02-20
* https://github.com/kswedberg/jquery-smooth-scroll
* Copyright (c) 2013 Karl Swedberg
* Licensed MIT (/blob/master/LICENSE-MIT)
*/

(function($) {

var version = '1.4.9',
var version = '1.4.10',
defaults = {
exclude: [],
excludeWithin:[],
Expand Down
11 changes: 7 additions & 4 deletions jquery.smooth-scroll.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "smooth-scroll",
"version": "1.4.10",
"scripts": {
"test": "./node_modules/.bin/grunt"
},
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.0",
"grunt-contrib-jshint": "~0.1.1",
"grunt-contrib-uglify": "~0.1.1",
"grunt-contrib-concat": "~0.1.2",
"grunt-shell": "~0.2",
"grunt-version": "~0.1.1"
}
}
14 changes: 7 additions & 7 deletions smooth-scroll.jquery.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"name": "smooth-scroll",
"version": "1.4.10",
"title": "Smooth Scroll",
"description": "Easy implementation of smooth scrolling for same-page links",
"version": "1.4.9",
"homepage": "https://github.com/kswedberg/jquery-smooth-scroll",
"author": {
"name": "Karl Swedberg",
"email": "[email protected]",
Expand All @@ -13,17 +12,18 @@
"type": "git",
"url": "https://github.com/kswedberg/jquery-smooth-scroll"
},
"bugs": {
"url": "https://github.com/kswedberg/jquery-smooth-scroll/issues"
},
"homepage": "https://github.com/kswedberg/jquery-smooth-scroll",
"docs": "https://github.com/kswedberg/jquery-smooth-scroll",
"bugs": "https://github.com/kswedberg/jquery-smooth-scroll/issues",
"demo": "http://plugins.learningjquery.com/smooth-scroll/demo/",
"licenses": [
{
"type": "MIT",
"url": "/blob/master/LICENSE-MIT"
"url": "https://github.com/kswedberg/jquery-smooth-scroll/blob/master/LICENSE-MIT"
}
],
"dependencies": {
"jquery": "~1.3"
"jquery": ">=1.3"
},
"keywords": ["scroll", "animation"]
}
2 changes: 1 addition & 1 deletion src/jquery.smooth-scroll.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(function($) {

var version = '@VERSION',
var version = '1.4.10',
defaults = {
exclude: [],
excludeWithin:[],
Expand Down

0 comments on commit b66b67f

Please sign in to comment.