From 42adf7b047ce28920d8ccac851255d004ccbf495 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 24 Oct 2024 13:29:57 +0200 Subject: [PATCH] repo-tools: make generate-patch run yarn install Signed-off-by: Patrik Oldsberg --- packages/repo-tools/cli-report.md | 1 + .../commands/generate-patch/generate-patch.ts | 16 +++++++++++++--- packages/repo-tools/src/commands/index.ts | 4 ++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/repo-tools/cli-report.md b/packages/repo-tools/cli-report.md index 3c5906fc4a..da483fe016 100644 --- a/packages/repo-tools/cli-report.md +++ b/packages/repo-tools/cli-report.md @@ -63,6 +63,7 @@ Options: --registry-url --base-version --query + --skip-install -h, --help ``` diff --git a/packages/repo-tools/src/commands/generate-patch/generate-patch.ts b/packages/repo-tools/src/commands/generate-patch/generate-patch.ts index 27f3e2039a..6701695155 100644 --- a/packages/repo-tools/src/commands/generate-patch/generate-patch.ts +++ b/packages/repo-tools/src/commands/generate-patch/generate-patch.ts @@ -60,6 +60,7 @@ export default async ( query?: string; registryUrl?: string; baseVersion?: string; + skipInstall?: boolean; }, ) => { const sourceRepo = await getPackages(process.cwd()); @@ -115,9 +116,18 @@ export default async ( await updateTargetRootPkg(patchEntry); - console.log( - 'Done, be sure to reinstall dependencies in the target workspace', - ); + if (!opts.skipInstall) { + console.log("Running 'yarn install' in target workspace"); + await exec('yarn', ['install'], { + cwd: ctx.targetRoot, + }).catch(() => { + throw new Error( + "Failed to run 'yarn install' in target workspace, please run it manually to troubleshoot", + ); + }); + } else { + console.log("Skipped running 'yarn install'"); + } } finally { fs.rmSync(tmpDir, { force: true, recursive: true, maxRetries: 3 }); } diff --git a/packages/repo-tools/src/commands/index.ts b/packages/repo-tools/src/commands/index.ts index 97208299a3..e3c4c9e41f 100644 --- a/packages/repo-tools/src/commands/index.ts +++ b/packages/repo-tools/src/commands/index.ts @@ -271,6 +271,10 @@ export function registerCommands(program: Command) { '--query ', 'Only apply the patch for a specific version query in the target repository', ) + .option( + '--skip-install', + 'Skip dependency installation in the target repository after applying the patch', + ) .description( 'Generate a patch for the selected package in the target repository', )