1+
12module . exports = function ( Release ) {
23
34 var
4- fs = require ( "fs" ) ,
5- shell = require ( "shelljs" ) ,
6- ensureSizzle = require ( "./ensure-sizzle" ) ,
7-
8- devFile = "dist/jquery.js" ,
9- minFile = "dist/jquery.min.js" ,
10- mapFile = "dist/jquery.min.map" ,
11-
12- cdnFolder = "dist/cdn" ,
13-
14- releaseFiles = {
15- "jquery-VER.js" : devFile ,
16- "jquery-VER.min.js" : minFile ,
17- "jquery-VER.min.map" : mapFile
18- } ,
19-
20- googleFilesCDN = [
21- "jquery.js" , "jquery.min.js" , "jquery.min.map"
22- ] ,
23-
24- msFilesCDN = [
25- "jquery-VER.js" , "jquery-VER.min.js" , "jquery-VER.min.map"
26- ] ,
5+ files = [ "dist/jquery.js" , "dist/jquery.min.js" , "dist/jquery.min.map" ] ,
6+ cdn = require ( "./release/cdn" ) ,
7+ dist = require ( "./release/dist" ) ,
8+ ensureSizzle = require ( "./release/ensure-sizzle" ) ,
279
28- _complete = Release . complete ;
10+ npmTags = Release . npmTags ;
2911
30- /**
31- * Generates copies for the CDNs
32- */
33- function makeReleaseCopies ( ) {
34- shell . mkdir ( "-p" , cdnFolder ) ;
35-
36- Object . keys ( releaseFiles ) . forEach ( function ( key ) {
37- var text ,
38- builtFile = releaseFiles [ key ] ,
39- unpathedFile = key . replace ( / V E R / g, Release . newVersion ) ,
40- releaseFile = cdnFolder + "/" + unpathedFile ;
41-
42- if ( / \. m a p $ / . test ( releaseFile ) ) {
43- // Map files need to reference the new uncompressed name;
44- // assume that all files reside in the same directory.
45- // "file":"jquery.min.js","sources":["jquery.js"]
46- text = fs . readFileSync ( builtFile , "utf8" )
47- . replace ( / " f i l e " : " ( [ ^ " ] + ) " , " s o u r c e s " : \[ " ( [ ^ " ] + ) " \] / ,
48- "\"file\":\"" + unpathedFile . replace ( / \. m i n \. m a p / , ".min.js" ) +
49- "\",\"sources\":[\"" + unpathedFile . replace ( / \. m i n \. m a p / , ".js" ) + "\"]" ) ;
50- fs . writeFileSync ( releaseFile , text ) ;
51- } else if ( / \. m i n \. j s $ / . test ( releaseFile ) ) {
52- // Remove the source map comment; it causes way too many problems.
53- // Keep the map file in case DevTools allow manual association.
54- text = fs . readFileSync ( builtFile , "utf8" )
55- . replace ( / \/ \/ # s o u r c e M a p p i n g U R L = \S + / , "" ) ;
56- fs . writeFileSync ( releaseFile , text ) ;
57- } else if ( builtFile !== releaseFile ) {
58- shell . cp ( "-f" , builtFile , releaseFile ) ;
59- }
60- } ) ;
61- }
62-
63- function buildGoogleCDN ( ) {
64- makeArchive ( "googlecdn" , googleFilesCDN ) ;
65- }
66-
67- function buildMicrosoftCDN ( ) {
68- makeArchive ( "mscdn" , msFilesCDN ) ;
69- }
70-
71- function makeArchive ( cdn , files ) {
72- if ( Release . preRelease ) {
73- console . log ( "Skipping archive creation for " + cdn + "; this is a beta release." ) ;
74- return ;
75- }
76-
77- console . log ( "Creating production archive for " + cdn ) ;
78-
79- var archiver = require ( "archiver" ) ( "zip" ) ,
80- md5file = cdnFolder + "/" + cdn + "-md5.txt" ,
81- output = fs . createWriteStream (
82- cdnFolder + "/" + cdn + "-jquery-" + Release . newVersion + ".zip"
83- ) ;
84-
85- output . on ( "error" , function ( err ) {
86- throw err ;
87- } ) ;
88-
89- archiver . pipe ( output ) ;
90-
91- files = files . map ( function ( item ) {
92- return cdnFolder + "/" + item . replace ( / V E R / g, Release . newVersion ) ;
93- } ) ;
94-
95- shell . exec ( "md5sum" , files , function ( code , stdout ) {
96- fs . writeFileSync ( md5file , stdout ) ;
97- files . push ( md5file ) ;
98-
99- files . forEach ( function ( file ) {
100- archiver . append ( fs . createReadStream ( file ) , { name : file } ) ;
101- } ) ;
102-
103- archiver . finalize ( ) ;
104- } ) ;
105- }
12+ // Have jquery-release update the version
13+ // in our bower.json template
14+ Release . _jsonFiles . push ( "build/release/_bower.json" ) ;
10615
10716 Release . define ( {
10817 npmPublish : true ,
109- issueTracker : "trac" ,
110- contributorReportId : 508 ,
18+ issueTracker : "github" ,
11119 /**
11220 * Ensure the repo is in a proper state before release
11321 * @param {Function } callback
@@ -123,48 +31,37 @@ module.exports = function( Release ) {
12331 */
12432 generateArtifacts : function ( callback ) {
12533 Release . exec ( "grunt" , "Grunt command failed" ) ;
126- makeReleaseCopies ( ) ;
127- callback ( [ "dist/jquery.js" , "dist/jquery.min.js" , "dist/jquery.min.map" ] ) ;
34+ cdn . makeReleaseCopies ( Release ) ;
35+ callback ( files ) ;
12836 } ,
12937 /**
130- * Release completion
38+ * Acts as insertion point for restoring Release.dir.repo
39+ * It was changed to reuse npm publish code in jquery-release
40+ * for publishing the distribution repo instead
13141 */
132- complete : function ( ) {
133- // Build CDN archives async
134- buildGoogleCDN ( ) ;
135- buildMicrosoftCDN ( ) ;
136- _complete ( ) ;
42+ npmTags : function ( ) {
43+ // origRepo is not defined if dist was skipped
44+ Release . dir . repo = Release . dir . origRepo || Release . dir . repo ;
45+ return npmTags ( ) ;
13746 } ,
13847 /**
139- * Our trac milestones are different than the new version
140- * @example
141- *
142- * // For Release.newVersion equal to 2.1.0 or 1.11.0
143- * Release._tracMilestone();
144- * // => 1.11/2.1
145- *
146- * // For Release.newVersion equal to 2.1.1 or 1.11.1
147- * Release._tracMilestone();
148- * // => 1.11.1/2.1.1
48+ * Publish to distribution repo and npm
49+ * @param {Function } callback
14950 */
150- tracMilestone : function ( ) {
151- var otherVersion ,
152- m = Release . newVersion . split ( "." ) ,
153- major = m [ 0 ] | 0 ,
154- minor = m [ 1 ] | 0 ,
155- patch = m [ 2 ] | 0 ? "." + m [ 2 ] : "" ,
156- version = major + "." + minor + patch ;
157- if ( major === 1 ) {
158- otherVersion = "2." + ( minor - 10 ) + patch ;
159- return version + "/" + otherVersion ;
51+ dist : function ( callback ) {
52+
53+ if ( Release . isTest ) {
54+ callback ( ) ;
55+ return ;
16056 }
161- otherVersion = "1." + ( minor + 10 ) + patch ;
162- return otherVersion + "/" + version ;
57+
58+ dist ( Release , callback ) ;
16359 }
16460 } ) ;
16561} ;
16662
16763module . exports . dependencies = [
16864 "archiver@0.5.2" ,
169- "shelljs@0.2.6"
65+ "shelljs@0.2.6" ,
66+ "npm@2.3.0"
17067] ;
0 commit comments