-
Notifications
You must be signed in to change notification settings - Fork 34
/
Gruntfile.js
132 lines (126 loc) · 3.35 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*global module:false*/
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
meta: {
banner: '/* \n' +
' * <%= pkg.name %> v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> \n' +
' * <%= pkg.description %> \n' +
' * <%= pkg.homepage %> \n' +
' * \n' +
' * Copyright <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>; <%= pkg.license %> Licensed \n' +
' */ \n\n'
},
// JS Hint
jshint: {
options: {
globals: {
'jQuery': true,
'$' : true
},
browser: true,
curly: true,
eqeqeq: true,
forin: true,
freeze: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
nonew: true,
smarttabs: true,
sub: true,
undef: true,
validthis: true
},
files: ['src/<%= pkg.codename %>.js']
},
// Concat
concat: {
js: {
options: {
banner: '<%= meta.banner %>'
},
files: {
'<%= pkg.codename %>.js': [ 'src/<%= pkg.codename %>.js' ]
}
},
css: {
options: {
banner: '<%= meta.banner %>'
},
files: {
'<%= pkg.codename %>.css': [ 'src/<%= pkg.codename %>.css' ]
}
}
},
// Uglify
uglify: {
options: {
banner: '<%= meta.banner %>',
report: 'min'
},
target: {
files: {
'<%= pkg.codename %>.min.js': [ '<%= pkg.codename %>.js' ]
}
}
},
// jQuery Manifest
jquerymanifest: {
options: {
source: grunt.file.readJSON('package.json'),
overrides: {
name: '<%= pkg.id %>',
keywords: '<%= pkg.keywords %>',
homepage: '<%= pkg.homepage %>',
docs: '<%= pkg.homepage %>',
demo: '<%= pkg.homepage %>',
download: '<%= pkg.repository.url %>',
bugs: '<%= pkg.repository.url %>/issues',
dependencies: {
jquery: '>=1.7'
}
}
}
},
//Bower sync
sync: {
all: {
options: {
sync: [ 'name', 'version', 'description', 'author', 'license', 'homepage' ],
overrides: {
main: [
'<%= pkg.codename %>.js',
'<%= pkg.codename %>.css'
],
ignore: [ "*.jquery.json", "Gruntfile.js", "src/" ]
}
}
}
}
});
// Readme
grunt.registerTask('buildReadme', 'Build Formstone README.md file.', function () {
var pkg = grunt.file.readJSON('package.json'),
destination = "README.md",
markdown = '<h2>Development of this plugin has ended. Please upgrade to the new <a href="http://formstone.it">Formstone</a>.</h2><br> \n\n' +
'<a href="http://gruntjs.com" target="_blank"><img src="https://cdn.gruntjs.com/builtwith.png" alt="Built with Grunt"></a> \n' +
'# ' + pkg.name + ' \n\n' +
pkg.description + ' \n\n' +
'- [Demo](' + pkg.demo + ') \n' +
'- [Documentation](' + pkg.homepage + ') \n\n' +
'#### Bower Support \n' +
'`bower install ' + pkg.name + '`';
grunt.file.write(destination, markdown);
grunt.log.writeln('File "' + destination + '" created.');
});
// Load tasks
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-jquerymanifest');
grunt.loadNpmTasks('grunt-npm2bower-sync');
// Default task.
grunt.registerTask('default', [ 'jshint', 'concat', 'uglify', 'jquerymanifest', 'sync', 'buildReadme' ]);
};