From c8440ff5bdd3e1fe4b92d005e581b4634fa7ab8e Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Tue, 14 May 2024 14:41:43 +0800 Subject: [PATCH] fix: allow to disable sync unpkg files --- app/core/event/SyncPackageVersionFile.ts | 2 ++ app/port/config.ts | 4 ++++ config/config.default.ts | 1 + 3 files changed, 7 insertions(+) diff --git a/app/core/event/SyncPackageVersionFile.ts b/app/core/event/SyncPackageVersionFile.ts index 6cf38c61..5dc7d20d 100644 --- a/app/core/event/SyncPackageVersionFile.ts +++ b/app/core/event/SyncPackageVersionFile.ts @@ -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); diff --git a/app/port/config.ts b/app/port/config.ts index 8a763afe..867f2424 100644 --- a/app/port/config.ts +++ b/app/port/config.ts @@ -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. diff --git a/config/config.default.ts b/config/config.default.ts index cc6729a0..1c090583 100644 --- a/config/config.default.ts +++ b/config/config.default.ts @@ -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',