mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 06:56:24 +00:00
feat: use purl for nvm
This commit is contained in:
parent
e6c43be773
commit
2bdc54501a
8 changed files with 4 additions and 136 deletions
|
@ -1,60 +0,0 @@
|
||||||
const {
|
|
||||||
getMajor,
|
|
||||||
getMinor,
|
|
||||||
isGreaterThan,
|
|
||||||
isPinnedVersion,
|
|
||||||
sortVersions,
|
|
||||||
} = require('../../../versioning/semver');
|
|
||||||
const { getDependency } = require('../../../datasource/github');
|
|
||||||
|
|
||||||
async function getPackageUpdates(config) {
|
|
||||||
logger.debug('getPackageUpdates()');
|
|
||||||
logger.trace({ config });
|
|
||||||
const { currentVersion } = config;
|
|
||||||
logger.info('Checking for nvmrc updates');
|
|
||||||
if (!isPinnedVersion(currentVersion)) {
|
|
||||||
logger.info('Skipping non-pinned node version: ' + currentVersion);
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
let endpoint;
|
|
||||||
let token;
|
|
||||||
// istanbul ignore if
|
|
||||||
if (process.env.GITHUB_ENDPOINT) {
|
|
||||||
logger.debug('Removing GHE token before retrieving node releases');
|
|
||||||
endpoint = process.env.GITHUB_ENDPOINT;
|
|
||||||
delete process.env.GITHUB_ENDPOINT;
|
|
||||||
token = process.env.GITHUB_TOKEN;
|
|
||||||
process.env.GITHUB_TOKEN = process.env.GITHUB_COM_TOKEN;
|
|
||||||
}
|
|
||||||
const newReleases = Object.keys((await getDependency('nodejs/node')).versions)
|
|
||||||
.filter(release => getMajor(currentVersion) === getMajor(release))
|
|
||||||
.filter(release => isGreaterThan(release, currentVersion));
|
|
||||||
newReleases.sort(sortVersions);
|
|
||||||
// istanbul ignore if
|
|
||||||
if (endpoint) {
|
|
||||||
logger.debug('Restoring GHE token and endpoint');
|
|
||||||
process.env.GITHUB_TOKEN = token;
|
|
||||||
process.env.GITHUB_ENDPOINT = endpoint;
|
|
||||||
}
|
|
||||||
if (newReleases.length) {
|
|
||||||
logger.debug({ newReleases }, 'Found newer Node releases');
|
|
||||||
} else {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
const newVersion = newReleases[newReleases.length - 1];
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
type: getMajor(newVersion) > getMajor(currentVersion) ? 'major' : 'minor',
|
|
||||||
newVersion,
|
|
||||||
newVersionMajor: getMajor(newVersion),
|
|
||||||
newVersionMinor: getMinor(newVersion),
|
|
||||||
fromVersion: currentVersion,
|
|
||||||
toVersion: newVersion,
|
|
||||||
repositoryUrl: 'https://github.com/nodejs/node',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
getPackageUpdates,
|
|
||||||
};
|
|
|
@ -7,6 +7,8 @@ function extractDependencies(content) {
|
||||||
{
|
{
|
||||||
depName: 'node',
|
depName: 'node',
|
||||||
currentVersion: content.trim(),
|
currentVersion: content.trim(),
|
||||||
|
purl: 'pkg:github/nodejs/node?clean=true',
|
||||||
|
versionScheme: 'semver',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
return { deps };
|
return { deps };
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
const { extractDependencies } = require('./extract');
|
const { extractDependencies } = require('./extract');
|
||||||
const { getPackageUpdates } = require('./package');
|
|
||||||
const { updateDependency } = require('./update');
|
const { updateDependency } = require('./update');
|
||||||
|
|
||||||
const language = 'node';
|
const language = 'node';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
extractDependencies,
|
extractDependencies,
|
||||||
getPackageUpdates,
|
|
||||||
language,
|
language,
|
||||||
updateDependency,
|
updateDependency,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
const nodeManager = require('../_helpers/node/package');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
getPackageUpdates,
|
|
||||||
};
|
|
||||||
|
|
||||||
function getPackageUpdates(config) {
|
|
||||||
logger.debug('nvm.getPackageUpdates()');
|
|
||||||
return nodeManager.getPackageUpdates(config);
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
const nodeManager = require('../../../../lib/manager/_helpers/node/package');
|
|
||||||
const { getDependency } = require('../../../../lib/datasource/github');
|
|
||||||
|
|
||||||
jest.mock('../../../../lib/datasource/github');
|
|
||||||
|
|
||||||
describe('manager/npm/engines', () => {
|
|
||||||
let config;
|
|
||||||
beforeEach(() => {
|
|
||||||
config = {
|
|
||||||
depName: 'node',
|
|
||||||
};
|
|
||||||
});
|
|
||||||
it('skips non-pinned versions', async () => {
|
|
||||||
config.currentVersion = '8';
|
|
||||||
const res = await nodeManager.getPackageUpdates(config);
|
|
||||||
expect(res).toEqual([]);
|
|
||||||
});
|
|
||||||
it('returns empty', async () => {
|
|
||||||
config.currentVersion = '8.9.0';
|
|
||||||
getDependency.mockReturnValueOnce({ versions: {} });
|
|
||||||
const res = await nodeManager.getPackageUpdates(config);
|
|
||||||
expect(res).toEqual([]);
|
|
||||||
});
|
|
||||||
it('filters v', async () => {
|
|
||||||
config.currentVersion = '8.9.0';
|
|
||||||
getDependency.mockReturnValueOnce({
|
|
||||||
versions: { '8.0.0': {}, '8.9.1': {} },
|
|
||||||
});
|
|
||||||
const res = await nodeManager.getPackageUpdates(config);
|
|
||||||
expect(res).toHaveLength(1);
|
|
||||||
expect(res[0].newVersion).toEqual('8.9.1');
|
|
||||||
});
|
|
||||||
it('skips major versions', async () => {
|
|
||||||
config.currentVersion = '8.9.0';
|
|
||||||
getDependency.mockReturnValueOnce({ versions: { '9.4.0': {} } });
|
|
||||||
const res = await nodeManager.getPackageUpdates(config);
|
|
||||||
expect(res).toHaveLength(0);
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -5,6 +5,8 @@ Array [
|
||||||
Object {
|
Object {
|
||||||
"currentVersion": "8.4.0",
|
"currentVersion": "8.4.0",
|
||||||
"depName": "node",
|
"depName": "node",
|
||||||
|
"purl": "pkg:github/nodejs/node?clean=true",
|
||||||
|
"versionScheme": "semver",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
||||||
|
|
||||||
exports[`lib/manager/node/package getPackageUpdates returns result if needing updates 1`] = `Array []`;
|
|
|
@ -1,22 +0,0 @@
|
||||||
const node = require('../../../lib/manager/nvm/package');
|
|
||||||
const defaultConfig = require('../../../lib/config/defaults').getConfig();
|
|
||||||
|
|
||||||
describe('lib/manager/node/package', () => {
|
|
||||||
describe('getPackageUpdates', () => {
|
|
||||||
let config;
|
|
||||||
beforeEach(() => {
|
|
||||||
config = {
|
|
||||||
...defaultConfig,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
it('returns empty if matching', async () => {
|
|
||||||
config.currentVersion = ['6', '8'];
|
|
||||||
config.supportPolicy = ['lts_active'];
|
|
||||||
expect(await node.getPackageUpdates(config)).toEqual([]);
|
|
||||||
});
|
|
||||||
it('returns result if needing updates', async () => {
|
|
||||||
config.currentVersion = ['6', '8'];
|
|
||||||
expect(await node.getPackageUpdates(config)).toMatchSnapshot();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
Loading…
Reference in a new issue