Skip to content

refactor: factor out isWantedDepPrefSame to extend in a future commit#8125

Merged
zkochan merged 1 commit intocatalogsfrom
gluxon/factor-out-isWantedPrefSame
Jun 5, 2024
Merged

refactor: factor out isWantedDepPrefSame to extend in a future commit#8125
zkochan merged 1 commit intocatalogsfrom
gluxon/factor-out-isWantedPrefSame

Conversation

@gluxon
Copy link
Member

@gluxon gluxon commented May 24, 2024

Copying a commit out from #8020 to merge into the main branch. This small refactor should be a no-op and not change pnpm's behavior.

@gluxon gluxon force-pushed the gluxon/factor-out-isWantedPrefSame branch from d2b2146 to 9c66437 Compare May 24, 2024 03:35
Comment on lines +627 to +629
function isWantedDepPrefSame (_alias: string, prevPref: string | undefined, nextPref: string): boolean {
return prevPref === nextPref
}
Copy link
Member Author

Choose a reason for hiding this comment

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

In #8020, this becomes:

function isWantedDepPrefSame (alias: string, prevPref: string | undefined, nextPref: string): boolean {
if (prevPref !== nextPref) {
return false
}
// When pnpm catalogs are used, the specifiers can be the same (e.g.
// "catalog:default"), but the wanted versions for the dependency can be
// different after resolution if the catalog config was just edited.
const catalogName = parseCatalogProtocol(prevPref)
// If there's no catalog name, the catalog protocol was not used and we
// can assume the pref is the same since prevPref and nextPref match.
if (catalogName === null) {
return true
}
const prevCatalogEntrySpec = ctx.wantedLockfile.catalogs?.[catalogName]?.[alias]?.specifier
const nextCatalogEntrySpec = ctx.catalogs[catalogName]?.[alias]
return prevCatalogEntrySpec === nextCatalogEntrySpec
}

@gluxon gluxon marked this pull request as ready for review May 24, 2024 05:33
@gluxon gluxon requested a review from zkochan as a code owner May 24, 2024 05:33
@zkochan
Copy link
Member

zkochan commented Jun 4, 2024

This is a needless change without the catalogs feature. I don't think we should merge it.

@gluxon gluxon changed the base branch from main to catalogs June 5, 2024 06:30
@gluxon
Copy link
Member Author

gluxon commented Jun 5, 2024

This is a needless change without the catalogs feature. I don't think we should merge it.

That's a fair point. I'll point this PR onto the catalogs branch.

@zkochan zkochan merged commit 4fcf925 into catalogs Jun 5, 2024
@zkochan zkochan deleted the gluxon/factor-out-isWantedPrefSame branch June 5, 2024 12:37
@gluxon gluxon mentioned this pull request Jun 16, 2024
@gluxon gluxon mentioned this pull request Jun 26, 2024
18 tasks
zkochan added a commit that referenced this pull request Jun 27, 2024
* feat: create new @pnpm/catalogs.types package (#8026)

* feat: read catalog configs from workspace manifest (#8123)

* refactor: move InvalidWorkspaceManifestError to its own file

* feat: read catalogs config from workspace manifest

* chore: add changeset for new catalog config parsing

* feat: create new `@pnpm/catalogs.protocol-parser` package (#8124)

This works around a problem with pnpm's CI setup not compiling
packages that are not dependencies of the main pnpm package before
running these tests.

#8027 (comment)

* refactor: factor out isWantedDepPrefSame to extend in a future commit (#8125)

* feat: create new `@pnpm/catalogs.config` package (#8220)

* refactor: remove single default catalog check

This check will happen in  `@pnpm/catalogs.config` instead.

* feat: create new @pnpm/catalogs.config package

* fix: work around CI setup not compiling orphan packages before testing

This works around a problem with pnpm's CI setup not compiling
packages that are not dependencies of the main pnpm package before
running these tests.

#8027 (comment)

* feat: create new `@pnpm/catalogs.resolver` package (#8219)

* feat: create new @pnpm/catalogs.resolver package

* fix: work around CI setup not compiling orphan packages before testing

This works around a problem with pnpm's CI setup not compiling
packages that are not dependencies of the main pnpm package before
running these tests.

#8027 (comment)

* feat: implement catalog protocol for publish (#8225)

* feat: implement catalog protocol for install (#8221)

* feat: add catalogs to @pnpm/config

* refactor: factor out resolveDependenciesOfImporterDependency function

* feat: implement catalog resolver and replace prefs

* revert: work around CI setup not compiling orphan packages before testing

* feat: record catalog lookup snapshots through propagated metadata

* feat: update projects when catalogs config changes

* test: add catalog protocol install tests

* refactor: remove filter-packages-from-dir dependency from core tests (#8244)

* refactor: remove filter-packages-from-dir dependency from core tests

* test: refactor

* test: refactor

---------

Co-authored-by: Zoltan Kochan <z@kochan.io>

---------

Co-authored-by: Zoltan Kochan <z@kochan.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants