Only propose latest major in cli select
This commit is contained in:
@ -2,6 +2,7 @@ import { getLatestsSemVersionedTagFactory } from "../tools/octokit-addons/getLat
|
|||||||
import { Octokit } from "@octokit/rest";
|
import { Octokit } from "@octokit/rest";
|
||||||
import cliSelect from "cli-select";
|
import cliSelect from "cli-select";
|
||||||
import { lastKeycloakVersionWithAccountV1 } from "./constants";
|
import { lastKeycloakVersionWithAccountV1 } from "./constants";
|
||||||
|
import { SemVer } from "../tools/SemVer";
|
||||||
|
|
||||||
export async function promptKeycloakVersion() {
|
export async function promptKeycloakVersion() {
|
||||||
const { getLatestsSemVersionedTag } = (() => {
|
const { getLatestsSemVersionedTag } = (() => {
|
||||||
@ -18,32 +19,45 @@ export async function promptKeycloakVersion() {
|
|||||||
return { getLatestsSemVersionedTag };
|
return { getLatestsSemVersionedTag };
|
||||||
})();
|
})();
|
||||||
|
|
||||||
console.log("Select Keycloak version?");
|
console.log("Select Keycloak version");
|
||||||
|
|
||||||
const tags = [
|
const semVersionedTagByMajor = new Map<number, { tag: string; version: SemVer }>();
|
||||||
...(await getLatestsSemVersionedTag({
|
|
||||||
"count": 15,
|
(
|
||||||
|
await getLatestsSemVersionedTag({
|
||||||
|
"count": 50,
|
||||||
"owner": "keycloak",
|
"owner": "keycloak",
|
||||||
"repo": "keycloak"
|
"repo": "keycloak"
|
||||||
}).then(arr => arr.map(({ tag }) => tag))),
|
})
|
||||||
lastKeycloakVersionWithAccountV1,
|
).forEach(semVersionedTag => {
|
||||||
"19.0.1",
|
const currentSemVersionedTag = semVersionedTagByMajor.get(semVersionedTag.version.major);
|
||||||
"11.0.3"
|
|
||||||
];
|
|
||||||
|
|
||||||
if (process.env["GITHUB_ACTIONS"] === "true") {
|
if (currentSemVersionedTag !== undefined && SemVer.compare(semVersionedTag.version, currentSemVersionedTag.version) === -1) {
|
||||||
return { "keycloakVersion": tags[0] };
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { value: keycloakVersion } = await cliSelect<string>({
|
semVersionedTagByMajor.set(semVersionedTag.version.major, semVersionedTag);
|
||||||
"values": tags
|
});
|
||||||
|
|
||||||
|
const lastMajorVersions = Array.from(semVersionedTagByMajor.values()).map(({ tag: version }) => {
|
||||||
|
let out = version;
|
||||||
|
|
||||||
|
if (version === lastKeycloakVersionWithAccountV1) {
|
||||||
|
out += " (last version with account v1 built in)";
|
||||||
|
}
|
||||||
|
|
||||||
|
return out;
|
||||||
|
});
|
||||||
|
|
||||||
|
const { value } = await cliSelect<string>({
|
||||||
|
"values": lastMajorVersions
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
console.log("Aborting");
|
console.log("Aborting");
|
||||||
|
|
||||||
process.exit(-1);
|
process.exit(-1);
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(keycloakVersion);
|
const keycloakVersion = value.split(" ")[0];
|
||||||
|
|
||||||
return { keycloakVersion };
|
return { keycloakVersion };
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user