"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.miseTooling = exports.asdfTooling = void 0;
const tslib_1 = require("tslib");
const github_releases_1 = require("../../datasource/github-releases");
const github_tags_1 = require("../../datasource/github-tags");
const java_version_1 = require("../../datasource/java-version");
const node_version_1 = require("../../datasource/node-version");
const ruby_version_1 = require("../../datasource/ruby-version");
const regexVersioning = tslib_1.__importStar(require("../../versioning/regex"));
const semverVersioning = tslib_1.__importStar(require("../../versioning/semver"));
const upgradeable_tooling_1 = require("../asdf/upgradeable-tooling");
exports.asdfTooling = upgradeable_tooling_1.upgradeableTooling;
exports.miseTooling = {
    bun: {
        misePluginUrl: 'https://mise.jdx.dev/lang/bun.html',
        config: {
            packageName: 'oven-sh/bun',
            datasource: github_releases_1.GithubReleasesDatasource.id,
            extractVersion: '^bun-v(?<version>\\S+)',
        },
    },
    deno: {
        misePluginUrl: 'https://mise.jdx.dev/lang/deno.html',
        config: {
            packageName: 'denoland/deno',
            datasource: github_releases_1.GithubReleasesDatasource.id,
            extractVersion: '^v(?<version>\\S+)',
        },
    },
    erlang: {
        misePluginUrl: 'https://mise.jdx.dev/lang/erlang.html',
        config: {
            packageName: 'erlang/otp',
            datasource: github_tags_1.GithubTagsDatasource.id,
            extractVersion: '^OTP-(?<version>\\S+)',
            versioning: `${regexVersioning.id}:^(?<major>\\d+?)\\.(?<minor>\\d+?)(\\.(?<patch>\\d+))?$`,
        },
    },
    go: {
        misePluginUrl: 'https://mise.jdx.dev/lang/go.html',
        config: {
            packageName: 'golang/go',
            datasource: github_tags_1.GithubTagsDatasource.id,
            extractVersion: '^go(?<version>\\S+)',
        },
    },
    java: {
        misePluginUrl: 'https://mise.jdx.dev/lang/java.html',
        config: (version) => {
            // no prefix is shorthand for openjdk
            const versionMatch = version.match(/^(\d\S+)/)?.[1];
            if (versionMatch) {
                return {
                    datasource: java_version_1.JavaVersionDatasource.id,
                    packageName: 'java-jdk',
                    currentValue: versionMatch,
                };
            }
            const openJdkMatches = version.match(/^openjdk-(?<version>\d\S+)/)?.groups;
            if (openJdkMatches) {
                return {
                    datasource: java_version_1.JavaVersionDatasource.id,
                    packageName: 'java-jdk',
                    currentValue: openJdkMatches.version,
                };
            }
            const adoptOpenJdkMatches = version.match(/^adoptopenjdk-(?<version>\d\S+)/)?.groups;
            if (adoptOpenJdkMatches) {
                return {
                    datasource: java_version_1.JavaVersionDatasource.id,
                    packageName: 'java-jdk',
                    currentValue: adoptOpenJdkMatches.version,
                };
            }
            const temurinJdkMatches = version.match(/^temurin-(?<version>\d\S+)/)?.groups;
            if (temurinJdkMatches) {
                return {
                    datasource: java_version_1.JavaVersionDatasource.id,
                    packageName: 'java-jdk',
                    currentValue: temurinJdkMatches.version,
                };
            }
            const correttoJdkMatches = version.match(/^corretto-(?<version>\d\S+)/)?.groups;
            if (correttoJdkMatches) {
                return {
                    datasource: java_version_1.JavaVersionDatasource.id,
                    packageName: 'java-jdk',
                    currentValue: correttoJdkMatches.version,
                };
            }
            const zuluJdkMatches = version.match(/^zulu-(?<version>\d\S+)/)?.groups;
            if (zuluJdkMatches) {
                return {
                    datasource: java_version_1.JavaVersionDatasource.id,
                    packageName: 'java-jdk',
                    currentValue: zuluJdkMatches.version,
                };
            }
            const oracleGraalvmJdkMatches = version.match(/^oracle-graalvm-(?<version>\d\S+)/)?.groups;
            if (oracleGraalvmJdkMatches) {
                return {
                    datasource: java_version_1.JavaVersionDatasource.id,
                    packageName: 'java-jdk',
                    currentValue: oracleGraalvmJdkMatches.version,
                };
            }
            return undefined;
        },
    },
    node: {
        misePluginUrl: 'https://mise.jdx.dev/lang/node.html',
        config: {
            packageName: 'nodejs',
            datasource: node_version_1.NodeVersionDatasource.id,
        },
    },
    python: {
        misePluginUrl: 'https://mise.jdx.dev/lang/python.html',
        config: {
            packageName: 'python/cpython',
            datasource: github_tags_1.GithubTagsDatasource.id,
            extractVersion: '^v(?<version>\\S+)',
        },
    },
    ruby: {
        misePluginUrl: 'https://mise.jdx.dev/lang/ruby.html',
        config: {
            packageName: 'ruby-version',
            datasource: ruby_version_1.RubyVersionDatasource.id,
            versioning: semverVersioning.id,
        },
    },
};
//# sourceMappingURL=upgradeable-tooling.js.map