Skip to content

Commit 6b9b2ab

Browse files
committed
Build: Add esformatter and format build files
Closes jquery-archivegh-8079
1 parent 62a1e78 commit 6b9b2ab

21 files changed

+1388
-1365
lines changed

Gruntfile.js

+46-46
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
11
module.exports = function( grunt ) {
2-
"use strict";
2+
"use strict";
33

4-
var path = require( "path" );
5-
var dist = "dist" + path.sep;
6-
var today = grunt.template.today( "UTC:yyyy" );
4+
var path = require( "path" );
5+
var dist = "dist" + path.sep;
6+
var today = grunt.template.today( "UTC:yyyy" );
77

8-
require( "load-grunt-config" )( grunt, {
9-
configPath: [
10-
path.join( process.cwd(), "build/tasks/options" ),
11-
path.join( process.cwd(), "build/tasks" )
12-
],
13-
init: true,
14-
data: {
15-
pkg: grunt.file.readJSON( "package.json" ),
8+
require( "load-grunt-config" )( grunt, {
9+
configPath: [
10+
path.join( process.cwd(), "build/tasks/options" ),
11+
path.join( process.cwd(), "build/tasks" )
12+
],
13+
init: true,
14+
data: {
15+
pkg: grunt.file.readJSON( "package.json" ),
16+
dist: dist,
17+
name: "jquery.mobile",
18+
phpPort: Math.floor( 8000 + Math.random() * 1000 ),
19+
versionSuffix: "",
20+
headHash: "",
21+
headShortHash: "",
22+
version: "<%= version %>",
23+
dirs: {
1624
dist: dist,
17-
name: "jquery.mobile",
18-
phpPort: Math.floor( 8000 + Math.random() * 1000 ),
19-
versionSuffix: "",
20-
headHash: "",
21-
headShortHash: "",
22-
version: "<%= version %>",
23-
dirs: {
24-
dist: dist,
25-
cdn: {
26-
google: path.join( dist, "cdn-google" ),
27-
jquery: path.join( dist, "cdn" ),
28-
git: path.join( dist, "git" )
29-
},
30-
tmp: path.join( dist, "tmp" )
25+
cdn: {
26+
google: path.join( dist, "cdn-google" ),
27+
jquery: path.join( dist, "cdn" ),
28+
git: path.join( dist, "git" )
3129
},
32-
banner: [
33-
"/*!",
34-
"* jQuery Mobile <%= version %>",
35-
"* <%if ( headHash ) {%>Git HEAD hash: <%= headHash %> <> <% } %>Date: " +
36-
grunt.template.today( "UTC:ddd mmm d yyyy HH:MM:ss Z" ),
37-
"* http://jquerymobile.com",
38-
"*",
39-
"* Copyright 2010, " + today + " jQuery Foundation, Inc. and other" +
40-
" contributors",
41-
"* Released under the MIT license.",
42-
"* http://jquery.org/license",
43-
"*",
44-
"*/",
45-
"",
46-
"",
47-
""
48-
].join( grunt.util.linefeed ),
30+
tmp: path.join( dist, "tmp" )
31+
},
32+
banner: [
33+
"/*!",
34+
"* jQuery Mobile <%= version %>",
35+
"* <%if ( headHash ) {%>Git HEAD hash: <%= headHash %> <> <% } %>Date: " +
36+
grunt.template.today( "UTC:ddd mmm d yyyy HH:MM:ss Z" ),
37+
"* http://jquerymobile.com",
38+
"*",
39+
"* Copyright 2010, " + today + " jQuery Foundation, Inc. and other" +
40+
" contributors",
41+
"* Released under the MIT license.",
42+
"* http://jquery.org/license",
43+
"*",
44+
"*/",
45+
"",
46+
"",
47+
""
48+
].join( grunt.util.linefeed ),
4949

50-
bannerMin: "/*! jQuery Mobile <%= version %> | <%if ( headShortHash ) {%>Git HEAD" +
50+
bannerMin: "/*! jQuery Mobile <%= version %> | <%if ( headShortHash ) {%>Git HEAD" +
5151
"hash: <%= headShortHash %> <> <% } %>" + grunt.template.today( "UTC:yyyy-mm-dd" ) +
5252
"T" + grunt.template.today( "UTC:HH:MM:ss" ) + "Z | (c) 2010, " +
5353
today + " jQuery Foundation, Inc. | jquery.org/license */\n"
54-
}
55-
} );
54+
}
55+
} );
5656
};

build/files.js

+111-111
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,128 @@
11
module.exports = function( grunt ) {
2-
var path = require( "path" );
3-
var _ = require( "underscore" );
4-
var files = {
5-
css: {
6-
structure: {
7-
src: "css/structure/jquery.mobile.structure.css",
8-
unminified: "<%= name %>.structure<%= versionSuffix %>.css"
9-
},
10-
theme: {
11-
src: "css/themes/default/jquery.mobile.theme.css",
12-
unminified: "<%= name %>.theme<%= versionSuffix %>.css"
13-
},
14-
bundle: {
15-
src: "css/themes/default/jquery.mobile.css",
16-
unminified: "<%= name %><%= versionSuffix %>.css"
17-
},
18-
inlinesvg: {
19-
src: "css/themes/default/jquery.mobile.inline-svg.css",
20-
unminified: "<%= name %>.inline-svg<%= versionSuffix %>.css"
21-
},
22-
inlinepng: {
23-
src: "css/themes/default/jquery.mobile.inline-png.css",
24-
unminified: "<%= name %>.inline-png<%= versionSuffix %>.css"
25-
},
26-
externalpng: {
27-
src: "css/themes/default/jquery.mobile.external-png.css",
28-
unminified: "<%= name %>.external-png<%= versionSuffix %>.css"
29-
},
30-
icons: {
31-
src: "css/themes/default/jquery.mobile.icons.css",
32-
unminified: "<%= name %>.icons<%= versionSuffix %>.css"
33-
}
34-
},
35-
getCSSFiles: function( destDir ) {
36-
destDir = destDir || ".";
37-
var list = [];
38-
_.values( files.css ).forEach( function( value ) {
39-
list.push( {
40-
src: value.src,
41-
dest: path.join( destDir, value.unminified )
42-
} );
43-
} );
44-
return list;
45-
},
46-
getMinifiedCSSFiles: function( destDir ) {
47-
destDir = destDir || ".";
48-
var list = [];
49-
_.values( files.css ).forEach( function( value ) {
50-
list.push( {
51-
src: path.join( destDir, value.unminified ),
52-
dest: path.join( destDir, value.minified )
53-
} );
54-
} );
55-
return list;
56-
},
57-
cdn: [
58-
"<%= name %><%= versionSuffix %>.js",
59-
"<%= name %><%= versionSuffix %>.min.js",
60-
"<%= name %><%= versionSuffix %>.min.map",
2+
var path = require( "path" );
3+
var _ = require( "underscore" );
4+
var files = {
5+
css: {
6+
structure: {
7+
src: "css/structure/jquery.mobile.structure.css",
8+
unminified: "<%= name %>.structure<%= versionSuffix %>.css"
9+
},
10+
theme: {
11+
src: "css/themes/default/jquery.mobile.theme.css",
12+
unminified: "<%= name %>.theme<%= versionSuffix %>.css"
13+
},
14+
bundle: {
15+
src: "css/themes/default/jquery.mobile.css",
16+
unminified: "<%= name %><%= versionSuffix %>.css"
17+
},
18+
inlinesvg: {
19+
src: "css/themes/default/jquery.mobile.inline-svg.css",
20+
unminified: "<%= name %>.inline-svg<%= versionSuffix %>.css"
21+
},
22+
inlinepng: {
23+
src: "css/themes/default/jquery.mobile.inline-png.css",
24+
unminified: "<%= name %>.inline-png<%= versionSuffix %>.css"
25+
},
26+
externalpng: {
27+
src: "css/themes/default/jquery.mobile.external-png.css",
28+
unminified: "<%= name %>.external-png<%= versionSuffix %>.css"
29+
},
30+
icons: {
31+
src: "css/themes/default/jquery.mobile.icons.css",
32+
unminified: "<%= name %>.icons<%= versionSuffix %>.css"
33+
}
34+
},
35+
getCSSFiles: function( destDir ) {
36+
destDir = destDir || ".";
37+
var list = [];
38+
_.values( files.css ).forEach( function( value ) {
39+
list.push( {
40+
src: value.src,
41+
dest: path.join( destDir, value.unminified )
42+
} );
43+
} );
44+
return list;
45+
},
46+
getMinifiedCSSFiles: function( destDir ) {
47+
destDir = destDir || ".";
48+
var list = [];
49+
_.values( files.css ).forEach( function( value ) {
50+
list.push( {
51+
src: path.join( destDir, value.unminified ),
52+
dest: path.join( destDir, value.minified )
53+
} );
54+
} );
55+
return list;
56+
},
57+
cdn: [
58+
"<%= name %><%= versionSuffix %>.js",
59+
"<%= name %><%= versionSuffix %>.min.js",
60+
"<%= name %><%= versionSuffix %>.min.map",
6161

62-
"<%= files.css.structure.unminified %>",
63-
"<%= files.css.structure.minified %>",
64-
"<%= files.css.bundle.unminified %>",
65-
"<%= files.css.bundle.minified %>",
66-
"<%= files.css.inlinesvg.unminified %>",
67-
"<%= files.css.inlinesvg.minified %>",
68-
"<%= files.css.inlinepng.unminified %>",
69-
"<%= files.css.inlinepng.minified %>",
70-
"<%= files.css.externalpng.unminified %>",
71-
"<%= files.css.externalpng.minified %>",
72-
"<%= files.css.icons.unminified %>",
73-
"<%= files.css.icons.minified %>",
62+
"<%= files.css.structure.unminified %>",
63+
"<%= files.css.structure.minified %>",
64+
"<%= files.css.bundle.unminified %>",
65+
"<%= files.css.bundle.minified %>",
66+
"<%= files.css.inlinesvg.unminified %>",
67+
"<%= files.css.inlinesvg.minified %>",
68+
"<%= files.css.inlinepng.unminified %>",
69+
"<%= files.css.inlinepng.minified %>",
70+
"<%= files.css.externalpng.unminified %>",
71+
"<%= files.css.externalpng.minified %>",
72+
"<%= files.css.icons.unminified %>",
73+
"<%= files.css.icons.minified %>",
7474

75-
"images/*.*",
76-
"images/icons-png/**"
77-
],
75+
"images/*.*",
76+
"images/icons-png/**"
77+
],
7878

79-
zipFileName: "<%= name %><%= versionSuffix %>.zip",
79+
zipFileName: "<%= name %><%= versionSuffix %>.zip",
8080

81-
distZipOut: path.join( "<%= dist %>", "<%= name %><%= versionSuffix %>.zip" ),
81+
distZipOut: path.join( "<%= dist %>", "<%= name %><%= versionSuffix %>.zip" ),
8282

83-
imagesZipOut: path.join( "<%= dist %>", "<%= name %>.images<%= versionSuffix %>.zip" )
83+
imagesZipOut: path.join( "<%= dist %>", "<%= name %>.images<%= versionSuffix %>.zip" )
8484

85-
};
85+
};
8686

87-
// Add minified property to files.css.*
88-
_.forEach( files.css, function( o ) {
89-
o.minified = o.unminified.replace( /\.css$/, ".min.css" );
90-
} );
87+
// Add minified property to files.css.*
88+
_.forEach( files.css, function( o ) {
89+
o.minified = o.unminified.replace( /\.css$/, ".min.css" );
90+
} );
9191

92-
files.cdn = [
93-
"<%= name %><%= versionSuffix %>.js",
94-
"<%= name %><%= versionSuffix %>.min.js",
95-
"<%= name %><%= versionSuffix %>.min.map",
92+
files.cdn = [
93+
"<%= name %><%= versionSuffix %>.js",
94+
"<%= name %><%= versionSuffix %>.min.js",
95+
"<%= name %><%= versionSuffix %>.min.map",
9696

97-
files.css.structure.unminified,
98-
files.css.structure.minified,
99-
files.css.bundle.unminified,
100-
files.css.bundle.minified,
101-
files.css.inlinesvg.unminified,
102-
files.css.inlinesvg.minified,
103-
files.css.inlinepng.unminified,
104-
files.css.inlinepng.minified,
105-
files.css.externalpng.unminified,
106-
files.css.externalpng.minified,
107-
files.css.icons.unminified,
108-
files.css.icons.minified,
97+
files.css.structure.unminified,
98+
files.css.structure.minified,
99+
files.css.bundle.unminified,
100+
files.css.bundle.minified,
101+
files.css.inlinesvg.unminified,
102+
files.css.inlinesvg.minified,
103+
files.css.inlinepng.unminified,
104+
files.css.inlinepng.minified,
105+
files.css.externalpng.unminified,
106+
files.css.externalpng.minified,
107+
files.css.icons.unminified,
108+
files.css.icons.minified,
109109

110-
"images/*.*",
111-
"images/icons-png/**"
112-
];
110+
"images/*.*",
111+
"images/icons-png/**"
112+
];
113113

114-
files.distZipContent = [
115-
files.cdn,
114+
files.distZipContent = [
115+
files.cdn,
116116

117-
files.css.theme.unminified,
118-
files.css.theme.minified,
117+
files.css.theme.unminified,
118+
files.css.theme.minified,
119119

120-
"images/icons-svg/**",
121-
"demos/**"
122-
];
120+
"images/icons-svg/**",
121+
"demos/**"
122+
];
123123

124-
files.googleCDNZipOut = path.join( path.join( "<%= dist %>", "cdn-google" ),
125-
files.zipFileName );
124+
files.googleCDNZipOut = path.join( path.join( "<%= dist %>", "cdn-google" ),
125+
files.zipFileName );
126126

127-
return files;
127+
return files;
128128
}

build/filter.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@ var fs = require( "fs" ),
1414
copyrightMinFile = copyrightBaseName + ".min.txt";
1515

1616
module.exports = function( contents, ext, callback ) {
17-
var version = pkg.version.trim();
17+
var version = pkg.version.trim();
1818

19-
if ( /^\.min/.test( ext ) ) {
20-
copyrightFile = copyrightMinFile;
21-
} else {
22-
copyrightFile = copyrightRegFile;
23-
}
24-
fs.readFile( path.join( buildDir, copyrightFile ), "utf8",
25-
function( err, copyright ) {
26-
if ( err ) {
27-
callback( err );
28-
} else {
29-
contents = copyright.replace( copyrightVersionRegExp, version ) + "\n" + contents;
30-
contents = contents.replace( apiVersionRegExp, "\"" + version + "\"" );
19+
if ( /^\.min/.test( ext ) ) {
20+
copyrightFile = copyrightMinFile;
21+
} else {
22+
copyrightFile = copyrightRegFile;
23+
}
24+
fs.readFile( path.join( buildDir, copyrightFile ), "utf8",
25+
function( err, copyright ) {
26+
if ( err ) {
27+
callback( err );
28+
} else {
29+
contents = copyright.replace( copyrightVersionRegExp, version ) + "\n" + contents;
30+
contents = contents.replace( apiVersionRegExp, "\"" + version + "\"" );
3131

32-
callback( null, contents );
33-
}
32+
callback( null, contents );
3433
}
35-
);
34+
}
35+
);
3636
};

0 commit comments

Comments
 (0)