Skip to content

Commit

Permalink
Bump semver to v7.5.3 (#1176)
Browse files Browse the repository at this point in the history
* Bump semver to v7.5.3

* Refactor semver imports to module imports

* Create cyan-badgers-complain.md

---------

Co-authored-by: Mateusz Burzyński <[email protected]>
  • Loading branch information
joshwooding and Andarist authored Jun 27, 2023
1 parent 11cb3e9 commit 41988ce
Show file tree
Hide file tree
Showing 19 changed files with 49 additions and 44 deletions.
9 changes: 9 additions & 0 deletions .changeset/cyan-badgers-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@changesets/apply-release-plan": patch
"@changesets/assemble-release-plan": patch
"@changesets/cli": patch
"@changesets/get-dependents-graph": patch
"@changesets/release-utils": patch
---

Bump [`semver`](https://github.com/npm/node-semver) dependency to v7.5.3
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"@types/lodash": "^4.14.136",
"@types/meow": "^5.0.0",
"@types/prettier": "^2.7.1",
"@types/semver": "^6.0.0",
"@types/semver": "^7.5.0",
"@typescript-eslint/eslint-plugin": "^5.43.0",
"@typescript-eslint/parser": "^5.43.0",
"codecov": "^3.6.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/apply-release-plan/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"outdent": "^0.5.0",
"prettier": "^2.7.1",
"resolve-from": "^5.0.0",
"semver": "^5.4.1"
"semver": "^7.5.3"
},
"devDependencies": {
"@changesets/test-utils": "*",
Expand Down
4 changes: 2 additions & 2 deletions packages/apply-release-plan/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Shared utility functions and business logic
*/
import semver from "semver";
import semverSatisfies from "semver/functions/satisfies";
import { VersionType } from "@changesets/types";

const bumpTypes = ["none", "patch", "minor", "major"];
Expand Down Expand Up @@ -36,7 +36,7 @@ export function shouldUpdateDependencyBasedOnConfig(
onlyUpdatePeerDependentsWhenOutOfRange: boolean;
}
): boolean {
if (!semver.satisfies(release.version, depVersionRange)) {
if (!semverSatisfies(release.version, depVersionRange)) {
// Dependencies leaving semver range should always be updated
return true;
}
Expand Down
7 changes: 4 additions & 3 deletions packages/apply-release-plan/src/version-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {
VersionType,
} from "@changesets/types";
import getVersionRangeType from "@changesets/get-version-range-type";
import semver from "semver";
import Range from "semver/classes/range"
import semverPrerelease from "semver/functions/prerelease";
import { shouldUpdateDependencyBasedOnConfig } from "./utils";

const DEPENDENCY_TYPES = [
Expand Down Expand Up @@ -88,10 +89,10 @@ export default function versionPackage(
// we don't want to change these versions because they will match
// any version and if someone makes the range that
// they probably want it to stay like that...
new semver.Range(depCurrentVersion).range !== "" ||
new Range(depCurrentVersion).range !== "" ||
// ...unless the current version of a dependency is a prerelease (which doesn't satisfy x/X/*)
// leaving those as is would leave the package in a non-installable state (wrong dep versions would get installed)
semver.prerelease(version) !== null
semverPrerelease(version) !== null
) {
let newNewRange = snapshot
? version
Expand Down
2 changes: 1 addition & 1 deletion packages/assemble-release-plan/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@changesets/get-dependents-graph": "^1.3.5",
"@changesets/types": "^5.2.1",
"@manypkg/get-packages": "^1.1.3",
"semver": "^5.4.1"
"semver": "^7.5.3"
},
"devDependencies": {
"@changesets/config": "*"
Expand Down
6 changes: 3 additions & 3 deletions packages/assemble-release-plan/src/determine-dependents.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import semver from "semver";
import semverSatisfies from "semver/functions/satisfies";
import {
DependencyType,
PackageJSON,
Expand Down Expand Up @@ -86,7 +86,7 @@ export default function determineDependents({
releases.get(dependent)!.type === "none") &&
(config.___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH
.updateInternalDependents === "always" ||
!semver.satisfies(
!semverSatisfies(
incrementVersion(nextRelease, preInfo),
versionRange
))
Expand Down Expand Up @@ -231,7 +231,7 @@ function shouldBumpMajor({
// 1. If onlyUpdatePeerDependentsWhenOutOfRange set to true, bump major if the version is leaving the range.
// 2. If onlyUpdatePeerDependentsWhenOutOfRange set to false, bump major regardless whether or not the version is leaving the range.
(!onlyUpdatePeerDependentsWhenOutOfRange ||
!semver.satisfies(
!semverSatisfies(
incrementVersion(nextRelease, preInfo),
versionRange
)) &&
Expand Down
4 changes: 2 additions & 2 deletions packages/assemble-release-plan/src/increment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as semver from "semver";
import semverInc from "semver/functions/inc";
import { InternalRelease, PreInfo } from "./types";
import { InternalError } from "@changesets/errors";

Expand All @@ -10,7 +10,7 @@ export function incrementVersion(
return release.oldVersion;
}

let version = semver.inc(release.oldVersion, release.type)!;
let version = semverInc(release.oldVersion, release.type)!;
if (preInfo !== undefined && preInfo.state.mode !== "exit") {
let preVersion = preInfo.preVersions.get(release.name);
if (preVersion === undefined) {
Expand Down
4 changes: 2 additions & 2 deletions packages/assemble-release-plan/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import flattenReleases from "./flatten-releases";
import matchFixedConstraint from "./match-fixed-constraint";
import applyLinks from "./apply-links";
import { incrementVersion } from "./increment";
import * as semver from "semver";
import semverParse from "semver/functions/parse";
import { InternalError } from "@changesets/errors";
import { Packages, Package } from "@manypkg/get-packages";
import { getDependentsGraph } from "@changesets/get-dependents-graph";
Expand All @@ -22,7 +22,7 @@ type SnapshotReleaseParameters = {
};

function getPreVersion(version: string) {
let parsed = semver.parse(version)!;
let parsed = semverParse(version)!;
let preVersion =
parsed.prerelease[1] === undefined ? -1 : parsed.prerelease[1];
if (typeof preVersion !== "number") {
Expand Down
4 changes: 2 additions & 2 deletions packages/assemble-release-plan/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PackageGroup, VersionType } from "@changesets/types";
import { Package } from "@manypkg/get-packages";
import semver from "semver";
import semverGt from "semver/functions/gt";
import { InternalRelease } from "./types";

export function getHighestReleaseType(
Expand Down Expand Up @@ -50,7 +50,7 @@ export function getCurrentHighestVersion(

if (
highestVersion === undefined ||
semver.gt(pkg.packageJson.version, highestVersion)
semverGt(pkg.packageJson.version, highestVersion)
) {
highestVersion = pkg.packageJson.version;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@changesets/write": "^0.2.3",
"@manypkg/get-packages": "^1.1.3",
"@types/is-ci": "^3.0.0",
"@types/semver": "^6.0.0",
"@types/semver": "^7.5.0",
"ansi-colors": "^4.1.3",
"chalk": "^2.1.0",
"enquirer": "^2.3.0",
Expand All @@ -59,7 +59,7 @@
"p-limit": "^2.2.0",
"preferred-pm": "^3.0.0",
"resolve-from": "^5.0.0",
"semver": "^5.4.1",
"semver": "^7.5.3",
"spawndamnit": "^2.0.0",
"term-size": "^2.1.0",
"tty-table": "^4.1.5"
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/add/createChangeset.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import chalk from "chalk";

import semver from "semver";
import semverLt from "semver/functions/lt";

import * as cli from "../../utils/cli-utilities";
import { error, log } from "@changesets/logger";
Expand All @@ -11,7 +11,7 @@ import { ExitError } from "@changesets/errors";
const { green, yellow, red, bold, blue, cyan } = chalk;

async function confirmMajorRelease(pkgJSON: PackageJSON) {
if (semver.lt(pkgJSON.version, "1.0.0")) {
if (semverLt(pkgJSON.version, "1.0.0")) {
// prettier-ignore
log(yellow(`WARNING: Releasing a major version for ${green(pkgJSON.name)} will be its ${red('first major release')}.`))
log(
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/publish/npm-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import pLimit from "p-limit";
import preferredPM from "preferred-pm";
import chalk from "chalk";
import spawn from "spawndamnit";
import semver from "semver";
import semverParse from "semver/functions/parse";
import { askQuestion } from "../../utils/cli-utilities";
import isCI from "is-ci";
import { TwoFactorState } from "../../utils/types";
Expand Down Expand Up @@ -49,7 +49,7 @@ async function getPublishTool(
try {
let result = await spawn("pnpm", ["--version"], { cwd });
let version = result.stdout.toString().trim();
let parsed = semver.parse(version);
let parsed = semverParse(version);
return {
name: "pnpm",
shouldAddNoGitChecks:
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/publish/publishPackages.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { join } from "path";
import semver from "semver";
import semverParse from "semver/functions/parse";
import chalk from "chalk";
import { AccessType } from "@changesets/types";
import { Package } from "@manypkg/get-packages";
Expand Down Expand Up @@ -161,7 +161,7 @@ async function getUnpublishedPackages(
response.pkgInfo.versions &&
response.pkgInfo.versions.every(
(version: string) =>
semver.parse(version)!.prerelease[0] === preState.tag
semverParse(version)!.prerelease[0] === preState.tag
)
) {
publishedState = "only-pre";
Expand Down
2 changes: 1 addition & 1 deletion packages/get-dependents-graph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@manypkg/get-packages": "^1.1.3",
"chalk": "^2.1.0",
"fs-extra": "^7.0.1",
"semver": "^5.4.1"
"semver": "^7.5.3"
},
"devDependencies": {
"@changesets/test-utils": "*"
Expand Down
4 changes: 2 additions & 2 deletions packages/get-dependents-graph/src/get-dependency-graph.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This is a modified version of the graph-getting in bolt
import semver from "semver";
import Range from "semver/classes/range";
import chalk from "chalk";
import { Packages, Package } from "@manypkg/get-packages";
import { PackageJSON } from "@changesets/types";
Expand Down Expand Up @@ -42,7 +42,7 @@ const getValidRange = (potentialRange: string) => {
}

try {
return new semver.Range(potentialRange);
return new Range(potentialRange);
} catch {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/release-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"mdast-util-to-string": "^1.0.6",
"remark-parse": "^7.0.1",
"remark-stringify": "^7.0.3",
"semver": "^5.4.1",
"semver": "^7.5.3",
"spawndamnit": "^2.0.0",
"unified": "^8.3.2"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/release-utils/src/run.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getPackages, Package } from "@manypkg/get-packages";
import path from "path";
import * as semver from "semver";
import semverLt from "semver/functions/lt";
import {
execWithOutput,
getVersionsByDirectory,
Expand Down Expand Up @@ -127,7 +127,7 @@ export async function runVersion({
"cli",
"package.json"
));
let cmd = semver.lt(changesetsCliPkgJson.version, "2.0.0")
let cmd = semverLt(changesetsCliPkgJson.version, "2.0.0")
? "bump"
: "version";
await execWithOutput(
Expand Down
21 changes: 8 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2055,20 +2055,15 @@
dependencies:
"@types/node" "*"

"@types/semver@^6.0.0":
version "6.2.0"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-6.2.0.tgz#d688d574400d96c5b0114968705366f431831e1a"
integrity sha512-1OzrNb4RuAzIT7wHSsgZRlMBlNsJl+do6UblR7JMW4oB7bbR+uBEYtUh7gEc/jM84GGilh68lSOokyM/zNUlBA==

"@types/semver@^6.0.1":
version "6.2.2"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-6.2.2.tgz#5c27df09ca39e3c9beb4fae6b95f4d71426df0a9"
integrity sha512-RxAwYt4rGwK5GyoRwuP0jT6ZHAVTdz2EqgsHmX0PYNjGsko+OeT4WFXXTs/lM3teJUJodM+SNtAL5/pXIJ61IQ==

"@types/semver@^7.3.12":
version "7.3.13"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.3.13.tgz#da4bfd73f49bd541d28920ab0e2bf0ee80f71c91"
integrity sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==
"@types/semver@^7.3.12", "@types/semver@^7.5.0":
version "7.5.0"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.0.tgz#591c1ce3a702c45ee15f47a42ade72c2fd78978a"
integrity sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==

"@types/stack-utils@^2.0.0":
version "2.0.1"
Expand Down Expand Up @@ -6640,10 +6635,10 @@ semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0:
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==

semver@^7.0.0, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8:
version "7.3.8"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798"
integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==
semver@^7.0.0, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8, semver@^7.5.3:
version "7.5.3"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.3.tgz#161ce8c2c6b4b3bdca6caadc9fa3317a4c4fe88e"
integrity sha512-QBlUtyVk/5EeHbi7X0fw6liDZc7BBmEaSYn01fMU1OUYbf6GPsbTtd8WmnqbI20SeycoHSeiybkE/q1Q+qlThQ==
dependencies:
lru-cache "^6.0.0"

Expand Down

0 comments on commit 41988ce

Please sign in to comment.