Skip to content

Commit

Permalink
Ignore GitHub dependencies (#70)
Browse files Browse the repository at this point in the history
* Don't include workspaces in progress

This should improve the consistency of progress in the progress bar as
previously some of the progress could get chewed up by ignored packages
thus giving the false impression of more progress than there actually
is.

* Ignore GitHub deps
  • Loading branch information
mskelton committed Jul 18, 2022
1 parent 74d0664 commit 2a3339a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 11 deletions.
6 changes: 3 additions & 3 deletions bundles/@yarnpkg/plugin-outdated.js

Large diffs are not rendered by default.

22 changes: 14 additions & 8 deletions src/OutdatedCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,20 @@ export class OutdatedCommand extends BaseCommand {
const pkg = project.storedPackages.get(res)
if (!pkg) this.throw(configuration, dependency)

// If the dependency is a workspace, then we don't need to check
// if it is outdated. These type of packages tend to be versioned with
// a tool like Changesets or Lerna; or they are private.
if (workspace.project.tryWorkspaceByLocator(pkg)) {
continue
}

// Ignore GitHub dependencies. In the future we could consider adding
// some custom logic to test this, but for now let's just ignore them
// so at least the plugin doesn't break.
if (pkg.reference.includes("github.com")) {
continue
}

dependencies.push({
dependencyType,
descriptor,
Expand Down Expand Up @@ -357,14 +371,6 @@ export class OutdatedCommand extends BaseCommand {
): Promise<OutdatedDependency[]> {
const outdated = dependencies.map(
async ({ dependencyType, descriptor, name, pkg, workspace }) => {
// If the dependency is a workspace, then we don't need to check
// if it is outdated. These type of packages tend to be versioned with
// a tool like Lerna or they are private.
if (workspace.project.tryWorkspaceByLocator(pkg)) {
progress?.tick()
return
}

const { latest, range, url } = await fetcher.fetch({
descriptor,
includeRange: this.includeRange,
Expand Down
24 changes: 24 additions & 0 deletions test/files/non-semver.lock
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,32 @@ __metadata:
"@scoped/patch": "patch:@scoped/patch@1.0.0#./alias.patch"
alias: "npm:patch@1.0.0"
file: "file:./file-dep"
githubA: mskelton/yarn-constraints-example
githubB: "github:mskelton/yarn-constraints-example"
githubC: "git@github.com:mskelton/yarn-constraints-example.git"
major: "*"
minor: ">1.0.0 <2.0.0"
patch: latest
languageName: unknown
linkType: soft

githubA@mskelton/yarn-constraints-example:
version: 0.0.0
resolution: "githubA@https://github.com/mskelton/yarn-constraints-example.git#commit=67be8b59748ffda1bc0dd2605f4abcdf23c8847c"
checksum: 32dc113c79338e4808807a876ac8d3e3f435bbc4d0f5055986b9a3bdeda6512840f26ce49f82aca9a88e2470e2fbb34245ac2d452837386cc75ef9afea1e778e
languageName: node
linkType: hard

"githubB@github:mskelton/yarn-constraints-example":
version: 0.0.0
resolution: "githubB@https://github.com/mskelton/yarn-constraints-example.git#commit=67be8b59748ffda1bc0dd2605f4abcdf23c8847c"
checksum: 02a2c40208398365ae11168a2de08902b27e6dac2327959ce078e69d15cfa340b97c34ff1f818ba8ff5ee961fa064de599f37424368488c6ed502760cd645c89
languageName: node
linkType: hard

"githubC@git@github.com:mskelton/yarn-constraints-example.git":
version: 0.0.0
resolution: "githubC@git@github.com:mskelton/yarn-constraints-example.git#commit=67be8b59748ffda1bc0dd2605f4abcdf23c8847c"
checksum: 23a1df853c2e943e0b8766c2a6abf9fa9efacb21eaaf9dd0319bf85fdf6c57a498adde3e90327aca8c26fb3de270a028c9804ae14afba7aeeb3259ab8f1af345
languageName: node
linkType: hard
3 changes: 3 additions & 0 deletions test/specs/outdated.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ test.describe.parallel("yarn outdated", () => {
"@scoped/patch": "patch:@scoped/patch@1.0.0#./alias.patch",
alias: "npm:patch@1.0.0",
file: "file:./file-dep",
githubA: "mskelton/yarn-constraints-example",
githubB: "github:mskelton/yarn-constraints-example",
githubC: "git@github.com:mskelton/yarn-constraints-example.git",
major: "*",
minor: ">1.0.0 <2.0.0",
patch: "latest",
Expand Down

0 comments on commit 2a3339a

Please sign in to comment.