From 8e2237b7fec44961be14205eafad00e39a605893 Mon Sep 17 00:00:00 2001 From: Tyler Butler Date: Mon, 28 Oct 2024 18:09:48 -0700 Subject: [PATCH] rm setDependencyVersion --- .../src/test/versions.test.ts | 34 +----------- .../build-infrastructure/src/versions.ts | 55 ------------------- 2 files changed, 1 insertion(+), 88 deletions(-) diff --git a/build-tools/packages/build-infrastructure/src/test/versions.test.ts b/build-tools/packages/build-infrastructure/src/test/versions.test.ts index b68e54081969..666eb9f22f03 100644 --- a/build-tools/packages/build-infrastructure/src/test/versions.test.ts +++ b/build-tools/packages/build-infrastructure/src/test/versions.test.ts @@ -13,7 +13,7 @@ import { simpleGit } from "simple-git"; import { loadFluidRepo } from "../fluidRepo.js"; import type { ReleaseGroupName, WorkspaceName } from "../types.js"; -import { setDependencyVersion, setVersion } from "../versions.js"; +import { setVersion } from "../versions.js"; import { testDataPath, testRepoRoot } from "./init.js"; @@ -70,35 +70,3 @@ describe("setVersion", () => { expect(allCorrect).to.be.true; }); }); - -describe("setDependencyVersion", () => { - afterEach(async () => { - await git.checkout(["HEAD", "--", testRepoRoot]); - repo.reload(); - }); - - it("update release group deps", async () => { - await setDependencyVersion( - main.packages, - group2.packages.map((p) => p.name), - "workspace:~", - ); - repo.reload(); - - const depsToCheck = new Set(group2.packages.map((p) => p.name)); - const allCorrect = main.packages.every((pkg) => { - for (const { name, version } of pkg.combinedDependencies) { - if (!depsToCheck.has(name)) { - continue; - } - const matches = version === "workspace:~"; - if (matches === false) { - console.error(`${name} has incorrect version/range: ${version}`); - return false; - } - } - return true; - }); - expect(allCorrect).to.be.true; - }); -}); diff --git a/build-tools/packages/build-infrastructure/src/versions.ts b/build-tools/packages/build-infrastructure/src/versions.ts index f43f64edf42d..b4519ca6da7c 100644 --- a/build-tools/packages/build-infrastructure/src/versions.ts +++ b/build-tools/packages/build-infrastructure/src/versions.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. */ -import type { InterdependencyRange } from "@fluid-tools/version-tools"; import * as semver from "semver"; import { updatePackageJsonFile } from "./packageJsonUtils.js"; @@ -29,57 +28,3 @@ export async function setVersion( }); } } - -/** - * - * Note that any loaded objects such as an IFluidRepo instance may need to be reloaded after calling this function. - * - * @param packages - Packages whose dependencies should be updated. - * @param dependencyNames - The names of the dependencies that should be modified. - * @param dependencyRange - The new dependency range to use. - */ -export async function setDependencyVersion( - packages: IPackage[], - dependencyNames: string[], - dependencyRange: InterdependencyRange, -): Promise { - const depRangeToSet = - typeof dependencyRange === "string" ? dependencyRange : dependencyRange.version; - - const dependenciesToUpdate: ReadonlySet = new Set(dependencyNames); - const savePromises: Promise[] = []; - for (const pkg of packages) { - for (const { name, depKind } of pkg.combinedDependencies) { - if (!dependenciesToUpdate.has(name)) { - continue; - } - - switch (depKind) { - case "dev": { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - pkg.packageJson.devDependencies![name] = depRangeToSet; - break; - } - - case "peer": { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - pkg.packageJson.peerDependencies![name] = depRangeToSet; - break; - } - - case "prod": { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - pkg.packageJson.dependencies![name] = depRangeToSet; - break; - } - - default: { - throw new Error(`Unknown dependency type: ${depKind}`); - } - } - } - savePromises.push(pkg.savePackageJson()); - } - - await Promise.all(savePromises); -}