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

Fix dependent packages showing up as changed in getAffectedPackages #786

Merged
merged 3 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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/nervous-dancers-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@definitelytyped/definitions-parser": patch
---

Fix dependent packages showing up as changed in getAffectedPackages
13 changes: 11 additions & 2 deletions packages/definitions-parser/src/get-affected-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ export async function getAffectedPackages(
definitelyTypedPath: string
): Promise<{ errors: string[] } | PreparePackagesResult> {
const errors = [];
// No ... prefix; we only want packages that were actually edited.
const changedPackageDirectories = await execAndThrowErrors(
`pnpm ls -r --depth -1 --parseable --filter '...@types/**[${sourceRemote}/${sourceBranch}]'`,
`pnpm ls -r --depth -1 --parseable --filter '@types/**[${sourceRemote}/${sourceBranch}]'`,
definitelyTypedPath
);

Expand All @@ -29,7 +30,10 @@ export async function getAffectedPackages(
const { additions, deletions } = git;
const addedPackageDirectories = mapDefined(additions, (id) => id.typesDirectoryName);
const allDependentDirectories = [];
const filters = [`--filter '...[${sourceRemote}/${sourceBranch}]'`];
// Start the filter off with all packages that were touched along with those that depend on them.
const filters = [`--filter '...@types/**[${sourceRemote}/${sourceBranch}]'`];
// For packages that have been deleted, they won't appear in the graph anymore; look for packages
// that still depend on the package (but via npm) and manually add them.
for (const d of deletions) {
for (const dep of await allPackages.allTypings()) {
for (const [name, version] of dep.allPackageJsonDependencies()) {
Expand All @@ -52,6 +56,11 @@ export async function getAffectedPackages(
)
);
}

jakebailey marked this conversation as resolved.
Show resolved Hide resolved
console.log("changedPackageDirectories", changedPackageDirectories);
console.log("addedPackageDirectories", addedPackageDirectories);
console.log("allDependentDirectories", allDependentDirectories);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we log similar derived information a little bit later? It's useful but probably overwhelming especially for large changes.

No recommendation, just an observation. More logging is better than none, so I guess leave it in.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forgot to push, this is not supposed to be there!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(pushed now...)


return getAffectedPackagesWorker(
allPackages,
changedPackageDirectories,
Expand Down