chore: reset cdnjs datasource exports and logs

This commit is contained in:
Rhys Arkins 2020-06-19 11:57:45 +02:00
parent cf06b69abb
commit 78a1443835

View file

@ -7,13 +7,13 @@ export const id = 'cdnjs';
const http = new Http(id); const http = new Http(id);
export interface CdnjsAsset { interface CdnjsAsset {
version: string; version: string;
files: string[]; files: string[];
sri?: Record<string, string>; sri?: Record<string, string>;
} }
export interface CdnjsResponse { interface CdnjsResponse {
homepage?: string; homepage?: string;
repository?: { repository?: {
type: 'git' | unknown; type: 'git' | unknown;
@ -30,6 +30,7 @@ async function downloadLibrary(library: string): CachePromise<CdnjsResponse> {
export async function getReleases({ export async function getReleases({
lookupName, lookupName,
}: GetReleasesConfig): Promise<ReleaseResult | null> { }: GetReleasesConfig): Promise<ReleaseResult | null> {
// Each library contains multiple assets, so we cache at the library level instead of per-asset
const library = lookupName.split('/')[0]; const library = lookupName.split('/')[0];
try { try {
const { assets, homepage, repository } = await cacheAble({ const { assets, homepage, repository } = await cacheAble({
@ -56,7 +57,7 @@ export async function getReleases({
return result; return result;
} catch (err) { } catch (err) {
if (err.statusCode === 404) { if (err.statusCode === 404) {
logger.debug({ library, err }, 'Package lookup error'); logger.debug({ library }, 'cdnjs library not found');
return null; return null;
} }
// Throw a DatasourceError for all other types of errors // Throw a DatasourceError for all other types of errors