release.js
function updateSite () {
    start('Adding new version of the docs site...');
    const options = { cwd: './code.material.angularjs.org' };
    writeDocsJson();

    // build files for bower
    exec([
        'rm -rf dist',
        'gulp docs'
    ]);
    replaceFilePaths();

    // copy files over to site repo
    exec([
        `cp -Rf ../dist/docs ${newVersion}`,
        'rm -rf latest && cp -Rf ../dist/docs latest',
        'git add -A',
        `git commit -m "release: version ${newVersion}"`,
        'rm -rf ../dist'
    ], options);
    replaceBaseHref(newVersion);
    replaceBaseHref('latest');

    // update firebase.json file
    updateFirebaseJson();
    exec(['git commit --amend --no-edit -a'], options);
    done();

    // add steps to push script
    pushCmds.push(
        comment('push the site'),
        'cd ' + options.cwd,
        'git pull --rebase --strategy=ours',
        'git push',
        'cd ..'
    );

    function updateFirebaseJson () {
      fs.writeFileSync(options.cwd + '/firebase.json', getFirebaseJson());
      function getFirebaseJson () {
        const json = require(options.cwd + '/firebase.json');
        json.hosting.rewrites = json.hosting.rewrites || [];
        const rewrites = json.hosting.rewrites;

        switch (rewrites.length) {
          case 0:
            rewrites.push(getRewrite('HEAD'));
          case 1:
            rewrites.push(getRewrite('latest'));
          default:
            rewrites.push(getRewrite(newVersion));
        }
        return JSON.stringify(json, null, 2);
        function getRewrite (str) {
          return {
            source:      '/' + str + '/**/!(*.@(js|html|css|json|svg|png|jpg|jpeg))',
            destination: '/' + str + '/index.html'
          };
        }
      }
    }

    function writeDocsJson () {
      const config = require(options.cwd + '/docs.json');
      config.versions.unshift(newVersion);

      // only set to default if not a release candidate
      config.latest = newVersion;
      fs.writeFileSync(options.cwd + '/docs.json', JSON.stringify(config, null, 2));
    }
  }
function updateSite () {
    start('Adding new version of the docs site...');
    const options = { cwd: './code.material.angularjs.org' };
    writeDocsJson();

    // build files for bower
    exec([
        'rm -rf dist',
        'gulp docs'
    ]);
    replaceFilePaths();

    // copy files over to site repo
    exec([
        `cp -Rf ../dist/docs ${newVersion}`,
        'rm -rf latest && cp -Rf ../dist/docs latest',
        'git add -A',
        `git commit -m "release: version ${newVersion}"`,
        'rm -rf ../dist'
    ], options);
    replaceBaseHref(newVersion);
    replaceBaseHref('latest');

    // update firebase.json file
    updateFirebaseJson();
    exec(['git commit --amend --no-edit -a'], options);
    done();

    // add steps to push script
    pushCmds.push(
        comment('push the site'),
        'cd ' + options.cwd,
        'git pull --rebase --strategy=ours',
        'git push',
        'cd ..'
    );

    function updateFirebaseJson () {
      fs.writeFileSync(options.cwd + '/firebase.json', getFirebaseJson());
      function getFirebaseJson () {
        const json = require(options.cwd + '/firebase.json');
        json.hosting.rewrites = json.hosting.rewrites || [];
        const rewrites = json.hosting.rewrites;

        switch (rewrites.length) {
          case 0:
            rewrites.push(getRewrite('HEAD'));
          case 1:
            rewrites.push(getRewrite('latest'));
          default:
            rewrites.push(getRewrite(newVersion));
        }
        return JSON.stringify(json, null, 2);
        function getRewrite (str) {
          return {
            source:      '/' + str + '/**/!(*.@(js|html|css|json|svg|png|jpg|jpeg))',
            destination: '/' + str + '/index.html'
          };
        }
      }
    }

    function writeDocsJson () {
      const config = require(options.cwd + '/docs.json');
      config.versions.unshift(newVersion);

      // only set to default if not a release candidate
      config.latest = newVersion;
      fs.writeFileSync(options.cwd + '/docs.json', JSON.stringify(config, null, 2));
    }
  }
function updateSite ( ) { start ( 'Adding new version of the docs site...' ) ; const options = { cwd : './code.material.angularjs.org' } ; writeDocsJson ( ) ; // build files for bower exec ( [ 'rm -rf dist' , 'gulp docs' ] ) ; replaceFilePaths ( ) ; // copy files over to site repo exec ( [ ` ${ newVersion } ` , 'rm -rf latest && cp -Rf ../dist/docs latest' , 'git add -A' , ` ${ newVersion } ` , 'rm -rf ../dist' ] , options ) ; replaceBaseHref ( newVersion ) ; replaceBaseHref ( 'latest' ) ; // update firebase.json file updateFirebaseJson ( ) ; exec ( [ 'git commit --amend --no-edit -a' ] , options ) ; done ( ) ; // add steps to push script pushCmds . push ( comment ( 'push the site' ) , 'cd ' + options . cwd , 'git pull --rebase --strategy=ours' , 'git push' , 'cd ..' ) ; function updateFirebaseJson ( ) { fs . writeFileSync ( options . cwd + '/firebase.json' , getFirebaseJson ( ) ) ; function getFirebaseJson ( ) { const json = require ( options . cwd + '/firebase.json' ) ; json . hosting . rewrites = json . hosting . rewrites || [ ] ; const rewrites = json . hosting . rewrites ; switch ( rewrites . length ) { case 0 : rewrites . push ( getRewrite ( 'HEAD' ) ) ; case 1 : rewrites . push ( getRewrite ( 'latest' ) ) ; default : rewrites . push ( getRewrite ( newVersion ) ) ; } return JSON . stringify ( json , null , 2 ) ; function getRewrite ( str ) { return { source : '/' + str + '/**/!(*.@(js|html|css|json|svg|png|jpg|jpeg))' , destination : '/' + str + '/index.html' } ; } } } function writeDocsJson ( ) { const config = require ( options . cwd + '/docs.json' ) ; config . versions . unshift ( newVersion ) ; // only set to default if not a release candidate config . latest = newVersion ; fs . writeFileSync ( options . cwd + '/docs.json' , JSON . stringify ( config , null , 2 ) ) ; } }
builds the website for the new version
builds the website for the new version