feat(registry): modernize npm registry file handling and package extraction APIs

This commit is contained in:
2026-05-01 15:39:02 +00:00
parent 3bb68776fb
commit 0dedf79fa7
14 changed files with 3712 additions and 4592 deletions
+4 -3
View File
@@ -12,6 +12,7 @@ export interface ICacheDescriptor {
export class RegistryCache {
npmregistryRef: NpmRegistry;
public levelCache: plugins.levelcache.LevelCache;
public smartFileFactory = plugins.smartfile.SmartFileFactory.nodeFs();
constructor(npmRegistryRefArg: NpmRegistry) {
this.npmregistryRef = npmRegistryRefArg;
@@ -22,12 +23,12 @@ export class RegistryCache {
public async getCachedFile(
cacheDescriptorArg: ICacheDescriptor
): Promise<plugins.smartfile.SmartFile> {
): Promise<plugins.smartfile.SmartFile | null> {
const cacheEntry = await this.levelCache.retrieveCacheEntryByKey(
this.getCacheDescriptorAsString(cacheDescriptorArg)
);
if (cacheEntry) {
return plugins.smartfile.SmartFile.fromFoldedJson(cacheEntry.contents.toString());
return this.smartFileFactory.fromFoldedJson(cacheEntry.contents.toString());
}
return null;
}
@@ -55,7 +56,7 @@ export class RegistryCache {
}
}
public getCacheDescriptorAsString(cacheDescriptorArg?: ICacheDescriptor) {
public getCacheDescriptorAsString(cacheDescriptorArg: ICacheDescriptor) {
return `${cacheDescriptorArg.registryUrl}//+//${cacheDescriptorArg.packageName}//+//${
cacheDescriptorArg.filePath
}//+//${cacheDescriptorArg.distTag || cacheDescriptorArg.version}`;