forked from jquery/jquery-migrate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
187 lines (175 loc) · 4.65 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/*global module:false*/
module.exports = function(grunt) {
"use strict";
// The concatenated file won't pass onevar but our modules can
var readOptionalJSON = function( filepath ) {
var data = {};
try {
data = grunt.file.readJSON( filepath );
} catch(e) {}
return data;
},
srcHintOptions = readOptionalJSON("src/.jshintrc");
delete srcHintOptions.onevar;
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
files: [
"src/intro.js",
"src/migrate.js",
"src/attributes.js",
"src/core.js",
"src/ajax.js",
"src/data.js",
"src/manipulation.js",
"src/event.js",
"src/outro.js"
],
tests: [
"dev+git",
"dev+git2",
"min+git",
"min+git2",
"dev+2.0.3",
"dev+1.10.2",
"dev+1.9.1",
"dev+1.8.3",
"dev+1.7.2",
"dev+1.6.4"
],
banners: {
tiny: "/*! <%= pkg.name %> <%= pkg.version %> - <%= pkg.homepage %> */"
},
concat: {
options: {
banner: "/*!\n * <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " +
"<%= grunt.template.today('yyyy-mm-dd') %>\n" +
" * <%= pkg.homepage %>\n" +
" * Copyright 2005, <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>;" +
" Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %>\n */\n"
},
dist: {
src: "<%= files %>",
dest: "dist/<%= pkg.name %>.js"
}
},
qunit: {
files: [ "test/**/*.html" ]
},
jshint: {
dist: {
src: [ "dist/jquery-migrate.js" ],
options: srcHintOptions
},
tests: {
src: [ "test/*.js" ],
options: {
jshintrc: "test/.jshintrc"
}
},
grunt: {
src: [ "Gruntfile.js" ],
options: {
jshintrc: ".jshintrc"
}
}
},
uglify: {
all: {
files: {
"dist/jquery-migrate.min.js": [ "src/migratemute.js", "dist/jquery-migrate.js" ]
}
},
options: {
banner: "/*! jQuery Migrate v<%= pkg.version %> | (c) 2005, <%= grunt.template.today('yyyy') %> <%= pkg.author.name %> | jquery.org/license */\n",
beautify: {
ascii_only: true
}
}
}
});
// Load grunt tasks from NPM packages
grunt.loadNpmTasks("grunt-git-authors");
grunt.loadNpmTasks("grunt-contrib-concat");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks("grunt-contrib-qunit");
// Default task.
grunt.registerTask( "default", [ "concat", "uglify", "jshint", "qunit" ] );
// Skip unit tests, used by testswarm
grunt.registerTask( "buildnounit", [ "concat", "uglify", "jshint" ] );
// Testswarm
grunt.registerTask( "testswarm", function( commit, configFile ) {
var jobName,
testswarm = require( "testswarm" ),
runs = {},
done = this.async(),
pull = /PR-(\d+)/.exec( commit ),
config = grunt.file.readJSON( configFile ).jquerymigrate,
tests = grunt.config("tests");
if ( pull ) {
jobName = "Pull <a href='https://github.com/jquery/jquery-migrate/pull/" +
pull[ 1 ] + "'>#" + pull[ 1 ] + "</a>";
} else {
jobName = "Commit <a href='https://github.com/jquery/jquery-migrate/commit/" +
commit + "'>" + commit.substr( 0, 10 ) + "</a>";
}
tests.forEach(function( test ) {
var plugin_jquery = test.split("+");
runs[test] = config.testUrl + commit + "/test/index.html?plugin=" +
plugin_jquery[0] + "&jquery=" + plugin_jquery[1];
});
// TODO: create separate job for git/git2 so we can do different browsersets
testswarm.createClient( {
url: config.swarmUrl,
pollInterval: 10000,
timeout: 1000 * 60 * 30
} )
.addReporter( testswarm.reporters.cli )
.auth( {
id: config.authUsername,
token: config.authToken
})
.addjob(
{
name: jobName,
runs: runs,
runMax: config.runMax,
browserSets: "popular-no-old-ie"
}, function( err, passed ) {
if ( err ) {
grunt.log.error( err );
}
done( passed );
}
);
});
// Update manifest for jQuery plugin registry
grunt.registerTask( "manifest", function() {
var pkg = grunt.config( "pkg" );
grunt.file.write( "migrate.jquery.json", JSON.stringify({
name: "migrate",
title: pkg.title,
description: pkg.description,
keywords: pkg.keywords,
version: pkg.version,
author: {
name: pkg.author.name,
url: pkg.author.url.replace( "master", pkg.version )
},
maintainers: pkg.maintainers,
licenses: pkg.licenses.map(function( license ) {
license.url = license.url.replace( "master", pkg.version );
return license;
}),
bugs: pkg.bugs,
homepage: pkg.homepage,
docs: pkg.homepage,
download: "https://github.com/jquery/jquery-migrate/blob/" + pkg.version + "/README.md#download",
dependencies: {
jquery: ">=1.6.4"
}
}, null, "\t" ) );
});
};