Skip to content

Commit

Permalink
feat(node): use node-version datasource (#26918)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice authored Jan 29, 2024
1 parent 7780a02 commit 8c9167e
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 81 deletions.
9 changes: 3 additions & 6 deletions lib/modules/manager/nodenv/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ describe('modules/manager/nodenv/extract', () => {
expect(res.deps).toEqual([
{
currentValue: '8.4.0',
datasource: 'github-tags',
datasource: 'node-version',
depName: 'node',
packageName: 'nodejs/node',
},
]);
});
Expand All @@ -19,9 +18,8 @@ describe('modules/manager/nodenv/extract', () => {
expect(res.deps).toEqual([
{
currentValue: '8.4',
datasource: 'github-tags',
datasource: 'node-version',
depName: 'node',
packageName: 'nodejs/node',
},
]);
});
Expand All @@ -31,9 +29,8 @@ describe('modules/manager/nodenv/extract', () => {
expect(res.deps).toEqual([
{
currentValue: 'latestn',
datasource: 'github-tags',
datasource: 'node-version',
depName: 'node',
packageName: 'nodejs/node',
},
]);
});
Expand Down
5 changes: 2 additions & 3 deletions lib/modules/manager/nodenv/extract.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { GithubTagsDatasource } from '../../datasource/github-tags';
import { NodeVersionDatasource } from '../../datasource/node-version';
import type { PackageDependency, PackageFileContent } from '../types';

export function extractPackageFile(content: string): PackageFileContent {
const dep: PackageDependency = {
depName: 'node',
currentValue: content.trim(),
datasource: GithubTagsDatasource.id,
packageName: 'nodejs/node',
datasource: NodeVersionDatasource.id,
};
return { deps: [dep] };
}
4 changes: 2 additions & 2 deletions lib/modules/manager/nodenv/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Category } from '../../../constants';
import { GithubTagsDatasource } from '../../datasource/github-tags';
import { NodeVersionDatasource } from '../../datasource/node-version';
import * as nodeVersioning from '../../versioning/node';

