From 3951630206b2d5ad99ddd00a357ae71441aaeff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Legan=C3=A9s-Combarro=20=27piranna?= Date: Fri, 9 Feb 2024 18:05:07 +0100 Subject: [PATCH] Support `semver` target with `gitTags` package manager --- src/package-managers/gitTags.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/package-managers/gitTags.ts b/src/package-managers/gitTags.ts index a3dd8767..c0ad3d84 100644 --- a/src/package-managers/gitTags.ts +++ b/src/package-managers/gitTags.ts @@ -1,7 +1,7 @@ /** Fetches package metadata from Github tags. */ import parseGithubUrl from 'parse-github-url' import remoteGitTags from 'remote-git-tags' -import semver from 'semver' +import { valid } from 'semver' import { print } from '../lib/logging' import * as versionUtil from '../lib/version-util' import { GetVersion } from '../types/GetVersion' @@ -42,7 +42,7 @@ const getSortedVersions = async (name: string, declaration: VersionSpec, options .map(versionUtil.fixPseudoVersion) // do not pass semver.valid reference directly since the mapping index will be interpreted as the loose option // https://github.com/npm/node-semver#functions - .filter(tag => semver.valid(tag)) + .filter(tag => valid(tag)) .sort(versionUtil.compareVersions) return tags @@ -85,6 +85,12 @@ export const greatestLevel = export const minor = greatestLevel('minor') export const patch = greatestLevel('patch') +/** semver is not possible on a remote Git URL, do nothing. */ +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export const semver: GetVersion = async (_name: string, _declaration: VersionSpec, _options?: Options) => { + return { version: null } +} + // use greatest for newest rather than leaving newest undefined // this allows a mix of npm and github urls to be used in a package file without causing an "Unsupported target" error export const newest = greatest