Skip to content

Commit

Permalink
feat(datasource)!: default to the central default versioning (#23020)
Browse files Browse the repository at this point in the history
  • Loading branch information
secustor authored and rarkins committed Jul 4, 2023
1 parent e808598 commit db728be
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions lib/modules/datasource/flutter-version/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { regEx } from '../../../util/regex';
import { id as semverId } from '../../versioning/semver';
import { Datasource } from '../datasource';
import type { GetReleasesConfig, ReleaseResult } from '../types';
import type { FlutterResponse } from './types';
Expand All @@ -18,6 +19,8 @@ export class FlutterVersionDatasource extends Datasource {

override readonly caching = true;

override readonly defaultVersioning = semverId;

async getReleases({
registryUrl,
}: GetReleasesConfig): Promise<ReleaseResult | null> {
Expand Down
3 changes: 3 additions & 0 deletions lib/modules/datasource/hexpm-bob/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { logger } from '../../../logger';
import { ExternalHostError } from '../../../types/errors/external-host-error';
import { cache } from '../../../util/cache/package/decorator';
import { HttpError } from '../../../util/http';
import { id as semverId } from '../../versioning/semver';
import { Datasource } from '../datasource';
import type { GetReleasesConfig, ReleaseResult } from '../types';
import { datasource, defaultRegistryUrl } from './common';
Expand All @@ -21,6 +22,8 @@ export class HexpmBobDatasource extends Datasource {

override readonly caching = true;

override readonly defaultVersioning = semverId;

@cache({
namespace: `datasource-${datasource}`,
key: ({ registryUrl, packageName }: GetReleasesConfig) =>
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/datasource/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe('modules/datasource/index', () => {

describe('getDefaultVersioning()', () => {
it('returns semver if undefined', () => {
expect(getDefaultVersioning(undefined)).toBe('semver');
expect(getDefaultVersioning(undefined)).toBe('semver-coerced');
});
});

Expand Down
5 changes: 3 additions & 2 deletions lib/modules/datasource/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { regEx } from '../../util/regex';
import { Result } from '../../util/result';
import { uniq } from '../../util/uniq';
import { trimTrailingSlash } from '../../util/url';
import { defaultVersioning } from '../versioning';
import * as allVersioning from '../versioning';
import datasources from './api';
import { addMetaData } from './metadata';
Expand Down Expand Up @@ -241,14 +242,14 @@ export function getDefaultVersioning(
datasourceName: string | undefined
): string {
if (!datasourceName) {
return 'semver';
return defaultVersioning.id;
}
const datasource = getDatasourceFor(datasourceName);
// istanbul ignore if: wrong regex manager config?
if (!datasource) {
logger.warn({ datasourceName }, 'Missing datasource!');
}
return datasource?.defaultVersioning ?? 'semver';
return datasource?.defaultVersioning ?? defaultVersioning.id;
}

function applyReplacements(
Expand Down
3 changes: 3 additions & 0 deletions lib/modules/versioning/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import versionings from './api';
import { Versioning } from './schema';
import * as semverCoerced from './semver-coerced';
import type { VersioningApi, VersioningApiConstructor } from './types';

export * from './types';

export const defaultVersioning = semverCoerced;

export const getVersioningList = (): string[] => Array.from(versionings.keys());
/**
* Get versioning map. Can be used to dynamically add new versioning type
Expand Down

0 comments on commit db728be

Please sign in to comment.