Skip to content

Commit

Permalink
refactor: Rename CdnJsDatasource to CdnjsDatasource (#30866)
Browse files Browse the repository at this point in the history
  • Loading branch information
zharinov authored Aug 19, 2024
1 parent ff52da8 commit 56e5ea0
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions lib/modules/datasource/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AzurePipelinesTasksDatasource } from './azure-pipelines-tasks';
import { BazelDatasource } from './bazel';
import { BitbucketTagsDatasource } from './bitbucket-tags';
import { BitriseDatasource } from './bitrise';
import { CdnJsDatasource } from './cdnjs';
import { CdnjsDatasource } from './cdnjs';
import { ClojureDatasource } from './clojure';
import { ConanDatasource } from './conan';
import { CondaDatasource } from './conda';
Expand Down Expand Up @@ -75,7 +75,7 @@ api.set(AzurePipelinesTasksDatasource.id, new AzurePipelinesTasksDatasource());
api.set(BazelDatasource.id, new BazelDatasource());
api.set(BitbucketTagsDatasource.id, new BitbucketTagsDatasource());
api.set(BitriseDatasource.id, new BitriseDatasource());
api.set(CdnJsDatasource.id, new CdnJsDatasource());
api.set(CdnjsDatasource.id, new CdnjsDatasource());
api.set(ClojureDatasource.id, new ClojureDatasource());
api.set(ConanDatasource.id, new ConanDatasource());
api.set(CondaDatasource.id, new CondaDatasource());
Expand Down
30 changes: 15 additions & 15 deletions lib/modules/datasource/cdnjs/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Fixtures } from '../../../../test/fixtures';
import * as httpMock from '../../../../test/http-mock';
import { EXTERNAL_HOST_ERROR } from '../../../constants/error-messages';
import { HttpError } from '../../../util/http';
import { CdnJsDatasource } from '.';
import { CdnjsDatasource } from '.';

const baseUrl = 'https://api.cdnjs.com/';