export { extractPackageFile } from './extract';
Expand All @@ -14,4 +14,4 @@ export const defaultConfig = {

export const categories: Category[] = ['js', 'node'];

export const supportedDatasources = [GithubTagsDatasource.id];
export const supportedDatasources = [NodeVersionDatasource.id];
20 changes: 5 additions & 15 deletions lib/modules/manager/npm/extract/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,10 @@ exports[`modules/manager/npm/extract/index .extractPackageFile() extracts engine
{
"commitMessageTopic": "Node.js",
"currentValue": ">= 8.9.2",
"datasource": "github-tags",
"datasource": "node-version",
"depName": "node",
"depType": "engines",
"packageName": "nodejs/node",
"prettyDepType": "engine",
"versioning": "node",
},
{
"commitMessageTopic": "npm",
Expand Down Expand Up @@ -440,22 +438,18 @@ exports[`modules/manager/npm/extract/index .extractPackageFile() extracts volta
{
"commitMessageTopic": "Node.js",
"currentValue": "8.9.2",
"datasource": "github-tags",
"datasource": "node-version",
"depName": "node",
"depType": "engines",
"packageName": "nodejs/node",
"prettyDepType": "engine",
"versioning": "node",
},
{
"commitMessageTopic": "Node.js",
"currentValue": "8.9.2",
"datasource": "github-tags",
"datasource": "node-version",
"depName": "node",
"depType": "volta",
"packageName": "nodejs/node",
"prettyDepType": "volta",
"versioning": "node",
},
{
"commitMessageTopic": "Yarn",
Expand Down Expand Up @@ -512,22 +506,18 @@ exports[`modules/manager/npm/extract/index .extractPackageFile() extracts volta
{
"commitMessageTopic": "Node.js",
"currentValue": "8.9.2",
"datasource": "github-tags",
"datasource": "node-version",
"depName": "node",
"depType": "engines",
"packageName": "nodejs/node",
"prettyDepType": "engine",
"versioning": "node",
},
{
"commitMessageTopic": "Node.js",
"currentValue": "8.9.2",
"datasource": "github-tags",
"datasource": "node-version",
"depName": "node",
"depType": "volta",
"packageName": "nodejs/node",
"prettyDepType": "volta",
"versioning": "node",
},
{
"commitMessageTopic": "Yarn",
Expand Down
10 changes: 3 additions & 7 deletions lib/modules/manager/npm/extract/common/dependency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import validateNpmPackageName from 'validate-npm-package-name';
import { logger } from '../../../../../logger';
import { regEx } from '../../../../../util/regex';
import { GithubTagsDatasource } from '../../../../datasource/github-tags';
import { NodeVersionDatasource } from '../../../../datasource/node-version';
import { NpmDatasource } from '../../../../datasource/npm';
import * as nodeVersioning from '../../../../versioning/node';
import { api, isValid, isVersion } from '../../../../versioning/npm';
import type { PackageDependency } from '../../../types';

Expand Down Expand Up @@ -38,9 +38,7 @@ export function extractDependency(
dep.currentValue = input.trim();
if (depType === 'engines' || depType === 'packageManager') {
if (depName === 'node') {
dep.datasource = GithubTagsDatasource.id;
dep.packageName = 'nodejs/node';
dep.versioning = nodeVersioning.id;
dep.datasource = NodeVersionDatasource.id;
} else if (depName === 'yarn') {
dep.datasource = NpmDatasource.id;
dep.commitMessageTopic = 'Yarn';
Expand Down Expand Up @@ -70,9 +68,7 @@ export function extractDependency(
// support for volta
if (depType === 'volta') {
if (depName === 'node') {
dep.datasource = GithubTagsDatasource.id;
dep.packageName = 'nodejs/node';
dep.versioning = nodeVersioning.id;
dep.datasource = NodeVersionDatasource.id;
} else if (depName === 'yarn') {
dep.datasource = NpmDatasource.id;
dep.commitMessageTopic = 'Yarn';
Expand Down
15 changes: 4 additions & 11 deletions lib/modules/manager/npm/extract/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,7 @@ describe('modules/manager/npm/extract/index', () => {
{
depName: 'node',
currentValue: '>= 8.9.2',
datasource: 'github-tags',
versioning: 'node',
datasource: 'node-version',
depType: 'engines',
},
{
Expand Down Expand Up @@ -462,12 +461,10 @@ describe('modules/manager/npm/extract/index', () => {
{
commitMessageTopic: 'Node.js',
currentValue: '8.9.2',
datasource: 'github-tags',
datasource: 'node-version',
depName: 'node',
depType: 'volta',
packageName: 'nodejs/node',
prettyDepType: 'volta',
versioning: 'node',
},
{
commitMessageTopic: 'Yarn',
Expand Down Expand Up @@ -506,12 +503,10 @@ describe('modules/manager/npm/extract/index', () => {
{
commitMessageTopic: 'Node.js',
currentValue: '16.0.0',
datasource: 'github-tags',
datasource: 'node-version',
depName: 'node',
depType: 'volta',
packageName: 'nodejs/node',
prettyDepType: 'volta',
versioning: 'node',
},
{
commitMessageTopic: 'Yarn',
Expand Down Expand Up @@ -683,12 +678,10 @@ describe('modules/manager/npm/extract/index', () => {
{
commitMessageTopic: 'Node.js',
currentValue: '8.9.2',
datasource: 'github-tags',
datasource: 'node-version',
depName: 'node',
depType: 'engines',
packageName: 'nodejs/node',
prettyDepType: 'engine',
versioning: 'node',
},
{
commitMessageTopic: 'Yarn',
Expand Down
7 changes: 6 additions & 1 deletion lib/modules/manager/npm/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Category } from '../../../constants';
import { GithubTagsDatasource } from '../../datasource/github-tags';
import { NodeVersionDatasource } from '../../datasource/node-version';
import { NpmDatasource } from '../../datasource/npm';
import * as npmVersioning from '../../versioning/npm';

Expand Down Expand Up @@ -31,4 +32,8 @@ export const defaultConfig = {

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

export const supportedDatasources = [GithubTagsDatasource.id, NpmDatasource.id];
export const supportedDatasources = [
GithubTagsDatasource.id,
NpmDatasource.id,
NodeVersionDatasource.id,
];
9 changes: 3 additions & 6 deletions lib/modules/manager/nvm/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ describe('modules/manager/nvm/extract', () => {
expect(res.deps).toEqual([
{
currentValue: '8.4.0',
datasource: 'github-tags',
datasource: 'node-version',
depName: 'node',
packageName: 'nodejs/node',
},
]);
});
Expand All @@ -19,9 +18,8 @@ describe('modules/manager/nvm/extract', () => {
expect(res.deps).toEqual([
{
currentValue: '8.4',
datasource: 'github-tags',
datasource: 'node-version',
depName: 'node',
packageName: 'nodejs/node',
},
]);
});
Expand All @@ -31,9 +29,8 @@ describe('modules/manager/nvm/extract', () => {
expect(res.deps).toEqual([
{
currentValue: 'latestn',
datasource: 'github-tags',
datasource: 'node-version',
depName: 'node',
packageName: 'nodejs/node',
},
]);
});
Expand Down
5 changes: 2 additions & 3 deletions lib/modules/manager/nvm/extract.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { GithubTagsDatasource } from '../../datasource/github-tags';
import { NodeVersionDatasource } from '../../datasource/node-version';
import type { PackageDependency, PackageFileContent } from '../types';

export function extractPackageFile(content: string): PackageFileContent {
const dep: PackageDependency = {
depName: 'node',
currentValue: content.trim(),
datasource: GithubTagsDatasource.id,
packageName: 'nodejs/node',
datasource: NodeVersionDatasource.id,
};
return { deps: [dep] };
}
4 changes: 2 additions & 2 deletions lib/modules/manager/nvm/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Category } from '../../../constants';
import { GithubTagsDatasource } from '../../datasource/github-tags';
import { NodeVersionDatasource } from '../../datasource/node-version';
import * as nodeVersioning from '../../versioning/node';

export { extractPackageFile } from './extract';
Expand All @@ -15,4 +15,4 @@ export const defaultConfig = {

export const categories: Category[] = ['js', 'node'];

export const supportedDatasources = [GithubTagsDatasource.id];
export const supportedDatasources = [NodeVersionDatasource.id];
6 changes: 2 additions & 4 deletions lib/modules/manager/travis/__snapshots__/extract.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ exports[`modules/manager/travis/extract extractPackageFile() returns results 1`]
"deps": [
{
"currentValue": "6",
"datasource": "github-tags",
"datasource": "node-version",
"depName": "node",
"packageName": "nodejs/node",
},
{
"currentValue": "8",
"datasource": "github-tags",
"datasource": "node-version",
"depName": "node",
"packageName": "nodejs/node",
},
],
}
Expand Down
18 changes: 6 additions & 12 deletions lib/modules/manager/travis/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ describe('modules/manager/travis/extract', () => {
deps: [
{
currentValue: '11.10.1',
datasource: 'github-tags',
datasource: 'node-version',
depName: 'node',
packageName: 'nodejs/node',
},
],
});
Expand All @@ -46,15 +45,13 @@ describe('modules/manager/travis/extract', () => {
deps: [
{
currentValue: '11.10.1',
datasource: 'github-tags',
datasource: 'node-version',
depName: 'node',
packageName: 'nodejs/node',
},
{
currentValue: '11.10.2',
datasource: 'github-tags',
datasource: 'node-version',
depName: 'node',
packageName: 'nodejs/node',
},
],
});
Expand All @@ -66,15 +63,13 @@ describe('modules/manager/travis/extract', () => {
deps: [
{
currentValue: '11.10.1',
datasource: 'github-tags',
datasource: 'node-version',
depName: 'node',
packageName: 'nodejs/node',
},
{
currentValue: '11.10.2',
datasource: 'github-tags',
datasource: 'node-version',
depName: 'node',
packageName: 'nodejs/node',
},
],
});
Expand All @@ -86,9 +81,8 @@ describe('modules/manager/travis/extract', () => {
deps: [
{
currentValue: '11.10.1',
datasource: 'github-tags',
datasource: 'node-version',
depName: 'node',
packageName: 'nodejs/node',
},
],
});
Expand Down
Loading

0 comments on commit 8c9167e

Please sign in to comment.