'use strict';

// inner modules
const packageDefault = require('./package-default');
const packageRemote = require('./package-remote');
const packageCommon = require('./package-common');

// public methods
module.exports.getNewVersion = (
    pkg,
    commits,
    isSnapshot, isNextBranch, isSupportBranch, isHotfixBranch,
    envTarget
  ) => {
  return Promise.resolve()
    .then(() => {
      if (pkg.remote && pkg.build && pkg.build.envTargetActive) {
        return packageRemote.getNewVersion(pkg, envTarget);
      } else {
        return packageDefault.getNewVersion(pkg, commits, isSnapshot, isNextBranch, isSupportBranch, isHotfixBranch);
      }
    })

    .catch((e) => {
      throw e;
    })
}

module.exports.updateVersion = packageCommon.updateVersion;
