SPB Git

Repository Public

version.ts 2.6 KB 61 lines typescript

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : ORIX App Universe8 * File             : src/lib/releases/version.ts9 * Module           : lib10 * Repository       : https://git.spboucher.ai/orix-spboucher-ai11 * Project Website  : https://www.orixlab.dev12 * Created          : 2026-11-2113 * Last Modified    : 2026-11-2114 *15 * Author           : Simon-Pierre Boucher16 * Position         : Professor of Finance17 * Institution      : Université du Québec en Outaouais (UQO)18 * Organization     : SP Boucher19 * Website          : https://spboucher.ai20 * Git              : https://git.spboucher.ai21 *22 * Preferred Contact: support@spboucher.ai23 * Development      : dev@spboucher.ai24 * Support          : support@spboucher.ai25 * Security/Admin   : admin@spboucher.ai26 *27 * Copyright (c) 202628 * Simon-Pierre Boucher29 * All rights reserved where applicable. This file is governed by the30 * applicable project license, copyright notices and relevant law.31 * Existing third-party rights and notices remain unaffected.32 *33 * License          : None specified (no license file in this repository)34 *35 * Do not embed credentials, private keys, access tokens,36 * certificates or confidential personal information.37 *38 * =============================================================================39 * END OF SP BOUCHER SOURCE HEADER40 * =============================================================================41 */4243export type Version = { major: number; minor: number; patch: number; pre: string | null; text: string };4445/**46 * Parses a release tag: v1.2.3, 1.2, v2.0.0-beta.1. Anything after a hyphen marks a pre-release / build tag.47 * A repository that ships two platforms prefixes its Mac tags (mac-v2.0.2, as ORIX Astra does): the prefix is ignored.48 */49export function parseTag(tag: string): Version | null {50  const m = /^(?:mac-)?v?(\d+)\.(\d+)(?:\.(\d+))?(?:[-+](.+))?$/.exec(tag.trim());51  if (!m) return null;52  const [major, minor, patch] = [Number(m[1]), Number(m[2]), Number(m[3] ?? 0)];53  return { major, minor, patch, pre: m[4] ?? null, text: `${major}.${minor}.${patch}` };54}5556export function compareVersions(a: string, b: string): number {57  const x = parseTag(a), y = parseTag(b);58  if (!x || !y) return a.localeCompare(b);59  return x.major - y.major || x.minor - y.minor || x.patch - y.patch || (x.pre === y.pre ? 0 : x.pre === null ? 1 : y.pre === null ? -1 : x.pre.localeCompare(y.pre));60}61
Files main
Menu

Theme