Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repo-tools: add generate-patch command #27331

Merged
merged 6 commits into from
Oct 24, 2024
Merged
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
5 changes: 5 additions & 0 deletions .changeset/tough-onions-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@backstage/repo-tools': patch
---

Added a new `generate-patch` command that can be used to generate patches for current changes in a source workspace to be installed it a target workspace.
18 changes: 18 additions & 0 deletions docs/tooling/local-dev/linking-local-packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,21 @@ You can also link backend packages using the exact same process, simply start yo
### React errors

If you are encountering errors related to React, it is likely that the versions of React in the two workspaces are different. Make sure that the versions of `react` and `react-dom` are the same in both workspaces, or at least that they are in sync between the package that you're serving the app from and the external workspace.

## Generating temporary patches

!!!info
This feature is experimental and currently only supports Yarn workspaces.
!!!

After making local changes to a package in an external workspace you might often want to merge and deploy these changes in your own project. You can use Yarn patches for this purpose, but it can be quite cumbersome to create these patches manually. To make this process easier, you can use `yarn backstage-repo-tools generate-patch` command from the `@backstage/repo-tools` package to generate a patch and resolution entries in the external workspace.

For example, if you've made changes to the `@backstage/backend-app-api` package in a local clone of the main `backstage` repository, you can generate a patch for your internal project as follows:

```bash title="Run in the cloned backstage repository"
yarn backstage-repo-tools generate patch @backstage/backend-app-api --target ../our-developer-portal
```

This will generate a patch file in your `our-developer-portal` workspace. The patch will be based on the most recently released version of the source package, with the additional changes on top.

If you want to base the patch on a different version of the source package, you can specify the version using the `--base-version <version>` option, and if you want to only use the patch for a specific version query, you can specify that using the `--query <query>` option.
15 changes: 15 additions & 0 deletions packages/repo-tools/cli-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Commands:
type-deps
peer-deps [options]
generate-catalog-info [options]
generate-patch [options] <package>
knip-reports [options] [paths...]
package [command]
repo [command]
Expand Down Expand Up @@ -52,6 +53,20 @@ Options:
-h, --help
```

### `backstage-repo-tools generate-patch`

```
Usage: backstage-repo-tools generate-patch [options] <package>

Options:
--target <target-repo>
--registry-url <registry-url>
--base-version <version>
--query <query>
--skip-install
-h, --help
```

### `backstage-repo-tools knip-reports`

```
Expand Down
1 change: 1 addition & 0 deletions packages/repo-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"minimatch": "^9.0.0",
"p-limit": "^3.0.2",
"portfinder": "^1.0.32",
"tar": "^6.1.12",
"ts-morph": "^23.0.0",
"yaml-diff-patch": "^2.0.0"
},
Expand Down
Loading
Loading