|
| 1 | +var shell = require( "shelljs" ); |
| 2 | + |
| 3 | +module.exports = function( Release ) { |
| 4 | + var realRemote = "git@github.com:jquery/codeorigin.jquery.com.git", |
| 5 | + testRemote = "git@github.com:jquery/fake-cdn.git"; |
| 6 | + |
| 7 | + Release.define({ |
| 8 | + _cloneCdnRepo: function() { |
| 9 | + var local = Release.dir.base + "/codeorigin.jquery.com", |
| 10 | + remote = Release.isTest ? testRemote : realRemote; |
| 11 | + |
| 12 | + console.log( "Cloning " + remote.cyan + "..." ); |
| 13 | + Release.git( "clone " + remote + " " + local, "Error cloning CDN repo." ); |
| 14 | + console.log(); |
| 15 | + |
| 16 | + return local; |
| 17 | + }, |
| 18 | + |
| 19 | + _pushToCdn: function() { |
| 20 | + var projectCdn, |
| 21 | + jqueryCdn = Release._cloneCdnRepo(), |
| 22 | + releaseCdn = Release.dir.repo + "/dist/cdn", |
| 23 | + commitMessage = Release.project + ": Added version " + Release.newVersion; |
| 24 | + |
| 25 | + if ( Release.project === "jquery" ) { |
| 26 | + projectCdn = jqueryCdn; |
| 27 | + } else if ( /^jquery-/.test( Release.project ) ) { |
| 28 | + projectCdn = jqueryCdn + "/" + Release.project.substring( 7 ) + |
| 29 | + "/" + Release.newVersion; |
| 30 | + } else { |
| 31 | + projectCdn = jqueryCdn + "/" + Release.project + "/" + Release.newVersion; |
| 32 | + } |
| 33 | + |
| 34 | + shell.mkdir( "-p", projectCdn ); |
| 35 | + shell.cp( "-r", releaseCdn + "/*", projectCdn ); |
| 36 | + |
| 37 | + console.log( "Adding files..." ); |
| 38 | + process.chdir( projectCdn ); |
| 39 | + Release.git( "add ." , "Error adding files." ); |
| 40 | + Release.git( "commit -m '" + commitMessage + "'" , "Error commiting files." ); |
| 41 | + Release.git( "push", "Error pushing to CDN." ); |
| 42 | + console.log(); |
| 43 | + } |
| 44 | + }); |
| 45 | +}; |
0 commit comments