-
Notifications
You must be signed in to change notification settings - Fork 954
fix: Missing Packages After bit new with Forked Env #10201
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
Open
zkochan
wants to merge
15
commits into
teambit:master
Choose a base branch
from
zkochan:fix/10200
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
705a10b
test: add failing e2e for forked env missing deps (PR #10150 regression)
zkochan c6b802e
fix: resolve forked env missing deps regression from PR #10150
zkochan e4ed040
style: fix
zkochan 5d83398
Merge branch 'master' into fix/10200
zkochan 7075933
Apply suggestion from @Copilot
zkochan b82b39f
Apply suggestion from @Copilot
zkochan 10ee224
fix: compile
zkochan 5d4a025
Merge branch 'master' into fix/10200
zkochan 99ed48e
refactor: workspace manifest factory
zkochan fe0c1d7
refactor: pr
zkochan f61e377
fix: comment
zkochan 819675d
Merge branch 'master' into fix/10200
zkochan 65ba9ac
Merge branch 'master' into fix/10200
zkochan def7eb1
Merge remote-tracking branch 'upstream/master' into fix/10200
zkochan 08b002c
refactor: address copilot review comments
zkochan 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| import { IssuesClasses } from '@teambit/component-issues'; | ||
| import { Helper } from '@teambit/legacy.e2e-helper'; | ||
|
|
||
| /** | ||
| * Regression test for PR #10150. | ||
| * | ||
| * When `bit new` (or `bit fork`) creates a workspace with a forked env, the | ||
| * forking process copies the dep-resolver aspect config verbatim from the | ||
| * source version. If that config contains entries with the "+" sentinel | ||
| * (MANUALLY_ADD_DEPENDENCY — meaning "resolve version from the workspace | ||
| * package.json"), a chicken-and-egg problem arises on a fresh workspace: | ||
| * | ||
| * 1. _manuallyAddPackage() tries to resolve "+" from the workspace | ||
| * root package.json, but the package is not yet installed → null → | ||
| * pushed to missingPackageDependencies (not to packageDependencies). | ||
| * 2. The package is therefore absent from depManifestBeforeFiltering. | ||
| * 3. The usedPeerDependencies filter (introduced by PR #10150) checks | ||
| * depManifestBeforeFiltering and excludes the package. | ||
| * 4. pnpm never installs it. | ||
| * 5. Every subsequent `bit status` / `bit install` repeats the cycle. | ||
| * | ||
| * Before PR #10150, `defaultPeerDependencies` was spread unconditionally, | ||
| * which broke the cycle on the first install. | ||
| */ | ||
| describe('forked env with "+" dependency markers (PR #10150 regression)', function () { | ||
| this.timeout(0); | ||
| let helper: Helper; | ||
|
|
||
| before(() => { | ||
| helper = new Helper(); | ||
| }); | ||
|
|
||
| after(() => { | ||
| helper.scopeHelper.destroy(); | ||
| }); | ||
|
|
||
| describe('fork an env whose dep-resolver config has "+" entries for env peer packages', () => { | ||
| const envName = 'react-based-env'; | ||
|
|
||
| before(() => { | ||
| // ── Source workspace: create the env, tag, and export ────────────── | ||
| helper.scopeHelper.setWorkspaceWithRemoteScope(); | ||
|
|
||
| // Create a custom env with env.jsonc that declares is-positive as a | ||
| // peer dependency. For the env component *itself*, this peer entry | ||
| // becomes part of the selfPolicy (via getPoliciesFromEnvForItself), | ||
| // which feeds into _getDefaultPeerDependencies(). | ||
| const envPolicy = { | ||
| peers: [{ name: 'is-positive', version: '3.1.0', supportedRange: '^3.0.0' }], | ||
| }; | ||
| helper.env.setCustomNewEnv(undefined, undefined, { policy: envPolicy }, true); | ||
|
|
||
| // Make sure is-positive is present in the workspace so the "+" marker | ||
| // can be resolved during tagging in this (source) workspace. | ||
| helper.command.install('is-positive@3.1.0'); | ||
|
|
||
| // Simulate the original env having an explicit "+" dep-resolver entry | ||
| // for is-positive. This is the config that gets copied verbatim when | ||
| // the component is forked. | ||
| const bitmap = helper.bitMap.read(); | ||
| bitmap[envName] = bitmap[envName] || {}; | ||
| bitmap[envName].config = { | ||
| ...bitmap[envName].config, | ||
| 'teambit.dependencies/dependency-resolver': { | ||
| policy: { | ||
| dependencies: { | ||
| 'is-positive': '+', | ||
| }, | ||
| }, | ||
| }, | ||
| }; | ||
| helper.bitMap.write(bitmap); | ||
|
|
||
| helper.command.tagAllWithoutBuild(); | ||
| helper.command.export(); | ||
|
|
||
| // ── Fresh workspace: fork the env ───────────────────────────────── | ||
| helper.scopeHelper.reInitWorkspace({ | ||
| // Enable the MissingManuallyConfiguredPackages issue so the test | ||
| // can detect it (the default e2e helper suppresses it). | ||
| disableMissingManuallyConfiguredPackagesIssue: false, | ||
| }); | ||
| helper.scopeHelper.addRemoteScope(); | ||
|
|
||
| // Fork the env from the remote scope. The forking process copies the | ||
| // dep-resolver config (including the "+" entry for is-positive) from | ||
| // the tagged version into the new component's .bitmap. | ||
| helper.command.fork(`${helper.scopes.remote}/${envName} my-forked-env`); | ||
| }); | ||
|
|
||
| it('bit status should not have MissingManuallyConfiguredPackages issue for the forked env', () => { | ||
| helper.command.expectStatusToNotHaveIssue(IssuesClasses.MissingManuallyConfiguredPackages.name); | ||
| }); | ||
|
|
||
| it('bit status should not have any component issues', () => { | ||
| helper.command.expectStatusToNotHaveIssues(); | ||
| }); | ||
| }); | ||
| }); | ||
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
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.