Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens Langhammer
2024-11-06 18:06:41 +01:00
parent 9959221c21
commit 3e40fab883

View File

@ -4,13 +4,18 @@ import { readFileSync } from "fs";
import path from "path";
const __dirname = fileURLToPath(new URL(".", import.meta.url));
const structureFilePath = path.join(__dirname, "../docs/customize/blueprints/v1/structure.md");
const structureFilePath = path.join(
__dirname,
"../docs/customize/blueprints/v1/structure.md",
);
const cmd = ["git", "ls-remote", "--tags", "origin"].join(" ");
const tagblob = execSync(cmd, { encoding: "utf8" });
const itsadate = /\d{4}\.\d{1,2}\.\d{1,2}$/;
const sortfn = (d1, d2) => {
const [y1, m1, y2, m2] = [d1[0], d1[1], d2[0], d2[1]].map((s) => parseInt(s, 10));
const [y1, m1, y2, m2] = [d1[0], d1[1], d2[0], d2[1]].map((s) =>
parseInt(s, 10),
);
return y1 < y2 ? 1 : y1 > y2 ? -1 : m1 < m2 ? 1 : m1 > m2 ? -1 : 0;
};
@ -30,16 +35,22 @@ const taglines = tagblob
const results = await Promise.allSettled(
taglines.map((version) =>
fetch(`https://version-${version}.goauthentik.io/blueprints/schema.json`, {
method: "HEAD",
}),
fetch(
`https://version-${version}.goauthentik.io/blueprints/schema.json`,
{
method: "HEAD",
},
),
),
);
const version = /version-(\d{4}-\d{1,2})/;
const valid = results
.filter((result) => result.status === "fulfilled" && result.value.status === 200)
.filter(
(result) =>
result.status === "fulfilled" && result.value.status === 200,
)
.map((result) => result.value.url)
.map((url) => {
const thedate = version.exec(url)[1];
@ -47,7 +58,8 @@ const valid = results
});
const structurefile = readFileSync(structureFilePath, "utf-8");
const schemablock = /<Collapse title="Available Older Blueprint Schemas">.*?<\/Collapse>/m;
const schemablock =
/<Collapse title="Available Older Blueprint Schemas">.*?<\/Collapse>/m;
console.log(
structurefile.replace(