From 246018e04157a8b7531c3d25384b2da6f29083ed Mon Sep 17 00:00:00 2001 From: Mario Campos Date: Tue, 11 Aug 2026 15:25:46 -0500 Subject: [PATCH] Move `VersionInfo` to dedicated module --- src/cli/output-cache.ts | 3 ++- src/cli/types.ts | 13 +++++++++++++ src/codeql.ts | 15 +-------------- src/testing-utils.ts | 3 ++- src/tools-features.ts | 2 +- src/util.ts | 3 ++- 6 files changed, 21 insertions(+), 18 deletions(-) create mode 100644 src/cli/types.ts diff --git a/src/cli/output-cache.ts b/src/cli/output-cache.ts index e7faa0005..957dfd3b4 100644 --- a/src/cli/output-cache.ts +++ b/src/cli/output-cache.ts @@ -2,10 +2,11 @@ import * as fs from "fs"; import path from "path"; import { getTemporaryDirectory } from "../actions-util"; -import { VersionInfo } from "../codeql"; import { Env, getEnv } from "../environment"; import { isPersistedVersionInfo } from "../util"; +import type { VersionInfo } from "./types"; + /** * The name of the temporary file that backs the on-disk cache of * CLI responses between workflow steps. diff --git a/src/cli/types.ts b/src/cli/types.ts new file mode 100644 index 000000000..ad48ff29b --- /dev/null +++ b/src/cli/types.ts @@ -0,0 +1,13 @@ +export interface VersionInfo { + version: string; + features?: { [name: string]: boolean }; + /** + * The overlay version helps deal with backward incompatible changes for + * overlay analysis. When a precompiled query pack reports the same overlay + * version as the CodeQL CLI, we can use the CodeQL CLI to perform overlay + * analysis with that pack. Otherwise, if the overlay versions are different, + * or if either the pack or the CLI does not report an overlay version, + * we need to revert to non-overlay analysis. + */ + overlayVersion?: number; +} diff --git a/src/codeql.ts b/src/codeql.ts index db017f1f5..fecc155bb 100644 --- a/src/codeql.ts +++ b/src/codeql.ts @@ -13,6 +13,7 @@ import { } from "./actions-util"; import * as api from "./api-client"; import * as outputCache from "./cli/output-cache"; +import type { VersionInfo } from "./cli/types"; import { CliError, wrapCliConfigurationError } from "./cli-errors"; import { appendExtraQueryExclusions, type Config } from "./config-utils"; import { DocUrl } from "./doc-url"; @@ -216,20 +217,6 @@ export interface CodeQL { ): Promise; } -export interface VersionInfo { - version: string; - features?: { [name: string]: boolean }; - /** - * The overlay version helps deal with backward incompatible changes for - * overlay analysis. When a precompiled query pack reports the same overlay - * version as the CodeQL CLI, we can use the CodeQL CLI to perform overlay - * analysis with that pack. Otherwise, if the overlay versions are different, - * or if either the pack or the CLI does not report an overlay version, - * we need to revert to non-overlay analysis. - */ - overlayVersion?: number; -} - export interface ResolveDatabaseOutput { overlayBaseSpecifier?: string; } diff --git a/src/testing-utils.ts b/src/testing-utils.ts index f25356923..e4f26daa0 100644 --- a/src/testing-utils.ts +++ b/src/testing-utils.ts @@ -19,6 +19,7 @@ import * as apiClient from "./api-client"; import { GitHubApiDetails } from "./api-client"; import { CachingKind } from "./caching-utils"; import { resetCachedCodeQlVersion } from "./cli/output-cache"; +import type { VersionInfo } from "./cli/types"; import * as codeql from "./codeql"; import { Config } from "./config-utils"; import * as defaults from "./defaults.json"; @@ -872,7 +873,7 @@ export const makeVersionInfo = ( version: string, features?: { [name: string]: boolean }, overlayVersion?: number, -): codeql.VersionInfo => ({ +): VersionInfo => ({ version, features, overlayVersion, diff --git a/src/tools-features.ts b/src/tools-features.ts index ff87b754d..4931be65b 100644 --- a/src/tools-features.ts +++ b/src/tools-features.ts @@ -1,6 +1,6 @@ import * as semver from "semver"; -import type { VersionInfo } from "./codeql"; +import type { VersionInfo } from "./cli/types"; export enum ToolsFeature { BuiltinExtractorsSpecifyDefaultQueries = "builtinExtractorsSpecifyDefaultQueries", diff --git a/src/util.ts b/src/util.ts index 572afd6d1..e691a7c17 100644 --- a/src/util.ts +++ b/src/util.ts @@ -10,7 +10,8 @@ import * as yaml from "js-yaml"; import * as semver from "semver"; import * as apiCompatibility from "./api-compatibility.json"; -import type { CodeQL, VersionInfo } from "./codeql"; +import type { VersionInfo } from "./cli/types"; +import type { CodeQL } from "./codeql"; import type { Pack } from "./config/db-config"; import type { Config } from "./config-utils"; import { EnvVar, getRequiredEnvParam } from "./environment";