lib/services/upgrade.js
function runTransforms(transforms, upgradeFile, ref, data, locals) {
  log('debug', `Running ${transforms.length} transforms`);
  return bluebird.reduce(transforms, function (acc, val) {
    var key = val.toString();

    // Parsefloat strips decimals with `.0` leaving just the int,
    // let's add them back in
    if (!_.includes(key, '.')) {
      key += '.0';
    }

    return bluebird.try(upgradeFile[key].bind(null, ref, acc, locals))
      .catch(e => {
        log('error', `Error upgrading ${ref} to version ${key}: ${e.message}`, {
          errStack: e.stack,
          cmptData: JSON.stringify(acc)
        });
        return bluebird.reject(e);
      });
  }, data)
    .then(function (resp) {
      // Assign the version number automatically
      resp._version = transforms[transforms.length - 1];
      return resp;
    });
}
function runTransforms(transforms, upgradeFile, ref, data, locals) {
  log('debug', `Running ${transforms.length} transforms`);
  return bluebird.reduce(transforms, function (acc, val) {
    var key = val.toString();

    // Parsefloat strips decimals with `.0` leaving just the int,
    // let's add them back in
    if (!_.includes(key, '.')) {
      key += '.0';
    }

    return bluebird.try(upgradeFile[key].bind(null, ref, acc, locals))
      .catch(e => {
        log('error', `Error upgrading ${ref} to version ${key}: ${e.message}`, {
          errStack: e.stack,
          cmptData: JSON.stringify(acc)
        });
        return bluebird.reject(e);
      });
  }, data)
    .then(function (resp) {
      // Assign the version number automatically
      resp._version = transforms[transforms.length - 1];
      return resp;
    });
}
function runTransforms ( transforms , upgradeFile , ref , data , locals ) { log ( 'debug' , ` ${ transforms . length } ` ) ; return bluebird . reduce ( transforms , function ( acc , val ) { var key = val . toString ( ) ; // Parsefloat strips decimals with `.0` leaving just the int, // let's add them back in if ( ! _ . includes ( key , '.' ) ) { key += '.0' ; } return bluebird . try ( upgradeFile [ key ] . bind ( null , ref , acc , locals ) ) . catch ( e => { log ( 'error' , ` ${ ref } ${ key } ${ e . message } ` , { errStack : e . stack , cmptData : JSON . stringify ( acc ) } ) ; return bluebird . reject ( e ) ; } ) ; } , data ) . then ( function ( resp ) { // Assign the version number automatically resp . _version = transforms [ transforms . length - 1 ] ; return resp ; } ) ; }
We have a the transforms we need to perform, so let's
reduce them into the final data object.

@param  {Array}   transforms
@param  {Object}  upgradeFile
@param  {String}  ref
@param  {Object}  data
@param  {Object}  locals
@return {Promise}
We have a the transforms we need to perform so let s reduce them into the final data object .