Skip to content
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

fix: allow to disable sync unpkg files #679

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions app/core/event/SyncPackageVersionFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class SyncPackageVersionFileEvent {
private readonly packageVersionFileService: PackageVersionFileService;

protected async syncPackageVersionFile(fullname: string, version: string) {
// must set enableUnpkg and enableSyncUnpkgFiles = true both
if (!this.config.cnpmcore.enableUnpkg) return;
if (!this.config.cnpmcore.enableSyncUnpkgFiles) return;
// ignore sync on unittest
if (this.config.env === 'unittest' && fullname !== '@cnpm/unittest-unpkg-demo') return;
const [ scope, name ] = getScopeAndName(fullname);
Expand Down
4 changes: 4 additions & 0 deletions app/port/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ export type CnpmcoreConfig = {
* enable unpkg features, https://github.com/cnpm/cnpmcore/issues/452
*/
enableUnpkg: boolean,
/**
* enable sync unpkg files
*/
enableSyncUnpkgFiles: boolean;
/**
* enable this would make sync specific version task not append latest version into this task automatically,it would mark the local latest stable version as latest tag.
* in most cases, you should set to false to keep the same behavior as source registry.
Expand Down
1 change: 1 addition & 0 deletions config/config.default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const cnpmcoreConfig: CnpmcoreConfig = {
syncNotFound: false,
redirectNotFound: true,
enableUnpkg: true,
enableSyncUnpkgFiles: true,
strictSyncSpecivicVersion: false,
enableElasticsearch: !!process.env.CNPMCORE_CONFIG_ENABLE_ES,
elasticsearchIndex: 'cnpmcore_packages',
Expand Down
Loading