refactor: rename config admin functions to global

This commit is contained in:
Rhys Arkins 2021-08-16 18:00:51 +02:00
parent 750bc1656e
commit bf69924b78
101 changed files with 411 additions and 411 deletions

View file

@ -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;
}

View file

@ -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',

View file

@ -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');

View file

@ -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': '',

View file

@ -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];

View file

@ -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;

View file

@ -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;

View file

@ -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({

View file

@ -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'
);

View file

@ -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')

View file

@ -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

View file

@ -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);

View file

@ -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 () => {

View file

@ -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');

View file

@ -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);

View file

@ -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(

View file

@ -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({

View file

@ -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' },

View file

@ -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('{ }');

View file

@ -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');

View file

@ -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();

View file

@ -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<PackageFile | null> {
const { localDir } = getAdminConfig();
const { localDir } = getGlobalConfig();
const git = Git(localDir);
const gitModulesPath = upath.join(localDir, fileName);

View file

@ -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({

View file

@ -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<string | null> {
const { localDir } = getAdminConfig();
const { localDir } = getGlobalConfig();
const git = Git(localDir);
const submoduleGit = Git(upath.join(localDir, upgrade.depName));

View file

@ -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()', () => {

View file

@ -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

View file

@ -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',

View file

@ -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: [],

View file

@ -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<typeof _exec> = _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: [],

View file

@ -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<UpdateArtifactsResult[] | null> {
try {
const { localDir: projectDir } = getAdminConfig();
const { localDir: projectDir } = getGlobalConfig();
logger.debug({ updatedDeps }, 'gradle-wrapper.updateArtifacts()');
const gradlew = gradleWrapperFileName(config);
const gradlewPath = resolve(projectDir, `./${gradlew}`);

View file

@ -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 () => {

View file

@ -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, [

View file

@ -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<PackageFile[] | null> {
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));

View file

@ -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';
}

View file

@ -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<typeof _fs> = _fs as any;
const exec: jest.Mock<typeof _exec> = _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);

View file

@ -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(

View file

@ -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()', () => {

View file

@ -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'

View file

@ -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()', () => {

View file

@ -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);

View file

@ -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',

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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';
}

View file

@ -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;
}

View file

@ -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<typeof _getRandomString> =
_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);

View file

@ -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<string[]> {
const { localDir } = getAdminConfig();
const { localDir } = getGlobalConfig();
const registries =
(await getConfiguredRegistries(packageFileName, localDir)) ||
getDefaultRegistries();

View file

@ -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

View file

@ -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<PackageFile | null> {
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)

View file

@ -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<typeof _fs> = _fs as any;
const exec: jest.Mock<typeof _exec> = _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'],

View file

@ -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(

View file

@ -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/',

View file

@ -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

View file

@ -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', () => {

View file

@ -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();
}

View file

@ -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);

View file

@ -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<typeof _fs> = _fs as any;
const exec: jest.Mock<typeof _exec> = _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);

View file

@ -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
);

View file

@ -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());

View file

@ -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(() => {

View file

@ -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',

View file

@ -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'

View file

@ -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 () => {

View file

@ -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<void> {
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);

View file

@ -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);
});
});

View file

@ -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];

View file

@ -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<RepoAdminConfig>;
adminConfig?: Partial<RepoGlobalConfig>;
}
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');
});

View file

@ -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<string> {
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<RawExecArguments> {
const { docker } = opts;
const { customEnvVariables } = getAdminConfig();
const { customEnvVariables } = getGlobalConfig();
const rawOptions = getRawExecOptions(opts);
@ -129,7 +129,7 @@ export async function exec(
opts: ExecOptions = {}
): Promise<ExecResult> {
const { docker } = opts;
const { dockerChildPrefix } = getAdminConfig();
const { dockerChildPrefix } = getGlobalConfig();
const { rawCommands, rawOptions } = await prepareRawExec(cmd, opts);
const useDocker = isDocker(opts);

View file

@ -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),
});

View file

@ -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<string | Buffer> {
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<void> {
const { localDir } = getAdminConfig();
const { localDir } = getGlobalConfig();
const localFileName = join(localDir, fileName);
await fs.outputFile(localFileName, fileContent);
}
export async function deleteLocalFile(fileName: string): Promise<void> {
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<void> {
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<void> {
// istanbul ignore next
export async function ensureLocalDir(dirName: string): Promise<void> {
const { localDir } = getAdminConfig();
const { localDir } = getGlobalConfig();
const localDirName = join(localDir, dirName);
await fs.ensureDir(localDirName);
}
export async function ensureCacheDir(name: string): Promise<string> {
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<string> {
* 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<boolean> {
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<string[]> {
const { localDir } = getAdminConfig();
const { localDir } = getGlobalConfig();
const localPath = join(localDir, path);
const fileList = await fs.readdir(localPath);
return fileList;

View file

@ -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',

View file

@ -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<void> {
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<void> {
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);

View file

@ -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) {

View file

@ -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');
});

View file

@ -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);

View file

@ -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',

View file

@ -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;
}

View file

@ -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<PostUpgradeCommandsExecutionResult | null> {
const { allowedPostUpgradeCommands } = getAdminConfig();
const { allowedPostUpgradeCommands } = getGlobalConfig();
const hasChangedFiles =
config.updatedPackageFiles?.length > 0 ||

View file

@ -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<void> {
'\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<void> {
}
}
if (branchExists(config.branchName)) {
if (getAdminConfig().dryRun) {
if (getGlobalConfig().dryRun) {
logger.info('DRY-RUN: Would delete branch ' + config.branchName);
} else {
await deleteBranch(config.branchName);

View file

@ -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,

View file

@ -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
);

View file

@ -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');

View file

@ -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}`
);

View file

@ -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}"`
);

View file

@ -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({

View file

@ -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[] = [];

View file

@ -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

View file

@ -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();
});

View file

@ -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;

View file

@ -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'])
);

View file

@ -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`);

View file

@ -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<ExtractResult>());

View file

@ -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<ProcessResult> {
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);

View file

@ -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();

View file

@ -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', () => {

View file

@ -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;
}

View file

@ -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];

View file

@ -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;
}

View file

@ -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<Pr>({}));
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<Pr>({
@ -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'

View file

@ -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({

Some files were not shown because too many files have changed in this diff Show more