Skip to content

Commit

Permalink
refactor: latestVersion -> tags.latest (#8739)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Feb 18, 2021
1 parent a719136 commit 33e7e41
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 22 deletions.
1 change: 0 additions & 1 deletion lib/datasource/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export interface Release {

export interface ReleaseResult {
sourceDirectory?: string;
latestVersion?: string;
changelogUrl?: string;
dependencyUrl?: string;
deprecationMessage?: string;
Expand Down
17 changes: 2 additions & 15 deletions lib/datasource/npm/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

exports[`datasource/npm/index should fetch package info from custom registry 1`] = `
Object {
"latestVersion": "0.0.1",
"name": "foobar",
"releases": Array [
Object {
Expand All @@ -25,7 +24,6 @@ Object {

exports[`datasource/npm/index should fetch package info from npm 1`] = `
Object {
"latestVersion": "0.0.1",
"name": "foobar",
"releases": Array [
Object {
Expand All @@ -48,7 +46,6 @@ Object {

exports[`datasource/npm/index should handle foobar 1`] = `
Object {
"latestVersion": "0.0.1",
"name": "foobar",
"releases": Array [
Object {
Expand All @@ -71,7 +68,6 @@ Object {

exports[`datasource/npm/index should handle no time 1`] = `
Object {
"latestVersion": "0.0.1",
"name": "foobar",
"releases": Array [
Object {
Expand All @@ -93,7 +89,6 @@ Object {

exports[`datasource/npm/index should parse repo url (string) 1`] = `
Object {
"latestVersion": "0.0.1",
"name": "foobar",
"releases": Array [
Object {
Expand All @@ -111,7 +106,6 @@ Object {

exports[`datasource/npm/index should parse repo url 1`] = `
Object {
"latestVersion": "0.0.1",
"name": "foobar",
"releases": Array [
Object {
Expand All @@ -129,7 +123,6 @@ Object {

exports[`datasource/npm/index should replace any environment variable in npmrc 1`] = `
Object {
"latestVersion": "0.0.1",
"name": "foobar",
"releases": Array [
Object {
Expand All @@ -152,13 +145,12 @@ Object {

exports[`datasource/npm/index should return deprecated 1`] = `
Object {
"deprecationMessage": "On registry \`https://registry.npmjs.org/\`, the \\"latest\\" version (v0.0.2) of dependency \`foobar\` has the following deprecation notice:
"deprecationMessage": "On registry \`https://registry.npmjs.org/\`, the \\"latest\\" version of dependency \`foobar\` has the following deprecation notice:
\`This is deprecated\`
Marking the latest version of an npm package as deprecated results in the entire package being considered deprecated, so contact the package author you think this is a mistake.",
"deprecationSource": "npm",
"latestVersion": "0.0.2",
"name": "foobar",
"releases": Array [
Object {
Expand All @@ -180,7 +172,7 @@ Marking the latest version of an npm package as deprecated results in the entire
`;
exports[`datasource/npm/index should return deprecated 2`] = `
"On registry \`https://registry.npmjs.org/\`, the \\"latest\\" version (v0.0.2) of dependency \`foobar\` has the following deprecation notice:
"On registry \`https://registry.npmjs.org/\`, the \\"latest\\" version of dependency \`foobar\` has the following deprecation notice:
\`This is deprecated\`
Expand All @@ -189,7 +181,6 @@ Marking the latest version of an npm package as deprecated results in the entire
exports[`datasource/npm/index should send an authorization header if provided 1`] = `
Object {
"latestVersion": "0.0.1",
"name": "foobar",
"releases": Array [
Object {
Expand All @@ -212,7 +203,6 @@ Object {
exports[`datasource/npm/index should use NPM_TOKEN if provided 1`] = `
Object {
"latestVersion": "0.0.1",
"name": "foobar",
"releases": Array [
Object {
Expand All @@ -235,7 +225,6 @@ Object {
exports[`datasource/npm/index should use default registry if missing from npmrc 1`] = `
Object {
"latestVersion": "0.0.1",
"name": "foobar",
"releases": Array [
Object {
Expand All @@ -258,7 +247,6 @@ Object {
exports[`datasource/npm/index should use host rules by baseUrl if provided 1`] = `
Object {
"latestVersion": "0.0.1",
"name": "foobar",
"releases": Array [
Object {
Expand All @@ -281,7 +269,6 @@ Object {
exports[`datasource/npm/index should use host rules by hostName if provided 1`] = `
Object {
"latestVersion": "0.0.1",
"name": "foobar",
"releases": Array [
Object {
Expand Down
4 changes: 1 addition & 3 deletions lib/datasource/npm/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export interface NpmDependency extends ReleaseResult {
deprecationSource?: string;
name: string;
homepage: string;
latestVersion: string;
sourceUrl: string;
versions: Record<string, any>;
'dist-tags': Record<string, string>;
Expand Down Expand Up @@ -194,7 +193,6 @@ export async function getDependency(
const dep: NpmDependency = {
name: res.name,
homepage: res.homepage,
latestVersion: res['dist-tags'].latest,
sourceUrl,
versions: {},
releases: null,
Expand All @@ -205,7 +203,7 @@ export async function getDependency(
dep.sourceDirectory = res.repository.directory;
}
if (latestVersion.deprecated) {
dep.deprecationMessage = `On registry \`${regUrl}\`, the "latest" version (v${dep.latestVersion}) of dependency \`${packageName}\` has the following deprecation notice:\n\n\`${latestVersion.deprecated}\`\n\nMarking the latest version of an npm package as deprecated results in the entire package being considered deprecated, so contact the package author you think this is a mistake.`;
dep.deprecationMessage = `On registry \`${regUrl}\`, the "latest" version of dependency \`${packageName}\` has the following deprecation notice:\n\n\`${latestVersion.deprecated}\`\n\nMarking the latest version of an npm package as deprecated results in the entire package being considered deprecated, so contact the package author you think this is a mistake.`;
dep.deprecationSource = id;
}
dep.releases = Object.keys(res.versions).map((version) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ exports[`workers/repository/process/lookup .lookupUpdates() ignores deprecated 1
Object {
"changelogUrl": undefined,
"dependencyUrl": undefined,
"deprecationMessage": "On registry \`https://registry.npmjs.org/\`, the \\"latest\\" version (v1.4.1) of dependency \`q2\` has the following deprecation notice:
"deprecationMessage": "On registry \`https://registry.npmjs.org/\`, the \\"latest\\" version of dependency \`q2\` has the following deprecation notice:
\`true\`
Expand Down
5 changes: 3 additions & 2 deletions lib/workers/repository/process/lookup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ export async function lookupUpdates(
res.homepage = dependency.homepage;
res.changelogUrl = dependency.changelogUrl;
res.dependencyUrl = dependency?.dependencyUrl;
const { latestVersion, releases } = dependency;
const { releases } = dependency;
const latestVersion = dependency.tags?.latest;
// Filter out any results from datasource that don't comply with our versioning
let allVersions = releases.filter((release) =>
versioning.isVersion(release.version)
Expand Down Expand Up @@ -296,7 +297,7 @@ export async function lookupUpdates(
let filteredVersions = filterVersions(
config,
filterStart,
dependency.latestVersion,
latestVersion,
allVersions
).filter((v) =>
// Leave only compatible versions
Expand Down

0 comments on commit 33e7e41

Please sign in to comment.