diff --git a/lib/datasource/docker/common.ts b/lib/datasource/docker/common.ts index 38c9ef43616ac654f7f8d18d17ca5f12afdd0aa5..758ba2c98bf6b282c0c2bf2409ada532f437bd90 100644 --- a/lib/datasource/docker/common.ts +++ b/lib/datasource/docker/common.ts @@ -1,4 +1,5 @@ -import { ECR, ECRClientConfig } from '@aws-sdk/client-ecr'; +import { ECR } from '@aws-sdk/client-ecr'; +import type { ECRClientConfig } from '@aws-sdk/client-ecr'; import is from '@sindresorhus/is'; import { parse } from 'auth-header'; import hasha from 'hasha'; diff --git a/lib/datasource/nuget/v3.ts b/lib/datasource/nuget/v3.ts index af461330bc885d4b4dca48fc0d30bf2a4ef73864..c3a98e6e40834b90e7407436b55ea9cf09e48bf4 100644 --- a/lib/datasource/nuget/v3.ts +++ b/lib/datasource/nuget/v3.ts @@ -1,6 +1,6 @@ import is from '@sindresorhus/is'; import pAll from 'p-all'; -import * as semver from 'semver'; +import semver from 'semver'; import { XmlDocument } from 'xmldoc'; import { logger } from '../../logger'; import { ExternalHostError } from '../../types/errors/external-host-error'; diff --git a/lib/manager/bazel/update.ts b/lib/manager/bazel/update.ts index 2e40e884682c1bd2fe20819322ab4097963bf4a6..4415aeee8d790e870f5209c9c7176b711fed0fff 100644 --- a/lib/manager/bazel/update.ts +++ b/lib/manager/bazel/update.ts @@ -1,4 +1,4 @@ -import { fromStream } from 'hasha'; +import hasha from 'hasha'; import { logger } from '../../logger'; import * as packageCache from '../../util/cache/package'; import { Http } from '../../util/http'; @@ -55,7 +55,7 @@ async function getHashFromUrl(url: string): Promise<string | null> { return cachedResult; } try { - const hash = await fromStream(http.stream(url), { + const hash = await hasha.fromStream(http.stream(url), { algorithm: 'sha256', }); const cacheMinutes = 3 * 24 * 60; // 3 days diff --git a/lib/manager/gradle/deep/gradle-updates-report.spec.ts b/lib/manager/gradle/deep/gradle-updates-report.spec.ts index 25709740f8f178b14e2c1af451caa9ffdd478ab4..d00e67f212dbafb6e479cc6cddc84fd5e06d828b 100644 --- a/lib/manager/gradle/deep/gradle-updates-report.spec.ts +++ b/lib/manager/gradle/deep/gradle-updates-report.spec.ts @@ -1,4 +1,4 @@ -import * as fs from 'fs-extra'; +import fs from 'fs-extra'; import tmp, { DirectoryResult } from 'tmp-promise'; import * as upath from 'upath'; import { GlobalConfig } from '../../../config/global'; diff --git a/lib/manager/homebrew/update.ts b/lib/manager/homebrew/update.ts index b1c72c33240106ae679c99cb204213d3db011373..e49be2c52a53c74cd5275f7cfd77ad438099f298 100644 --- a/lib/manager/homebrew/update.ts +++ b/lib/manager/homebrew/update.ts @@ -1,4 +1,4 @@ -import { fromStream } from 'hasha'; +import hasha from 'hasha'; import semver from 'semver'; import { logger } from '../../logger'; import { Http } from '../../util/http'; @@ -162,7 +162,7 @@ export async function updateDependency({ newUrl = `https://github.com/${ownerName}/${repoName}/releases/download/${ upgrade.newValue }/${repoName}-${String(semver.coerce(upgrade.newValue))}.tar.gz`; - newSha256 = await fromStream(http.stream(newUrl), { + newSha256 = await hasha.fromStream(http.stream(newUrl), { algorithm: 'sha256', }); } catch (errOuter) { @@ -173,7 +173,7 @@ export async function updateDependency({ const ownerName = String(upgrade.managerData.ownerName); const repoName = String(upgrade.managerData.repoName); newUrl = `https://github.com/${ownerName}/${repoName}/archive/${upgrade.newValue}.tar.gz`; - newSha256 = await fromStream(http.stream(newUrl), { + newSha256 = await hasha.fromStream(http.stream(newUrl), { algorithm: 'sha256', }); } catch (errInner) { diff --git a/lib/manager/metadata.spec.ts b/lib/manager/metadata.spec.ts index 3c1d271c436c8ced8c7025480909453a238ea826..b52744d9f1888c2926a2bf796e6437cc45cd4cb1 100644 --- a/lib/manager/metadata.spec.ts +++ b/lib/manager/metadata.spec.ts @@ -1,4 +1,4 @@ -import * as fs from 'fs-extra'; +import fs from 'fs-extra'; describe('manager/metadata', () => { const managerList: string[] = fs diff --git a/lib/manager/npm/update/locked-dependency/index.ts b/lib/manager/npm/update/locked-dependency/index.ts index a919c61649192df22da028f98267dc63b78b5c3d..1626e72fd7634fff9582c55c3990724d9577d12a 100644 --- a/lib/manager/npm/update/locked-dependency/index.ts +++ b/lib/manager/npm/update/locked-dependency/index.ts @@ -1,5 +1,5 @@ import { logger } from '../../../../logger'; -import * as semver from '../../../../versioning/semver'; +import semver from '../../../../versioning/semver'; import type { UpdateLockedConfig, UpdateLockedResult } from '../../../types'; import * as packageLock from './package-lock'; import * as yarnLock from './yarn-lock'; diff --git a/lib/util/cache/repository/index.ts b/lib/util/cache/repository/index.ts index 6441098c10faa1c557914feafdfbc281cc43143b..ac83fe2590e8df349f278e20efebe308d98eff9d 100644 --- a/lib/util/cache/repository/index.ts +++ b/lib/util/cache/repository/index.ts @@ -1,4 +1,4 @@ -import * as fs from 'fs-extra'; +import fs from 'fs-extra'; import upath from 'upath'; import { GlobalConfig } from '../../../config/global'; import type { diff --git a/lib/util/fs/index.ts b/lib/util/fs/index.ts index 50d179ad20bef7bb18c7e46cb3bc396286e23354..01a0dd000a6a6ad2783cbffa3933834845932d0f 100644 --- a/lib/util/fs/index.ts +++ b/lib/util/fs/index.ts @@ -1,7 +1,7 @@ import stream from 'stream'; import util from 'util'; import is from '@sindresorhus/is'; -import * as fs from 'fs-extra'; +import fs from 'fs-extra'; import upath from 'upath'; import { GlobalConfig } from '../../config/global'; import { logger } from '../../logger'; diff --git a/lib/util/fs/proxies.spec.ts b/lib/util/fs/proxies.spec.ts index c2d057e93c159b36e41aa54c5e904ca03f8d042b..8ec054f8d85e81569130d73c06d82857f18d3afc 100644 --- a/lib/util/fs/proxies.spec.ts +++ b/lib/util/fs/proxies.spec.ts @@ -1,4 +1,4 @@ -import * as fs from 'fs-extra'; +import fs from 'fs-extra'; import { remove } from './proxies'; jest.mock('fs-extra'); diff --git a/lib/util/fs/proxies.ts b/lib/util/fs/proxies.ts index 4008ec28950772100ae6ae0dbf004dd741110105..3fe9c68833b394d79950b68f39a0b63fd39532f0 100644 --- a/lib/util/fs/proxies.ts +++ b/lib/util/fs/proxies.ts @@ -1,5 +1,5 @@ -import * as fs from 'fs-extra'; -import { MoveOptions, WriteFileOptions } from 'fs-extra'; +import fs from 'fs-extra'; +import type { MoveOptions, WriteFileOptions } from 'fs-extra'; // istanbul ignore next export function stat(path: string | Buffer): Promise<fs.Stats> { diff --git a/lib/util/git/index.spec.ts b/lib/util/git/index.spec.ts index 1b4e1282193ee7060cd701387816c5746aaaf58f..38afe5b30ff43a30f83149b2c6d9cbc08ccb2939 100644 --- a/lib/util/git/index.spec.ts +++ b/lib/util/git/index.spec.ts @@ -123,7 +123,7 @@ describe('util/git/index', () => { url: base.path, }); await git.syncGit(); - expect(await fs.exists(tmpDir.path + '/.gitmodules')).toBeTruthy(); + expect(await fs.pathExists(tmpDir.path + '/.gitmodules')).toBeTruthy(); // FIXME: explicit assert condition expect(await git.getFileList()).toMatchSnapshot(); await repo.reset(['--hard', 'HEAD^']); @@ -554,7 +554,7 @@ describe('util/git/index', () => { url: base.path, }); await git.syncGit(); - expect(await fs.exists(tmpDir.path + '/.gitmodules')).toBeTruthy(); + expect(await fs.pathExists(tmpDir.path + '/.gitmodules')).toBeTruthy(); await repo.reset(['--hard', 'HEAD^']); }); diff --git a/lib/util/git/index.ts b/lib/util/git/index.ts index 3169292138654dbb29ea1be2dacb91c240ed3c91..796ebffad6354889e54df692c948c860da1784ed 100644 --- a/lib/util/git/index.ts +++ b/lib/util/git/index.ts @@ -1,6 +1,7 @@ import URL from 'url'; import fs from 'fs-extra'; -import Git, { Options, ResetMode, SimpleGit, TaskOptions } from 'simple-git'; +import type { Options, SimpleGit, TaskOptions } from 'simple-git'; +import * as simpleGit from 'simple-git'; import upath from 'upath'; import { configFileNames } from '../../config/app-strings'; import { GlobalConfig } from '../../config/global'; @@ -33,10 +34,6 @@ import type { export { setNoVerify } from './config'; export { setPrivateKey } from './private-key'; -declare module 'fs-extra' { - export function exists(pathLike: string): Promise<boolean>; -} - // istanbul ignore next function checkForPlatformFailure(err: Error): void { if (process.env.NODE_ENV === 'test') { @@ -148,7 +145,7 @@ export const GIT_MINIMUM_VERSION = '2.33.0'; // git show-current export async function validateGitVersion(): Promise<boolean> { let version: string; - const globalGit = Git(); + const globalGit = simpleGit.default(); try { const raw = await globalGit.raw(['--version']); for (const section of raw.split(/\s+/)) { @@ -211,7 +208,7 @@ export async function initRepo(args: StorageConfig): Promise<void> { config.additionalBranches = []; config.branchIsModified = {}; const { localDir } = GlobalConfig.get(); - git = Git(localDir, simpleGitConfig()); + git = simpleGit.default(localDir, simpleGitConfig()); gitInitialized = false; await fetchBranchCommits(); } @@ -314,7 +311,7 @@ export async function syncGit(): Promise<void> { const gitHead = upath.join(localDir, '.git/HEAD'); let clone = true; - if (await fs.exists(gitHead)) { + if (await fs.pathExists(gitHead)) { try { await git.raw(['remote', 'set-url', 'origin', config.url]); await resetToBranch(await getDefaultBranch(git)); @@ -446,7 +443,7 @@ export async function checkoutBranch(branchName: string): Promise<CommitSha> { if (latestCommitDate) { logger.debug({ branchName, latestCommitDate }, 'latest commit'); } - await git.reset(ResetMode.HARD); + await git.reset(simpleGit.ResetMode.HARD); return config.currentBranchSha; } catch (err) /* istanbul ignore next */ { checkForPlatformFailure(err); @@ -592,7 +589,7 @@ export async function mergeBranch(branchName: string): Promise<void> { let status; try { await syncGit(); - await git.reset(ResetMode.HARD); + await git.reset(simpleGit.ResetMode.HARD); await git.checkout(['-B', branchName, 'origin/' + branchName]); await git.checkout([ '-B', @@ -688,7 +685,7 @@ export async function commitFiles({ await configSigningKey(localDir); await writeGitAuthor(); try { - await git.reset(ResetMode.HARD); + await git.reset(simpleGit.ResetMode.HARD); await git.raw(['clean', '-fd']); await git.checkout(['-B', branchName, 'origin/' + config.currentBranch]); const deletedFiles: string[] = []; diff --git a/lib/util/html.spec.ts b/lib/util/html.spec.ts index 6f3564f723ffd41fda5976bed9db2ca6ec738e32..09795d27ed63095bc3e801ba8bf9a19c04f670ca 100644 --- a/lib/util/html.spec.ts +++ b/lib/util/html.spec.ts @@ -1,13 +1,14 @@ -import { HTMLElement, parse } from './html'; +import * as parser from 'node-html-parser'; +import { parse } from './html'; describe('util/html', () => { it('parses HTML', () => { const body = parse('<div>Hello, world!</div>'); expect(body.childNodes).toHaveLength(1); - const div = body.childNodes[0] as HTMLElement; + const div = body.childNodes[0] as parser.HTMLElement; expect(div.tagName).toBe('DIV'); expect(div.textContent).toBe('Hello, world!'); - expect(div instanceof HTMLElement).toBeTrue(); + expect(div instanceof parser.HTMLElement).toBeTrue(); }); it('returns empty', () => { const body = parse(''); @@ -29,6 +30,6 @@ describe('util/html', () => { const div = childNodesA[0]; expect(div.tagName).toBe('A'); expect(div.textContent).toBe('node A'); - expect(div instanceof HTMLElement).toBe(true); + expect(div instanceof parser.HTMLElement).toBe(true); }); }); diff --git a/lib/util/html.ts b/lib/util/html.ts index d0ee29fd8b630eef84bf6f70a6e34cce58439d64..b0edc8be4d6addf368f2e191aecb0eb323051ec0 100644 --- a/lib/util/html.ts +++ b/lib/util/html.ts @@ -1,6 +1,7 @@ -import { HTMLElement, Options, parse as _parse } from 'node-html-parser'; +import type { HTMLElement, Options } from 'node-html-parser'; +import _parse from 'node-html-parser'; -export { HTMLElement }; +export type { HTMLElement, Options }; export function parse(html: string, config?: Partial<Options>): HTMLElement { if (typeof config !== 'undefined') { diff --git a/lib/util/template/index.ts b/lib/util/template/index.ts index 92b78ecedce39c1bf650c141cd2cad8c3c1a40e6..344c398da58f30ada1c65a568d94ebf3154c6949 100644 --- a/lib/util/template/index.ts +++ b/lib/util/template/index.ts @@ -1,5 +1,5 @@ import is from '@sindresorhus/is'; -import * as handlebars from 'handlebars'; +import handlebars from 'handlebars'; import { GlobalConfig } from '../../config/global'; import { logger } from '../../logger'; import { clone } from '../clone'; diff --git a/lib/versioning/npm/index.ts b/lib/versioning/npm/index.ts index b2827405c16b8b53b1c97fce70c99a036357322e..32a6c157824c23c0bad5ce7078e7edad2b3c3a8f 100644 --- a/lib/versioning/npm/index.ts +++ b/lib/versioning/npm/index.ts @@ -1,5 +1,5 @@ -import * as semver from 'semver'; -import { is as isStable } from 'semver-stable'; +import semver from 'semver'; +import stable from 'semver-stable'; import type { VersioningApi } from '../types'; import { getNewValue } from './range'; @@ -47,7 +47,7 @@ export const api: VersioningApi = { isGreaterThan, isLessThanRange, isSingleVersion, - isStable, + isStable: stable.is, isValid, isVersion, matches, diff --git a/lib/versioning/npm/range.ts b/lib/versioning/npm/range.ts index fb4d15815ec2c079874b85d6f57933ab18a0ef83..71638bf8710696ede4eabc6a35ddea80136a60c9 100644 --- a/lib/versioning/npm/range.ts +++ b/lib/versioning/npm/range.ts @@ -1,16 +1,18 @@ -import { - inc as increment, - valid as isVersion, +import semver from 'semver'; +import semverUtils from 'semver-utils'; +import { logger } from '../../logger'; +import { regEx } from '../../util/regex'; +import type { NewValueConfig } from '../types'; + +const { + inc: increment, + valid: isVersion, major, minor, patch, prerelease, satisfies, -} from 'semver'; -import { parseRange } from 'semver-utils'; -import { logger } from '../../logger'; -import { regEx } from '../../util/regex'; -import type { NewValueConfig } from '../types'; +} = semver; function replaceCaretValue(oldValue: string, newValue: string): string { const toVersionMajor = major(newValue); @@ -73,7 +75,7 @@ export function getNewValue({ newVersion, }); } - const parsedRange = parseRange(currentValue); + const parsedRange = semverUtils.parseRange(currentValue); const element = parsedRange[parsedRange.length - 1]; if (rangeStrategy === 'widen') { if (satisfies(newVersion, currentValue)) { @@ -164,7 +166,7 @@ export function getNewValue({ return currentValue; } } else { - const newRange = parseRange(currentValue); + const newRange = semverUtils.parseRange(currentValue); const versions = newRange.map((x) => { const subRange = x.semver; const bumpedSubRange = getNewValue({ diff --git a/lib/workers/global/config/parse/file.ts b/lib/workers/global/config/parse/file.ts index fa2076c3c1be4bafbb0f986649f39003b2e899bb..66f195e0a1da3666979a7619c8e6065f35175725 100644 --- a/lib/workers/global/config/parse/file.ts +++ b/lib/workers/global/config/parse/file.ts @@ -1,5 +1,5 @@ import is from '@sindresorhus/is'; -import * as fs from 'fs-extra'; +import fs from 'fs-extra'; import { load } from 'js-yaml'; import JSON5 from 'json5'; import upath from 'upath'; diff --git a/lib/workers/repository/init/cache.ts b/lib/workers/repository/init/cache.ts index 7144938a358054a7c15a87fc4d02583f0bf22ff8..e9668143f88fa4e765e67473ff3b6977e8915f22 100644 --- a/lib/workers/repository/init/cache.ts +++ b/lib/workers/repository/init/cache.ts @@ -1,4 +1,4 @@ -import * as fs from 'fs-extra'; +import fs from 'fs-extra'; import type { RenovateConfig } from '../../../config/types'; import * as memCache from '../../../util/cache/memory'; import * as repositoryCache from '../../../util/cache/repository'; diff --git a/lib/workers/repository/process/lookup/filter.ts b/lib/workers/repository/process/lookup/filter.ts index 522840e1bec3c1bf3053a156ef193ee42c13b45d..fe604ff7244d48123e616c4c5daf248fb3e565f3 100644 --- a/lib/workers/repository/process/lookup/filter.ts +++ b/lib/workers/repository/process/lookup/filter.ts @@ -1,4 +1,4 @@ -import * as semver from 'semver'; +import semver from 'semver'; import { CONFIG_VALIDATION } from '../../../../constants/error-messages'; import type { Release } from '../../../../datasource/types'; import { logger } from '../../../../logger'; diff --git a/lib/workers/repository/updates/branch-name.ts b/lib/workers/repository/updates/branch-name.ts index 7e45f0802df0efe0005f91867f8eaf1bcc027bed..eed788922c747a65440e8a75d4d1e56a168b74be 100644 --- a/lib/workers/repository/updates/branch-name.ts +++ b/lib/workers/repository/updates/branch-name.ts @@ -1,4 +1,4 @@ -import { clean as cleanGitRef } from 'clean-git-ref'; +import cleanGitRef from 'clean-git-ref'; import hasha from 'hasha'; import slugify from 'slugify'; import type { RenovateConfig } from '../../../config/types'; @@ -19,7 +19,8 @@ const RE_MULTIPLE_DASH = regEx(/--+/g); * - chained dashes(breaks markdown comments) are replaced by single dash */ function cleanBranchName(branchName: string): string { - return cleanGitRef(branchName) + return cleanGitRef + .clean(branchName) .replace(regEx(/^\.|\.$/), '') // leading or trailing dot .replace(regEx(/\/\./g), '/') // leading dot after slash .replace(regEx(/\s/g), '') // whitespace