Expand All @@ -19,7 +19,7 @@ describe('modules/datasource/cdnjs/index', () => {
httpMock.scope(baseUrl).get(pathFor('foo/bar')).reply(200, '}');
await expect(
getPkgReleases({
datasource: CdnJsDatasource.id,
datasource: CdnjsDatasource.id,
packageName: 'foo/bar',
}),
).rejects.toThrow(EXTERNAL_HOST_ERROR);
Expand All @@ -29,7 +29,7 @@ describe('modules/datasource/cdnjs/index', () => {
httpMock.scope(baseUrl).get(pathFor('foo/bar')).replyWithError('error');
await expect(
getPkgReleases({
datasource: CdnJsDatasource.id,
datasource: CdnjsDatasource.id,
packageName: 'foo/bar',
}),
).rejects.toThrow(EXTERNAL_HOST_ERROR);
Expand All @@ -39,7 +39,7 @@ describe('modules/datasource/cdnjs/index', () => {
httpMock.scope(baseUrl).get(pathFor('foo/bar')).reply(404);
expect(
await getPkgReleases({
datasource: CdnJsDatasource.id,
datasource: CdnjsDatasource.id,
packageName: 'foo/bar',
}),
).toBeNull();
Expand All @@ -52,7 +52,7 @@ describe('modules/datasource/cdnjs/index', () => {
.reply(200, {});
expect(
await getPkgReleases({
datasource: CdnJsDatasource.id,
datasource: CdnjsDatasource.id,
packageName: 'doesnotexist/doesnotexist',
}),
).toBeNull();
Expand All @@ -62,7 +62,7 @@ describe('modules/datasource/cdnjs/index', () => {
httpMock.scope(baseUrl).get(pathFor('foo/bar')).reply(401);
await expect(
getPkgReleases({
datasource: CdnJsDatasource.id,
datasource: CdnjsDatasource.id,
packageName: 'foo/bar',
}),
).rejects.toThrow(EXTERNAL_HOST_ERROR);
Expand All @@ -72,7 +72,7 @@ describe('modules/datasource/cdnjs/index', () => {
httpMock.scope(baseUrl).get(pathFor('foo/bar')).reply(429);
await expect(
getPkgReleases({
datasource: CdnJsDatasource.id,
datasource: CdnjsDatasource.id,
packageName: 'foo/bar',
}),
).rejects.toThrow(EXTERNAL_HOST_ERROR);
Expand All @@ -82,7 +82,7 @@ describe('modules/datasource/cdnjs/index', () => {
httpMock.scope(baseUrl).get(pathFor('foo/bar')).reply(502);
await expect(
getPkgReleases({
datasource: CdnJsDatasource.id,
datasource: CdnjsDatasource.id,
packageName: 'foo/bar',
}),
).rejects.toThrow(EXTERNAL_HOST_ERROR);
Expand All @@ -92,7 +92,7 @@ describe('modules/datasource/cdnjs/index', () => {
httpMock.scope(baseUrl).get(pathFor('foo/bar')).replyWithError('error');
await expect(
getPkgReleases({
datasource: CdnJsDatasource.id,
datasource: CdnjsDatasource.id,
packageName: 'foo/bar',
}),
).rejects.toThrow(EXTERNAL_HOST_ERROR);
Expand All @@ -104,7 +104,7 @@ describe('modules/datasource/cdnjs/index', () => {
.get(pathFor('d3-force/d3-force.js'))
.reply(200, Fixtures.get('d3-force.json'));
const res = await getPkgReleases({
datasource: CdnJsDatasource.id,
datasource: CdnjsDatasource.id,
packageName: 'd3-force/d3-force.js',
});
expect(res).toMatchSnapshot();
Expand All @@ -120,7 +120,7 @@ describe('modules/datasource/cdnjs/index', () => {

const res = await getDigest(
{
datasource: CdnJsDatasource.id,
datasource: CdnjsDatasource.id,
packageName: 'foo/bar',
},
'1.2.0',
Expand All @@ -136,7 +136,7 @@ describe('modules/datasource/cdnjs/index', () => {

const res = await getDigest(
{
datasource: CdnJsDatasource.id,
datasource: CdnjsDatasource.id,
packageName: 'foo/bar',
},
'1.2.0',
Expand All @@ -152,7 +152,7 @@ describe('modules/datasource/cdnjs/index', () => {

const res = await getDigest(
{
datasource: CdnJsDatasource.id,
datasource: CdnjsDatasource.id,
packageName: 'foo/bar',
},
'1.2.0',
Expand All @@ -165,7 +165,7 @@ describe('modules/datasource/cdnjs/index', () => {
await expect(
getDigest(
{
datasource: CdnJsDatasource.id,
datasource: CdnjsDatasource.id,
packageName: 'foo/bar',
},
'1.2.0',
Expand All @@ -181,7 +181,7 @@ describe('modules/datasource/cdnjs/index', () => {

const res = await getDigest(
{
datasource: CdnJsDatasource.id,
datasource: CdnjsDatasource.id,
packageName: 'bootstrap/js/bootstrap.min.js',
},
'5.2.3',
Expand Down
8 changes: 4 additions & 4 deletions lib/modules/datasource/cdnjs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import {
CdnjsAPIVersionResponseSchema,
} from './schema';

export class CdnJsDatasource extends Datasource {
export class CdnjsDatasource extends Datasource {
static readonly id = 'cdnjs';

constructor() {
super(CdnJsDatasource.id);
super(CdnjsDatasource.id);
}

override readonly customRegistrySupport = false;
Expand All @@ -33,7 +33,7 @@ export class CdnJsDatasource extends Datasource {
'The source URL is determined from the `repository` field in the results.';

@cache({
namespace: `datasource-${CdnJsDatasource.id}`,
namespace: `datasource-${CdnjsDatasource.id}`,
key: ({ packageName }: GetReleasesConfig) => packageName.split('/')[0],
})
async getReleases(config: GetReleasesConfig): Promise<ReleaseResult | null> {
Expand Down Expand Up @@ -76,7 +76,7 @@ export class CdnJsDatasource extends Datasource {
}

@cache({
namespace: `datasource-${CdnJsDatasource.id}-digest`,
namespace: `datasource-${CdnjsDatasource.id}-digest`,
key: ({ registryUrl, packageName }: DigestConfig, newValue: string) =>
`${registryUrl}:${packageName}:${newValue}}`,
})
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/manager/cdnurl/extract.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { regEx } from '../../../util/regex';
import { CdnJsDatasource } from '../../datasource/cdnjs';
import { CdnjsDatasource } from '../../datasource/cdnjs';
import type { PackageDependency, PackageFileContent } from '../types';

export const cloudflareUrlRegex = regEx(
Expand All @@ -20,7 +20,7 @@ export function extractPackageFile(content: string): PackageFileContent {
match = cloudflareUrlRegex.exec(rest);

deps.push({
datasource: CdnJsDatasource.id,
datasource: CdnjsDatasource.id,
depName,
packageName: `${depName}/${asset}`,
currentValue,
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/manager/cdnurl/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Category } from '../../../constants';
import { CdnJsDatasource } from '../../datasource/cdnjs';
import { CdnjsDatasource } from '../../datasource/cdnjs';
import * as semverVersioning from '../../versioning/semver';
import { extractPackageFile } from './extract';

Expand All @@ -12,4 +12,4 @@ export const defaultConfig = {

export const categories: Category[] = ['cd'];

export const supportedDatasources = [CdnJsDatasource.id];
export const supportedDatasources = [CdnjsDatasource.id];
4 changes: 2 additions & 2 deletions lib/modules/manager/html/extract.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { regEx } from '../../../util/regex';
import { CdnJsDatasource } from '../../datasource/cdnjs';
import { CdnjsDatasource } from '../../datasource/cdnjs';
import { cloudflareUrlRegex } from '../cdnurl/extract';
import type { PackageDependency, PackageFileContent } from '../types';

Expand All @@ -16,7 +16,7 @@ export function extractDep(tag: string): PackageDependency | null {
}
const { depName, currentValue, asset } = match.groups;
const dep: PackageDependency = {
datasource: CdnJsDatasource.id,
datasource: CdnjsDatasource.id,
depName,
packageName: `${depName}/${asset}`,
currentValue,
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/manager/html/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Category } from '../../../constants';
import { CdnJsDatasource } from '../../datasource/cdnjs';
import { CdnjsDatasource } from '../../datasource/cdnjs';
import * as semverVersioning from '../../versioning/semver';
import { extractPackageFile } from './extract';

Expand All @@ -16,4 +16,4 @@ export const defaultConfig = {

export const categories: Category[] = ['cd'];

export const supportedDatasources = [CdnJsDatasource.id];
export const supportedDatasources = [CdnjsDatasource.id];

0 comments on commit 56e5ea0

Please sign in to comment.