diff --git a/lib/config/presets/types.ts b/lib/config/presets/types.ts index 329f933e6549837ac0ae88ba2859d2d1e52438a6..4833c59b5cdbfc833b9b804dbdd43e5d258f333d 100644 --- a/lib/config/presets/types.ts +++ b/lib/config/presets/types.ts @@ -21,3 +21,17 @@ export interface ParsedPreset { presetName: string; params?: string[]; } + +export type PresetFetcher = ( + repo: string, + fileName: string, + endpoint: string +) => Promise<Preset>; + +export type FetchPresetConfig = { + pkgName: string; + filePreset: string; + presetPath?: string; + endpoint: string; + fetch: PresetFetcher; +}; diff --git a/lib/config/presets/util.spec.ts b/lib/config/presets/util.spec.ts index a4a9ff908ac15ee5f6736ddb4037b01644390fd1..752dc8fff6600b5989647c60b4dfc160de1ffd0c 100644 --- a/lib/config/presets/util.spec.ts +++ b/lib/config/presets/util.spec.ts @@ -1,11 +1,6 @@ import { getName } from '../../../test/util'; -import type { Preset } from './types'; -import { - FetchPresetConfig, - PRESET_DEP_NOT_FOUND, - PRESET_NOT_FOUND, - fetchPreset, -} from './util'; +import type { FetchPresetConfig, Preset } from './types'; +import { PRESET_DEP_NOT_FOUND, PRESET_NOT_FOUND, fetchPreset } from './util'; const config: FetchPresetConfig = { pkgName: 'some/repo', diff --git a/lib/config/presets/util.ts b/lib/config/presets/util.ts index 6d224a8c1552519be4d2d211abdb1a85fe7ef2ac..f14573cc377b122f610540a8b6885fd713627bb0 100644 --- a/lib/config/presets/util.ts +++ b/lib/config/presets/util.ts @@ -1,6 +1,6 @@ import { logger } from '../../logger'; import { ensureTrailingSlash } from '../../util/url'; -import type { Preset } from './types'; +import type { FetchPresetConfig, Preset } from './types'; export const PRESET_DEP_NOT_FOUND = 'dep not found'; export const PRESET_INVALID = 'invalid preset'; @@ -10,20 +10,6 @@ export const PRESET_PROHIBITED_SUBPRESET = 'prohibited sub-preset'; export const PRESET_RENOVATE_CONFIG_NOT_FOUND = 'preset renovate-config not found'; -export type PresetFetcher = ( - repo: string, - fileName: string, - endpoint: string -) => Promise<Preset>; - -export type FetchPresetConfig = { - pkgName: string; - filePreset: string; - presetPath?: string; - endpoint: string; - fetch: PresetFetcher; -}; - export async function fetchPreset({ pkgName, filePreset, diff --git a/lib/datasource/github-releases/index.ts b/lib/datasource/github-releases/index.ts index a505dd7424926e428504b2a88981788b0bac4720..4fe6e5469e3fae9bfb219b5f4e0757ba02f4f833 100644 --- a/lib/datasource/github-releases/index.ts +++ b/lib/datasource/github-releases/index.ts @@ -2,6 +2,7 @@ import * as packageCache from '../../util/cache/package'; import { GithubHttp } from '../../util/http/github'; import { ensureTrailingSlash } from '../../util/url'; import type { GetReleasesConfig, ReleaseResult } from '../types'; +import type { GithubRelease } from './types'; export const id = 'github-releases'; export const customRegistrySupport = true; @@ -17,12 +18,6 @@ function getCacheKey(depHost: string, repo: string): string { return `${depHost}:${repo}:${type}`; } -type GithubRelease = { - tag_name: string; - published_at: string; - prerelease: boolean; -}; - /** * github.getReleases * diff --git a/lib/datasource/github-releases/types.ts b/lib/datasource/github-releases/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..48ca80461ecabd535d5a5a346e71518b56a4b289 --- /dev/null +++ b/lib/datasource/github-releases/types.ts @@ -0,0 +1,5 @@ +export type GithubRelease = { + tag_name: string; + published_at: string; + prerelease: boolean; +}; diff --git a/lib/datasource/gitlab-tags/index.ts b/lib/datasource/gitlab-tags/index.ts index bb9c0f3c95075d1ae9a92ce2493341199ef9fcb3..6c93462dc32ef4cd8f7e45bc679d96f1b2b666f4 100644 --- a/lib/datasource/gitlab-tags/index.ts +++ b/lib/datasource/gitlab-tags/index.ts @@ -2,6 +2,7 @@ import URL from 'url'; import * as packageCache from '../../util/cache/package'; import { GitlabHttp } from '../../util/http/gitlab'; import type { GetReleasesConfig, ReleaseResult } from '../types'; +import type { GitlabTag } from './types'; const gitlabApi = new GitlabHttp(); @@ -11,18 +12,12 @@ export const defaultRegistryUrls = ['https://gitlab.com']; export const registryStrategy = 'first'; const cacheNamespace = 'datasource-gitlab'; + function getCacheKey(depHost: string, repo: string): string { const type = 'tags'; return `${depHost}:${repo}:${type}`; } -type GitlabTag = { - name: string; - commit?: { - created_at?: string; - }; -}; - export async function getReleases({ registryUrl: depHost, lookupName: repo, diff --git a/lib/datasource/gitlab-tags/types.ts b/lib/datasource/gitlab-tags/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..47d6ee66bda8bcb4492d6c72766f08ecf1cab5d5 --- /dev/null +++ b/lib/datasource/gitlab-tags/types.ts @@ -0,0 +1,6 @@ +export type GitlabTag = { + name: string; + commit?: { + created_at?: string; + }; +}; diff --git a/lib/datasource/maven/index.ts b/lib/datasource/maven/index.ts index 8ee4e527b475dfb2f2e93f183047fa5e7c023335..21b4bb26ac0cfc85c3bb5062100d2ba4cfcaa988 100644 --- a/lib/datasource/maven/index.ts +++ b/lib/datasource/maven/index.ts @@ -8,7 +8,11 @@ import * as mavenVersioning from '../../versioning/maven'; import { compare } from '../../versioning/maven/compare'; import type { GetReleasesConfig, Release, ReleaseResult } from '../types'; import { MAVEN_REPO } from './common'; -import type { MavenDependency } from './types'; +import type { + ArtifactInfoResult, + ArtifactsInfo, + MavenDependency, +} from './types'; import { downloadMavenXml, getDependencyInfo, @@ -80,8 +84,6 @@ async function getVersionsFromMetadata( return versions; } -type ArtifactsInfo = Record<string, boolean | null>; - // istanbul ignore next function isValidArtifactsInfo( info: ArtifactsInfo | null, @@ -93,8 +95,6 @@ function isValidArtifactsInfo( return versions.every((v) => info[v] !== undefined); } -type ArtifactInfoResult = [string, boolean | string | null]; - async function getArtifactInfo( version: string, artifactUrl: url.URL diff --git a/lib/datasource/maven/types.ts b/lib/datasource/maven/types.ts index 06d8fd4c211d262a4c502da23c3dd1ca5c693403..2d314a407874b65a9ab51eeb70ca5af91c60b2dd 100644 --- a/lib/datasource/maven/types.ts +++ b/lib/datasource/maven/types.ts @@ -11,3 +11,7 @@ export interface MavenXml { authorization?: boolean; xml?: XmlDocument; } + +export type ArtifactsInfo = Record<string, boolean | null>; + +export type ArtifactInfoResult = [string, boolean | string | null]; diff --git a/lib/datasource/pypi/index.ts b/lib/datasource/pypi/index.ts index 144e417ec8ea7668070e136bf3963a3ae0c8013f..f68d0afe2623c5e5190c76a1e1602b80404b1dff 100644 --- a/lib/datasource/pypi/index.ts +++ b/lib/datasource/pypi/index.ts @@ -6,6 +6,7 @@ import { Http } from '../../util/http'; import { ensureTrailingSlash } from '../../util/url'; import * as pep440 from '../../versioning/pep440'; import type { GetReleasesConfig, Release, ReleaseResult } from '../types'; +import type { PypiJSON, PypiJSONRelease, Releases } from './types'; export const id = 'pypi'; export const customRegistrySupport = true; @@ -19,22 +20,6 @@ export const caching = true; const githubRepoPattern = /^https?:\/\/github\.com\/[^\\/]+\/[^\\/]+$/; const http = new Http(id); -type PypiJSONRelease = { - requires_python?: string; - upload_time?: string; - yanked?: boolean; -}; -type Releases = Record<string, PypiJSONRelease[]>; -type PypiJSON = { - info: { - name: string; - home_page?: string; - project_urls?: Record<string, string>; - }; - - releases?: Releases; -}; - function normalizeName(input: string): string { return input.toLowerCase().replace(/(-|\.)/g, '_'); } diff --git a/lib/datasource/pypi/types.ts b/lib/datasource/pypi/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..b63ec776cd7e1a1227e7fc003f56dad3b8c70e9d --- /dev/null +++ b/lib/datasource/pypi/types.ts @@ -0,0 +1,15 @@ +export type PypiJSONRelease = { + requires_python?: string; + upload_time?: string; + yanked?: boolean; +}; +export type Releases = Record<string, PypiJSONRelease[]>; +export type PypiJSON = { + info: { + name: string; + home_page?: string; + project_urls?: Record<string, string>; + }; + + releases?: Releases; +}; diff --git a/lib/manager/azure-pipelines/extract.ts b/lib/manager/azure-pipelines/extract.ts index 06b946b3652c9a610e3a9017e2f6f74f05a7d765..8307542e9d8faebdc60b4ca389f774f543203975 100644 --- a/lib/manager/azure-pipelines/extract.ts +++ b/lib/manager/azure-pipelines/extract.ts @@ -3,25 +3,7 @@ import * as datasourceGitTags from '../../datasource/git-tags'; import { logger } from '../../logger'; import { getDep } from '../dockerfile/extract'; import type { PackageDependency, PackageFile } from '../types'; - -interface Container { - image: string; -} - -interface Repository { - type: 'git' | 'github' | 'bitbucket'; - name: string; - ref: string; -} - -interface Resources { - repositories: Repository[]; - containers: Container[]; -} - -interface AzurePipelines { - resources: Resources; -} +import type { AzurePipelines, Container, Repository } from './types'; export function extractRepository( repository: Repository diff --git a/lib/manager/azure-pipelines/types.ts b/lib/manager/azure-pipelines/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..708638e2006cc166ef9a2a7bcab6ef433ea89015 --- /dev/null +++ b/lib/manager/azure-pipelines/types.ts @@ -0,0 +1,15 @@ +export interface Container { + image: string; +} +export interface Repository { + type: 'git' | 'github' | 'bitbucket'; + name: string; + ref: string; +} +export interface Resources { + repositories: Repository[]; + containers: Container[]; +} +export interface AzurePipelines { + resources: Resources; +} diff --git a/lib/manager/batect/extract.ts b/lib/manager/batect/extract.ts index c75c05b10d43814621f007c036c734b54b018451..1062361f69e823987c004075a6c8bde8d93e8694 100644 --- a/lib/manager/batect/extract.ts +++ b/lib/manager/batect/extract.ts @@ -1,6 +1,5 @@ import { safeLoad } from 'js-yaml'; import * as upath from 'upath'; - import { id as gitTagDatasource } from '../../datasource/git-tags'; import { logger } from '../../logger'; import { readLocalFile } from '../../util/fs'; @@ -13,6 +12,7 @@ import type { BatectFileInclude, BatectGitInclude, BatectInclude, + ExtractionResult, } from './types'; function loadConfig(content: string): BatectConfig { @@ -116,11 +116,6 @@ function extractReferencedConfigFiles( return paths.map((p) => upath.join(dirName, p)); } -interface ExtractionResult { - deps: PackageDependency[]; - referencedConfigFiles: string[]; -} - export function extractPackageFile( content: string, fileName: string diff --git a/lib/manager/batect/types.ts b/lib/manager/batect/types.ts index 0495bbe86b73d4af39623b933f07e3886637d0d0..c5a1765e7060cda3a85a55e30576c94004f427e8 100644 --- a/lib/manager/batect/types.ts +++ b/lib/manager/batect/types.ts @@ -1,3 +1,5 @@ +import type { PackageDependency } from '../types'; + export interface BatectConfig { containers?: Record<string, BatectContainer>; include?: BatectInclude[]; @@ -19,3 +21,8 @@ export interface BatectGitInclude { repo: string; ref: string; } + +export interface ExtractionResult { + deps: PackageDependency[]; + referencedConfigFiles: string[]; +} diff --git a/lib/manager/bazel/extract.ts b/lib/manager/bazel/extract.ts index 197e801b666bd8de882e4356263ac72f01a28dfa..2c2d534fef9e71877a42570a7d48e8858cd3f666 100644 --- a/lib/manager/bazel/extract.ts +++ b/lib/manager/bazel/extract.ts @@ -10,12 +10,7 @@ import { logger } from '../../logger'; import { SkipReason } from '../../types'; import * as dockerVersioning from '../../versioning/docker'; import type { PackageDependency, PackageFile } from '../types'; - -interface UrlParsedResult { - datasource: string; - repo: string; - currentValue: string; -} +import type { UrlParsedResult } from './types'; function parseUrl(urlString: string): UrlParsedResult | null { // istanbul ignore if diff --git a/lib/manager/bazel/types.ts b/lib/manager/bazel/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..78960463e54b0d55de9862c1ee75bb070ccd50f3 --- /dev/null +++ b/lib/manager/bazel/types.ts @@ -0,0 +1,5 @@ +export interface UrlParsedResult { + datasource: string; + repo: string; + currentValue: string; +} diff --git a/lib/manager/cocoapods/extract.ts b/lib/manager/cocoapods/extract.ts index c6f88feba65ae84c208563618789e3c22066f535..1f15a83065d99f4ffe7d08646d50367c1d6c180a 100644 --- a/lib/manager/cocoapods/extract.ts +++ b/lib/manager/cocoapods/extract.ts @@ -4,6 +4,7 @@ import { logger } from '../../logger'; import { SkipReason } from '../../types'; import { getSiblingFileName, localPathExists } from '../../util/fs'; import type { PackageDependency, PackageFile } from '../types'; +import type { ParsedLine } from './types'; const regexMappings = [ /^\s*pod\s+(['"])(?<spec>[^'"/]+)(\/(?<subspec>[^'"]+))?\1/, @@ -14,18 +15,6 @@ const regexMappings = [ /^\s*source\s*(['"])(?<source>[^'"]+)\1/, ]; -export interface ParsedLine { - depName?: string; - groupName?: string; - spec?: string; - subspec?: string; - currentValue?: string; - git?: string; - tag?: string; - path?: string; - source?: string; -} - export function parseLine(line: string): ParsedLine { let result: ParsedLine = {}; if (!line) { diff --git a/lib/manager/cocoapods/types.ts b/lib/manager/cocoapods/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..74fef13b828c8fe927549a066f1fb8de95cb563a --- /dev/null +++ b/lib/manager/cocoapods/types.ts @@ -0,0 +1,11 @@ +export interface ParsedLine { + depName?: string; + groupName?: string; + spec?: string; + subspec?: string; + currentValue?: string; + git?: string; + tag?: string; + path?: string; + source?: string; +} diff --git a/lib/manager/composer/artifacts.ts b/lib/manager/composer/artifacts.ts index 229c629cbf9da1bf594b2d0dca6c64492f35e441..eee7d89949278d29f7af6929ef8ecf8a715c38c0 100644 --- a/lib/manager/composer/artifacts.ts +++ b/lib/manager/composer/artifacts.ts @@ -25,20 +25,9 @@ import { import { getRepoStatus } from '../../util/git'; import * as hostRules from '../../util/host-rules'; import type { UpdateArtifact, UpdateArtifactsResult } from '../types'; +import type { AuthJson } from './types'; import { composerVersioningId, getConstraint } from './utils'; -interface UserPass { - username: string; - password: string; -} - -interface AuthJson { - 'github-oauth'?: Record<string, string>; - 'gitlab-token'?: Record<string, string>; - 'gitlab-domains'?: string[]; - 'http-basic'?: Record<string, UserPass>; -} - function getAuthJson(): string | null { const authJson: AuthJson = {}; diff --git a/lib/manager/composer/range.ts b/lib/manager/composer/range.ts index 65212e27cd0c009d0a4ae73f27f3ed062efdac33..325578e66a97dfe1406ab09854a6ed01b60183a7 100644 --- a/lib/manager/composer/range.ts +++ b/lib/manager/composer/range.ts @@ -1,7 +1,7 @@ import { logger } from '../../logger'; import type { RangeStrategy } from '../../types'; import type { RangeConfig } from '../types'; -import { ComposerManagerData } from './types'; +import type { ComposerManagerData } from './types'; export function getRangeStrategy(config: RangeConfig): RangeStrategy { const { diff --git a/lib/manager/composer/types.ts b/lib/manager/composer/types.ts index 2b421f7edcd3bd4e2b279a34aeada5b50249bf8d..3e34fe8604ccac5469ef4c70860f95999eae97e8 100644 --- a/lib/manager/composer/types.ts +++ b/lib/manager/composer/types.ts @@ -34,3 +34,15 @@ export interface ComposerLock { export interface ComposerManagerData { composerJsonType?: string; } + +export interface UserPass { + username: string; + password: string; +} + +export interface AuthJson { + 'github-oauth'?: Record<string, string>; + 'gitlab-token'?: Record<string, string>; + 'gitlab-domains'?: string[]; + 'http-basic'?: Record<string, UserPass>; +} diff --git a/lib/manager/docker-compose/extract.ts b/lib/manager/docker-compose/extract.ts index 43be4a262a03c5550c14178b5e497408ad8da3df..7e276b0db50bca837153e7e0e23dceff9e610b9d 100644 --- a/lib/manager/docker-compose/extract.ts +++ b/lib/manager/docker-compose/extract.ts @@ -3,19 +3,7 @@ import { safeLoad } from 'js-yaml'; import { logger } from '../../logger'; import { getDep } from '../dockerfile/extract'; import type { PackageFile } from '../types'; - -interface DockerComposeConfig { - version?: string; - services?: Record<string, DockerComposeService>; -} - -interface DockerComposeService { - image?: string; - build?: { - context?: string; - dockerfile?: string; - }; -} +import type { DockerComposeConfig } from './types'; class LineMapper { private imageLines: { line: string; lineNumber: number; used: boolean }[]; @@ -47,7 +35,7 @@ export function extractPackageFile( let config: DockerComposeConfig; try { // TODO: fix me (#9610) - config = safeLoad(content, { json: true }) as unknown; + config = safeLoad(content, { json: true }) as DockerComposeConfig; if (!config) { logger.debug( { fileName }, diff --git a/lib/manager/docker-compose/types.ts b/lib/manager/docker-compose/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..25495d806264d48412a30884fff8c2a04a48a83e --- /dev/null +++ b/lib/manager/docker-compose/types.ts @@ -0,0 +1,12 @@ +export type DockerComposeConfig = { + version?: string; + services?: Record<string, DockerComposeService>; +} & Record<string, DockerComposeService>; + +export interface DockerComposeService { + image?: string; + build?: { + context?: string; + dockerfile?: string; + }; +} diff --git a/lib/manager/git-submodules/extract.ts b/lib/manager/git-submodules/extract.ts index 50e3e667c64834b1b58c1f2f0cbad8d174402067..ac41b7f6b7cf52d935c21b36d37bffb1a51106e2 100644 --- a/lib/manager/git-submodules/extract.ts +++ b/lib/manager/git-submodules/extract.ts @@ -5,11 +5,7 @@ import * as datasourceGitRefs from '../../datasource/git-refs'; import { logger } from '../../logger'; import { getHttpUrl, getRemoteUrlWithToken } from '../../util/git/url'; import type { ManagerConfig, PackageFile } from '../types'; - -type GitModule = { - name: string; - path: string; -}; +import { GitModule } from './types'; async function getUrl( git: SimpleGit, diff --git a/lib/manager/git-submodules/types.ts b/lib/manager/git-submodules/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..24fb38a15a8ecbd8d25cbc7de739e1e96ef6c5d5 --- /dev/null +++ b/lib/manager/git-submodules/types.ts @@ -0,0 +1,4 @@ +export type GitModule = { + name: string; + path: string; +}; diff --git a/lib/manager/gradle-lite/common.ts b/lib/manager/gradle-lite/common.ts index 3ef9d3c020dccc2f40b7ce68c991634beafd0880..5cf3d4dac202a60cc8211a3eb23dabf858a04adc 100644 --- a/lib/manager/gradle-lite/common.ts +++ b/lib/manager/gradle-lite/common.ts @@ -1,23 +1,9 @@ -import type { PackageDependency } from '../types'; - export { MAVEN_REPO } from '../../datasource/maven/common'; export const JCENTER_REPO = 'https://jcenter.bintray.com/'; export const GOOGLE_REPO = 'https://dl.google.com/android/maven2/'; -export interface ManagerData { - fileReplacePosition: number; - packageFile?: string; -} - -export interface VariableData extends ManagerData { - key: string; - value: string; -} - -export type PackageVariables = Record<string, VariableData>; -export type VariableRegistry = Record<string, PackageVariables>; - +// TODO: convert to types export enum TokenType { Space = 'space', LineComment = 'lineComment', @@ -62,43 +48,3 @@ export enum TokenType { UnknownFragment = 'unknownFragment', } - -export interface Token { - type: TokenType; - value: string; - offset: number; -} - -export interface StringInterpolation extends Token { - type: TokenType.StringInterpolation; - children: Token[]; // Tokens inside double-quoted string that are subject of interpolation - isComplete: boolean; // True if token has parsed completely - isValid: boolean; // False if string contains something unprocessable -} - -// Matcher on single token -export interface SyntaxMatcher { - matchType: TokenType | TokenType[]; - matchValue?: string | string[]; - lookahead?: boolean; - tokenMapKey?: string; -} - -export type TokenMap = Record<string, Token>; - -export interface SyntaxHandlerInput { - packageFile: string; - variables: PackageVariables; - tokenMap: TokenMap; -} - -export type SyntaxHandlerOutput = { - deps?: PackageDependency<ManagerData>[]; - vars?: PackageVariables; - urls?: string[]; -} | null; - -export interface SyntaxMatchConfig { - matchers: SyntaxMatcher[]; - handler: (MatcherHandlerInput) => SyntaxHandlerOutput; -} diff --git a/lib/manager/gradle-lite/extract.ts b/lib/manager/gradle-lite/extract.ts index 80c5db748b9788e748eef4167b49a0d9b50bd9f9..d6a8fe9aeb2b1b74d2bc07a91c6df365c1f8e821 100644 --- a/lib/manager/gradle-lite/extract.ts +++ b/lib/manager/gradle-lite/extract.ts @@ -3,8 +3,8 @@ import { id as datasource, defaultRegistryUrls } from '../../datasource/maven'; import { logger } from '../../logger'; import { readLocalFile } from '../../util/fs'; import type { ExtractConfig, PackageDependency, PackageFile } from '../types'; -import type { ManagerData, PackageVariables, VariableRegistry } from './common'; import { parseGradle, parseProps } from './parser'; +import type { ManagerData, PackageVariables, VariableRegistry } from './types'; import { getVars, isGradleFile, diff --git a/lib/manager/gradle-lite/parser.ts b/lib/manager/gradle-lite/parser.ts index 5827c9de082da20da666b2ffe3a3d7a8d218ad25..f20432155e382cf5fd6272cce46a5acfd1829f64 100644 --- a/lib/manager/gradle-lite/parser.ts +++ b/lib/manager/gradle-lite/parser.ts @@ -3,12 +3,13 @@ import is from '@sindresorhus/is'; import { logger } from '../../logger'; import { regEx } from '../../util/regex'; import type { PackageDependency } from '../types'; -import { - GOOGLE_REPO, - JCENTER_REPO, - MAVEN_REPO, +import { GOOGLE_REPO, JCENTER_REPO, MAVEN_REPO, TokenType } from './common'; +import { tokenize } from './tokenizer'; +import type { ManagerData, + MatchConfig, PackageVariables, + ParseGradleResult, StringInterpolation, SyntaxHandlerInput, SyntaxHandlerOutput, @@ -16,10 +17,8 @@ import { SyntaxMatcher, Token, TokenMap, - TokenType, VariableData, -} from './common'; -import { tokenize } from './tokenizer'; +} from './types'; import { interpolateString, isDependencyString, @@ -487,12 +486,6 @@ const matcherConfigs: SyntaxMatchConfig[] = [ }, ]; -interface MatchConfig { - tokens: Token[]; - variables: PackageVariables; - packageFile: string; -} - function tryMatch({ tokens, variables, @@ -515,12 +508,6 @@ function tryMatch({ return null; } -interface ParseGradleResult { - deps: PackageDependency<ManagerData>[]; - urls: string[]; - vars: PackageVariables; -} - export function parseGradle( input: string, initVars: PackageVariables = {}, diff --git a/lib/manager/gradle-lite/tokenizer.ts b/lib/manager/gradle-lite/tokenizer.ts index 0025b268d6eff475056aaad92459e2996b63928e..e9663268558fd35e2b5db718988b743a6c43ad88 100644 --- a/lib/manager/gradle-lite/tokenizer.ts +++ b/lib/manager/gradle-lite/tokenizer.ts @@ -1,5 +1,6 @@ import moo from 'moo'; -import { StringInterpolation, Token, TokenType } from './common'; +import { TokenType } from './common'; +import { StringInterpolation, Token } from './types'; const escapedCharRegex = /\\['"bfnrt\\]/; const escapedChars = { diff --git a/lib/manager/gradle-lite/types.ts b/lib/manager/gradle-lite/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..10f1d0c374c992375ba795c1298e2dc552101029 --- /dev/null +++ b/lib/manager/gradle-lite/types.ts @@ -0,0 +1,67 @@ +import type { PackageDependency } from '../types'; +import type { TokenType } from './common'; + +export interface ManagerData { + fileReplacePosition: number; + packageFile?: string; +} + +export interface VariableData extends ManagerData { + key: string; + value: string; +} + +export type PackageVariables = Record<string, VariableData>; +export type VariableRegistry = Record<string, PackageVariables>; + +export interface Token { + type: TokenType; + value: string; + offset: number; +} + +export interface StringInterpolation extends Token { + type: TokenType.StringInterpolation; + children: Token[]; // Tokens inside double-quoted string that are subject of interpolation + isComplete: boolean; // True if token has parsed completely + isValid: boolean; // False if string contains something unprocessable +} + +// Matcher on single token +export interface SyntaxMatcher { + matchType: TokenType | TokenType[]; + matchValue?: string | string[]; + lookahead?: boolean; + tokenMapKey?: string; +} + +export type TokenMap = Record<string, Token>; + +export interface SyntaxHandlerInput { + packageFile: string; + variables: PackageVariables; + tokenMap: TokenMap; +} + +export type SyntaxHandlerOutput = { + deps?: PackageDependency<ManagerData>[]; + vars?: PackageVariables; + urls?: string[]; +} | null; + +export interface SyntaxMatchConfig { + matchers: SyntaxMatcher[]; + handler: (MatcherHandlerInput) => SyntaxHandlerOutput; +} + +export interface MatchConfig { + tokens: Token[]; + variables: PackageVariables; + packageFile: string; +} + +export interface ParseGradleResult { + deps: PackageDependency<ManagerData>[]; + urls: string[]; + vars: PackageVariables; +} diff --git a/lib/manager/gradle-lite/update.ts b/lib/manager/gradle-lite/update.ts index 2666cf3c623cdcba89e3a8045904cf48c43951d1..2de06c61171bebb6a563dee082038a0cb9d8ff57 100644 --- a/lib/manager/gradle-lite/update.ts +++ b/lib/manager/gradle-lite/update.ts @@ -1,6 +1,6 @@ import { logger } from '../../logger'; import type { UpdateDependencyConfig } from '../types'; -import type { ManagerData } from './common'; +import type { ManagerData } from './types'; import { versionLikeSubstring } from './utils'; export function updateDependency({ diff --git a/lib/manager/gradle-lite/utils.ts b/lib/manager/gradle-lite/utils.ts index 639725795a8b2b7a611a8ef71eed5bd36cb8283e..85fc366270a41f90d4f5ee969603f6926fb76f2f 100644 --- a/lib/manager/gradle-lite/utils.ts +++ b/lib/manager/gradle-lite/utils.ts @@ -1,13 +1,13 @@ import upath from 'upath'; import { regEx } from '../../util/regex'; import type { PackageDependency } from '../types'; +import { TokenType } from './common'; import { ManagerData, PackageVariables, Token, - TokenType, VariableRegistry, -} from './common'; +} from './types'; const artifactRegex = regEx( '^[a-zA-Z][-_a-zA-Z0-9]*(?:\\.[a-zA-Z0-9][-_a-zA-Z0-9]*?)*$' diff --git a/lib/manager/gradle/build-gradle.ts b/lib/manager/gradle/build-gradle.ts index a142433632e3d4e9b400d73b112dcb29d9c2b6ec..e90b245e2f1b83d718061a8413d37f698e8589de 100644 --- a/lib/manager/gradle/build-gradle.ts +++ b/lib/manager/gradle/build-gradle.ts @@ -1,5 +1,5 @@ import { regEx } from '../../util/regex'; -import { BuildDependency } from './gradle-updates-report'; +import { BuildDependency, GradleDependency, UpdateFunction } from './types'; /** * Functions adapted/ported from https://github.com/patrikerdes/gradle-use-latest-versions-plugin @@ -8,20 +8,6 @@ import { BuildDependency } from './gradle-updates-report'; let variables: Record<string, string> = {}; -export interface GradleDependency { - group: string; - name: string; - version?: string; -} - -interface UpdateFunction { - ( - dependency: GradleDependency, - buildGradleContent: string, - newValue: string - ): string; -} - const groovyQuotes = `(?:["'](?:""|'')?)`; const groovyVersionVariable = `(?:${groovyQuotes}\\$)?{?([^\\s"'{}$)]+)}?${groovyQuotes}?`; const kotlinVersionVariable = `(?:"\\$)?{?([^\\s"{}$]+?)}?"?`; diff --git a/lib/manager/gradle/gradle-updates-report.ts b/lib/manager/gradle/gradle-updates-report.ts index 1398fb99a43877bd8f47a955dc0b3bbef9a6aa54..e90ca8960053c27935509d0d3aab915e4bcabba9 100644 --- a/lib/manager/gradle/gradle-updates-report.ts +++ b/lib/manager/gradle/gradle-updates-report.ts @@ -2,31 +2,14 @@ import { exists, readFile, writeFile } from 'fs-extra'; import { join } from 'upath'; import * as datasourceSbtPackage from '../../datasource/sbt-package'; import { logger } from '../../logger'; +import type { + BuildDependency, + GradleDependencyWithRepos, + GradleProject, +} from './types'; export const GRADLE_DEPENDENCY_REPORT_FILENAME = 'gradle-renovate-report.json'; -interface GradleProject { - project: string; - repositories: string[]; - dependencies: GradleDependency[]; -} - -interface GradleDependency { - name: string; - group: string; - version: string; -} - -type GradleDependencyWithRepos = GradleDependency & { repos: string[] }; - -export interface BuildDependency { - name: string; - depGroup: string; - depName?: string; - currentValue?: string; - registryUrls?: string[]; -} - export async function createRenovateGradlePlugin( localDir: string ): Promise<void> { diff --git a/lib/manager/gradle/index.ts b/lib/manager/gradle/index.ts index 04550342bc2ac5d474c1994534fad1366224ce7d..c83bf3d78383c9b494deb2929bac46700c920c87 100644 --- a/lib/manager/gradle/index.ts +++ b/lib/manager/gradle/index.ts @@ -16,7 +16,6 @@ import type { Upgrade, } from '../types'; import { - GradleDependency, collectVersionVariables, init, updateGradleVersion, @@ -25,6 +24,7 @@ import { createRenovateGradlePlugin, extractDependenciesFromUpdatesReport, } from './gradle-updates-report'; +import type { GradleDependency } from './types'; import { extraEnv, gradleWrapperFileName, prepareGradleCommand } from './utils'; export const GRADLE_DEPENDENCY_REPORT_OPTIONS = diff --git a/lib/manager/gradle/types.ts b/lib/manager/gradle/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..00994f1429d69af99652f96200a3d8d6bf0cbf07 --- /dev/null +++ b/lib/manager/gradle/types.ts @@ -0,0 +1,29 @@ +export interface GradleDependency { + group: string; + name: string; + version?: string; +} + +export interface UpdateFunction { + ( + dependency: GradleDependency, + buildGradleContent: string, + newValue: string + ): string; +} + +export interface GradleProject { + project: string; + repositories: string[]; + dependencies: GradleDependency[]; +} + +export type GradleDependencyWithRepos = GradleDependency & { repos: string[] }; + +export interface BuildDependency { + name: string; + depGroup: string; + depName?: string; + currentValue?: string; + registryUrls?: string[]; +} diff --git a/lib/manager/helm-values/extract.ts b/lib/manager/helm-values/extract.ts index f2cd4230c0dc15e3f85a9b1478b4bdf843bc22fa..6ee1da6bea19994cf3f85aa2ef9f260e3d9d82bc 100644 --- a/lib/manager/helm-values/extract.ts +++ b/lib/manager/helm-values/extract.ts @@ -3,11 +3,8 @@ import { logger } from '../../logger'; import { id as dockerVersioning } from '../../versioning/docker'; import { getDep } from '../dockerfile/extract'; import type { PackageDependency, PackageFile } from '../types'; - -import { - HelmDockerImageDependency, - matchesHelmValuesDockerHeuristic, -} from './util'; +import type { HelmDockerImageDependency } from './types'; +import { matchesHelmValuesDockerHeuristic } from './util'; function getHelmDep({ registry, diff --git a/lib/manager/helm-values/types.ts b/lib/manager/helm-values/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..b507048353b0d13564279353430954db8a3caf30 --- /dev/null +++ b/lib/manager/helm-values/types.ts @@ -0,0 +1,5 @@ +export type HelmDockerImageDependency = { + registry?: string; + repository: string; + tag: string; +}; diff --git a/lib/manager/helm-values/util.ts b/lib/manager/helm-values/util.ts index 1aeabaf30b37f42813e019cd92b2a7d497ded5e3..ffc9ee74cbc502b214414b653bf9667f6280c79a 100644 --- a/lib/manager/helm-values/util.ts +++ b/lib/manager/helm-values/util.ts @@ -1,10 +1,5 @@ import { hasKey } from '../../util/object'; - -export type HelmDockerImageDependency = { - registry?: string; - repository: string; - tag: string; -}; +import { HelmDockerImageDependency } from './types'; const parentKeyRe = /image$/i; diff --git a/lib/manager/helmfile/extract.ts b/lib/manager/helmfile/extract.ts index 5273622ba329719dc0c7e8bd76321cbae66844a1..72d7bda798367cabf418decf62b09fb832da706e 100644 --- a/lib/manager/helmfile/extract.ts +++ b/lib/manager/helmfile/extract.ts @@ -4,21 +4,11 @@ import * as datasourceHelm from '../../datasource/helm'; import { logger } from '../../logger'; import { SkipReason } from '../../types'; import type { ExtractConfig, PackageDependency, PackageFile } from '../types'; +import type { Doc } from './types'; const isValidChartName = (name: string): boolean => !/[!@#$%^&*(),.?":{}/|<>A-Z]/.test(name); -interface Doc { - releases?: { - chart: string; - version: string; - }[]; - repositories?: { - name: string; - url: string; - }[]; -} - export function extractPackageFile( content: string, fileName: string, diff --git a/lib/manager/helmfile/types.ts b/lib/manager/helmfile/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..8c6b6a19bb31b651cc872afa712fa3bf02e2a99a --- /dev/null +++ b/lib/manager/helmfile/types.ts @@ -0,0 +1,10 @@ +export interface Doc { + releases?: { + chart: string; + version: string; + }[]; + repositories?: { + name: string; + url: string; + }[]; +} diff --git a/lib/manager/homebrew/extract.ts b/lib/manager/homebrew/extract.ts index c6d34398e1a6d71ef82056ca92011b13b43e89c2..04803fc6c561b691d516832787730527b28d3139 100644 --- a/lib/manager/homebrew/extract.ts +++ b/lib/manager/homebrew/extract.ts @@ -2,6 +2,7 @@ import * as datasourceGithubTags from '../../datasource/github-tags'; import { logger } from '../../logger'; import { SkipReason } from '../../types'; import type { PackageDependency, PackageFile } from '../types'; +import type { UrlPathParsedResult } from './types'; import { isSpace, removeComments, skip } from './util'; function parseSha256(idx: number, content: string): string | null { @@ -54,12 +55,6 @@ function extractUrl(content: string): string | null { return parseUrl(i, content); } -export interface UrlPathParsedResult { - currentValue: string; - ownerName: string; - repoName: string; -} - export function parseUrlPath(urlStr: string): UrlPathParsedResult | null { if (!urlStr) { return null; diff --git a/lib/manager/homebrew/types.ts b/lib/manager/homebrew/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..723eacfef2265e0f0ed9e6a3ef7a9117c7028935 --- /dev/null +++ b/lib/manager/homebrew/types.ts @@ -0,0 +1,5 @@ +export interface UrlPathParsedResult { + currentValue: string; + ownerName: string; + repoName: string; +} diff --git a/lib/manager/kustomize/extract.ts b/lib/manager/kustomize/extract.ts index cb1b70580f0485f5923de8a920fb95f970006abc..5fe464ebc35f02e8f6281f516604666a5b9d230a 100644 --- a/lib/manager/kustomize/extract.ts +++ b/lib/manager/kustomize/extract.ts @@ -5,18 +5,7 @@ import * as datasourceGitHubTags from '../../datasource/github-tags'; import { logger } from '../../logger'; import * as dockerVersioning from '../../versioning/docker'; import type { PackageDependency, PackageFile } from '../types'; - -interface Image { - name: string; - newTag: string; - newName?: string; -} - -interface Kustomize { - kind: string; - bases: string[]; - images: Image[]; -} +import type { Image, Kustomize } from './types'; // URL specifications should follow the hashicorp URL format // https://github.com/hashicorp/go-getter#url-format diff --git a/lib/manager/kustomize/types.ts b/lib/manager/kustomize/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..b791575c30c056c019e780d26f5a47977f6b1abd --- /dev/null +++ b/lib/manager/kustomize/types.ts @@ -0,0 +1,10 @@ +export interface Image { + name: string; + newTag: string; + newName?: string; +} +export interface Kustomize { + kind: string; + bases: string[]; + images: Image[]; +} diff --git a/lib/manager/leiningen/extract.ts b/lib/manager/leiningen/extract.ts index 360c4ce3d9ab47adb6792337e5ad04a1f2ef689b..ea712618cf25e83e95120f213e443ac649ab9934 100644 --- a/lib/manager/leiningen/extract.ts +++ b/lib/manager/leiningen/extract.ts @@ -1,5 +1,6 @@ import * as datasourceClojure from '../../datasource/clojure'; import type { PackageDependency, PackageFile } from '../types'; +import type { ExtractContext } from './types'; export function trimAtKey(str: string, kwName: string): string | null { const regex = new RegExp(`:${kwName}(?=\\s)`); @@ -19,11 +20,6 @@ export function expandDepName(name: string): string { return name.includes('/') ? name.replace('/', ':') : `${name}:${name}`; } -export interface ExtractContext { - depType?: string; - registryUrls?: string[]; -} - export function extractFromVectors( str: string, offset = 0, diff --git a/lib/manager/leiningen/types.ts b/lib/manager/leiningen/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..940f428932afd60925f60e300ba1619e106da289 --- /dev/null +++ b/lib/manager/leiningen/types.ts @@ -0,0 +1,4 @@ +export interface ExtractContext { + depType?: string; + registryUrls?: string[]; +} diff --git a/lib/manager/maven/extract.ts b/lib/manager/maven/extract.ts index 8c725a77a96a164432998c2b25578a312aab8f61..a8721584c6b113c14fb6bc6ae2d17fe45139a359 100644 --- a/lib/manager/maven/extract.ts +++ b/lib/manager/maven/extract.ts @@ -7,6 +7,7 @@ import { logger } from '../../logger'; import { SkipReason } from '../../types'; import { readLocalFile } from '../../util/fs'; import type { ExtractConfig, PackageDependency, PackageFile } from '../types'; +import type { MavenProp } from './types'; export function parsePom(raw: string): XmlDocument | null { let project: XmlDocument; @@ -35,12 +36,6 @@ function containsPlaceholder(str: string): boolean { return /\${.*?}/g.test(str); } -interface MavenProp { - val: string; - fileReplacePosition: number; - packageFile: string; -} - function depFromNode(node: XmlElement): PackageDependency | null { if (!('valueWithPath' in node)) { return null; diff --git a/lib/manager/maven/types.ts b/lib/manager/maven/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..af4354e8da1eec3e97dad8a6ec721ef76bbcbb31 --- /dev/null +++ b/lib/manager/maven/types.ts @@ -0,0 +1,5 @@ +export interface MavenProp { + val: string; + fileReplacePosition: number; + packageFile: string; +} diff --git a/lib/manager/npm/post-update/index.ts b/lib/manager/npm/post-update/index.ts index a9e9f70b361ba689f8faa8fc5c0b2a52decd46a8..8de797b7e29551c03d8517a86b598b1013b8815d 100644 --- a/lib/manager/npm/post-update/index.ts +++ b/lib/manager/npm/post-update/index.ts @@ -23,6 +23,13 @@ import type { PackageFile, PostUpdateConfig, Upgrade } from '../../types'; import * as lerna from './lerna'; import * as npm from './npm'; import * as pnpm from './pnpm'; +import type { + AdditionalPackageFiles, + ArtifactError, + DetermineLockFileDirsResult, + UpdatedArtifacts, + WriteExistingFilesResult, +} from './types'; import * as yarn from './yarn'; // Strips empty values, deduplicates, and returns the directories from filenames @@ -30,12 +37,6 @@ import * as yarn from './yarn'; const getDirs = (arr: string[]): string[] => Array.from(new Set(arr.filter(Boolean))); -export interface DetermineLockFileDirsResult { - yarnLockDirs: string[]; - npmLockDirs: string[]; - pnpmShrinkwrapDirs: string[]; - lernaJsonFiles: string[]; -} // istanbul ignore next export function determineLockFileDirs( config: PostUpdateConfig, @@ -263,20 +264,6 @@ export async function writeUpdatedPackageFiles( } } -export interface AdditionalPackageFiles { - npm?: Partial<PackageFile>[]; -} - -interface ArtifactError { - lockFile: string; - stderr: string; -} - -interface UpdatedArtifacts { - name: string; - contents: string | Buffer; -} - // istanbul ignore next async function getNpmrcContent(dir: string): Promise<string | null> { const npmrcFilePath = upath.join(dir, '.npmrc'); @@ -398,10 +385,6 @@ async function updateYarnOffline( } } -export interface WriteExistingFilesResult { - artifactErrors: ArtifactError[]; - updatedArtifacts: UpdatedArtifacts[]; -} // istanbul ignore next export async function getAdditionalFiles( config: PostUpdateConfig, diff --git a/lib/manager/npm/post-update/lerna.ts b/lib/manager/npm/post-update/lerna.ts index 4cf0bc54750c0c6360b41ac07b97182c3aaaf9b2..94f661afc0247251d2dc475a16a5f7385bdbde12 100644 --- a/lib/manager/npm/post-update/lerna.ts +++ b/lib/manager/npm/post-update/lerna.ts @@ -6,13 +6,9 @@ import { logger } from '../../../logger'; import { ExecOptions, exec } from '../../../util/exec'; import type { PackageFile, PostUpdateConfig } from '../../types'; import { getNodeConstraint } from './node-version'; +import type { GenerateLockFileResult } from './types'; import { getOptimizeCommand } from './yarn'; -export interface GenerateLockFileResult { - error?: boolean; - stderr?: string; -} - // Exported for testability export function getLernaVersion( lernaPackageFile: Partial<PackageFile> diff --git a/lib/manager/npm/post-update/npm.ts b/lib/manager/npm/post-update/npm.ts index 9405b604056a2bb8e234da247d1ba7577a9664ee..b087603fb6aa61742bd1d5b2afc16313143abbe0 100644 --- a/lib/manager/npm/post-update/npm.ts +++ b/lib/manager/npm/post-update/npm.ts @@ -11,12 +11,7 @@ import { ExecOptions, exec } from '../../../util/exec'; import { move, pathExists, readFile, remove } from '../../../util/fs'; import type { PostUpdateConfig, Upgrade } from '../../types'; import { getNodeConstraint } from './node-version'; - -export interface GenerateLockFileResult { - error?: boolean; - lockFile?: string; - stderr?: string; -} +import type { GenerateLockFileResult } from './types'; export async function generateLockFile( cwd: string, diff --git a/lib/manager/npm/post-update/pnpm.ts b/lib/manager/npm/post-update/pnpm.ts index f6a802fc609a010a67096354b18b984cb02f9412..52a2c35008a43c23a87e2c9722e26372b2fb84ca 100644 --- a/lib/manager/npm/post-update/pnpm.ts +++ b/lib/manager/npm/post-update/pnpm.ts @@ -8,13 +8,7 @@ import { ExecOptions, exec } from '../../../util/exec'; import { readFile, remove } from '../../../util/fs'; import type { PostUpdateConfig, Upgrade } from '../../types'; import { getNodeConstraint } from './node-version'; - -export interface GenerateLockFileResult { - error?: boolean; - lockFile?: string; - stderr?: string; - stdout?: string; -} +import type { GenerateLockFileResult } from './types'; export async function generateLockFile( cwd: string, diff --git a/lib/manager/npm/post-update/types.ts b/lib/manager/npm/post-update/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..035ac3d39d47c23597a4f0f664d2c4a5f8deacef --- /dev/null +++ b/lib/manager/npm/post-update/types.ts @@ -0,0 +1,34 @@ +import type { PackageFile } from '../../types'; + +export interface DetermineLockFileDirsResult { + yarnLockDirs: string[]; + npmLockDirs: string[]; + pnpmShrinkwrapDirs: string[]; + lernaJsonFiles: string[]; +} + +export interface AdditionalPackageFiles { + npm?: Partial<PackageFile>[]; +} + +export interface ArtifactError { + lockFile: string; + stderr: string; +} + +export interface UpdatedArtifacts { + name: string; + contents: string | Buffer; +} + +export interface WriteExistingFilesResult { + artifactErrors: ArtifactError[]; + updatedArtifacts: UpdatedArtifacts[]; +} + +export interface GenerateLockFileResult { + error?: boolean; + lockFile?: string; + stderr?: string; + stdout?: string; +} diff --git a/lib/manager/npm/post-update/yarn.ts b/lib/manager/npm/post-update/yarn.ts index f555bcbce78f02bc4b394476237a9f95a53e6973..595124ad614bdfe0e69f35a23103408b7ac0fa0f 100644 --- a/lib/manager/npm/post-update/yarn.ts +++ b/lib/manager/npm/post-update/yarn.ts @@ -14,12 +14,7 @@ import { ExecOptions, exec } from '../../../util/exec'; import { readFile, remove } from '../../../util/fs'; import type { PostUpdateConfig, Upgrade } from '../../types'; import { getNodeConstraint } from './node-version'; - -export interface GenerateLockFileResult { - error?: boolean; - lockFile?: string; - stderr?: string; -} +import { GenerateLockFileResult } from './types'; export async function checkYarnrc( cwd: string diff --git a/lib/manager/nuget/types.ts b/lib/manager/nuget/types.ts index e2cbb13bf93d4f8fafbb4712af6a8e0404ed29f7..631f8114e7e78a8538e650326f0c65853caf956f 100644 --- a/lib/manager/nuget/types.ts +++ b/lib/manager/nuget/types.ts @@ -9,3 +9,8 @@ export interface DotnetTool { readonly version: string; readonly commands: string[]; } + +export interface Registry { + readonly url: string; + readonly name?: string; +} diff --git a/lib/manager/nuget/util.ts b/lib/manager/nuget/util.ts index b18c97efdf8194dbfb326308b455ef6c8387adda..d7fcd54f03e71645df3e810bfff79e088f75bce4 100644 --- a/lib/manager/nuget/util.ts +++ b/lib/manager/nuget/util.ts @@ -5,6 +5,7 @@ import { XmlDocument } from 'xmldoc'; import * as datasourceNuget from '../../datasource/nuget'; import { logger } from '../../logger'; import { readFile } from '../../util/fs'; +import type { Registry } from './types'; async function readFileAsXmlDocument(file: string): Promise<XmlDocument> { try { @@ -15,11 +16,6 @@ async function readFileAsXmlDocument(file: string): Promise<XmlDocument> { } } -export interface Registry { - readonly url: string; - readonly name?: string; -} - /* istanbul ignore next */ export function getRandomString(): string { return cryptoRandomString({ length: 16 }); diff --git a/lib/manager/pip_setup/extract.ts b/lib/manager/pip_setup/extract.ts index e6692ade9e8a50c240c51fb3a94f5879363e3d54..e0274334280b48476e1db1c0abc4ff22e4b297cd 100644 --- a/lib/manager/pip_setup/extract.ts +++ b/lib/manager/pip_setup/extract.ts @@ -6,7 +6,8 @@ import { BinarySource } from '../../util/exec/common'; import { isSkipComment } from '../../util/ignore'; import { dependencyPattern } from '../pip_requirements/extract'; import type { ExtractConfig, PackageDependency, PackageFile } from '../types'; -import { PythonSetup, getExtractFile, parseReport } from './util'; +import type { PythonSetup } from './types'; +import { getExtractFile, parseReport } from './util'; export const pythonVersions = ['python', 'python3', 'python3.8', 'python3.9']; let pythonAlias: string | null = null; diff --git a/lib/manager/pip_setup/types.ts b/lib/manager/pip_setup/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..39187e14cefb823310d52db3653d43b75b560741 --- /dev/null +++ b/lib/manager/pip_setup/types.ts @@ -0,0 +1,4 @@ +export interface PythonSetup { + extras_require: Record<string, string[]>; + install_requires: string[]; +} diff --git a/lib/manager/pip_setup/util.ts b/lib/manager/pip_setup/util.ts index 84b020c0df26ad80da8688258a148657b3068c2a..88e7e70eecee13eb4eb2440a6d49d1337bbb4803 100644 --- a/lib/manager/pip_setup/util.ts +++ b/lib/manager/pip_setup/util.ts @@ -2,6 +2,7 @@ import { dirname } from 'path'; import { join } from 'upath'; import dataFiles from '../../data-files.generated'; import { ensureCacheDir, outputFile, readLocalFile } from '../../util/fs'; +import type { PythonSetup } from './types'; // need to match filename in `data/extract.py` const REPORT = 'renovate-pip_setup-report.json'; @@ -21,11 +22,6 @@ export async function getExtractFile(): Promise<string> { return extractPy; } -export interface PythonSetup { - extras_require: Record<string, string[]>; - install_requires: string[]; -} - export async function parseReport(packageFile: string): Promise<PythonSetup> { const data = await readLocalFile(join(dirname(packageFile), REPORT), 'utf8'); return JSON.parse(data); diff --git a/lib/manager/pipenv/artifacts.spec.ts b/lib/manager/pipenv/artifacts.spec.ts index 165edc209b7e24050dccd124eb21bffdc6063d44..53019bc17c2bde2a786cbc09cae22fc118d031d2 100644 --- a/lib/manager/pipenv/artifacts.spec.ts +++ b/lib/manager/pipenv/artifacts.spec.ts @@ -7,7 +7,7 @@ import { setUtilConfig } from '../../util'; import { BinarySource } from '../../util/exec/common'; import * as docker from '../../util/exec/docker'; import * as _env from '../../util/exec/env'; -import { StatusResult } from '../../util/git'; +import type { StatusResult } from '../../util/git'; import * as pipenv from './artifacts'; jest.mock('fs-extra'); diff --git a/lib/manager/pipenv/extract.ts b/lib/manager/pipenv/extract.ts index 84c7e4fc34ac414528b38f4479d636b30367f387..ddd9107ded7fccb1e2a1e56adbb7ffa80f83b9fd 100644 --- a/lib/manager/pipenv/extract.ts +++ b/lib/manager/pipenv/extract.ts @@ -6,6 +6,7 @@ import { logger } from '../../logger'; import { SkipReason } from '../../types'; import { localPathExists } from '../../util/fs'; import type { PackageDependency, PackageFile } from '../types'; +import type { PipFile } from './types'; // based on https://www.python.org/dev/peps/pep-0508/#names const packageRegex = /^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$/i; @@ -16,27 +17,6 @@ const specifierPartPattern = `\\s*${rangePattern.replace( '?:' )}\\s*`; const specifierPattern = `${specifierPartPattern}(?:,${specifierPartPattern})*`; -interface PipSource { - name: string; - url: string; -} - -interface PipFile { - source: PipSource[]; - - packages?: Record<string, PipRequirement>; - 'dev-packages'?: Record<string, PipRequirement>; - requires?: Record<string, string>; -} - -interface PipRequirement { - index?: string; - version?: string; - path?: string; - file?: string; - git?: string; -} - function extractFromSection( pipfile: PipFile, section: 'packages' | 'dev-packages' diff --git a/lib/manager/pipenv/types.ts b/lib/manager/pipenv/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3e914aea1c05f50e23ba2f516d13dab1b28d72e --- /dev/null +++ b/lib/manager/pipenv/types.ts @@ -0,0 +1,20 @@ +export interface PipSource { + name: string; + url: string; +} + +export interface PipFile { + source: PipSource[]; + + packages?: Record<string, PipRequirement>; + 'dev-packages'?: Record<string, PipRequirement>; + requires?: Record<string, string>; +} + +export interface PipRequirement { + index?: string; + version?: string; + path?: string; + file?: string; + git?: string; +} diff --git a/lib/manager/sbt/extract.ts b/lib/manager/sbt/extract.ts index 84c8daf4af0d36ddcf2ea95616b2229fd9f88304..6b6b2dc5d2ec096f1a8f7a2ec63e74aeb1f29f7d 100644 --- a/lib/manager/sbt/extract.ts +++ b/lib/manager/sbt/extract.ts @@ -5,6 +5,7 @@ import * as datasourceSbtPlugin from '../../datasource/sbt-plugin'; import { get } from '../../versioning'; import * as mavenVersioning from '../../versioning/maven'; import type { PackageDependency, PackageFile } from '../types'; +import type { ParseContext, ParseOptions } from './types'; const stripComment = (str: string): string => str.replace(/(^|\s+)\/\/.*$/, ''); @@ -102,12 +103,6 @@ const getVarInfo = (str: string, ctx: ParseContext): { val: string } => { return { val }; }; -interface ParseContext { - scalaVersion: string; - variables: any; - depType?: string; -} - function parseDepExpr( expr: string, ctx: ParseContext @@ -198,12 +193,6 @@ function parseDepExpr( return result; } -interface ParseOptions { - isMultiDeps?: boolean; - scalaVersion?: string; - variables?: Record<string, any>; -} - function parseSbtLine( acc: PackageFile & ParseOptions, line: string, diff --git a/lib/manager/sbt/types.ts b/lib/manager/sbt/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..7c0ef4c7f7bad73a52b5b78eb53a025d1e82d1f7 --- /dev/null +++ b/lib/manager/sbt/types.ts @@ -0,0 +1,11 @@ +export interface ParseContext { + scalaVersion: string; + variables: any; + depType?: string; +} + +export interface ParseOptions { + isMultiDeps?: boolean; + scalaVersion?: string; + variables?: Record<string, any>; +} diff --git a/lib/manager/swift/extract.ts b/lib/manager/swift/extract.ts index a30b57287d42f249b1ecbe361169a6df184c3fa8..f7feb08408933caf2baa0c318bda3e418df4b4fa 100644 --- a/lib/manager/swift/extract.ts +++ b/lib/manager/swift/extract.ts @@ -1,5 +1,6 @@ import * as datasourceGitTags from '../../datasource/git-tags'; import type { PackageDependency, PackageFile } from '../types'; +import type { MatchResult } from './types'; const regExps = { wildcard: /^.*?/, @@ -87,13 +88,6 @@ function searchKeysForState(state): (keyof typeof regExps)[] { return [DEPS]; } } -interface MatchResult { - idx: number; - len: number; - label: string; - substr: string; -} - function getMatch(str: string, state: string): MatchResult | null { const keys = searchKeysForState(state); let result = null; diff --git a/lib/manager/swift/types.ts b/lib/manager/swift/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..ebfaa18c1631dd2062763b3293c3fde8d63c65f6 --- /dev/null +++ b/lib/manager/swift/types.ts @@ -0,0 +1,6 @@ +export interface MatchResult { + idx: number; + len: number; + label: string; + substr: string; +} diff --git a/lib/manager/terraform/common.ts b/lib/manager/terraform/common.ts new file mode 100644 index 0000000000000000000000000000000000000000..25be93cd16927e7cc98c13cafd060ba607fa4ac6 --- /dev/null +++ b/lib/manager/terraform/common.ts @@ -0,0 +1,28 @@ +export enum TerraformDependencyTypes { + unknown = 'unknown', + module = 'module', + provider = 'provider', + required_providers = 'required_providers', + resource = 'resource', + terraform_version = 'terraform_version', +} + +export enum TerraformResourceTypes { + unknown = 'unknown', + /** + * https://www.terraform.io/docs/providers/docker/r/container.html + */ + docker_container = 'docker_container', + /** + * https://www.terraform.io/docs/providers/docker/r/image.html + */ + docker_image = 'docker_image', + /** + * https://www.terraform.io/docs/providers/docker/r/service.html + */ + docker_service = 'docker_service', + /** + * https://www.terraform.io/docs/providers/helm/r/release.html + */ + helm_release = 'helm_release', +} diff --git a/lib/manager/terraform/extract.ts b/lib/manager/terraform/extract.ts index 0048bde408dc4ad59eed1e6dca2f42e578c9aab3..889d5df024dd323db7639cc79d5ed9a854334d13 100644 --- a/lib/manager/terraform/extract.ts +++ b/lib/manager/terraform/extract.ts @@ -1,5 +1,6 @@ import { logger } from '../../logger'; import type { PackageDependency, PackageFile } from '../types'; +import { TerraformDependencyTypes } from './common'; import { analyseTerraformModule, extractTerraformModule } from './modules'; import { analyzeTerraformProvider, @@ -17,9 +18,8 @@ import { analyseTerraformResource, extractTerraformResource, } from './resources'; +import type { TerraformManagerData } from './types'; import { - TerraformDependencyTypes, - TerraformManagerData, checkFileContainsDependency, getTerraformDependencyType, } from './util'; diff --git a/lib/manager/terraform/modules.ts b/lib/manager/terraform/modules.ts index d4d645565fc0e389fed3e81b38d3cb6c46349e88..f1deb1182a913c2d9a8de80cb57cc2d5a5b9d568 100644 --- a/lib/manager/terraform/modules.ts +++ b/lib/manager/terraform/modules.ts @@ -4,8 +4,9 @@ import * as datasourceTerraformModule from '../../datasource/terraform-module'; import { logger } from '../../logger'; import { SkipReason } from '../../types'; import type { PackageDependency } from '../types'; +import { TerraformDependencyTypes } from './common'; import { extractTerraformProvider } from './providers'; -import { ExtractionResult, TerraformDependencyTypes } from './util'; +import type { ExtractionResult } from './types'; export const githubRefMatchRegex = /github\.com([/:])(?<project>[^/]+\/[a-z0-9-_.]+).*\?ref=(?<tag>.*)$/i; export const gitTagsRefMatchRegex = /(?:git::)?(?<url>(?:http|https|ssh):\/\/(?:.*@)?(?<path>.*.*\/(?<project>.*\/.*)))\?ref=(?<tag>.*)$/; diff --git a/lib/manager/terraform/providers.ts b/lib/manager/terraform/providers.ts index aa06ad0d73609c35904084912ab64270696c5650..f5679c9b8194b5fb21bbde0cd4abd48f03241487 100644 --- a/lib/manager/terraform/providers.ts +++ b/lib/manager/terraform/providers.ts @@ -3,11 +3,9 @@ import * as datasourceTerraformProvider from '../../datasource/terraform-provide import { logger } from '../../logger'; import { SkipReason } from '../../types'; import type { PackageDependency } from '../types'; -import { - ExtractionResult, - TerraformDependencyTypes, - keyValueExtractionRegex, -} from './util'; +import { TerraformDependencyTypes } from './common'; +import type { ExtractionResult } from './types'; +import { keyValueExtractionRegex } from './util'; export const sourceExtractionRegex = /^(?:(?<hostname>(?:[a-zA-Z0-9]+\.+)+[a-zA-Z0-9]+)\/)?(?:(?<namespace>[^/]+)\/)?(?<type>[^/]+)/; diff --git a/lib/manager/terraform/required-providers.ts b/lib/manager/terraform/required-providers.ts index 44b1186210c23e742eea741aece730bda02fdaf5..7d519ed74aec3c827de5da83fa94468d3618fe4b 100644 --- a/lib/manager/terraform/required-providers.ts +++ b/lib/manager/terraform/required-providers.ts @@ -1,10 +1,8 @@ import type { PackageDependency } from '../types'; +import { TerraformDependencyTypes } from './common'; import { analyzeTerraformProvider } from './providers'; -import { - ExtractionResult, - TerraformDependencyTypes, - keyValueExtractionRegex, -} from './util'; +import type { ExtractionResult } from './types'; +import { keyValueExtractionRegex } from './util'; export const providerBlockExtractionRegex = /^\s*(?<key>[^\s]+)\s+=\s+{/; diff --git a/lib/manager/terraform/required-version.ts b/lib/manager/terraform/required-version.ts index c8bb1e4dad6f326bd9220d2ec25dee733d094b3b..d5f6020389daa5840485093410f3f34df3bf3560 100644 --- a/lib/manager/terraform/required-version.ts +++ b/lib/manager/terraform/required-version.ts @@ -1,11 +1,9 @@ import * as datasourceGithubTags from '../../datasource/github-tags'; import { logger } from '../../logger'; import type { PackageDependency } from '../types'; -import { - ExtractionResult, - TerraformDependencyTypes, - keyValueExtractionRegex, -} from './util'; +import { TerraformDependencyTypes } from './common'; +import type { ExtractionResult } from './types'; +import { keyValueExtractionRegex } from './util'; export function extractTerraformRequiredVersion( startingLine: number, diff --git a/lib/manager/terraform/resources.ts b/lib/manager/terraform/resources.ts index 4937a8e98ef4d6d510e7b95500fb4a4d4b8ba7c9..7cf7799639a967603f96f72ec3fc0b63f05ec363 100644 --- a/lib/manager/terraform/resources.ts +++ b/lib/manager/terraform/resources.ts @@ -2,11 +2,9 @@ import * as datasourceHelm from '../../datasource/helm'; import { SkipReason } from '../../types'; import { getDep } from '../dockerfile/extract'; import type { PackageDependency } from '../types'; +import { TerraformDependencyTypes, TerraformResourceTypes } from './common'; +import type { ExtractionResult, ResourceManagerData } from './types'; import { - ExtractionResult, - ResourceManagerData, - TerraformDependencyTypes, - TerraformResourceTypes, checkIfStringIsPath, keyValueExtractionRegex, resourceTypeExtractionRegex, diff --git a/lib/manager/terraform/types.ts b/lib/manager/terraform/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..865289501d0492a0ac9378a7a41aad14f9a3baab --- /dev/null +++ b/lib/manager/terraform/types.ts @@ -0,0 +1,22 @@ +import type { PackageDependency } from '../types'; +import type { + TerraformDependencyTypes, + TerraformResourceTypes, +} from './common'; + +export interface ExtractionResult { + lineNumber: number; + dependencies: PackageDependency[]; +} + +export interface TerraformManagerData { + terraformDependencyType: TerraformDependencyTypes; +} + +export interface ResourceManagerData extends TerraformManagerData { + resourceType?: TerraformResourceTypes; + chart?: string; + image?: string; + name?: string; + repository?: string; +} diff --git a/lib/manager/terraform/util.spec.ts b/lib/manager/terraform/util.spec.ts index 678464fc52a1f39cd4803cb538c6ec0357b8a829..367cb4ad1a6164cba560a7e5420935032924b87b 100644 --- a/lib/manager/terraform/util.spec.ts +++ b/lib/manager/terraform/util.spec.ts @@ -1,5 +1,6 @@ import { getName } from '../../../test/util'; -import { TerraformDependencyTypes, getTerraformDependencyType } from './util'; +import { TerraformDependencyTypes } from './common'; +import { getTerraformDependencyType } from './util'; describe(getName(), () => { describe('getTerraformDependencyType()', () => { diff --git a/lib/manager/terraform/util.ts b/lib/manager/terraform/util.ts index ff770199e672d583828ba3f2fe9a9b56b6efaeda..2ee93770e175a7c563d7f9c31d32732e0ed248a9 100644 --- a/lib/manager/terraform/util.ts +++ b/lib/manager/terraform/util.ts @@ -1,54 +1,8 @@ -import type { PackageDependency } from '../types'; +import { TerraformDependencyTypes } from './common'; export const keyValueExtractionRegex = /^\s*(?<key>[^\s]+)\s+=\s+"(?<value>[^"]+)"\s*$/; export const resourceTypeExtractionRegex = /^\s*resource\s+"(?<type>[^\s]+)"\s+"(?<name>[^"]+)"\s*{/; -export interface ExtractionResult { - lineNumber: number; - dependencies: PackageDependency[]; -} - -export enum TerraformDependencyTypes { - unknown = 'unknown', - module = 'module', - provider = 'provider', - required_providers = 'required_providers', - resource = 'resource', - terraform_version = 'terraform_version', -} - -export interface TerraformManagerData { - terraformDependencyType: TerraformDependencyTypes; -} - -export enum TerraformResourceTypes { - unknown = 'unknown', - /** - * https://www.terraform.io/docs/providers/docker/r/container.html - */ - docker_container = 'docker_container', - /** - * https://www.terraform.io/docs/providers/docker/r/image.html - */ - docker_image = 'docker_image', - /** - * https://www.terraform.io/docs/providers/docker/r/service.html - */ - docker_service = 'docker_service', - /** - * https://www.terraform.io/docs/providers/helm/r/release.html - */ - helm_release = 'helm_release', -} - -export interface ResourceManagerData extends TerraformManagerData { - resourceType?: TerraformResourceTypes; - chart?: string; - image?: string; - name?: string; - repository?: string; -} - export function getTerraformDependencyType( value: string ): TerraformDependencyTypes { diff --git a/lib/manager/terragrunt/common.ts b/lib/manager/terragrunt/common.ts new file mode 100644 index 0000000000000000000000000000000000000000..c5a699e242bc5f2f9e980b4bf63295a791898bc8 --- /dev/null +++ b/lib/manager/terragrunt/common.ts @@ -0,0 +1,8 @@ +export enum TerragruntResourceTypes { + unknown = 'unknown', +} + +export enum TerragruntDependencyTypes { + unknown = 'unknown', + terragrunt = 'terraform', +} diff --git a/lib/manager/terragrunt/extract.ts b/lib/manager/terragrunt/extract.ts index ce7ba4d1e5f669ea49d79cfef201a5b9f53a70a7..6f114a45f1bfd3fbf681eab1e4ce6f554db080b8 100644 --- a/lib/manager/terragrunt/extract.ts +++ b/lib/manager/terragrunt/extract.ts @@ -1,9 +1,9 @@ import { logger } from '../../logger'; import type { PackageDependency, PackageFile } from '../types'; +import { TerragruntDependencyTypes } from './common'; import { analyseTerragruntModule, extractTerragruntModule } from './modules'; +import type { TerraformManagerData } from './types'; import { - TerraformManagerData, - TerragruntDependencyTypes, checkFileContainsDependency, getTerragruntDependencyType, } from './util'; diff --git a/lib/manager/terragrunt/modules.ts b/lib/manager/terragrunt/modules.ts index e11e12e20bf95fbc418bb7cf022e29b89e5c6dff..5a0703006ce15c967dc96f154f96eae56c7e74a2 100644 --- a/lib/manager/terragrunt/modules.ts +++ b/lib/manager/terragrunt/modules.ts @@ -4,8 +4,9 @@ import * as datasourceTerragruntModule from '../../datasource/terraform-module'; import { logger } from '../../logger'; import { SkipReason } from '../../types'; import type { PackageDependency } from '../types'; +import { TerragruntDependencyTypes } from './common'; import { extractTerragruntProvider } from './providers'; -import { ExtractionResult, TerragruntDependencyTypes } from './util'; +import type { ExtractionResult } from './types'; export const githubRefMatchRegex = /github\.com([/:])(?<project>[^/]+\/[a-z0-9-_.]+).*\?ref=(?<tag>.*)$/i; export const gitTagsRefMatchRegex = /(?:git::)?(?<url>(?:http|https|ssh):\/\/(?:.*@)?(?<path>.*.*\/(?<project>.*\/.*)))\?ref=(?<tag>.*)$/; diff --git a/lib/manager/terragrunt/providers.ts b/lib/manager/terragrunt/providers.ts index cdda18bee5e963d2e305fa092a82a0caf74871bd..b0c24e0844dd40a456ee509a4a5b15dcd52b9ee6 100644 --- a/lib/manager/terragrunt/providers.ts +++ b/lib/manager/terragrunt/providers.ts @@ -1,9 +1,7 @@ import type { PackageDependency } from '../types'; -import { - ExtractionResult, - TerragruntDependencyTypes, - keyValueExtractionRegex, -} from './util'; +import { TerragruntDependencyTypes } from './common'; +import type { ExtractionResult } from './types'; +import { keyValueExtractionRegex } from './util'; export const sourceExtractionRegex = /^(?:(?<hostname>(?:[a-zA-Z0-9]+\.+)+[a-zA-Z0-9]+)\/)?(?:(?<namespace>[^/]+)\/)?(?<type>[^/]+)/; diff --git a/lib/manager/terragrunt/types.ts b/lib/manager/terragrunt/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..0f474282e3e04b0e9f999f06fc160a6a6dca3daa --- /dev/null +++ b/lib/manager/terragrunt/types.ts @@ -0,0 +1,22 @@ +import type { PackageDependency } from '../types'; +import type { + TerragruntDependencyTypes, + TerragruntResourceTypes, +} from './common'; + +export interface ExtractionResult { + lineNumber: number; + dependencies: PackageDependency[]; +} + +export interface TerraformManagerData { + terragruntDependencyType: TerragruntDependencyTypes; +} + +export interface ResourceManagerData extends TerraformManagerData { + resourceType?: TerragruntResourceTypes; + chart?: string; + image?: string; + name?: string; + repository?: string; +} diff --git a/lib/manager/terragrunt/util.spec.ts b/lib/manager/terragrunt/util.spec.ts index cc37ccedaae72d68c73afaba890acbd88efb2d2a..26e12fe03d6ce933d4b43dc8090ee365500fb6ed 100644 --- a/lib/manager/terragrunt/util.spec.ts +++ b/lib/manager/terragrunt/util.spec.ts @@ -1,5 +1,6 @@ import { getName } from '../../../test/util'; -import { TerragruntDependencyTypes, getTerragruntDependencyType } from './util'; +import { TerragruntDependencyTypes } from './common'; +import { getTerragruntDependencyType } from './util'; describe(getName(), () => { describe('getTerragruntDependencyType()', () => { diff --git a/lib/manager/terragrunt/util.ts b/lib/manager/terragrunt/util.ts index 299e8cc5774e3043606c03ce709f0fd3e7da3634..63ebc18956a983290f88d6888ae09db1cd8f0820 100644 --- a/lib/manager/terragrunt/util.ts +++ b/lib/manager/terragrunt/util.ts @@ -1,36 +1,7 @@ -import type { PackageDependency } from '../types'; +import { TerragruntDependencyTypes } from './common'; export const keyValueExtractionRegex = /^\s*source\s+=\s+"(?<value>[^"]+)"\s*$/; -export interface ExtractionResult { - lineNumber: number; - dependencies: PackageDependency[]; -} - -export enum TerragruntDependencyTypes { - unknown = 'unknown', - terragrunt = 'terraform', -} - -export interface TerraformManagerData { - terragruntDependencyType: TerragruntDependencyTypes; -} - -export enum TerragruntResourceTypes { - unknown = 'unknown', - /** - * https://www.terraform.io/docs/providers/docker/r/container.html - */ -} - -export interface ResourceManagerData extends TerraformManagerData { - resourceType?: TerragruntResourceTypes; - chart?: string; - image?: string; - name?: string; - repository?: string; -} - export function getTerragruntDependencyType( value: string ): TerragruntDependencyTypes { diff --git a/lib/util/cache/repository/index.ts b/lib/util/cache/repository/index.ts index 4c540193a315041c33e19c4c3db7af0a676b9e8d..c8949ac215cfa78a3a485d042560bc64caa695ee 100644 --- a/lib/util/cache/repository/index.ts +++ b/lib/util/cache/repository/index.ts @@ -5,50 +5,11 @@ import type { RepositoryCacheConfig, } from '../../../config/types'; import { logger } from '../../../logger'; -import type { PackageFile } from '../../../manager/types'; -import type { RepoInitConfig } from '../../../workers/repository/init/types'; +import type { Cache } from './types'; // Increment this whenever there could be incompatibilities between old and new cache structure export const CACHE_REVISION = 8; -export interface BaseBranchCache { - sha: string; // branch commit sha - configHash: string; // object hash of config - packageFiles: Record<string, PackageFile[]>; // extract result -} - -export interface BranchUpgradeCache { - currentDigest?: string; - currentValue?: string; - datasource?: string; - depName?: string; - fixedVersion?: string; - currentVersion?: string; - lookupName?: string; - newDigest?: string; - newValue?: string; - newVersion?: string; - sourceUrl?: string; -} - -export interface BranchCache { - automerge: boolean; - branchName: string; - isModified: boolean; - prNo: number | null; - sha: string | null; - parentSha: string | null; - upgrades: BranchUpgradeCache[]; -} - -export interface Cache { - branches?: BranchCache[]; - repository?: string; - revision?: number; - init?: RepoInitConfig; - scan?: Record<string, BaseBranchCache>; -} - let repositoryCache: RepositoryCacheConfig = 'disabled'; let cacheFileName: string; let cache: Cache = Object.create({}); diff --git a/lib/util/cache/repository/types.ts b/lib/util/cache/repository/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..3a7995b559d728b92c7202b1d00551df42c6ab03 --- /dev/null +++ b/lib/util/cache/repository/types.ts @@ -0,0 +1,40 @@ +import type { PackageFile } from '../../../manager/types'; +import type { RepoInitConfig } from '../../../workers/repository/init/types'; + +export interface BaseBranchCache { + sha: string; // branch commit sha + configHash: string; // object hash of config + packageFiles: Record<string, PackageFile[]>; // extract result +} + +export interface BranchUpgradeCache { + currentDigest?: string; + currentValue?: string; + datasource?: string; + depName?: string; + fixedVersion?: string; + currentVersion?: string; + lookupName?: string; + newDigest?: string; + newValue?: string; + newVersion?: string; + sourceUrl?: string; +} + +export interface BranchCache { + automerge: boolean; + branchName: string; + isModified: boolean; + prNo: number | null; + sha: string | null; + parentSha: string | null; + upgrades: BranchUpgradeCache[]; +} + +export interface Cache { + branches?: BranchCache[]; + repository?: string; + revision?: number; + init?: RepoInitConfig; + scan?: Record<string, BaseBranchCache>; +} diff --git a/lib/workers/branch/index.spec.ts b/lib/workers/branch/index.spec.ts index d14c901d568b827727ccf66b1ee933bde6ab1303..0099908babdf853b53bb7b605fc210e787ecd953 100644 --- a/lib/workers/branch/index.spec.ts +++ b/lib/workers/branch/index.spec.ts @@ -12,7 +12,7 @@ import { REPOSITORY_CHANGED, } from '../../constants/error-messages'; import * as _npmPostExtract from '../../manager/npm/post-update'; -import type { WriteExistingFilesResult } from '../../manager/npm/post-update'; +import type { WriteExistingFilesResult } from '../../manager/npm/post-update/types'; import { PrState } from '../../types'; import * as _exec from '../../util/exec'; import { File, StatusResult } from '../../util/git'; diff --git a/lib/workers/repository/cache.ts b/lib/workers/repository/cache.ts index 1104be2bc405a0ff2c8099b11639a7d114b71c4d..e8f9c4bcd51113e4357fa2160eb3759dbda3a254 100644 --- a/lib/workers/repository/cache.ts +++ b/lib/workers/repository/cache.ts @@ -2,11 +2,11 @@ import { logger } from '../../logger'; import { platform } from '../../platform'; -import { +import { getCache } from '../../util/cache/repository'; +import type { BranchCache, BranchUpgradeCache, - getCache, -} from '../../util/cache/repository'; +} from '../../util/cache/repository/types'; import { getBranchCommit, getBranchParentSha,