{"size": 733, "ext": "js", "max_stars_repo_path": "src/utils/designUtils.js", "max_stars_repo_name": "csenn/schesign-js-utils", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/utils/designUtils.js", "max_issues_repo_name": "csenn/schesign-js-utils", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/utils/designUtils.js", "max_forks_repo_name": "csenn/schesign-js-utils", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 31.8695652174, "max_line_length": 89, "alphanum_fraction": 0.6425648022}
import { UPDATE_MAJOR, UPDATE_MINOR, UPDATE_PATCH } from '../constants/publishConstants';

export function getNextVersion(currentLabel, updateType) {
  const label = currentLabel === 'master' ? '0.0.0' : currentLabel;
  const currentSplit = label.split('.');
  let major = parseInt(currentSplit[0]);
  let minor = parseInt(currentSplit[1]);
  let patch = parseInt(currentSplit[2]);

  if (updateType === UPDATE_MAJOR) {
    major += 1;
    return `${major}.0.0`;
  } else if (updateType === UPDATE_MINOR) {
    minor += 1;
    return `${major}.${minor}.0`;
  } else if (updateType === UPDATE_PATCH) {
    patch += 1;
    return `${major}.${minor}.${patch}`;
  } else {
    throw new Error(`Invalid updateType: ${updateType}`);
  }
}
