// Regular Expressions have been copied from, some more work were necessary to make it work: // original rez regex written in python (#11634) // version_range_regex = ( // # Match a version number (e.g. 1.0.0) // r" ^(?P{version_group})$" // "|" // # Or match an exact version number (e.g. ==1.0.0) // " ^(?P" // " ==" # Required == operator // " (?P{version_group})?" // " )$" // "|" // # Or match an inclusive bound (e.g. 1.0.0..2.0.0) // " ^(?P" // " (?P{version_group})?" // " \.\." # Required .. operator // " (?P{version_group})?" // " )$" // "|" // # Or match a lower bound (e.g. 1.0.0+) // " ^(?P" // " (?P>|>=)?" # Bound is exclusive? // " (?P{version_group})?" // " (?(lower_bound_prefix)|\+)" # + only if bound is not exclusive // " )$" // "|" // # Or match an upper bound (e.g. <=1.0.0) // " ^(?P" // " (?P<(?={version_group})|<=)?" # Bound is exclusive? // " (?P{version_group})?" // " )$" // "|" // # Or match a range in ascending order (e.g. 1.0.0+<2.0.0) // " ^(?P" // " (?P" // " (?P>|>=)?" # Lower bound is exclusive? // " (?P{version_group})?" // " (?(range_lower_asc_prefix)|\+)?" # + only if lower bound is not exclusive // " )(?P" // " (?(range_lower_asc_version),?|)" # , only if lower bound is found // " (?P<(?={version_group})|<=)" # <= only if followed by a version group // " (?P{version_group})?" // " )" // " )$" // "|" // # Or match a range in descending order (e.g. <=2.0.0,1.0.0+) // " ^(?P" // " (?P" // " (?P<|<=)?" # Upper bound is exclusive? // " (?P{version_group})?" // " (?(range_upper_desc_prefix)|\+)?" # + only if upper bound is not exclusive // " )(?P" // " (?(range_upper_desc_version),|)" # Comma is not optional because we don't want to recognize something like "<4>3" // " (?P<(?={version_group})|>=?)" # >= or > only if followed by a version group // " (?P{version_group})?" // " )" // " )$" // ).format(version_group=version_group) // - Replace {version_group} -> ${versionGroup} // - Replace (?P<...>) -> (?<...>) // - Replace ?(...) -> \k<...> import { regEx } from '../../../util/regex'; // - Replace single \ -> double \ export const versionGroup = '([0-9a-zA-Z_]+(?:[.-][0-9a-zA-Z_]+)*)'; export const matchVersion = regEx( `^(?${versionGroup})$` ); /* Match a version number (e.g. 1.0.0) */ export const exactVersion = regEx( `^(?==(?${versionGroup})?)$` ); /* Match an exact version number (e.g. ==1.0.0) */ // inclusiveBound is called inclusive but behaviour in rez is this: // package-1..3 will match versions 1.2.3, 2.3.4, but not 3.0.0 or above export const inclusiveBound = regEx( `^(?(?${versionGroup})?\\.\\.(?${versionGroup})?)$` ); /* Match an inclusive bound (e.g. 1.0.0..2.0.0) */ // Add ? after |\\+) in order to match >=1.15 export const lowerBound = new RegExp( // TODO #12872 named backreference `^(?(?>|>=)?(?${versionGroup})?(\\k|\\+)?)$` ); /* Match a lower bound (e.g. 1.0.0+) */ export const upperBound = new RegExp( // TODO #12872 lookahead `^(?(?<(?=${versionGroup})|<=)?(?${versionGroup})?)$` ); /* Match an upper bound (e.g. <=1.0.0) */ // Add ,? to match >=7,<9 (otherwise it just matches >=7<9) export const ascendingRange = new RegExp( // TODO #12872 named backreference `^(?(?(?>|>=)?(?${versionGroup})?(\\k|\\+)?),?(?(\\k,?|)(?<(?=${versionGroup})|<=)(?${versionGroup})?))$` ); /* Match a range in ascending order (e.g. 1.0.0+<2.0.0) */ // Add , to match <9,>=7 (otherwise it just matches <9>=7) export const descendingRange = new RegExp( // TODO #12872 named backreference `^(?(?(?<|<=)?(?${versionGroup})?(\\k|\\+)?),(?(\\k,|)(?<(?=${versionGroup})|>=?)(?${versionGroup})?))$` ); /* Match a range in descending order (e.g. <=2.0.0,1.0.0+) */