nextVersion

tcmts.cli.releases.nextVersion · #fivcfh4j · term · runs anywhere

The version a level of change calls for after prev: from 1.0, a major for breaking changes, a minor for additions, a patch otherwise; before 1.0, a minor for breaking changes and a patch for anything else (as npm and Cargo read 0.x versions).

import type { Level } from "#codebase/tcmts/cli/semver_checks";
import { bumpVersion } from "#codebase/tcmts/core/semver";

export function nextVersion(prev: string | undefined, level: Level | undefined): string {
  if (!prev) return "0.1.0";
  const zero = prev.startsWith("0.");
  return bumpVersion(prev, !level ? "patch" : zero ? (level === "major" ? "minor" : "patch") : level);
}

uses

used by