mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
fca10221b9
* chore: promote no-explicit-any from warn to error and resolve violations Upgrades the oxlint rule severity and removes all 40 existing `no-explicit-any` warnings across the codebase. Most call sites gained proper types (SharedEditor refs, JSONNode/JSONMark for ProseMirror JSON walking, DocumentsStore, dd-trace `Span` parameter inference, prosemirror Fragment public API in place of internal `(fragment as any).content`). A few load-bearing `any` uses were preserved with scoped disable comments where changing the type would cascade widely (Sequelize JSONB columns on `Event`, the `withTracing` higher-order function generic, `Extension.options` consumed by many subclasses, dd-trace's `req` patching). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
83 lines
2.5 KiB
TypeScript
83 lines
2.5 KiB
TypeScript
import { version } from "../../package.json";
|
|
import Logger from "@server/logging/Logger";
|
|
import fetch from "./fetch";
|
|
|
|
const dockerhubLink =
|
|
"https://hub.docker.com/v2/repositories/outlinewiki/outline";
|
|
|
|
function isFullReleaseVersion(versionName: string): boolean {
|
|
const releaseRegex = /^(version-)?\d+\.\d+\.\d+$/; // Matches "N.N.N" or "version-N.N.N" for dockerhub releases before v0.56.0"
|
|
return releaseRegex.test(versionName);
|
|
}
|
|
|
|
export async function getVersionInfo(currentVersion: string): Promise<{
|
|
latestVersion: string;
|
|
versionsBehind: number;
|
|
}> {
|
|
try {
|
|
let allVersions: string[] = [];
|
|
let latestVersion: string | null = null;
|
|
let nextUrl: string | null =
|
|
dockerhubLink + "/tags?name=&ordering=last_updated&page_size=100";
|
|
|
|
// Continue fetching pages until the required versions are found or no more pages
|
|
while (nextUrl) {
|
|
const response = await fetch(nextUrl);
|
|
const data = (await response.json()) as {
|
|
results: { name: string }[];
|
|
next?: string | null;
|
|
};
|
|
|
|
// Map and filter the versions to keep only full releases
|
|
const pageVersions = data.results
|
|
.map((result) => result.name)
|
|
.filter(isFullReleaseVersion);
|
|
|
|
allVersions = allVersions.concat(pageVersions);
|
|
|
|
// Set the latest version if not already set
|
|
if (!latestVersion && pageVersions.length > 0) {
|
|
latestVersion = pageVersions[0];
|
|
}
|
|
|
|
// Check if the current version is found
|
|
const currentIndex = allVersions.findIndex(
|
|
(version: string) => version === currentVersion
|
|
);
|
|
|
|
if (currentIndex !== -1) {
|
|
const versionsBehind = currentIndex; // The number of versions behind
|
|
return {
|
|
latestVersion: latestVersion || currentVersion, // Fallback to current if no latest found
|
|
versionsBehind,
|
|
};
|
|
}
|
|
|
|
nextUrl = data.next || null;
|
|
}
|
|
|
|
return {
|
|
latestVersion: latestVersion || currentVersion,
|
|
versionsBehind: -1, // Return -1 if current version is not found
|
|
};
|
|
} catch (error) {
|
|
Logger.warn(
|
|
"Failed to fetch version information from Docker Hub. This is expected in isolated environments.",
|
|
{
|
|
currentVersion,
|
|
error: error instanceof Error ? error.message : String(error),
|
|
}
|
|
);
|
|
|
|
// Return fallback values when external request fails
|
|
return {
|
|
latestVersion: currentVersion,
|
|
versionsBehind: -1,
|
|
};
|
|
}
|
|
}
|
|
|
|
export function getVersion(): string {
|
|
return version;
|
|
}
|