|
1 | 1 | (function () {
|
2 | 2 | 'use strict';
|
3 | 3 |
|
| 4 | + const SOURCE_REPO = 'flex-layout'; |
| 5 | + const SOURCE_REPO_TITLE = 'Angular Flex-Layout'; |
| 6 | + const BUILD_REPO = 'flex-layout-builds'; |
| 7 | + |
4 | 8 | var colors = require('colors');
|
5 | 9 | var strip = require('cli-color/strip');
|
6 | 10 | var fs = require('fs');
|
|
12 | 16 | var pushCmds = [ 'rm abort push' ];
|
13 | 17 | var cleanupCmds = [];
|
14 | 18 | var defaultOptions = { encoding: 'utf-8' };
|
15 |
| - var origin = 'git@github.com:angular/material.git'; |
| 19 | + var origin = 'git@github.com:angular/flex-layout.git'; |
16 | 20 | var lineWidth = 80;
|
17 |
| - var lastMajorVer = JSON.parse(exec('curl https://material.angularjs.org/docs.json')).latest; |
| 21 | + var lastMajorVer = "2.0.0.-beta.1"; //JSON.parse(exec(`curl ${URL_VERSIONS}`)).latest; |
18 | 22 | var newVersion;
|
19 | 23 | var dryRun;
|
20 | 24 |
|
|
40 | 44 | createChangelog();
|
41 | 45 | commitChanges();
|
42 | 46 | tagRelease();
|
43 |
| - cloneRepo('bower-material'); |
44 |
| - updateBowerVersion(); |
45 |
| - cloneRepo('code.material.angularjs.org'); |
46 |
| - updateSite(); |
| 47 | + cloneRepo(BUILD_REPO); |
| 48 | + generateLatestBuild(); |
47 | 49 | updateMaster();
|
48 | 50 | writeScript('abort', abortCmds.concat(cleanupCmds));
|
49 | 51 | if (!dryRun) writeScript('push', pushCmds.concat(cleanupCmds));
|
|
83 | 85 | /** writes the new version to package.json */
|
84 | 86 | function updateVersion () {
|
85 | 87 | start(`Updating ${"package.json".cyan} version from ${oldVersion.cyan} to ${newVersion.cyan}...`);
|
| 88 | + |
| 89 | + // Update the repo-root package.json |
86 | 90 | pkg.version = newVersion;
|
87 | 91 | fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2));
|
| 92 | + |
| 93 | + // update the package.json deploy to npm |
| 94 | + let npmPackagePath = './tools/scripts/release/npm_assets/package.json'; |
| 95 | + pkg = require(npmPackagePath); |
| 96 | + pkg.version = newVersion; |
| 97 | + fs.writeFileSync(npmPackagePath, JSON.stringify(pkg, null, 2)); |
| 98 | + |
88 | 99 | done();
|
| 100 | + |
89 | 101 | abortCmds.push('git checkout package.json');
|
| 102 | + abortCmds.push(`gig checkout ${npmPackagePath}`); |
| 103 | + |
90 | 104 | pushCmds.push('git add package.json');
|
| 105 | + pushCmds.push(`git add ${npmPackagePath}`); |
91 | 106 | }
|
92 | 107 |
|
93 | 108 | /** generates the changelog from the commits since the last release */
|
|
208 | 223 | exec('chmod +x ' + name);
|
209 | 224 | }
|
210 | 225 |
|
211 |
| - /** updates the version for bower-material in package.json and bower.json */ |
212 |
| - function updateBowerVersion () { |
213 |
| - start('Updating bower version...'); |
214 |
| - var options = { cwd: './bower-material' }, |
215 |
| - bower = require(options.cwd + '/bower.json'), |
216 |
| - pkg = require(options.cwd + '/package.json'); |
217 |
| - //-- update versions in config files |
218 |
| - bower.version = pkg.version = newVersion; |
219 |
| - fs.writeFileSync(options.cwd + '/package.json', JSON.stringify(pkg, null, 2)); |
220 |
| - fs.writeFileSync(options.cwd + '/bower.json', JSON.stringify(bower, null, 2)); |
221 |
| - done(); |
222 |
| - start('Building bower files...'); |
223 |
| - //-- build files for bower |
| 226 | + /** updates the version for flex-layout-builds in package.json */ |
| 227 | + function generateLatestBuild () { |
| 228 | + start('Building deployed files...'); |
224 | 229 | exec([
|
225 | 230 | 'rm -rf dist',
|
226 |
| - 'gulp build', |
227 |
| - 'gulp build-all-modules --mode=default', |
228 |
| - 'gulp build-all-modules --mode=closure', |
229 |
| - 'rm -rf dist/demos' |
| 231 | + 'gulp build:release' |
230 | 232 | ]);
|
231 | 233 | done();
|
232 |
| - start('Copy files into bower repo...'); |
233 |
| - //-- copy files over to bower repo |
| 234 | + |
| 235 | + start(`Copy files into ${BUILD_REPO} repo...`); |
234 | 236 | exec([
|
235 | 237 | 'cp -Rf ../dist/* ./',
|
236 | 238 | 'git add -A',
|
237 | 239 | `git commit -m "release: version ${newVersion}"`,
|
238 | 240 | 'rm -rf ../dist'
|
239 | 241 | ], options);
|
240 | 242 | done();
|
| 243 | + |
241 | 244 | //-- add steps to push script
|
242 | 245 | pushCmds.push(
|
243 |
| - comment('push to bower (master and tag) and publish to npm'), |
| 246 | + comment('push to builds (master and tag) and publish to npm'), |
244 | 247 | 'cd ' + options.cwd,
|
245 | 248 | 'cp ../CHANGELOG.md .',
|
246 | 249 | 'git add CHANGELOG.md',
|
|
254 | 257 | );
|
255 | 258 | }
|
256 | 259 |
|
257 |
| - /** builds the website for the new version */ |
258 |
| - function updateSite () { |
259 |
| - start('Adding new version of the docs site...'); |
260 |
| - var options = { cwd: './code.material.angularjs.org' }; |
261 |
| - writeDocsJson(); |
262 |
| - |
263 |
| - //-- build files for bower |
264 |
| - exec([ |
265 |
| - 'rm -rf dist', |
266 |
| - 'gulp docs' |
267 |
| - ]); |
268 |
| - replaceFilePaths(); |
269 |
| - |
270 |
| - //-- copy files over to site repo |
271 |
| - exec([ |
272 |
| - `cp -Rf ../dist/docs ${newVersion}`, |
273 |
| - 'rm -rf latest && cp -Rf ../dist/docs latest', |
274 |
| - 'git add -A', |
275 |
| - `git commit -m "release: version ${newVersion}"`, |
276 |
| - 'rm -rf ../dist' |
277 |
| - ], options); |
278 |
| - replaceBaseHref(newVersion); |
279 |
| - replaceBaseHref('latest'); |
280 |
| - |
281 |
| - //-- update firebase.json file |
282 |
| - writeFirebaseJson(); |
283 |
| - exec([ 'git commit --amend --no-edit -a' ], options); |
284 |
| - done(); |
285 |
| - |
286 |
| - //-- add steps to push script |
287 |
| - pushCmds.push( |
288 |
| - comment('push the site'), |
289 |
| - 'cd ' + options.cwd, |
290 |
| - 'git pull --rebase --strategy=ours', |
291 |
| - 'git push', |
292 |
| - 'cd ..' |
293 |
| - ); |
294 |
| - |
295 |
| - function writeFirebaseJson () { |
296 |
| - fs.writeFileSync(options.cwd + '/firebase.json', getFirebaseJson()); |
297 |
| - function getFirebaseJson () { |
298 |
| - var json = require(options.cwd + '/firebase.json'); |
299 |
| - json.rewrites = json.rewrites || []; |
300 |
| - switch (json.rewrites.length) { |
301 |
| - case 0: |
302 |
| - json.rewrites.push(getRewrite('HEAD')); |
303 |
| - case 1: |
304 |
| - json.rewrites.push(getRewrite('latest')); |
305 |
| - default: |
306 |
| - json.rewrites.push(getRewrite(newVersion)); |
307 |
| - } |
308 |
| - return JSON.stringify(json, null, 2); |
309 |
| - function getRewrite (str) { |
310 |
| - return { |
311 |
| - source: '/' + str + '/**/!(*.@(js|html|css|json|svg|png|jpg|jpeg))', |
312 |
| - destination: '/' + str + '/index.html' |
313 |
| - }; |
314 |
| - } |
315 |
| - } |
316 |
| - } |
317 |
| - |
318 |
| - function writeDocsJson () { |
319 |
| - var config = require(options.cwd + '/docs.json'); |
320 |
| - config.versions.unshift(newVersion); |
321 |
| - |
322 |
| - //-- only set to default if not a release candidate |
323 |
| - config.latest = newVersion; |
324 |
| - fs.writeFileSync(options.cwd + '/docs.json', JSON.stringify(config, null, 2)); |
325 |
| - } |
326 |
| - } |
327 |
| - |
328 |
| - /** replaces localhost file paths with public URLs */ |
329 |
| - function replaceFilePaths () { |
330 |
| - //-- handle docs.js |
331 |
| - var path = __dirname + '/dist/docs/docs.js'; |
332 |
| - var file = fs.readFileSync(path); |
333 |
| - var contents = file.toString() |
334 |
| - .replace(/http:\/\/localhost:8080\/angular-material/g, 'https://cdn.gitcdn.link/cdn/angular/bower-material/v' + newVersion + '/angular-material') |
335 |
| - .replace(/http:\/\/localhost:8080\/docs.css/g, 'https://material.angularjs.org/' + newVersion + '/docs.css'); |
336 |
| - fs.writeFileSync(path, contents); |
337 |
| - |
338 |
| - } |
339 |
| - |
340 |
| - /** replaces base href in index.html for new version as well as latest */ |
341 |
| - function replaceBaseHref (folder) { |
342 |
| - //-- handle index.html |
343 |
| - var path = __dirname + '/code.material.angularjs.org/' + folder + '/index.html'; |
344 |
| - var file = fs.readFileSync(path); |
345 |
| - var contents = file.toString().replace(/base href="\//g, 'base href="/' + folder + '/'); |
346 |
| - fs.writeFileSync(path, contents); |
347 |
| - } |
348 | 260 |
|
349 | 261 | /** copies the changelog back over to master branch */
|
350 | 262 | function updateMaster () {
|
|
384 | 296 | function header () {
|
385 | 297 | clear();
|
386 | 298 | line();
|
387 |
| - log(center('Angular Material Release')); |
| 299 | + log(center(`${SOURCE_REPO_TITLE} Release v${newVersion}`)); |
388 | 300 | line();
|
389 | 301 | }
|
390 | 302 |
|
|
0 commit comments