repo-tools: make generate-patch run yarn install

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-10-24 13:29:57 +02:00
parent e6a3f63c6c
commit 42adf7b047
3 changed files with 18 additions and 3 deletions
+1
View File
@@ -63,6 +63,7 @@ Options:
--registry-url <registry-url>
--base-version <version>
--query <query>
--skip-install
-h, --help
```
@@ -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 });
}
@@ -271,6 +271,10 @@ export function registerCommands(program: Command) {
'--query <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',
)