import type { Action, DependencyVersions } from "@garden-io/grow-sdk/actions/action"; import type { ActionConfigInput } from "@garden-io/grow-sdk/actions/types"; import type { ActionType } from "@garden-io/grow-sdk/declarations/action-type"; import { TreeCache } from "../cache"; import type { GrowContext } from "../context"; import type { ExternalSourceType } from "../ext-sources"; import type { Log } from "../logger/log-entry"; import type { Profiler } from "../util/profiling"; export declare const NEW_RESOURCE_VERSION = "0000000000"; export declare const gitVersionRegex: RegExp; /** * throws if no git is installed or version is too old */ export declare function validateGitInstall(): Promise; export interface TreeVersion { contentHash: string; /** * Important! Do not use the files to determine if a file will exist when performing an action. * Other mechanisms, e.g. the build command itself and `copyFrom` might affect available files at runtime. * * See also https://github.com/garden-io/garden/issues/5201 */ files: string[]; } export interface TreeVersions { [key: string]: TreeVersion; } export interface ModuleVersion extends TreeVersion { versionString: string; dependencyVersions: DependencyVersions; } export interface NamedModuleVersion extends ModuleVersion { name: string; } export interface NamedTreeVersion extends TreeVersion { name: string; } export interface VcsInfo { branch: string; commitHash: string; originUrl: string; } export type ActionDescription = `action ${string}`; export type ActionRoot = `${ActionDescription} root`; export type RepoPathDescription = "directory" | "repository" | "submodule" | "project root" | ActionRoot; export interface GetFilesParams { log: Log; path: string; pathDescription?: RepoPathDescription; include?: string[]; exclude?: string[]; filter?: (path: string) => boolean; failOnPrompt?: boolean; scanRoot: string | undefined; } export interface BaseIncludeExcludeFiles { include?: string[]; exclude: string[]; } export type IncludeExcludeFilesHandler = (params: T) => Promise; export interface GetTreeVersionParams { log: Log; action: Action; scanRoot: string | undefined; force?: boolean; } export interface RemoteSourceParams { url: string; name: string; sourceType: ExternalSourceType; log: Log; failOnPrompt?: boolean; } export interface VcsFile { path: string; hash: string; } export interface VcsHandlerParams { context?: GrowContext; growRoot: string; growMetadataDirPath: string; ignoreFile: string; } export declare abstract class VcsHandler { protected readonly growRoot: string; protected readonly context?: GrowContext; protected readonly growMetadataDirPath: string; protected readonly ignoreFile: string; protected readonly profiler: Profiler; readonly cache: TreeCache; protected constructor(params: VcsHandlerParams); abstract readonly name: string; abstract getRepoRoot(log: Log, path: string): Promise; /** * Scans the repository returns the list of the tracked files. * Applies Grow's exclude/include filters and .dotignore files. * * Does NOT sort the results by paths and filenames. */ abstract getFiles(params: GetFilesParams): Promise; abstract ensureRemoteSource(params: RemoteSourceParams): Promise; abstract updateRemoteSource(params: RemoteSourceParams): Promise; abstract getPathInfo(log: Log, path: string): Promise; clearTreeCache(): void; getTreeVersion({ log, action, force, scanRoot, }: GetTreeVersionParams): Promise; /** * Write a file and ensure relevant caches are invalidated after writing. */ writeFile(log: Log, path: string, data: string | NodeJS.ArrayBufferView): Promise; /** * Returns a map of the optimal paths for each of the given action source path. * This is used to avoid scanning more of each git repository than necessary, and * reduces duplicate scanning of the same directories (since fewer unique roots mean * more tree cache hits). */ getMinimalRoots(log: Log, paths: string[]): Promise<{ [path: string]: string; }>; /** * Returns the absolute path to the local directory for all remote sources */ getRemoteSourcesLocalPath(type: ExternalSourceType): string; /** * Returns the absolute path to the local directory for the remote source */ getRemoteSourceLocalPath(name: string, url: string, type: ExternalSourceType): string; } export declare function getResourceTreeCacheKey(action: Action): string[]; export declare function describeConfig(config: ActionConfigInput): ActionDescription; /** * Checks if the {@code subPathCandidate} is a sub-path of {@code basePath}. * Sub-path means that a candidate must be located inside a reference path. * * Both {@code basePath} and {@code subPathCandidate} must be absolute paths * * @param basePath the reference path (absolute) * @param subPathCandidate the path to be checked (absolute) */ export declare function isSubPath(basePath: string, subPathCandidate: string): boolean;