-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@angular/cli): logic which determines which temp version of the C…
…LI is to be download during `ng update` Previously, when using an older version of the Angular CLI, during `ng update`, we download the temporary `latest` version to run the update. The ensured that when running that the runner used to run the update contains the latest bug fixes and improvements. This however, can be problematic in some cases. Such as when there are API breaking changes, when running a relatively old schematic with the latest CLI can cause runtime issues, especially since those schematics were never meant to be executed on a CLI X major versions in the future. With this change, we improve the logic to determine which version of the Angular CLI should be used to run the update. Below is a summarization of this. - When using the `--next` command line argument, the `@next` version of the CLI will be used to run the update. - When updating an `@angular/` or `@nguniversal/` package, the target version will be used to run the update. Example: `ng update @angular/core@12`, the update will run on most recent patch version of `@angular/cli` of that major version `@12.2.6`. - When updating an `@angular/` or `@nguniversal/` and no target version is specified. Example: `ng update @angular/core` the update will run on most latest version of the `@angular/cli`. - When updating a third-party package, the most recent patch version of the installed `@angular/cli` will be used to run the update. Example if `13.0.0` is installed and `13.1.1` is available on NPM, the latter will be used. (cherry picked from commit 1e9e890)
- Loading branch information
1 parent
6650765
commit 250a58b
Showing
4 changed files
with
91 additions
and
64 deletions.
There are no files selected for viewing
This file contains 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 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 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
14 changes: 10 additions & 4 deletions
14
tests/legacy-cli/e2e/tests/update/update-secure-registry.ts
This file contains 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,29 +1,35 @@ | ||
import { ng } from '../../utils/process'; | ||
import { createNpmConfigForAuthentication } from '../../utils/registry'; | ||
import { expectToFail } from '../../utils/utils'; | ||
import { isPrereleaseCli } from '../../utils/project'; | ||
|
||
export default async function () { | ||
// The environment variable has priority over the .npmrc | ||
delete process.env['NPM_CONFIG_REGISTRY']; | ||
const worksMessage = 'We analyzed your package.json'; | ||
|
||
const extraArgs = []; | ||
if (isPrereleaseCli()) { | ||
extraArgs.push('--next'); | ||
} | ||
|
||
// Valid authentication token | ||
await createNpmConfigForAuthentication(false); | ||
const { stdout: stdout1 } = await ng('update'); | ||
const { stdout: stdout1 } = await ng('update', ...extraArgs); | ||
if (!stdout1.includes(worksMessage)) { | ||
throw new Error(`Expected stdout to contain "${worksMessage}"`); | ||
} | ||
|
||
await createNpmConfigForAuthentication(true); | ||
const { stdout: stdout2 } = await ng('update'); | ||
const { stdout: stdout2 } = await ng('update', ...extraArgs); | ||
if (!stdout2.includes(worksMessage)) { | ||
throw new Error(`Expected stdout to contain "${worksMessage}"`); | ||
} | ||
|
||
// Invalid authentication token | ||
await createNpmConfigForAuthentication(false, true); | ||
await expectToFail(() => ng('update')); | ||
await expectToFail(() => ng('update', ...extraArgs)); | ||
|
||
await createNpmConfigForAuthentication(true, true); | ||
await expectToFail(() => ng('update')); | ||
await expectToFail(() => ng('update', ...extraArgs)); | ||
} |