 *  1 - the first version is greater than the second version
 *
 * Set `unstableFirst` to `true` to make versions with `dev`, `beta`, etc go last when the main version numbers are the
 * same. It's useful for detecting compatible versions, for example:
 * `isV3Api = compareVersions('3', version, true) <= 0 && compareVersions('4', version, true) < 0`.
 */
export function compareVersions(version1: string, version2: string, stableFirst?: boolean): -1 | 0 | 1 {
  if (version1 === version2) {
    return 0
  }
