Skip to content
Snippets Groups Projects
Select Git revision
  • a8c04b7d740f19cc093a9eb7d22871d51a5cac89
  • master default protected
  • 3
  • 3.14
  • 3.14.2
  • 3.14.1
  • 3.14.0
  • 3.13
  • 3.13.1
  • 3.13.0
  • 3.12
  • 3.12.0
  • 3.11
  • 3.11.5
  • 3.11.4
  • 3.11.3
  • 3.11.2
  • 3.11.1
  • 3.11.0
  • 3.10.3
  • 3.10.2
  • 3.10.1
22 results

README.md

Blame
  • util.ts 1.37 KiB
    import { regEx } from '../../../util/regex';
    import { get } from '../../versioning';
    import * as mavenVersioning from '../../versioning/maven';
    
    /*
      https://www.scala-sbt.org/release/docs/Cross-Build.html#Publishing+conventions
     */
    export function normalizeScalaVersion(str: string): string {
      // istanbul ignore if
      if (!str) {
        return str;
      }
      const versioning = get(mavenVersioning.id);
      if (versioning.isVersion(str)) {
        // Do not normalize unstable versions
        if (!versioning.isStable(str)) {
          return str;
        }
        // Do not normalize versions prior to 2.10
        if (!versioning.isGreaterThan(str, '2.10.0')) {
          return str;
        }
      }
      const isScala3 = versioning.isGreaterThan(str, '3.0.0');
      if (regEx(/^\d+\.\d+\.\d+$/).test(str)) {
        if (isScala3) {
          return str.replace(regEx(/^(\d+)\.(\d+)\.\d+$/), '$1');
        } else {
          return str.replace(regEx(/^(\d+)\.(\d+)\.\d+$/), '$1.$2');
        }
      }
      // istanbul ignore next
      return str;
    }
    
    export function sortPackageFiles(packageFiles: string[]): string[] {
      // process build.sbt first
      const sortedPackageFiles = [...packageFiles];
      const buildSbtIndex = sortedPackageFiles.findIndex((file) =>
        file.endsWith('build.sbt'),
      );
      if (buildSbtIndex !== -1) {
        const buildSbt = sortedPackageFiles.splice(buildSbtIndex, 1)[0];
        sortedPackageFiles.unshift(buildSbt);
      }
      return sortedPackageFiles;
    }