-
Notifications
You must be signed in to change notification settings - Fork 11.9k
ci: add bun package manager to e2e tests #31856
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 all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,19 @@ | ||
| import { cp } from 'node:fs/promises'; | ||
| import { resolve } from 'node:path'; | ||
| import { assetDir } from '../../../utils/assets'; | ||
| import { expectFileToExist } from '../../../utils/fs'; | ||
| import { ng } from '../../../utils/process'; | ||
|
|
||
| export default async function () { | ||
| await ng('add', assetDir('add-collection'), '--name=blah', '--skip-confirmation'); | ||
| const collectionName = 'add-collection-dir'; | ||
| const dirCollectionPath = resolve(collectionName); | ||
|
|
||
| // Copy locally as bun doesn't install the dependency correctly if it has symlinks. | ||
| await cp(assetDir(collectionName), dirCollectionPath, { | ||
| recursive: true, | ||
| dereference: true, | ||
| }); | ||
|
|
||
| await ng('add', dirCollectionPath, '--name=blah', '--skip-confirmation'); | ||
| await expectFileToExist('blah'); | ||
| } | ||
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 |
|---|---|---|
| @@ -1,24 +1,44 @@ | ||
| import assert from 'node:assert/strict'; | ||
| import { resolve } from 'node:path'; | ||
| import { cp } from 'node:fs/promises'; | ||
| import { assetDir } from '../../../utils/assets'; | ||
| import { ng } from '../../../utils/process'; | ||
|
|
||
| const warning = 'Adding the package may not succeed.'; | ||
| export default async function (): Promise<void> { | ||
| const warning = /Adding the package may not succeed/; | ||
|
|
||
| export default async function () { | ||
| const { stdout: bad } = await ng( | ||
| 'add', | ||
| assetDir('add-collection-peer-bad'), | ||
| '--skip-confirmation', | ||
| const stdout1 = await runNgAdd('add-collection-peer-bad'); | ||
| assert.match( | ||
| stdout1, | ||
| warning, | ||
| `Peer warning should be shown for add-collection-peer-bad but was not.`, | ||
| ); | ||
| assert.match(bad, new RegExp(warning), 'peer warning not shown on bad package'); | ||
|
|
||
| const { stdout: base } = await ng('add', assetDir('add-collection'), '--skip-confirmation'); | ||
| assert.doesNotMatch(base, new RegExp(warning), 'peer warning shown on base package'); | ||
| const stdout2 = await runNgAdd('add-collection-dir'); | ||
| assert.doesNotMatch( | ||
| stdout2, | ||
| warning, | ||
| `Peer warning should NOT be shown for add-collection-dir but was.`, | ||
| ); | ||
|
|
||
| const { stdout: good } = await ng( | ||
| 'add', | ||
| assetDir('add-collection-peer-good'), | ||
| '--skip-confirmation', | ||
| const stdout3 = await runNgAdd('add-collection-peer-good'); | ||
| assert.doesNotMatch( | ||
| stdout3, | ||
| warning, | ||
| `Peer warning should NOT be shown for add-collection-peer-good but was.`, | ||
| ); | ||
| assert.doesNotMatch(good, new RegExp(warning), 'peer warning shown on good package'); | ||
| } | ||
|
|
||
| async function runNgAdd(collectionName: string): Promise<string> { | ||
| const collectionPath = resolve(collectionName); | ||
|
|
||
| // Copy locally as bun doesn't install the dependency correctly if it has symlinks. | ||
| await cp(assetDir(collectionName), collectionPath, { | ||
| recursive: true, | ||
| dereference: true, | ||
| }); | ||
|
|
||
| const { stdout } = await ng('add', collectionPath, '--skip-confirmation'); | ||
|
|
||
| return stdout; | ||
| } |
59 changes: 33 additions & 26 deletions
59
tests/legacy-cli/e2e/tests/commands/add/secure-registry.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 |
|---|---|---|
| @@ -1,42 +1,49 @@ | ||
| import { expectFileNotToExist, expectFileToExist } from '../../../utils/fs'; | ||
| import { expectFileNotToExist, expectFileToExist, rimraf } from '../../../utils/fs'; | ||
| import { getActivePackageManager, installWorkspacePackages } from '../../../utils/packages'; | ||
| import { git, ng } from '../../../utils/process'; | ||
| import { createNpmConfigForAuthentication } from '../../../utils/registry'; | ||
| import { expectToFail } from '../../../utils/utils'; | ||
|
|
||
| export default async function () { | ||
| // The environment variable has priority over the .npmrc | ||
| delete process.env['NPM_CONFIG_REGISTRY']; | ||
| const isNpm = getActivePackageManager() === 'npm'; | ||
| const originalNpmConfigRegistry = process.env['NPM_CONFIG_REGISTRY']; | ||
| try { | ||
| // The environment variable has priority over the .npmrc | ||
| delete process.env['NPM_CONFIG_REGISTRY']; | ||
| const packageManager = getActivePackageManager(); | ||
| const supportsUnscopedAuth = packageManager !== 'bun' && packageManager !== 'npm'; | ||
| const command = ['add', '@angular/pwa', '--skip-confirmation']; | ||
|
|
||
| const command = ['add', '@angular/pwa', '--skip-confirmation']; | ||
| await expectFileNotToExist('public/manifest.webmanifest'); | ||
| await expectFileNotToExist('public/manifest.webmanifest'); | ||
|
|
||
| // Works with unscoped registry authentication details | ||
| if (!isNpm) { | ||
| // NPM no longer support unscoped. | ||
| await createNpmConfigForAuthentication(false); | ||
| // Works with unscoped registry authentication details | ||
| if (supportsUnscopedAuth) { | ||
| // Some package managers such as Bun and NPM do not support unscoped auth. | ||
| await createNpmConfigForAuthentication(false); | ||
| await ng(...command); | ||
| await expectFileToExist('public/manifest.webmanifest'); | ||
| await git('clean', '-dxf'); | ||
| } | ||
|
|
||
| // Works with scoped registry authentication details | ||
| await expectFileNotToExist('public/manifest.webmanifest'); | ||
|
|
||
| await createNpmConfigForAuthentication(true); | ||
| await ng(...command); | ||
| await expectFileToExist('public/manifest.webmanifest'); | ||
| await git('clean', '-dxf'); | ||
| } | ||
| // Works with scoped registry authentication details | ||
| await expectFileNotToExist('public/manifest.webmanifest'); | ||
|
|
||
| await createNpmConfigForAuthentication(true); | ||
| await ng(...command); | ||
| await expectFileToExist('public/manifest.webmanifest'); | ||
| // Invalid authentication token | ||
| if (!supportsUnscopedAuth) { | ||
| // Some package managers such as Bun and NPM do not support unscoped auth. | ||
| await createNpmConfigForAuthentication(false, true); | ||
| await expectToFail(() => ng(...command)); | ||
| } | ||
|
|
||
| // Invalid authentication token | ||
| if (isNpm) { | ||
| // NPM no longer support unscoped. | ||
| await createNpmConfigForAuthentication(false, true); | ||
| await createNpmConfigForAuthentication(true, true); | ||
| await expectToFail(() => ng(...command)); | ||
| } finally { | ||
| process.env['NPM_CONFIG_REGISTRY'] = originalNpmConfigRegistry; | ||
| await git('clean', '-dxf'); | ||
| await installWorkspacePackages(); | ||
| } | ||
|
|
||
| await createNpmConfigForAuthentication(true, true); | ||
| await expectToFail(() => ng(...command)); | ||
|
|
||
| await git('clean', '-dxf'); | ||
| await installWorkspacePackages(); | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we report this to
bunas well?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I’ll open an issue tomorrow