Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"@oxc-node/core": "^0.1.0",
"@tsconfig/node22": "^22.0.6",
"@types/node": "^26.2.0",
"@types/semver": "^7.8.0",
"@vitest/coverage-v8": "^4.1.10",
"@vitest/eslint-plugin": "^1.6.27",
"eslint": "^10.8.1",
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 @@ -24,7 +24,7 @@
"@changesets/types": "workspace:^",
"import-meta-resolve": "^4.2.0",
"jsonc-parser": "^3.3.1",
"semver": "^7.8.1"
"verkit": "^0.4.0"
},
"devDependencies": {
"@changesets/test-utils": "workspace:*",
Expand Down
4 changes: 2 additions & 2 deletions packages/apply-release-plan/src/get-changelog-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
ModCompWithPackage,
NewChangesetWithCommit,
} from "@changesets/types";
import validRange from "semver/ranges/valid.js";
import { isValidRange } from "verkit";
import { capitalize, shouldUpdateDependencyBasedOnConfig } from "./utils.ts";

type ChangelogLines = {
Expand Down Expand Up @@ -59,7 +59,7 @@ export async function getChangelogEntry(
const usesWorkspaceRange = versionRange?.startsWith("workspace:");
return (
versionRange &&
(usesWorkspaceRange || validRange(versionRange) != null) &&
(usesWorkspaceRange || isValidRange(versionRange)) &&
shouldUpdateDependencyBasedOnConfig(
cwd,
rel,
Expand Down
7 changes: 3 additions & 4 deletions packages/apply-release-plan/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import type { ComprehensiveRelease, VersionType } from "@changesets/types";
/**
* Shared utility functions and business logic
*/
import semverSatisfies from "semver/functions/satisfies.js";
import validRange from "semver/ranges/valid.js";
import { isValidRange, satisfies } from "verkit";

const bumpTypes = ["none", "patch", "minor", "major"];

Expand Down Expand Up @@ -54,7 +53,7 @@ export function shouldUpdateDependencyBasedOnConfig(
depVersionRange = `${depVersionRange}${release.oldVersion}`;
break;
default: {
if (!validRange(depVersionRange)) {
if (!isValidRange(depVersionRange)) {
return (
path.posix.normalize(depVersionRange) ===
path.relative(cwd, release.dir).replace(/\\/g, "/")
Expand All @@ -64,7 +63,7 @@ export function shouldUpdateDependencyBasedOnConfig(
}
}
}
if (!semverSatisfies(release.newVersion, depVersionRange)) {
if (!satisfies(release.newVersion, depVersionRange)) {
// Dependencies leaving semver range should always be updated
return true;
}
Expand Down
12 changes: 5 additions & 7 deletions packages/apply-release-plan/src/version-package.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import type { ComprehensiveRelease, PackageJSON } from "@changesets/types";
import Range from "semver/classes/range.js";
import semverPrerelease from "semver/functions/prerelease.js";
import validRange from "semver/ranges/valid.js";
import { isPrerelease, isValidRange, normalizeRange, parseRange } from "verkit";
import type { EditJsonOperation } from "./edit-json.ts";
import { shouldUpdateDependencyBasedOnConfig } from "./utils.ts";

Expand Down Expand Up @@ -69,7 +67,7 @@ export function getDependencyVersionEdits(
if (
!usesWorkspaceRange &&
(bumpVersionsWithWorkspaceProtocolOnly ||
validRange(depCurrentVersion) == null)
!isValidRange(depCurrentVersion))
) {
continue;
}
Expand All @@ -83,7 +81,7 @@ export function getDependencyVersionEdits(
workspaceDepVersion === "*" ||
workspaceDepVersion === "^" ||
workspaceDepVersion === "~" ||
validRange(workspaceDepVersion) == null
!isValidRange(workspaceDepVersion)
) {
continue;
}
Expand All @@ -94,10 +92,10 @@ export function getDependencyVersionEdits(
// 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 Range(depCurrentVersion).range !== "" ||
normalizeRange(parseRange(depCurrentVersion)) !== "" ||
// ...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)
semverPrerelease(newVersion) != null
isPrerelease(newVersion)
) {
let newNewRange = snapshot
? newVersion
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 @@ -21,7 +21,7 @@
"@changesets/get-dependents-graph": "workspace:^",
"@changesets/should-skip-package": "workspace:^",
"@changesets/types": "workspace:^",
"semver": "^7.8.1"
"verkit": "^0.4.0"
},
"devDependencies": {
"@changesets/config": "workspace:*"
Expand Down
7 changes: 3 additions & 4 deletions packages/assemble-release-plan/src/determine-dependents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import type {
VersionType,
Package,
} from "@changesets/types";
import semverSatisfies from "semver/functions/satisfies.js";
import validRange from "semver/ranges/valid.js";
import { isValidRange, satisfies } from "verkit";
import { incrementVersion } from "./increment.ts";
import type { InternalRelease, PreInfo } from "./types.ts";
import { mapGetOrThrowInternal } from "./utils.ts";
Expand Down Expand Up @@ -92,7 +91,7 @@ export function determineDependents({
releases.get(dependent)!.type === "none") &&
(config.___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH
.updateInternalDependents === "always" ||
!semverSatisfies(
!satisfies(
incrementVersion(nextRelease, preInfo),
versionRange,
))
Expand Down Expand Up @@ -205,7 +204,7 @@ function getDependencyVersionRanges(
versionRange = `${versionRange}${dependencyRelease.oldVersion}`;
break;
default: {
if (!validRange(versionRange)) {
if (!isValidRange(versionRange)) {
if (
path.posix.normalize(versionRange) ===
path.relative(rootDir, dependencyPackage.dir).replace(/\\/g, "/")
Expand Down
6 changes: 3 additions & 3 deletions packages/assemble-release-plan/src/increment.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import semverInc from "semver/functions/inc.js";
import { increment } from "verkit";
import type { InternalRelease, PreInfo } from "./types.ts";
import { mapGetOrThrowInternal } from "./utils.ts";

export function incrementVersion(
release: InternalRelease,
preInfo: PreInfo | undefined,
) {
): string {
if (release.type === "none") {
return release.oldVersion;
}

let version = semverInc(release.oldVersion, release.type)!;
let version = increment(release.oldVersion, release.type)!;
if (preInfo != null && preInfo.state.mode !== "exit") {
const preVersion = mapGetOrThrowInternal(
preInfo.preVersions,
Expand Down
4 changes: 2 additions & 2 deletions packages/assemble-release-plan/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { randomUUID } from "node:crypto";
import { defaultConfig } from "@changesets/config";
import type { Config, VersionType } from "@changesets/types";
import { inc } from "semver";
import { increment } from "verkit";
import { beforeEach, describe, expect, it } from "vitest";
import { assembleReleasePlan } from "./index.ts";
import { FakeFullState } from "./test-utils.ts";
Expand Down Expand Up @@ -1256,7 +1256,7 @@ describe("dependent bumping", () => {
const dependency = releases.find((r) => r.name === "pkg-a-b");
expect(dependency).toBeDefined();
expect(dependency!.newVersion).toEqual(
c.bump !== "none" ? inc(BASE_VERSION, c.bump) : BASE_VERSION,
c.bump !== "none" ? increment(BASE_VERSION, c.bump) : BASE_VERSION,
);

// The dependent got bumped (or not) as expected.
Expand Down
5 changes: 2 additions & 3 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 type {
Package,
Packages,
} from "@changesets/types";
import semverParse from "semver/functions/parse.js";
import { parse } from "verkit";
import { applyLinks } from "./apply-links.ts";
import { determineDependents } from "./determine-dependents.ts";
import { flattenReleases } from "./flatten-releases.ts";
Expand All @@ -25,8 +25,7 @@ type SnapshotReleaseParameters = {
};

function getPreVersion(version: string) {
const parsed = semverParse(version)!;
let preVersion = parsed.prerelease[1] ?? -1;
let preVersion = parse(version).prerelease?.[1] ?? -1;
if (typeof preVersion !== "number") {
throw new InternalError("preVersion is not a 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 { InternalError } from "@changesets/errors";
import type { PackageGroup, VersionType, Package } from "@changesets/types";
import semverGt from "semver/functions/gt.js";
import { isGreater } from "verkit";
import type { InternalRelease } from "./types.ts";

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

if (
highestVersion == null ||
semverGt(pkg.packageJson.version, highestVersion)
isGreater(pkg.packageJson.version, highestVersion)
) {
highestVersion = pkg.packageJson.version;
}
Expand Down
5 changes: 2 additions & 3 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,14 @@
"import-meta-resolve": "^4.2.0",
"launch-editor": "^2.14.1",
"package-manager-detector": "^1.6.0",
"semver": "^7.8.1",
"tinyexec": "^1.3.0"
"tinyexec": "^1.3.0",
"verkit": "^0.4.0"
},
"devDependencies": {
"@changesets/color": "workspace:^",
"@changesets/test-utils": "workspace:*",
"@lydell/node-pty": "1.2.0-beta.15",
"@pnpm/pnpr": "0.0.0-26070301",
"@types/semver": "^7.8.0",
"human-id": "^4.2.0",
"modern-tar": "^0.8.4",
"npm-10": "npm:npm@^10.9.8",
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
Expand Up @@ -7,13 +7,13 @@ import type {
VersionType,
} from "@changesets/types";
import { log, type Option } from "@clack/prompts";
import semverLt from "semver/functions/lt.js";
import { isLess } from "verkit";
import { askWithEditor } from "../../utils/askWithEditor.ts";
import * as cli from "../../utils/cli-utilities.ts";
import { importantWarning } from "../../utils/cli-utilities.ts";

async function confirmMajorRelease({ name, version }: PackageJSON) {
if (semverLt(version, "1.0.0")) {
if (isLess(version, "1.0.0")) {
importantWarning(
`
The ${c.red("major")} version of ${c.blue(name)} will be its ${c.red("first major release")} (1.0.0).
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/publish-plan/getPublishPlan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type {
import { log } from "@clack/prompts";
import { getPackages } from "@manypkg/get-packages";
import { graphSequencer } from "@pnpm/deps.graph-sequencer";
import semverParse from "semver/functions/parse.js";
import { parse } from "verkit";
import { npmRequestQueue } from "../../lib/common.ts";
import { splitByTagStatus } from "../../utils/gitTags.ts";
import { getPublishTool } from "../publish/getPublishTool.ts";
Expand Down Expand Up @@ -145,7 +145,7 @@ ${response.error.message || "Unknown error"}
response.info["dist-tags"].latest &&
response.info.versions.every(
(version: string) =>
semverParse(version)!.prerelease[0] === preState.tag,
parse(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 @@ -18,7 +18,7 @@
},
"dependencies": {
"@changesets/types": "workspace:^",
"semver": "^7.8.1"
"verkit": "^0.4.0"
},
"devDependencies": {
"@changesets/color": "workspace:^",
Expand Down
10 changes: 3 additions & 7 deletions packages/get-dependents-graph/src/get-dependency-graph.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from "node:path";
import c from "@changesets/color";
import type { Package, Packages, PackageJSON } from "@changesets/types";
import Range from "semver/classes/range.js";
import { satisfies, tryParseRange } from "verkit";

const DEPENDENCY_TYPES = [
"dependencies",
Expand Down Expand Up @@ -45,11 +45,7 @@ const getValidRange = (potentialRange: string) => {
return null;
}

try {
return new Range(potentialRange);
} catch {
return null;
}
return tryParseRange(potentialRange);
};

export function getDependencyGraph(
Expand Down Expand Up @@ -133,7 +129,7 @@ export function getDependencyGraph(

const range = getValidRange(depRange);

if ((range && !range.test(expected)) || isProtocolRange(depRange)) {
if ((range && !satisfies(expected, range)) || isProtocolRange(depRange)) {
valid = false;
// TODO: replace with returning errors/warnings
console.error(
Expand Down
Loading