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

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/core/service/PackageVersionFileService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export class PackageVersionFileService extends AbstractService {
version: string;
}
> = {};
// allow large package scopes, e.g. ['@foo', '@bar']
#unpkgWhiteListAllowLargeScopes: string[] = [];

async listPackageVersionFiles(pkgVersion: PackageVersion, directory: string) {
await this.#ensurePackageVersionFilesSync(pkgVersion);
Expand Down Expand Up @@ -116,6 +118,7 @@ export class PackageVersionFileService extends AbstractService {
this.#unpkgWhiteListAllowPackages = manifest.allowPackages ?? ({} as any);
this.#unpkgWhiteListAllowScopes = manifest.allowScopes ?? ([] as any);
this.#unpkgWhiteListAllowLargePackages = manifest.allowLargePackages ?? ({} as any);
this.#unpkgWhiteListAllowLargeScopes = manifest.allowLargeScopes ?? ([] as any);
this.logger.info(
'[PackageVersionFileService.updateUnpkgWhiteList] version:%s, total %s packages, %s scopes, %s large packages',
whiteListPackageVersion,
Expand All @@ -129,6 +132,9 @@ export class PackageVersionFileService extends AbstractService {
if (!this.config.cnpmcore.enableSyncUnpkgFilesWhiteList) return false;
await this.#updateUnpkgWhiteList();

// check allow large scopes
if (this.#unpkgWhiteListAllowLargeScopes.includes(pkgScope)) return true;
Comment on lines +135 to +136
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new allowLargeScopes feature lacks test coverage. While the isAllowLargePackageVersion method is mocked in some tests, there are no tests that verify the scope-level large package allowance functionality works correctly.

Tests should verify:

  1. Packages from scopes in allowLargeScopes are allowed regardless of size
  2. The scope check happens before the individual package check
  3. The allowLargeScopes field is correctly loaded from the manifest

Looking at the existing test patterns in test/port/controller/PackageVersionFileController/listFiles.test.ts, similar tests should be added for the allowLargeScopes functionality.

Copilot uses AI. Check for mistakes.

const fullname = getFullname(pkgScope, pkgName);
const pkgConfig = this.#unpkgWhiteListAllowLargePackages[fullname];
if (!pkgConfig?.version) return false;
Expand Down
Loading