Skip to content

Commit 4aba526

Browse files
committed
refactor(@angular/cli): correct package manager cache key and add barrel file
The in-memory cache for the package manager abstraction did not properly include the registry URL in its cache key. This could lead to cache collisions if the same package was requested from two different registries. This commit corrects the cache key to be a composite of the package specifier and the registry URL. Additionally, a new `index.ts` barrel file has been added to create a single, clear public entry point for the package manager feature, improving code organization.
1 parent d6a986f commit 4aba526

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.dev/license
7+
*/
8+
9+
export { createPackageManager } from './factory';
10+
export type { PackageManagerName } from './package-manager-descriptor';
11+
export { PackageManager } from './package-manager';
12+
export type * from './package-metadata';
13+
export type { InstalledPackage } from './package-tree';

packages/angular/cli/src/package-managers/package-manager.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const METADATA_FIELDS = ['name', 'dist-tags', 'versions', 'time'] as const;
3535
const MANIFEST_FIELDS = [
3636
'name',
3737
'version',
38+
'deprecated',
3839
'dependencies',
3940
'peerDependencies',
4041
'devDependencies',
@@ -337,7 +338,7 @@ export class PackageManager {
337338
return this.#fetchAndParse(
338339
commandArgs,
339340
(stdout, logger) => this.descriptor.outputParsers.getRegistryMetadata(stdout, logger),
340-
{ ...options, cache: this.#metadataCache, cacheKey: packageName },
341+
{ ...options, cache: this.#metadataCache, cacheKey },
341342
);
342343
}
343344

@@ -369,7 +370,7 @@ export class PackageManager {
369370
return this.#fetchAndParse(
370371
commandArgs,
371372
(stdout, logger) => this.descriptor.outputParsers.getPackageManifest(stdout, logger),
372-
{ ...options, cache: this.#manifestCache, cacheKey: specifier },
373+
{ ...options, cache: this.#manifestCache, cacheKey },
373374
);
374375
}
375376

packages/angular/cli/src/package-managers/package-metadata.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ export interface PackageManifest {
8080
/** The version of the package. */
8181
version: string;
8282

83+
/** A message indicating that the package version is deprecated. */
84+
deprecated?: string;
85+
8386
/** A mapping of production dependencies. */
8487
dependencies?: Record<string, string>;
8588

0 commit comments

Comments
 (0)