mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 06:56:24 +00:00
refactor: remove unused nuget.getPackageUpdates
This commit is contained in:
parent
5604f488b7
commit
17f54934e2
4 changed files with 0 additions and 120 deletions
|
@ -1,9 +1,7 @@
|
|||
const { extractDependencies } = require('./extract');
|
||||
const { getPackageUpdates } = require('./package');
|
||||
const { updateDependency } = require('./update');
|
||||
|
||||
module.exports = {
|
||||
extractDependencies,
|
||||
getPackageUpdates,
|
||||
updateDependency,
|
||||
};
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
const nugetApi = require('../../datasource/nuget');
|
||||
const {
|
||||
semverSort,
|
||||
isStable,
|
||||
isGreaterThan,
|
||||
getMajor,
|
||||
getMinor,
|
||||
isValid,
|
||||
} = require('../../versioning/semver');
|
||||
|
||||
module.exports = {
|
||||
getPackageUpdates,
|
||||
};
|
||||
|
||||
async function getPackageUpdates(config) {
|
||||
const { currentVersion, depName, lineNumber, ignoreUnstable } = config;
|
||||
const upgrades = [];
|
||||
|
||||
logger.debug('nuget.getPackageUpdates()');
|
||||
logger.trace({ config });
|
||||
|
||||
const versions = await nugetApi.getVersions(depName);
|
||||
if (versions === undefined) {
|
||||
logger.warn('No versions retrieved from nuget');
|
||||
return upgrades;
|
||||
}
|
||||
const applicableVersions = ignoreUnstable
|
||||
? versions.filter(v => isStable(v))
|
||||
: versions;
|
||||
const newVersion = applicableVersions.sort(semverSort).pop();
|
||||
|
||||
if (!isValid(currentVersion)) {
|
||||
logger.debug({ newVersion }, 'Skipping non-semver current version.');
|
||||
} else if (!isValid(newVersion)) {
|
||||
logger.debug({ newVersion }, 'Skipping non-semver newVersion version.');
|
||||
} else if (
|
||||
newVersion !== undefined &&
|
||||
isGreaterThan(newVersion, currentVersion)
|
||||
) {
|
||||
const upgrade = {};
|
||||
|
||||
upgrade.newVersion = newVersion;
|
||||
upgrade.newVersionMajor = getMajor(newVersion);
|
||||
upgrade.newVersionMinor = getMinor(newVersion);
|
||||
upgrade.type =
|
||||
getMajor(newVersion) > getMajor(currentVersion) ? 'major' : 'minor';
|
||||
upgrade.lineNumber = lineNumber;
|
||||
upgrade.changeLogFromVersion = currentVersion;
|
||||
upgrade.changeLogToVersion = newVersion;
|
||||
|
||||
upgrades.push(upgrade);
|
||||
}
|
||||
|
||||
return upgrades;
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`lib/manager/nuget/package getPackageUpdates() returns higher version if available 1`] = `
|
||||
Array [
|
||||
Object {
|
||||
"changeLogFromVersion": "2.3.0",
|
||||
"changeLogToVersion": "2.4.0",
|
||||
"lineNumber": 1337,
|
||||
"newVersion": "2.4.0",
|
||||
"newVersionMajor": 2,
|
||||
"newVersionMinor": 4,
|
||||
"type": "minor",
|
||||
},
|
||||
]
|
||||
`;
|
|
@ -1,48 +0,0 @@
|
|||
const { getPackageUpdates } = require('../../../lib/manager/nuget/package');
|
||||
const nugetApi = require('../../../lib/datasource/nuget');
|
||||
const defaultConfig = require('../../../lib/config/defaults').getConfig();
|
||||
|
||||
nugetApi.getNuspec = jest.fn();
|
||||
nugetApi.getVersions = jest.fn();
|
||||
|
||||
describe('lib/manager/nuget/package', () => {
|
||||
describe('getPackageUpdates()', () => {
|
||||
let config;
|
||||
beforeEach(() => {
|
||||
config = {
|
||||
...defaultConfig,
|
||||
depName: 'some-dep',
|
||||
currentVersion: '2.3.0',
|
||||
lineNumber: 1337,
|
||||
ignoreUnstable: true,
|
||||
};
|
||||
});
|
||||
it('returns empty if no versions are found', async () => {
|
||||
expect(await getPackageUpdates(config)).toEqual([]);
|
||||
});
|
||||
it('returns empty if current version is not semver', async () => {
|
||||
config.currentVersion = undefined;
|
||||
nugetApi.getVersions.mockReturnValueOnce(['1.0.0']);
|
||||
expect(await getPackageUpdates(config)).toEqual([]);
|
||||
});
|
||||
it('returns empty if latest version is not semver', async () => {
|
||||
nugetApi.getVersions.mockReturnValueOnce(['5.0.0.0']);
|
||||
expect(await getPackageUpdates(config)).toEqual([]);
|
||||
});
|
||||
it('returns empty if highest version is current version', async () => {
|
||||
nugetApi.getVersions.mockReturnValueOnce([
|
||||
'1.0.0',
|
||||
config.currentVersion,
|
||||
]);
|
||||
expect(await getPackageUpdates(config)).toEqual([]);
|
||||
});
|
||||
it('returns higher version if available', async () => {
|
||||
nugetApi.getVersions.mockReturnValueOnce(['1.0.0', '2.3.1', '2.4.0']);
|
||||
expect(await getPackageUpdates(config)).toMatchSnapshot();
|
||||
});
|
||||
it('ignores unstable version if specified', async () => {
|
||||
nugetApi.getVersions.mockReturnValueOnce(['3.0.0-alpha1']);
|
||||
expect(await getPackageUpdates(config)).toEqual([]);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue