Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 40123f1

Browse files
author
Angular Builds
committed
2037b91 fix(@angular/cli): improve bun lockfile detection and optimize lockfile checks
1 parent a37d58a commit 40123f1

File tree

5 files changed

+58
-37
lines changed

5 files changed

+58
-37
lines changed

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular/cli",
3-
"version": "21.0.0-next.2+sha-1529595",
3+
"version": "21.0.0-next.2+sha-2037b91",
44
"description": "CLI tool for Angular",
55
"main": "lib/cli/index.js",
66
"bin": {
@@ -25,13 +25,13 @@
2525
},
2626
"homepage": "https://github.com/angular/angular-cli",
2727
"dependencies": {
28-
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#1529595",
29-
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#1529595",
30-
"@angular-devkit/schematics": "github:angular/angular-devkit-schematics-builds#1529595",
28+
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#2037b91",
29+
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#2037b91",
30+
"@angular-devkit/schematics": "github:angular/angular-devkit-schematics-builds#2037b91",
3131
"@inquirer/prompts": "7.8.4",
3232
"@listr2/prompt-adapter-inquirer": "3.0.3",
3333
"@modelcontextprotocol/sdk": "1.17.5",
34-
"@schematics/angular": "github:angular/schematics-angular-builds#1529595",
34+
"@schematics/angular": "github:angular/schematics-angular-builds#2037b91",
3535
"@yarnpkg/lockfile": "1.1.0",
3636
"algoliasearch": "5.37.0",
3737
"ini": "5.0.0",
@@ -47,14 +47,14 @@
4747
"ng-update": {
4848
"migrations": "@schematics/angular/migrations/migration-collection.json",
4949
"packageGroup": {
50-
"@angular/cli": "github:angular/cli-builds#1529595",
51-
"@angular/build": "github:angular/angular-build-builds#1529595",
52-
"@angular/ssr": "github:angular/angular-ssr-builds#1529595",
53-
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#1529595",
54-
"@angular-devkit/build-angular": "github:angular/angular-devkit-build-angular-builds#1529595",
55-
"@angular-devkit/build-webpack": "github:angular/angular-devkit-build-webpack-builds#1529595",
56-
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#1529595",
57-
"@angular-devkit/schematics": "github:angular/angular-devkit-schematics-builds#1529595"
50+
"@angular/cli": "github:angular/cli-builds#2037b91",
51+
"@angular/build": "github:angular/angular-build-builds#2037b91",
52+
"@angular/ssr": "github:angular/angular-ssr-builds#2037b91",
53+
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#2037b91",
54+
"@angular-devkit/build-angular": "github:angular/angular-devkit-build-angular-builds#2037b91",
55+
"@angular-devkit/build-webpack": "github:angular/angular-devkit-build-webpack-builds#2037b91",
56+
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#2037b91",
57+
"@angular-devkit/schematics": "github:angular/angular-devkit-schematics-builds#2037b91"
5858
}
5959
},
6060
"packageManager": "[email protected]",

src/utilities/package-manager.d.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@ export interface PackageManagerUtilsContext {
1212
workspace?: AngularWorkspace;
1313
root: string;
1414
}
15+
/**
16+
* Utilities for interacting with various package managers.
17+
*/
1518
export declare class PackageManagerUtils {
1619
private readonly context;
20+
/**
21+
* @param context The context for the package manager utilities, including workspace and global configuration.
22+
*/
1723
constructor(context: PackageManagerUtilsContext);
1824
/** Get the package manager name. */
1925
get name(): PackageManager;
@@ -32,6 +38,12 @@ export declare class PackageManagerUtils {
3238
private run;
3339
private getVersion;
3440
private getName;
41+
/**
42+
* Checks if a lockfile for a specific package manager exists in the root directory.
43+
* @param packageManager The package manager to check for.
44+
* @param filesInRoot An array of file names in the root directory.
45+
* @returns True if the lockfile exists, false otherwise.
46+
*/
3547
private hasLockfile;
3648
private getConfiguredPackageManager;
3749
}

src/utilities/package-manager.js

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ const node_path_1 = require("node:path");
5050
const workspace_schema_1 = require("../../lib/config/workspace-schema");
5151
const config_1 = require("./config");
5252
const memoize_1 = require("./memoize");
53+
/**
54+
* A map of package managers to their corresponding lockfile names.
55+
*/
56+
const LOCKFILE_NAMES = {
57+
[workspace_schema_1.PackageManager.Yarn]: 'yarn.lock',
58+
[workspace_schema_1.PackageManager.Pnpm]: 'pnpm-lock.yaml',
59+
[workspace_schema_1.PackageManager.Bun]: ['bun.lockb', 'bun.lock'],
60+
[workspace_schema_1.PackageManager.Npm]: 'package-lock.json',
61+
};
62+
/**
63+
* Utilities for interacting with various package managers.
64+
*/
5365
let PackageManagerUtils = (() => {
5466
let _instanceExtraInitializers = [];
5567
let _getVersion_decorators;
@@ -64,6 +76,9 @@ let PackageManagerUtils = (() => {
6476
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
6577
}
6678
context = __runInitializers(this, _instanceExtraInitializers);
79+
/**
80+
* @param context The context for the package manager utilities, including workspace and global configuration.
81+
*/
6782
constructor(context) {
6883
this.context = context;
6984
}
@@ -211,10 +226,11 @@ let PackageManagerUtils = (() => {
211226
if (packageManager) {
212227
return packageManager;
213228
}
214-
const hasNpmLock = this.hasLockfile(workspace_schema_1.PackageManager.Npm);
215-
const hasYarnLock = this.hasLockfile(workspace_schema_1.PackageManager.Yarn);
216-
const hasPnpmLock = this.hasLockfile(workspace_schema_1.PackageManager.Pnpm);
217-
const hasBunLock = this.hasLockfile(workspace_schema_1.PackageManager.Bun);
229+
const filesInRoot = (0, node_fs_1.readdirSync)(this.context.root);
230+
const hasNpmLock = this.hasLockfile(workspace_schema_1.PackageManager.Npm, filesInRoot);
231+
const hasYarnLock = this.hasLockfile(workspace_schema_1.PackageManager.Yarn, filesInRoot);
232+
const hasPnpmLock = this.hasLockfile(workspace_schema_1.PackageManager.Pnpm, filesInRoot);
233+
const hasBunLock = this.hasLockfile(workspace_schema_1.PackageManager.Bun, filesInRoot);
218234
// PERF NOTE: `this.getVersion` spawns the package a the child_process which can take around ~300ms at times.
219235
// Therefore, we should only call this method when needed. IE: don't call `this.getVersion(PackageManager.Pnpm)` unless truly needed.
220236
// The result of this method is not stored in a variable because it's memoized.
@@ -259,24 +275,17 @@ let PackageManagerUtils = (() => {
259275
// Potentially with a prompt to choose and optionally set as the default.
260276
return workspace_schema_1.PackageManager.Npm;
261277
}
262-
hasLockfile(packageManager) {
263-
let lockfileName;
264-
switch (packageManager) {
265-
case workspace_schema_1.PackageManager.Yarn:
266-
lockfileName = 'yarn.lock';
267-
break;
268-
case workspace_schema_1.PackageManager.Pnpm:
269-
lockfileName = 'pnpm-lock.yaml';
270-
break;
271-
case workspace_schema_1.PackageManager.Bun:
272-
lockfileName = 'bun.lockb';
273-
break;
274-
case workspace_schema_1.PackageManager.Npm:
275-
default:
276-
lockfileName = 'package-lock.json';
277-
break;
278-
}
279-
return (0, node_fs_1.existsSync)((0, node_path_1.join)(this.context.root, lockfileName));
278+
/**
279+
* Checks if a lockfile for a specific package manager exists in the root directory.
280+
* @param packageManager The package manager to check for.
281+
* @param filesInRoot An array of file names in the root directory.
282+
* @returns True if the lockfile exists, false otherwise.
283+
*/
284+
hasLockfile(packageManager, filesInRoot) {
285+
const lockfiles = LOCKFILE_NAMES[packageManager];
286+
return typeof lockfiles === 'string'
287+
? filesInRoot.includes(lockfiles)
288+
: lockfiles.some((lockfile) => filesInRoot.includes(lockfile));
280289
}
281290
getConfiguredPackageManager() {
282291
const getPackageManager = (source) => {

src/utilities/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ class Version {
2222
this.patch = patch;
2323
}
2424
}
25-
exports.VERSION = new Version('21.0.0-next.2+sha-1529595');
25+
exports.VERSION = new Version('21.0.0-next.2+sha-2037b91');

uniqueId

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Mon Sep 08 2025 10:47:47 GMT+0000 (Coordinated Universal Time)
1+
Mon Sep 08 2025 15:17:46 GMT+0000 (Coordinated Universal Time)

0 commit comments

Comments
 (0)