diff --git a/lib/config/admin.ts b/lib/config/admin.ts index 83eb5bdfca..38e856b891 100644 --- a/lib/config/admin.ts +++ b/lib/config/admin.ts @@ -1,9 +1,9 @@ -import type { RenovateConfig, RepoAdminConfig } from './types'; +import type { RenovateConfig, RepoGlobalConfig } from './types'; -let adminConfig: RepoAdminConfig = {}; +let repoGlobalConfig: RepoGlobalConfig = {}; // TODO: once admin config work is complete, add a test to make sure this list includes all options with admin=true (#9603) -const repoAdminOptions = [ +const repoGlobalOptions = [ 'allowCustomCrateRegistries', 'allowPostUpgradeCommandTemplating', 'allowScripts', @@ -21,18 +21,18 @@ const repoAdminOptions = [ 'cacheDir', ]; -export function setAdminConfig( - config: RenovateConfig | RepoAdminConfig = {} +export function setGlobalConfig( + config: RenovateConfig | RepoGlobalConfig = {} ): RenovateConfig { - adminConfig = {}; + repoGlobalConfig = {}; const result = { ...config }; - for (const option of repoAdminOptions) { - adminConfig[option] = config[option]; + for (const option of repoGlobalOptions) { + repoGlobalConfig[option] = config[option]; delete result[option]; // eslint-disable-line no-param-reassign } return result; } -export function getAdminConfig(): RepoAdminConfig { - return adminConfig; +export function getGlobalConfig(): RepoGlobalConfig { + return repoGlobalConfig; } diff --git a/lib/config/decrypt.spec.ts b/lib/config/decrypt.spec.ts index 427ca926a4..a4e023f427 100644 --- a/lib/config/decrypt.spec.ts +++ b/lib/config/decrypt.spec.ts @@ -1,5 +1,5 @@ import { getName, loadFixture } from '../../test/util'; -import { setAdminConfig } from './admin'; +import { setGlobalConfig } from './admin'; import { decryptConfig } from './decrypt'; import type { RenovateConfig } from './types'; @@ -10,7 +10,7 @@ describe(getName(), () => { let config: RenovateConfig; beforeEach(() => { config = {}; - setAdminConfig(); + setGlobalConfig(); }); it('returns empty with no privateKey', () => { delete config.encrypted; @@ -25,17 +25,17 @@ describe(getName(), () => { }); it('handles invalid encrypted type', () => { config.encrypted = 1; - setAdminConfig({ privateKey }); + setGlobalConfig({ privateKey }); const res = decryptConfig(config); expect(res.encrypted).not.toBeDefined(); }); it('handles invalid encrypted value', () => { config.encrypted = { a: 1 }; - setAdminConfig({ privateKey }); + setGlobalConfig({ privateKey }); expect(() => decryptConfig(config)).toThrow(Error('config-validation')); }); it('replaces npm token placeholder in npmrc', () => { - setAdminConfig({ privateKey }); + setGlobalConfig({ privateKey }); config.npmrc = '//registry.npmjs.org/:_authToken=${NPM_TOKEN}\n//registry.npmjs.org/:_authToken=${NPM_TOKEN}\n'; // eslint-disable-line no-template-curly-in-string config.encrypted = { @@ -50,7 +50,7 @@ describe(getName(), () => { ); }); it('appends npm token in npmrc', () => { - setAdminConfig({ privateKey }); + setGlobalConfig({ privateKey }); config.npmrc = 'foo=bar\n'; // eslint-disable-line no-template-curly-in-string config.encrypted = { npmToken: @@ -62,7 +62,7 @@ describe(getName(), () => { expect(res.npmrc).toMatchSnapshot(); }); it('decrypts nested', () => { - setAdminConfig({ privateKey }); + setGlobalConfig({ privateKey }); config.packageFiles = [ { packageFile: 'package.json', diff --git a/lib/config/decrypt.ts b/lib/config/decrypt.ts index 5ad212fa6a..eabc39909b 100644 --- a/lib/config/decrypt.ts +++ b/lib/config/decrypt.ts @@ -3,13 +3,13 @@ import is from '@sindresorhus/is'; import { logger } from '../logger'; import { maskToken } from '../util/mask'; import { add } from '../util/sanitize'; -import { getAdminConfig } from './admin'; +import { getGlobalConfig } from './admin'; import type { RenovateConfig } from './types'; export function decryptConfig(config: RenovateConfig): RenovateConfig { logger.trace({ config }, 'decryptConfig()'); const decryptedConfig = { ...config }; - const { privateKey } = getAdminConfig(); + const { privateKey } = getGlobalConfig(); for (const [key, val] of Object.entries(config)) { if (key === 'encrypted' && is.object(val)) { logger.debug({ config: val }, 'Found encrypted config'); diff --git a/lib/config/migration.spec.ts b/lib/config/migration.spec.ts index 727e12af86..b91b3b311e 100644 --- a/lib/config/migration.spec.ts +++ b/lib/config/migration.spec.ts @@ -1,6 +1,6 @@ import { getName } from '../../test/util'; import { PLATFORM_TYPE_GITHUB } from '../constants/platforms'; -import { setAdminConfig } from './admin'; +import { setGlobalConfig } from './admin'; import { getConfig } from './defaults'; import * as configMigration from './migration'; import type { @@ -707,7 +707,7 @@ describe(getName(), () => { }); }); it('it migrates presets', () => { - setAdminConfig({ + setGlobalConfig({ migratePresets: { '@org': 'local>org/renovate-config', '@org2/foo': '', diff --git a/lib/config/migration.ts b/lib/config/migration.ts index 3db7a6c91f..b269094a52 100644 --- a/lib/config/migration.ts +++ b/lib/config/migration.ts @@ -3,7 +3,7 @@ import is from '@sindresorhus/is'; import { dequal } from 'dequal'; import { logger } from '../logger'; import { clone } from '../util/clone'; -import { getAdminConfig } from './admin'; +import { getGlobalConfig } from './admin'; import { getOptions } from './options'; import { removedPresets } from './presets/common'; import type { @@ -56,7 +56,7 @@ export function migrateConfig( 'optionalDependencies', 'peerDependencies', ]; - const { migratePresets } = getAdminConfig(); + const { migratePresets } = getGlobalConfig(); for (const [key, val] of Object.entries(config)) { if (removedOptions.includes(key)) { delete migratedConfig[key]; diff --git a/lib/config/presets/npm/index.spec.ts b/lib/config/presets/npm/index.spec.ts index 19151aa612..5754cea5d1 100644 --- a/lib/config/presets/npm/index.spec.ts +++ b/lib/config/presets/npm/index.spec.ts @@ -1,6 +1,6 @@ import * as httpMock from '../../../../test/http-mock'; import { getName } from '../../../../test/util'; -import { setAdminConfig } from '../../admin'; +import { setGlobalConfig } from '../../admin'; import * as npm from '.'; jest.mock('registry-auth-token'); @@ -9,7 +9,7 @@ jest.mock('delay'); describe(getName(), () => { beforeEach(() => { jest.resetAllMocks(); - setAdminConfig(); + setGlobalConfig(); }); afterEach(() => { delete process.env.RENOVATE_CACHE_NPM_MINUTES; diff --git a/lib/config/types.ts b/lib/config/types.ts index fdd56479c4..c7801fa198 100644 --- a/lib/config/types.ts +++ b/lib/config/types.ts @@ -86,7 +86,7 @@ export interface GlobalOnlyConfig { // Config options used within the repository worker, but not user configurable // The below should contain config options where admin=true -export interface RepoAdminConfig { +export interface RepoGlobalConfig { allowCustomCrateRegistries?: boolean; allowPostUpgradeCommandTemplating?: boolean; allowScripts?: boolean; diff --git a/lib/datasource/crate/index.spec.ts b/lib/datasource/crate/index.spec.ts index 47ba345702..a23552bc1b 100644 --- a/lib/datasource/crate/index.spec.ts +++ b/lib/datasource/crate/index.spec.ts @@ -6,8 +6,8 @@ import { dirname, join } from 'upath'; import { getPkgReleases } from '..'; import * as httpMock from '../../../test/http-mock'; import { getName, loadFixture } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; -import type { RepoAdminConfig } from '../../config/types'; +import { setGlobalConfig } from '../../config/admin'; +import type { RepoGlobalConfig } from '../../config/types'; import * as memCache from '../../util/cache/memory'; import { RegistryFlavor, RegistryInfo } from './types'; import { id as datasource, fetchCrateRecordsPayload, getIndexSuffix } from '.'; @@ -75,7 +75,7 @@ describe(getName(), () => { describe('getReleases', () => { let tmpDir: DirectoryResult | null; - let adminConfig: RepoAdminConfig; + let adminConfig: RepoGlobalConfig; beforeEach(async () => { tmpDir = await dir(); @@ -84,7 +84,7 @@ describe(getName(), () => { localDir: join(tmpDir.path, 'local'), cacheDir: join(tmpDir.path, 'cache'), }; - setAdminConfig(adminConfig); + setGlobalConfig(adminConfig); simpleGit.mockReset(); memCache.init(); @@ -93,7 +93,7 @@ describe(getName(), () => { afterEach(() => { fs.rmdirSync(tmpDir.path, { recursive: true }); tmpDir = null; - setAdminConfig(); + setGlobalConfig(); }); it('returns null for missing registry url', async () => { @@ -229,7 +229,7 @@ describe(getName(), () => { }); it('clones cloudsmith private registry', async () => { const { mockClone } = setupGitMocks(); - setAdminConfig({ ...adminConfig, allowCustomCrateRegistries: true }); + setGlobalConfig({ ...adminConfig, allowCustomCrateRegistries: true }); const url = 'https://dl.cloudsmith.io/basic/myorg/myrepo/cargo/index.git'; const res = await getPkgReleases({ datasource, @@ -243,7 +243,7 @@ describe(getName(), () => { }); it('clones other private registry', async () => { const { mockClone } = setupGitMocks(); - setAdminConfig({ ...adminConfig, allowCustomCrateRegistries: true }); + setGlobalConfig({ ...adminConfig, allowCustomCrateRegistries: true }); const url = 'https://github.com/mcorbin/testregistry'; const res = await getPkgReleases({ datasource, @@ -257,7 +257,7 @@ describe(getName(), () => { }); it('clones once then reuses the cache', async () => { const { mockClone } = setupGitMocks(); - setAdminConfig({ ...adminConfig, allowCustomCrateRegistries: true }); + setGlobalConfig({ ...adminConfig, allowCustomCrateRegistries: true }); const url = 'https://github.com/mcorbin/othertestregistry'; await getPkgReleases({ datasource, @@ -273,7 +273,7 @@ describe(getName(), () => { }); it('guards against race conditions while cloning', async () => { const { mockClone } = setupGitMocks(250); - setAdminConfig({ ...adminConfig, allowCustomCrateRegistries: true }); + setGlobalConfig({ ...adminConfig, allowCustomCrateRegistries: true }); const url = 'https://github.com/mcorbin/othertestregistry'; await Promise.all([ @@ -299,7 +299,7 @@ describe(getName(), () => { }); it('returns null when git clone fails', async () => { setupErrorGitMock(); - setAdminConfig({ ...adminConfig, allowCustomCrateRegistries: true }); + setGlobalConfig({ ...adminConfig, allowCustomCrateRegistries: true }); const url = 'https://github.com/mcorbin/othertestregistry'; const result = await getPkgReleases({ diff --git a/lib/datasource/crate/index.ts b/lib/datasource/crate/index.ts index 87108e683e..52b44e2147 100644 --- a/lib/datasource/crate/index.ts +++ b/lib/datasource/crate/index.ts @@ -1,7 +1,7 @@ import hasha from 'hasha'; import Git from 'simple-git'; import { join } from 'upath'; -import { getAdminConfig } from '../../config/admin'; +import { getGlobalConfig } from '../../config/admin'; import { logger } from '../../logger'; import { ExternalHostError } from '../../types/errors/external-host-error'; import * as memCache from '../../util/cache/memory'; @@ -135,7 +135,7 @@ async function fetchRegistryInfo( }; if (flavor !== RegistryFlavor.CratesIo) { - if (!getAdminConfig().allowCustomCrateRegistries) { + if (!getGlobalConfig().allowCustomCrateRegistries) { logger.warn( 'crate datasource: allowCustomCrateRegistries=true is required for registries other than crates.io, bailing out' ); diff --git a/lib/datasource/npm/index.spec.ts b/lib/datasource/npm/index.spec.ts index b81d2b79c1..3ee2290cd4 100644 --- a/lib/datasource/npm/index.spec.ts +++ b/lib/datasource/npm/index.spec.ts @@ -3,7 +3,7 @@ import _registryAuthToken from 'registry-auth-token'; import { getPkgReleases } from '..'; import * as httpMock from '../../../test/http-mock'; import { getName } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; +import { setGlobalConfig } from '../../config/admin'; import { EXTERNAL_HOST_ERROR } from '../../constants/error-messages'; import * as hostRules from '../../util/host-rules'; import { id as datasource, getNpmrc, resetCache, setNpmrc } from '.'; @@ -18,7 +18,7 @@ let npmResponse: any; describe(getName(), () => { beforeEach(() => { jest.resetAllMocks(); - setAdminConfig(); + setGlobalConfig(); hostRules.clear(); resetCache(); setNpmrc(); @@ -358,7 +358,7 @@ describe(getName(), () => { .reply(200, npmResponse); process.env.REGISTRY = 'https://registry.from-env.com'; process.env.RENOVATE_CACHE_NPM_MINUTES = '15'; - setAdminConfig({ exposeAllEnv: true }); + setGlobalConfig({ exposeAllEnv: true }); // eslint-disable-next-line no-template-curly-in-string const npmrc = 'registry=${REGISTRY}'; const res = await getPkgReleases({ datasource, depName: 'foobar', npmrc }); @@ -367,7 +367,7 @@ describe(getName(), () => { }); it('should throw error if necessary env var is not present', () => { - setAdminConfig({ exposeAllEnv: true }); + setGlobalConfig({ exposeAllEnv: true }); // eslint-disable-next-line no-template-curly-in-string expect(() => setNpmrc('registry=${REGISTRY_MISSING}')).toThrow( Error('env-replace') diff --git a/lib/datasource/npm/npmrc.spec.ts b/lib/datasource/npm/npmrc.spec.ts index 23ecde3dca..e95c091b85 100644 --- a/lib/datasource/npm/npmrc.spec.ts +++ b/lib/datasource/npm/npmrc.spec.ts @@ -1,5 +1,5 @@ import { getName, mocked } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; +import { setGlobalConfig } from '../../config/admin'; import * as _sanitize from '../../util/sanitize'; import { getNpmrc, setNpmrc } from './npmrc'; @@ -10,7 +10,7 @@ const sanitize = mocked(_sanitize); describe(getName(), () => { beforeEach(() => { setNpmrc(''); - setAdminConfig(); + setGlobalConfig(); jest.resetAllMocks(); }); @@ -38,7 +38,7 @@ describe(getName(), () => { }); it('sanitize _authtoken with high trust', () => { - setAdminConfig({ exposeAllEnv: true }); + setGlobalConfig({ exposeAllEnv: true }); process.env.TEST_TOKEN = 'test'; setNpmrc( // eslint-disable-next-line no-template-curly-in-string diff --git a/lib/datasource/npm/npmrc.ts b/lib/datasource/npm/npmrc.ts index 832d2080e7..7723367745 100644 --- a/lib/datasource/npm/npmrc.ts +++ b/lib/datasource/npm/npmrc.ts @@ -3,7 +3,7 @@ import is from '@sindresorhus/is'; import ini from 'ini'; import registryAuthToken from 'registry-auth-token'; import getRegistryUrl from 'registry-auth-token/registry-url'; -import { getAdminConfig } from '../../config/admin'; +import { getGlobalConfig } from '../../config/admin'; import { logger } from '../../logger'; import type { OutgoingHttpHeaders } from '../../util/http/types'; import { maskToken } from '../../util/mask'; @@ -60,7 +60,7 @@ export function setNpmrc(input?: string): void { npmrcRaw = input; logger.debug('Setting npmrc'); npmrc = ini.parse(input.replace(/\\n/g, '\n')); - const { exposeAllEnv } = getAdminConfig(); + const { exposeAllEnv } = getGlobalConfig(); for (const [key, val] of Object.entries(npmrc)) { if (!exposeAllEnv) { sanitize(key, val); diff --git a/lib/manager/batect/extract.spec.ts b/lib/manager/batect/extract.spec.ts index 9596f4b7bb..f90d73f189 100644 --- a/lib/manager/batect/extract.spec.ts +++ b/lib/manager/batect/extract.spec.ts @@ -1,6 +1,6 @@ import { getName } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; -import type { RepoAdminConfig } from '../../config/types'; +import { setGlobalConfig } from '../../config/admin'; +import type { RepoGlobalConfig } from '../../config/types'; import { id as gitTagDatasource } from '../../datasource/git-tags'; import { id as dockerVersioning } from '../../versioning/docker'; import { id as semverVersioning } from '../../versioning/semver'; @@ -27,7 +27,7 @@ function createGitDependency(repo: string, version: string): PackageDependency { }; } -const adminConfig: RepoAdminConfig = { +const adminConfig: RepoGlobalConfig = { localDir: '', }; @@ -36,11 +36,11 @@ const config: ExtractConfig = {}; describe(getName(), () => { describe('extractPackageFile()', () => { beforeEach(() => { - setAdminConfig(adminConfig); + setGlobalConfig(adminConfig); }); afterEach(() => { - setAdminConfig(); + setGlobalConfig(); }); it('returns empty array for empty configuration file', async () => { diff --git a/lib/manager/bundler/artifacts.spec.ts b/lib/manager/bundler/artifacts.spec.ts index 116ca3e801..f4ab00611e 100644 --- a/lib/manager/bundler/artifacts.spec.ts +++ b/lib/manager/bundler/artifacts.spec.ts @@ -2,8 +2,8 @@ import { exec as _exec } from 'child_process'; import { join } from 'upath'; import { envMock, mockExecAll } from '../../../test/exec-util'; import { fs, git, mocked } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; -import type { RepoAdminConfig } from '../../config/types'; +import { setGlobalConfig } from '../../config/admin'; +import type { RepoGlobalConfig } from '../../config/types'; import * as _datasource from '../../datasource'; import * as docker from '../../util/exec/docker'; import * as _env from '../../util/exec/env'; @@ -26,7 +26,7 @@ jest.mock('../../../lib/util/git'); jest.mock('../../../lib/util/host-rules'); jest.mock('./host-rules'); -const adminConfig: RepoAdminConfig = { +const adminConfig: RepoGlobalConfig = { // `join` fixes Windows CI localDir: join('/tmp/github/some/repo'), cacheDir: join('/tmp/cache'), @@ -52,11 +52,11 @@ describe('bundler.updateArtifacts()', () => { bundlerHostRules.findAllAuthenticatable.mockReturnValue([]); docker.resetPrefetchedImages(); - setAdminConfig(adminConfig); + setGlobalConfig(adminConfig); fs.ensureCacheDir.mockResolvedValue('/tmp/cache/others/gem'); }); afterEach(() => { - setAdminConfig(); + setGlobalConfig(); }); it('returns null by default', async () => { expect( @@ -106,7 +106,7 @@ describe('bundler.updateArtifacts()', () => { expect(execSnapshots).toMatchSnapshot(); }); it('works explicit global binarySource', async () => { - setAdminConfig({ ...adminConfig, binarySource: 'global' }); + setGlobalConfig({ ...adminConfig, binarySource: 'global' }); fs.readLocalFile.mockResolvedValueOnce('Current Gemfile.lock'); fs.writeLocalFile.mockResolvedValueOnce(null as never); fs.readLocalFile.mockResolvedValueOnce(null); @@ -127,7 +127,7 @@ describe('bundler.updateArtifacts()', () => { }); describe('Docker', () => { beforeEach(() => { - setAdminConfig({ + setGlobalConfig({ ...adminConfig, binarySource: 'docker', }); @@ -159,7 +159,7 @@ describe('bundler.updateArtifacts()', () => { expect(execSnapshots).toMatchSnapshot(); }); it('constraints options', async () => { - setAdminConfig({ ...adminConfig, binarySource: 'docker' }); + setGlobalConfig({ ...adminConfig, binarySource: 'docker' }); fs.readLocalFile.mockResolvedValueOnce('Current Gemfile.lock'); fs.writeLocalFile.mockResolvedValueOnce(null as never); datasource.getPkgReleases.mockResolvedValueOnce({ @@ -191,7 +191,7 @@ describe('bundler.updateArtifacts()', () => { expect(execSnapshots).toMatchSnapshot(); }); it('invalid constraints options', async () => { - setAdminConfig({ ...adminConfig, binarySource: 'docker' }); + setGlobalConfig({ ...adminConfig, binarySource: 'docker' }); fs.readLocalFile.mockResolvedValueOnce('Current Gemfile.lock'); fs.writeLocalFile.mockResolvedValueOnce(null as never); datasource.getPkgReleases.mockResolvedValueOnce({ @@ -224,7 +224,7 @@ describe('bundler.updateArtifacts()', () => { }); it('injects bundler host configuration environment variables', async () => { - setAdminConfig({ ...adminConfig, binarySource: 'docker' }); + setGlobalConfig({ ...adminConfig, binarySource: 'docker' }); fs.readLocalFile.mockResolvedValueOnce('Current Gemfile.lock'); fs.writeLocalFile.mockResolvedValueOnce(null as never); fs.readLocalFile.mockResolvedValueOnce('1.2.0'); @@ -264,7 +264,7 @@ describe('bundler.updateArtifacts()', () => { }); it('injects bundler host configuration as command with bundler < 2', async () => { - setAdminConfig({ ...adminConfig, binarySource: 'docker' }); + setGlobalConfig({ ...adminConfig, binarySource: 'docker' }); fs.readLocalFile.mockResolvedValueOnce('Current Gemfile.lock'); fs.writeLocalFile.mockResolvedValueOnce(null as never); fs.readLocalFile.mockResolvedValueOnce('1.2.0'); @@ -309,7 +309,7 @@ describe('bundler.updateArtifacts()', () => { }); it('injects bundler host configuration as command with bundler >= 2', async () => { - setAdminConfig({ ...adminConfig, binarySource: 'docker' }); + setGlobalConfig({ ...adminConfig, binarySource: 'docker' }); fs.readLocalFile.mockResolvedValueOnce('Current Gemfile.lock'); fs.writeLocalFile.mockResolvedValueOnce(null as never); fs.readLocalFile.mockResolvedValueOnce('1.2.0'); @@ -354,7 +354,7 @@ describe('bundler.updateArtifacts()', () => { }); it('injects bundler host configuration as command with bundler == latest', async () => { - setAdminConfig({ ...adminConfig, binarySource: 'docker' }); + setGlobalConfig({ ...adminConfig, binarySource: 'docker' }); fs.readLocalFile.mockResolvedValueOnce('Current Gemfile.lock'); fs.writeLocalFile.mockResolvedValueOnce(null as never); fs.readLocalFile.mockResolvedValueOnce('1.2.0'); diff --git a/lib/manager/cargo/artifacts.spec.ts b/lib/manager/cargo/artifacts.spec.ts index e955e7559b..699a13707e 100644 --- a/lib/manager/cargo/artifacts.spec.ts +++ b/lib/manager/cargo/artifacts.spec.ts @@ -3,8 +3,8 @@ import _fs from 'fs-extra'; import { join } from 'upath'; import { envMock, mockExecAll } from '../../../test/exec-util'; import { git, mocked } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; -import type { RepoAdminConfig } from '../../config/types'; +import { setGlobalConfig } from '../../config/admin'; +import type { RepoGlobalConfig } from '../../config/types'; import * as docker from '../../util/exec/docker'; import * as _env from '../../util/exec/env'; import type { UpdateArtifactsConfig } from '../types'; @@ -22,7 +22,7 @@ const env = mocked(_env); const config: UpdateArtifactsConfig = {}; -const adminConfig: RepoAdminConfig = { +const adminConfig: RepoGlobalConfig = { // `join` fixes Windows CI localDir: join('/tmp/github/some/repo'), }; @@ -33,11 +33,11 @@ describe('.updateArtifacts()', () => { jest.resetModules(); env.getChildProcessEnv.mockReturnValue(envMock.basic); - setAdminConfig(adminConfig); + setGlobalConfig(adminConfig); docker.resetPrefetchedImages(); }); afterEach(() => { - setAdminConfig(); + setGlobalConfig(); }); it('returns null if no Cargo.lock found', async () => { fs.stat.mockRejectedValue(new Error('not found!')); @@ -171,7 +171,7 @@ describe('.updateArtifacts()', () => { it('returns updated Cargo.lock with docker', async () => { fs.stat.mockResolvedValueOnce({ name: 'Cargo.lock' } as any); - setAdminConfig({ ...adminConfig, binarySource: 'docker' }); + setGlobalConfig({ ...adminConfig, binarySource: 'docker' }); git.getFile.mockResolvedValueOnce('Old Cargo.lock'); const execSnapshots = mockExecAll(exec); fs.readFile.mockResolvedValueOnce('New Cargo.lock' as any); diff --git a/lib/manager/cargo/extract.spec.ts b/lib/manager/cargo/extract.spec.ts index d64737cf92..15a182a964 100644 --- a/lib/manager/cargo/extract.spec.ts +++ b/lib/manager/cargo/extract.spec.ts @@ -1,8 +1,8 @@ import { dir } from 'tmp-promise'; import { join } from 'upath'; import { getName, loadFixture } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; -import type { RepoAdminConfig } from '../../config/types'; +import { setGlobalConfig } from '../../config/admin'; +import type { RepoGlobalConfig } from '../../config/types'; import { writeLocalFile } from '../../util/fs'; import type { ExtractConfig } from '../types'; import { extractPackageFile } from './extract'; @@ -18,7 +18,7 @@ const cargo6toml = loadFixture('Cargo.6.toml'); describe(getName(), () => { describe('extractPackageFile()', () => { let config: ExtractConfig; - let adminConfig: RepoAdminConfig; + let adminConfig: RepoGlobalConfig; beforeEach(async () => { config = {}; @@ -28,10 +28,10 @@ describe(getName(), () => { cacheDir: join(tmpDir.path, 'cache'), }; - setAdminConfig(adminConfig); + setGlobalConfig(adminConfig); }); afterEach(() => { - setAdminConfig(); + setGlobalConfig(); }); it('returns null for invalid toml', async () => { expect( diff --git a/lib/manager/cocoapods/artifacts.spec.ts b/lib/manager/cocoapods/artifacts.spec.ts index 05a559e391..03e20295d9 100644 --- a/lib/manager/cocoapods/artifacts.spec.ts +++ b/lib/manager/cocoapods/artifacts.spec.ts @@ -3,8 +3,8 @@ import _fs from 'fs-extra'; import { join } from 'upath'; import { envMock, mockExecAll } from '../../../test/exec-util'; import { git, mocked } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; -import type { RepoAdminConfig } from '../../config/types'; +import { setGlobalConfig } from '../../config/admin'; +import type { RepoGlobalConfig } from '../../config/types'; import * as _datasource from '../../datasource'; import * as _env from '../../util/exec/env'; import type { StatusResult } from '../../util/git'; @@ -27,7 +27,7 @@ delete process.env.CP_HOME_DIR; const config: UpdateArtifactsConfig = {}; -const adminConfig: RepoAdminConfig = { +const adminConfig: RepoGlobalConfig = { localDir: join('/tmp/github/some/repo'), cacheDir: join('/tmp/cache'), }; @@ -37,7 +37,7 @@ describe('.updateArtifacts()', () => { jest.resetAllMocks(); env.getChildProcessEnv.mockReturnValue(envMock.basic); - setAdminConfig(adminConfig); + setGlobalConfig(adminConfig); datasource.getPkgReleases.mockResolvedValue({ releases: [ @@ -51,7 +51,7 @@ describe('.updateArtifacts()', () => { }); }); afterEach(() => { - setAdminConfig(); + setGlobalConfig(); }); it('returns null if no Podfile.lock found', async () => { const execSnapshots = mockExecAll(exec); @@ -79,7 +79,7 @@ describe('.updateArtifacts()', () => { }); it('returns null for invalid local directory', async () => { const execSnapshots = mockExecAll(exec); - setAdminConfig({ + setGlobalConfig({ localDir: '', }); @@ -124,7 +124,7 @@ describe('.updateArtifacts()', () => { }); it('returns updated Podfile', async () => { const execSnapshots = mockExecAll(exec); - setAdminConfig({ ...adminConfig, binarySource: 'docker' }); + setGlobalConfig({ ...adminConfig, binarySource: 'docker' }); fs.readFile.mockResolvedValueOnce('Old Podfile' as any); git.getRepoStatus.mockResolvedValueOnce({ modified: ['Podfile.lock'], @@ -143,7 +143,7 @@ describe('.updateArtifacts()', () => { }); it('returns updated Podfile and Pods files', async () => { const execSnapshots = mockExecAll(exec); - setAdminConfig({ ...adminConfig, binarySource: 'docker' }); + setGlobalConfig({ ...adminConfig, binarySource: 'docker' }); fs.readFile.mockResolvedValueOnce('Old Manifest.lock' as any); fs.readFile.mockResolvedValueOnce('New Podfile' as any); fs.readFile.mockResolvedValueOnce('Pods manifest' as any); @@ -199,7 +199,7 @@ describe('.updateArtifacts()', () => { it('dynamically selects Docker image tag', async () => { const execSnapshots = mockExecAll(exec); - setAdminConfig({ ...adminConfig, binarySource: 'docker' }); + setGlobalConfig({ ...adminConfig, binarySource: 'docker' }); fs.readFile.mockResolvedValueOnce('COCOAPODS: 1.2.4' as any); @@ -221,7 +221,7 @@ describe('.updateArtifacts()', () => { it('falls back to the `latest` Docker image tag', async () => { const execSnapshots = mockExecAll(exec); - setAdminConfig({ ...adminConfig, binarySource: 'docker' }); + setGlobalConfig({ ...adminConfig, binarySource: 'docker' }); fs.readFile.mockResolvedValueOnce('COCOAPODS: 1.2.4' as any); datasource.getPkgReleases.mockResolvedValueOnce({ diff --git a/lib/manager/cocoapods/extract.spec.ts b/lib/manager/cocoapods/extract.spec.ts index f4c70a6792..6ac0d0cb91 100644 --- a/lib/manager/cocoapods/extract.spec.ts +++ b/lib/manager/cocoapods/extract.spec.ts @@ -1,17 +1,17 @@ import { getName, loadFixture } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; -import type { RepoAdminConfig } from '../../config/types'; +import { setGlobalConfig } from '../../config/admin'; +import type { RepoGlobalConfig } from '../../config/types'; import { extractPackageFile } from '.'; const simplePodfile = loadFixture('Podfile.simple'); const complexPodfile = loadFixture('Podfile.complex'); -const adminConfig: RepoAdminConfig = { localDir: '' }; +const adminConfig: RepoGlobalConfig = { localDir: '' }; describe(getName(), () => { describe('extractPackageFile()', () => { it('extracts from simple file', async () => { - setAdminConfig(adminConfig); + setGlobalConfig(adminConfig); const { deps } = await extractPackageFile(simplePodfile, 'Podfile'); expect(deps).toMatchSnapshot([ { depName: 'a' }, @@ -40,7 +40,7 @@ describe(getName(), () => { }); it('extracts from complex file', async () => { - setAdminConfig(adminConfig); + setGlobalConfig(adminConfig); const { deps } = await extractPackageFile(complexPodfile, 'Podfile'); expect(deps).toMatchSnapshot([ { depName: 'IQKeyboardManager', currentValue: '~> 6.5.0' }, diff --git a/lib/manager/composer/artifacts.spec.ts b/lib/manager/composer/artifacts.spec.ts index b9ea47f0e1..f2febd368c 100644 --- a/lib/manager/composer/artifacts.spec.ts +++ b/lib/manager/composer/artifacts.spec.ts @@ -1,8 +1,8 @@ import { join } from 'upath'; import { envMock, exec, mockExecAll } from '../../../test/exec-util'; import { env, fs, git, mocked, partial } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; -import type { RepoAdminConfig } from '../../config/types'; +import { setGlobalConfig } from '../../config/admin'; +import type { RepoGlobalConfig } from '../../config/types'; import { PLATFORM_TYPE_GITHUB, PLATFORM_TYPE_GITLAB, @@ -28,7 +28,7 @@ const config: UpdateArtifactsConfig = { ignoreScripts: false, }; -const adminConfig: RepoAdminConfig = { +const adminConfig: RepoGlobalConfig = { allowScripts: false, // `join` fixes Windows CI localDir: join('/tmp/github/some/repo'), @@ -48,7 +48,7 @@ describe('.updateArtifacts()', () => { env.getChildProcessEnv.mockReturnValue(envMock.basic); docker.resetPrefetchedImages(); hostRules.clear(); - setAdminConfig(adminConfig); + setGlobalConfig(adminConfig); fs.ensureCacheDir.mockResolvedValue('/tmp/renovate/cache/others/composer'); datasource.getPkgReleases.mockResolvedValueOnce({ releases: [ @@ -64,7 +64,7 @@ describe('.updateArtifacts()', () => { }); afterEach(() => { - setAdminConfig(); + setGlobalConfig(); }); it('returns if no composer.lock found', async () => { @@ -83,7 +83,7 @@ describe('.updateArtifacts()', () => { const execSnapshots = mockExecAll(exec); fs.readLocalFile.mockResolvedValueOnce('{}'); git.getRepoStatus.mockResolvedValue(repoStatus); - setAdminConfig({ ...adminConfig, allowScripts: true }); + setGlobalConfig({ ...adminConfig, allowScripts: true }); expect( await composer.updateArtifacts({ packageFileName: 'composer.json', @@ -217,7 +217,7 @@ describe('.updateArtifacts()', () => { }); it('supports docker mode', async () => { - setAdminConfig({ ...adminConfig, binarySource: 'docker' }); + setGlobalConfig({ ...adminConfig, binarySource: 'docker' }); fs.readLocalFile.mockResolvedValueOnce('{}'); const execSnapshots = mockExecAll(exec); @@ -252,7 +252,7 @@ describe('.updateArtifacts()', () => { }); it('supports global mode', async () => { - setAdminConfig({ ...adminConfig, binarySource: 'global' }); + setGlobalConfig({ ...adminConfig, binarySource: 'global' }); fs.readLocalFile.mockResolvedValueOnce('{}'); const execSnapshots = mockExecAll(exec); fs.readLocalFile.mockResolvedValueOnce('{ }'); diff --git a/lib/manager/composer/artifacts.ts b/lib/manager/composer/artifacts.ts index 2c69d8106f..a455693789 100644 --- a/lib/manager/composer/artifacts.ts +++ b/lib/manager/composer/artifacts.ts @@ -1,6 +1,6 @@ import is from '@sindresorhus/is'; import { quote } from 'shlex'; -import { getAdminConfig } from '../../config/admin'; +import { getGlobalConfig } from '../../config/admin'; import { SYSTEM_INSUFFICIENT_DISK_SPACE, TEMPORARY_ERROR, @@ -137,7 +137,7 @@ export async function updateArtifacts({ args += ' --ignore-platform-reqs'; } args += ' --no-ansi --no-interaction'; - if (!getAdminConfig().allowScripts || config.ignoreScripts) { + if (!getGlobalConfig().allowScripts || config.ignoreScripts) { args += ' --no-scripts --no-autoloader --no-plugins'; } logger.debug({ cmd, args }, 'composer command'); diff --git a/lib/manager/git-submodules/extract.spec.ts b/lib/manager/git-submodules/extract.spec.ts index 89d2826460..e8bb1de419 100644 --- a/lib/manager/git-submodules/extract.spec.ts +++ b/lib/manager/git-submodules/extract.spec.ts @@ -1,7 +1,7 @@ import { mock } from 'jest-mock-extended'; import _simpleGit, { Response, SimpleGit } from 'simple-git'; import { getName, partial } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; +import { setGlobalConfig } from '../../config/admin'; import * as hostRules from '../../util/host-rules'; import type { PackageFile } from '../types'; import extractPackageFile from './extract'; @@ -44,7 +44,7 @@ describe(getName(), () => { }); describe('extractPackageFile()', () => { it('extracts submodules', async () => { - setAdminConfig({ localDir: `${__dirname}/__fixtures__` }); + setGlobalConfig({ localDir: `${__dirname}/__fixtures__` }); hostRules.add({ matchHost: 'github.com', token: 'abc123' }); let res: PackageFile; expect(await extractPackageFile('', '.gitmodules.1', {})).toBeNull(); diff --git a/lib/manager/git-submodules/extract.ts b/lib/manager/git-submodules/extract.ts index 7c92f1b13f..764cb45f20 100644 --- a/lib/manager/git-submodules/extract.ts +++ b/lib/manager/git-submodules/extract.ts @@ -1,7 +1,7 @@ import URL from 'url'; import Git, { SimpleGit } from 'simple-git'; import upath from 'upath'; -import { getAdminConfig } from '../../config/admin'; +import { getGlobalConfig } from '../../config/admin'; import * as datasourceGitRefs from '../../datasource/git-refs'; import { logger } from '../../logger'; import { getHttpUrl, getRemoteUrlWithToken } from '../../util/git/url'; @@ -88,7 +88,7 @@ export default async function extractPackageFile( fileName: string, config: ManagerConfig ): Promise { - const { localDir } = getAdminConfig(); + const { localDir } = getGlobalConfig(); const git = Git(localDir); const gitModulesPath = upath.join(localDir, fileName); diff --git a/lib/manager/git-submodules/update.spec.ts b/lib/manager/git-submodules/update.spec.ts index 9887e7ceb8..4c65961d0f 100644 --- a/lib/manager/git-submodules/update.spec.ts +++ b/lib/manager/git-submodules/update.spec.ts @@ -2,8 +2,8 @@ import _simpleGit from 'simple-git'; import { dir } from 'tmp-promise'; import { join } from 'upath'; import { getName } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; -import type { RepoAdminConfig } from '../../config/types'; +import { setGlobalConfig } from '../../config/admin'; +import type { RepoGlobalConfig } from '../../config/types'; import type { Upgrade } from '../types'; import updateDependency from './update'; @@ -13,16 +13,16 @@ const simpleGit: any = _simpleGit; describe(getName(), () => { describe('updateDependency', () => { let upgrade: Upgrade; - let adminConfig: RepoAdminConfig; + let adminConfig: RepoGlobalConfig; beforeAll(async () => { upgrade = { depName: 'renovate' }; const tmpDir = await dir(); adminConfig = { localDir: join(tmpDir.path) }; - setAdminConfig(adminConfig); + setGlobalConfig(adminConfig); }); afterAll(() => { - setAdminConfig(); + setGlobalConfig(); }); it('returns null on error', async () => { simpleGit.mockReturnValue({ diff --git a/lib/manager/git-submodules/update.ts b/lib/manager/git-submodules/update.ts index da05a5ae46..056c25857f 100644 --- a/lib/manager/git-submodules/update.ts +++ b/lib/manager/git-submodules/update.ts @@ -1,6 +1,6 @@ import Git from 'simple-git'; import upath from 'upath'; -import { getAdminConfig } from '../../config/admin'; +import { getGlobalConfig } from '../../config/admin'; import { logger } from '../../logger'; import type { UpdateDependencyConfig } from '../types'; @@ -8,7 +8,7 @@ export default async function updateDependency({ fileContent, upgrade, }: UpdateDependencyConfig): Promise { - const { localDir } = getAdminConfig(); + const { localDir } = getGlobalConfig(); const git = Git(localDir); const submoduleGit = Git(upath.join(localDir, upgrade.depName)); diff --git a/lib/manager/gitlabci/extract.spec.ts b/lib/manager/gitlabci/extract.spec.ts index ae3f1f3076..c80da39b42 100644 --- a/lib/manager/gitlabci/extract.spec.ts +++ b/lib/manager/gitlabci/extract.spec.ts @@ -1,20 +1,20 @@ import { getName, logger } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; -import type { RepoAdminConfig } from '../../config/types'; +import { setGlobalConfig } from '../../config/admin'; +import type { RepoGlobalConfig } from '../../config/types'; import type { ExtractConfig, PackageDependency } from '../types'; import { extractAllPackageFiles } from './extract'; const config: ExtractConfig = {}; -const adminConfig: RepoAdminConfig = { localDir: '' }; +const adminConfig: RepoGlobalConfig = { localDir: '' }; describe(getName(), () => { beforeEach(() => { - setAdminConfig(adminConfig); + setGlobalConfig(adminConfig); }); afterEach(() => { - setAdminConfig(); + setGlobalConfig(); }); describe('extractAllPackageFiles()', () => { diff --git a/lib/manager/gomod/artifacts.spec.ts b/lib/manager/gomod/artifacts.spec.ts index afc2b1c464..2b83aca859 100644 --- a/lib/manager/gomod/artifacts.spec.ts +++ b/lib/manager/gomod/artifacts.spec.ts @@ -3,8 +3,8 @@ import _fs from 'fs-extra'; import { join } from 'upath'; import { envMock, mockExecAll } from '../../../test/exec-util'; import { git, mocked } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; -import type { RepoAdminConfig } from '../../config/types'; +import { setGlobalConfig } from '../../config/admin'; +import type { RepoGlobalConfig } from '../../config/types'; import * as docker from '../../util/exec/docker'; import * as _env from '../../util/exec/env'; import type { StatusResult } from '../../util/git'; @@ -36,7 +36,7 @@ require gopkg.in/russross/blackfriday.v1 v1.0.0 replace github.com/pkg/errors => ../errors `; -const adminConfig: RepoAdminConfig = { +const adminConfig: RepoGlobalConfig = { // `join` fixes Windows CI localDir: join('/tmp/github/some/repo'), cacheDir: join('/tmp/renovate/cache'), @@ -61,11 +61,11 @@ describe('.updateArtifacts()', () => { delete process.env.GOPATH; env.getChildProcessEnv.mockReturnValue({ ...envMock.basic, ...goEnv }); - setAdminConfig(adminConfig); + setGlobalConfig(adminConfig); docker.resetPrefetchedImages(); }); afterEach(() => { - setAdminConfig(); + setGlobalConfig(); }); it('returns if no go.sum found', async () => { const execSnapshots = mockExecAll(exec); @@ -151,7 +151,7 @@ describe('.updateArtifacts()', () => { expect(execSnapshots).toMatchSnapshot(); }); it('supports docker mode without credentials', async () => { - setAdminConfig({ ...adminConfig, binarySource: 'docker' }); + setGlobalConfig({ ...adminConfig, binarySource: 'docker' }); fs.readFile.mockResolvedValueOnce('Current go.sum' as any); fs.readFile.mockResolvedValueOnce(null as any); // vendor modules filename const execSnapshots = mockExecAll(exec); @@ -170,7 +170,7 @@ describe('.updateArtifacts()', () => { expect(execSnapshots).toMatchSnapshot(); }); it('supports global mode', async () => { - setAdminConfig({ ...adminConfig, binarySource: 'global' }); + setGlobalConfig({ ...adminConfig, binarySource: 'global' }); fs.readFile.mockResolvedValueOnce('Current go.sum' as any); fs.readFile.mockResolvedValueOnce(null as any); // vendor modules filename const execSnapshots = mockExecAll(exec); @@ -189,7 +189,7 @@ describe('.updateArtifacts()', () => { expect(execSnapshots).toMatchSnapshot(); }); it('supports docker mode with credentials', async () => { - setAdminConfig({ ...adminConfig, binarySource: 'docker' }); + setGlobalConfig({ ...adminConfig, binarySource: 'docker' }); hostRules.find.mockReturnValueOnce({ token: 'some-token', }); @@ -211,7 +211,7 @@ describe('.updateArtifacts()', () => { expect(execSnapshots).toMatchSnapshot(); }); it('supports docker mode with goModTidy', async () => { - setAdminConfig({ ...adminConfig, binarySource: 'docker' }); + setGlobalConfig({ ...adminConfig, binarySource: 'docker' }); hostRules.find.mockReturnValueOnce({}); fs.readFile.mockResolvedValueOnce('Current go.sum' as any); fs.readFile.mockResolvedValueOnce(null as any); // vendor modules filename diff --git a/lib/manager/gomod/artifacts.ts b/lib/manager/gomod/artifacts.ts index 0ec30ac673..3e3c4615f0 100644 --- a/lib/manager/gomod/artifacts.ts +++ b/lib/manager/gomod/artifacts.ts @@ -1,7 +1,7 @@ import is from '@sindresorhus/is'; import { quote } from 'shlex'; import { dirname, join } from 'upath'; -import { getAdminConfig } from '../../config/admin'; +import { getGlobalConfig } from '../../config/admin'; import { TEMPORARY_ERROR } from '../../constants/error-messages'; import { PLATFORM_TYPE_GITHUB } from '../../constants/platforms'; import { logger } from '../../logger'; @@ -125,7 +125,7 @@ export async function updateArtifacts({ GONOPROXY: process.env.GONOPROXY, GONOSUMDB: process.env.GONOSUMDB, GOFLAGS: useModcacherw(config.constraints?.go) ? '-modcacherw' : null, - CGO_ENABLED: getAdminConfig().binarySource === 'docker' ? '0' : null, + CGO_ENABLED: getGlobalConfig().binarySource === 'docker' ? '0' : null, }, docker: { image: 'go', diff --git a/lib/manager/gradle-wrapper/artifacts-real.spec.ts b/lib/manager/gradle-wrapper/artifacts-real.spec.ts index 77d5d6c377..46afc409da 100644 --- a/lib/manager/gradle-wrapper/artifacts-real.spec.ts +++ b/lib/manager/gradle-wrapper/artifacts-real.spec.ts @@ -3,8 +3,8 @@ import Git from 'simple-git'; import { resolve } from 'upath'; import * as httpMock from '../../../test/http-mock'; import { getName, git, partial } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; -import type { RepoAdminConfig } from '../../config/types'; +import { setGlobalConfig } from '../../config/admin'; +import type { RepoGlobalConfig } from '../../config/types'; import type { StatusResult } from '../../util/git'; import { ifSystemSupportsGradle } from '../gradle/deep/__testutil__/gradle'; import type { UpdateArtifactsConfig } from '../types'; @@ -14,7 +14,7 @@ jest.mock('../../util/git'); const fixtures = resolve(__dirname, './__fixtures__'); -const adminConfig: RepoAdminConfig = { +const adminConfig: RepoGlobalConfig = { localDir: resolve(fixtures, './testFiles'), }; @@ -42,12 +42,12 @@ describe(getName(), () => { beforeEach(() => { jest.resetAllMocks(); - setAdminConfig(adminConfig); + setGlobalConfig(adminConfig); }); afterEach(async () => { await Git(fixtures).checkout(['HEAD', '--', '.']); - setAdminConfig(); + setGlobalConfig(); }); it('replaces existing value', async () => { @@ -168,7 +168,7 @@ describe(getName(), () => { localDir: resolve(fixtures, './wrongCmd'), }; - setAdminConfig(wrongCmdConfig); + setGlobalConfig(wrongCmdConfig); const res = await dcUpdate.updateArtifacts({ packageFileName: 'gradle/wrapper/gradle-wrapper.properties', updatedDeps: [], @@ -191,7 +191,7 @@ describe(getName(), () => { }); it('gradlew not found', async () => { - setAdminConfig({ localDir: 'some-dir' }); + setGlobalConfig({ localDir: 'some-dir' }); const res = await dcUpdate.updateArtifacts({ packageFileName: 'gradle-wrapper.properties', updatedDeps: [], diff --git a/lib/manager/gradle-wrapper/artifacts.spec.ts b/lib/manager/gradle-wrapper/artifacts.spec.ts index e9636111f3..841f029ad5 100644 --- a/lib/manager/gradle-wrapper/artifacts.spec.ts +++ b/lib/manager/gradle-wrapper/artifacts.spec.ts @@ -12,8 +12,8 @@ import { git, partial, } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; -import type { RepoAdminConfig } from '../../config/types'; +import { setGlobalConfig } from '../../config/admin'; +import type { RepoGlobalConfig } from '../../config/types'; import { resetPrefetchedImages } from '../../util/exec/docker'; import type { StatusResult } from '../../util/git'; import type { UpdateArtifactsConfig } from '../types'; @@ -27,7 +27,7 @@ jest.mock('../../util/exec/env'); const exec: jest.Mock = _exec as any; const fixtures = resolve(__dirname, './__fixtures__'); -const adminConfig: RepoAdminConfig = { +const adminConfig: RepoGlobalConfig = { localDir: resolve(fixtures, './testFiles'), }; @@ -54,14 +54,14 @@ describe(getName(), () => { LC_ALL: 'en_US', }); - setAdminConfig(adminConfig); + setGlobalConfig(adminConfig); resetPrefetchedImages(); fs.readLocalFile.mockResolvedValue('test'); }); afterEach(() => { - setAdminConfig(); + setGlobalConfig(); }); it('replaces existing value', async () => { @@ -100,7 +100,7 @@ describe(getName(), () => { }); it('gradlew not found', async () => { - setAdminConfig({ ...adminConfig, localDir: 'some-dir' }); + setGlobalConfig({ ...adminConfig, localDir: 'some-dir' }); const res = await dcUpdate.updateArtifacts({ packageFileName: 'gradle-wrapper.properties', updatedDeps: [], diff --git a/lib/manager/gradle-wrapper/artifacts.ts b/lib/manager/gradle-wrapper/artifacts.ts index fb9b73b94b..f1d2d35731 100644 --- a/lib/manager/gradle-wrapper/artifacts.ts +++ b/lib/manager/gradle-wrapper/artifacts.ts @@ -1,6 +1,6 @@ import { stat } from 'fs-extra'; import { resolve } from 'upath'; -import { getAdminConfig } from '../../config/admin'; +import { getGlobalConfig } from '../../config/admin'; import { TEMPORARY_ERROR } from '../../constants/error-messages'; import { logger } from '../../logger'; import { ExecOptions, exec } from '../../util/exec'; @@ -55,7 +55,7 @@ export async function updateArtifacts({ config, }: UpdateArtifact): Promise { try { - const { localDir: projectDir } = getAdminConfig(); + const { localDir: projectDir } = getGlobalConfig(); logger.debug({ updatedDeps }, 'gradle-wrapper.updateArtifacts()'); const gradlew = gradleWrapperFileName(config); const gradlewPath = resolve(projectDir, `./${gradlew}`); diff --git a/lib/manager/gradle/deep/index-real.spec.ts b/lib/manager/gradle/deep/index-real.spec.ts index 74a9e0a0d8..e87bfcca38 100644 --- a/lib/manager/gradle/deep/index-real.spec.ts +++ b/lib/manager/gradle/deep/index-real.spec.ts @@ -1,8 +1,8 @@ import fsExtra from 'fs-extra'; import tmp, { DirectoryResult } from 'tmp-promise'; import { getName } from '../../../../test/util'; -import { setAdminConfig } from '../../../config/admin'; -import type { RepoAdminConfig } from '../../../config/types'; +import { setGlobalConfig } from '../../../config/admin'; +import type { RepoGlobalConfig } from '../../../config/types'; import type { ExtractConfig } from '../../types'; import { ifSystemSupportsGradle } from './__testutil__/gradle'; import * as manager from '.'; @@ -21,13 +21,13 @@ describe(getName(), () => { let workingDir: DirectoryResult; let testRunConfig: ExtractConfig; let successFile: string; - let adminConfig: RepoAdminConfig; + let adminConfig: RepoGlobalConfig; beforeEach(async () => { workingDir = await tmp.dir({ unsafeCleanup: true }); successFile = ''; adminConfig = { localDir: workingDir.path }; - setAdminConfig(adminConfig); + setGlobalConfig(adminConfig); testRunConfig = { ...baseConfig }; await fsExtra.copy(`${fixtures}/minimal-project`, workingDir.path); await fsExtra.copy(`${fixtures}/gradle-wrappers/6`, workingDir.path); @@ -48,7 +48,7 @@ allprojects { }); afterEach(() => { - setAdminConfig(); + setGlobalConfig(); }); it('executes an executable gradle wrapper', async () => { diff --git a/lib/manager/gradle/deep/index.spec.ts b/lib/manager/gradle/deep/index.spec.ts index fff9174ac0..171701915d 100644 --- a/lib/manager/gradle/deep/index.spec.ts +++ b/lib/manager/gradle/deep/index.spec.ts @@ -11,8 +11,8 @@ import { loadFixture, mocked, } from '../../../../test/util'; -import { setAdminConfig } from '../../../config/admin'; -import type { RepoAdminConfig } from '../../../config/types'; +import { setGlobalConfig } from '../../../config/admin'; +import type { RepoGlobalConfig } from '../../../config/types'; import * as docker from '../../../util/exec/docker'; import * as _env from '../../../util/exec/env'; import type { ExtractConfig } from '../../types'; @@ -26,7 +26,7 @@ const fs = mocked(_fs); jest.mock('../../../util/exec/env'); const env = mocked(_env); -const adminConfig: RepoAdminConfig = { +const adminConfig: RepoGlobalConfig = { localDir: join('/foo/bar'), }; @@ -88,11 +88,11 @@ describe(getName(), () => { } beforeAll(() => { - setAdminConfig(adminConfig); + setGlobalConfig(adminConfig); }); afterAll(() => { - setAdminConfig(); + setGlobalConfig(); }); beforeEach(() => { @@ -220,7 +220,7 @@ describe(getName(), () => { }); it('should use docker if required', async () => { - setAdminConfig(dockerAdminConfig); + setGlobalConfig(dockerAdminConfig); const execSnapshots = setupMocks({ wrapperFilename: null }); const dependencies = await extractAllPackageFiles(config, [ 'build.gradle', @@ -231,7 +231,7 @@ describe(getName(), () => { }); it('should use docker even if gradlew is available', async () => { - setAdminConfig(dockerAdminConfig); + setGlobalConfig(dockerAdminConfig); const execSnapshots = setupMocks(); const dependencies = await extractAllPackageFiles(config, [ 'build.gradle', @@ -242,7 +242,7 @@ describe(getName(), () => { }); it('should use docker even if gradlew.bat is available on Windows', async () => { - setAdminConfig(dockerAdminConfig); + setGlobalConfig(dockerAdminConfig); jest.spyOn(os, 'platform').mockReturnValueOnce('win32'); const execSnapshots = setupMocks({ wrapperFilename: 'gradlew.bat' }); const dependencies = await extractAllPackageFiles(config, [ diff --git a/lib/manager/gradle/deep/index.ts b/lib/manager/gradle/deep/index.ts index 26b47629cb..52655279e7 100644 --- a/lib/manager/gradle/deep/index.ts +++ b/lib/manager/gradle/deep/index.ts @@ -1,7 +1,7 @@ import type { Stats } from 'fs'; import { stat } from 'fs-extra'; import upath from 'upath'; -import { getAdminConfig } from '../../../config/admin'; +import { getGlobalConfig } from '../../../config/admin'; import { TEMPORARY_ERROR } from '../../../constants/error-messages'; import * as datasourceMaven from '../../../datasource/maven'; import { logger } from '../../../logger'; @@ -91,7 +91,7 @@ export async function extractAllPackageFiles( ): Promise { let rootBuildGradle: string | undefined; let gradlew: Stats | null; - const { localDir } = getAdminConfig(); + const { localDir } = getGlobalConfig(); for (const packageFile of packageFiles) { const dirname = upath.dirname(packageFile); const gradlewPath = upath.join(dirname, gradleWrapperFileName(config)); diff --git a/lib/manager/gradle/deep/utils.ts b/lib/manager/gradle/deep/utils.ts index 1f2b9d4cfa..e5e175d2dc 100644 --- a/lib/manager/gradle/deep/utils.ts +++ b/lib/manager/gradle/deep/utils.ts @@ -2,7 +2,7 @@ import type { Stats } from 'fs'; import os from 'os'; import { chmod } from 'fs-extra'; import upath from 'upath'; -import { getAdminConfig } from '../../../config/admin'; +import { getGlobalConfig } from '../../../config/admin'; import type { ExtractConfig } from '../../types'; export const extraEnv = { @@ -13,7 +13,7 @@ export const extraEnv = { export function gradleWrapperFileName(config: ExtractConfig): string { if ( os.platform() === 'win32' && - getAdminConfig()?.binarySource !== 'docker' + getGlobalConfig()?.binarySource !== 'docker' ) { return 'gradlew.bat'; } diff --git a/lib/manager/helmv3/artifacts.spec.ts b/lib/manager/helmv3/artifacts.spec.ts index 75ea7963c7..f8e05164fc 100644 --- a/lib/manager/helmv3/artifacts.spec.ts +++ b/lib/manager/helmv3/artifacts.spec.ts @@ -3,8 +3,8 @@ import _fs from 'fs-extra'; import { join } from 'upath'; import { envMock, mockExecAll } from '../../../test/exec-util'; import { git, mocked } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; -import type { RepoAdminConfig } from '../../config/types'; +import { setGlobalConfig } from '../../config/admin'; +import type { RepoGlobalConfig } from '../../config/types'; import * as docker from '../../util/exec/docker'; import * as _env from '../../util/exec/env'; import type { UpdateArtifactsConfig } from '../types'; @@ -20,7 +20,7 @@ const fs: jest.Mocked = _fs as any; const exec: jest.Mock = _exec as any; const env = mocked(_env); -const adminConfig: RepoAdminConfig = { +const adminConfig: RepoGlobalConfig = { localDir: join('/tmp/github/some/repo'), // `join` fixes Windows CI }; @@ -32,11 +32,11 @@ describe('.updateArtifacts()', () => { jest.resetModules(); env.getChildProcessEnv.mockReturnValue(envMock.basic); - setAdminConfig(adminConfig); + setGlobalConfig(adminConfig); docker.resetPrefetchedImages(); }); afterEach(() => { - setAdminConfig(); + setGlobalConfig(); }); it('returns null if no Chart.lock found', async () => { const updatedDeps = [{ depName: 'dep1' }]; @@ -108,7 +108,7 @@ describe('.updateArtifacts()', () => { }); it('returns updated Chart.lock with docker', async () => { - setAdminConfig({ ...adminConfig, binarySource: 'docker' }); + setGlobalConfig({ ...adminConfig, binarySource: 'docker' }); git.getFile.mockResolvedValueOnce('Old Chart.lock'); const execSnapshots = mockExecAll(exec); fs.readFile.mockResolvedValueOnce('New Chart.lock' as any); diff --git a/lib/manager/mix/artifacts.spec.ts b/lib/manager/mix/artifacts.spec.ts index 441b7d0f1a..81d8254c54 100644 --- a/lib/manager/mix/artifacts.spec.ts +++ b/lib/manager/mix/artifacts.spec.ts @@ -1,8 +1,8 @@ import { join } from 'upath'; import { envMock, exec, mockExecAll } from '../../../test/exec-util'; import { env, fs, getName, hostRules } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; -import type { RepoAdminConfig } from '../../config/types'; +import { setGlobalConfig } from '../../config/admin'; +import type { RepoGlobalConfig } from '../../config/types'; import * as docker from '../../util/exec/docker'; import type { UpdateArtifactsConfig } from '../types'; import { updateArtifacts } from '.'; @@ -12,7 +12,7 @@ jest.mock('../../util/exec/env'); jest.mock('../../util/fs'); jest.mock('../../util/host-rules'); -const adminConfig: RepoAdminConfig = { +const adminConfig: RepoGlobalConfig = { // `join` fixes Windows CI localDir: join('/tmp/github/some/repo'), }; @@ -25,11 +25,11 @@ describe(getName(), () => { jest.resetModules(); env.getChildProcessEnv.mockReturnValue(envMock.basic); - setAdminConfig(adminConfig); + setGlobalConfig(adminConfig); }); afterEach(() => { - setAdminConfig(); + setGlobalConfig(); }); it('returns null if no mix.lock found', async () => { @@ -82,7 +82,7 @@ describe(getName(), () => { it('returns updated mix.lock', async () => { jest.spyOn(docker, 'removeDanglingContainers').mockResolvedValueOnce(); - setAdminConfig({ ...adminConfig, binarySource: 'docker' }); + setGlobalConfig({ ...adminConfig, binarySource: 'docker' }); fs.readLocalFile.mockResolvedValueOnce('Old mix.lock'); fs.getSiblingFileName.mockReturnValueOnce('mix.lock'); const execSnapshots = mockExecAll(exec); @@ -101,7 +101,7 @@ describe(getName(), () => { it('authenticates to private repositories', async () => { jest.spyOn(docker, 'removeDanglingContainers').mockResolvedValueOnce(); - setAdminConfig({ ...adminConfig, binarySource: 'docker' }); + setGlobalConfig({ ...adminConfig, binarySource: 'docker' }); fs.readLocalFile.mockResolvedValueOnce('Old mix.lock'); fs.getSiblingFileName.mockReturnValueOnce('mix.lock'); const execSnapshots = mockExecAll(exec); @@ -141,7 +141,7 @@ describe(getName(), () => { }); it('returns updated mix.lock in subdir', async () => { - setAdminConfig({ ...adminConfig, binarySource: 'docker' }); + setGlobalConfig({ ...adminConfig, binarySource: 'docker' }); fs.getSiblingFileName.mockReturnValueOnce('subdir/mix.lock'); mockExecAll(exec); expect( diff --git a/lib/manager/mix/extract.spec.ts b/lib/manager/mix/extract.spec.ts index 03484b6acd..4bde662f07 100644 --- a/lib/manager/mix/extract.spec.ts +++ b/lib/manager/mix/extract.spec.ts @@ -1,12 +1,12 @@ import { getName, loadFixture } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; +import { setGlobalConfig } from '../../config/admin'; import { extractPackageFile } from '.'; const sample = loadFixture('mix.exs'); describe(getName(), () => { beforeEach(() => { - setAdminConfig({ localDir: '' }); + setGlobalConfig({ localDir: '' }); }); describe('extractPackageFile()', () => { diff --git a/lib/manager/npm/extract/index.ts b/lib/manager/npm/extract/index.ts index cf53c686c3..f5ac26637b 100644 --- a/lib/manager/npm/extract/index.ts +++ b/lib/manager/npm/extract/index.ts @@ -1,6 +1,6 @@ import is from '@sindresorhus/is'; import validateNpmPackageName from 'validate-npm-package-name'; -import { getAdminConfig } from '../../../config/admin'; +import { getGlobalConfig } from '../../../config/admin'; import { CONFIG_VALIDATION } from '../../../constants/error-messages'; import * as datasourceGithubTags from '../../../datasource/github-tags'; import { id as npmId } from '../../../datasource/npm'; @@ -105,7 +105,7 @@ export async function extractPackageFile( logger.debug('Stripping package-lock setting from .npmrc'); npmrc = npmrc.replace(/(^|\n)package-lock.*?(\n|$)/g, '\n'); } - if (npmrc.includes('=${') && !getAdminConfig().exposeAllEnv) { + if (npmrc.includes('=${') && !getGlobalConfig().exposeAllEnv) { logger.debug( { npmrcFileName }, 'Stripping .npmrc file of lines with variables' diff --git a/lib/manager/npm/extract/pnpm.spec.ts b/lib/manager/npm/extract/pnpm.spec.ts index 2f3d55998f..16db0d8762 100644 --- a/lib/manager/npm/extract/pnpm.spec.ts +++ b/lib/manager/npm/extract/pnpm.spec.ts @@ -1,6 +1,6 @@ import yaml from 'js-yaml'; import { getFixturePath, getName, logger } from '../../../../test/util'; -import { setAdminConfig } from '../../../config/admin'; +import { setGlobalConfig } from '../../../config/admin'; import * as fs from '../../../util/fs'; import { detectPnpmWorkspaces, @@ -10,7 +10,7 @@ import { describe(getName(), () => { beforeAll(() => { - setAdminConfig({ localDir: getFixturePath('pnpm-monorepo/', '..') }); + setGlobalConfig({ localDir: getFixturePath('pnpm-monorepo/', '..') }); }); describe('.extractPnpmFilters()', () => { diff --git a/lib/manager/npm/post-update/index.ts b/lib/manager/npm/post-update/index.ts index 3c9d42710d..47df5072e7 100644 --- a/lib/manager/npm/post-update/index.ts +++ b/lib/manager/npm/post-update/index.ts @@ -3,7 +3,7 @@ import { parseSyml } from '@yarnpkg/parsers'; import deepmerge from 'deepmerge'; import { dump, load } from 'js-yaml'; import upath from 'upath'; -import { getAdminConfig } from '../../../config/admin'; +import { getGlobalConfig } from '../../../config/admin'; import { SYSTEM_INSUFFICIENT_DISK_SPACE } from '../../../constants/error-messages'; import { id as npmId } from '../../../datasource/npm'; import { logger } from '../../../logger'; @@ -139,7 +139,7 @@ export async function writeExistingFiles( { packageFiles: npmFiles.map((n) => n.packageFile) }, 'Writing package.json files' ); - const { localDir } = getAdminConfig(); + const { localDir } = getGlobalConfig(); for (const packageFile of npmFiles) { const basedir = upath.join( localDir, @@ -218,7 +218,7 @@ export async function writeUpdatedPackageFiles( logger.debug('No files found'); return; } - const { localDir } = getAdminConfig(); + const { localDir } = getGlobalConfig(); for (const packageFile of config.updatedPackageFiles) { if (packageFile.name.endsWith('package-lock.json')) { logger.debug(`Writing package-lock file: ${packageFile.name}`); @@ -439,7 +439,7 @@ export async function getAdditionalFiles( } catch (err) { logger.warn({ err }, 'Error getting token for packageFile'); } - const { localDir } = getAdminConfig(); + const { localDir } = getGlobalConfig(); for (const npmLock of dirs.npmLockDirs) { const lockFileDir = upath.dirname(npmLock); const fullLockFileDir = upath.join(localDir, lockFileDir); diff --git a/lib/manager/npm/post-update/lerna.spec.ts b/lib/manager/npm/post-update/lerna.spec.ts index 329acac7c9..0961cb42d4 100644 --- a/lib/manager/npm/post-update/lerna.spec.ts +++ b/lib/manager/npm/post-update/lerna.spec.ts @@ -1,7 +1,7 @@ import { exec as _exec } from 'child_process'; import { envMock, mockExecAll } from '../../../../test/exec-util'; import { getName, mocked } from '../../../../test/util'; -import { setAdminConfig } from '../../../config/admin'; +import { setGlobalConfig } from '../../../config/admin'; import * as _env from '../../../util/exec/env'; import * as _lernaHelper from './lerna'; @@ -95,7 +95,7 @@ describe(getName(), () => { }); it('allows scripts for trust level high', async () => { const execSnapshots = mockExecAll(exec); - setAdminConfig({ allowScripts: true }); + setGlobalConfig({ allowScripts: true }); const res = await lernaHelper.generateLockFiles( lernaPkgFile('npm'), 'some-dir', diff --git a/lib/manager/npm/post-update/lerna.ts b/lib/manager/npm/post-update/lerna.ts index 94f661afc0..bdfa42526b 100644 --- a/lib/manager/npm/post-update/lerna.ts +++ b/lib/manager/npm/post-update/lerna.ts @@ -1,6 +1,6 @@ import semver, { validRange } from 'semver'; import { quote } from 'shlex'; -import { getAdminConfig } from '../../../config/admin'; +import { getGlobalConfig } from '../../../config/admin'; import { TEMPORARY_ERROR } from '../../../constants/error-messages'; import { logger } from '../../../logger'; import { ExecOptions, exec } from '../../../util/exec'; @@ -67,7 +67,7 @@ export async function generateLockFiles( return { error: false }; } let lernaCommand = `lerna bootstrap --no-ci --ignore-scripts -- `; - if (getAdminConfig().allowScripts && config.ignoreScripts !== false) { + if (getGlobalConfig().allowScripts && config.ignoreScripts !== false) { cmdOptions = cmdOptions.replace('--ignore-scripts ', ''); lernaCommand = lernaCommand.replace('--ignore-scripts ', ''); } @@ -88,7 +88,7 @@ export async function generateLockFiles( }, }; // istanbul ignore if - if (getAdminConfig().exposeAllEnv) { + if (getGlobalConfig().exposeAllEnv) { execOptions.extraEnv.NPM_AUTH = env.NPM_AUTH; execOptions.extraEnv.NPM_EMAIL = env.NPM_EMAIL; } diff --git a/lib/manager/npm/post-update/npm.ts b/lib/manager/npm/post-update/npm.ts index b087603fb6..b484072f58 100644 --- a/lib/manager/npm/post-update/npm.ts +++ b/lib/manager/npm/post-update/npm.ts @@ -1,7 +1,7 @@ import { validRange } from 'semver'; import { quote } from 'shlex'; import { join } from 'upath'; -import { getAdminConfig } from '../../../config/admin'; +import { getGlobalConfig } from '../../../config/admin'; import { SYSTEM_INSUFFICIENT_DISK_SPACE, TEMPORARY_ERROR, @@ -52,7 +52,7 @@ export async function generateLockFile( cmdOptions += '--package-lock-only --no-audit'; } - if (!getAdminConfig().allowScripts || config.ignoreScripts) { + if (!getGlobalConfig().allowScripts || config.ignoreScripts) { cmdOptions += ' --ignore-scripts'; } @@ -71,7 +71,7 @@ export async function generateLockFile( }, }; // istanbul ignore if - if (getAdminConfig().exposeAllEnv) { + if (getGlobalConfig().exposeAllEnv) { execOptions.extraEnv.NPM_AUTH = env.NPM_AUTH; execOptions.extraEnv.NPM_EMAIL = env.NPM_EMAIL; } diff --git a/lib/manager/npm/post-update/pnpm.ts b/lib/manager/npm/post-update/pnpm.ts index 52a2c35008..f1d0bc9d56 100644 --- a/lib/manager/npm/post-update/pnpm.ts +++ b/lib/manager/npm/post-update/pnpm.ts @@ -1,7 +1,7 @@ import { validRange } from 'semver'; import { quote } from 'shlex'; import { join } from 'upath'; -import { getAdminConfig } from '../../../config/admin'; +import { getGlobalConfig } from '../../../config/admin'; import { TEMPORARY_ERROR } from '../../../constants/error-messages'; import { logger } from '../../../logger'; import { ExecOptions, exec } from '../../../util/exec'; @@ -44,13 +44,13 @@ export async function generateLockFile( }, }; // istanbul ignore if - if (getAdminConfig().exposeAllEnv) { + if (getGlobalConfig().exposeAllEnv) { execOptions.extraEnv.NPM_AUTH = env.NPM_AUTH; execOptions.extraEnv.NPM_EMAIL = env.NPM_EMAIL; } cmd = 'pnpm'; let args = 'install --recursive --lockfile-only'; - if (!getAdminConfig().allowScripts || config.ignoreScripts) { + if (!getGlobalConfig().allowScripts || config.ignoreScripts) { args += ' --ignore-scripts'; args += ' --ignore-pnpmfile'; } diff --git a/lib/manager/npm/post-update/yarn.ts b/lib/manager/npm/post-update/yarn.ts index d4fa0b9150..c47dcaa433 100644 --- a/lib/manager/npm/post-update/yarn.ts +++ b/lib/manager/npm/post-update/yarn.ts @@ -2,7 +2,7 @@ import is from '@sindresorhus/is'; import { gte, minVersion, validRange } from 'semver'; import { quote } from 'shlex'; import { join } from 'upath'; -import { getAdminConfig } from '../../../config/admin'; +import { getGlobalConfig } from '../../../config/admin'; import { SYSTEM_INSUFFICIENT_DISK_SPACE, TEMPORARY_ERROR, @@ -99,7 +99,7 @@ export async function generateLockFile( extraEnv.YARN_HTTP_TIMEOUT = '100000'; extraEnv.YARN_GLOBAL_FOLDER = env.YARN_GLOBAL_FOLDER; } - if (!getAdminConfig().allowScripts || config.ignoreScripts) { + if (!getGlobalConfig().allowScripts || config.ignoreScripts) { if (isYarn1) { cmdOptions += ' --ignore-scripts'; } else { @@ -118,7 +118,7 @@ export async function generateLockFile( }, }; // istanbul ignore if - if (getAdminConfig().exposeAllEnv) { + if (getGlobalConfig().exposeAllEnv) { execOptions.extraEnv.NPM_AUTH = env.NPM_AUTH; execOptions.extraEnv.NPM_EMAIL = env.NPM_EMAIL; } diff --git a/lib/manager/nuget/artifacts.spec.ts b/lib/manager/nuget/artifacts.spec.ts index f6eae1fb60..02a3d2a749 100644 --- a/lib/manager/nuget/artifacts.spec.ts +++ b/lib/manager/nuget/artifacts.spec.ts @@ -2,8 +2,8 @@ import { exec as _exec } from 'child_process'; import { join } from 'upath'; import { envMock, mockExecAll } from '../../../test/exec-util'; import { fs, mocked } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; -import type { RepoAdminConfig } from '../../config/types'; +import { setGlobalConfig } from '../../config/admin'; +import type { RepoGlobalConfig } from '../../config/types'; import * as docker from '../../util/exec/docker'; import * as _env from '../../util/exec/env'; import * as _hostRules from '../../util/host-rules'; @@ -31,7 +31,7 @@ const getRandomString: jest.Mock = _getRandomString as any; const hostRules = mocked(_hostRules); -const adminConfig: RepoAdminConfig = { +const adminConfig: RepoGlobalConfig = { // `join` fixes Windows CI localDir: join('/tmp/github/some/repo'), cacheDir: join('/tmp/renovate/cache'), @@ -49,12 +49,12 @@ describe('updateArtifacts', () => { Promise.resolve(`others/${dirName}`) ); getRandomString.mockReturnValue('not-so-random' as any); - setAdminConfig(adminConfig); + setGlobalConfig(adminConfig); docker.resetPrefetchedImages(); }); afterEach(() => { - setAdminConfig(); + setGlobalConfig(); }); it('aborts if no lock file found', async () => { @@ -150,7 +150,7 @@ describe('updateArtifacts', () => { }); it('supports docker mode', async () => { - setAdminConfig({ ...adminConfig, binarySource: 'docker' }); + setGlobalConfig({ ...adminConfig, binarySource: 'docker' }); const execSnapshots = mockExecAll(exec); fs.getSiblingFileName.mockReturnValueOnce('packages.lock.json'); fs.readLocalFile.mockResolvedValueOnce('Current packages.lock.json' as any); @@ -166,7 +166,7 @@ describe('updateArtifacts', () => { expect(execSnapshots).toMatchSnapshot(); }); it('supports global mode', async () => { - setAdminConfig({ ...adminConfig, binarySource: 'global' }); + setGlobalConfig({ ...adminConfig, binarySource: 'global' }); const execSnapshots = mockExecAll(exec); fs.getSiblingFileName.mockReturnValueOnce('packages.lock.json'); fs.readLocalFile.mockResolvedValueOnce('Current packages.lock.json' as any); diff --git a/lib/manager/nuget/artifacts.ts b/lib/manager/nuget/artifacts.ts index 2482979773..ab30ad4537 100644 --- a/lib/manager/nuget/artifacts.ts +++ b/lib/manager/nuget/artifacts.ts @@ -1,5 +1,5 @@ import { join } from 'path'; -import { getAdminConfig } from '../../config/admin'; +import { getGlobalConfig } from '../../config/admin'; import { TEMPORARY_ERROR } from '../../constants/error-messages'; import { id, parseRegistryUrl } from '../../datasource/nuget'; import { logger } from '../../logger'; @@ -29,7 +29,7 @@ async function addSourceCmds( config: UpdateArtifactsConfig, nugetConfigFile: string ): Promise { - const { localDir } = getAdminConfig(); + const { localDir } = getGlobalConfig(); const registries = (await getConfiguredRegistries(packageFileName, localDir)) || getDefaultRegistries(); diff --git a/lib/manager/nuget/extract.spec.ts b/lib/manager/nuget/extract.spec.ts index 77361bc882..cb30fef239 100644 --- a/lib/manager/nuget/extract.spec.ts +++ b/lib/manager/nuget/extract.spec.ts @@ -1,23 +1,23 @@ import * as upath from 'upath'; import { getName, loadFixture } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; -import type { RepoAdminConfig } from '../../config/types'; +import { setGlobalConfig } from '../../config/admin'; +import type { RepoGlobalConfig } from '../../config/types'; import type { ExtractConfig } from '../types'; import { extractPackageFile } from './extract'; const config: ExtractConfig = {}; -const adminConfig: RepoAdminConfig = { +const adminConfig: RepoGlobalConfig = { localDir: upath.resolve('lib/manager/nuget/__fixtures__'), }; describe(getName(), () => { describe('extractPackageFile()', () => { beforeEach(() => { - setAdminConfig(adminConfig); + setGlobalConfig(adminConfig); }); afterEach(() => { - setAdminConfig(); + setGlobalConfig(); }); it('returns empty for invalid csproj', async () => { // FIXME: explicit assert condition diff --git a/lib/manager/nuget/extract.ts b/lib/manager/nuget/extract.ts index 27a6ebecaf..c9c0dec906 100644 --- a/lib/manager/nuget/extract.ts +++ b/lib/manager/nuget/extract.ts @@ -1,5 +1,5 @@ import { XmlDocument, XmlElement, XmlNode } from 'xmldoc'; -import { getAdminConfig } from '../../config/admin'; +import { getGlobalConfig } from '../../config/admin'; import * as datasourceNuget from '../../datasource/nuget'; import { logger } from '../../logger'; import { getSiblingFileName, localPathExists } from '../../util/fs'; @@ -71,7 +71,7 @@ export async function extractPackageFile( ): Promise { logger.trace({ packageFile }, 'nuget.extractPackageFile()'); - const { localDir } = getAdminConfig(); + const { localDir } = getGlobalConfig(); const registries = await getConfiguredRegistries(packageFile, localDir); const registryUrls = registries ? registries.map((registry) => registry.url) diff --git a/lib/manager/pip-compile/artifacts.spec.ts b/lib/manager/pip-compile/artifacts.spec.ts index a586ace9cc..56fa4ac5f4 100644 --- a/lib/manager/pip-compile/artifacts.spec.ts +++ b/lib/manager/pip-compile/artifacts.spec.ts @@ -3,8 +3,8 @@ import _fs from 'fs-extra'; import { join } from 'upath'; import { envMock, mockExecAll } from '../../../test/exec-util'; import { git, mocked } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; -import type { RepoAdminConfig } from '../../config/types'; +import { setGlobalConfig } from '../../config/admin'; +import type { RepoGlobalConfig } from '../../config/types'; import * as docker from '../../util/exec/docker'; import * as _env from '../../util/exec/env'; import type { StatusResult } from '../../util/git'; @@ -22,7 +22,7 @@ const fs: jest.Mocked = _fs as any; const exec: jest.Mock = _exec as any; const env = mocked(_env); -const adminConfig: RepoAdminConfig = { +const adminConfig: RepoGlobalConfig = { // `join` fixes Windows CI localDir: join('/tmp/github/some/repo'), cacheDir: join('/tmp/renovate/cache'), @@ -40,7 +40,7 @@ describe('.updateArtifacts()', () => { LANG: 'en_US.UTF-8', LC_ALL: 'en_US', }); - setAdminConfig(adminConfig); + setGlobalConfig(adminConfig); docker.resetPrefetchedImages(); }); @@ -89,7 +89,7 @@ describe('.updateArtifacts()', () => { }); it('supports docker mode', async () => { - setAdminConfig(dockerAdminConfig); + setGlobalConfig(dockerAdminConfig); const execSnapshots = mockExecAll(exec); git.getRepoStatus.mockResolvedValue({ modified: ['requirements.txt'], @@ -141,7 +141,7 @@ describe('.updateArtifacts()', () => { }); it('uses pipenv version from config', async () => { - setAdminConfig(dockerAdminConfig); + setGlobalConfig(dockerAdminConfig); const execSnapshots = mockExecAll(exec); git.getRepoStatus.mockResolvedValue({ modified: ['requirements.txt'], diff --git a/lib/manager/pip_requirements/artifacts.spec.ts b/lib/manager/pip_requirements/artifacts.spec.ts index bb806bdbc1..477b8d756e 100644 --- a/lib/manager/pip_requirements/artifacts.spec.ts +++ b/lib/manager/pip_requirements/artifacts.spec.ts @@ -1,5 +1,5 @@ import _fs from 'fs-extra'; -import { setAdminConfig } from '../../config/admin'; +import { setGlobalConfig } from '../../config/admin'; import type { UpdateArtifactsConfig } from '../types'; import { updateArtifacts } from './artifacts'; @@ -19,7 +19,7 @@ describe('.updateArtifacts()', () => { beforeEach(() => { jest.resetAllMocks(); jest.resetModules(); - setAdminConfig({ localDir: '' }); + setGlobalConfig({ localDir: '' }); }); it('returns null if no updatedDeps were provided', async () => { expect( diff --git a/lib/manager/pip_requirements/extract.spec.ts b/lib/manager/pip_requirements/extract.spec.ts index b73af574fa..5d7d40c933 100644 --- a/lib/manager/pip_requirements/extract.spec.ts +++ b/lib/manager/pip_requirements/extract.spec.ts @@ -1,5 +1,5 @@ import { getName, loadFixture } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; +import { setGlobalConfig } from '../../config/admin'; import { extractPackageFile } from './extract'; const requirements1 = loadFixture('requirements1.txt'); @@ -13,11 +13,11 @@ const requirements7 = loadFixture('requirements7.txt'); describe(getName(), () => { beforeEach(() => { delete process.env.PIP_TEST_TOKEN; - setAdminConfig(); + setGlobalConfig(); }); afterEach(() => { delete process.env.PIP_TEST_TOKEN; - setAdminConfig(); + setGlobalConfig(); }); describe('extractPackageFile()', () => { let config; @@ -123,7 +123,7 @@ describe(getName(), () => { }); it('should replace env vars in high trust mode', () => { process.env.PIP_TEST_TOKEN = 'its-a-secret'; - setAdminConfig({ exposeAllEnv: true }); + setGlobalConfig({ exposeAllEnv: true }); const res = extractPackageFile(requirements7, 'unused_file_name', {}); expect(res.registryUrls).toEqual([ 'https://pypi.org/pypi/', diff --git a/lib/manager/pip_requirements/extract.ts b/lib/manager/pip_requirements/extract.ts index d225a7790a..694731feb3 100644 --- a/lib/manager/pip_requirements/extract.ts +++ b/lib/manager/pip_requirements/extract.ts @@ -1,6 +1,6 @@ // based on https://www.python.org/dev/peps/pep-0508/#names import { RANGE_PATTERN } from '@renovate/pep440/lib/specifier'; -import { getAdminConfig } from '../../config/admin'; +import { getGlobalConfig } from '../../config/admin'; import { PypiDatasource } from '../../datasource/pypi'; import { logger } from '../../logger'; import { SkipReason } from '../../types'; @@ -85,7 +85,7 @@ export function extractPackageFile( res.registryUrls = registryUrls.map((url) => { // handle the optional quotes in eg. `--extra-index-url "https://foo.bar"` const cleaned = url.replace(/^"/, '').replace(/"$/, ''); - if (!getAdminConfig().exposeAllEnv) { + if (!getGlobalConfig().exposeAllEnv) { return cleaned; } // interpolate any environment variables diff --git a/lib/manager/pip_setup/extract.spec.ts b/lib/manager/pip_setup/extract.spec.ts index f3ea6b3e11..a732b3f831 100644 --- a/lib/manager/pip_setup/extract.spec.ts +++ b/lib/manager/pip_setup/extract.spec.ts @@ -1,6 +1,6 @@ import { envMock, exec, mockExecSequence } from '../../../test/exec-util'; import { env, getName } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; +import { setGlobalConfig } from '../../config/admin'; import { getPythonAlias, parsePythonVersion, @@ -18,7 +18,7 @@ describe(getName(), () => { resetModule(); env.getChildProcessEnv.mockReturnValue(envMock.basic); - setAdminConfig({ localDir: '/tmp/foo/bar' }); + setGlobalConfig({ localDir: '/tmp/foo/bar' }); }); describe('parsePythonVersion', () => { it('returns major and minor version numbers', () => { diff --git a/lib/manager/pip_setup/extract.ts b/lib/manager/pip_setup/extract.ts index ddcfb0c111..f2b3f166c1 100644 --- a/lib/manager/pip_setup/extract.ts +++ b/lib/manager/pip_setup/extract.ts @@ -1,4 +1,4 @@ -import { getAdminConfig } from '../../config/admin'; +import { getGlobalConfig } from '../../config/admin'; import { PypiDatasource } from '../../datasource/pypi'; import { logger } from '../../logger'; import { SkipReason } from '../../types'; @@ -49,7 +49,7 @@ export async function extractSetupFile( let cmd = 'python'; const extractPy = await getExtractFile(); const args = [`"${extractPy}"`, `"${packageFile}"`]; - if (getAdminConfig().binarySource !== 'docker') { + if (getGlobalConfig().binarySource !== 'docker') { logger.debug('Running python via global command'); cmd = await getPythonAlias(); } diff --git a/lib/manager/pip_setup/index.spec.ts b/lib/manager/pip_setup/index.spec.ts index c3cb2e846a..80196bbaa5 100644 --- a/lib/manager/pip_setup/index.spec.ts +++ b/lib/manager/pip_setup/index.spec.ts @@ -6,8 +6,8 @@ import { mockExecSequence, } from '../../../test/exec-util'; import { env, getName, loadFixture } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; -import type { RepoAdminConfig } from '../../config/types'; +import { setGlobalConfig } from '../../config/admin'; +import type { RepoGlobalConfig } from '../../config/types'; import * as fs from '../../util/fs'; import type { ExtractConfig } from '../types'; import * as extract from './extract'; @@ -17,7 +17,7 @@ const packageFile = 'setup.py'; const content = loadFixture(packageFile); const jsonContent = loadFixture('setup.py.json'); -const adminConfig: RepoAdminConfig = { +const adminConfig: RepoGlobalConfig = { localDir: '/tmp/github/some/repo', cacheDir: '/tmp/renovate/cache', }; @@ -46,7 +46,7 @@ describe(getName(), () => { jest.resetModules(); extract.resetModule(); - setAdminConfig(adminConfig); + setGlobalConfig(adminConfig); env.getChildProcessEnv.mockReturnValue(envMock.basic); // do not copy extract.py @@ -54,7 +54,7 @@ describe(getName(), () => { }); afterEach(() => { - setAdminConfig(); + setGlobalConfig(); }); it('returns found deps', async () => { @@ -76,7 +76,7 @@ describe(getName(), () => { }); it('returns found deps (docker)', async () => { - setAdminConfig({ ...adminConfig, binarySource: 'docker' }); + setGlobalConfig({ ...adminConfig, binarySource: 'docker' }); const execSnapshots = mockExecAll(exec, { stdout: '', stderr: '' }); jest.spyOn(fs, 'readLocalFile').mockResolvedValueOnce(jsonContent); diff --git a/lib/manager/pipenv/artifacts.spec.ts b/lib/manager/pipenv/artifacts.spec.ts index 4238134ee4..5dbe29b60a 100644 --- a/lib/manager/pipenv/artifacts.spec.ts +++ b/lib/manager/pipenv/artifacts.spec.ts @@ -3,8 +3,8 @@ import _fs from 'fs-extra'; import { join } from 'upath'; import { envMock, mockExecAll } from '../../../test/exec-util'; import { git, mocked } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; -import type { RepoAdminConfig } from '../../config/types'; +import { setGlobalConfig } from '../../config/admin'; +import type { RepoGlobalConfig } from '../../config/types'; import * as docker from '../../util/exec/docker'; import * as _env from '../../util/exec/env'; import type { StatusResult } from '../../util/git'; @@ -22,7 +22,7 @@ const fs: jest.Mocked = _fs as any; const exec: jest.Mock = _exec as any; const env = mocked(_env); -const adminConfig: RepoAdminConfig = { +const adminConfig: RepoGlobalConfig = { // `join` fixes Windows CI localDir: join('/tmp/github/some/repo'), cacheDir: join('/tmp/renovate/cache'), @@ -42,7 +42,7 @@ describe('.updateArtifacts()', () => { LC_ALL: 'en_US', }); - setAdminConfig(adminConfig); + setGlobalConfig(adminConfig); docker.resetPrefetchedImages(); pipFileLock = { _meta: { requires: {} }, @@ -108,7 +108,7 @@ describe('.updateArtifacts()', () => { expect(execSnapshots).toMatchSnapshot(); }); it('supports docker mode', async () => { - setAdminConfig(dockerAdminConfig); + setGlobalConfig(dockerAdminConfig); pipFileLock._meta.requires.python_version = '3.7'; fs.readFile.mockResolvedValueOnce(JSON.stringify(pipFileLock) as any); const execSnapshots = mockExecAll(exec); @@ -159,7 +159,7 @@ describe('.updateArtifacts()', () => { expect(execSnapshots).toMatchSnapshot(); }); it('uses pipenv version from Pipfile', async () => { - setAdminConfig(dockerAdminConfig); + setGlobalConfig(dockerAdminConfig); pipFileLock.default.pipenv.version = '==2020.8.13'; fs.readFile.mockResolvedValueOnce(JSON.stringify(pipFileLock) as any); const execSnapshots = mockExecAll(exec); @@ -178,7 +178,7 @@ describe('.updateArtifacts()', () => { expect(execSnapshots).toMatchSnapshot(); }); it('uses pipenv version from Pipfile dev packages', async () => { - setAdminConfig(dockerAdminConfig); + setGlobalConfig(dockerAdminConfig); pipFileLock.develop.pipenv.version = '==2020.8.13'; fs.readFile.mockResolvedValueOnce(JSON.stringify(pipFileLock) as any); const execSnapshots = mockExecAll(exec); @@ -197,7 +197,7 @@ describe('.updateArtifacts()', () => { expect(execSnapshots).toMatchSnapshot(); }); it('uses pipenv version from config', async () => { - setAdminConfig(dockerAdminConfig); + setGlobalConfig(dockerAdminConfig); pipFileLock.default.pipenv.version = '==2020.8.13'; fs.readFile.mockResolvedValueOnce(JSON.stringify(pipFileLock) as any); const execSnapshots = mockExecAll(exec); diff --git a/lib/manager/poetry/artifacts.spec.ts b/lib/manager/poetry/artifacts.spec.ts index d56d277c38..30122cdab3 100644 --- a/lib/manager/poetry/artifacts.spec.ts +++ b/lib/manager/poetry/artifacts.spec.ts @@ -3,8 +3,8 @@ import _fs from 'fs-extra'; import { join } from 'upath'; import { envMock, mockExecAll } from '../../../test/exec-util'; import { loadFixture, mocked } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; -import type { RepoAdminConfig } from '../../config/types'; +import { setGlobalConfig } from '../../config/admin'; +import type { RepoGlobalConfig } from '../../config/types'; import * as _datasource from '../../datasource'; import * as docker from '../../util/exec/docker'; import * as _env from '../../util/exec/env'; @@ -26,7 +26,7 @@ const env = mocked(_env); const datasource = mocked(_datasource); const hostRules = mocked(_hostRules); -const adminConfig: RepoAdminConfig = { +const adminConfig: RepoGlobalConfig = { localDir: join('/tmp/github/some/repo'), }; @@ -36,7 +36,7 @@ describe('.updateArtifacts()', () => { beforeEach(() => { jest.resetAllMocks(); env.getChildProcessEnv.mockReturnValue(envMock.basic); - setAdminConfig(adminConfig); + setGlobalConfig(adminConfig); docker.resetPrefetchedImages(); }); it('returns null if no poetry.lock found', async () => { @@ -130,7 +130,7 @@ describe('.updateArtifacts()', () => { expect(execSnapshots).toMatchSnapshot(); }); it('returns updated poetry.lock using docker', async () => { - setAdminConfig({ ...adminConfig, binarySource: 'docker' }); + setGlobalConfig({ ...adminConfig, binarySource: 'docker' }); fs.readFile.mockResolvedValueOnce('[metadata]\n' as any); const execSnapshots = mockExecAll(exec); fs.readFile.mockReturnValueOnce('New poetry.lock' as any); @@ -155,7 +155,7 @@ describe('.updateArtifacts()', () => { expect(execSnapshots).toMatchSnapshot(); }); it('returns updated poetry.lock using docker (constraints)', async () => { - setAdminConfig({ ...adminConfig, binarySource: 'docker' }); + setGlobalConfig({ ...adminConfig, binarySource: 'docker' }); fs.readFile.mockResolvedValueOnce( '[metadata]\npython-versions = "~2.7 || ^3.4"' as any ); diff --git a/lib/manager/terraform/lockfile/hash.spec.ts b/lib/manager/terraform/lockfile/hash.spec.ts index cae12b4be4..c6f24a9cdd 100644 --- a/lib/manager/terraform/lockfile/hash.spec.ts +++ b/lib/manager/terraform/lockfile/hash.spec.ts @@ -7,7 +7,7 @@ import { loadFixture, logger, } from '../../../../test/util'; -import { setAdminConfig } from '../../../config/admin'; +import { setGlobalConfig } from '../../../config/admin'; import { TerraformProviderDatasource } from '../../../datasource/terraform-provider'; import { Logger } from '../../../logger/types'; import { TerraformProviderHash } from './hash'; @@ -22,7 +22,7 @@ describe(getName(), () => { beforeEach(async () => { cacheDir = await dir({ unsafeCleanup: true }); - setAdminConfig({ cacheDir: cacheDir.path }); + setGlobalConfig({ cacheDir: cacheDir.path }); }); afterEach(() => cacheDir.cleanup()); diff --git a/lib/manager/terraform/lockfile/index.spec.ts b/lib/manager/terraform/lockfile/index.spec.ts index 919ee97815..19fa728ca2 100644 --- a/lib/manager/terraform/lockfile/index.spec.ts +++ b/lib/manager/terraform/lockfile/index.spec.ts @@ -1,6 +1,6 @@ import { join } from 'upath'; import { fs, getName, loadFixture, mocked } from '../../../../test/util'; -import { setAdminConfig } from '../../../config/admin'; +import { setGlobalConfig } from '../../../config/admin'; import { getPkgReleases } from '../../../datasource'; import type { UpdateArtifactsConfig } from '../../types'; import { TerraformProviderHash } from './hash'; @@ -32,7 +32,7 @@ describe(getName(), () => { beforeEach(() => { jest.resetAllMocks(); jest.resetModules(); - setAdminConfig(adminConfig); + setGlobalConfig(adminConfig); }); afterEach(() => { diff --git a/lib/util/cache/repository/index.spec.ts b/lib/util/cache/repository/index.spec.ts index 1e7f0e8250..647095ddd1 100644 --- a/lib/util/cache/repository/index.spec.ts +++ b/lib/util/cache/repository/index.spec.ts @@ -1,6 +1,6 @@ import * as _fs from 'fs-extra'; import { getName, mocked } from '../../../../test/util'; -import { setAdminConfig } from '../../../config/admin'; +import { setGlobalConfig } from '../../../config/admin'; import * as repositoryCache from '.'; jest.mock('fs-extra'); @@ -10,7 +10,7 @@ const fs = mocked(_fs); describe(getName(), () => { beforeEach(() => { jest.resetAllMocks(); - setAdminConfig({ cacheDir: '/tmp/renovate/cache/' }); + setGlobalConfig({ cacheDir: '/tmp/renovate/cache/' }); }); const config = { platform: 'github', diff --git a/lib/util/cache/repository/index.ts b/lib/util/cache/repository/index.ts index 27779993b7..a9970e972e 100644 --- a/lib/util/cache/repository/index.ts +++ b/lib/util/cache/repository/index.ts @@ -1,6 +1,6 @@ import * as fs from 'fs-extra'; import { join } from 'upath'; -import { getAdminConfig } from '../../../config/admin'; +import { getGlobalConfig } from '../../../config/admin'; import type { RenovateConfig, RepositoryCacheConfig, @@ -17,7 +17,7 @@ let cache: Cache = Object.create({}); export function getCacheFileName(config: RenovateConfig): string { return join( - getAdminConfig().cacheDir, + getGlobalConfig().cacheDir, '/renovate/repository/', config.platform, config.repository + '.json' diff --git a/lib/util/exec/docker/index.spec.ts b/lib/util/exec/docker/index.spec.ts index 3de9589823..2b12d55efe 100644 --- a/lib/util/exec/docker/index.spec.ts +++ b/lib/util/exec/docker/index.spec.ts @@ -4,7 +4,7 @@ import { mockExecSequence, } from '../../../../test/exec-util'; import { getName } from '../../../../test/util'; -import { setAdminConfig } from '../../../config/admin'; +import { setGlobalConfig } from '../../../config/admin'; import { SYSTEM_INSUFFICIENT_MEMORY } from '../../../constants/error-messages'; import { getPkgReleases as _getPkgReleases } from '../../../datasource'; import { logger } from '../../../logger'; @@ -132,12 +132,12 @@ describe(getName(), () => { describe('removeDanglingContainers', () => { beforeEach(() => { - setAdminConfig({ binarySource: 'docker' }); + setGlobalConfig({ binarySource: 'docker' }); }); it('short-circuits in non-Docker environment', async () => { const execSnapshots = mockExecAll(exec); - setAdminConfig({ binarySource: 'global' }); + setGlobalConfig({ binarySource: 'global' }); await removeDanglingContainers(); expect(execSnapshots).toBeEmpty(); }); @@ -222,7 +222,7 @@ describe(getName(), () => { `bash -l -c "foo && bar && baz"`; beforeEach(() => { - setAdminConfig({ dockerUser: 'some-user' }); + setGlobalConfig({ dockerUser: 'some-user' }); }); it('returns executable command', async () => { diff --git a/lib/util/exec/docker/index.ts b/lib/util/exec/docker/index.ts index 36a1689906..c3fc9a5074 100644 --- a/lib/util/exec/docker/index.ts +++ b/lib/util/exec/docker/index.ts @@ -1,5 +1,5 @@ import is from '@sindresorhus/is'; -import { getAdminConfig } from '../../../config/admin'; +import { getGlobalConfig } from '../../../config/admin'; import { SYSTEM_INSUFFICIENT_MEMORY } from '../../../constants/error-messages'; import { getPkgReleases } from '../../../datasource'; import { logger } from '../../../logger'; @@ -150,7 +150,7 @@ export async function removeDockerContainer( } export async function removeDanglingContainers(): Promise { - const { binarySource, dockerChildPrefix } = getAdminConfig(); + const { binarySource, dockerChildPrefix } = getGlobalConfig(); if (binarySource !== 'docker') { return; } @@ -203,7 +203,7 @@ export async function generateDockerCommand( dockerUser, dockerChildPrefix, dockerImagePrefix, - } = getAdminConfig(); + } = getGlobalConfig(); const result = ['docker run --rm']; const containerName = getContainerName(image, dockerChildPrefix); const containerLabel = getContainerLabel(dockerChildPrefix); diff --git a/lib/util/exec/env.spec.ts b/lib/util/exec/env.spec.ts index b0e67ddf96..60e13fe85d 100644 --- a/lib/util/exec/env.spec.ts +++ b/lib/util/exec/env.spec.ts @@ -1,4 +1,4 @@ -import { setAdminConfig } from '../../config/admin'; +import { setGlobalConfig } from '../../config/admin'; import { getChildProcessEnv } from './env'; describe('getChildProcess environment when trustlevel set to low', () => { @@ -54,7 +54,7 @@ describe('getChildProcess environment when trustlevel set to low', () => { describe('getChildProcessEnv when trustlevel set to high', () => { it('returns process.env if trustlevel set to high', () => { - setAdminConfig({ exposeAllEnv: true }); + setGlobalConfig({ exposeAllEnv: true }); expect(getChildProcessEnv()).toMatchObject(process.env); }); }); diff --git a/lib/util/exec/env.ts b/lib/util/exec/env.ts index 480338560e..7bbad5a146 100644 --- a/lib/util/exec/env.ts +++ b/lib/util/exec/env.ts @@ -1,4 +1,4 @@ -import { getAdminConfig } from '../../config/admin'; +import { getGlobalConfig } from '../../config/admin'; const basicEnvVars = [ 'HTTP_PROXY', @@ -20,7 +20,7 @@ export function getChildProcessEnv( customEnvVars: string[] = [] ): NodeJS.ProcessEnv { const env: NodeJS.ProcessEnv = {}; - if (getAdminConfig().exposeAllEnv) { + if (getGlobalConfig().exposeAllEnv) { return { ...env, ...process.env }; } const envVars = [...basicEnvVars, ...customEnvVars]; diff --git a/lib/util/exec/index.spec.ts b/lib/util/exec/index.spec.ts index 7472034fd5..fed2200ecf 100644 --- a/lib/util/exec/index.spec.ts +++ b/lib/util/exec/index.spec.ts @@ -5,8 +5,8 @@ import { } from 'child_process'; import { envMock } from '../../../test/exec-util'; import { getName } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; -import type { RepoAdminConfig } from '../../config/types'; +import { setGlobalConfig } from '../../config/admin'; +import type { RepoGlobalConfig } from '../../config/types'; import { TEMPORARY_ERROR } from '../../constants/error-messages'; import { RawExecOptions, VolumeOption } from './common'; import * as dockerModule from './docker'; @@ -22,7 +22,7 @@ interface TestInput { inOpts: ExecOptions; outCmd: string[]; outOpts: RawExecOptions[]; - adminConfig?: Partial; + adminConfig?: Partial; } describe(getName(), () => { @@ -40,7 +40,7 @@ describe(getName(), () => { jest.restoreAllMocks(); jest.resetModules(); processEnvOrig = process.env; - setAdminConfig(); + setGlobalConfig(); }); afterEach(() => { @@ -677,7 +677,7 @@ describe(getName(), () => { callback(null, { stdout: '', stderr: '' }); return undefined; }); - setAdminConfig({ cacheDir, localDir: cwd, ...adminConfig }); + setGlobalConfig({ cacheDir, localDir: cwd, ...adminConfig }); await exec(cmd as string, inOpts); expect(actualCmd).toEqual(outCommand); @@ -694,19 +694,19 @@ describe(getName(), () => { return undefined; }); - setAdminConfig({ binarySource: 'global' }); + setGlobalConfig({ binarySource: 'global' }); await exec(inCmd, { docker }); await exec(inCmd, { docker }); - setAdminConfig({ binarySource: 'docker' }); + setGlobalConfig({ binarySource: 'docker' }); await exec(inCmd, { docker }); await exec(inCmd, { docker }); - setAdminConfig({ binarySource: 'global' }); + setGlobalConfig({ binarySource: 'global' }); await exec(inCmd, { docker }); await exec(inCmd, { docker }); - setAdminConfig({ binarySource: 'docker' }); + setGlobalConfig({ binarySource: 'docker' }); await exec(inCmd, { docker }); await exec(inCmd, { docker }); @@ -730,7 +730,7 @@ describe(getName(), () => { }); it('wraps error if removeDockerContainer throws an error', async () => { - setAdminConfig({ binarySource: 'docker' }); + setGlobalConfig({ binarySource: 'docker' }); cpExec.mockImplementation(() => { throw new Error('some error occurred'); }); diff --git a/lib/util/exec/index.ts b/lib/util/exec/index.ts index 42b0d31fec..c333a9349b 100644 --- a/lib/util/exec/index.ts +++ b/lib/util/exec/index.ts @@ -1,6 +1,6 @@ import type { ExecOptions as ChildProcessExecOptions } from 'child_process'; import { dirname, join } from 'upath'; -import { getAdminConfig } from '../../config/admin'; +import { getGlobalConfig } from '../../config/admin'; import { TEMPORARY_ERROR } from '../../constants/error-messages'; import { logger } from '../../logger'; import { @@ -25,7 +25,7 @@ function getChildEnv({ extraEnv = {}, env: forcedEnv = {}, }: ExecOptions): ExtraEnv { - const { customEnvVariables: globalConfigEnv } = getAdminConfig(); + const { customEnvVariables: globalConfigEnv } = getGlobalConfig(); const inheritedKeys = Object.entries(extraEnv).reduce( (acc, [key, val]) => @@ -59,7 +59,7 @@ function dockerEnvVars( } function getCwd({ cwd, cwdFile }: ExecOptions): string { - const { localDir: defaultCwd } = getAdminConfig(); + const { localDir: defaultCwd } = getGlobalConfig(); const paramCwd = cwdFile ? join(defaultCwd, dirname(cwdFile)) : cwd; return paramCwd || defaultCwd; } @@ -86,7 +86,7 @@ function getRawExecOptions(opts: ExecOptions): RawExecOptions { } function isDocker({ docker }: ExecOptions): boolean { - const { binarySource } = getAdminConfig(); + const { binarySource } = getGlobalConfig(); return binarySource === 'docker' && !!docker; } @@ -100,7 +100,7 @@ async function prepareRawExec( opts: ExecOptions = {} ): Promise { const { docker } = opts; - const { customEnvVariables } = getAdminConfig(); + const { customEnvVariables } = getGlobalConfig(); const rawOptions = getRawExecOptions(opts); @@ -129,7 +129,7 @@ export async function exec( opts: ExecOptions = {} ): Promise { const { docker } = opts; - const { dockerChildPrefix } = getAdminConfig(); + const { dockerChildPrefix } = getGlobalConfig(); const { rawCommands, rawOptions } = await prepareRawExec(cmd, opts); const useDocker = isDocker(opts); diff --git a/lib/util/fs/index.spec.ts b/lib/util/fs/index.spec.ts index da63e7beaa..32b4877a3a 100644 --- a/lib/util/fs/index.spec.ts +++ b/lib/util/fs/index.spec.ts @@ -2,7 +2,7 @@ import { withDir } from 'tmp-promise'; import { join } from 'upath'; import { envMock } from '../../../test/exec-util'; import { getName, mocked } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; +import { setGlobalConfig } from '../../config/admin'; import * as _env from '../exec/env'; import { ensureCacheDir, @@ -22,7 +22,7 @@ const env = mocked(_env); describe(getName(), () => { describe('readLocalFile', () => { beforeEach(() => { - setAdminConfig({ localDir: '' }); + setGlobalConfig({ localDir: '' }); }); it('reads buffer', async () => { @@ -60,7 +60,7 @@ describe(getName(), () => { it('returns path for file', async () => { await withDir( async (localDir) => { - setAdminConfig({ + setGlobalConfig({ localDir: localDir.path, }); @@ -114,7 +114,7 @@ describe(getName(), () => { it('returns dir content', async () => { await withDir( async (localDir) => { - setAdminConfig({ + setGlobalConfig({ localDir: localDir.path, }); await writeLocalFile('test/Cargo.toml', ''); @@ -142,7 +142,7 @@ describe(getName(), () => { it('return empty array for non existing directory', async () => { await withDir( async (localDir) => { - setAdminConfig({ + setGlobalConfig({ localDir: localDir.path, }); await expect(readLocalDirectory('somedir')).rejects.toThrow(); @@ -174,7 +174,7 @@ describe(getName(), () => { ...envMock.basic, }); - setAdminConfig({ + setGlobalConfig({ cacheDir: join(dirFromConfig), }); diff --git a/lib/util/fs/index.ts b/lib/util/fs/index.ts index b932356c5a..fa0fa895d6 100644 --- a/lib/util/fs/index.ts +++ b/lib/util/fs/index.ts @@ -3,7 +3,7 @@ import util from 'util'; import is from '@sindresorhus/is'; import * as fs from 'fs-extra'; import { isAbsolute, join, parse } from 'upath'; -import { getAdminConfig } from '../../config/admin'; +import { getGlobalConfig } from '../../config/admin'; import { logger } from '../../logger'; export * from './proxies'; @@ -31,7 +31,7 @@ export async function readLocalFile( fileName: string, encoding?: string ): Promise { - const { localDir } = getAdminConfig(); + const { localDir } = getGlobalConfig(); const localFileName = join(localDir, fileName); try { const fileContent = await fs.readFile(localFileName, encoding); @@ -46,13 +46,13 @@ export async function writeLocalFile( fileName: string, fileContent: string ): Promise { - const { localDir } = getAdminConfig(); + const { localDir } = getGlobalConfig(); const localFileName = join(localDir, fileName); await fs.outputFile(localFileName, fileContent); } export async function deleteLocalFile(fileName: string): Promise { - const { localDir } = getAdminConfig(); + const { localDir } = getGlobalConfig(); if (localDir) { const localFileName = join(localDir, fileName); await fs.remove(localFileName); @@ -64,7 +64,7 @@ export async function renameLocalFile( fromFile: string, toFile: string ): Promise { - const { localDir } = getAdminConfig(); + const { localDir } = getGlobalConfig(); await fs.move(join(localDir, fromFile), join(localDir, toFile)); } @@ -77,13 +77,13 @@ export async function ensureDir(dirName: string): Promise { // istanbul ignore next export async function ensureLocalDir(dirName: string): Promise { - const { localDir } = getAdminConfig(); + const { localDir } = getGlobalConfig(); const localDirName = join(localDir, dirName); await fs.ensureDir(localDirName); } export async function ensureCacheDir(name: string): Promise { - const cacheDirName = join(getAdminConfig().cacheDir, `others/${name}`); + const cacheDirName = join(getGlobalConfig().cacheDir, `others/${name}`); await fs.ensureDir(cacheDirName); return cacheDirName; } @@ -94,12 +94,12 @@ export async function ensureCacheDir(name: string): Promise { * without risk of that information leaking to other repositories/users. */ export function privateCacheDir(): string { - const { cacheDir } = getAdminConfig(); + const { cacheDir } = getGlobalConfig(); return join(cacheDir, '__renovate-private-cache'); } export function localPathExists(pathName: string): Promise { - const { localDir } = getAdminConfig(); + const { localDir } = getGlobalConfig(); // Works for both files as well as directories return fs .stat(join(localDir, pathName)) @@ -140,7 +140,7 @@ export async function findLocalSiblingOrParent( * Get files by name from directory */ export async function readLocalDirectory(path: string): Promise { - const { localDir } = getAdminConfig(); + const { localDir } = getGlobalConfig(); const localPath = join(localDir, path); const fileList = await fs.readdir(localPath); return fileList; diff --git a/lib/util/git/index.spec.ts b/lib/util/git/index.spec.ts index 834f017061..2863565d6d 100644 --- a/lib/util/git/index.spec.ts +++ b/lib/util/git/index.spec.ts @@ -3,7 +3,7 @@ import Git from 'simple-git'; import SimpleGit from 'simple-git/src/git'; import tmp from 'tmp-promise'; import { getName } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; +import { setGlobalConfig } from '../../config/admin'; import * as git from '.'; import { GitNoVerifyOption, setNoVerify } from '.'; @@ -71,7 +71,7 @@ describe(getName(), () => { await repo.clone(base.path, '.', ['--bare']); await repo.addConfig('commit.gpgsign', 'false'); tmpDir = await tmp.dir({ unsafeCleanup: true }); - setAdminConfig({ localDir: tmpDir.path }); + setGlobalConfig({ localDir: tmpDir.path }); await git.initRepo({ url: origin.path, gitAuthorName: 'Jest', diff --git a/lib/util/git/index.ts b/lib/util/git/index.ts index c19deea75d..876274b593 100644 --- a/lib/util/git/index.ts +++ b/lib/util/git/index.ts @@ -9,7 +9,7 @@ import Git, { TaskOptions, } from 'simple-git'; import { join } from 'upath'; -import { getAdminConfig } from '../../config/admin'; +import { getGlobalConfig } from '../../config/admin'; import { configFileNames } from '../../config/app-strings'; import type { RenovateConfig } from '../../config/types'; import { @@ -185,7 +185,7 @@ export async function initRepo(args: StorageConfig): Promise { config.ignoredAuthors = []; config.additionalBranches = []; config.branchIsModified = {}; - const { localDir } = getAdminConfig(); + const { localDir } = getGlobalConfig(); git = Git(localDir); gitInitialized = false; await fetchBranchCommits(); @@ -267,7 +267,7 @@ export async function syncGit(): Promise { return; } gitInitialized = true; - const { localDir } = getAdminConfig(); + const { localDir } = getGlobalConfig(); logger.debug('Initializing git repository into ' + localDir); const gitHead = join(localDir, '.git/HEAD'); let clone = true; @@ -708,7 +708,7 @@ export async function commitFiles({ await writePrivateKey(); privateKeySet = true; } - const { localDir } = getAdminConfig(); + const { localDir } = getGlobalConfig(); await configSigningKey(localDir); try { await git.reset(ResetMode.HARD); diff --git a/lib/util/template/index.ts b/lib/util/template/index.ts index 8eb152a074..15f78df64c 100644 --- a/lib/util/template/index.ts +++ b/lib/util/template/index.ts @@ -1,6 +1,6 @@ import is from '@sindresorhus/is'; import * as handlebars from 'handlebars'; -import { getAdminConfig } from '../../config/admin'; +import { getGlobalConfig } from '../../config/admin'; import { logger } from '../../logger'; import { clone } from '../clone'; @@ -146,7 +146,7 @@ export function compile( input: CompileInput, filterFields = true ): string { - const data = { ...getAdminConfig(), ...input }; + const data = { ...getGlobalConfig(), ...input }; const filteredInput = filterFields ? getFilteredObject(data) : data; logger.trace({ template, filteredInput }, 'Compiling template'); if (filterFields) { diff --git a/lib/workers/branch/automerge.spec.ts b/lib/workers/branch/automerge.spec.ts index 0e6f62784a..d36118120f 100644 --- a/lib/workers/branch/automerge.spec.ts +++ b/lib/workers/branch/automerge.spec.ts @@ -1,5 +1,5 @@ import { defaultConfig, getName, git, platform } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; +import { setGlobalConfig } from '../../config/admin'; import type { RenovateConfig } from '../../config/types'; import { BranchStatus } from '../../types'; import { tryBranchAutomerge } from './automerge'; @@ -13,7 +13,7 @@ describe(getName(), () => { config = { ...defaultConfig, }; - setAdminConfig(); + setGlobalConfig(); }); it('returns false if not configured for automerge', async () => { config.automerge = false; @@ -63,7 +63,7 @@ describe(getName(), () => { it('returns true if automerge succeeds (dry-run)', async () => { config.automerge = true; config.automergeType = 'branch'; - setAdminConfig({ dryRun: true }); + setGlobalConfig({ dryRun: true }); platform.getBranchStatus.mockResolvedValueOnce(BranchStatus.green); expect(await tryBranchAutomerge(config)).toBe('automerged'); }); diff --git a/lib/workers/branch/automerge.ts b/lib/workers/branch/automerge.ts index 765d0c2b01..a169fdc473 100644 --- a/lib/workers/branch/automerge.ts +++ b/lib/workers/branch/automerge.ts @@ -1,4 +1,4 @@ -import { getAdminConfig } from '../../config/admin'; +import { getGlobalConfig } from '../../config/admin'; import type { RenovateConfig } from '../../config/types'; import { logger } from '../../logger'; import { platform } from '../../platform'; @@ -32,7 +32,7 @@ export async function tryBranchAutomerge( if (branchStatus === BranchStatus.green) { logger.debug(`Automerging branch`); try { - if (getAdminConfig().dryRun) { + if (getGlobalConfig().dryRun) { logger.info('DRY-RUN: Would automerge branch' + config.branchName); } else { await mergeBranch(config.branchName); diff --git a/lib/workers/branch/commit.spec.ts b/lib/workers/branch/commit.spec.ts index 3fd61b5182..900dbe5182 100644 --- a/lib/workers/branch/commit.spec.ts +++ b/lib/workers/branch/commit.spec.ts @@ -1,5 +1,5 @@ import { defaultConfig, getName, git, partial } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; +import { setGlobalConfig } from '../../config/admin'; import type { BranchConfig } from '../types'; import { commitFilesToBranch } from './commit'; @@ -21,7 +21,7 @@ describe(getName(), () => { }); jest.resetAllMocks(); git.commitFiles.mockResolvedValueOnce('abc123'); - setAdminConfig(); + setGlobalConfig(); }); it('handles empty files', async () => { await commitFilesToBranch(config); @@ -37,7 +37,7 @@ describe(getName(), () => { expect(git.commitFiles.mock.calls).toMatchSnapshot(); }); it('dry runs', async () => { - setAdminConfig({ dryRun: true }); + setGlobalConfig({ dryRun: true }); config.updatedPackageFiles.push({ name: 'package.json', contents: 'some contents', diff --git a/lib/workers/branch/commit.ts b/lib/workers/branch/commit.ts index 4eb1b36828..39f23a7699 100644 --- a/lib/workers/branch/commit.ts +++ b/lib/workers/branch/commit.ts @@ -1,6 +1,6 @@ import is from '@sindresorhus/is'; import minimatch from 'minimatch'; -import { getAdminConfig } from '../../config/admin'; +import { getGlobalConfig } from '../../config/admin'; import { CONFIG_SECRETS_EXPOSED } from '../../constants/error-messages'; import { logger } from '../../logger'; import { commitFiles } from '../../util/git'; @@ -32,7 +32,7 @@ export function commitFilesToBranch( const fileLength = [...new Set(updatedFiles.map((file) => file.name))].length; logger.debug(`${fileLength} file(s) to commit`); // istanbul ignore if - if (getAdminConfig().dryRun) { + if (getGlobalConfig().dryRun) { logger.info('DRY-RUN: Would commit files to branch ' + config.branchName); return null; } diff --git a/lib/workers/branch/execute-post-upgrade-commands.ts b/lib/workers/branch/execute-post-upgrade-commands.ts index 9e67efc305..82fc2baf06 100644 --- a/lib/workers/branch/execute-post-upgrade-commands.ts +++ b/lib/workers/branch/execute-post-upgrade-commands.ts @@ -1,6 +1,6 @@ import is from '@sindresorhus/is'; import minimatch from 'minimatch'; -import { getAdminConfig } from '../../config/admin'; +import { getGlobalConfig } from '../../config/admin'; import { addMeta, logger } from '../../logger'; import type { ArtifactError } from '../../manager/types'; import { exec } from '../../util/exec'; @@ -23,7 +23,7 @@ export async function postUpgradeCommandsExecutor( let updatedArtifacts = [...(config.updatedArtifacts || [])]; const artifactErrors = [...(config.artifactErrors || [])]; const { allowedPostUpgradeCommands, allowPostUpgradeCommandTemplating } = - getAdminConfig(); + getGlobalConfig(); for (const upgrade of filteredUpgradeCommands) { addMeta({ dep: upgrade.depName }); @@ -62,7 +62,7 @@ export async function postUpgradeCommandsExecutor( logger.debug({ cmd: compiledCmd }, 'Executing post-upgrade task'); const execResult = await exec(compiledCmd, { - cwd: getAdminConfig().localDir, + cwd: getGlobalConfig().localDir, }); logger.debug( @@ -149,7 +149,7 @@ export async function postUpgradeCommandsExecutor( export default async function executePostUpgradeCommands( config: BranchConfig ): Promise { - const { allowedPostUpgradeCommands } = getAdminConfig(); + const { allowedPostUpgradeCommands } = getGlobalConfig(); const hasChangedFiles = config.updatedPackageFiles?.length > 0 || diff --git a/lib/workers/branch/handle-existing.ts b/lib/workers/branch/handle-existing.ts index 349506fa13..853e360fed 100644 --- a/lib/workers/branch/handle-existing.ts +++ b/lib/workers/branch/handle-existing.ts @@ -1,4 +1,4 @@ -import { getAdminConfig } from '../../config/admin'; +import { getGlobalConfig } from '../../config/admin'; import { logger } from '../../logger'; import { Pr, platform } from '../../platform'; import { PrState } from '../../types'; @@ -19,7 +19,7 @@ export async function handlepr(config: BranchConfig, pr: Pr): Promise { '\n\nIf this PR was closed by mistake or you changed your mind, you can simply rename this PR and you will soon get a fresh replacement PR opened.'; if (!config.suppressNotifications.includes('prIgnoreNotification')) { const ignoreTopic = `Renovate Ignore Notification`; - if (getAdminConfig().dryRun) { + if (getGlobalConfig().dryRun) { logger.info( `DRY-RUN: Would ensure closed PR comment in PR #${pr.number}` ); @@ -32,7 +32,7 @@ export async function handlepr(config: BranchConfig, pr: Pr): Promise { } } if (branchExists(config.branchName)) { - if (getAdminConfig().dryRun) { + if (getGlobalConfig().dryRun) { logger.info('DRY-RUN: Would delete branch ' + config.branchName); } else { await deleteBranch(config.branchName); diff --git a/lib/workers/branch/index.spec.ts b/lib/workers/branch/index.spec.ts index 09f14c07dc..c7bdc2ed28 100644 --- a/lib/workers/branch/index.spec.ts +++ b/lib/workers/branch/index.spec.ts @@ -6,8 +6,8 @@ import { mocked, platform, } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; -import type { RepoAdminConfig } from '../../config/types'; +import { setGlobalConfig } from '../../config/admin'; +import type { RepoGlobalConfig } from '../../config/types'; import { MANAGER_LOCKFILE_ERROR, REPOSITORY_CHANGED, @@ -66,7 +66,7 @@ const sanitize = mocked(_sanitize); const fs = mocked(_fs); const limits = mocked(_limits); -const adminConfig: RepoAdminConfig = { localDir: '', cacheDir: '' }; +const adminConfig: RepoGlobalConfig = { localDir: '', cacheDir: '' }; describe(getName(), () => { describe('processBranch', () => { @@ -99,7 +99,7 @@ describe(getName(), () => { body: '', }, }); - setAdminConfig(adminConfig); + setGlobalConfig(adminConfig); sanitize.sanitize.mockImplementation((input) => input); }); afterEach(() => { @@ -107,7 +107,7 @@ describe(getName(), () => { platform.ensureCommentRemoval.mockClear(); commit.commitFilesToBranch.mockClear(); jest.resetAllMocks(); - setAdminConfig(); + setGlobalConfig(); }); it('skips branch if not scheduled and branch does not exist', async () => { schedule.isScheduledNow.mockReturnValueOnce(false); @@ -433,7 +433,7 @@ describe(getName(), () => { git.branchExists.mockReturnValue(true); commit.commitFilesToBranch.mockResolvedValueOnce(null); automerge.tryBranchAutomerge.mockResolvedValueOnce('automerged'); - setAdminConfig({ ...adminConfig, dryRun: true }); + setGlobalConfig({ ...adminConfig, dryRun: true }); await branchWorker.processBranch(config); expect(automerge.tryBranchAutomerge).toHaveBeenCalledTimes(1); expect(prWorker.ensurePr).toHaveBeenCalledTimes(0); @@ -738,7 +738,7 @@ describe(getName(), () => { checkExisting.prAlreadyExisted.mockResolvedValueOnce({ state: PrState.Closed, } as Pr); - setAdminConfig({ ...adminConfig, dryRun: true }); + setGlobalConfig({ ...adminConfig, dryRun: true }); // FIXME: explicit assert condition expect(await branchWorker.processBranch(config)).toMatchSnapshot(); }); @@ -749,7 +749,7 @@ describe(getName(), () => { state: PrState.Open, } as Pr); git.isBranchModified.mockResolvedValueOnce(true); - setAdminConfig({ ...adminConfig, dryRun: true }); + setGlobalConfig({ ...adminConfig, dryRun: true }); // FIXME: explicit assert condition expect(await branchWorker.processBranch(config)).toMatchSnapshot(); }); @@ -772,7 +772,7 @@ describe(getName(), () => { git.isBranchModified.mockResolvedValueOnce(true); schedule.isScheduledNow.mockReturnValueOnce(false); commit.commitFilesToBranch.mockResolvedValueOnce(null); - setAdminConfig({ ...adminConfig, dryRun: true }); + setGlobalConfig({ ...adminConfig, dryRun: true }); // FIXME: explicit assert condition expect( await branchWorker.processBranch({ @@ -805,7 +805,7 @@ describe(getName(), () => { pr: {}, } as EnsurePrResult); commit.commitFilesToBranch.mockResolvedValueOnce(null); - setAdminConfig({ ...adminConfig, dryRun: true }); + setGlobalConfig({ ...adminConfig, dryRun: true }); // FIXME: explicit assert condition expect( await branchWorker.processBranch({ @@ -881,7 +881,7 @@ describe(getName(), () => { schedule.isScheduledNow.mockReturnValueOnce(false); commit.commitFilesToBranch.mockResolvedValueOnce(null); - setAdminConfig({ + setGlobalConfig({ ...adminConfig, allowedPostUpgradeCommands: ['^echo {{{versioning}}}$'], allowPostUpgradeCommandTemplating: true, @@ -959,7 +959,7 @@ describe(getName(), () => { schedule.isScheduledNow.mockReturnValueOnce(false); commit.commitFilesToBranch.mockResolvedValueOnce(null); - setAdminConfig({ + setGlobalConfig({ ...adminConfig, allowedPostUpgradeCommands: ['^exit 1$'], allowPostUpgradeCommandTemplating: true, @@ -1028,7 +1028,7 @@ describe(getName(), () => { schedule.isScheduledNow.mockReturnValueOnce(false); commit.commitFilesToBranch.mockResolvedValueOnce(null); - setAdminConfig({ + setGlobalConfig({ ...adminConfig, allowedPostUpgradeCommands: ['^echo {{{versioning}}}$'], allowPostUpgradeCommandTemplating: false, @@ -1109,7 +1109,7 @@ describe(getName(), () => { schedule.isScheduledNow.mockReturnValueOnce(false); commit.commitFilesToBranch.mockResolvedValueOnce(null); - setAdminConfig({ + setGlobalConfig({ ...adminConfig, allowedPostUpgradeCommands: ['^echo {{{depName}}}$'], allowPostUpgradeCommandTemplating: true, @@ -1244,7 +1244,7 @@ describe(getName(), () => { schedule.isScheduledNow.mockReturnValueOnce(false); commit.commitFilesToBranch.mockResolvedValueOnce(null); - setAdminConfig({ + setGlobalConfig({ ...adminConfig, allowedPostUpgradeCommands: ['^echo hardcoded-string$'], allowPostUpgradeCommandTemplating: true, diff --git a/lib/workers/branch/index.ts b/lib/workers/branch/index.ts index 5a871a46d6..939d82ca39 100644 --- a/lib/workers/branch/index.ts +++ b/lib/workers/branch/index.ts @@ -1,5 +1,5 @@ import { DateTime } from 'luxon'; -import { getAdminConfig } from '../../config/admin'; +import { getGlobalConfig } from '../../config/admin'; import type { RenovateConfig } from '../../config/types'; import { CONFIG_VALIDATION, @@ -416,7 +416,7 @@ export async function processBranch( } else if (config.updatedArtifacts?.length && branchPr) { // If there are artifacts, no errors, and an existing PR then ensure any artifacts error comment is removed // istanbul ignore if - if (getAdminConfig().dryRun) { + if (getGlobalConfig().dryRun) { logger.info( `DRY-RUN: Would ensure comment removal in PR #${branchPr.number}` ); @@ -479,7 +479,7 @@ export async function processBranch( const mergeStatus = await tryBranchAutomerge(config); logger.debug(`mergeStatus=${mergeStatus}`); if (mergeStatus === 'automerged') { - if (getAdminConfig().dryRun) { + if (getGlobalConfig().dryRun) { logger.info('DRY-RUN: Would delete branch' + config.branchName); } else { await deleteBranchSilently(config.branchName); @@ -657,7 +657,7 @@ export async function processBranch( config.suppressNotifications.includes('lockFileErrors') ) ) { - if (getAdminConfig().dryRun) { + if (getGlobalConfig().dryRun) { logger.info( `DRY-RUN: Would ensure lock file error comment in PR #${pr.number}` ); @@ -679,7 +679,7 @@ export async function processBranch( // Check if state needs setting if (existingState !== state) { logger.debug(`Updating status check state to failed`); - if (getAdminConfig().dryRun) { + if (getGlobalConfig().dryRun) { logger.info( 'DRY-RUN: Would set branch status in ' + config.branchName ); diff --git a/lib/workers/branch/lock-files/index.spec.ts b/lib/workers/branch/lock-files/index.spec.ts index 947caf80d6..fd57f3255b 100644 --- a/lib/workers/branch/lock-files/index.spec.ts +++ b/lib/workers/branch/lock-files/index.spec.ts @@ -1,5 +1,5 @@ import { getName, git, mocked } from '../../../../test/util'; -import { setAdminConfig } from '../../../config/admin'; +import { setGlobalConfig } from '../../../config/admin'; import { getConfig } from '../../../config/defaults'; import * as _lockFiles from '../../../manager/npm/post-update'; import * as _lerna from '../../../manager/npm/post-update/lerna'; @@ -31,7 +31,7 @@ const { writeUpdatedPackageFiles, getAdditionalFiles } = lockFiles; describe(getName(), () => { describe('writeUpdatedPackageFiles', () => { beforeEach(() => { - setAdminConfig({ + setGlobalConfig({ localDir: 'some-tmp-dir', }); fs.outputFile = jest.fn(); @@ -70,7 +70,7 @@ describe(getName(), () => { }); describe('getAdditionalFiles', () => { beforeEach(() => { - setAdminConfig({ + setGlobalConfig({ localDir: 'some-tmp-dir', }); git.getFile.mockResolvedValueOnce('some lock file contents'); diff --git a/lib/workers/branch/reuse.ts b/lib/workers/branch/reuse.ts index 7c2718c48f..0e4ab690d3 100644 --- a/lib/workers/branch/reuse.ts +++ b/lib/workers/branch/reuse.ts @@ -1,4 +1,4 @@ -import { getAdminConfig } from '../../config/admin'; +import { getGlobalConfig } from '../../config/admin'; import type { RenovateConfig } from '../../config/types'; import { logger } from '../../logger'; import { platform } from '../../platform'; @@ -35,7 +35,7 @@ export async function shouldReuseExistingBranch( if (pr.labels?.includes(config.rebaseLabel)) { logger.debug(`Manual rebase requested via PR labels for #${pr.number}`); // istanbul ignore if - if (getAdminConfig().dryRun) { + if (getGlobalConfig().dryRun) { logger.info( `DRY-RUN: Would delete label ${config.rebaseLabel} from #${pr.number}` ); diff --git a/lib/workers/pr/automerge.ts b/lib/workers/pr/automerge.ts index cb4f84764a..038fc5f2b6 100644 --- a/lib/workers/pr/automerge.ts +++ b/lib/workers/pr/automerge.ts @@ -1,4 +1,4 @@ -import { getAdminConfig } from '../../config/admin'; +import { getGlobalConfig } from '../../config/admin'; import { logger } from '../../logger'; import { Pr, platform } from '../../platform'; import { BranchStatus } from '../../types'; @@ -75,7 +75,7 @@ export async function checkAutoMerge( if (automergeType === 'pr-comment') { logger.debug(`Applying automerge comment: ${automergeComment}`); // istanbul ignore if - if (getAdminConfig().dryRun) { + if (getGlobalConfig().dryRun) { logger.info( `DRY-RUN: Would add PR automerge comment to PR #${pr.number}` ); @@ -99,7 +99,7 @@ export async function checkAutoMerge( } // Let's merge this // istanbul ignore if - if (getAdminConfig().dryRun) { + if (getGlobalConfig().dryRun) { logger.info( `DRY-RUN: Would merge PR #${pr.number} with strategy "${automergeStrategy}"` ); diff --git a/lib/workers/pr/index.ts b/lib/workers/pr/index.ts index 20f5e9971a..d268543e19 100644 --- a/lib/workers/pr/index.ts +++ b/lib/workers/pr/index.ts @@ -1,4 +1,4 @@ -import { getAdminConfig } from '../../config/admin'; +import { getGlobalConfig } from '../../config/admin'; import type { RenovateConfig } from '../../config/types'; import { PLATFORM_INTEGRATION_UNAUTHORIZED, @@ -67,7 +67,7 @@ export async function addAssigneesReviewers( } if (assignees.length > 0) { // istanbul ignore if - if (getAdminConfig().dryRun) { + if (getGlobalConfig().dryRun) { logger.info(`DRY-RUN: Would add assignees to PR #${pr.number}`); } else { await platform.addAssignees(pr.number, assignees); @@ -96,7 +96,7 @@ export async function addAssigneesReviewers( } if (reviewers.length > 0) { // istanbul ignore if - if (getAdminConfig().dryRun) { + if (getGlobalConfig().dryRun) { logger.info(`DRY-RUN: Would add reviewers to PR #${pr.number}`); } else { await platform.addReviewers(pr.number, reviewers); @@ -383,7 +383,7 @@ export async function ensurePr( ); } // istanbul ignore if - if (getAdminConfig().dryRun) { + if (getGlobalConfig().dryRun) { logger.info(`DRY-RUN: Would update PR #${existingPr.number}`); } else { await platform.updatePr({ @@ -406,7 +406,7 @@ export async function ensurePr( let pr: Pr; try { // istanbul ignore if - if (getAdminConfig().dryRun) { + if (getGlobalConfig().dryRun) { logger.info('DRY-RUN: Would create PR: ' + prTitle); pr = { number: 0, displayNumber: 'Dry run PR' } as never; } else { @@ -449,7 +449,7 @@ export async function ensurePr( { branch: branchName }, 'Deleting branch due to server error' ); - if (getAdminConfig().dryRun) { + if (getGlobalConfig().dryRun) { logger.info('DRY-RUN: Would delete branch: ' + config.branchName); } else { await deleteBranch(branchName); @@ -470,7 +470,7 @@ export async function ensurePr( content = platform.massageMarkdown(content); logger.debug('Adding branch automerge failure message to PR'); // istanbul ignore if - if (getAdminConfig().dryRun) { + if (getGlobalConfig().dryRun) { logger.info(`DRY-RUN: Would add comment to PR #${pr.number}`); } else { await platform.ensureComment({ diff --git a/lib/workers/repository/dependency-dashboard.spec.ts b/lib/workers/repository/dependency-dashboard.spec.ts index dfed70fab7..1f8648494a 100644 --- a/lib/workers/repository/dependency-dashboard.spec.ts +++ b/lib/workers/repository/dependency-dashboard.spec.ts @@ -8,7 +8,7 @@ import { logger, platform, } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; +import { setGlobalConfig } from '../../config/admin'; import { PLATFORM_TYPE_GITHUB } from '../../constants/platforms'; import type { Platform } from '../../platform'; import { BranchConfig, BranchResult, BranchUpgradeConfig } from '../types'; @@ -33,7 +33,7 @@ async function dryRun( ensureIssueCalls = 0 ) { jest.clearAllMocks(); - setAdminConfig({ dryRun: true }); + setGlobalConfig({ dryRun: true }); await dependencyDashboard.ensureDependencyDashboard(config, branches); expect(platform.ensureIssueClosing).toHaveBeenCalledTimes( ensureIssueClosingCalls @@ -61,7 +61,7 @@ describe(getName(), () => { describe('ensureDependencyDashboard()', () => { beforeEach(() => { - setAdminConfig(); + setGlobalConfig(); }); it('do nothing if dependencyDashboard is disabled', async () => { const branches: BranchConfig[] = []; diff --git a/lib/workers/repository/dependency-dashboard.ts b/lib/workers/repository/dependency-dashboard.ts index 7b4fa5d41c..11509ba14b 100644 --- a/lib/workers/repository/dependency-dashboard.ts +++ b/lib/workers/repository/dependency-dashboard.ts @@ -1,6 +1,6 @@ import is from '@sindresorhus/is'; import { nameFromLevel } from 'bunyan'; -import { getAdminConfig } from '../../config/admin'; +import { getGlobalConfig } from '../../config/admin'; import type { RenovateConfig } from '../../config/types'; import { getProblems, logger } from '../../logger'; import { platform } from '../../platform'; @@ -125,7 +125,7 @@ export async function ensureDependencyDashboard( is.nonEmptyArray(branches) && branches.some((branch) => branch.result !== BranchResult.Automerged); if (config.dependencyDashboardAutoclose && !hasBranches) { - if (getAdminConfig().dryRun) { + if (getGlobalConfig().dryRun) { logger.info( 'DRY-RUN: Would close Dependency Dashboard ' + config.dependencyDashboardTitle @@ -338,7 +338,7 @@ export async function ensureDependencyDashboard( } } - if (getAdminConfig().dryRun) { + if (getGlobalConfig().dryRun) { logger.info( 'DRY-RUN: Would ensure Dependency Dashboard ' + config.dependencyDashboardTitle diff --git a/lib/workers/repository/error-config.spec.ts b/lib/workers/repository/error-config.spec.ts index 5e7f6b8475..d31835beba 100644 --- a/lib/workers/repository/error-config.spec.ts +++ b/lib/workers/repository/error-config.spec.ts @@ -5,7 +5,7 @@ import { getName, platform, } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; +import { setGlobalConfig } from '../../config/admin'; import { CONFIG_VALIDATION } from '../../constants/error-messages'; import { Pr } from '../../platform'; import { PrState } from '../../types'; @@ -22,7 +22,7 @@ beforeEach(() => { describe(getName(), () => { describe('raiseConfigWarningIssue()', () => { beforeEach(() => { - setAdminConfig(); + setGlobalConfig(); }); it('creates issues', async () => { const error = new Error(CONFIG_VALIDATION); @@ -37,7 +37,7 @@ describe(getName(), () => { error.validationSource = 'package.json'; error.validationMessage = 'some-message'; platform.ensureIssue.mockResolvedValueOnce('created'); - setAdminConfig({ dryRun: true }); + setGlobalConfig({ dryRun: true }); const res = await raiseConfigWarningIssue(config, error); expect(res).toBeUndefined(); }); @@ -62,7 +62,7 @@ describe(getName(), () => { number: 1, state: PrState.Open, }); - setAdminConfig({ dryRun: true }); + setGlobalConfig({ dryRun: true }); const res = await raiseConfigWarningIssue(config, error); expect(res).toBeUndefined(); }); diff --git a/lib/workers/repository/error-config.ts b/lib/workers/repository/error-config.ts index 8b12091fb1..8bdc32b2e8 100644 --- a/lib/workers/repository/error-config.ts +++ b/lib/workers/repository/error-config.ts @@ -1,4 +1,4 @@ -import { getAdminConfig } from '../../config/admin'; +import { getGlobalConfig } from '../../config/admin'; import type { RenovateConfig } from '../../config/types'; import { logger } from '../../logger'; import { platform } from '../../platform'; @@ -22,7 +22,7 @@ export async function raiseConfigWarningIssue( logger.debug('Updating onboarding PR with config error notice'); body = `## Action Required: Fix Renovate Configuration\n\n${body}`; body += `\n\nOnce you have resolved this problem (in this onboarding branch), Renovate will return to providing you with a preview of your repository's configuration.`; - if (getAdminConfig().dryRun) { + if (getGlobalConfig().dryRun) { logger.info(`DRY-RUN: Would update PR #${pr.number}`); } else { try { @@ -35,7 +35,7 @@ export async function raiseConfigWarningIssue( logger.warn({ err }, 'Error updating onboarding PR'); } } - } else if (getAdminConfig().dryRun) { + } else if (getGlobalConfig().dryRun) { logger.info('DRY-RUN: Would ensure config error issue'); } else { const once = false; diff --git a/lib/workers/repository/finalise/prune.spec.ts b/lib/workers/repository/finalise/prune.spec.ts index eac6395691..b16f83f3af 100644 --- a/lib/workers/repository/finalise/prune.spec.ts +++ b/lib/workers/repository/finalise/prune.spec.ts @@ -5,7 +5,7 @@ import { git, platform, } from '../../../../test/util'; -import { setAdminConfig } from '../../../config/admin'; +import { setGlobalConfig } from '../../../config/admin'; import { PLATFORM_TYPE_GITHUB } from '../../../constants/platforms'; import * as cleanup from './prune'; @@ -23,7 +23,7 @@ beforeEach(() => { describe(getName(), () => { describe('pruneStaleBranches()', () => { beforeEach(() => { - setAdminConfig(); + setGlobalConfig(); }); it('returns if no branchList', async () => { delete config.branchList; @@ -70,7 +70,7 @@ describe(getName(), () => { }); it('does nothing on dryRun', async () => { config.branchList = ['renovate/a', 'renovate/b']; - setAdminConfig({ dryRun: true }); + setGlobalConfig({ dryRun: true }); git.getBranchList.mockReturnValueOnce( config.branchList.concat(['renovate/c']) ); @@ -110,7 +110,7 @@ describe(getName(), () => { }); it('skips comment if dry run', async () => { config.branchList = ['renovate/a', 'renovate/b']; - setAdminConfig({ dryRun: true }); + setGlobalConfig({ dryRun: true }); git.getBranchList.mockReturnValueOnce( config.branchList.concat(['renovate/c']) ); @@ -125,7 +125,7 @@ describe(getName(), () => { }); it('dry run delete branch no PR', async () => { config.branchList = ['renovate/a', 'renovate/b']; - setAdminConfig({ dryRun: true }); + setGlobalConfig({ dryRun: true }); git.getBranchList.mockReturnValueOnce( config.branchList.concat(['renovate/c']) ); diff --git a/lib/workers/repository/finalise/prune.ts b/lib/workers/repository/finalise/prune.ts index 921cad4cdc..0eacf8e8e2 100644 --- a/lib/workers/repository/finalise/prune.ts +++ b/lib/workers/repository/finalise/prune.ts @@ -1,4 +1,4 @@ -import { getAdminConfig } from '../../../config/admin'; +import { getGlobalConfig } from '../../../config/admin'; import type { RenovateConfig } from '../../../config/types'; import { REPOSITORY_CHANGED } from '../../../constants/error-messages'; import { logger } from '../../../logger'; @@ -31,7 +31,7 @@ async function cleanUpBranches( { prNo: pr.number, prTitle: pr.title }, 'Branch is modified - skipping PR autoclosing' ); - if (getAdminConfig().dryRun) { + if (getGlobalConfig().dryRun) { logger.info(`DRY-RUN: Would add Autoclosing Skipped comment to PR`); } else { await platform.ensureComment({ @@ -41,7 +41,7 @@ async function cleanUpBranches( 'This PR has been flagged for autoclosing, however it is being skipped due to the branch being already modified. Please close/delete it manually or report a bug if you think this is in error.', }); } - } else if (getAdminConfig().dryRun) { + } else if (getGlobalConfig().dryRun) { logger.info( { prNo: pr.number, prTitle: pr.title }, `DRY-RUN: Would autoclose PR` @@ -62,7 +62,7 @@ async function cleanUpBranches( }); await deleteBranch(branchName); } - } else if (getAdminConfig().dryRun) { + } else if (getGlobalConfig().dryRun) { logger.info(`DRY-RUN: Would delete orphan branch ${branchName}`); } else { logger.info({ branch: branchName }, `Deleting orphan branch`); diff --git a/lib/workers/repository/index.spec.ts b/lib/workers/repository/index.spec.ts index e16e5dd4df..eeaf6ed5ae 100644 --- a/lib/workers/repository/index.spec.ts +++ b/lib/workers/repository/index.spec.ts @@ -1,7 +1,7 @@ import { mock } from 'jest-mock-extended'; import { RenovateConfig, getConfig, getName, mocked } from '../../../test/util'; -import { setAdminConfig } from '../../config/admin'; +import { setGlobalConfig } from '../../config/admin'; import * as _process from './process'; import { ExtractResult } from './process/extract-update'; import { renovateRepository } from '.'; @@ -18,7 +18,7 @@ describe(getName(), () => { let config: RenovateConfig; beforeEach(() => { config = getConfig(); - setAdminConfig({ localDir: '' }); + setGlobalConfig({ localDir: '' }); }); it('runs', async () => { process.extractDependencies.mockResolvedValue(mock()); diff --git a/lib/workers/repository/index.ts b/lib/workers/repository/index.ts index 222e262be9..50366cc63e 100644 --- a/lib/workers/repository/index.ts +++ b/lib/workers/repository/index.ts @@ -1,5 +1,5 @@ import fs from 'fs-extra'; -import { getAdminConfig, setAdminConfig } from '../../config/admin'; +import { getGlobalConfig, setGlobalConfig } from '../../config/admin'; import type { RenovateConfig } from '../../config/types'; import { logger, setMeta } from '../../logger'; import { removeDanglingContainers } from '../../util/exec/docker'; @@ -30,14 +30,14 @@ export async function renovateRepository( canRetry = true ): Promise { splitInit(); - let config = setAdminConfig(repoConfig); + let config = setGlobalConfig(repoConfig); await removeDanglingContainers(); setMeta({ repository: config.repository }); logger.info({ renovateVersion }, 'Repository started'); logger.trace({ config }); let repoResult: ProcessResult; queue.clear(); - const { localDir } = getAdminConfig(); + const { localDir } = getGlobalConfig(); try { await fs.ensureDir(localDir); logger.debug('Using localDir: ' + localDir); diff --git a/lib/workers/repository/init/cache.spec.ts b/lib/workers/repository/init/cache.spec.ts index 52af4a3f35..6ade2a365b 100644 --- a/lib/workers/repository/init/cache.spec.ts +++ b/lib/workers/repository/init/cache.spec.ts @@ -1,5 +1,5 @@ import { RenovateConfig, getConfig, getName } from '../../../../test/util'; -import { setAdminConfig } from '../../../config/admin'; +import { setGlobalConfig } from '../../../config/admin'; import { initializeCaches } from './cache'; describe(getName(), () => { @@ -7,7 +7,7 @@ describe(getName(), () => { let config: RenovateConfig; beforeEach(() => { config = { ...getConfig() }; - setAdminConfig({ cacheDir: '' }); + setGlobalConfig({ cacheDir: '' }); }); it('initializes', async () => { expect(await initializeCaches(config)).toBeUndefined(); diff --git a/lib/workers/repository/init/index.spec.ts b/lib/workers/repository/init/index.spec.ts index 80b97baa5e..76b039ad3b 100644 --- a/lib/workers/repository/init/index.spec.ts +++ b/lib/workers/repository/init/index.spec.ts @@ -1,5 +1,5 @@ import { getName, logger, mocked } from '../../../../test/util'; -import { setAdminConfig } from '../../../config/admin'; +import { setGlobalConfig } from '../../../config/admin'; import * as _secrets from '../../../config/secrets'; import * as _onboarding from '../onboarding/branch'; import * as _apis from './apis'; @@ -24,10 +24,10 @@ const secrets = mocked(_secrets); describe(getName(), () => { beforeEach(() => { - setAdminConfig({ localDir: '', cacheDir: '' }); + setGlobalConfig({ localDir: '', cacheDir: '' }); }); afterEach(() => { - setAdminConfig(); + setGlobalConfig(); }); describe('initRepo', () => { diff --git a/lib/workers/repository/onboarding/branch/create.ts b/lib/workers/repository/onboarding/branch/create.ts index c819f09bec..9523c5bbb4 100644 --- a/lib/workers/repository/onboarding/branch/create.ts +++ b/lib/workers/repository/onboarding/branch/create.ts @@ -1,4 +1,4 @@ -import { getAdminConfig } from '../../../../config/admin'; +import { getGlobalConfig } from '../../../../config/admin'; import { configFileNames } from '../../../../config/app-strings'; import type { RenovateConfig } from '../../../../config/types'; import { logger } from '../../../../logger'; @@ -26,7 +26,7 @@ export async function createOnboardingBranch( const commitMessage = commitMessageFactory.create(); // istanbul ignore if - if (getAdminConfig().dryRun) { + if (getGlobalConfig().dryRun) { logger.info('DRY-RUN: Would commit files to onboarding branch'); return null; } diff --git a/lib/workers/repository/onboarding/branch/index.ts b/lib/workers/repository/onboarding/branch/index.ts index c38584c1f2..7439d3a9c7 100644 --- a/lib/workers/repository/onboarding/branch/index.ts +++ b/lib/workers/repository/onboarding/branch/index.ts @@ -1,5 +1,5 @@ import { mergeChildConfig } from '../../../../config'; -import { getAdminConfig } from '../../../../config/admin'; +import { getGlobalConfig } from '../../../../config/admin'; import type { RenovateConfig } from '../../../../config/types'; import { REPOSITORY_FORKED, @@ -66,7 +66,7 @@ export async function checkOnboardingBranch( ); } } - if (!getAdminConfig().dryRun) { + if (!getGlobalConfig().dryRun) { await checkoutBranch(onboardingBranch); } const branchList = [onboardingBranch]; diff --git a/lib/workers/repository/onboarding/branch/rebase.ts b/lib/workers/repository/onboarding/branch/rebase.ts index 82cd7d93fd..aaf9ccca91 100644 --- a/lib/workers/repository/onboarding/branch/rebase.ts +++ b/lib/workers/repository/onboarding/branch/rebase.ts @@ -1,4 +1,4 @@ -import { getAdminConfig } from '../../../../config/admin'; +import { getGlobalConfig } from '../../../../config/admin'; import { configFileNames } from '../../../../config/app-strings'; import type { RenovateConfig } from '../../../../config/types'; import { logger } from '../../../../logger'; @@ -43,7 +43,7 @@ export async function rebaseOnboardingBranch( const commitMessage = commitMessageFactory.create(); // istanbul ignore if - if (getAdminConfig().dryRun) { + if (getGlobalConfig().dryRun) { logger.info('DRY-RUN: Would rebase files in onboarding branch'); return null; } diff --git a/lib/workers/repository/onboarding/pr/index.spec.ts b/lib/workers/repository/onboarding/pr/index.spec.ts index 52060ab572..20c9cfad40 100644 --- a/lib/workers/repository/onboarding/pr/index.spec.ts +++ b/lib/workers/repository/onboarding/pr/index.spec.ts @@ -6,7 +6,7 @@ import { partial, platform, } from '../../../../../test/util'; -import { setAdminConfig } from '../../../../config/admin'; +import { setGlobalConfig } from '../../../../config/admin'; import { logger } from '../../../../logger'; import type { PackageFile } from '../../../../manager/types'; import { Pr } from '../../../../platform'; @@ -32,7 +32,7 @@ describe(getName(), () => { branches = []; platform.massageMarkdown = jest.fn((input) => input); platform.createPr.mockResolvedValueOnce(partial({})); - setAdminConfig(); + setGlobalConfig(); }); let createPrBody: string; it('returns if onboarded', async () => { @@ -90,7 +90,7 @@ describe(getName(), () => { expect(platform.createPr).toHaveBeenCalledTimes(1); }); it('dryrun of updates PR when modified', async () => { - setAdminConfig({ dryRun: true }); + setGlobalConfig({ dryRun: true }); config.baseBranch = 'some-branch'; platform.getBranchPr.mockResolvedValueOnce( partial({ @@ -109,7 +109,7 @@ describe(getName(), () => { ); }); it('dryrun of creates PR', async () => { - setAdminConfig({ dryRun: true }); + setGlobalConfig({ dryRun: true }); await ensureOnboardingPr(config, packageFiles, branches); expect(logger.info).toHaveBeenCalledWith( 'DRY-RUN: Would check branch renovate/configure' diff --git a/lib/workers/repository/onboarding/pr/index.ts b/lib/workers/repository/onboarding/pr/index.ts index befbebc21c..af9e0eaabb 100644 --- a/lib/workers/repository/onboarding/pr/index.ts +++ b/lib/workers/repository/onboarding/pr/index.ts @@ -1,4 +1,4 @@ -import { getAdminConfig } from '../../../../config/admin'; +import { getGlobalConfig } from '../../../../config/admin'; import type { RenovateConfig } from '../../../../config/types'; import { logger } from '../../../../logger'; import type { PackageFile } from '../../../../manager/types'; @@ -66,7 +66,7 @@ If you need any further assistance then you can also [request help here](${confi prBody = prBody.replace('{{PACKAGE FILES}}\n', ''); } let configDesc = ''; - if (getAdminConfig().dryRun) { + if (getGlobalConfig().dryRun) { logger.info(`DRY-RUN: Would check branch ${config.onboardingBranch}`); } else if (await isBranchModified(config.onboardingBranch)) { configDesc = emojify( @@ -114,7 +114,7 @@ If you need any further assistance then you can also [request help here](${confi return; } // PR must need updating - if (getAdminConfig().dryRun) { + if (getGlobalConfig().dryRun) { logger.info('DRY-RUN: Would update onboarding PR'); } else { await platform.updatePr({ @@ -129,7 +129,7 @@ If you need any further assistance then you can also [request help here](${confi logger.debug('Creating onboarding PR'); const labels: string[] = config.addLabels ?? []; try { - if (getAdminConfig().dryRun) { + if (getGlobalConfig().dryRun) { logger.info('DRY-RUN: Would create onboarding PR'); } else { const pr = await platform.createPr({ diff --git a/lib/workers/repository/process/deprecated.ts b/lib/workers/repository/process/deprecated.ts index 054cadb949..b86a67dc97 100644 --- a/lib/workers/repository/process/deprecated.ts +++ b/lib/workers/repository/process/deprecated.ts @@ -1,4 +1,4 @@ -import { getAdminConfig } from '../../../config/admin'; +import { getGlobalConfig } from '../../../config/admin'; import type { RenovateConfig } from '../../../config/types'; import { logger } from '../../../logger'; import type { PackageFile } from '../../../manager/types'; @@ -55,7 +55,7 @@ export async function raiseDeprecationWarnings( .join(', ')}`; issueBody += `\n\nIf you don't care about this, you can close this issue and not be warned about \`${depName}\`'s deprecation again. If you would like to completely disable all future deprecation warnings then add the following to your config:\n\n\`\`\`\n"suppressNotifications": ["deprecationWarningIssues"]\n\`\`\`\n\n`; // istanbul ignore if - if (getAdminConfig().dryRun) { + if (getGlobalConfig().dryRun) { logger.info('DRY-RUN: Ensure deprecation warning issue for ' + depName); } else { const ensureOnce = true;