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- ] ,
27-
28- _complete = Release . complete ;
29-
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- }
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" ) ,
769
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- }
10+ npmTags = Release . npmTags ,
11+ createTag = Release . _createTag ;
10612
10713 Release . define ( {
10814 npmPublish : true ,
109- npmTags : function ( ) {
110- return [ "1.x" ] ;
111- } ,
112- issueTracker : "trac" ,
113- contributorReportId : 508 ,
15+ issueTracker : "github" ,
11416 /**
11517 * Ensure the repo is in a proper state before release
11618 * @param {Function } callback
11719 */
11820 checkRepoState : function ( callback ) {
11921 ensureSizzle ( Release , callback ) ;
12022 } ,
23+ /**
24+ * The tag for compat is different
25+ * This sets a different new version for the source repo,
26+ * but after building with the correct tag
27+ * e.g. 3.0.0-compat
28+ */
29+ _createTag : function ( paths ) {
30+ Release . distVersion = Release . newVersion ;
31+ Release . newVersion = Release . newVersion
32+ . replace ( / ( \d + \. \d + \. \d + ) / , "$1-compat" ) ;
33+ return createTag ( paths ) ;
34+ } ,
12135 /**
12236 * Generates any release artifacts that should be included in the release.
12337 * The callback must be invoked with an array of files that should be
@@ -126,48 +40,37 @@ module.exports = function( Release ) {
12640 */
12741 generateArtifacts : function ( callback ) {
12842 Release . exec ( "grunt" , "Grunt command failed" ) ;
129- makeReleaseCopies ( ) ;
130- callback ( [ "dist/jquery.js" , "dist/jquery.min.js" , "dist/jquery.min.map" ] ) ;
43+ cdn . makeReleaseCopies ( Release ) ;
44+ callback ( files ) ;
13145 } ,
13246 /**
133- * Release completion
47+ * Acts as insertion point for restoring Release.dir.repo
48+ * It was changed to reuse npm publish code in jquery-release
49+ * for publishing the distribution repo instead
13450 */
135- complete : function ( ) {
136- // Build CDN archives async
137- buildGoogleCDN ( ) ;
138- buildMicrosoftCDN ( ) ;
139- _complete ( ) ;
51+ npmTags : function ( ) {
52+ // origRepo is not defined if dist was skipped
53+ Release . dir . repo = Release . dir . origRepo || Release . dir . repo ;
54+ return npmTags ( ) ;
14055 } ,
14156 /**
142- * Our trac milestones are different than the new version
143- * @example
144- *
145- * // For Release.newVersion equal to 2.1.0 or 1.11.0
146- * Release._tracMilestone();
147- * // => 1.11/2.1
148- *
149- * // For Release.newVersion equal to 2.1.1 or 1.11.1
150- * Release._tracMilestone();
151- * // => 1.11.1/2.1.1
57+ * Publish to distribution repo and npm
58+ * @param {Function } callback
15259 */
153- tracMilestone : function ( ) {
154- var otherVersion ,
155- m = Release . newVersion . split ( "." ) ,
156- major = m [ 0 ] | 0 ,
157- minor = m [ 1 ] | 0 ,
158- patch = m [ 2 ] | 0 ? "." + m [ 2 ] : "" ,
159- version = major + "." + minor + patch ;
160- if ( major === 1 ) {
161- otherVersion = "2." + ( minor - 10 ) + patch ;
162- return version + "/" + otherVersion ;
60+ dist : function ( callback ) {
61+
62+ if ( Release . isTest ) {
63+ callback ( ) ;
64+ return ;
16365 }
164- otherVersion = "1." + ( minor + 10 ) + patch ;
165- return otherVersion + "/" + version ;
66+
67+ dist ( Release , callback ) ;
16668 }
16769 } ) ;
16870} ;
16971
17072module . exports . dependencies = [
17173 "archiver@0.5.2" ,
172- "shelljs@0.2.6"
74+ "shelljs@0.2.6" ,
75+ "npm@2.3.0"
17376] ;
0 commit comments