gulpfile.babel.js
function mdlPublish(pubScope) {
  let cacheTtl = null;
  let src = null;
  let dest = null;

  if (pubScope === 'staging') {
    // Set staging specific vars here.
    cacheTtl = 0;
    src = 'dist/*';
    dest = bucketStaging;
  } else if (pubScope === 'prod') {
    // Set prod specific vars here.
    cacheTtl = 60;
    src = 'dist/*';
    dest = bucketProd;
  } else if (pubScope === 'promote') {
    // Set promote (essentially prod) specific vars here.
    cacheTtl = 60;
    src = `${bucketStaging}/*`;
    dest = bucketProd;
  }

  let infoMsg = `Publishing ${pubScope}/${pkg.version} to GCS (${dest})`;
  if (src) {
    infoMsg += ` from ${src}`;
  }
  console.log(infoMsg);

  // Build gsutil commands:
  // The gsutil -h option is used to set metadata headers.
  // The gsutil -m option requests parallel copies.
  // The gsutil -R option is used for recursive file copy.
  const cacheControl = `-h "Cache-Control:public,max-age=${cacheTtl}"`;
  const gsutilCacheCmd = `gsutil -m setmeta ${cacheControl} ${dest}/**`;
  const gsutilCpCmd = `gsutil -m cp -r -z html,css,js,svg ${src} ${dest}`;

  gulp.src('').pipe($.shell([gsutilCpCmd, gsutilCacheCmd]));
}
function mdlPublish(pubScope) {
  let cacheTtl = null;
  let src = null;
  let dest = null;

  if (pubScope === 'staging') {
    // Set staging specific vars here.
    cacheTtl = 0;
    src = 'dist/*';
    dest = bucketStaging;
  } else if (pubScope === 'prod') {
    // Set prod specific vars here.
    cacheTtl = 60;
    src = 'dist/*';
    dest = bucketProd;
  } else if (pubScope === 'promote') {
    // Set promote (essentially prod) specific vars here.
    cacheTtl = 60;
    src = `${bucketStaging}/*`;
    dest = bucketProd;
  }

  let infoMsg = `Publishing ${pubScope}/${pkg.version} to GCS (${dest})`;
  if (src) {
    infoMsg += ` from ${src}`;
  }
  console.log(infoMsg);

  // Build gsutil commands:
  // The gsutil -h option is used to set metadata headers.
  // The gsutil -m option requests parallel copies.
  // The gsutil -R option is used for recursive file copy.
  const cacheControl = `-h "Cache-Control:public,max-age=${cacheTtl}"`;
  const gsutilCacheCmd = `gsutil -m setmeta ${cacheControl} ${dest}/**`;
  const gsutilCpCmd = `gsutil -m cp -r -z html,css,js,svg ${src} ${dest}`;

  gulp.src('').pipe($.shell([gsutilCpCmd, gsutilCacheCmd]));
}
function mdlPublish ( pubScope ) { let cacheTtl = null ; let src = null ; let dest = null ; if ( pubScope === 'staging' ) { // Set staging specific vars here. cacheTtl = 0 ; src = 'dist/*' ; dest = bucketStaging ; } else if ( pubScope === 'prod' ) { // Set prod specific vars here. cacheTtl = 60 ; src = 'dist/*' ; dest = bucketProd ; } else if ( pubScope === 'promote' ) { // Set promote (essentially prod) specific vars here. cacheTtl = 60 ; src = ` ${ bucketStaging } ` ; dest = bucketProd ; } let infoMsg = ` ${ pubScope } ${ pkg . version } ${ dest } ` ; if ( src ) { infoMsg += ` ${ src } ` ; } console . log ( infoMsg ) ; // Build gsutil commands: // The gsutil -h option is used to set metadata headers. // The gsutil -m option requests parallel copies. // The gsutil -R option is used for recursive file copy. const cacheControl = ` ${ cacheTtl } ` ; const gsutilCacheCmd = ` ${ cacheControl } ${ dest } ` ; const gsutilCpCmd = ` ${ src } ${ dest } ` ; gulp . src ( '' ) . pipe ( $ . shell ( [ gsutilCpCmd , gsutilCacheCmd ] ) ) ; }
Function to publish staging or prod version from local tree,
or to promote staging to prod, per passed arg.
@param {string} pubScope the scope to publish to.
Function to publish staging or prod version from local tree or to promote staging to prod per passed arg .