From 3b4a855bcea246ddecda5438d5e2ea7531c32a29 Mon Sep 17 00:00:00 2001 From: Michael Zhen <112977307+zhenmichael@users.noreply.github.com> Date: Wed, 30 Oct 2024 20:56:45 +0000 Subject: [PATCH 1/2] initial implementation for setDependencyRange --- .../build-infrastructure/src/fluidRepo.ts | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/build-tools/packages/build-infrastructure/src/fluidRepo.ts b/build-tools/packages/build-infrastructure/src/fluidRepo.ts index e8fae51a98ad..e79a95bcb939 100644 --- a/build-tools/packages/build-infrastructure/src/fluidRepo.ts +++ b/build-tools/packages/build-infrastructure/src/fluidRepo.ts @@ -5,6 +5,7 @@ import path from "node:path"; +import type { InterdependencyRange } from "@fluid-tools/version-tools"; import { type SimpleGit, simpleGit } from "simple-git"; import { type IFluidRepoLayout, getFluidRepoLayout } from "./config.js"; @@ -235,3 +236,28 @@ export function getAllDependenciesInRepo( workspaces: [...workspaces], }; } + +export async function setDependencyRange( + packagesToUpdate: IPackage[], + dependencies: IPackage[], + dependencyRange: InterdependencyRange +): Promise { + for (const pkg of packagesToUpdate) { + for (const dep of pkg.combinedDependencies) { + if (dependencies.some(d => d.name === dep.name)) { + console.log(`Match found: ${dep.name}`); + + // Update the version in packageJson + const depName = dep.name; + if ((pkg.packageJson.dependencies?.[depName]) !== undefined) { + pkg.packageJson.dependencies[depName] = dependencyRange as string; + } else if ((pkg.packageJson.devDependencies?.[depName]) !== undefined) { + pkg.packageJson.devDependencies[depName] = dependencyRange as string; + } else if ((pkg.packageJson.peerDependencies?.[depName]) !== undefined) { + pkg.packageJson.peerDependencies[depName] = dependencyRange as string; + } + } + } + await pkg.savePackageJson(); + } +} From 2a41a0291f599cda46c5542737cd0707223664a1 Mon Sep 17 00:00:00 2001 From: Michael Zhen <112977307+zhenmichael@users.noreply.github.com> Date: Wed, 30 Oct 2024 20:58:11 +0000 Subject: [PATCH 2/2] remove console.log --- build-tools/packages/build-infrastructure/src/fluidRepo.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/build-tools/packages/build-infrastructure/src/fluidRepo.ts b/build-tools/packages/build-infrastructure/src/fluidRepo.ts index e79a95bcb939..a7601880366c 100644 --- a/build-tools/packages/build-infrastructure/src/fluidRepo.ts +++ b/build-tools/packages/build-infrastructure/src/fluidRepo.ts @@ -245,8 +245,6 @@ export async function setDependencyRange( for (const pkg of packagesToUpdate) { for (const dep of pkg.combinedDependencies) { if (dependencies.some(d => d.name === dep.name)) { - console.log(`Match found: ${dep.name}`); - // Update the version in packageJson const depName = dep.name; if ((pkg.packageJson.dependencies?.[depName]) !== undefined) {