Move VersionInfo-related types to cli/output-cache.ts

This brings them out of the crowded all-purpose `util.ts` and into `cli/output-cache.ts` where they are exclusively used.
This commit is contained in:
Mario Campos
2026-08-11 15:35:03 -05:00
parent 246018e041
commit 0a99875ae5
3 changed files with 48 additions and 42 deletions

20
lib/entry-points.js generated
View File

@@ -145241,14 +145241,6 @@ function asHTTPError(arg) {
} }
return void 0; return void 0;
} }
function isVersionInfo(x) {
const candidate = x;
return typeof candidate === "object" && candidate !== null && typeof candidate.version === "string" && (candidate.features === void 0 || typeof candidate.features === "object" && candidate.features !== null) && (candidate.overlayVersion === void 0 || typeof candidate.overlayVersion === "number");
}
function isPersistedVersionInfo(x) {
const candidate = x;
return typeof candidate === "object" && candidate !== null && typeof candidate.cmd === "string" && isVersionInfo(candidate.version);
}
async function codeQlVersionAtLeast(codeql, requiredVersion) { async function codeQlVersionAtLeast(codeql, requiredVersion) {
return semver.gte((await codeql.getVersion()).version, requiredVersion); return semver.gte((await codeql.getVersion()).version, requiredVersion);
} }
@@ -146292,6 +146284,14 @@ function getCachedCodeQlVersion(cmd, env = getEnv()) {
cachedCodeQlVersion = persisted.version; cachedCodeQlVersion = persisted.version;
return cachedCodeQlVersion; return cachedCodeQlVersion;
} }
function isVersionInfo(x) {
const candidate = x;
return typeof candidate === "object" && candidate !== null && typeof candidate.version === "string" && (candidate.features === void 0 || typeof candidate.features === "object" && candidate.features !== null) && (candidate.overlayVersion === void 0 || typeof candidate.overlayVersion === "number");
}
function isPersistedVersionInfo(x) {
const candidate = x;
return typeof candidate === "object" && candidate !== null && typeof candidate.cmd === "string" && isVersionInfo(candidate.version);
}
// src/config/pack-registries.ts // src/config/pack-registries.ts
function parseRegistries(registriesInput) { function parseRegistries(registriesInput) {
@@ -157827,7 +157827,7 @@ var import_async = __toESM(require_async(), 1);
var import_path7 = require("path"); var import_path7 = require("path");
// node_modules/archiver/lib/error.js // node_modules/archiver/lib/error.js
var import_util35 = __toESM(require("util"), 1); var import_util34 = __toESM(require("util"), 1);
var ERROR_CODES = { var ERROR_CODES = {
ABORTED: "archive was aborted", ABORTED: "archive was aborted",
DIRECTORYDIRPATHREQUIRED: "diretory dirpath argument must be a non-empty string value", DIRECTORYDIRPATHREQUIRED: "diretory dirpath argument must be a non-empty string value",
@@ -157852,7 +157852,7 @@ function ArchiverError(code, data) {
this.code = code; this.code = code;
this.data = data; this.data = data;
} }
import_util35.default.inherits(ArchiverError, Error); import_util34.default.inherits(ArchiverError, Error);
// node_modules/archiver/lib/core.js // node_modules/archiver/lib/core.js
var import_readable_stream2 = __toESM(require_ours(), 1); var import_readable_stream2 = __toESM(require_ours(), 1);

View File

@@ -3,10 +3,15 @@ import path from "path";
import { getTemporaryDirectory } from "../actions-util"; import { getTemporaryDirectory } from "../actions-util";
import { Env, getEnv } from "../environment"; import { Env, getEnv } from "../environment";
import { isPersistedVersionInfo } from "../util";
import type { VersionInfo } from "./types"; import type { VersionInfo } from "./types";
/** The persisted version together with the CLI path it was obtained from. */
interface PersistedVersionInfo {
cmd: string;
version: VersionInfo;
}
/** /**
* The name of the temporary file that backs the on-disk cache of * The name of the temporary file that backs the on-disk cache of
* CLI responses between workflow steps. * CLI responses between workflow steps.
@@ -99,3 +104,35 @@ export function getCachedCodeQlVersion(
cachedCodeQlVersion = persisted.version; cachedCodeQlVersion = persisted.version;
return cachedCodeQlVersion; return cachedCodeQlVersion;
} }
/**
* Determines whether a value is a `VersionInfo` object.
* @param x The value to test
*/
function isVersionInfo(x: unknown): x is VersionInfo {
const candidate = x as Partial<VersionInfo> | null;
return (
typeof candidate === "object" &&
candidate !== null &&
typeof candidate.version === "string" &&
(candidate.features === undefined ||
(typeof candidate.features === "object" &&
candidate.features !== null)) &&
(candidate.overlayVersion === undefined ||
typeof candidate.overlayVersion === "number")
);
}
/**
* Determines whether a value is a `PersistedVersionInfo` object.
* @param x The value to test
*/
function isPersistedVersionInfo(x: unknown): x is PersistedVersionInfo {
const candidate = x as Partial<PersistedVersionInfo> | null;
return (
typeof candidate === "object" &&
candidate !== null &&
typeof candidate.cmd === "string" &&
isVersionInfo(candidate.version)
);
}

View File

@@ -10,7 +10,6 @@ import * as yaml from "js-yaml";
import * as semver from "semver"; import * as semver from "semver";
import * as apiCompatibility from "./api-compatibility.json"; import * as apiCompatibility from "./api-compatibility.json";
import type { VersionInfo } from "./cli/types";
import type { CodeQL } from "./codeql"; import type { CodeQL } from "./codeql";
import type { Pack } from "./config/db-config"; import type { Pack } from "./config/db-config";
import type { Config } from "./config-utils"; import type { Config } from "./config-utils";
@@ -599,36 +598,6 @@ export function asHTTPError(arg: any): HTTPError | undefined {
return undefined; return undefined;
} }
/** The persisted version together with the CLI path it was obtained from. */
interface PersistedVersionInfo {
cmd: string;
version: VersionInfo;
}
function isVersionInfo(x: unknown): x is VersionInfo {
const candidate = x as Partial<VersionInfo> | null;
return (
typeof candidate === "object" &&
candidate !== null &&
typeof candidate.version === "string" &&
(candidate.features === undefined ||
(typeof candidate.features === "object" &&
candidate.features !== null)) &&
(candidate.overlayVersion === undefined ||
typeof candidate.overlayVersion === "number")
);
}
export function isPersistedVersionInfo(x: unknown): x is PersistedVersionInfo {
const candidate = x as Partial<PersistedVersionInfo> | null;
return (
typeof candidate === "object" &&
candidate !== null &&
typeof candidate.cmd === "string" &&
isVersionInfo(candidate.version)
);
}
export async function codeQlVersionAtLeast( export async function codeQlVersionAtLeast(
codeql: CodeQL, codeql: CodeQL,
requiredVersion: string, requiredVersion: string,