Repository navigation
fix(deps): keep env.jsonc component peers after lane merge, support +^/+~ versions #10815
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2d7d6b4
fix(deps): keep env.jsonc component peers after lane merge, support +…
davidfirst d48c359
refactor(deps): simplify plus-version helper and peer restore
davidfirst f4963f0
fix(deps): keep plus-version peers correct through bit update and sco…
davidfirst 3924f9f
feat(snapping): gate +^/+~ versions behind the plus-range-versions fe…
davidfirst 6b602b0
fix(deps): resolve a package plus-version peer from a concrete versio…
davidfirst ad5dd69
Merge branch 'master' into fix/env-jsonc-lane-peer-deps
davidfirst 4bbbdf5
fix(snapping): gate +^/+~ in the legacy env.jsonc policy format too
davidfirst 9154cda
fix(deps): keep an unconstrained workspace range when resolving a pac…
davidfirst 4db6f7c
fix(deps): pick the strictest plus version for a singleton peer reque…
davidfirst b766d81
Merge remote-tracking branch 'origin/master' into fix/env-jsonc-lane-…
davidfirst 7be5870
Merge branch 'master' into fix/env-jsonc-lane-peer-deps
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
scopes/component/isolator/prepare-package-json-to-write.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import { expect } from 'chai'; | ||
| import { ComponentID, ComponentIdList } from '@teambit/component-id'; | ||
| import { ExtensionDataList } from '@teambit/legacy.extension-data'; | ||
| import { IsolatorMain } from './isolator.main.runtime'; | ||
|
|
||
| const depId = ComponentID.fromString('my-scope/dep@0.0.2'); | ||
|
|
||
| function preparePackageJson(componentDepsToIgnore: ComponentIdList, includePeers: boolean) { | ||
| const isolator = Object.create(IsolatorMain.prototype); | ||
| isolator.logger = { debug: () => {} }; | ||
| isolator.dependencyResolver = { getComponentDependencies: () => [{ componentId: depId, versionRange: '+^' }] }; | ||
| const noDeps = { getAllIds: () => new ComponentIdList() }; | ||
| const legacyComp = { | ||
| id: ComponentID.fromString('my-scope/user@0.0.2'), | ||
| version: '0.0.2', | ||
| mainFile: 'index.js', | ||
| _getHomepage: () => undefined, | ||
| packageDependencies: {}, | ||
| devPackageDependencies: {}, | ||
| peerPackageDependencies: {}, | ||
| extensions: new ExtensionDataList(), | ||
| dependencies: noDeps, | ||
| devDependencies: noDeps, | ||
| peerDependencies: { getAllIds: () => ComponentIdList.fromArray([depId]) }, | ||
| }; | ||
| const component = { id: legacyComp.id, state: { _consumer: legacyComp } }; | ||
| return isolator.preparePackageJsonToWrite(component, '.', componentDepsToIgnore, includePeers).packageJsonObject; | ||
| } | ||
|
|
||
| describe('IsolatorMain.preparePackageJsonToWrite()', () => { | ||
| it('should write the component peers with their resolved version when asked to', () => { | ||
| const packageJson = preparePackageJson(new ComponentIdList(), true); | ||
| expect(Object.values(packageJson.peerDependencies)).to.deep.equal(['^0.0.2']); | ||
| }); | ||
| it('should not write the component peers by default', () => { | ||
| const packageJson = preparePackageJson(new ComponentIdList(), false); | ||
| expect(packageJson.peerDependencies).to.deep.equal({}); | ||
| }); | ||
| it('should not write a component peer that is part of the capsules', () => { | ||
| const packageJson = preparePackageJson(ComponentIdList.fromArray([depId]), true); | ||
| expect(packageJson.peerDependencies).to.deep.equal({}); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
scopes/dependencies/dependencies/dependencies-loader/apply-overrides.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { expect } from 'chai'; | ||
| import { ApplyOverrides } from './apply-overrides'; | ||
|
|
||
| function createApplyOverrides({ installed, inWorkspacePolicy }: { installed?: string; inWorkspacePolicy?: string }) { | ||
| const applyOverrides = Object.create(ApplyOverrides.prototype); | ||
| applyOverrides.depsResolver = { | ||
| getWorkspacePolicyManifest: () => ({ dependencies: inWorkspacePolicy ? { 'my-pkg': inWorkspacePolicy } : {} }), | ||
| }; | ||
| applyOverrides._resolvePackageData = () => (installed ? { concreteVersion: installed } : undefined); | ||
| return applyOverrides; | ||
| } | ||
|
|
||
| describe('ApplyOverrides.resolveEnvPeerDepVersion()', () => { | ||
| it('should prefer the installed version by default', () => { | ||
| const applyOverrides = createApplyOverrides({ installed: '2.0.0', inWorkspacePolicy: '3.0.1' }); | ||
| expect(applyOverrides.resolveEnvPeerDepVersion('my-pkg')).to.equal('2.0.0'); | ||
| }); | ||
| it('should prefer the workspace policy when asked to, as the installed version could be outdated', () => { | ||
| const applyOverrides = createApplyOverrides({ installed: '2.0.0', inWorkspacePolicy: '3.0.1' }); | ||
| expect(applyOverrides.resolveEnvPeerDepVersion('my-pkg', true)).to.equal('3.0.1'); | ||
| }); | ||
| it('should fall back to the installed version when the workspace policy does not have the package', () => { | ||
| const applyOverrides = createApplyOverrides({ installed: '2.0.0' }); | ||
| expect(applyOverrides.resolveEnvPeerDepVersion('my-pkg', true)).to.equal('2.0.0'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.