Skip to content

Commit

Permalink
feat(datasource): rename node -> node-version (#21149)
Browse files Browse the repository at this point in the history
  • Loading branch information
RahulGautamSingh committed Apr 12, 2023
1 parent f7d7316 commit efc366e
Show file tree
Hide file tree
Showing 18 changed files with 102 additions and 47 deletions.
11 changes: 11 additions & 0 deletions lib/config/migrations/custom/datasource-migration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,15 @@ describe('config/migrations/custom/datasource-migration', () => {
}
);
});

it('should migrate node', () => {
expect(DatasourceMigration).toMigrate(
{
datasource: 'node',
},
{
datasource: 'node-version',
}
);
});
});
2 changes: 2 additions & 0 deletions lib/config/migrations/custom/datasource-migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export function migrateDatasource(value: string): string {
return 'java-version';
case 'dotnet':
return 'dotnet-version';
case 'node':
return 'node-version';
}
return value;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ describe('config/migrations/custom/match-datasources-migration', () => {
it('should migrate properly', () => {
expect(MatchDatasourcesMigration).toMigrate(
{
matchDatasources: ['adoptium-java', 'dotnet', 'npm'],
matchDatasources: ['adoptium-java', 'dotnet', 'npm', 'node'],
},
{
matchDatasources: ['java-version', 'dotnet-version', 'npm'],
matchDatasources: [
'java-version',
'dotnet-version',
'npm',
'node-version',
],
}
);
});
Expand Down
2 changes: 2 additions & 0 deletions lib/config/migrations/custom/match-datasources-migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export class MatchDatasourcesMigration extends AbstractMigration {
return 'java-version';
case 'dotnet':
return 'dotnet-version';
case 'node':
return 'node-version';
default:
return datasource;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/config/presets/internal/regex-managers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ describe('config/presets/internal/regex-managers', () => {
expect(res?.deps).toMatchObject([
{
currentValue: '18.13.0',
datasource: 'node',
datasource: 'node-version',
depName: 'node',
replaceString:
'# renovate: datasource=node depName=node versioning=node\n NODE_VERSION: 18.13.0\n',
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/datasource/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { JavaVersionDatasource } from './java-version';
import { JenkinsPluginsDatasource } from './jenkins-plugins';
import { KubernetesApiDatasource } from './kubernetes-api';
import { MavenDatasource } from './maven';
import { NodeDatasource } from './node';
import { NodeVersionDatasource } from './node-version';
import { NpmDatasource } from './npm';
import { NugetDatasource } from './nuget';
import { OrbDatasource } from './orb';
Expand Down Expand Up @@ -99,7 +99,7 @@ api.set(JavaVersionDatasource.id, new JavaVersionDatasource());
api.set(JenkinsPluginsDatasource.id, new JenkinsPluginsDatasource());
api.set(KubernetesApiDatasource.id, new KubernetesApiDatasource());
api.set(MavenDatasource.id, new MavenDatasource());
api.set(NodeDatasource.id, new NodeDatasource());
api.set(NodeVersionDatasource.id, new NodeVersionDatasource());
api.set(NpmDatasource.id, new NpmDatasource());
api.set(NugetDatasource.id, new NugetDatasource());
api.set(OrbDatasource.id, new OrbDatasource());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`modules/datasource/node/index getReleases processes real data 1`] = `
exports[`modules/datasource/node-version/index getReleases processes real data 1`] = `
{
"homepage": "https://nodejs.org",
"registryUrl": "https://nodejs.org/dist",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const defaultRegistryUrl = 'https://nodejs.org/dist';

export const datasource = 'node';
export const datasource = 'node-version';
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as httpMock from '../../../../test/http-mock';
import { EXTERNAL_HOST_ERROR } from '../../../constants/error-messages';
import { datasource, defaultRegistryUrl } from './common';

describe('modules/datasource/node/index', () => {
describe('modules/datasource/node-version/index', () => {
describe('getReleases', () => {
it('throws for 500', async () => {
httpMock.scope(defaultRegistryUrl).get('/index.json').reply(500);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { GetReleasesConfig, ReleaseResult } from '../types';
import { datasource, defaultRegistryUrl } from './common';
import type { NodeRelease } from './types';

export class NodeDatasource extends Datasource {
export class NodeVersionDatasource extends Datasource {
static readonly id = datasource;

constructor() {
Expand Down
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions lib/modules/manager/asdf/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('modules/manager/asdf/extract', () => {
deps: [
{
currentValue: '16.16.0',
datasource: 'node',
datasource: 'node-version',
depName: 'node',
},
],
Expand All @@ -34,7 +34,7 @@ describe('modules/manager/asdf/extract', () => {
deps: [
{
currentValue: '16.16.0',
datasource: 'node',
datasource: 'node-version',
depName: 'node',
},
],
Expand Down Expand Up @@ -287,7 +287,7 @@ dummy 1.2.3
},
{
currentValue: '18.12.0',
datasource: 'node',
datasource: 'node-version',
depName: 'node',
},
{
Expand Down Expand Up @@ -489,7 +489,7 @@ dummy 1.2.3
deps: [
{
currentValue: data.expect,
datasource: 'node',
datasource: 'node-version',
depName: 'node',
},
],
Expand Down Expand Up @@ -518,7 +518,7 @@ dummy 1.2.3
deps: [
{
currentValue: '16.16.0',
datasource: 'node',
datasource: 'node-version',
depName: 'node',
},
],
Expand All @@ -531,7 +531,7 @@ dummy 1.2.3
deps: [
{
currentValue: '16.16.0',
datasource: 'node',
datasource: 'node-version',
depName: 'node',
skipReason: 'ignored',
},
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/manager/asdf/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { GithubReleasesDatasource } from '../../datasource/github-releases';
import { GithubTagsDatasource } from '../../datasource/github-tags';
import { HexpmBobDatasource } from '../../datasource/hexpm-bob';
import { JavaVersionDatasource } from '../../datasource/java-version';
import { NodeDatasource } from '../../datasource/node';
import { NodeVersionDatasource } from '../../datasource/node-version';
import { NpmDatasource } from '../../datasource/npm';
import { RubyVersionDatasource } from '../../datasource/ruby-version';

Expand All @@ -23,7 +23,7 @@ export const supportedDatasources = [
GithubReleasesDatasource.id,
GithubTagsDatasource.id,
HexpmBobDatasource.id,
NodeDatasource.id,
NodeVersionDatasource.id,
NpmDatasource.id,
RubyVersionDatasource.id,
DartVersionDatasource.id,
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/manager/asdf/upgradeable-tooling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { GithubReleasesDatasource } from '../../datasource/github-releases';
import { GithubTagsDatasource } from '../../datasource/github-tags';
import { HexpmBobDatasource } from '../../datasource/hexpm-bob';
import { JavaVersionDatasource } from '../../datasource/java-version';
import { NodeDatasource } from '../../datasource/node';
import { NodeVersionDatasource } from '../../datasource/node-version';
import { NpmDatasource } from '../../datasource/npm';
import { RubyVersionDatasource } from '../../datasource/ruby-version';
import * as regexVersioning from '../../versioning/regex';
Expand Down Expand Up @@ -266,7 +266,7 @@ export const upgradeableTooling: Record<string, ToolingDefinition> = {
asdfPluginUrl: 'https://github.com/asdf-vm/asdf-nodejs',
config: {
depName: 'node',
datasource: NodeDatasource.id,
datasource: NodeVersionDatasource.id,
},
},
ocaml: {
Expand Down
89 changes: 62 additions & 27 deletions lib/modules/manager/regex/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,33 +559,68 @@ describe('modules/manager/regex/index', () => {
});
});

it('migrates', async () => {
const config: CustomExtractConfig = {
matchStrings: [
'# renovate: datasource=(?<datasource>[a-z-]+?)(?: (?:packageName|lookupName)=(?<packageName>.+?))?(?: versioning=(?<versioning>[a-z-]+?))?\\sRUN install-[a-z]+? (?<depName>[a-z-]+?) (?<currentValue>.+?)(?:\\s|$)',
],
versioningTemplate:
'{{#if versioning}}{{versioning}}{{else}}semver{{/if}}',
};
const res = await extractPackageFile(
it.each([
[
'dotnet',
codeBlock`
# renovate: datasource=dotnet packageName=dotnet-runtime
RUN install-tool dotnet 6.0.13
`,
# renovate: datasource=dotnet packageName=dotnet-runtime
RUN install-tool dotnet 6.0.13
`,
'Dockerfile',
config
);
expect(res).toMatchObject({
deps: [
{
depName: 'dotnet',
packageName: 'dotnet-runtime',
currentValue: '6.0.13',
datasource: 'dotnet-version',
replaceString:
'# renovate: datasource=dotnet packageName=dotnet-runtime\nRUN install-tool dotnet 6.0.13',
},
],
});
});
'dotnet-version',
'dotnet-runtime',
'dotnet',
],
[
'adoptium-java',
codeBlock`
# renovate: datasource=adoptium-java packageName=java
RUN install-tool java 6.0.13
`,
'Dockerfile',
'java-version',
'java',
'java',
],
[
'node',
codeBlock`
# renovate: datasource=node packageName=node
RUN install-tool node 6.0.13
`,
'Dockerfile',
'node-version',
'node',
'node',
],
])(
'migrates %s',
async (
_oldDatasource,
content,
packageFile,
newDatasource,
packageName,
depName
) => {
const config: CustomExtractConfig = {
matchStrings: [
'# renovate: datasource=(?<datasource>[a-z-]+?)(?: (?:packageName|lookupName)=(?<packageName>.+?))?(?: versioning=(?<versioning>[a-z-]+?))?\\sRUN install-[a-z]+? (?<depName>[a-z-]+?) (?<currentValue>.+?)(?:\\s|$)',
],
versioningTemplate:
'{{#if versioning}}{{versioning}}{{else}}semver{{/if}}',
};
const res = await extractPackageFile(content, packageFile, config);
expect(res).toMatchObject({
deps: [
{
depName,
packageName,
currentValue: '6.0.13',
datasource: newDatasource,
},
],
});
}
);
});
2 changes: 1 addition & 1 deletion lib/util/exec/containerbase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const allToolConfig: Record<string, ToolConfig> = {
versioning: semverVersioningId,
},
node: {
datasource: 'node',
datasource: 'node-version',
packageName: 'node',
versioning: nodeVersioningId,
},
Expand Down

0 comments on commit efc366e

Please sign in to comment.