keycloak_theme/src/bin/promptKeycloakVersion.ts

48 lines
1.3 KiB
TypeScript
Raw Normal View History

2022-04-20 00:39:40 +02:00
import { getLatestsSemVersionedTagFactory } from "./tools/octokit-addons/getLatestsSemVersionedTag";
import { Octokit } from "@octokit/rest";
import cliSelect from "cli-select";
export async function promptKeycloakVersion() {
const { getLatestsSemVersionedTag } = (() => {
const { octokit } = (() => {
const githubToken = process.env.GITHUB_TOKEN;
const octokit = new Octokit(githubToken === undefined ? undefined : { "auth": githubToken });
return { octokit };
})();
const { getLatestsSemVersionedTag } = getLatestsSemVersionedTagFactory({ octokit });
return { getLatestsSemVersionedTag };
})();
console.log("Select Keycloak version?");
2022-04-20 00:39:40 +02:00
2022-04-22 18:22:28 +02:00
const tags = [
...(await getLatestsSemVersionedTag({
"count": 10,
"doIgnoreBeta": true,
"owner": "keycloak",
"repo": "keycloak"
2022-04-22 18:22:28 +02:00
}).then(arr => arr.map(({ tag }) => tag))),
"11.0.3"
2022-04-22 18:22:28 +02:00
];
if (process.env["GITHUB_ACTIONS"] === "true") {
return { "keycloakVersion": tags[0] };
}
2022-04-20 00:39:40 +02:00
const { value: keycloakVersion } = await cliSelect<string>({
"values": tags
2022-04-20 00:39:40 +02:00
}).catch(() => {
console.log("Aborting");
process.exit(-1);
});
console.log(keycloakVersion);
return { keycloakVersion };
}