mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 23:16:26 +00:00
refactor: rename config admin functions to global
This commit is contained in:
parent
750bc1656e
commit
bf69924b78
101 changed files with 411 additions and 411 deletions
|
@ -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)
|
// 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',
|
'allowCustomCrateRegistries',
|
||||||
'allowPostUpgradeCommandTemplating',
|
'allowPostUpgradeCommandTemplating',
|
||||||
'allowScripts',
|
'allowScripts',
|
||||||
|
@ -21,18 +21,18 @@ const repoAdminOptions = [
|
||||||
'cacheDir',
|
'cacheDir',
|
||||||
];
|
];
|
||||||
|
|
||||||
export function setAdminConfig(
|
export function setGlobalConfig(
|
||||||
config: RenovateConfig | RepoAdminConfig = {}
|
config: RenovateConfig | RepoGlobalConfig = {}
|
||||||
): RenovateConfig {
|
): RenovateConfig {
|
||||||
adminConfig = {};
|
repoGlobalConfig = {};
|
||||||
const result = { ...config };
|
const result = { ...config };
|
||||||
for (const option of repoAdminOptions) {
|
for (const option of repoGlobalOptions) {
|
||||||
adminConfig[option] = config[option];
|
repoGlobalConfig[option] = config[option];
|
||||||
delete result[option]; // eslint-disable-line no-param-reassign
|
delete result[option]; // eslint-disable-line no-param-reassign
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAdminConfig(): RepoAdminConfig {
|
export function getGlobalConfig(): RepoGlobalConfig {
|
||||||
return adminConfig;
|
return repoGlobalConfig;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { getName, loadFixture } from '../../test/util';
|
import { getName, loadFixture } from '../../test/util';
|
||||||
import { setAdminConfig } from './admin';
|
import { setGlobalConfig } from './admin';
|
||||||
import { decryptConfig } from './decrypt';
|
import { decryptConfig } from './decrypt';
|
||||||
import type { RenovateConfig } from './types';
|
import type { RenovateConfig } from './types';
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ describe(getName(), () => {
|
||||||
let config: RenovateConfig;
|
let config: RenovateConfig;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
config = {};
|
config = {};
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
it('returns empty with no privateKey', () => {
|
it('returns empty with no privateKey', () => {
|
||||||
delete config.encrypted;
|
delete config.encrypted;
|
||||||
|
@ -25,17 +25,17 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
it('handles invalid encrypted type', () => {
|
it('handles invalid encrypted type', () => {
|
||||||
config.encrypted = 1;
|
config.encrypted = 1;
|
||||||
setAdminConfig({ privateKey });
|
setGlobalConfig({ privateKey });
|
||||||
const res = decryptConfig(config);
|
const res = decryptConfig(config);
|
||||||
expect(res.encrypted).not.toBeDefined();
|
expect(res.encrypted).not.toBeDefined();
|
||||||
});
|
});
|
||||||
it('handles invalid encrypted value', () => {
|
it('handles invalid encrypted value', () => {
|
||||||
config.encrypted = { a: 1 };
|
config.encrypted = { a: 1 };
|
||||||
setAdminConfig({ privateKey });
|
setGlobalConfig({ privateKey });
|
||||||
expect(() => decryptConfig(config)).toThrow(Error('config-validation'));
|
expect(() => decryptConfig(config)).toThrow(Error('config-validation'));
|
||||||
});
|
});
|
||||||
it('replaces npm token placeholder in npmrc', () => {
|
it('replaces npm token placeholder in npmrc', () => {
|
||||||
setAdminConfig({ privateKey });
|
setGlobalConfig({ privateKey });
|
||||||
config.npmrc =
|
config.npmrc =
|
||||||
'//registry.npmjs.org/:_authToken=${NPM_TOKEN}\n//registry.npmjs.org/:_authToken=${NPM_TOKEN}\n'; // eslint-disable-line no-template-curly-in-string
|
'//registry.npmjs.org/:_authToken=${NPM_TOKEN}\n//registry.npmjs.org/:_authToken=${NPM_TOKEN}\n'; // eslint-disable-line no-template-curly-in-string
|
||||||
config.encrypted = {
|
config.encrypted = {
|
||||||
|
@ -50,7 +50,7 @@ describe(getName(), () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('appends npm token in npmrc', () => {
|
it('appends npm token in npmrc', () => {
|
||||||
setAdminConfig({ privateKey });
|
setGlobalConfig({ privateKey });
|
||||||
config.npmrc = 'foo=bar\n'; // eslint-disable-line no-template-curly-in-string
|
config.npmrc = 'foo=bar\n'; // eslint-disable-line no-template-curly-in-string
|
||||||
config.encrypted = {
|
config.encrypted = {
|
||||||
npmToken:
|
npmToken:
|
||||||
|
@ -62,7 +62,7 @@ describe(getName(), () => {
|
||||||
expect(res.npmrc).toMatchSnapshot();
|
expect(res.npmrc).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
it('decrypts nested', () => {
|
it('decrypts nested', () => {
|
||||||
setAdminConfig({ privateKey });
|
setGlobalConfig({ privateKey });
|
||||||
config.packageFiles = [
|
config.packageFiles = [
|
||||||
{
|
{
|
||||||
packageFile: 'package.json',
|
packageFile: 'package.json',
|
||||||
|
|
|
@ -3,13 +3,13 @@ import is from '@sindresorhus/is';
|
||||||
import { logger } from '../logger';
|
import { logger } from '../logger';
|
||||||
import { maskToken } from '../util/mask';
|
import { maskToken } from '../util/mask';
|
||||||
import { add } from '../util/sanitize';
|
import { add } from '../util/sanitize';
|
||||||
import { getAdminConfig } from './admin';
|
import { getGlobalConfig } from './admin';
|
||||||
import type { RenovateConfig } from './types';
|
import type { RenovateConfig } from './types';
|
||||||
|
|
||||||
export function decryptConfig(config: RenovateConfig): RenovateConfig {
|
export function decryptConfig(config: RenovateConfig): RenovateConfig {
|
||||||
logger.trace({ config }, 'decryptConfig()');
|
logger.trace({ config }, 'decryptConfig()');
|
||||||
const decryptedConfig = { ...config };
|
const decryptedConfig = { ...config };
|
||||||
const { privateKey } = getAdminConfig();
|
const { privateKey } = getGlobalConfig();
|
||||||
for (const [key, val] of Object.entries(config)) {
|
for (const [key, val] of Object.entries(config)) {
|
||||||
if (key === 'encrypted' && is.object(val)) {
|
if (key === 'encrypted' && is.object(val)) {
|
||||||
logger.debug({ config: val }, 'Found encrypted config');
|
logger.debug({ config: val }, 'Found encrypted config');
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { getName } from '../../test/util';
|
import { getName } from '../../test/util';
|
||||||
import { PLATFORM_TYPE_GITHUB } from '../constants/platforms';
|
import { PLATFORM_TYPE_GITHUB } from '../constants/platforms';
|
||||||
import { setAdminConfig } from './admin';
|
import { setGlobalConfig } from './admin';
|
||||||
import { getConfig } from './defaults';
|
import { getConfig } from './defaults';
|
||||||
import * as configMigration from './migration';
|
import * as configMigration from './migration';
|
||||||
import type {
|
import type {
|
||||||
|
@ -707,7 +707,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('it migrates presets', () => {
|
it('it migrates presets', () => {
|
||||||
setAdminConfig({
|
setGlobalConfig({
|
||||||
migratePresets: {
|
migratePresets: {
|
||||||
'@org': 'local>org/renovate-config',
|
'@org': 'local>org/renovate-config',
|
||||||
'@org2/foo': '',
|
'@org2/foo': '',
|
||||||
|
|
|
@ -3,7 +3,7 @@ import is from '@sindresorhus/is';
|
||||||
import { dequal } from 'dequal';
|
import { dequal } from 'dequal';
|
||||||
import { logger } from '../logger';
|
import { logger } from '../logger';
|
||||||
import { clone } from '../util/clone';
|
import { clone } from '../util/clone';
|
||||||
import { getAdminConfig } from './admin';
|
import { getGlobalConfig } from './admin';
|
||||||
import { getOptions } from './options';
|
import { getOptions } from './options';
|
||||||
import { removedPresets } from './presets/common';
|
import { removedPresets } from './presets/common';
|
||||||
import type {
|
import type {
|
||||||
|
@ -56,7 +56,7 @@ export function migrateConfig(
|
||||||
'optionalDependencies',
|
'optionalDependencies',
|
||||||
'peerDependencies',
|
'peerDependencies',
|
||||||
];
|
];
|
||||||
const { migratePresets } = getAdminConfig();
|
const { migratePresets } = getGlobalConfig();
|
||||||
for (const [key, val] of Object.entries(config)) {
|
for (const [key, val] of Object.entries(config)) {
|
||||||
if (removedOptions.includes(key)) {
|
if (removedOptions.includes(key)) {
|
||||||
delete migratedConfig[key];
|
delete migratedConfig[key];
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import * as httpMock from '../../../../test/http-mock';
|
import * as httpMock from '../../../../test/http-mock';
|
||||||
import { getName } from '../../../../test/util';
|
import { getName } from '../../../../test/util';
|
||||||
import { setAdminConfig } from '../../admin';
|
import { setGlobalConfig } from '../../admin';
|
||||||
import * as npm from '.';
|
import * as npm from '.';
|
||||||
|
|
||||||
jest.mock('registry-auth-token');
|
jest.mock('registry-auth-token');
|
||||||
|
@ -9,7 +9,7 @@ jest.mock('delay');
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
delete process.env.RENOVATE_CACHE_NPM_MINUTES;
|
delete process.env.RENOVATE_CACHE_NPM_MINUTES;
|
||||||
|
|
|
@ -86,7 +86,7 @@ export interface GlobalOnlyConfig {
|
||||||
|
|
||||||
// Config options used within the repository worker, but not user configurable
|
// Config options used within the repository worker, but not user configurable
|
||||||
// The below should contain config options where admin=true
|
// The below should contain config options where admin=true
|
||||||
export interface RepoAdminConfig {
|
export interface RepoGlobalConfig {
|
||||||
allowCustomCrateRegistries?: boolean;
|
allowCustomCrateRegistries?: boolean;
|
||||||
allowPostUpgradeCommandTemplating?: boolean;
|
allowPostUpgradeCommandTemplating?: boolean;
|
||||||
allowScripts?: boolean;
|
allowScripts?: boolean;
|
||||||
|
|
|
@ -6,8 +6,8 @@ import { dirname, join } from 'upath';
|
||||||
import { getPkgReleases } from '..';
|
import { getPkgReleases } from '..';
|
||||||
import * as httpMock from '../../../test/http-mock';
|
import * as httpMock from '../../../test/http-mock';
|
||||||
import { getName, loadFixture } from '../../../test/util';
|
import { getName, loadFixture } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import type { RepoAdminConfig } from '../../config/types';
|
import type { RepoGlobalConfig } from '../../config/types';
|
||||||
import * as memCache from '../../util/cache/memory';
|
import * as memCache from '../../util/cache/memory';
|
||||||
import { RegistryFlavor, RegistryInfo } from './types';
|
import { RegistryFlavor, RegistryInfo } from './types';
|
||||||
import { id as datasource, fetchCrateRecordsPayload, getIndexSuffix } from '.';
|
import { id as datasource, fetchCrateRecordsPayload, getIndexSuffix } from '.';
|
||||||
|
@ -75,7 +75,7 @@ describe(getName(), () => {
|
||||||
|
|
||||||
describe('getReleases', () => {
|
describe('getReleases', () => {
|
||||||
let tmpDir: DirectoryResult | null;
|
let tmpDir: DirectoryResult | null;
|
||||||
let adminConfig: RepoAdminConfig;
|
let adminConfig: RepoGlobalConfig;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
tmpDir = await dir();
|
tmpDir = await dir();
|
||||||
|
@ -84,7 +84,7 @@ describe(getName(), () => {
|
||||||
localDir: join(tmpDir.path, 'local'),
|
localDir: join(tmpDir.path, 'local'),
|
||||||
cacheDir: join(tmpDir.path, 'cache'),
|
cacheDir: join(tmpDir.path, 'cache'),
|
||||||
};
|
};
|
||||||
setAdminConfig(adminConfig);
|
setGlobalConfig(adminConfig);
|
||||||
|
|
||||||
simpleGit.mockReset();
|
simpleGit.mockReset();
|
||||||
memCache.init();
|
memCache.init();
|
||||||
|
@ -93,7 +93,7 @@ describe(getName(), () => {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
fs.rmdirSync(tmpDir.path, { recursive: true });
|
fs.rmdirSync(tmpDir.path, { recursive: true });
|
||||||
tmpDir = null;
|
tmpDir = null;
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns null for missing registry url', async () => {
|
it('returns null for missing registry url', async () => {
|
||||||
|
@ -229,7 +229,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
it('clones cloudsmith private registry', async () => {
|
it('clones cloudsmith private registry', async () => {
|
||||||
const { mockClone } = setupGitMocks();
|
const { mockClone } = setupGitMocks();
|
||||||
setAdminConfig({ ...adminConfig, allowCustomCrateRegistries: true });
|
setGlobalConfig({ ...adminConfig, allowCustomCrateRegistries: true });
|
||||||
const url = 'https://dl.cloudsmith.io/basic/myorg/myrepo/cargo/index.git';
|
const url = 'https://dl.cloudsmith.io/basic/myorg/myrepo/cargo/index.git';
|
||||||
const res = await getPkgReleases({
|
const res = await getPkgReleases({
|
||||||
datasource,
|
datasource,
|
||||||
|
@ -243,7 +243,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
it('clones other private registry', async () => {
|
it('clones other private registry', async () => {
|
||||||
const { mockClone } = setupGitMocks();
|
const { mockClone } = setupGitMocks();
|
||||||
setAdminConfig({ ...adminConfig, allowCustomCrateRegistries: true });
|
setGlobalConfig({ ...adminConfig, allowCustomCrateRegistries: true });
|
||||||
const url = 'https://github.com/mcorbin/testregistry';
|
const url = 'https://github.com/mcorbin/testregistry';
|
||||||
const res = await getPkgReleases({
|
const res = await getPkgReleases({
|
||||||
datasource,
|
datasource,
|
||||||
|
@ -257,7 +257,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
it('clones once then reuses the cache', async () => {
|
it('clones once then reuses the cache', async () => {
|
||||||
const { mockClone } = setupGitMocks();
|
const { mockClone } = setupGitMocks();
|
||||||
setAdminConfig({ ...adminConfig, allowCustomCrateRegistries: true });
|
setGlobalConfig({ ...adminConfig, allowCustomCrateRegistries: true });
|
||||||
const url = 'https://github.com/mcorbin/othertestregistry';
|
const url = 'https://github.com/mcorbin/othertestregistry';
|
||||||
await getPkgReleases({
|
await getPkgReleases({
|
||||||
datasource,
|
datasource,
|
||||||
|
@ -273,7 +273,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
it('guards against race conditions while cloning', async () => {
|
it('guards against race conditions while cloning', async () => {
|
||||||
const { mockClone } = setupGitMocks(250);
|
const { mockClone } = setupGitMocks(250);
|
||||||
setAdminConfig({ ...adminConfig, allowCustomCrateRegistries: true });
|
setGlobalConfig({ ...adminConfig, allowCustomCrateRegistries: true });
|
||||||
const url = 'https://github.com/mcorbin/othertestregistry';
|
const url = 'https://github.com/mcorbin/othertestregistry';
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
|
@ -299,7 +299,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
it('returns null when git clone fails', async () => {
|
it('returns null when git clone fails', async () => {
|
||||||
setupErrorGitMock();
|
setupErrorGitMock();
|
||||||
setAdminConfig({ ...adminConfig, allowCustomCrateRegistries: true });
|
setGlobalConfig({ ...adminConfig, allowCustomCrateRegistries: true });
|
||||||
const url = 'https://github.com/mcorbin/othertestregistry';
|
const url = 'https://github.com/mcorbin/othertestregistry';
|
||||||
|
|
||||||
const result = await getPkgReleases({
|
const result = await getPkgReleases({
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import hasha from 'hasha';
|
import hasha from 'hasha';
|
||||||
import Git from 'simple-git';
|
import Git from 'simple-git';
|
||||||
import { join } from 'upath';
|
import { join } from 'upath';
|
||||||
import { getAdminConfig } from '../../config/admin';
|
import { getGlobalConfig } from '../../config/admin';
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import { ExternalHostError } from '../../types/errors/external-host-error';
|
import { ExternalHostError } from '../../types/errors/external-host-error';
|
||||||
import * as memCache from '../../util/cache/memory';
|
import * as memCache from '../../util/cache/memory';
|
||||||
|
@ -135,7 +135,7 @@ async function fetchRegistryInfo(
|
||||||
};
|
};
|
||||||
|
|
||||||
if (flavor !== RegistryFlavor.CratesIo) {
|
if (flavor !== RegistryFlavor.CratesIo) {
|
||||||
if (!getAdminConfig().allowCustomCrateRegistries) {
|
if (!getGlobalConfig().allowCustomCrateRegistries) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
'crate datasource: allowCustomCrateRegistries=true is required for registries other than crates.io, bailing out'
|
'crate datasource: allowCustomCrateRegistries=true is required for registries other than crates.io, bailing out'
|
||||||
);
|
);
|
||||||
|
|
|
@ -3,7 +3,7 @@ import _registryAuthToken from 'registry-auth-token';
|
||||||
import { getPkgReleases } from '..';
|
import { getPkgReleases } from '..';
|
||||||
import * as httpMock from '../../../test/http-mock';
|
import * as httpMock from '../../../test/http-mock';
|
||||||
import { getName } from '../../../test/util';
|
import { getName } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import { EXTERNAL_HOST_ERROR } from '../../constants/error-messages';
|
import { EXTERNAL_HOST_ERROR } from '../../constants/error-messages';
|
||||||
import * as hostRules from '../../util/host-rules';
|
import * as hostRules from '../../util/host-rules';
|
||||||
import { id as datasource, getNpmrc, resetCache, setNpmrc } from '.';
|
import { id as datasource, getNpmrc, resetCache, setNpmrc } from '.';
|
||||||
|
@ -18,7 +18,7 @@ let npmResponse: any;
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
hostRules.clear();
|
hostRules.clear();
|
||||||
resetCache();
|
resetCache();
|
||||||
setNpmrc();
|
setNpmrc();
|
||||||
|
@ -358,7 +358,7 @@ describe(getName(), () => {
|
||||||
.reply(200, npmResponse);
|
.reply(200, npmResponse);
|
||||||
process.env.REGISTRY = 'https://registry.from-env.com';
|
process.env.REGISTRY = 'https://registry.from-env.com';
|
||||||
process.env.RENOVATE_CACHE_NPM_MINUTES = '15';
|
process.env.RENOVATE_CACHE_NPM_MINUTES = '15';
|
||||||
setAdminConfig({ exposeAllEnv: true });
|
setGlobalConfig({ exposeAllEnv: true });
|
||||||
// eslint-disable-next-line no-template-curly-in-string
|
// eslint-disable-next-line no-template-curly-in-string
|
||||||
const npmrc = 'registry=${REGISTRY}';
|
const npmrc = 'registry=${REGISTRY}';
|
||||||
const res = await getPkgReleases({ datasource, depName: 'foobar', npmrc });
|
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', () => {
|
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
|
// eslint-disable-next-line no-template-curly-in-string
|
||||||
expect(() => setNpmrc('registry=${REGISTRY_MISSING}')).toThrow(
|
expect(() => setNpmrc('registry=${REGISTRY_MISSING}')).toThrow(
|
||||||
Error('env-replace')
|
Error('env-replace')
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { getName, mocked } from '../../../test/util';
|
import { getName, mocked } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import * as _sanitize from '../../util/sanitize';
|
import * as _sanitize from '../../util/sanitize';
|
||||||
import { getNpmrc, setNpmrc } from './npmrc';
|
import { getNpmrc, setNpmrc } from './npmrc';
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ const sanitize = mocked(_sanitize);
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
setNpmrc('');
|
setNpmrc('');
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sanitize _authtoken with high trust', () => {
|
it('sanitize _authtoken with high trust', () => {
|
||||||
setAdminConfig({ exposeAllEnv: true });
|
setGlobalConfig({ exposeAllEnv: true });
|
||||||
process.env.TEST_TOKEN = 'test';
|
process.env.TEST_TOKEN = 'test';
|
||||||
setNpmrc(
|
setNpmrc(
|
||||||
// eslint-disable-next-line no-template-curly-in-string
|
// eslint-disable-next-line no-template-curly-in-string
|
||||||
|
|
|
@ -3,7 +3,7 @@ import is from '@sindresorhus/is';
|
||||||
import ini from 'ini';
|
import ini from 'ini';
|
||||||
import registryAuthToken from 'registry-auth-token';
|
import registryAuthToken from 'registry-auth-token';
|
||||||
import getRegistryUrl from 'registry-auth-token/registry-url';
|
import getRegistryUrl from 'registry-auth-token/registry-url';
|
||||||
import { getAdminConfig } from '../../config/admin';
|
import { getGlobalConfig } from '../../config/admin';
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import type { OutgoingHttpHeaders } from '../../util/http/types';
|
import type { OutgoingHttpHeaders } from '../../util/http/types';
|
||||||
import { maskToken } from '../../util/mask';
|
import { maskToken } from '../../util/mask';
|
||||||
|
@ -60,7 +60,7 @@ export function setNpmrc(input?: string): void {
|
||||||
npmrcRaw = input;
|
npmrcRaw = input;
|
||||||
logger.debug('Setting npmrc');
|
logger.debug('Setting npmrc');
|
||||||
npmrc = ini.parse(input.replace(/\\n/g, '\n'));
|
npmrc = ini.parse(input.replace(/\\n/g, '\n'));
|
||||||
const { exposeAllEnv } = getAdminConfig();
|
const { exposeAllEnv } = getGlobalConfig();
|
||||||
for (const [key, val] of Object.entries(npmrc)) {
|
for (const [key, val] of Object.entries(npmrc)) {
|
||||||
if (!exposeAllEnv) {
|
if (!exposeAllEnv) {
|
||||||
sanitize(key, val);
|
sanitize(key, val);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { getName } from '../../../test/util';
|
import { getName } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import type { RepoAdminConfig } from '../../config/types';
|
import type { RepoGlobalConfig } from '../../config/types';
|
||||||
import { id as gitTagDatasource } from '../../datasource/git-tags';
|
import { id as gitTagDatasource } from '../../datasource/git-tags';
|
||||||
import { id as dockerVersioning } from '../../versioning/docker';
|
import { id as dockerVersioning } from '../../versioning/docker';
|
||||||
import { id as semverVersioning } from '../../versioning/semver';
|
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: '',
|
localDir: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -36,11 +36,11 @@ const config: ExtractConfig = {};
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
describe('extractPackageFile()', () => {
|
describe('extractPackageFile()', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
setAdminConfig(adminConfig);
|
setGlobalConfig(adminConfig);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns empty array for empty configuration file', async () => {
|
it('returns empty array for empty configuration file', async () => {
|
||||||
|
|
|
@ -2,8 +2,8 @@ import { exec as _exec } from 'child_process';
|
||||||
import { join } from 'upath';
|
import { join } from 'upath';
|
||||||
import { envMock, mockExecAll } from '../../../test/exec-util';
|
import { envMock, mockExecAll } from '../../../test/exec-util';
|
||||||
import { fs, git, mocked } from '../../../test/util';
|
import { fs, git, mocked } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import type { RepoAdminConfig } from '../../config/types';
|
import type { RepoGlobalConfig } from '../../config/types';
|
||||||
import * as _datasource from '../../datasource';
|
import * as _datasource from '../../datasource';
|
||||||
import * as docker from '../../util/exec/docker';
|
import * as docker from '../../util/exec/docker';
|
||||||
import * as _env from '../../util/exec/env';
|
import * as _env from '../../util/exec/env';
|
||||||
|
@ -26,7 +26,7 @@ jest.mock('../../../lib/util/git');
|
||||||
jest.mock('../../../lib/util/host-rules');
|
jest.mock('../../../lib/util/host-rules');
|
||||||
jest.mock('./host-rules');
|
jest.mock('./host-rules');
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoGlobalConfig = {
|
||||||
// `join` fixes Windows CI
|
// `join` fixes Windows CI
|
||||||
localDir: join('/tmp/github/some/repo'),
|
localDir: join('/tmp/github/some/repo'),
|
||||||
cacheDir: join('/tmp/cache'),
|
cacheDir: join('/tmp/cache'),
|
||||||
|
@ -52,11 +52,11 @@ describe('bundler.updateArtifacts()', () => {
|
||||||
bundlerHostRules.findAllAuthenticatable.mockReturnValue([]);
|
bundlerHostRules.findAllAuthenticatable.mockReturnValue([]);
|
||||||
docker.resetPrefetchedImages();
|
docker.resetPrefetchedImages();
|
||||||
|
|
||||||
setAdminConfig(adminConfig);
|
setGlobalConfig(adminConfig);
|
||||||
fs.ensureCacheDir.mockResolvedValue('/tmp/cache/others/gem');
|
fs.ensureCacheDir.mockResolvedValue('/tmp/cache/others/gem');
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
it('returns null by default', async () => {
|
it('returns null by default', async () => {
|
||||||
expect(
|
expect(
|
||||||
|
@ -106,7 +106,7 @@ describe('bundler.updateArtifacts()', () => {
|
||||||
expect(execSnapshots).toMatchSnapshot();
|
expect(execSnapshots).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
it('works explicit global binarySource', async () => {
|
it('works explicit global binarySource', async () => {
|
||||||
setAdminConfig({ ...adminConfig, binarySource: 'global' });
|
setGlobalConfig({ ...adminConfig, binarySource: 'global' });
|
||||||
fs.readLocalFile.mockResolvedValueOnce('Current Gemfile.lock');
|
fs.readLocalFile.mockResolvedValueOnce('Current Gemfile.lock');
|
||||||
fs.writeLocalFile.mockResolvedValueOnce(null as never);
|
fs.writeLocalFile.mockResolvedValueOnce(null as never);
|
||||||
fs.readLocalFile.mockResolvedValueOnce(null);
|
fs.readLocalFile.mockResolvedValueOnce(null);
|
||||||
|
@ -127,7 +127,7 @@ describe('bundler.updateArtifacts()', () => {
|
||||||
});
|
});
|
||||||
describe('Docker', () => {
|
describe('Docker', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
setAdminConfig({
|
setGlobalConfig({
|
||||||
...adminConfig,
|
...adminConfig,
|
||||||
binarySource: 'docker',
|
binarySource: 'docker',
|
||||||
});
|
});
|
||||||
|
@ -159,7 +159,7 @@ describe('bundler.updateArtifacts()', () => {
|
||||||
expect(execSnapshots).toMatchSnapshot();
|
expect(execSnapshots).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
it('constraints options', async () => {
|
it('constraints options', async () => {
|
||||||
setAdminConfig({ ...adminConfig, binarySource: 'docker' });
|
setGlobalConfig({ ...adminConfig, binarySource: 'docker' });
|
||||||
fs.readLocalFile.mockResolvedValueOnce('Current Gemfile.lock');
|
fs.readLocalFile.mockResolvedValueOnce('Current Gemfile.lock');
|
||||||
fs.writeLocalFile.mockResolvedValueOnce(null as never);
|
fs.writeLocalFile.mockResolvedValueOnce(null as never);
|
||||||
datasource.getPkgReleases.mockResolvedValueOnce({
|
datasource.getPkgReleases.mockResolvedValueOnce({
|
||||||
|
@ -191,7 +191,7 @@ describe('bundler.updateArtifacts()', () => {
|
||||||
expect(execSnapshots).toMatchSnapshot();
|
expect(execSnapshots).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
it('invalid constraints options', async () => {
|
it('invalid constraints options', async () => {
|
||||||
setAdminConfig({ ...adminConfig, binarySource: 'docker' });
|
setGlobalConfig({ ...adminConfig, binarySource: 'docker' });
|
||||||
fs.readLocalFile.mockResolvedValueOnce('Current Gemfile.lock');
|
fs.readLocalFile.mockResolvedValueOnce('Current Gemfile.lock');
|
||||||
fs.writeLocalFile.mockResolvedValueOnce(null as never);
|
fs.writeLocalFile.mockResolvedValueOnce(null as never);
|
||||||
datasource.getPkgReleases.mockResolvedValueOnce({
|
datasource.getPkgReleases.mockResolvedValueOnce({
|
||||||
|
@ -224,7 +224,7 @@ describe('bundler.updateArtifacts()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('injects bundler host configuration environment variables', async () => {
|
it('injects bundler host configuration environment variables', async () => {
|
||||||
setAdminConfig({ ...adminConfig, binarySource: 'docker' });
|
setGlobalConfig({ ...adminConfig, binarySource: 'docker' });
|
||||||
fs.readLocalFile.mockResolvedValueOnce('Current Gemfile.lock');
|
fs.readLocalFile.mockResolvedValueOnce('Current Gemfile.lock');
|
||||||
fs.writeLocalFile.mockResolvedValueOnce(null as never);
|
fs.writeLocalFile.mockResolvedValueOnce(null as never);
|
||||||
fs.readLocalFile.mockResolvedValueOnce('1.2.0');
|
fs.readLocalFile.mockResolvedValueOnce('1.2.0');
|
||||||
|
@ -264,7 +264,7 @@ describe('bundler.updateArtifacts()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('injects bundler host configuration as command with bundler < 2', async () => {
|
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.readLocalFile.mockResolvedValueOnce('Current Gemfile.lock');
|
||||||
fs.writeLocalFile.mockResolvedValueOnce(null as never);
|
fs.writeLocalFile.mockResolvedValueOnce(null as never);
|
||||||
fs.readLocalFile.mockResolvedValueOnce('1.2.0');
|
fs.readLocalFile.mockResolvedValueOnce('1.2.0');
|
||||||
|
@ -309,7 +309,7 @@ describe('bundler.updateArtifacts()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('injects bundler host configuration as command with bundler >= 2', async () => {
|
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.readLocalFile.mockResolvedValueOnce('Current Gemfile.lock');
|
||||||
fs.writeLocalFile.mockResolvedValueOnce(null as never);
|
fs.writeLocalFile.mockResolvedValueOnce(null as never);
|
||||||
fs.readLocalFile.mockResolvedValueOnce('1.2.0');
|
fs.readLocalFile.mockResolvedValueOnce('1.2.0');
|
||||||
|
@ -354,7 +354,7 @@ describe('bundler.updateArtifacts()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('injects bundler host configuration as command with bundler == latest', async () => {
|
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.readLocalFile.mockResolvedValueOnce('Current Gemfile.lock');
|
||||||
fs.writeLocalFile.mockResolvedValueOnce(null as never);
|
fs.writeLocalFile.mockResolvedValueOnce(null as never);
|
||||||
fs.readLocalFile.mockResolvedValueOnce('1.2.0');
|
fs.readLocalFile.mockResolvedValueOnce('1.2.0');
|
||||||
|
|
|
@ -3,8 +3,8 @@ import _fs from 'fs-extra';
|
||||||
import { join } from 'upath';
|
import { join } from 'upath';
|
||||||
import { envMock, mockExecAll } from '../../../test/exec-util';
|
import { envMock, mockExecAll } from '../../../test/exec-util';
|
||||||
import { git, mocked } from '../../../test/util';
|
import { git, mocked } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import type { RepoAdminConfig } from '../../config/types';
|
import type { RepoGlobalConfig } from '../../config/types';
|
||||||
import * as docker from '../../util/exec/docker';
|
import * as docker from '../../util/exec/docker';
|
||||||
import * as _env from '../../util/exec/env';
|
import * as _env from '../../util/exec/env';
|
||||||
import type { UpdateArtifactsConfig } from '../types';
|
import type { UpdateArtifactsConfig } from '../types';
|
||||||
|
@ -22,7 +22,7 @@ const env = mocked(_env);
|
||||||
|
|
||||||
const config: UpdateArtifactsConfig = {};
|
const config: UpdateArtifactsConfig = {};
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoGlobalConfig = {
|
||||||
// `join` fixes Windows CI
|
// `join` fixes Windows CI
|
||||||
localDir: join('/tmp/github/some/repo'),
|
localDir: join('/tmp/github/some/repo'),
|
||||||
};
|
};
|
||||||
|
@ -33,11 +33,11 @@ describe('.updateArtifacts()', () => {
|
||||||
jest.resetModules();
|
jest.resetModules();
|
||||||
|
|
||||||
env.getChildProcessEnv.mockReturnValue(envMock.basic);
|
env.getChildProcessEnv.mockReturnValue(envMock.basic);
|
||||||
setAdminConfig(adminConfig);
|
setGlobalConfig(adminConfig);
|
||||||
docker.resetPrefetchedImages();
|
docker.resetPrefetchedImages();
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
it('returns null if no Cargo.lock found', async () => {
|
it('returns null if no Cargo.lock found', async () => {
|
||||||
fs.stat.mockRejectedValue(new Error('not found!'));
|
fs.stat.mockRejectedValue(new Error('not found!'));
|
||||||
|
@ -171,7 +171,7 @@ describe('.updateArtifacts()', () => {
|
||||||
|
|
||||||
it('returns updated Cargo.lock with docker', async () => {
|
it('returns updated Cargo.lock with docker', async () => {
|
||||||
fs.stat.mockResolvedValueOnce({ name: 'Cargo.lock' } as any);
|
fs.stat.mockResolvedValueOnce({ name: 'Cargo.lock' } as any);
|
||||||
setAdminConfig({ ...adminConfig, binarySource: 'docker' });
|
setGlobalConfig({ ...adminConfig, binarySource: 'docker' });
|
||||||
git.getFile.mockResolvedValueOnce('Old Cargo.lock');
|
git.getFile.mockResolvedValueOnce('Old Cargo.lock');
|
||||||
const execSnapshots = mockExecAll(exec);
|
const execSnapshots = mockExecAll(exec);
|
||||||
fs.readFile.mockResolvedValueOnce('New Cargo.lock' as any);
|
fs.readFile.mockResolvedValueOnce('New Cargo.lock' as any);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { dir } from 'tmp-promise';
|
import { dir } from 'tmp-promise';
|
||||||
import { join } from 'upath';
|
import { join } from 'upath';
|
||||||
import { getName, loadFixture } from '../../../test/util';
|
import { getName, loadFixture } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import type { RepoAdminConfig } from '../../config/types';
|
import type { RepoGlobalConfig } from '../../config/types';
|
||||||
import { writeLocalFile } from '../../util/fs';
|
import { writeLocalFile } from '../../util/fs';
|
||||||
import type { ExtractConfig } from '../types';
|
import type { ExtractConfig } from '../types';
|
||||||
import { extractPackageFile } from './extract';
|
import { extractPackageFile } from './extract';
|
||||||
|
@ -18,7 +18,7 @@ const cargo6toml = loadFixture('Cargo.6.toml');
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
describe('extractPackageFile()', () => {
|
describe('extractPackageFile()', () => {
|
||||||
let config: ExtractConfig;
|
let config: ExtractConfig;
|
||||||
let adminConfig: RepoAdminConfig;
|
let adminConfig: RepoGlobalConfig;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
config = {};
|
config = {};
|
||||||
|
@ -28,10 +28,10 @@ describe(getName(), () => {
|
||||||
cacheDir: join(tmpDir.path, 'cache'),
|
cacheDir: join(tmpDir.path, 'cache'),
|
||||||
};
|
};
|
||||||
|
|
||||||
setAdminConfig(adminConfig);
|
setGlobalConfig(adminConfig);
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
it('returns null for invalid toml', async () => {
|
it('returns null for invalid toml', async () => {
|
||||||
expect(
|
expect(
|
||||||
|
|
|
@ -3,8 +3,8 @@ import _fs from 'fs-extra';
|
||||||
import { join } from 'upath';
|
import { join } from 'upath';
|
||||||
import { envMock, mockExecAll } from '../../../test/exec-util';
|
import { envMock, mockExecAll } from '../../../test/exec-util';
|
||||||
import { git, mocked } from '../../../test/util';
|
import { git, mocked } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import type { RepoAdminConfig } from '../../config/types';
|
import type { RepoGlobalConfig } from '../../config/types';
|
||||||
import * as _datasource from '../../datasource';
|
import * as _datasource from '../../datasource';
|
||||||
import * as _env from '../../util/exec/env';
|
import * as _env from '../../util/exec/env';
|
||||||
import type { StatusResult } from '../../util/git';
|
import type { StatusResult } from '../../util/git';
|
||||||
|
@ -27,7 +27,7 @@ delete process.env.CP_HOME_DIR;
|
||||||
|
|
||||||
const config: UpdateArtifactsConfig = {};
|
const config: UpdateArtifactsConfig = {};
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoGlobalConfig = {
|
||||||
localDir: join('/tmp/github/some/repo'),
|
localDir: join('/tmp/github/some/repo'),
|
||||||
cacheDir: join('/tmp/cache'),
|
cacheDir: join('/tmp/cache'),
|
||||||
};
|
};
|
||||||
|
@ -37,7 +37,7 @@ describe('.updateArtifacts()', () => {
|
||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
env.getChildProcessEnv.mockReturnValue(envMock.basic);
|
env.getChildProcessEnv.mockReturnValue(envMock.basic);
|
||||||
|
|
||||||
setAdminConfig(adminConfig);
|
setGlobalConfig(adminConfig);
|
||||||
|
|
||||||
datasource.getPkgReleases.mockResolvedValue({
|
datasource.getPkgReleases.mockResolvedValue({
|
||||||
releases: [
|
releases: [
|
||||||
|
@ -51,7 +51,7 @@ describe('.updateArtifacts()', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
it('returns null if no Podfile.lock found', async () => {
|
it('returns null if no Podfile.lock found', async () => {
|
||||||
const execSnapshots = mockExecAll(exec);
|
const execSnapshots = mockExecAll(exec);
|
||||||
|
@ -79,7 +79,7 @@ describe('.updateArtifacts()', () => {
|
||||||
});
|
});
|
||||||
it('returns null for invalid local directory', async () => {
|
it('returns null for invalid local directory', async () => {
|
||||||
const execSnapshots = mockExecAll(exec);
|
const execSnapshots = mockExecAll(exec);
|
||||||
setAdminConfig({
|
setGlobalConfig({
|
||||||
localDir: '',
|
localDir: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ describe('.updateArtifacts()', () => {
|
||||||
});
|
});
|
||||||
it('returns updated Podfile', async () => {
|
it('returns updated Podfile', async () => {
|
||||||
const execSnapshots = mockExecAll(exec);
|
const execSnapshots = mockExecAll(exec);
|
||||||
setAdminConfig({ ...adminConfig, binarySource: 'docker' });
|
setGlobalConfig({ ...adminConfig, binarySource: 'docker' });
|
||||||
fs.readFile.mockResolvedValueOnce('Old Podfile' as any);
|
fs.readFile.mockResolvedValueOnce('Old Podfile' as any);
|
||||||
git.getRepoStatus.mockResolvedValueOnce({
|
git.getRepoStatus.mockResolvedValueOnce({
|
||||||
modified: ['Podfile.lock'],
|
modified: ['Podfile.lock'],
|
||||||
|
@ -143,7 +143,7 @@ describe('.updateArtifacts()', () => {
|
||||||
});
|
});
|
||||||
it('returns updated Podfile and Pods files', async () => {
|
it('returns updated Podfile and Pods files', async () => {
|
||||||
const execSnapshots = mockExecAll(exec);
|
const execSnapshots = mockExecAll(exec);
|
||||||
setAdminConfig({ ...adminConfig, binarySource: 'docker' });
|
setGlobalConfig({ ...adminConfig, binarySource: 'docker' });
|
||||||
fs.readFile.mockResolvedValueOnce('Old Manifest.lock' as any);
|
fs.readFile.mockResolvedValueOnce('Old Manifest.lock' as any);
|
||||||
fs.readFile.mockResolvedValueOnce('New Podfile' as any);
|
fs.readFile.mockResolvedValueOnce('New Podfile' as any);
|
||||||
fs.readFile.mockResolvedValueOnce('Pods manifest' as any);
|
fs.readFile.mockResolvedValueOnce('Pods manifest' as any);
|
||||||
|
@ -199,7 +199,7 @@ describe('.updateArtifacts()', () => {
|
||||||
it('dynamically selects Docker image tag', async () => {
|
it('dynamically selects Docker image tag', async () => {
|
||||||
const execSnapshots = mockExecAll(exec);
|
const execSnapshots = mockExecAll(exec);
|
||||||
|
|
||||||
setAdminConfig({ ...adminConfig, binarySource: 'docker' });
|
setGlobalConfig({ ...adminConfig, binarySource: 'docker' });
|
||||||
|
|
||||||
fs.readFile.mockResolvedValueOnce('COCOAPODS: 1.2.4' as any);
|
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 () => {
|
it('falls back to the `latest` Docker image tag', async () => {
|
||||||
const execSnapshots = mockExecAll(exec);
|
const execSnapshots = mockExecAll(exec);
|
||||||
|
|
||||||
setAdminConfig({ ...adminConfig, binarySource: 'docker' });
|
setGlobalConfig({ ...adminConfig, binarySource: 'docker' });
|
||||||
|
|
||||||
fs.readFile.mockResolvedValueOnce('COCOAPODS: 1.2.4' as any);
|
fs.readFile.mockResolvedValueOnce('COCOAPODS: 1.2.4' as any);
|
||||||
datasource.getPkgReleases.mockResolvedValueOnce({
|
datasource.getPkgReleases.mockResolvedValueOnce({
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
import { getName, loadFixture } from '../../../test/util';
|
import { getName, loadFixture } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import type { RepoAdminConfig } from '../../config/types';
|
import type { RepoGlobalConfig } from '../../config/types';
|
||||||
import { extractPackageFile } from '.';
|
import { extractPackageFile } from '.';
|
||||||
|
|
||||||
const simplePodfile = loadFixture('Podfile.simple');
|
const simplePodfile = loadFixture('Podfile.simple');
|
||||||
const complexPodfile = loadFixture('Podfile.complex');
|
const complexPodfile = loadFixture('Podfile.complex');
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = { localDir: '' };
|
const adminConfig: RepoGlobalConfig = { localDir: '' };
|
||||||
|
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
describe('extractPackageFile()', () => {
|
describe('extractPackageFile()', () => {
|
||||||
it('extracts from simple file', async () => {
|
it('extracts from simple file', async () => {
|
||||||
setAdminConfig(adminConfig);
|
setGlobalConfig(adminConfig);
|
||||||
const { deps } = await extractPackageFile(simplePodfile, 'Podfile');
|
const { deps } = await extractPackageFile(simplePodfile, 'Podfile');
|
||||||
expect(deps).toMatchSnapshot([
|
expect(deps).toMatchSnapshot([
|
||||||
{ depName: 'a' },
|
{ depName: 'a' },
|
||||||
|
@ -40,7 +40,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('extracts from complex file', async () => {
|
it('extracts from complex file', async () => {
|
||||||
setAdminConfig(adminConfig);
|
setGlobalConfig(adminConfig);
|
||||||
const { deps } = await extractPackageFile(complexPodfile, 'Podfile');
|
const { deps } = await extractPackageFile(complexPodfile, 'Podfile');
|
||||||
expect(deps).toMatchSnapshot([
|
expect(deps).toMatchSnapshot([
|
||||||
{ depName: 'IQKeyboardManager', currentValue: '~> 6.5.0' },
|
{ depName: 'IQKeyboardManager', currentValue: '~> 6.5.0' },
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { join } from 'upath';
|
import { join } from 'upath';
|
||||||
import { envMock, exec, mockExecAll } from '../../../test/exec-util';
|
import { envMock, exec, mockExecAll } from '../../../test/exec-util';
|
||||||
import { env, fs, git, mocked, partial } from '../../../test/util';
|
import { env, fs, git, mocked, partial } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import type { RepoAdminConfig } from '../../config/types';
|
import type { RepoGlobalConfig } from '../../config/types';
|
||||||
import {
|
import {
|
||||||
PLATFORM_TYPE_GITHUB,
|
PLATFORM_TYPE_GITHUB,
|
||||||
PLATFORM_TYPE_GITLAB,
|
PLATFORM_TYPE_GITLAB,
|
||||||
|
@ -28,7 +28,7 @@ const config: UpdateArtifactsConfig = {
|
||||||
ignoreScripts: false,
|
ignoreScripts: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoGlobalConfig = {
|
||||||
allowScripts: false,
|
allowScripts: false,
|
||||||
// `join` fixes Windows CI
|
// `join` fixes Windows CI
|
||||||
localDir: join('/tmp/github/some/repo'),
|
localDir: join('/tmp/github/some/repo'),
|
||||||
|
@ -48,7 +48,7 @@ describe('.updateArtifacts()', () => {
|
||||||
env.getChildProcessEnv.mockReturnValue(envMock.basic);
|
env.getChildProcessEnv.mockReturnValue(envMock.basic);
|
||||||
docker.resetPrefetchedImages();
|
docker.resetPrefetchedImages();
|
||||||
hostRules.clear();
|
hostRules.clear();
|
||||||
setAdminConfig(adminConfig);
|
setGlobalConfig(adminConfig);
|
||||||
fs.ensureCacheDir.mockResolvedValue('/tmp/renovate/cache/others/composer');
|
fs.ensureCacheDir.mockResolvedValue('/tmp/renovate/cache/others/composer');
|
||||||
datasource.getPkgReleases.mockResolvedValueOnce({
|
datasource.getPkgReleases.mockResolvedValueOnce({
|
||||||
releases: [
|
releases: [
|
||||||
|
@ -64,7 +64,7 @@ describe('.updateArtifacts()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns if no composer.lock found', async () => {
|
it('returns if no composer.lock found', async () => {
|
||||||
|
@ -83,7 +83,7 @@ describe('.updateArtifacts()', () => {
|
||||||
const execSnapshots = mockExecAll(exec);
|
const execSnapshots = mockExecAll(exec);
|
||||||
fs.readLocalFile.mockResolvedValueOnce('{}');
|
fs.readLocalFile.mockResolvedValueOnce('{}');
|
||||||
git.getRepoStatus.mockResolvedValue(repoStatus);
|
git.getRepoStatus.mockResolvedValue(repoStatus);
|
||||||
setAdminConfig({ ...adminConfig, allowScripts: true });
|
setGlobalConfig({ ...adminConfig, allowScripts: true });
|
||||||
expect(
|
expect(
|
||||||
await composer.updateArtifacts({
|
await composer.updateArtifacts({
|
||||||
packageFileName: 'composer.json',
|
packageFileName: 'composer.json',
|
||||||
|
@ -217,7 +217,7 @@ describe('.updateArtifacts()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('supports docker mode', async () => {
|
it('supports docker mode', async () => {
|
||||||
setAdminConfig({ ...adminConfig, binarySource: 'docker' });
|
setGlobalConfig({ ...adminConfig, binarySource: 'docker' });
|
||||||
fs.readLocalFile.mockResolvedValueOnce('{}');
|
fs.readLocalFile.mockResolvedValueOnce('{}');
|
||||||
|
|
||||||
const execSnapshots = mockExecAll(exec);
|
const execSnapshots = mockExecAll(exec);
|
||||||
|
@ -252,7 +252,7 @@ describe('.updateArtifacts()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('supports global mode', async () => {
|
it('supports global mode', async () => {
|
||||||
setAdminConfig({ ...adminConfig, binarySource: 'global' });
|
setGlobalConfig({ ...adminConfig, binarySource: 'global' });
|
||||||
fs.readLocalFile.mockResolvedValueOnce('{}');
|
fs.readLocalFile.mockResolvedValueOnce('{}');
|
||||||
const execSnapshots = mockExecAll(exec);
|
const execSnapshots = mockExecAll(exec);
|
||||||
fs.readLocalFile.mockResolvedValueOnce('{ }');
|
fs.readLocalFile.mockResolvedValueOnce('{ }');
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import is from '@sindresorhus/is';
|
import is from '@sindresorhus/is';
|
||||||
import { quote } from 'shlex';
|
import { quote } from 'shlex';
|
||||||
import { getAdminConfig } from '../../config/admin';
|
import { getGlobalConfig } from '../../config/admin';
|
||||||
import {
|
import {
|
||||||
SYSTEM_INSUFFICIENT_DISK_SPACE,
|
SYSTEM_INSUFFICIENT_DISK_SPACE,
|
||||||
TEMPORARY_ERROR,
|
TEMPORARY_ERROR,
|
||||||
|
@ -137,7 +137,7 @@ export async function updateArtifacts({
|
||||||
args += ' --ignore-platform-reqs';
|
args += ' --ignore-platform-reqs';
|
||||||
}
|
}
|
||||||
args += ' --no-ansi --no-interaction';
|
args += ' --no-ansi --no-interaction';
|
||||||
if (!getAdminConfig().allowScripts || config.ignoreScripts) {
|
if (!getGlobalConfig().allowScripts || config.ignoreScripts) {
|
||||||
args += ' --no-scripts --no-autoloader --no-plugins';
|
args += ' --no-scripts --no-autoloader --no-plugins';
|
||||||
}
|
}
|
||||||
logger.debug({ cmd, args }, 'composer command');
|
logger.debug({ cmd, args }, 'composer command');
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { mock } from 'jest-mock-extended';
|
import { mock } from 'jest-mock-extended';
|
||||||
import _simpleGit, { Response, SimpleGit } from 'simple-git';
|
import _simpleGit, { Response, SimpleGit } from 'simple-git';
|
||||||
import { getName, partial } from '../../../test/util';
|
import { getName, partial } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import * as hostRules from '../../util/host-rules';
|
import * as hostRules from '../../util/host-rules';
|
||||||
import type { PackageFile } from '../types';
|
import type { PackageFile } from '../types';
|
||||||
import extractPackageFile from './extract';
|
import extractPackageFile from './extract';
|
||||||
|
@ -44,7 +44,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
describe('extractPackageFile()', () => {
|
describe('extractPackageFile()', () => {
|
||||||
it('extracts submodules', async () => {
|
it('extracts submodules', async () => {
|
||||||
setAdminConfig({ localDir: `${__dirname}/__fixtures__` });
|
setGlobalConfig({ localDir: `${__dirname}/__fixtures__` });
|
||||||
hostRules.add({ matchHost: 'github.com', token: 'abc123' });
|
hostRules.add({ matchHost: 'github.com', token: 'abc123' });
|
||||||
let res: PackageFile;
|
let res: PackageFile;
|
||||||
expect(await extractPackageFile('', '.gitmodules.1', {})).toBeNull();
|
expect(await extractPackageFile('', '.gitmodules.1', {})).toBeNull();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import URL from 'url';
|
import URL from 'url';
|
||||||
import Git, { SimpleGit } from 'simple-git';
|
import Git, { SimpleGit } from 'simple-git';
|
||||||
import upath from 'upath';
|
import upath from 'upath';
|
||||||
import { getAdminConfig } from '../../config/admin';
|
import { getGlobalConfig } from '../../config/admin';
|
||||||
import * as datasourceGitRefs from '../../datasource/git-refs';
|
import * as datasourceGitRefs from '../../datasource/git-refs';
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import { getHttpUrl, getRemoteUrlWithToken } from '../../util/git/url';
|
import { getHttpUrl, getRemoteUrlWithToken } from '../../util/git/url';
|
||||||
|
@ -88,7 +88,7 @@ export default async function extractPackageFile(
|
||||||
fileName: string,
|
fileName: string,
|
||||||
config: ManagerConfig
|
config: ManagerConfig
|
||||||
): Promise<PackageFile | null> {
|
): Promise<PackageFile | null> {
|
||||||
const { localDir } = getAdminConfig();
|
const { localDir } = getGlobalConfig();
|
||||||
const git = Git(localDir);
|
const git = Git(localDir);
|
||||||
const gitModulesPath = upath.join(localDir, fileName);
|
const gitModulesPath = upath.join(localDir, fileName);
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@ import _simpleGit from 'simple-git';
|
||||||
import { dir } from 'tmp-promise';
|
import { dir } from 'tmp-promise';
|
||||||
import { join } from 'upath';
|
import { join } from 'upath';
|
||||||
import { getName } from '../../../test/util';
|
import { getName } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import type { RepoAdminConfig } from '../../config/types';
|
import type { RepoGlobalConfig } from '../../config/types';
|
||||||
import type { Upgrade } from '../types';
|
import type { Upgrade } from '../types';
|
||||||
import updateDependency from './update';
|
import updateDependency from './update';
|
||||||
|
|
||||||
|
@ -13,16 +13,16 @@ const simpleGit: any = _simpleGit;
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
describe('updateDependency', () => {
|
describe('updateDependency', () => {
|
||||||
let upgrade: Upgrade;
|
let upgrade: Upgrade;
|
||||||
let adminConfig: RepoAdminConfig;
|
let adminConfig: RepoGlobalConfig;
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
upgrade = { depName: 'renovate' };
|
upgrade = { depName: 'renovate' };
|
||||||
|
|
||||||
const tmpDir = await dir();
|
const tmpDir = await dir();
|
||||||
adminConfig = { localDir: join(tmpDir.path) };
|
adminConfig = { localDir: join(tmpDir.path) };
|
||||||
setAdminConfig(adminConfig);
|
setGlobalConfig(adminConfig);
|
||||||
});
|
});
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
it('returns null on error', async () => {
|
it('returns null on error', async () => {
|
||||||
simpleGit.mockReturnValue({
|
simpleGit.mockReturnValue({
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import Git from 'simple-git';
|
import Git from 'simple-git';
|
||||||
import upath from 'upath';
|
import upath from 'upath';
|
||||||
import { getAdminConfig } from '../../config/admin';
|
import { getGlobalConfig } from '../../config/admin';
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import type { UpdateDependencyConfig } from '../types';
|
import type { UpdateDependencyConfig } from '../types';
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ export default async function updateDependency({
|
||||||
fileContent,
|
fileContent,
|
||||||
upgrade,
|
upgrade,
|
||||||
}: UpdateDependencyConfig): Promise<string | null> {
|
}: UpdateDependencyConfig): Promise<string | null> {
|
||||||
const { localDir } = getAdminConfig();
|
const { localDir } = getGlobalConfig();
|
||||||
const git = Git(localDir);
|
const git = Git(localDir);
|
||||||
const submoduleGit = Git(upath.join(localDir, upgrade.depName));
|
const submoduleGit = Git(upath.join(localDir, upgrade.depName));
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
import { getName, logger } from '../../../test/util';
|
import { getName, logger } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import type { RepoAdminConfig } from '../../config/types';
|
import type { RepoGlobalConfig } from '../../config/types';
|
||||||
import type { ExtractConfig, PackageDependency } from '../types';
|
import type { ExtractConfig, PackageDependency } from '../types';
|
||||||
import { extractAllPackageFiles } from './extract';
|
import { extractAllPackageFiles } from './extract';
|
||||||
|
|
||||||
const config: ExtractConfig = {};
|
const config: ExtractConfig = {};
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = { localDir: '' };
|
const adminConfig: RepoGlobalConfig = { localDir: '' };
|
||||||
|
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
setAdminConfig(adminConfig);
|
setGlobalConfig(adminConfig);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('extractAllPackageFiles()', () => {
|
describe('extractAllPackageFiles()', () => {
|
||||||
|
|
|
@ -3,8 +3,8 @@ import _fs from 'fs-extra';
|
||||||
import { join } from 'upath';
|
import { join } from 'upath';
|
||||||
import { envMock, mockExecAll } from '../../../test/exec-util';
|
import { envMock, mockExecAll } from '../../../test/exec-util';
|
||||||
import { git, mocked } from '../../../test/util';
|
import { git, mocked } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import type { RepoAdminConfig } from '../../config/types';
|
import type { RepoGlobalConfig } from '../../config/types';
|
||||||
import * as docker from '../../util/exec/docker';
|
import * as docker from '../../util/exec/docker';
|
||||||
import * as _env from '../../util/exec/env';
|
import * as _env from '../../util/exec/env';
|
||||||
import type { StatusResult } from '../../util/git';
|
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
|
replace github.com/pkg/errors => ../errors
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoGlobalConfig = {
|
||||||
// `join` fixes Windows CI
|
// `join` fixes Windows CI
|
||||||
localDir: join('/tmp/github/some/repo'),
|
localDir: join('/tmp/github/some/repo'),
|
||||||
cacheDir: join('/tmp/renovate/cache'),
|
cacheDir: join('/tmp/renovate/cache'),
|
||||||
|
@ -61,11 +61,11 @@ describe('.updateArtifacts()', () => {
|
||||||
|
|
||||||
delete process.env.GOPATH;
|
delete process.env.GOPATH;
|
||||||
env.getChildProcessEnv.mockReturnValue({ ...envMock.basic, ...goEnv });
|
env.getChildProcessEnv.mockReturnValue({ ...envMock.basic, ...goEnv });
|
||||||
setAdminConfig(adminConfig);
|
setGlobalConfig(adminConfig);
|
||||||
docker.resetPrefetchedImages();
|
docker.resetPrefetchedImages();
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
it('returns if no go.sum found', async () => {
|
it('returns if no go.sum found', async () => {
|
||||||
const execSnapshots = mockExecAll(exec);
|
const execSnapshots = mockExecAll(exec);
|
||||||
|
@ -151,7 +151,7 @@ describe('.updateArtifacts()', () => {
|
||||||
expect(execSnapshots).toMatchSnapshot();
|
expect(execSnapshots).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
it('supports docker mode without credentials', async () => {
|
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('Current go.sum' as any);
|
||||||
fs.readFile.mockResolvedValueOnce(null as any); // vendor modules filename
|
fs.readFile.mockResolvedValueOnce(null as any); // vendor modules filename
|
||||||
const execSnapshots = mockExecAll(exec);
|
const execSnapshots = mockExecAll(exec);
|
||||||
|
@ -170,7 +170,7 @@ describe('.updateArtifacts()', () => {
|
||||||
expect(execSnapshots).toMatchSnapshot();
|
expect(execSnapshots).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
it('supports global mode', async () => {
|
it('supports global mode', async () => {
|
||||||
setAdminConfig({ ...adminConfig, binarySource: 'global' });
|
setGlobalConfig({ ...adminConfig, binarySource: 'global' });
|
||||||
fs.readFile.mockResolvedValueOnce('Current go.sum' as any);
|
fs.readFile.mockResolvedValueOnce('Current go.sum' as any);
|
||||||
fs.readFile.mockResolvedValueOnce(null as any); // vendor modules filename
|
fs.readFile.mockResolvedValueOnce(null as any); // vendor modules filename
|
||||||
const execSnapshots = mockExecAll(exec);
|
const execSnapshots = mockExecAll(exec);
|
||||||
|
@ -189,7 +189,7 @@ describe('.updateArtifacts()', () => {
|
||||||
expect(execSnapshots).toMatchSnapshot();
|
expect(execSnapshots).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
it('supports docker mode with credentials', async () => {
|
it('supports docker mode with credentials', async () => {
|
||||||
setAdminConfig({ ...adminConfig, binarySource: 'docker' });
|
setGlobalConfig({ ...adminConfig, binarySource: 'docker' });
|
||||||
hostRules.find.mockReturnValueOnce({
|
hostRules.find.mockReturnValueOnce({
|
||||||
token: 'some-token',
|
token: 'some-token',
|
||||||
});
|
});
|
||||||
|
@ -211,7 +211,7 @@ describe('.updateArtifacts()', () => {
|
||||||
expect(execSnapshots).toMatchSnapshot();
|
expect(execSnapshots).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
it('supports docker mode with goModTidy', async () => {
|
it('supports docker mode with goModTidy', async () => {
|
||||||
setAdminConfig({ ...adminConfig, binarySource: 'docker' });
|
setGlobalConfig({ ...adminConfig, binarySource: 'docker' });
|
||||||
hostRules.find.mockReturnValueOnce({});
|
hostRules.find.mockReturnValueOnce({});
|
||||||
fs.readFile.mockResolvedValueOnce('Current go.sum' as any);
|
fs.readFile.mockResolvedValueOnce('Current go.sum' as any);
|
||||||
fs.readFile.mockResolvedValueOnce(null as any); // vendor modules filename
|
fs.readFile.mockResolvedValueOnce(null as any); // vendor modules filename
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import is from '@sindresorhus/is';
|
import is from '@sindresorhus/is';
|
||||||
import { quote } from 'shlex';
|
import { quote } from 'shlex';
|
||||||
import { dirname, join } from 'upath';
|
import { dirname, join } from 'upath';
|
||||||
import { getAdminConfig } from '../../config/admin';
|
import { getGlobalConfig } from '../../config/admin';
|
||||||
import { TEMPORARY_ERROR } from '../../constants/error-messages';
|
import { TEMPORARY_ERROR } from '../../constants/error-messages';
|
||||||
import { PLATFORM_TYPE_GITHUB } from '../../constants/platforms';
|
import { PLATFORM_TYPE_GITHUB } from '../../constants/platforms';
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
|
@ -125,7 +125,7 @@ export async function updateArtifacts({
|
||||||
GONOPROXY: process.env.GONOPROXY,
|
GONOPROXY: process.env.GONOPROXY,
|
||||||
GONOSUMDB: process.env.GONOSUMDB,
|
GONOSUMDB: process.env.GONOSUMDB,
|
||||||
GOFLAGS: useModcacherw(config.constraints?.go) ? '-modcacherw' : null,
|
GOFLAGS: useModcacherw(config.constraints?.go) ? '-modcacherw' : null,
|
||||||
CGO_ENABLED: getAdminConfig().binarySource === 'docker' ? '0' : null,
|
CGO_ENABLED: getGlobalConfig().binarySource === 'docker' ? '0' : null,
|
||||||
},
|
},
|
||||||
docker: {
|
docker: {
|
||||||
image: 'go',
|
image: 'go',
|
||||||
|
|
|
@ -3,8 +3,8 @@ import Git from 'simple-git';
|
||||||
import { resolve } from 'upath';
|
import { resolve } from 'upath';
|
||||||
import * as httpMock from '../../../test/http-mock';
|
import * as httpMock from '../../../test/http-mock';
|
||||||
import { getName, git, partial } from '../../../test/util';
|
import { getName, git, partial } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import type { RepoAdminConfig } from '../../config/types';
|
import type { RepoGlobalConfig } from '../../config/types';
|
||||||
import type { StatusResult } from '../../util/git';
|
import type { StatusResult } from '../../util/git';
|
||||||
import { ifSystemSupportsGradle } from '../gradle/deep/__testutil__/gradle';
|
import { ifSystemSupportsGradle } from '../gradle/deep/__testutil__/gradle';
|
||||||
import type { UpdateArtifactsConfig } from '../types';
|
import type { UpdateArtifactsConfig } from '../types';
|
||||||
|
@ -14,7 +14,7 @@ jest.mock('../../util/git');
|
||||||
|
|
||||||
const fixtures = resolve(__dirname, './__fixtures__');
|
const fixtures = resolve(__dirname, './__fixtures__');
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoGlobalConfig = {
|
||||||
localDir: resolve(fixtures, './testFiles'),
|
localDir: resolve(fixtures, './testFiles'),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -42,12 +42,12 @@ describe(getName(), () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
setAdminConfig(adminConfig);
|
setGlobalConfig(adminConfig);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await Git(fixtures).checkout(['HEAD', '--', '.']);
|
await Git(fixtures).checkout(['HEAD', '--', '.']);
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('replaces existing value', async () => {
|
it('replaces existing value', async () => {
|
||||||
|
@ -168,7 +168,7 @@ describe(getName(), () => {
|
||||||
localDir: resolve(fixtures, './wrongCmd'),
|
localDir: resolve(fixtures, './wrongCmd'),
|
||||||
};
|
};
|
||||||
|
|
||||||
setAdminConfig(wrongCmdConfig);
|
setGlobalConfig(wrongCmdConfig);
|
||||||
const res = await dcUpdate.updateArtifacts({
|
const res = await dcUpdate.updateArtifacts({
|
||||||
packageFileName: 'gradle/wrapper/gradle-wrapper.properties',
|
packageFileName: 'gradle/wrapper/gradle-wrapper.properties',
|
||||||
updatedDeps: [],
|
updatedDeps: [],
|
||||||
|
@ -191,7 +191,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('gradlew not found', async () => {
|
it('gradlew not found', async () => {
|
||||||
setAdminConfig({ localDir: 'some-dir' });
|
setGlobalConfig({ localDir: 'some-dir' });
|
||||||
const res = await dcUpdate.updateArtifacts({
|
const res = await dcUpdate.updateArtifacts({
|
||||||
packageFileName: 'gradle-wrapper.properties',
|
packageFileName: 'gradle-wrapper.properties',
|
||||||
updatedDeps: [],
|
updatedDeps: [],
|
||||||
|
|
|
@ -12,8 +12,8 @@ import {
|
||||||
git,
|
git,
|
||||||
partial,
|
partial,
|
||||||
} from '../../../test/util';
|
} from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import type { RepoAdminConfig } from '../../config/types';
|
import type { RepoGlobalConfig } from '../../config/types';
|
||||||
import { resetPrefetchedImages } from '../../util/exec/docker';
|
import { resetPrefetchedImages } from '../../util/exec/docker';
|
||||||
import type { StatusResult } from '../../util/git';
|
import type { StatusResult } from '../../util/git';
|
||||||
import type { UpdateArtifactsConfig } from '../types';
|
import type { UpdateArtifactsConfig } from '../types';
|
||||||
|
@ -27,7 +27,7 @@ jest.mock('../../util/exec/env');
|
||||||
const exec: jest.Mock<typeof _exec> = _exec as any;
|
const exec: jest.Mock<typeof _exec> = _exec as any;
|
||||||
const fixtures = resolve(__dirname, './__fixtures__');
|
const fixtures = resolve(__dirname, './__fixtures__');
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoGlobalConfig = {
|
||||||
localDir: resolve(fixtures, './testFiles'),
|
localDir: resolve(fixtures, './testFiles'),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -54,14 +54,14 @@ describe(getName(), () => {
|
||||||
LC_ALL: 'en_US',
|
LC_ALL: 'en_US',
|
||||||
});
|
});
|
||||||
|
|
||||||
setAdminConfig(adminConfig);
|
setGlobalConfig(adminConfig);
|
||||||
resetPrefetchedImages();
|
resetPrefetchedImages();
|
||||||
|
|
||||||
fs.readLocalFile.mockResolvedValue('test');
|
fs.readLocalFile.mockResolvedValue('test');
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('replaces existing value', async () => {
|
it('replaces existing value', async () => {
|
||||||
|
@ -100,7 +100,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('gradlew not found', async () => {
|
it('gradlew not found', async () => {
|
||||||
setAdminConfig({ ...adminConfig, localDir: 'some-dir' });
|
setGlobalConfig({ ...adminConfig, localDir: 'some-dir' });
|
||||||
const res = await dcUpdate.updateArtifacts({
|
const res = await dcUpdate.updateArtifacts({
|
||||||
packageFileName: 'gradle-wrapper.properties',
|
packageFileName: 'gradle-wrapper.properties',
|
||||||
updatedDeps: [],
|
updatedDeps: [],
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { stat } from 'fs-extra';
|
import { stat } from 'fs-extra';
|
||||||
import { resolve } from 'upath';
|
import { resolve } from 'upath';
|
||||||
import { getAdminConfig } from '../../config/admin';
|
import { getGlobalConfig } from '../../config/admin';
|
||||||
import { TEMPORARY_ERROR } from '../../constants/error-messages';
|
import { TEMPORARY_ERROR } from '../../constants/error-messages';
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import { ExecOptions, exec } from '../../util/exec';
|
import { ExecOptions, exec } from '../../util/exec';
|
||||||
|
@ -55,7 +55,7 @@ export async function updateArtifacts({
|
||||||
config,
|
config,
|
||||||
}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {
|
}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {
|
||||||
try {
|
try {
|
||||||
const { localDir: projectDir } = getAdminConfig();
|
const { localDir: projectDir } = getGlobalConfig();
|
||||||
logger.debug({ updatedDeps }, 'gradle-wrapper.updateArtifacts()');
|
logger.debug({ updatedDeps }, 'gradle-wrapper.updateArtifacts()');
|
||||||
const gradlew = gradleWrapperFileName(config);
|
const gradlew = gradleWrapperFileName(config);
|
||||||
const gradlewPath = resolve(projectDir, `./${gradlew}`);
|
const gradlewPath = resolve(projectDir, `./${gradlew}`);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import fsExtra from 'fs-extra';
|
import fsExtra from 'fs-extra';
|
||||||
import tmp, { DirectoryResult } from 'tmp-promise';
|
import tmp, { DirectoryResult } from 'tmp-promise';
|
||||||
import { getName } from '../../../../test/util';
|
import { getName } from '../../../../test/util';
|
||||||
import { setAdminConfig } from '../../../config/admin';
|
import { setGlobalConfig } from '../../../config/admin';
|
||||||
import type { RepoAdminConfig } from '../../../config/types';
|
import type { RepoGlobalConfig } from '../../../config/types';
|
||||||
import type { ExtractConfig } from '../../types';
|
import type { ExtractConfig } from '../../types';
|
||||||
import { ifSystemSupportsGradle } from './__testutil__/gradle';
|
import { ifSystemSupportsGradle } from './__testutil__/gradle';
|
||||||
import * as manager from '.';
|
import * as manager from '.';
|
||||||
|
@ -21,13 +21,13 @@ describe(getName(), () => {
|
||||||
let workingDir: DirectoryResult;
|
let workingDir: DirectoryResult;
|
||||||
let testRunConfig: ExtractConfig;
|
let testRunConfig: ExtractConfig;
|
||||||
let successFile: string;
|
let successFile: string;
|
||||||
let adminConfig: RepoAdminConfig;
|
let adminConfig: RepoGlobalConfig;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
workingDir = await tmp.dir({ unsafeCleanup: true });
|
workingDir = await tmp.dir({ unsafeCleanup: true });
|
||||||
successFile = '';
|
successFile = '';
|
||||||
adminConfig = { localDir: workingDir.path };
|
adminConfig = { localDir: workingDir.path };
|
||||||
setAdminConfig(adminConfig);
|
setGlobalConfig(adminConfig);
|
||||||
testRunConfig = { ...baseConfig };
|
testRunConfig = { ...baseConfig };
|
||||||
await fsExtra.copy(`${fixtures}/minimal-project`, workingDir.path);
|
await fsExtra.copy(`${fixtures}/minimal-project`, workingDir.path);
|
||||||
await fsExtra.copy(`${fixtures}/gradle-wrappers/6`, workingDir.path);
|
await fsExtra.copy(`${fixtures}/gradle-wrappers/6`, workingDir.path);
|
||||||
|
@ -48,7 +48,7 @@ allprojects {
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('executes an executable gradle wrapper', async () => {
|
it('executes an executable gradle wrapper', async () => {
|
||||||
|
|
|
@ -11,8 +11,8 @@ import {
|
||||||
loadFixture,
|
loadFixture,
|
||||||
mocked,
|
mocked,
|
||||||
} from '../../../../test/util';
|
} from '../../../../test/util';
|
||||||
import { setAdminConfig } from '../../../config/admin';
|
import { setGlobalConfig } from '../../../config/admin';
|
||||||
import type { RepoAdminConfig } from '../../../config/types';
|
import type { RepoGlobalConfig } from '../../../config/types';
|
||||||
import * as docker from '../../../util/exec/docker';
|
import * as docker from '../../../util/exec/docker';
|
||||||
import * as _env from '../../../util/exec/env';
|
import * as _env from '../../../util/exec/env';
|
||||||
import type { ExtractConfig } from '../../types';
|
import type { ExtractConfig } from '../../types';
|
||||||
|
@ -26,7 +26,7 @@ const fs = mocked(_fs);
|
||||||
jest.mock('../../../util/exec/env');
|
jest.mock('../../../util/exec/env');
|
||||||
const env = mocked(_env);
|
const env = mocked(_env);
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoGlobalConfig = {
|
||||||
localDir: join('/foo/bar'),
|
localDir: join('/foo/bar'),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -88,11 +88,11 @@ describe(getName(), () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
setAdminConfig(adminConfig);
|
setGlobalConfig(adminConfig);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -220,7 +220,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use docker if required', async () => {
|
it('should use docker if required', async () => {
|
||||||
setAdminConfig(dockerAdminConfig);
|
setGlobalConfig(dockerAdminConfig);
|
||||||
const execSnapshots = setupMocks({ wrapperFilename: null });
|
const execSnapshots = setupMocks({ wrapperFilename: null });
|
||||||
const dependencies = await extractAllPackageFiles(config, [
|
const dependencies = await extractAllPackageFiles(config, [
|
||||||
'build.gradle',
|
'build.gradle',
|
||||||
|
@ -231,7 +231,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use docker even if gradlew is available', async () => {
|
it('should use docker even if gradlew is available', async () => {
|
||||||
setAdminConfig(dockerAdminConfig);
|
setGlobalConfig(dockerAdminConfig);
|
||||||
const execSnapshots = setupMocks();
|
const execSnapshots = setupMocks();
|
||||||
const dependencies = await extractAllPackageFiles(config, [
|
const dependencies = await extractAllPackageFiles(config, [
|
||||||
'build.gradle',
|
'build.gradle',
|
||||||
|
@ -242,7 +242,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use docker even if gradlew.bat is available on Windows', async () => {
|
it('should use docker even if gradlew.bat is available on Windows', async () => {
|
||||||
setAdminConfig(dockerAdminConfig);
|
setGlobalConfig(dockerAdminConfig);
|
||||||
jest.spyOn(os, 'platform').mockReturnValueOnce('win32');
|
jest.spyOn(os, 'platform').mockReturnValueOnce('win32');
|
||||||
const execSnapshots = setupMocks({ wrapperFilename: 'gradlew.bat' });
|
const execSnapshots = setupMocks({ wrapperFilename: 'gradlew.bat' });
|
||||||
const dependencies = await extractAllPackageFiles(config, [
|
const dependencies = await extractAllPackageFiles(config, [
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import type { Stats } from 'fs';
|
import type { Stats } from 'fs';
|
||||||
import { stat } from 'fs-extra';
|
import { stat } from 'fs-extra';
|
||||||
import upath from 'upath';
|
import upath from 'upath';
|
||||||
import { getAdminConfig } from '../../../config/admin';
|
import { getGlobalConfig } from '../../../config/admin';
|
||||||
import { TEMPORARY_ERROR } from '../../../constants/error-messages';
|
import { TEMPORARY_ERROR } from '../../../constants/error-messages';
|
||||||
import * as datasourceMaven from '../../../datasource/maven';
|
import * as datasourceMaven from '../../../datasource/maven';
|
||||||
import { logger } from '../../../logger';
|
import { logger } from '../../../logger';
|
||||||
|
@ -91,7 +91,7 @@ export async function extractAllPackageFiles(
|
||||||
): Promise<PackageFile[] | null> {
|
): Promise<PackageFile[] | null> {
|
||||||
let rootBuildGradle: string | undefined;
|
let rootBuildGradle: string | undefined;
|
||||||
let gradlew: Stats | null;
|
let gradlew: Stats | null;
|
||||||
const { localDir } = getAdminConfig();
|
const { localDir } = getGlobalConfig();
|
||||||
for (const packageFile of packageFiles) {
|
for (const packageFile of packageFiles) {
|
||||||
const dirname = upath.dirname(packageFile);
|
const dirname = upath.dirname(packageFile);
|
||||||
const gradlewPath = upath.join(dirname, gradleWrapperFileName(config));
|
const gradlewPath = upath.join(dirname, gradleWrapperFileName(config));
|
||||||
|
|
|
@ -2,7 +2,7 @@ import type { Stats } from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import { chmod } from 'fs-extra';
|
import { chmod } from 'fs-extra';
|
||||||
import upath from 'upath';
|
import upath from 'upath';
|
||||||
import { getAdminConfig } from '../../../config/admin';
|
import { getGlobalConfig } from '../../../config/admin';
|
||||||
import type { ExtractConfig } from '../../types';
|
import type { ExtractConfig } from '../../types';
|
||||||
|
|
||||||
export const extraEnv = {
|
export const extraEnv = {
|
||||||
|
@ -13,7 +13,7 @@ export const extraEnv = {
|
||||||
export function gradleWrapperFileName(config: ExtractConfig): string {
|
export function gradleWrapperFileName(config: ExtractConfig): string {
|
||||||
if (
|
if (
|
||||||
os.platform() === 'win32' &&
|
os.platform() === 'win32' &&
|
||||||
getAdminConfig()?.binarySource !== 'docker'
|
getGlobalConfig()?.binarySource !== 'docker'
|
||||||
) {
|
) {
|
||||||
return 'gradlew.bat';
|
return 'gradlew.bat';
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,8 @@ import _fs from 'fs-extra';
|
||||||
import { join } from 'upath';
|
import { join } from 'upath';
|
||||||
import { envMock, mockExecAll } from '../../../test/exec-util';
|
import { envMock, mockExecAll } from '../../../test/exec-util';
|
||||||
import { git, mocked } from '../../../test/util';
|
import { git, mocked } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import type { RepoAdminConfig } from '../../config/types';
|
import type { RepoGlobalConfig } from '../../config/types';
|
||||||
import * as docker from '../../util/exec/docker';
|
import * as docker from '../../util/exec/docker';
|
||||||
import * as _env from '../../util/exec/env';
|
import * as _env from '../../util/exec/env';
|
||||||
import type { UpdateArtifactsConfig } from '../types';
|
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 exec: jest.Mock<typeof _exec> = _exec as any;
|
||||||
const env = mocked(_env);
|
const env = mocked(_env);
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoGlobalConfig = {
|
||||||
localDir: join('/tmp/github/some/repo'), // `join` fixes Windows CI
|
localDir: join('/tmp/github/some/repo'), // `join` fixes Windows CI
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,11 +32,11 @@ describe('.updateArtifacts()', () => {
|
||||||
jest.resetModules();
|
jest.resetModules();
|
||||||
|
|
||||||
env.getChildProcessEnv.mockReturnValue(envMock.basic);
|
env.getChildProcessEnv.mockReturnValue(envMock.basic);
|
||||||
setAdminConfig(adminConfig);
|
setGlobalConfig(adminConfig);
|
||||||
docker.resetPrefetchedImages();
|
docker.resetPrefetchedImages();
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
it('returns null if no Chart.lock found', async () => {
|
it('returns null if no Chart.lock found', async () => {
|
||||||
const updatedDeps = [{ depName: 'dep1' }];
|
const updatedDeps = [{ depName: 'dep1' }];
|
||||||
|
@ -108,7 +108,7 @@ describe('.updateArtifacts()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns updated Chart.lock with docker', async () => {
|
it('returns updated Chart.lock with docker', async () => {
|
||||||
setAdminConfig({ ...adminConfig, binarySource: 'docker' });
|
setGlobalConfig({ ...adminConfig, binarySource: 'docker' });
|
||||||
git.getFile.mockResolvedValueOnce('Old Chart.lock');
|
git.getFile.mockResolvedValueOnce('Old Chart.lock');
|
||||||
const execSnapshots = mockExecAll(exec);
|
const execSnapshots = mockExecAll(exec);
|
||||||
fs.readFile.mockResolvedValueOnce('New Chart.lock' as any);
|
fs.readFile.mockResolvedValueOnce('New Chart.lock' as any);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { join } from 'upath';
|
import { join } from 'upath';
|
||||||
import { envMock, exec, mockExecAll } from '../../../test/exec-util';
|
import { envMock, exec, mockExecAll } from '../../../test/exec-util';
|
||||||
import { env, fs, getName, hostRules } from '../../../test/util';
|
import { env, fs, getName, hostRules } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import type { RepoAdminConfig } from '../../config/types';
|
import type { RepoGlobalConfig } from '../../config/types';
|
||||||
import * as docker from '../../util/exec/docker';
|
import * as docker from '../../util/exec/docker';
|
||||||
import type { UpdateArtifactsConfig } from '../types';
|
import type { UpdateArtifactsConfig } from '../types';
|
||||||
import { updateArtifacts } from '.';
|
import { updateArtifacts } from '.';
|
||||||
|
@ -12,7 +12,7 @@ jest.mock('../../util/exec/env');
|
||||||
jest.mock('../../util/fs');
|
jest.mock('../../util/fs');
|
||||||
jest.mock('../../util/host-rules');
|
jest.mock('../../util/host-rules');
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoGlobalConfig = {
|
||||||
// `join` fixes Windows CI
|
// `join` fixes Windows CI
|
||||||
localDir: join('/tmp/github/some/repo'),
|
localDir: join('/tmp/github/some/repo'),
|
||||||
};
|
};
|
||||||
|
@ -25,11 +25,11 @@ describe(getName(), () => {
|
||||||
jest.resetModules();
|
jest.resetModules();
|
||||||
|
|
||||||
env.getChildProcessEnv.mockReturnValue(envMock.basic);
|
env.getChildProcessEnv.mockReturnValue(envMock.basic);
|
||||||
setAdminConfig(adminConfig);
|
setGlobalConfig(adminConfig);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns null if no mix.lock found', async () => {
|
it('returns null if no mix.lock found', async () => {
|
||||||
|
@ -82,7 +82,7 @@ describe(getName(), () => {
|
||||||
|
|
||||||
it('returns updated mix.lock', async () => {
|
it('returns updated mix.lock', async () => {
|
||||||
jest.spyOn(docker, 'removeDanglingContainers').mockResolvedValueOnce();
|
jest.spyOn(docker, 'removeDanglingContainers').mockResolvedValueOnce();
|
||||||
setAdminConfig({ ...adminConfig, binarySource: 'docker' });
|
setGlobalConfig({ ...adminConfig, binarySource: 'docker' });
|
||||||
fs.readLocalFile.mockResolvedValueOnce('Old mix.lock');
|
fs.readLocalFile.mockResolvedValueOnce('Old mix.lock');
|
||||||
fs.getSiblingFileName.mockReturnValueOnce('mix.lock');
|
fs.getSiblingFileName.mockReturnValueOnce('mix.lock');
|
||||||
const execSnapshots = mockExecAll(exec);
|
const execSnapshots = mockExecAll(exec);
|
||||||
|
@ -101,7 +101,7 @@ describe(getName(), () => {
|
||||||
|
|
||||||
it('authenticates to private repositories', async () => {
|
it('authenticates to private repositories', async () => {
|
||||||
jest.spyOn(docker, 'removeDanglingContainers').mockResolvedValueOnce();
|
jest.spyOn(docker, 'removeDanglingContainers').mockResolvedValueOnce();
|
||||||
setAdminConfig({ ...adminConfig, binarySource: 'docker' });
|
setGlobalConfig({ ...adminConfig, binarySource: 'docker' });
|
||||||
fs.readLocalFile.mockResolvedValueOnce('Old mix.lock');
|
fs.readLocalFile.mockResolvedValueOnce('Old mix.lock');
|
||||||
fs.getSiblingFileName.mockReturnValueOnce('mix.lock');
|
fs.getSiblingFileName.mockReturnValueOnce('mix.lock');
|
||||||
const execSnapshots = mockExecAll(exec);
|
const execSnapshots = mockExecAll(exec);
|
||||||
|
@ -141,7 +141,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns updated mix.lock in subdir', async () => {
|
it('returns updated mix.lock in subdir', async () => {
|
||||||
setAdminConfig({ ...adminConfig, binarySource: 'docker' });
|
setGlobalConfig({ ...adminConfig, binarySource: 'docker' });
|
||||||
fs.getSiblingFileName.mockReturnValueOnce('subdir/mix.lock');
|
fs.getSiblingFileName.mockReturnValueOnce('subdir/mix.lock');
|
||||||
mockExecAll(exec);
|
mockExecAll(exec);
|
||||||
expect(
|
expect(
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { getName, loadFixture } from '../../../test/util';
|
import { getName, loadFixture } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import { extractPackageFile } from '.';
|
import { extractPackageFile } from '.';
|
||||||
|
|
||||||
const sample = loadFixture('mix.exs');
|
const sample = loadFixture('mix.exs');
|
||||||
|
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
setAdminConfig({ localDir: '' });
|
setGlobalConfig({ localDir: '' });
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('extractPackageFile()', () => {
|
describe('extractPackageFile()', () => {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import is from '@sindresorhus/is';
|
import is from '@sindresorhus/is';
|
||||||
import validateNpmPackageName from 'validate-npm-package-name';
|
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 { CONFIG_VALIDATION } from '../../../constants/error-messages';
|
||||||
import * as datasourceGithubTags from '../../../datasource/github-tags';
|
import * as datasourceGithubTags from '../../../datasource/github-tags';
|
||||||
import { id as npmId } from '../../../datasource/npm';
|
import { id as npmId } from '../../../datasource/npm';
|
||||||
|
@ -105,7 +105,7 @@ export async function extractPackageFile(
|
||||||
logger.debug('Stripping package-lock setting from .npmrc');
|
logger.debug('Stripping package-lock setting from .npmrc');
|
||||||
npmrc = npmrc.replace(/(^|\n)package-lock.*?(\n|$)/g, '\n');
|
npmrc = npmrc.replace(/(^|\n)package-lock.*?(\n|$)/g, '\n');
|
||||||
}
|
}
|
||||||
if (npmrc.includes('=${') && !getAdminConfig().exposeAllEnv) {
|
if (npmrc.includes('=${') && !getGlobalConfig().exposeAllEnv) {
|
||||||
logger.debug(
|
logger.debug(
|
||||||
{ npmrcFileName },
|
{ npmrcFileName },
|
||||||
'Stripping .npmrc file of lines with variables'
|
'Stripping .npmrc file of lines with variables'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import yaml from 'js-yaml';
|
import yaml from 'js-yaml';
|
||||||
import { getFixturePath, getName, logger } from '../../../../test/util';
|
import { getFixturePath, getName, logger } from '../../../../test/util';
|
||||||
import { setAdminConfig } from '../../../config/admin';
|
import { setGlobalConfig } from '../../../config/admin';
|
||||||
import * as fs from '../../../util/fs';
|
import * as fs from '../../../util/fs';
|
||||||
import {
|
import {
|
||||||
detectPnpmWorkspaces,
|
detectPnpmWorkspaces,
|
||||||
|
@ -10,7 +10,7 @@ import {
|
||||||
|
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
setAdminConfig({ localDir: getFixturePath('pnpm-monorepo/', '..') });
|
setGlobalConfig({ localDir: getFixturePath('pnpm-monorepo/', '..') });
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('.extractPnpmFilters()', () => {
|
describe('.extractPnpmFilters()', () => {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { parseSyml } from '@yarnpkg/parsers';
|
||||||
import deepmerge from 'deepmerge';
|
import deepmerge from 'deepmerge';
|
||||||
import { dump, load } from 'js-yaml';
|
import { dump, load } from 'js-yaml';
|
||||||
import upath from 'upath';
|
import upath from 'upath';
|
||||||
import { getAdminConfig } from '../../../config/admin';
|
import { getGlobalConfig } from '../../../config/admin';
|
||||||
import { SYSTEM_INSUFFICIENT_DISK_SPACE } from '../../../constants/error-messages';
|
import { SYSTEM_INSUFFICIENT_DISK_SPACE } from '../../../constants/error-messages';
|
||||||
import { id as npmId } from '../../../datasource/npm';
|
import { id as npmId } from '../../../datasource/npm';
|
||||||
import { logger } from '../../../logger';
|
import { logger } from '../../../logger';
|
||||||
|
@ -139,7 +139,7 @@ export async function writeExistingFiles(
|
||||||
{ packageFiles: npmFiles.map((n) => n.packageFile) },
|
{ packageFiles: npmFiles.map((n) => n.packageFile) },
|
||||||
'Writing package.json files'
|
'Writing package.json files'
|
||||||
);
|
);
|
||||||
const { localDir } = getAdminConfig();
|
const { localDir } = getGlobalConfig();
|
||||||
for (const packageFile of npmFiles) {
|
for (const packageFile of npmFiles) {
|
||||||
const basedir = upath.join(
|
const basedir = upath.join(
|
||||||
localDir,
|
localDir,
|
||||||
|
@ -218,7 +218,7 @@ export async function writeUpdatedPackageFiles(
|
||||||
logger.debug('No files found');
|
logger.debug('No files found');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { localDir } = getAdminConfig();
|
const { localDir } = getGlobalConfig();
|
||||||
for (const packageFile of config.updatedPackageFiles) {
|
for (const packageFile of config.updatedPackageFiles) {
|
||||||
if (packageFile.name.endsWith('package-lock.json')) {
|
if (packageFile.name.endsWith('package-lock.json')) {
|
||||||
logger.debug(`Writing package-lock file: ${packageFile.name}`);
|
logger.debug(`Writing package-lock file: ${packageFile.name}`);
|
||||||
|
@ -439,7 +439,7 @@ export async function getAdditionalFiles(
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.warn({ err }, 'Error getting token for packageFile');
|
logger.warn({ err }, 'Error getting token for packageFile');
|
||||||
}
|
}
|
||||||
const { localDir } = getAdminConfig();
|
const { localDir } = getGlobalConfig();
|
||||||
for (const npmLock of dirs.npmLockDirs) {
|
for (const npmLock of dirs.npmLockDirs) {
|
||||||
const lockFileDir = upath.dirname(npmLock);
|
const lockFileDir = upath.dirname(npmLock);
|
||||||
const fullLockFileDir = upath.join(localDir, lockFileDir);
|
const fullLockFileDir = upath.join(localDir, lockFileDir);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { exec as _exec } from 'child_process';
|
import { exec as _exec } from 'child_process';
|
||||||
import { envMock, mockExecAll } from '../../../../test/exec-util';
|
import { envMock, mockExecAll } from '../../../../test/exec-util';
|
||||||
import { getName, mocked } from '../../../../test/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 _env from '../../../util/exec/env';
|
||||||
import * as _lernaHelper from './lerna';
|
import * as _lernaHelper from './lerna';
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
it('allows scripts for trust level high', async () => {
|
it('allows scripts for trust level high', async () => {
|
||||||
const execSnapshots = mockExecAll(exec);
|
const execSnapshots = mockExecAll(exec);
|
||||||
setAdminConfig({ allowScripts: true });
|
setGlobalConfig({ allowScripts: true });
|
||||||
const res = await lernaHelper.generateLockFiles(
|
const res = await lernaHelper.generateLockFiles(
|
||||||
lernaPkgFile('npm'),
|
lernaPkgFile('npm'),
|
||||||
'some-dir',
|
'some-dir',
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import semver, { validRange } from 'semver';
|
import semver, { validRange } from 'semver';
|
||||||
import { quote } from 'shlex';
|
import { quote } from 'shlex';
|
||||||
import { getAdminConfig } from '../../../config/admin';
|
import { getGlobalConfig } from '../../../config/admin';
|
||||||
import { TEMPORARY_ERROR } from '../../../constants/error-messages';
|
import { TEMPORARY_ERROR } from '../../../constants/error-messages';
|
||||||
import { logger } from '../../../logger';
|
import { logger } from '../../../logger';
|
||||||
import { ExecOptions, exec } from '../../../util/exec';
|
import { ExecOptions, exec } from '../../../util/exec';
|
||||||
|
@ -67,7 +67,7 @@ export async function generateLockFiles(
|
||||||
return { error: false };
|
return { error: false };
|
||||||
}
|
}
|
||||||
let lernaCommand = `lerna bootstrap --no-ci --ignore-scripts -- `;
|
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 ', '');
|
cmdOptions = cmdOptions.replace('--ignore-scripts ', '');
|
||||||
lernaCommand = lernaCommand.replace('--ignore-scripts ', '');
|
lernaCommand = lernaCommand.replace('--ignore-scripts ', '');
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ export async function generateLockFiles(
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
// istanbul ignore if
|
// istanbul ignore if
|
||||||
if (getAdminConfig().exposeAllEnv) {
|
if (getGlobalConfig().exposeAllEnv) {
|
||||||
execOptions.extraEnv.NPM_AUTH = env.NPM_AUTH;
|
execOptions.extraEnv.NPM_AUTH = env.NPM_AUTH;
|
||||||
execOptions.extraEnv.NPM_EMAIL = env.NPM_EMAIL;
|
execOptions.extraEnv.NPM_EMAIL = env.NPM_EMAIL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { validRange } from 'semver';
|
import { validRange } from 'semver';
|
||||||
import { quote } from 'shlex';
|
import { quote } from 'shlex';
|
||||||
import { join } from 'upath';
|
import { join } from 'upath';
|
||||||
import { getAdminConfig } from '../../../config/admin';
|
import { getGlobalConfig } from '../../../config/admin';
|
||||||
import {
|
import {
|
||||||
SYSTEM_INSUFFICIENT_DISK_SPACE,
|
SYSTEM_INSUFFICIENT_DISK_SPACE,
|
||||||
TEMPORARY_ERROR,
|
TEMPORARY_ERROR,
|
||||||
|
@ -52,7 +52,7 @@ export async function generateLockFile(
|
||||||
cmdOptions += '--package-lock-only --no-audit';
|
cmdOptions += '--package-lock-only --no-audit';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!getAdminConfig().allowScripts || config.ignoreScripts) {
|
if (!getGlobalConfig().allowScripts || config.ignoreScripts) {
|
||||||
cmdOptions += ' --ignore-scripts';
|
cmdOptions += ' --ignore-scripts';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ export async function generateLockFile(
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
// istanbul ignore if
|
// istanbul ignore if
|
||||||
if (getAdminConfig().exposeAllEnv) {
|
if (getGlobalConfig().exposeAllEnv) {
|
||||||
execOptions.extraEnv.NPM_AUTH = env.NPM_AUTH;
|
execOptions.extraEnv.NPM_AUTH = env.NPM_AUTH;
|
||||||
execOptions.extraEnv.NPM_EMAIL = env.NPM_EMAIL;
|
execOptions.extraEnv.NPM_EMAIL = env.NPM_EMAIL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { validRange } from 'semver';
|
import { validRange } from 'semver';
|
||||||
import { quote } from 'shlex';
|
import { quote } from 'shlex';
|
||||||
import { join } from 'upath';
|
import { join } from 'upath';
|
||||||
import { getAdminConfig } from '../../../config/admin';
|
import { getGlobalConfig } from '../../../config/admin';
|
||||||
import { TEMPORARY_ERROR } from '../../../constants/error-messages';
|
import { TEMPORARY_ERROR } from '../../../constants/error-messages';
|
||||||
import { logger } from '../../../logger';
|
import { logger } from '../../../logger';
|
||||||
import { ExecOptions, exec } from '../../../util/exec';
|
import { ExecOptions, exec } from '../../../util/exec';
|
||||||
|
@ -44,13 +44,13 @@ export async function generateLockFile(
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
// istanbul ignore if
|
// istanbul ignore if
|
||||||
if (getAdminConfig().exposeAllEnv) {
|
if (getGlobalConfig().exposeAllEnv) {
|
||||||
execOptions.extraEnv.NPM_AUTH = env.NPM_AUTH;
|
execOptions.extraEnv.NPM_AUTH = env.NPM_AUTH;
|
||||||
execOptions.extraEnv.NPM_EMAIL = env.NPM_EMAIL;
|
execOptions.extraEnv.NPM_EMAIL = env.NPM_EMAIL;
|
||||||
}
|
}
|
||||||
cmd = 'pnpm';
|
cmd = 'pnpm';
|
||||||
let args = 'install --recursive --lockfile-only';
|
let args = 'install --recursive --lockfile-only';
|
||||||
if (!getAdminConfig().allowScripts || config.ignoreScripts) {
|
if (!getGlobalConfig().allowScripts || config.ignoreScripts) {
|
||||||
args += ' --ignore-scripts';
|
args += ' --ignore-scripts';
|
||||||
args += ' --ignore-pnpmfile';
|
args += ' --ignore-pnpmfile';
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ import is from '@sindresorhus/is';
|
||||||
import { gte, minVersion, validRange } from 'semver';
|
import { gte, minVersion, validRange } from 'semver';
|
||||||
import { quote } from 'shlex';
|
import { quote } from 'shlex';
|
||||||
import { join } from 'upath';
|
import { join } from 'upath';
|
||||||
import { getAdminConfig } from '../../../config/admin';
|
import { getGlobalConfig } from '../../../config/admin';
|
||||||
import {
|
import {
|
||||||
SYSTEM_INSUFFICIENT_DISK_SPACE,
|
SYSTEM_INSUFFICIENT_DISK_SPACE,
|
||||||
TEMPORARY_ERROR,
|
TEMPORARY_ERROR,
|
||||||
|
@ -99,7 +99,7 @@ export async function generateLockFile(
|
||||||
extraEnv.YARN_HTTP_TIMEOUT = '100000';
|
extraEnv.YARN_HTTP_TIMEOUT = '100000';
|
||||||
extraEnv.YARN_GLOBAL_FOLDER = env.YARN_GLOBAL_FOLDER;
|
extraEnv.YARN_GLOBAL_FOLDER = env.YARN_GLOBAL_FOLDER;
|
||||||
}
|
}
|
||||||
if (!getAdminConfig().allowScripts || config.ignoreScripts) {
|
if (!getGlobalConfig().allowScripts || config.ignoreScripts) {
|
||||||
if (isYarn1) {
|
if (isYarn1) {
|
||||||
cmdOptions += ' --ignore-scripts';
|
cmdOptions += ' --ignore-scripts';
|
||||||
} else {
|
} else {
|
||||||
|
@ -118,7 +118,7 @@ export async function generateLockFile(
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
// istanbul ignore if
|
// istanbul ignore if
|
||||||
if (getAdminConfig().exposeAllEnv) {
|
if (getGlobalConfig().exposeAllEnv) {
|
||||||
execOptions.extraEnv.NPM_AUTH = env.NPM_AUTH;
|
execOptions.extraEnv.NPM_AUTH = env.NPM_AUTH;
|
||||||
execOptions.extraEnv.NPM_EMAIL = env.NPM_EMAIL;
|
execOptions.extraEnv.NPM_EMAIL = env.NPM_EMAIL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ import { exec as _exec } from 'child_process';
|
||||||
import { join } from 'upath';
|
import { join } from 'upath';
|
||||||
import { envMock, mockExecAll } from '../../../test/exec-util';
|
import { envMock, mockExecAll } from '../../../test/exec-util';
|
||||||
import { fs, mocked } from '../../../test/util';
|
import { fs, mocked } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import type { RepoAdminConfig } from '../../config/types';
|
import type { RepoGlobalConfig } from '../../config/types';
|
||||||
import * as docker from '../../util/exec/docker';
|
import * as docker from '../../util/exec/docker';
|
||||||
import * as _env from '../../util/exec/env';
|
import * as _env from '../../util/exec/env';
|
||||||
import * as _hostRules from '../../util/host-rules';
|
import * as _hostRules from '../../util/host-rules';
|
||||||
|
@ -31,7 +31,7 @@ const getRandomString: jest.Mock<typeof _getRandomString> =
|
||||||
_getRandomString as any;
|
_getRandomString as any;
|
||||||
const hostRules = mocked(_hostRules);
|
const hostRules = mocked(_hostRules);
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoGlobalConfig = {
|
||||||
// `join` fixes Windows CI
|
// `join` fixes Windows CI
|
||||||
localDir: join('/tmp/github/some/repo'),
|
localDir: join('/tmp/github/some/repo'),
|
||||||
cacheDir: join('/tmp/renovate/cache'),
|
cacheDir: join('/tmp/renovate/cache'),
|
||||||
|
@ -49,12 +49,12 @@ describe('updateArtifacts', () => {
|
||||||
Promise.resolve(`others/${dirName}`)
|
Promise.resolve(`others/${dirName}`)
|
||||||
);
|
);
|
||||||
getRandomString.mockReturnValue('not-so-random' as any);
|
getRandomString.mockReturnValue('not-so-random' as any);
|
||||||
setAdminConfig(adminConfig);
|
setGlobalConfig(adminConfig);
|
||||||
docker.resetPrefetchedImages();
|
docker.resetPrefetchedImages();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('aborts if no lock file found', async () => {
|
it('aborts if no lock file found', async () => {
|
||||||
|
@ -150,7 +150,7 @@ describe('updateArtifacts', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('supports docker mode', async () => {
|
it('supports docker mode', async () => {
|
||||||
setAdminConfig({ ...adminConfig, binarySource: 'docker' });
|
setGlobalConfig({ ...adminConfig, binarySource: 'docker' });
|
||||||
const execSnapshots = mockExecAll(exec);
|
const execSnapshots = mockExecAll(exec);
|
||||||
fs.getSiblingFileName.mockReturnValueOnce('packages.lock.json');
|
fs.getSiblingFileName.mockReturnValueOnce('packages.lock.json');
|
||||||
fs.readLocalFile.mockResolvedValueOnce('Current packages.lock.json' as any);
|
fs.readLocalFile.mockResolvedValueOnce('Current packages.lock.json' as any);
|
||||||
|
@ -166,7 +166,7 @@ describe('updateArtifacts', () => {
|
||||||
expect(execSnapshots).toMatchSnapshot();
|
expect(execSnapshots).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
it('supports global mode', async () => {
|
it('supports global mode', async () => {
|
||||||
setAdminConfig({ ...adminConfig, binarySource: 'global' });
|
setGlobalConfig({ ...adminConfig, binarySource: 'global' });
|
||||||
const execSnapshots = mockExecAll(exec);
|
const execSnapshots = mockExecAll(exec);
|
||||||
fs.getSiblingFileName.mockReturnValueOnce('packages.lock.json');
|
fs.getSiblingFileName.mockReturnValueOnce('packages.lock.json');
|
||||||
fs.readLocalFile.mockResolvedValueOnce('Current packages.lock.json' as any);
|
fs.readLocalFile.mockResolvedValueOnce('Current packages.lock.json' as any);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { getAdminConfig } from '../../config/admin';
|
import { getGlobalConfig } from '../../config/admin';
|
||||||
import { TEMPORARY_ERROR } from '../../constants/error-messages';
|
import { TEMPORARY_ERROR } from '../../constants/error-messages';
|
||||||
import { id, parseRegistryUrl } from '../../datasource/nuget';
|
import { id, parseRegistryUrl } from '../../datasource/nuget';
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
|
@ -29,7 +29,7 @@ async function addSourceCmds(
|
||||||
config: UpdateArtifactsConfig,
|
config: UpdateArtifactsConfig,
|
||||||
nugetConfigFile: string
|
nugetConfigFile: string
|
||||||
): Promise<string[]> {
|
): Promise<string[]> {
|
||||||
const { localDir } = getAdminConfig();
|
const { localDir } = getGlobalConfig();
|
||||||
const registries =
|
const registries =
|
||||||
(await getConfiguredRegistries(packageFileName, localDir)) ||
|
(await getConfiguredRegistries(packageFileName, localDir)) ||
|
||||||
getDefaultRegistries();
|
getDefaultRegistries();
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
import * as upath from 'upath';
|
import * as upath from 'upath';
|
||||||
import { getName, loadFixture } from '../../../test/util';
|
import { getName, loadFixture } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import type { RepoAdminConfig } from '../../config/types';
|
import type { RepoGlobalConfig } from '../../config/types';
|
||||||
import type { ExtractConfig } from '../types';
|
import type { ExtractConfig } from '../types';
|
||||||
import { extractPackageFile } from './extract';
|
import { extractPackageFile } from './extract';
|
||||||
|
|
||||||
const config: ExtractConfig = {};
|
const config: ExtractConfig = {};
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoGlobalConfig = {
|
||||||
localDir: upath.resolve('lib/manager/nuget/__fixtures__'),
|
localDir: upath.resolve('lib/manager/nuget/__fixtures__'),
|
||||||
};
|
};
|
||||||
|
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
describe('extractPackageFile()', () => {
|
describe('extractPackageFile()', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
setAdminConfig(adminConfig);
|
setGlobalConfig(adminConfig);
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
it('returns empty for invalid csproj', async () => {
|
it('returns empty for invalid csproj', async () => {
|
||||||
// FIXME: explicit assert condition
|
// FIXME: explicit assert condition
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { XmlDocument, XmlElement, XmlNode } from 'xmldoc';
|
import { XmlDocument, XmlElement, XmlNode } from 'xmldoc';
|
||||||
import { getAdminConfig } from '../../config/admin';
|
import { getGlobalConfig } from '../../config/admin';
|
||||||
import * as datasourceNuget from '../../datasource/nuget';
|
import * as datasourceNuget from '../../datasource/nuget';
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import { getSiblingFileName, localPathExists } from '../../util/fs';
|
import { getSiblingFileName, localPathExists } from '../../util/fs';
|
||||||
|
@ -71,7 +71,7 @@ export async function extractPackageFile(
|
||||||
): Promise<PackageFile | null> {
|
): Promise<PackageFile | null> {
|
||||||
logger.trace({ packageFile }, 'nuget.extractPackageFile()');
|
logger.trace({ packageFile }, 'nuget.extractPackageFile()');
|
||||||
|
|
||||||
const { localDir } = getAdminConfig();
|
const { localDir } = getGlobalConfig();
|
||||||
const registries = await getConfiguredRegistries(packageFile, localDir);
|
const registries = await getConfiguredRegistries(packageFile, localDir);
|
||||||
const registryUrls = registries
|
const registryUrls = registries
|
||||||
? registries.map((registry) => registry.url)
|
? registries.map((registry) => registry.url)
|
||||||
|
|
|
@ -3,8 +3,8 @@ import _fs from 'fs-extra';
|
||||||
import { join } from 'upath';
|
import { join } from 'upath';
|
||||||
import { envMock, mockExecAll } from '../../../test/exec-util';
|
import { envMock, mockExecAll } from '../../../test/exec-util';
|
||||||
import { git, mocked } from '../../../test/util';
|
import { git, mocked } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import type { RepoAdminConfig } from '../../config/types';
|
import type { RepoGlobalConfig } from '../../config/types';
|
||||||
import * as docker from '../../util/exec/docker';
|
import * as docker from '../../util/exec/docker';
|
||||||
import * as _env from '../../util/exec/env';
|
import * as _env from '../../util/exec/env';
|
||||||
import type { StatusResult } from '../../util/git';
|
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 exec: jest.Mock<typeof _exec> = _exec as any;
|
||||||
const env = mocked(_env);
|
const env = mocked(_env);
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoGlobalConfig = {
|
||||||
// `join` fixes Windows CI
|
// `join` fixes Windows CI
|
||||||
localDir: join('/tmp/github/some/repo'),
|
localDir: join('/tmp/github/some/repo'),
|
||||||
cacheDir: join('/tmp/renovate/cache'),
|
cacheDir: join('/tmp/renovate/cache'),
|
||||||
|
@ -40,7 +40,7 @@ describe('.updateArtifacts()', () => {
|
||||||
LANG: 'en_US.UTF-8',
|
LANG: 'en_US.UTF-8',
|
||||||
LC_ALL: 'en_US',
|
LC_ALL: 'en_US',
|
||||||
});
|
});
|
||||||
setAdminConfig(adminConfig);
|
setGlobalConfig(adminConfig);
|
||||||
docker.resetPrefetchedImages();
|
docker.resetPrefetchedImages();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ describe('.updateArtifacts()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('supports docker mode', async () => {
|
it('supports docker mode', async () => {
|
||||||
setAdminConfig(dockerAdminConfig);
|
setGlobalConfig(dockerAdminConfig);
|
||||||
const execSnapshots = mockExecAll(exec);
|
const execSnapshots = mockExecAll(exec);
|
||||||
git.getRepoStatus.mockResolvedValue({
|
git.getRepoStatus.mockResolvedValue({
|
||||||
modified: ['requirements.txt'],
|
modified: ['requirements.txt'],
|
||||||
|
@ -141,7 +141,7 @@ describe('.updateArtifacts()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('uses pipenv version from config', async () => {
|
it('uses pipenv version from config', async () => {
|
||||||
setAdminConfig(dockerAdminConfig);
|
setGlobalConfig(dockerAdminConfig);
|
||||||
const execSnapshots = mockExecAll(exec);
|
const execSnapshots = mockExecAll(exec);
|
||||||
git.getRepoStatus.mockResolvedValue({
|
git.getRepoStatus.mockResolvedValue({
|
||||||
modified: ['requirements.txt'],
|
modified: ['requirements.txt'],
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import _fs from 'fs-extra';
|
import _fs from 'fs-extra';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import type { UpdateArtifactsConfig } from '../types';
|
import type { UpdateArtifactsConfig } from '../types';
|
||||||
import { updateArtifacts } from './artifacts';
|
import { updateArtifacts } from './artifacts';
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ describe('.updateArtifacts()', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
jest.resetModules();
|
jest.resetModules();
|
||||||
setAdminConfig({ localDir: '' });
|
setGlobalConfig({ localDir: '' });
|
||||||
});
|
});
|
||||||
it('returns null if no updatedDeps were provided', async () => {
|
it('returns null if no updatedDeps were provided', async () => {
|
||||||
expect(
|
expect(
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { getName, loadFixture } from '../../../test/util';
|
import { getName, loadFixture } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import { extractPackageFile } from './extract';
|
import { extractPackageFile } from './extract';
|
||||||
|
|
||||||
const requirements1 = loadFixture('requirements1.txt');
|
const requirements1 = loadFixture('requirements1.txt');
|
||||||
|
@ -13,11 +13,11 @@ const requirements7 = loadFixture('requirements7.txt');
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
delete process.env.PIP_TEST_TOKEN;
|
delete process.env.PIP_TEST_TOKEN;
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
delete process.env.PIP_TEST_TOKEN;
|
delete process.env.PIP_TEST_TOKEN;
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
describe('extractPackageFile()', () => {
|
describe('extractPackageFile()', () => {
|
||||||
let config;
|
let config;
|
||||||
|
@ -123,7 +123,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
it('should replace env vars in high trust mode', () => {
|
it('should replace env vars in high trust mode', () => {
|
||||||
process.env.PIP_TEST_TOKEN = 'its-a-secret';
|
process.env.PIP_TEST_TOKEN = 'its-a-secret';
|
||||||
setAdminConfig({ exposeAllEnv: true });
|
setGlobalConfig({ exposeAllEnv: true });
|
||||||
const res = extractPackageFile(requirements7, 'unused_file_name', {});
|
const res = extractPackageFile(requirements7, 'unused_file_name', {});
|
||||||
expect(res.registryUrls).toEqual([
|
expect(res.registryUrls).toEqual([
|
||||||
'https://pypi.org/pypi/',
|
'https://pypi.org/pypi/',
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// based on https://www.python.org/dev/peps/pep-0508/#names
|
// based on https://www.python.org/dev/peps/pep-0508/#names
|
||||||
import { RANGE_PATTERN } from '@renovate/pep440/lib/specifier';
|
import { RANGE_PATTERN } from '@renovate/pep440/lib/specifier';
|
||||||
import { getAdminConfig } from '../../config/admin';
|
import { getGlobalConfig } from '../../config/admin';
|
||||||
import { PypiDatasource } from '../../datasource/pypi';
|
import { PypiDatasource } from '../../datasource/pypi';
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import { SkipReason } from '../../types';
|
import { SkipReason } from '../../types';
|
||||||
|
@ -85,7 +85,7 @@ export function extractPackageFile(
|
||||||
res.registryUrls = registryUrls.map((url) => {
|
res.registryUrls = registryUrls.map((url) => {
|
||||||
// handle the optional quotes in eg. `--extra-index-url "https://foo.bar"`
|
// handle the optional quotes in eg. `--extra-index-url "https://foo.bar"`
|
||||||
const cleaned = url.replace(/^"/, '').replace(/"$/, '');
|
const cleaned = url.replace(/^"/, '').replace(/"$/, '');
|
||||||
if (!getAdminConfig().exposeAllEnv) {
|
if (!getGlobalConfig().exposeAllEnv) {
|
||||||
return cleaned;
|
return cleaned;
|
||||||
}
|
}
|
||||||
// interpolate any environment variables
|
// interpolate any environment variables
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { envMock, exec, mockExecSequence } from '../../../test/exec-util';
|
import { envMock, exec, mockExecSequence } from '../../../test/exec-util';
|
||||||
import { env, getName } from '../../../test/util';
|
import { env, getName } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import {
|
import {
|
||||||
getPythonAlias,
|
getPythonAlias,
|
||||||
parsePythonVersion,
|
parsePythonVersion,
|
||||||
|
@ -18,7 +18,7 @@ describe(getName(), () => {
|
||||||
resetModule();
|
resetModule();
|
||||||
|
|
||||||
env.getChildProcessEnv.mockReturnValue(envMock.basic);
|
env.getChildProcessEnv.mockReturnValue(envMock.basic);
|
||||||
setAdminConfig({ localDir: '/tmp/foo/bar' });
|
setGlobalConfig({ localDir: '/tmp/foo/bar' });
|
||||||
});
|
});
|
||||||
describe('parsePythonVersion', () => {
|
describe('parsePythonVersion', () => {
|
||||||
it('returns major and minor version numbers', () => {
|
it('returns major and minor version numbers', () => {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { getAdminConfig } from '../../config/admin';
|
import { getGlobalConfig } from '../../config/admin';
|
||||||
import { PypiDatasource } from '../../datasource/pypi';
|
import { PypiDatasource } from '../../datasource/pypi';
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import { SkipReason } from '../../types';
|
import { SkipReason } from '../../types';
|
||||||
|
@ -49,7 +49,7 @@ export async function extractSetupFile(
|
||||||
let cmd = 'python';
|
let cmd = 'python';
|
||||||
const extractPy = await getExtractFile();
|
const extractPy = await getExtractFile();
|
||||||
const args = [`"${extractPy}"`, `"${packageFile}"`];
|
const args = [`"${extractPy}"`, `"${packageFile}"`];
|
||||||
if (getAdminConfig().binarySource !== 'docker') {
|
if (getGlobalConfig().binarySource !== 'docker') {
|
||||||
logger.debug('Running python via global command');
|
logger.debug('Running python via global command');
|
||||||
cmd = await getPythonAlias();
|
cmd = await getPythonAlias();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@ import {
|
||||||
mockExecSequence,
|
mockExecSequence,
|
||||||
} from '../../../test/exec-util';
|
} from '../../../test/exec-util';
|
||||||
import { env, getName, loadFixture } from '../../../test/util';
|
import { env, getName, loadFixture } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import type { RepoAdminConfig } from '../../config/types';
|
import type { RepoGlobalConfig } from '../../config/types';
|
||||||
import * as fs from '../../util/fs';
|
import * as fs from '../../util/fs';
|
||||||
import type { ExtractConfig } from '../types';
|
import type { ExtractConfig } from '../types';
|
||||||
import * as extract from './extract';
|
import * as extract from './extract';
|
||||||
|
@ -17,7 +17,7 @@ const packageFile = 'setup.py';
|
||||||
const content = loadFixture(packageFile);
|
const content = loadFixture(packageFile);
|
||||||
const jsonContent = loadFixture('setup.py.json');
|
const jsonContent = loadFixture('setup.py.json');
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoGlobalConfig = {
|
||||||
localDir: '/tmp/github/some/repo',
|
localDir: '/tmp/github/some/repo',
|
||||||
cacheDir: '/tmp/renovate/cache',
|
cacheDir: '/tmp/renovate/cache',
|
||||||
};
|
};
|
||||||
|
@ -46,7 +46,7 @@ describe(getName(), () => {
|
||||||
jest.resetModules();
|
jest.resetModules();
|
||||||
extract.resetModule();
|
extract.resetModule();
|
||||||
|
|
||||||
setAdminConfig(adminConfig);
|
setGlobalConfig(adminConfig);
|
||||||
env.getChildProcessEnv.mockReturnValue(envMock.basic);
|
env.getChildProcessEnv.mockReturnValue(envMock.basic);
|
||||||
|
|
||||||
// do not copy extract.py
|
// do not copy extract.py
|
||||||
|
@ -54,7 +54,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns found deps', async () => {
|
it('returns found deps', async () => {
|
||||||
|
@ -76,7 +76,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns found deps (docker)', async () => {
|
it('returns found deps (docker)', async () => {
|
||||||
setAdminConfig({ ...adminConfig, binarySource: 'docker' });
|
setGlobalConfig({ ...adminConfig, binarySource: 'docker' });
|
||||||
const execSnapshots = mockExecAll(exec, { stdout: '', stderr: '' });
|
const execSnapshots = mockExecAll(exec, { stdout: '', stderr: '' });
|
||||||
|
|
||||||
jest.spyOn(fs, 'readLocalFile').mockResolvedValueOnce(jsonContent);
|
jest.spyOn(fs, 'readLocalFile').mockResolvedValueOnce(jsonContent);
|
||||||
|
|
|
@ -3,8 +3,8 @@ import _fs from 'fs-extra';
|
||||||
import { join } from 'upath';
|
import { join } from 'upath';
|
||||||
import { envMock, mockExecAll } from '../../../test/exec-util';
|
import { envMock, mockExecAll } from '../../../test/exec-util';
|
||||||
import { git, mocked } from '../../../test/util';
|
import { git, mocked } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import type { RepoAdminConfig } from '../../config/types';
|
import type { RepoGlobalConfig } from '../../config/types';
|
||||||
import * as docker from '../../util/exec/docker';
|
import * as docker from '../../util/exec/docker';
|
||||||
import * as _env from '../../util/exec/env';
|
import * as _env from '../../util/exec/env';
|
||||||
import type { StatusResult } from '../../util/git';
|
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 exec: jest.Mock<typeof _exec> = _exec as any;
|
||||||
const env = mocked(_env);
|
const env = mocked(_env);
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoGlobalConfig = {
|
||||||
// `join` fixes Windows CI
|
// `join` fixes Windows CI
|
||||||
localDir: join('/tmp/github/some/repo'),
|
localDir: join('/tmp/github/some/repo'),
|
||||||
cacheDir: join('/tmp/renovate/cache'),
|
cacheDir: join('/tmp/renovate/cache'),
|
||||||
|
@ -42,7 +42,7 @@ describe('.updateArtifacts()', () => {
|
||||||
LC_ALL: 'en_US',
|
LC_ALL: 'en_US',
|
||||||
});
|
});
|
||||||
|
|
||||||
setAdminConfig(adminConfig);
|
setGlobalConfig(adminConfig);
|
||||||
docker.resetPrefetchedImages();
|
docker.resetPrefetchedImages();
|
||||||
pipFileLock = {
|
pipFileLock = {
|
||||||
_meta: { requires: {} },
|
_meta: { requires: {} },
|
||||||
|
@ -108,7 +108,7 @@ describe('.updateArtifacts()', () => {
|
||||||
expect(execSnapshots).toMatchSnapshot();
|
expect(execSnapshots).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
it('supports docker mode', async () => {
|
it('supports docker mode', async () => {
|
||||||
setAdminConfig(dockerAdminConfig);
|
setGlobalConfig(dockerAdminConfig);
|
||||||
pipFileLock._meta.requires.python_version = '3.7';
|
pipFileLock._meta.requires.python_version = '3.7';
|
||||||
fs.readFile.mockResolvedValueOnce(JSON.stringify(pipFileLock) as any);
|
fs.readFile.mockResolvedValueOnce(JSON.stringify(pipFileLock) as any);
|
||||||
const execSnapshots = mockExecAll(exec);
|
const execSnapshots = mockExecAll(exec);
|
||||||
|
@ -159,7 +159,7 @@ describe('.updateArtifacts()', () => {
|
||||||
expect(execSnapshots).toMatchSnapshot();
|
expect(execSnapshots).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
it('uses pipenv version from Pipfile', async () => {
|
it('uses pipenv version from Pipfile', async () => {
|
||||||
setAdminConfig(dockerAdminConfig);
|
setGlobalConfig(dockerAdminConfig);
|
||||||
pipFileLock.default.pipenv.version = '==2020.8.13';
|
pipFileLock.default.pipenv.version = '==2020.8.13';
|
||||||
fs.readFile.mockResolvedValueOnce(JSON.stringify(pipFileLock) as any);
|
fs.readFile.mockResolvedValueOnce(JSON.stringify(pipFileLock) as any);
|
||||||
const execSnapshots = mockExecAll(exec);
|
const execSnapshots = mockExecAll(exec);
|
||||||
|
@ -178,7 +178,7 @@ describe('.updateArtifacts()', () => {
|
||||||
expect(execSnapshots).toMatchSnapshot();
|
expect(execSnapshots).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
it('uses pipenv version from Pipfile dev packages', async () => {
|
it('uses pipenv version from Pipfile dev packages', async () => {
|
||||||
setAdminConfig(dockerAdminConfig);
|
setGlobalConfig(dockerAdminConfig);
|
||||||
pipFileLock.develop.pipenv.version = '==2020.8.13';
|
pipFileLock.develop.pipenv.version = '==2020.8.13';
|
||||||
fs.readFile.mockResolvedValueOnce(JSON.stringify(pipFileLock) as any);
|
fs.readFile.mockResolvedValueOnce(JSON.stringify(pipFileLock) as any);
|
||||||
const execSnapshots = mockExecAll(exec);
|
const execSnapshots = mockExecAll(exec);
|
||||||
|
@ -197,7 +197,7 @@ describe('.updateArtifacts()', () => {
|
||||||
expect(execSnapshots).toMatchSnapshot();
|
expect(execSnapshots).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
it('uses pipenv version from config', async () => {
|
it('uses pipenv version from config', async () => {
|
||||||
setAdminConfig(dockerAdminConfig);
|
setGlobalConfig(dockerAdminConfig);
|
||||||
pipFileLock.default.pipenv.version = '==2020.8.13';
|
pipFileLock.default.pipenv.version = '==2020.8.13';
|
||||||
fs.readFile.mockResolvedValueOnce(JSON.stringify(pipFileLock) as any);
|
fs.readFile.mockResolvedValueOnce(JSON.stringify(pipFileLock) as any);
|
||||||
const execSnapshots = mockExecAll(exec);
|
const execSnapshots = mockExecAll(exec);
|
||||||
|
|
|
@ -3,8 +3,8 @@ import _fs from 'fs-extra';
|
||||||
import { join } from 'upath';
|
import { join } from 'upath';
|
||||||
import { envMock, mockExecAll } from '../../../test/exec-util';
|
import { envMock, mockExecAll } from '../../../test/exec-util';
|
||||||
import { loadFixture, mocked } from '../../../test/util';
|
import { loadFixture, mocked } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import type { RepoAdminConfig } from '../../config/types';
|
import type { RepoGlobalConfig } from '../../config/types';
|
||||||
import * as _datasource from '../../datasource';
|
import * as _datasource from '../../datasource';
|
||||||
import * as docker from '../../util/exec/docker';
|
import * as docker from '../../util/exec/docker';
|
||||||
import * as _env from '../../util/exec/env';
|
import * as _env from '../../util/exec/env';
|
||||||
|
@ -26,7 +26,7 @@ const env = mocked(_env);
|
||||||
const datasource = mocked(_datasource);
|
const datasource = mocked(_datasource);
|
||||||
const hostRules = mocked(_hostRules);
|
const hostRules = mocked(_hostRules);
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoGlobalConfig = {
|
||||||
localDir: join('/tmp/github/some/repo'),
|
localDir: join('/tmp/github/some/repo'),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ describe('.updateArtifacts()', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
env.getChildProcessEnv.mockReturnValue(envMock.basic);
|
env.getChildProcessEnv.mockReturnValue(envMock.basic);
|
||||||
setAdminConfig(adminConfig);
|
setGlobalConfig(adminConfig);
|
||||||
docker.resetPrefetchedImages();
|
docker.resetPrefetchedImages();
|
||||||
});
|
});
|
||||||
it('returns null if no poetry.lock found', async () => {
|
it('returns null if no poetry.lock found', async () => {
|
||||||
|
@ -130,7 +130,7 @@ describe('.updateArtifacts()', () => {
|
||||||
expect(execSnapshots).toMatchSnapshot();
|
expect(execSnapshots).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
it('returns updated poetry.lock using docker', async () => {
|
it('returns updated poetry.lock using docker', async () => {
|
||||||
setAdminConfig({ ...adminConfig, binarySource: 'docker' });
|
setGlobalConfig({ ...adminConfig, binarySource: 'docker' });
|
||||||
fs.readFile.mockResolvedValueOnce('[metadata]\n' as any);
|
fs.readFile.mockResolvedValueOnce('[metadata]\n' as any);
|
||||||
const execSnapshots = mockExecAll(exec);
|
const execSnapshots = mockExecAll(exec);
|
||||||
fs.readFile.mockReturnValueOnce('New poetry.lock' as any);
|
fs.readFile.mockReturnValueOnce('New poetry.lock' as any);
|
||||||
|
@ -155,7 +155,7 @@ describe('.updateArtifacts()', () => {
|
||||||
expect(execSnapshots).toMatchSnapshot();
|
expect(execSnapshots).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
it('returns updated poetry.lock using docker (constraints)', async () => {
|
it('returns updated poetry.lock using docker (constraints)', async () => {
|
||||||
setAdminConfig({ ...adminConfig, binarySource: 'docker' });
|
setGlobalConfig({ ...adminConfig, binarySource: 'docker' });
|
||||||
fs.readFile.mockResolvedValueOnce(
|
fs.readFile.mockResolvedValueOnce(
|
||||||
'[metadata]\npython-versions = "~2.7 || ^3.4"' as any
|
'[metadata]\npython-versions = "~2.7 || ^3.4"' as any
|
||||||
);
|
);
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {
|
||||||
loadFixture,
|
loadFixture,
|
||||||
logger,
|
logger,
|
||||||
} from '../../../../test/util';
|
} from '../../../../test/util';
|
||||||
import { setAdminConfig } from '../../../config/admin';
|
import { setGlobalConfig } from '../../../config/admin';
|
||||||
import { TerraformProviderDatasource } from '../../../datasource/terraform-provider';
|
import { TerraformProviderDatasource } from '../../../datasource/terraform-provider';
|
||||||
import { Logger } from '../../../logger/types';
|
import { Logger } from '../../../logger/types';
|
||||||
import { TerraformProviderHash } from './hash';
|
import { TerraformProviderHash } from './hash';
|
||||||
|
@ -22,7 +22,7 @@ describe(getName(), () => {
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
cacheDir = await dir({ unsafeCleanup: true });
|
cacheDir = await dir({ unsafeCleanup: true });
|
||||||
setAdminConfig({ cacheDir: cacheDir.path });
|
setGlobalConfig({ cacheDir: cacheDir.path });
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => cacheDir.cleanup());
|
afterEach(() => cacheDir.cleanup());
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { join } from 'upath';
|
import { join } from 'upath';
|
||||||
import { fs, getName, loadFixture, mocked } from '../../../../test/util';
|
import { fs, getName, loadFixture, mocked } from '../../../../test/util';
|
||||||
import { setAdminConfig } from '../../../config/admin';
|
import { setGlobalConfig } from '../../../config/admin';
|
||||||
import { getPkgReleases } from '../../../datasource';
|
import { getPkgReleases } from '../../../datasource';
|
||||||
import type { UpdateArtifactsConfig } from '../../types';
|
import type { UpdateArtifactsConfig } from '../../types';
|
||||||
import { TerraformProviderHash } from './hash';
|
import { TerraformProviderHash } from './hash';
|
||||||
|
@ -32,7 +32,7 @@ describe(getName(), () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
jest.resetModules();
|
jest.resetModules();
|
||||||
setAdminConfig(adminConfig);
|
setGlobalConfig(adminConfig);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
|
4
lib/util/cache/repository/index.spec.ts
vendored
4
lib/util/cache/repository/index.spec.ts
vendored
|
@ -1,6 +1,6 @@
|
||||||
import * as _fs from 'fs-extra';
|
import * as _fs from 'fs-extra';
|
||||||
import { getName, mocked } from '../../../../test/util';
|
import { getName, mocked } from '../../../../test/util';
|
||||||
import { setAdminConfig } from '../../../config/admin';
|
import { setGlobalConfig } from '../../../config/admin';
|
||||||
import * as repositoryCache from '.';
|
import * as repositoryCache from '.';
|
||||||
|
|
||||||
jest.mock('fs-extra');
|
jest.mock('fs-extra');
|
||||||
|
@ -10,7 +10,7 @@ const fs = mocked(_fs);
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
setAdminConfig({ cacheDir: '/tmp/renovate/cache/' });
|
setGlobalConfig({ cacheDir: '/tmp/renovate/cache/' });
|
||||||
});
|
});
|
||||||
const config = {
|
const config = {
|
||||||
platform: 'github',
|
platform: 'github',
|
||||||
|
|
4
lib/util/cache/repository/index.ts
vendored
4
lib/util/cache/repository/index.ts
vendored
|
@ -1,6 +1,6 @@
|
||||||
import * as fs from 'fs-extra';
|
import * as fs from 'fs-extra';
|
||||||
import { join } from 'upath';
|
import { join } from 'upath';
|
||||||
import { getAdminConfig } from '../../../config/admin';
|
import { getGlobalConfig } from '../../../config/admin';
|
||||||
import type {
|
import type {
|
||||||
RenovateConfig,
|
RenovateConfig,
|
||||||
RepositoryCacheConfig,
|
RepositoryCacheConfig,
|
||||||
|
@ -17,7 +17,7 @@ let cache: Cache = Object.create({});
|
||||||
|
|
||||||
export function getCacheFileName(config: RenovateConfig): string {
|
export function getCacheFileName(config: RenovateConfig): string {
|
||||||
return join(
|
return join(
|
||||||
getAdminConfig().cacheDir,
|
getGlobalConfig().cacheDir,
|
||||||
'/renovate/repository/',
|
'/renovate/repository/',
|
||||||
config.platform,
|
config.platform,
|
||||||
config.repository + '.json'
|
config.repository + '.json'
|
||||||
|
|
|
@ -4,7 +4,7 @@ import {
|
||||||
mockExecSequence,
|
mockExecSequence,
|
||||||
} from '../../../../test/exec-util';
|
} from '../../../../test/exec-util';
|
||||||
import { getName } from '../../../../test/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 { SYSTEM_INSUFFICIENT_MEMORY } from '../../../constants/error-messages';
|
||||||
import { getPkgReleases as _getPkgReleases } from '../../../datasource';
|
import { getPkgReleases as _getPkgReleases } from '../../../datasource';
|
||||||
import { logger } from '../../../logger';
|
import { logger } from '../../../logger';
|
||||||
|
@ -132,12 +132,12 @@ describe(getName(), () => {
|
||||||
|
|
||||||
describe('removeDanglingContainers', () => {
|
describe('removeDanglingContainers', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
setAdminConfig({ binarySource: 'docker' });
|
setGlobalConfig({ binarySource: 'docker' });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('short-circuits in non-Docker environment', async () => {
|
it('short-circuits in non-Docker environment', async () => {
|
||||||
const execSnapshots = mockExecAll(exec);
|
const execSnapshots = mockExecAll(exec);
|
||||||
setAdminConfig({ binarySource: 'global' });
|
setGlobalConfig({ binarySource: 'global' });
|
||||||
await removeDanglingContainers();
|
await removeDanglingContainers();
|
||||||
expect(execSnapshots).toBeEmpty();
|
expect(execSnapshots).toBeEmpty();
|
||||||
});
|
});
|
||||||
|
@ -222,7 +222,7 @@ describe(getName(), () => {
|
||||||
`bash -l -c "foo && bar && baz"`;
|
`bash -l -c "foo && bar && baz"`;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
setAdminConfig({ dockerUser: 'some-user' });
|
setGlobalConfig({ dockerUser: 'some-user' });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns executable command', async () => {
|
it('returns executable command', async () => {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import is from '@sindresorhus/is';
|
import is from '@sindresorhus/is';
|
||||||
import { getAdminConfig } from '../../../config/admin';
|
import { getGlobalConfig } from '../../../config/admin';
|
||||||
import { SYSTEM_INSUFFICIENT_MEMORY } from '../../../constants/error-messages';
|
import { SYSTEM_INSUFFICIENT_MEMORY } from '../../../constants/error-messages';
|
||||||
import { getPkgReleases } from '../../../datasource';
|
import { getPkgReleases } from '../../../datasource';
|
||||||
import { logger } from '../../../logger';
|
import { logger } from '../../../logger';
|
||||||
|
@ -150,7 +150,7 @@ export async function removeDockerContainer(
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function removeDanglingContainers(): Promise<void> {
|
export async function removeDanglingContainers(): Promise<void> {
|
||||||
const { binarySource, dockerChildPrefix } = getAdminConfig();
|
const { binarySource, dockerChildPrefix } = getGlobalConfig();
|
||||||
if (binarySource !== 'docker') {
|
if (binarySource !== 'docker') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ export async function generateDockerCommand(
|
||||||
dockerUser,
|
dockerUser,
|
||||||
dockerChildPrefix,
|
dockerChildPrefix,
|
||||||
dockerImagePrefix,
|
dockerImagePrefix,
|
||||||
} = getAdminConfig();
|
} = getGlobalConfig();
|
||||||
const result = ['docker run --rm'];
|
const result = ['docker run --rm'];
|
||||||
const containerName = getContainerName(image, dockerChildPrefix);
|
const containerName = getContainerName(image, dockerChildPrefix);
|
||||||
const containerLabel = getContainerLabel(dockerChildPrefix);
|
const containerLabel = getContainerLabel(dockerChildPrefix);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import { getChildProcessEnv } from './env';
|
import { getChildProcessEnv } from './env';
|
||||||
|
|
||||||
describe('getChildProcess environment when trustlevel set to low', () => {
|
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', () => {
|
describe('getChildProcessEnv when trustlevel set to high', () => {
|
||||||
it('returns process.env if trustlevel set to high', () => {
|
it('returns process.env if trustlevel set to high', () => {
|
||||||
setAdminConfig({ exposeAllEnv: true });
|
setGlobalConfig({ exposeAllEnv: true });
|
||||||
expect(getChildProcessEnv()).toMatchObject(process.env);
|
expect(getChildProcessEnv()).toMatchObject(process.env);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { getAdminConfig } from '../../config/admin';
|
import { getGlobalConfig } from '../../config/admin';
|
||||||
|
|
||||||
const basicEnvVars = [
|
const basicEnvVars = [
|
||||||
'HTTP_PROXY',
|
'HTTP_PROXY',
|
||||||
|
@ -20,7 +20,7 @@ export function getChildProcessEnv(
|
||||||
customEnvVars: string[] = []
|
customEnvVars: string[] = []
|
||||||
): NodeJS.ProcessEnv {
|
): NodeJS.ProcessEnv {
|
||||||
const env: NodeJS.ProcessEnv = {};
|
const env: NodeJS.ProcessEnv = {};
|
||||||
if (getAdminConfig().exposeAllEnv) {
|
if (getGlobalConfig().exposeAllEnv) {
|
||||||
return { ...env, ...process.env };
|
return { ...env, ...process.env };
|
||||||
}
|
}
|
||||||
const envVars = [...basicEnvVars, ...customEnvVars];
|
const envVars = [...basicEnvVars, ...customEnvVars];
|
||||||
|
|
|
@ -5,8 +5,8 @@ import {
|
||||||
} from 'child_process';
|
} from 'child_process';
|
||||||
import { envMock } from '../../../test/exec-util';
|
import { envMock } from '../../../test/exec-util';
|
||||||
import { getName } from '../../../test/util';
|
import { getName } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import type { RepoAdminConfig } from '../../config/types';
|
import type { RepoGlobalConfig } from '../../config/types';
|
||||||
import { TEMPORARY_ERROR } from '../../constants/error-messages';
|
import { TEMPORARY_ERROR } from '../../constants/error-messages';
|
||||||
import { RawExecOptions, VolumeOption } from './common';
|
import { RawExecOptions, VolumeOption } from './common';
|
||||||
import * as dockerModule from './docker';
|
import * as dockerModule from './docker';
|
||||||
|
@ -22,7 +22,7 @@ interface TestInput {
|
||||||
inOpts: ExecOptions;
|
inOpts: ExecOptions;
|
||||||
outCmd: string[];
|
outCmd: string[];
|
||||||
outOpts: RawExecOptions[];
|
outOpts: RawExecOptions[];
|
||||||
adminConfig?: Partial<RepoAdminConfig>;
|
adminConfig?: Partial<RepoGlobalConfig>;
|
||||||
}
|
}
|
||||||
|
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
|
@ -40,7 +40,7 @@ describe(getName(), () => {
|
||||||
jest.restoreAllMocks();
|
jest.restoreAllMocks();
|
||||||
jest.resetModules();
|
jest.resetModules();
|
||||||
processEnvOrig = process.env;
|
processEnvOrig = process.env;
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
@ -677,7 +677,7 @@ describe(getName(), () => {
|
||||||
callback(null, { stdout: '', stderr: '' });
|
callback(null, { stdout: '', stderr: '' });
|
||||||
return undefined;
|
return undefined;
|
||||||
});
|
});
|
||||||
setAdminConfig({ cacheDir, localDir: cwd, ...adminConfig });
|
setGlobalConfig({ cacheDir, localDir: cwd, ...adminConfig });
|
||||||
await exec(cmd as string, inOpts);
|
await exec(cmd as string, inOpts);
|
||||||
|
|
||||||
expect(actualCmd).toEqual(outCommand);
|
expect(actualCmd).toEqual(outCommand);
|
||||||
|
@ -694,19 +694,19 @@ describe(getName(), () => {
|
||||||
return undefined;
|
return undefined;
|
||||||
});
|
});
|
||||||
|
|
||||||
setAdminConfig({ binarySource: 'global' });
|
setGlobalConfig({ binarySource: 'global' });
|
||||||
await exec(inCmd, { docker });
|
await exec(inCmd, { docker });
|
||||||
await exec(inCmd, { docker });
|
await exec(inCmd, { docker });
|
||||||
|
|
||||||
setAdminConfig({ binarySource: 'docker' });
|
setGlobalConfig({ binarySource: 'docker' });
|
||||||
await exec(inCmd, { docker });
|
await exec(inCmd, { docker });
|
||||||
await exec(inCmd, { docker });
|
await exec(inCmd, { docker });
|
||||||
|
|
||||||
setAdminConfig({ binarySource: 'global' });
|
setGlobalConfig({ binarySource: 'global' });
|
||||||
await exec(inCmd, { docker });
|
await exec(inCmd, { docker });
|
||||||
await exec(inCmd, { docker });
|
await exec(inCmd, { docker });
|
||||||
|
|
||||||
setAdminConfig({ binarySource: 'docker' });
|
setGlobalConfig({ binarySource: 'docker' });
|
||||||
await exec(inCmd, { docker });
|
await exec(inCmd, { docker });
|
||||||
await exec(inCmd, { docker });
|
await exec(inCmd, { docker });
|
||||||
|
|
||||||
|
@ -730,7 +730,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('wraps error if removeDockerContainer throws an error', async () => {
|
it('wraps error if removeDockerContainer throws an error', async () => {
|
||||||
setAdminConfig({ binarySource: 'docker' });
|
setGlobalConfig({ binarySource: 'docker' });
|
||||||
cpExec.mockImplementation(() => {
|
cpExec.mockImplementation(() => {
|
||||||
throw new Error('some error occurred');
|
throw new Error('some error occurred');
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import type { ExecOptions as ChildProcessExecOptions } from 'child_process';
|
import type { ExecOptions as ChildProcessExecOptions } from 'child_process';
|
||||||
import { dirname, join } from 'upath';
|
import { dirname, join } from 'upath';
|
||||||
import { getAdminConfig } from '../../config/admin';
|
import { getGlobalConfig } from '../../config/admin';
|
||||||
import { TEMPORARY_ERROR } from '../../constants/error-messages';
|
import { TEMPORARY_ERROR } from '../../constants/error-messages';
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import {
|
import {
|
||||||
|
@ -25,7 +25,7 @@ function getChildEnv({
|
||||||
extraEnv = {},
|
extraEnv = {},
|
||||||
env: forcedEnv = {},
|
env: forcedEnv = {},
|
||||||
}: ExecOptions): ExtraEnv<string> {
|
}: ExecOptions): ExtraEnv<string> {
|
||||||
const { customEnvVariables: globalConfigEnv } = getAdminConfig();
|
const { customEnvVariables: globalConfigEnv } = getGlobalConfig();
|
||||||
|
|
||||||
const inheritedKeys = Object.entries(extraEnv).reduce(
|
const inheritedKeys = Object.entries(extraEnv).reduce(
|
||||||
(acc, [key, val]) =>
|
(acc, [key, val]) =>
|
||||||
|
@ -59,7 +59,7 @@ function dockerEnvVars(
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCwd({ cwd, cwdFile }: ExecOptions): string {
|
function getCwd({ cwd, cwdFile }: ExecOptions): string {
|
||||||
const { localDir: defaultCwd } = getAdminConfig();
|
const { localDir: defaultCwd } = getGlobalConfig();
|
||||||
const paramCwd = cwdFile ? join(defaultCwd, dirname(cwdFile)) : cwd;
|
const paramCwd = cwdFile ? join(defaultCwd, dirname(cwdFile)) : cwd;
|
||||||
return paramCwd || defaultCwd;
|
return paramCwd || defaultCwd;
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ function getRawExecOptions(opts: ExecOptions): RawExecOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
function isDocker({ docker }: ExecOptions): boolean {
|
function isDocker({ docker }: ExecOptions): boolean {
|
||||||
const { binarySource } = getAdminConfig();
|
const { binarySource } = getGlobalConfig();
|
||||||
return binarySource === 'docker' && !!docker;
|
return binarySource === 'docker' && !!docker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ async function prepareRawExec(
|
||||||
opts: ExecOptions = {}
|
opts: ExecOptions = {}
|
||||||
): Promise<RawExecArguments> {
|
): Promise<RawExecArguments> {
|
||||||
const { docker } = opts;
|
const { docker } = opts;
|
||||||
const { customEnvVariables } = getAdminConfig();
|
const { customEnvVariables } = getGlobalConfig();
|
||||||
|
|
||||||
const rawOptions = getRawExecOptions(opts);
|
const rawOptions = getRawExecOptions(opts);
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ export async function exec(
|
||||||
opts: ExecOptions = {}
|
opts: ExecOptions = {}
|
||||||
): Promise<ExecResult> {
|
): Promise<ExecResult> {
|
||||||
const { docker } = opts;
|
const { docker } = opts;
|
||||||
const { dockerChildPrefix } = getAdminConfig();
|
const { dockerChildPrefix } = getGlobalConfig();
|
||||||
|
|
||||||
const { rawCommands, rawOptions } = await prepareRawExec(cmd, opts);
|
const { rawCommands, rawOptions } = await prepareRawExec(cmd, opts);
|
||||||
const useDocker = isDocker(opts);
|
const useDocker = isDocker(opts);
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { withDir } from 'tmp-promise';
|
||||||
import { join } from 'upath';
|
import { join } from 'upath';
|
||||||
import { envMock } from '../../../test/exec-util';
|
import { envMock } from '../../../test/exec-util';
|
||||||
import { getName, mocked } from '../../../test/util';
|
import { getName, mocked } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import * as _env from '../exec/env';
|
import * as _env from '../exec/env';
|
||||||
import {
|
import {
|
||||||
ensureCacheDir,
|
ensureCacheDir,
|
||||||
|
@ -22,7 +22,7 @@ const env = mocked(_env);
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
describe('readLocalFile', () => {
|
describe('readLocalFile', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
setAdminConfig({ localDir: '' });
|
setGlobalConfig({ localDir: '' });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('reads buffer', async () => {
|
it('reads buffer', async () => {
|
||||||
|
@ -60,7 +60,7 @@ describe(getName(), () => {
|
||||||
it('returns path for file', async () => {
|
it('returns path for file', async () => {
|
||||||
await withDir(
|
await withDir(
|
||||||
async (localDir) => {
|
async (localDir) => {
|
||||||
setAdminConfig({
|
setGlobalConfig({
|
||||||
localDir: localDir.path,
|
localDir: localDir.path,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ describe(getName(), () => {
|
||||||
it('returns dir content', async () => {
|
it('returns dir content', async () => {
|
||||||
await withDir(
|
await withDir(
|
||||||
async (localDir) => {
|
async (localDir) => {
|
||||||
setAdminConfig({
|
setGlobalConfig({
|
||||||
localDir: localDir.path,
|
localDir: localDir.path,
|
||||||
});
|
});
|
||||||
await writeLocalFile('test/Cargo.toml', '');
|
await writeLocalFile('test/Cargo.toml', '');
|
||||||
|
@ -142,7 +142,7 @@ describe(getName(), () => {
|
||||||
it('return empty array for non existing directory', async () => {
|
it('return empty array for non existing directory', async () => {
|
||||||
await withDir(
|
await withDir(
|
||||||
async (localDir) => {
|
async (localDir) => {
|
||||||
setAdminConfig({
|
setGlobalConfig({
|
||||||
localDir: localDir.path,
|
localDir: localDir.path,
|
||||||
});
|
});
|
||||||
await expect(readLocalDirectory('somedir')).rejects.toThrow();
|
await expect(readLocalDirectory('somedir')).rejects.toThrow();
|
||||||
|
@ -174,7 +174,7 @@ describe(getName(), () => {
|
||||||
...envMock.basic,
|
...envMock.basic,
|
||||||
});
|
});
|
||||||
|
|
||||||
setAdminConfig({
|
setGlobalConfig({
|
||||||
cacheDir: join(dirFromConfig),
|
cacheDir: join(dirFromConfig),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import util from 'util';
|
||||||
import is from '@sindresorhus/is';
|
import is from '@sindresorhus/is';
|
||||||
import * as fs from 'fs-extra';
|
import * as fs from 'fs-extra';
|
||||||
import { isAbsolute, join, parse } from 'upath';
|
import { isAbsolute, join, parse } from 'upath';
|
||||||
import { getAdminConfig } from '../../config/admin';
|
import { getGlobalConfig } from '../../config/admin';
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
|
|
||||||
export * from './proxies';
|
export * from './proxies';
|
||||||
|
@ -31,7 +31,7 @@ export async function readLocalFile(
|
||||||
fileName: string,
|
fileName: string,
|
||||||
encoding?: string
|
encoding?: string
|
||||||
): Promise<string | Buffer> {
|
): Promise<string | Buffer> {
|
||||||
const { localDir } = getAdminConfig();
|
const { localDir } = getGlobalConfig();
|
||||||
const localFileName = join(localDir, fileName);
|
const localFileName = join(localDir, fileName);
|
||||||
try {
|
try {
|
||||||
const fileContent = await fs.readFile(localFileName, encoding);
|
const fileContent = await fs.readFile(localFileName, encoding);
|
||||||
|
@ -46,13 +46,13 @@ export async function writeLocalFile(
|
||||||
fileName: string,
|
fileName: string,
|
||||||
fileContent: string
|
fileContent: string
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const { localDir } = getAdminConfig();
|
const { localDir } = getGlobalConfig();
|
||||||
const localFileName = join(localDir, fileName);
|
const localFileName = join(localDir, fileName);
|
||||||
await fs.outputFile(localFileName, fileContent);
|
await fs.outputFile(localFileName, fileContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteLocalFile(fileName: string): Promise<void> {
|
export async function deleteLocalFile(fileName: string): Promise<void> {
|
||||||
const { localDir } = getAdminConfig();
|
const { localDir } = getGlobalConfig();
|
||||||
if (localDir) {
|
if (localDir) {
|
||||||
const localFileName = join(localDir, fileName);
|
const localFileName = join(localDir, fileName);
|
||||||
await fs.remove(localFileName);
|
await fs.remove(localFileName);
|
||||||
|
@ -64,7 +64,7 @@ export async function renameLocalFile(
|
||||||
fromFile: string,
|
fromFile: string,
|
||||||
toFile: string
|
toFile: string
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const { localDir } = getAdminConfig();
|
const { localDir } = getGlobalConfig();
|
||||||
await fs.move(join(localDir, fromFile), join(localDir, toFile));
|
await fs.move(join(localDir, fromFile), join(localDir, toFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,13 +77,13 @@ export async function ensureDir(dirName: string): Promise<void> {
|
||||||
|
|
||||||
// istanbul ignore next
|
// istanbul ignore next
|
||||||
export async function ensureLocalDir(dirName: string): Promise<void> {
|
export async function ensureLocalDir(dirName: string): Promise<void> {
|
||||||
const { localDir } = getAdminConfig();
|
const { localDir } = getGlobalConfig();
|
||||||
const localDirName = join(localDir, dirName);
|
const localDirName = join(localDir, dirName);
|
||||||
await fs.ensureDir(localDirName);
|
await fs.ensureDir(localDirName);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function ensureCacheDir(name: string): Promise<string> {
|
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);
|
await fs.ensureDir(cacheDirName);
|
||||||
return 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.
|
* without risk of that information leaking to other repositories/users.
|
||||||
*/
|
*/
|
||||||
export function privateCacheDir(): string {
|
export function privateCacheDir(): string {
|
||||||
const { cacheDir } = getAdminConfig();
|
const { cacheDir } = getGlobalConfig();
|
||||||
return join(cacheDir, '__renovate-private-cache');
|
return join(cacheDir, '__renovate-private-cache');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function localPathExists(pathName: string): Promise<boolean> {
|
export function localPathExists(pathName: string): Promise<boolean> {
|
||||||
const { localDir } = getAdminConfig();
|
const { localDir } = getGlobalConfig();
|
||||||
// Works for both files as well as directories
|
// Works for both files as well as directories
|
||||||
return fs
|
return fs
|
||||||
.stat(join(localDir, pathName))
|
.stat(join(localDir, pathName))
|
||||||
|
@ -140,7 +140,7 @@ export async function findLocalSiblingOrParent(
|
||||||
* Get files by name from directory
|
* Get files by name from directory
|
||||||
*/
|
*/
|
||||||
export async function readLocalDirectory(path: string): Promise<string[]> {
|
export async function readLocalDirectory(path: string): Promise<string[]> {
|
||||||
const { localDir } = getAdminConfig();
|
const { localDir } = getGlobalConfig();
|
||||||
const localPath = join(localDir, path);
|
const localPath = join(localDir, path);
|
||||||
const fileList = await fs.readdir(localPath);
|
const fileList = await fs.readdir(localPath);
|
||||||
return fileList;
|
return fileList;
|
||||||
|
|
|
@ -3,7 +3,7 @@ import Git from 'simple-git';
|
||||||
import SimpleGit from 'simple-git/src/git';
|
import SimpleGit from 'simple-git/src/git';
|
||||||
import tmp from 'tmp-promise';
|
import tmp from 'tmp-promise';
|
||||||
import { getName } from '../../../test/util';
|
import { getName } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import * as git from '.';
|
import * as git from '.';
|
||||||
import { GitNoVerifyOption, setNoVerify } from '.';
|
import { GitNoVerifyOption, setNoVerify } from '.';
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ describe(getName(), () => {
|
||||||
await repo.clone(base.path, '.', ['--bare']);
|
await repo.clone(base.path, '.', ['--bare']);
|
||||||
await repo.addConfig('commit.gpgsign', 'false');
|
await repo.addConfig('commit.gpgsign', 'false');
|
||||||
tmpDir = await tmp.dir({ unsafeCleanup: true });
|
tmpDir = await tmp.dir({ unsafeCleanup: true });
|
||||||
setAdminConfig({ localDir: tmpDir.path });
|
setGlobalConfig({ localDir: tmpDir.path });
|
||||||
await git.initRepo({
|
await git.initRepo({
|
||||||
url: origin.path,
|
url: origin.path,
|
||||||
gitAuthorName: 'Jest',
|
gitAuthorName: 'Jest',
|
||||||
|
|
|
@ -9,7 +9,7 @@ import Git, {
|
||||||
TaskOptions,
|
TaskOptions,
|
||||||
} from 'simple-git';
|
} from 'simple-git';
|
||||||
import { join } from 'upath';
|
import { join } from 'upath';
|
||||||
import { getAdminConfig } from '../../config/admin';
|
import { getGlobalConfig } from '../../config/admin';
|
||||||
import { configFileNames } from '../../config/app-strings';
|
import { configFileNames } from '../../config/app-strings';
|
||||||
import type { RenovateConfig } from '../../config/types';
|
import type { RenovateConfig } from '../../config/types';
|
||||||
import {
|
import {
|
||||||
|
@ -185,7 +185,7 @@ export async function initRepo(args: StorageConfig): Promise<void> {
|
||||||
config.ignoredAuthors = [];
|
config.ignoredAuthors = [];
|
||||||
config.additionalBranches = [];
|
config.additionalBranches = [];
|
||||||
config.branchIsModified = {};
|
config.branchIsModified = {};
|
||||||
const { localDir } = getAdminConfig();
|
const { localDir } = getGlobalConfig();
|
||||||
git = Git(localDir);
|
git = Git(localDir);
|
||||||
gitInitialized = false;
|
gitInitialized = false;
|
||||||
await fetchBranchCommits();
|
await fetchBranchCommits();
|
||||||
|
@ -267,7 +267,7 @@ export async function syncGit(): Promise<void> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gitInitialized = true;
|
gitInitialized = true;
|
||||||
const { localDir } = getAdminConfig();
|
const { localDir } = getGlobalConfig();
|
||||||
logger.debug('Initializing git repository into ' + localDir);
|
logger.debug('Initializing git repository into ' + localDir);
|
||||||
const gitHead = join(localDir, '.git/HEAD');
|
const gitHead = join(localDir, '.git/HEAD');
|
||||||
let clone = true;
|
let clone = true;
|
||||||
|
@ -708,7 +708,7 @@ export async function commitFiles({
|
||||||
await writePrivateKey();
|
await writePrivateKey();
|
||||||
privateKeySet = true;
|
privateKeySet = true;
|
||||||
}
|
}
|
||||||
const { localDir } = getAdminConfig();
|
const { localDir } = getGlobalConfig();
|
||||||
await configSigningKey(localDir);
|
await configSigningKey(localDir);
|
||||||
try {
|
try {
|
||||||
await git.reset(ResetMode.HARD);
|
await git.reset(ResetMode.HARD);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import is from '@sindresorhus/is';
|
import is from '@sindresorhus/is';
|
||||||
import * as handlebars from 'handlebars';
|
import * as handlebars from 'handlebars';
|
||||||
import { getAdminConfig } from '../../config/admin';
|
import { getGlobalConfig } from '../../config/admin';
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import { clone } from '../clone';
|
import { clone } from '../clone';
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ export function compile(
|
||||||
input: CompileInput,
|
input: CompileInput,
|
||||||
filterFields = true
|
filterFields = true
|
||||||
): string {
|
): string {
|
||||||
const data = { ...getAdminConfig(), ...input };
|
const data = { ...getGlobalConfig(), ...input };
|
||||||
const filteredInput = filterFields ? getFilteredObject(data) : data;
|
const filteredInput = filterFields ? getFilteredObject(data) : data;
|
||||||
logger.trace({ template, filteredInput }, 'Compiling template');
|
logger.trace({ template, filteredInput }, 'Compiling template');
|
||||||
if (filterFields) {
|
if (filterFields) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { defaultConfig, getName, git, platform } from '../../../test/util';
|
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 type { RenovateConfig } from '../../config/types';
|
||||||
import { BranchStatus } from '../../types';
|
import { BranchStatus } from '../../types';
|
||||||
import { tryBranchAutomerge } from './automerge';
|
import { tryBranchAutomerge } from './automerge';
|
||||||
|
@ -13,7 +13,7 @@ describe(getName(), () => {
|
||||||
config = {
|
config = {
|
||||||
...defaultConfig,
|
...defaultConfig,
|
||||||
};
|
};
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
it('returns false if not configured for automerge', async () => {
|
it('returns false if not configured for automerge', async () => {
|
||||||
config.automerge = false;
|
config.automerge = false;
|
||||||
|
@ -63,7 +63,7 @@ describe(getName(), () => {
|
||||||
it('returns true if automerge succeeds (dry-run)', async () => {
|
it('returns true if automerge succeeds (dry-run)', async () => {
|
||||||
config.automerge = true;
|
config.automerge = true;
|
||||||
config.automergeType = 'branch';
|
config.automergeType = 'branch';
|
||||||
setAdminConfig({ dryRun: true });
|
setGlobalConfig({ dryRun: true });
|
||||||
platform.getBranchStatus.mockResolvedValueOnce(BranchStatus.green);
|
platform.getBranchStatus.mockResolvedValueOnce(BranchStatus.green);
|
||||||
expect(await tryBranchAutomerge(config)).toBe('automerged');
|
expect(await tryBranchAutomerge(config)).toBe('automerged');
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { getAdminConfig } from '../../config/admin';
|
import { getGlobalConfig } from '../../config/admin';
|
||||||
import type { RenovateConfig } from '../../config/types';
|
import type { RenovateConfig } from '../../config/types';
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import { platform } from '../../platform';
|
import { platform } from '../../platform';
|
||||||
|
@ -32,7 +32,7 @@ export async function tryBranchAutomerge(
|
||||||
if (branchStatus === BranchStatus.green) {
|
if (branchStatus === BranchStatus.green) {
|
||||||
logger.debug(`Automerging branch`);
|
logger.debug(`Automerging branch`);
|
||||||
try {
|
try {
|
||||||
if (getAdminConfig().dryRun) {
|
if (getGlobalConfig().dryRun) {
|
||||||
logger.info('DRY-RUN: Would automerge branch' + config.branchName);
|
logger.info('DRY-RUN: Would automerge branch' + config.branchName);
|
||||||
} else {
|
} else {
|
||||||
await mergeBranch(config.branchName);
|
await mergeBranch(config.branchName);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { defaultConfig, getName, git, partial } from '../../../test/util';
|
import { defaultConfig, getName, git, partial } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import type { BranchConfig } from '../types';
|
import type { BranchConfig } from '../types';
|
||||||
import { commitFilesToBranch } from './commit';
|
import { commitFilesToBranch } from './commit';
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
git.commitFiles.mockResolvedValueOnce('abc123');
|
git.commitFiles.mockResolvedValueOnce('abc123');
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
it('handles empty files', async () => {
|
it('handles empty files', async () => {
|
||||||
await commitFilesToBranch(config);
|
await commitFilesToBranch(config);
|
||||||
|
@ -37,7 +37,7 @@ describe(getName(), () => {
|
||||||
expect(git.commitFiles.mock.calls).toMatchSnapshot();
|
expect(git.commitFiles.mock.calls).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
it('dry runs', async () => {
|
it('dry runs', async () => {
|
||||||
setAdminConfig({ dryRun: true });
|
setGlobalConfig({ dryRun: true });
|
||||||
config.updatedPackageFiles.push({
|
config.updatedPackageFiles.push({
|
||||||
name: 'package.json',
|
name: 'package.json',
|
||||||
contents: 'some contents',
|
contents: 'some contents',
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import is from '@sindresorhus/is';
|
import is from '@sindresorhus/is';
|
||||||
import minimatch from 'minimatch';
|
import minimatch from 'minimatch';
|
||||||
import { getAdminConfig } from '../../config/admin';
|
import { getGlobalConfig } from '../../config/admin';
|
||||||
import { CONFIG_SECRETS_EXPOSED } from '../../constants/error-messages';
|
import { CONFIG_SECRETS_EXPOSED } from '../../constants/error-messages';
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import { commitFiles } from '../../util/git';
|
import { commitFiles } from '../../util/git';
|
||||||
|
@ -32,7 +32,7 @@ export function commitFilesToBranch(
|
||||||
const fileLength = [...new Set(updatedFiles.map((file) => file.name))].length;
|
const fileLength = [...new Set(updatedFiles.map((file) => file.name))].length;
|
||||||
logger.debug(`${fileLength} file(s) to commit`);
|
logger.debug(`${fileLength} file(s) to commit`);
|
||||||
// istanbul ignore if
|
// istanbul ignore if
|
||||||
if (getAdminConfig().dryRun) {
|
if (getGlobalConfig().dryRun) {
|
||||||
logger.info('DRY-RUN: Would commit files to branch ' + config.branchName);
|
logger.info('DRY-RUN: Would commit files to branch ' + config.branchName);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import is from '@sindresorhus/is';
|
import is from '@sindresorhus/is';
|
||||||
import minimatch from 'minimatch';
|
import minimatch from 'minimatch';
|
||||||
import { getAdminConfig } from '../../config/admin';
|
import { getGlobalConfig } from '../../config/admin';
|
||||||
import { addMeta, logger } from '../../logger';
|
import { addMeta, logger } from '../../logger';
|
||||||
import type { ArtifactError } from '../../manager/types';
|
import type { ArtifactError } from '../../manager/types';
|
||||||
import { exec } from '../../util/exec';
|
import { exec } from '../../util/exec';
|
||||||
|
@ -23,7 +23,7 @@ export async function postUpgradeCommandsExecutor(
|
||||||
let updatedArtifacts = [...(config.updatedArtifacts || [])];
|
let updatedArtifacts = [...(config.updatedArtifacts || [])];
|
||||||
const artifactErrors = [...(config.artifactErrors || [])];
|
const artifactErrors = [...(config.artifactErrors || [])];
|
||||||
const { allowedPostUpgradeCommands, allowPostUpgradeCommandTemplating } =
|
const { allowedPostUpgradeCommands, allowPostUpgradeCommandTemplating } =
|
||||||
getAdminConfig();
|
getGlobalConfig();
|
||||||
|
|
||||||
for (const upgrade of filteredUpgradeCommands) {
|
for (const upgrade of filteredUpgradeCommands) {
|
||||||
addMeta({ dep: upgrade.depName });
|
addMeta({ dep: upgrade.depName });
|
||||||
|
@ -62,7 +62,7 @@ export async function postUpgradeCommandsExecutor(
|
||||||
|
|
||||||
logger.debug({ cmd: compiledCmd }, 'Executing post-upgrade task');
|
logger.debug({ cmd: compiledCmd }, 'Executing post-upgrade task');
|
||||||
const execResult = await exec(compiledCmd, {
|
const execResult = await exec(compiledCmd, {
|
||||||
cwd: getAdminConfig().localDir,
|
cwd: getGlobalConfig().localDir,
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
|
@ -149,7 +149,7 @@ export async function postUpgradeCommandsExecutor(
|
||||||
export default async function executePostUpgradeCommands(
|
export default async function executePostUpgradeCommands(
|
||||||
config: BranchConfig
|
config: BranchConfig
|
||||||
): Promise<PostUpgradeCommandsExecutionResult | null> {
|
): Promise<PostUpgradeCommandsExecutionResult | null> {
|
||||||
const { allowedPostUpgradeCommands } = getAdminConfig();
|
const { allowedPostUpgradeCommands } = getGlobalConfig();
|
||||||
|
|
||||||
const hasChangedFiles =
|
const hasChangedFiles =
|
||||||
config.updatedPackageFiles?.length > 0 ||
|
config.updatedPackageFiles?.length > 0 ||
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { getAdminConfig } from '../../config/admin';
|
import { getGlobalConfig } from '../../config/admin';
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import { Pr, platform } from '../../platform';
|
import { Pr, platform } from '../../platform';
|
||||||
import { PrState } from '../../types';
|
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.';
|
'\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')) {
|
if (!config.suppressNotifications.includes('prIgnoreNotification')) {
|
||||||
const ignoreTopic = `Renovate Ignore Notification`;
|
const ignoreTopic = `Renovate Ignore Notification`;
|
||||||
if (getAdminConfig().dryRun) {
|
if (getGlobalConfig().dryRun) {
|
||||||
logger.info(
|
logger.info(
|
||||||
`DRY-RUN: Would ensure closed PR comment in PR #${pr.number}`
|
`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 (branchExists(config.branchName)) {
|
||||||
if (getAdminConfig().dryRun) {
|
if (getGlobalConfig().dryRun) {
|
||||||
logger.info('DRY-RUN: Would delete branch ' + config.branchName);
|
logger.info('DRY-RUN: Would delete branch ' + config.branchName);
|
||||||
} else {
|
} else {
|
||||||
await deleteBranch(config.branchName);
|
await deleteBranch(config.branchName);
|
||||||
|
|
|
@ -6,8 +6,8 @@ import {
|
||||||
mocked,
|
mocked,
|
||||||
platform,
|
platform,
|
||||||
} from '../../../test/util';
|
} from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import type { RepoAdminConfig } from '../../config/types';
|
import type { RepoGlobalConfig } from '../../config/types';
|
||||||
import {
|
import {
|
||||||
MANAGER_LOCKFILE_ERROR,
|
MANAGER_LOCKFILE_ERROR,
|
||||||
REPOSITORY_CHANGED,
|
REPOSITORY_CHANGED,
|
||||||
|
@ -66,7 +66,7 @@ const sanitize = mocked(_sanitize);
|
||||||
const fs = mocked(_fs);
|
const fs = mocked(_fs);
|
||||||
const limits = mocked(_limits);
|
const limits = mocked(_limits);
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = { localDir: '', cacheDir: '' };
|
const adminConfig: RepoGlobalConfig = { localDir: '', cacheDir: '' };
|
||||||
|
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
describe('processBranch', () => {
|
describe('processBranch', () => {
|
||||||
|
@ -99,7 +99,7 @@ describe(getName(), () => {
|
||||||
body: '',
|
body: '',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
setAdminConfig(adminConfig);
|
setGlobalConfig(adminConfig);
|
||||||
sanitize.sanitize.mockImplementation((input) => input);
|
sanitize.sanitize.mockImplementation((input) => input);
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
@ -107,7 +107,7 @@ describe(getName(), () => {
|
||||||
platform.ensureCommentRemoval.mockClear();
|
platform.ensureCommentRemoval.mockClear();
|
||||||
commit.commitFilesToBranch.mockClear();
|
commit.commitFilesToBranch.mockClear();
|
||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
it('skips branch if not scheduled and branch does not exist', async () => {
|
it('skips branch if not scheduled and branch does not exist', async () => {
|
||||||
schedule.isScheduledNow.mockReturnValueOnce(false);
|
schedule.isScheduledNow.mockReturnValueOnce(false);
|
||||||
|
@ -433,7 +433,7 @@ describe(getName(), () => {
|
||||||
git.branchExists.mockReturnValue(true);
|
git.branchExists.mockReturnValue(true);
|
||||||
commit.commitFilesToBranch.mockResolvedValueOnce(null);
|
commit.commitFilesToBranch.mockResolvedValueOnce(null);
|
||||||
automerge.tryBranchAutomerge.mockResolvedValueOnce('automerged');
|
automerge.tryBranchAutomerge.mockResolvedValueOnce('automerged');
|
||||||
setAdminConfig({ ...adminConfig, dryRun: true });
|
setGlobalConfig({ ...adminConfig, dryRun: true });
|
||||||
await branchWorker.processBranch(config);
|
await branchWorker.processBranch(config);
|
||||||
expect(automerge.tryBranchAutomerge).toHaveBeenCalledTimes(1);
|
expect(automerge.tryBranchAutomerge).toHaveBeenCalledTimes(1);
|
||||||
expect(prWorker.ensurePr).toHaveBeenCalledTimes(0);
|
expect(prWorker.ensurePr).toHaveBeenCalledTimes(0);
|
||||||
|
@ -738,7 +738,7 @@ describe(getName(), () => {
|
||||||
checkExisting.prAlreadyExisted.mockResolvedValueOnce({
|
checkExisting.prAlreadyExisted.mockResolvedValueOnce({
|
||||||
state: PrState.Closed,
|
state: PrState.Closed,
|
||||||
} as Pr);
|
} as Pr);
|
||||||
setAdminConfig({ ...adminConfig, dryRun: true });
|
setGlobalConfig({ ...adminConfig, dryRun: true });
|
||||||
// FIXME: explicit assert condition
|
// FIXME: explicit assert condition
|
||||||
expect(await branchWorker.processBranch(config)).toMatchSnapshot();
|
expect(await branchWorker.processBranch(config)).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
@ -749,7 +749,7 @@ describe(getName(), () => {
|
||||||
state: PrState.Open,
|
state: PrState.Open,
|
||||||
} as Pr);
|
} as Pr);
|
||||||
git.isBranchModified.mockResolvedValueOnce(true);
|
git.isBranchModified.mockResolvedValueOnce(true);
|
||||||
setAdminConfig({ ...adminConfig, dryRun: true });
|
setGlobalConfig({ ...adminConfig, dryRun: true });
|
||||||
// FIXME: explicit assert condition
|
// FIXME: explicit assert condition
|
||||||
expect(await branchWorker.processBranch(config)).toMatchSnapshot();
|
expect(await branchWorker.processBranch(config)).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
@ -772,7 +772,7 @@ describe(getName(), () => {
|
||||||
git.isBranchModified.mockResolvedValueOnce(true);
|
git.isBranchModified.mockResolvedValueOnce(true);
|
||||||
schedule.isScheduledNow.mockReturnValueOnce(false);
|
schedule.isScheduledNow.mockReturnValueOnce(false);
|
||||||
commit.commitFilesToBranch.mockResolvedValueOnce(null);
|
commit.commitFilesToBranch.mockResolvedValueOnce(null);
|
||||||
setAdminConfig({ ...adminConfig, dryRun: true });
|
setGlobalConfig({ ...adminConfig, dryRun: true });
|
||||||
// FIXME: explicit assert condition
|
// FIXME: explicit assert condition
|
||||||
expect(
|
expect(
|
||||||
await branchWorker.processBranch({
|
await branchWorker.processBranch({
|
||||||
|
@ -805,7 +805,7 @@ describe(getName(), () => {
|
||||||
pr: {},
|
pr: {},
|
||||||
} as EnsurePrResult);
|
} as EnsurePrResult);
|
||||||
commit.commitFilesToBranch.mockResolvedValueOnce(null);
|
commit.commitFilesToBranch.mockResolvedValueOnce(null);
|
||||||
setAdminConfig({ ...adminConfig, dryRun: true });
|
setGlobalConfig({ ...adminConfig, dryRun: true });
|
||||||
// FIXME: explicit assert condition
|
// FIXME: explicit assert condition
|
||||||
expect(
|
expect(
|
||||||
await branchWorker.processBranch({
|
await branchWorker.processBranch({
|
||||||
|
@ -881,7 +881,7 @@ describe(getName(), () => {
|
||||||
schedule.isScheduledNow.mockReturnValueOnce(false);
|
schedule.isScheduledNow.mockReturnValueOnce(false);
|
||||||
commit.commitFilesToBranch.mockResolvedValueOnce(null);
|
commit.commitFilesToBranch.mockResolvedValueOnce(null);
|
||||||
|
|
||||||
setAdminConfig({
|
setGlobalConfig({
|
||||||
...adminConfig,
|
...adminConfig,
|
||||||
allowedPostUpgradeCommands: ['^echo {{{versioning}}}$'],
|
allowedPostUpgradeCommands: ['^echo {{{versioning}}}$'],
|
||||||
allowPostUpgradeCommandTemplating: true,
|
allowPostUpgradeCommandTemplating: true,
|
||||||
|
@ -959,7 +959,7 @@ describe(getName(), () => {
|
||||||
schedule.isScheduledNow.mockReturnValueOnce(false);
|
schedule.isScheduledNow.mockReturnValueOnce(false);
|
||||||
commit.commitFilesToBranch.mockResolvedValueOnce(null);
|
commit.commitFilesToBranch.mockResolvedValueOnce(null);
|
||||||
|
|
||||||
setAdminConfig({
|
setGlobalConfig({
|
||||||
...adminConfig,
|
...adminConfig,
|
||||||
allowedPostUpgradeCommands: ['^exit 1$'],
|
allowedPostUpgradeCommands: ['^exit 1$'],
|
||||||
allowPostUpgradeCommandTemplating: true,
|
allowPostUpgradeCommandTemplating: true,
|
||||||
|
@ -1028,7 +1028,7 @@ describe(getName(), () => {
|
||||||
|
|
||||||
schedule.isScheduledNow.mockReturnValueOnce(false);
|
schedule.isScheduledNow.mockReturnValueOnce(false);
|
||||||
commit.commitFilesToBranch.mockResolvedValueOnce(null);
|
commit.commitFilesToBranch.mockResolvedValueOnce(null);
|
||||||
setAdminConfig({
|
setGlobalConfig({
|
||||||
...adminConfig,
|
...adminConfig,
|
||||||
allowedPostUpgradeCommands: ['^echo {{{versioning}}}$'],
|
allowedPostUpgradeCommands: ['^echo {{{versioning}}}$'],
|
||||||
allowPostUpgradeCommandTemplating: false,
|
allowPostUpgradeCommandTemplating: false,
|
||||||
|
@ -1109,7 +1109,7 @@ describe(getName(), () => {
|
||||||
schedule.isScheduledNow.mockReturnValueOnce(false);
|
schedule.isScheduledNow.mockReturnValueOnce(false);
|
||||||
commit.commitFilesToBranch.mockResolvedValueOnce(null);
|
commit.commitFilesToBranch.mockResolvedValueOnce(null);
|
||||||
|
|
||||||
setAdminConfig({
|
setGlobalConfig({
|
||||||
...adminConfig,
|
...adminConfig,
|
||||||
allowedPostUpgradeCommands: ['^echo {{{depName}}}$'],
|
allowedPostUpgradeCommands: ['^echo {{{depName}}}$'],
|
||||||
allowPostUpgradeCommandTemplating: true,
|
allowPostUpgradeCommandTemplating: true,
|
||||||
|
@ -1244,7 +1244,7 @@ describe(getName(), () => {
|
||||||
schedule.isScheduledNow.mockReturnValueOnce(false);
|
schedule.isScheduledNow.mockReturnValueOnce(false);
|
||||||
commit.commitFilesToBranch.mockResolvedValueOnce(null);
|
commit.commitFilesToBranch.mockResolvedValueOnce(null);
|
||||||
|
|
||||||
setAdminConfig({
|
setGlobalConfig({
|
||||||
...adminConfig,
|
...adminConfig,
|
||||||
allowedPostUpgradeCommands: ['^echo hardcoded-string$'],
|
allowedPostUpgradeCommands: ['^echo hardcoded-string$'],
|
||||||
allowPostUpgradeCommandTemplating: true,
|
allowPostUpgradeCommandTemplating: true,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
import { getAdminConfig } from '../../config/admin';
|
import { getGlobalConfig } from '../../config/admin';
|
||||||
import type { RenovateConfig } from '../../config/types';
|
import type { RenovateConfig } from '../../config/types';
|
||||||
import {
|
import {
|
||||||
CONFIG_VALIDATION,
|
CONFIG_VALIDATION,
|
||||||
|
@ -416,7 +416,7 @@ export async function processBranch(
|
||||||
} else if (config.updatedArtifacts?.length && branchPr) {
|
} else if (config.updatedArtifacts?.length && branchPr) {
|
||||||
// If there are artifacts, no errors, and an existing PR then ensure any artifacts error comment is removed
|
// If there are artifacts, no errors, and an existing PR then ensure any artifacts error comment is removed
|
||||||
// istanbul ignore if
|
// istanbul ignore if
|
||||||
if (getAdminConfig().dryRun) {
|
if (getGlobalConfig().dryRun) {
|
||||||
logger.info(
|
logger.info(
|
||||||
`DRY-RUN: Would ensure comment removal in PR #${branchPr.number}`
|
`DRY-RUN: Would ensure comment removal in PR #${branchPr.number}`
|
||||||
);
|
);
|
||||||
|
@ -479,7 +479,7 @@ export async function processBranch(
|
||||||
const mergeStatus = await tryBranchAutomerge(config);
|
const mergeStatus = await tryBranchAutomerge(config);
|
||||||
logger.debug(`mergeStatus=${mergeStatus}`);
|
logger.debug(`mergeStatus=${mergeStatus}`);
|
||||||
if (mergeStatus === 'automerged') {
|
if (mergeStatus === 'automerged') {
|
||||||
if (getAdminConfig().dryRun) {
|
if (getGlobalConfig().dryRun) {
|
||||||
logger.info('DRY-RUN: Would delete branch' + config.branchName);
|
logger.info('DRY-RUN: Would delete branch' + config.branchName);
|
||||||
} else {
|
} else {
|
||||||
await deleteBranchSilently(config.branchName);
|
await deleteBranchSilently(config.branchName);
|
||||||
|
@ -657,7 +657,7 @@ export async function processBranch(
|
||||||
config.suppressNotifications.includes('lockFileErrors')
|
config.suppressNotifications.includes('lockFileErrors')
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
if (getAdminConfig().dryRun) {
|
if (getGlobalConfig().dryRun) {
|
||||||
logger.info(
|
logger.info(
|
||||||
`DRY-RUN: Would ensure lock file error comment in PR #${pr.number}`
|
`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
|
// Check if state needs setting
|
||||||
if (existingState !== state) {
|
if (existingState !== state) {
|
||||||
logger.debug(`Updating status check state to failed`);
|
logger.debug(`Updating status check state to failed`);
|
||||||
if (getAdminConfig().dryRun) {
|
if (getGlobalConfig().dryRun) {
|
||||||
logger.info(
|
logger.info(
|
||||||
'DRY-RUN: Would set branch status in ' + config.branchName
|
'DRY-RUN: Would set branch status in ' + config.branchName
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { getName, git, mocked } from '../../../../test/util';
|
import { getName, git, mocked } from '../../../../test/util';
|
||||||
import { setAdminConfig } from '../../../config/admin';
|
import { setGlobalConfig } from '../../../config/admin';
|
||||||
import { getConfig } from '../../../config/defaults';
|
import { getConfig } from '../../../config/defaults';
|
||||||
import * as _lockFiles from '../../../manager/npm/post-update';
|
import * as _lockFiles from '../../../manager/npm/post-update';
|
||||||
import * as _lerna from '../../../manager/npm/post-update/lerna';
|
import * as _lerna from '../../../manager/npm/post-update/lerna';
|
||||||
|
@ -31,7 +31,7 @@ const { writeUpdatedPackageFiles, getAdditionalFiles } = lockFiles;
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
describe('writeUpdatedPackageFiles', () => {
|
describe('writeUpdatedPackageFiles', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
setAdminConfig({
|
setGlobalConfig({
|
||||||
localDir: 'some-tmp-dir',
|
localDir: 'some-tmp-dir',
|
||||||
});
|
});
|
||||||
fs.outputFile = jest.fn();
|
fs.outputFile = jest.fn();
|
||||||
|
@ -70,7 +70,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
describe('getAdditionalFiles', () => {
|
describe('getAdditionalFiles', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
setAdminConfig({
|
setGlobalConfig({
|
||||||
localDir: 'some-tmp-dir',
|
localDir: 'some-tmp-dir',
|
||||||
});
|
});
|
||||||
git.getFile.mockResolvedValueOnce('some lock file contents');
|
git.getFile.mockResolvedValueOnce('some lock file contents');
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { getAdminConfig } from '../../config/admin';
|
import { getGlobalConfig } from '../../config/admin';
|
||||||
import type { RenovateConfig } from '../../config/types';
|
import type { RenovateConfig } from '../../config/types';
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import { platform } from '../../platform';
|
import { platform } from '../../platform';
|
||||||
|
@ -35,7 +35,7 @@ export async function shouldReuseExistingBranch(
|
||||||
if (pr.labels?.includes(config.rebaseLabel)) {
|
if (pr.labels?.includes(config.rebaseLabel)) {
|
||||||
logger.debug(`Manual rebase requested via PR labels for #${pr.number}`);
|
logger.debug(`Manual rebase requested via PR labels for #${pr.number}`);
|
||||||
// istanbul ignore if
|
// istanbul ignore if
|
||||||
if (getAdminConfig().dryRun) {
|
if (getGlobalConfig().dryRun) {
|
||||||
logger.info(
|
logger.info(
|
||||||
`DRY-RUN: Would delete label ${config.rebaseLabel} from #${pr.number}`
|
`DRY-RUN: Would delete label ${config.rebaseLabel} from #${pr.number}`
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { getAdminConfig } from '../../config/admin';
|
import { getGlobalConfig } from '../../config/admin';
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import { Pr, platform } from '../../platform';
|
import { Pr, platform } from '../../platform';
|
||||||
import { BranchStatus } from '../../types';
|
import { BranchStatus } from '../../types';
|
||||||
|
@ -75,7 +75,7 @@ export async function checkAutoMerge(
|
||||||
if (automergeType === 'pr-comment') {
|
if (automergeType === 'pr-comment') {
|
||||||
logger.debug(`Applying automerge comment: ${automergeComment}`);
|
logger.debug(`Applying automerge comment: ${automergeComment}`);
|
||||||
// istanbul ignore if
|
// istanbul ignore if
|
||||||
if (getAdminConfig().dryRun) {
|
if (getGlobalConfig().dryRun) {
|
||||||
logger.info(
|
logger.info(
|
||||||
`DRY-RUN: Would add PR automerge comment to PR #${pr.number}`
|
`DRY-RUN: Would add PR automerge comment to PR #${pr.number}`
|
||||||
);
|
);
|
||||||
|
@ -99,7 +99,7 @@ export async function checkAutoMerge(
|
||||||
}
|
}
|
||||||
// Let's merge this
|
// Let's merge this
|
||||||
// istanbul ignore if
|
// istanbul ignore if
|
||||||
if (getAdminConfig().dryRun) {
|
if (getGlobalConfig().dryRun) {
|
||||||
logger.info(
|
logger.info(
|
||||||
`DRY-RUN: Would merge PR #${pr.number} with strategy "${automergeStrategy}"`
|
`DRY-RUN: Would merge PR #${pr.number} with strategy "${automergeStrategy}"`
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { getAdminConfig } from '../../config/admin';
|
import { getGlobalConfig } from '../../config/admin';
|
||||||
import type { RenovateConfig } from '../../config/types';
|
import type { RenovateConfig } from '../../config/types';
|
||||||
import {
|
import {
|
||||||
PLATFORM_INTEGRATION_UNAUTHORIZED,
|
PLATFORM_INTEGRATION_UNAUTHORIZED,
|
||||||
|
@ -67,7 +67,7 @@ export async function addAssigneesReviewers(
|
||||||
}
|
}
|
||||||
if (assignees.length > 0) {
|
if (assignees.length > 0) {
|
||||||
// istanbul ignore if
|
// istanbul ignore if
|
||||||
if (getAdminConfig().dryRun) {
|
if (getGlobalConfig().dryRun) {
|
||||||
logger.info(`DRY-RUN: Would add assignees to PR #${pr.number}`);
|
logger.info(`DRY-RUN: Would add assignees to PR #${pr.number}`);
|
||||||
} else {
|
} else {
|
||||||
await platform.addAssignees(pr.number, assignees);
|
await platform.addAssignees(pr.number, assignees);
|
||||||
|
@ -96,7 +96,7 @@ export async function addAssigneesReviewers(
|
||||||
}
|
}
|
||||||
if (reviewers.length > 0) {
|
if (reviewers.length > 0) {
|
||||||
// istanbul ignore if
|
// istanbul ignore if
|
||||||
if (getAdminConfig().dryRun) {
|
if (getGlobalConfig().dryRun) {
|
||||||
logger.info(`DRY-RUN: Would add reviewers to PR #${pr.number}`);
|
logger.info(`DRY-RUN: Would add reviewers to PR #${pr.number}`);
|
||||||
} else {
|
} else {
|
||||||
await platform.addReviewers(pr.number, reviewers);
|
await platform.addReviewers(pr.number, reviewers);
|
||||||
|
@ -383,7 +383,7 @@ export async function ensurePr(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// istanbul ignore if
|
// istanbul ignore if
|
||||||
if (getAdminConfig().dryRun) {
|
if (getGlobalConfig().dryRun) {
|
||||||
logger.info(`DRY-RUN: Would update PR #${existingPr.number}`);
|
logger.info(`DRY-RUN: Would update PR #${existingPr.number}`);
|
||||||
} else {
|
} else {
|
||||||
await platform.updatePr({
|
await platform.updatePr({
|
||||||
|
@ -406,7 +406,7 @@ export async function ensurePr(
|
||||||
let pr: Pr;
|
let pr: Pr;
|
||||||
try {
|
try {
|
||||||
// istanbul ignore if
|
// istanbul ignore if
|
||||||
if (getAdminConfig().dryRun) {
|
if (getGlobalConfig().dryRun) {
|
||||||
logger.info('DRY-RUN: Would create PR: ' + prTitle);
|
logger.info('DRY-RUN: Would create PR: ' + prTitle);
|
||||||
pr = { number: 0, displayNumber: 'Dry run PR' } as never;
|
pr = { number: 0, displayNumber: 'Dry run PR' } as never;
|
||||||
} else {
|
} else {
|
||||||
|
@ -449,7 +449,7 @@ export async function ensurePr(
|
||||||
{ branch: branchName },
|
{ branch: branchName },
|
||||||
'Deleting branch due to server error'
|
'Deleting branch due to server error'
|
||||||
);
|
);
|
||||||
if (getAdminConfig().dryRun) {
|
if (getGlobalConfig().dryRun) {
|
||||||
logger.info('DRY-RUN: Would delete branch: ' + config.branchName);
|
logger.info('DRY-RUN: Would delete branch: ' + config.branchName);
|
||||||
} else {
|
} else {
|
||||||
await deleteBranch(branchName);
|
await deleteBranch(branchName);
|
||||||
|
@ -470,7 +470,7 @@ export async function ensurePr(
|
||||||
content = platform.massageMarkdown(content);
|
content = platform.massageMarkdown(content);
|
||||||
logger.debug('Adding branch automerge failure message to PR');
|
logger.debug('Adding branch automerge failure message to PR');
|
||||||
// istanbul ignore if
|
// istanbul ignore if
|
||||||
if (getAdminConfig().dryRun) {
|
if (getGlobalConfig().dryRun) {
|
||||||
logger.info(`DRY-RUN: Would add comment to PR #${pr.number}`);
|
logger.info(`DRY-RUN: Would add comment to PR #${pr.number}`);
|
||||||
} else {
|
} else {
|
||||||
await platform.ensureComment({
|
await platform.ensureComment({
|
||||||
|
|
|
@ -8,7 +8,7 @@ import {
|
||||||
logger,
|
logger,
|
||||||
platform,
|
platform,
|
||||||
} from '../../../test/util';
|
} from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import { PLATFORM_TYPE_GITHUB } from '../../constants/platforms';
|
import { PLATFORM_TYPE_GITHUB } from '../../constants/platforms';
|
||||||
import type { Platform } from '../../platform';
|
import type { Platform } from '../../platform';
|
||||||
import { BranchConfig, BranchResult, BranchUpgradeConfig } from '../types';
|
import { BranchConfig, BranchResult, BranchUpgradeConfig } from '../types';
|
||||||
|
@ -33,7 +33,7 @@ async function dryRun(
|
||||||
ensureIssueCalls = 0
|
ensureIssueCalls = 0
|
||||||
) {
|
) {
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
setAdminConfig({ dryRun: true });
|
setGlobalConfig({ dryRun: true });
|
||||||
await dependencyDashboard.ensureDependencyDashboard(config, branches);
|
await dependencyDashboard.ensureDependencyDashboard(config, branches);
|
||||||
expect(platform.ensureIssueClosing).toHaveBeenCalledTimes(
|
expect(platform.ensureIssueClosing).toHaveBeenCalledTimes(
|
||||||
ensureIssueClosingCalls
|
ensureIssueClosingCalls
|
||||||
|
@ -61,7 +61,7 @@ describe(getName(), () => {
|
||||||
|
|
||||||
describe('ensureDependencyDashboard()', () => {
|
describe('ensureDependencyDashboard()', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
it('do nothing if dependencyDashboard is disabled', async () => {
|
it('do nothing if dependencyDashboard is disabled', async () => {
|
||||||
const branches: BranchConfig[] = [];
|
const branches: BranchConfig[] = [];
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import is from '@sindresorhus/is';
|
import is from '@sindresorhus/is';
|
||||||
import { nameFromLevel } from 'bunyan';
|
import { nameFromLevel } from 'bunyan';
|
||||||
import { getAdminConfig } from '../../config/admin';
|
import { getGlobalConfig } from '../../config/admin';
|
||||||
import type { RenovateConfig } from '../../config/types';
|
import type { RenovateConfig } from '../../config/types';
|
||||||
import { getProblems, logger } from '../../logger';
|
import { getProblems, logger } from '../../logger';
|
||||||
import { platform } from '../../platform';
|
import { platform } from '../../platform';
|
||||||
|
@ -125,7 +125,7 @@ export async function ensureDependencyDashboard(
|
||||||
is.nonEmptyArray(branches) &&
|
is.nonEmptyArray(branches) &&
|
||||||
branches.some((branch) => branch.result !== BranchResult.Automerged);
|
branches.some((branch) => branch.result !== BranchResult.Automerged);
|
||||||
if (config.dependencyDashboardAutoclose && !hasBranches) {
|
if (config.dependencyDashboardAutoclose && !hasBranches) {
|
||||||
if (getAdminConfig().dryRun) {
|
if (getGlobalConfig().dryRun) {
|
||||||
logger.info(
|
logger.info(
|
||||||
'DRY-RUN: Would close Dependency Dashboard ' +
|
'DRY-RUN: Would close Dependency Dashboard ' +
|
||||||
config.dependencyDashboardTitle
|
config.dependencyDashboardTitle
|
||||||
|
@ -338,7 +338,7 @@ export async function ensureDependencyDashboard(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getAdminConfig().dryRun) {
|
if (getGlobalConfig().dryRun) {
|
||||||
logger.info(
|
logger.info(
|
||||||
'DRY-RUN: Would ensure Dependency Dashboard ' +
|
'DRY-RUN: Would ensure Dependency Dashboard ' +
|
||||||
config.dependencyDashboardTitle
|
config.dependencyDashboardTitle
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {
|
||||||
getName,
|
getName,
|
||||||
platform,
|
platform,
|
||||||
} from '../../../test/util';
|
} from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import { CONFIG_VALIDATION } from '../../constants/error-messages';
|
import { CONFIG_VALIDATION } from '../../constants/error-messages';
|
||||||
import { Pr } from '../../platform';
|
import { Pr } from '../../platform';
|
||||||
import { PrState } from '../../types';
|
import { PrState } from '../../types';
|
||||||
|
@ -22,7 +22,7 @@ beforeEach(() => {
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
describe('raiseConfigWarningIssue()', () => {
|
describe('raiseConfigWarningIssue()', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
it('creates issues', async () => {
|
it('creates issues', async () => {
|
||||||
const error = new Error(CONFIG_VALIDATION);
|
const error = new Error(CONFIG_VALIDATION);
|
||||||
|
@ -37,7 +37,7 @@ describe(getName(), () => {
|
||||||
error.validationSource = 'package.json';
|
error.validationSource = 'package.json';
|
||||||
error.validationMessage = 'some-message';
|
error.validationMessage = 'some-message';
|
||||||
platform.ensureIssue.mockResolvedValueOnce('created');
|
platform.ensureIssue.mockResolvedValueOnce('created');
|
||||||
setAdminConfig({ dryRun: true });
|
setGlobalConfig({ dryRun: true });
|
||||||
const res = await raiseConfigWarningIssue(config, error);
|
const res = await raiseConfigWarningIssue(config, error);
|
||||||
expect(res).toBeUndefined();
|
expect(res).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
@ -62,7 +62,7 @@ describe(getName(), () => {
|
||||||
number: 1,
|
number: 1,
|
||||||
state: PrState.Open,
|
state: PrState.Open,
|
||||||
});
|
});
|
||||||
setAdminConfig({ dryRun: true });
|
setGlobalConfig({ dryRun: true });
|
||||||
const res = await raiseConfigWarningIssue(config, error);
|
const res = await raiseConfigWarningIssue(config, error);
|
||||||
expect(res).toBeUndefined();
|
expect(res).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { getAdminConfig } from '../../config/admin';
|
import { getGlobalConfig } from '../../config/admin';
|
||||||
import type { RenovateConfig } from '../../config/types';
|
import type { RenovateConfig } from '../../config/types';
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import { platform } from '../../platform';
|
import { platform } from '../../platform';
|
||||||
|
@ -22,7 +22,7 @@ export async function raiseConfigWarningIssue(
|
||||||
logger.debug('Updating onboarding PR with config error notice');
|
logger.debug('Updating onboarding PR with config error notice');
|
||||||
body = `## Action Required: Fix Renovate Configuration\n\n${body}`;
|
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.`;
|
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}`);
|
logger.info(`DRY-RUN: Would update PR #${pr.number}`);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
@ -35,7 +35,7 @@ export async function raiseConfigWarningIssue(
|
||||||
logger.warn({ err }, 'Error updating onboarding PR');
|
logger.warn({ err }, 'Error updating onboarding PR');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (getAdminConfig().dryRun) {
|
} else if (getGlobalConfig().dryRun) {
|
||||||
logger.info('DRY-RUN: Would ensure config error issue');
|
logger.info('DRY-RUN: Would ensure config error issue');
|
||||||
} else {
|
} else {
|
||||||
const once = false;
|
const once = false;
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {
|
||||||
git,
|
git,
|
||||||
platform,
|
platform,
|
||||||
} from '../../../../test/util';
|
} from '../../../../test/util';
|
||||||
import { setAdminConfig } from '../../../config/admin';
|
import { setGlobalConfig } from '../../../config/admin';
|
||||||
import { PLATFORM_TYPE_GITHUB } from '../../../constants/platforms';
|
import { PLATFORM_TYPE_GITHUB } from '../../../constants/platforms';
|
||||||
import * as cleanup from './prune';
|
import * as cleanup from './prune';
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ beforeEach(() => {
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
describe('pruneStaleBranches()', () => {
|
describe('pruneStaleBranches()', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
it('returns if no branchList', async () => {
|
it('returns if no branchList', async () => {
|
||||||
delete config.branchList;
|
delete config.branchList;
|
||||||
|
@ -70,7 +70,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
it('does nothing on dryRun', async () => {
|
it('does nothing on dryRun', async () => {
|
||||||
config.branchList = ['renovate/a', 'renovate/b'];
|
config.branchList = ['renovate/a', 'renovate/b'];
|
||||||
setAdminConfig({ dryRun: true });
|
setGlobalConfig({ dryRun: true });
|
||||||
git.getBranchList.mockReturnValueOnce(
|
git.getBranchList.mockReturnValueOnce(
|
||||||
config.branchList.concat(['renovate/c'])
|
config.branchList.concat(['renovate/c'])
|
||||||
);
|
);
|
||||||
|
@ -110,7 +110,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
it('skips comment if dry run', async () => {
|
it('skips comment if dry run', async () => {
|
||||||
config.branchList = ['renovate/a', 'renovate/b'];
|
config.branchList = ['renovate/a', 'renovate/b'];
|
||||||
setAdminConfig({ dryRun: true });
|
setGlobalConfig({ dryRun: true });
|
||||||
git.getBranchList.mockReturnValueOnce(
|
git.getBranchList.mockReturnValueOnce(
|
||||||
config.branchList.concat(['renovate/c'])
|
config.branchList.concat(['renovate/c'])
|
||||||
);
|
);
|
||||||
|
@ -125,7 +125,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
it('dry run delete branch no PR', async () => {
|
it('dry run delete branch no PR', async () => {
|
||||||
config.branchList = ['renovate/a', 'renovate/b'];
|
config.branchList = ['renovate/a', 'renovate/b'];
|
||||||
setAdminConfig({ dryRun: true });
|
setGlobalConfig({ dryRun: true });
|
||||||
git.getBranchList.mockReturnValueOnce(
|
git.getBranchList.mockReturnValueOnce(
|
||||||
config.branchList.concat(['renovate/c'])
|
config.branchList.concat(['renovate/c'])
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { getAdminConfig } from '../../../config/admin';
|
import { getGlobalConfig } from '../../../config/admin';
|
||||||
import type { RenovateConfig } from '../../../config/types';
|
import type { RenovateConfig } from '../../../config/types';
|
||||||
import { REPOSITORY_CHANGED } from '../../../constants/error-messages';
|
import { REPOSITORY_CHANGED } from '../../../constants/error-messages';
|
||||||
import { logger } from '../../../logger';
|
import { logger } from '../../../logger';
|
||||||
|
@ -31,7 +31,7 @@ async function cleanUpBranches(
|
||||||
{ prNo: pr.number, prTitle: pr.title },
|
{ prNo: pr.number, prTitle: pr.title },
|
||||||
'Branch is modified - skipping PR autoclosing'
|
'Branch is modified - skipping PR autoclosing'
|
||||||
);
|
);
|
||||||
if (getAdminConfig().dryRun) {
|
if (getGlobalConfig().dryRun) {
|
||||||
logger.info(`DRY-RUN: Would add Autoclosing Skipped comment to PR`);
|
logger.info(`DRY-RUN: Would add Autoclosing Skipped comment to PR`);
|
||||||
} else {
|
} else {
|
||||||
await platform.ensureComment({
|
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.',
|
'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(
|
logger.info(
|
||||||
{ prNo: pr.number, prTitle: pr.title },
|
{ prNo: pr.number, prTitle: pr.title },
|
||||||
`DRY-RUN: Would autoclose PR`
|
`DRY-RUN: Would autoclose PR`
|
||||||
|
@ -62,7 +62,7 @@ async function cleanUpBranches(
|
||||||
});
|
});
|
||||||
await deleteBranch(branchName);
|
await deleteBranch(branchName);
|
||||||
}
|
}
|
||||||
} else if (getAdminConfig().dryRun) {
|
} else if (getGlobalConfig().dryRun) {
|
||||||
logger.info(`DRY-RUN: Would delete orphan branch ${branchName}`);
|
logger.info(`DRY-RUN: Would delete orphan branch ${branchName}`);
|
||||||
} else {
|
} else {
|
||||||
logger.info({ branch: branchName }, `Deleting orphan branch`);
|
logger.info({ branch: branchName }, `Deleting orphan branch`);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { mock } from 'jest-mock-extended';
|
import { mock } from 'jest-mock-extended';
|
||||||
|
|
||||||
import { RenovateConfig, getConfig, getName, mocked } from '../../../test/util';
|
import { RenovateConfig, getConfig, getName, mocked } from '../../../test/util';
|
||||||
import { setAdminConfig } from '../../config/admin';
|
import { setGlobalConfig } from '../../config/admin';
|
||||||
import * as _process from './process';
|
import * as _process from './process';
|
||||||
import { ExtractResult } from './process/extract-update';
|
import { ExtractResult } from './process/extract-update';
|
||||||
import { renovateRepository } from '.';
|
import { renovateRepository } from '.';
|
||||||
|
@ -18,7 +18,7 @@ describe(getName(), () => {
|
||||||
let config: RenovateConfig;
|
let config: RenovateConfig;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
config = getConfig();
|
config = getConfig();
|
||||||
setAdminConfig({ localDir: '' });
|
setGlobalConfig({ localDir: '' });
|
||||||
});
|
});
|
||||||
it('runs', async () => {
|
it('runs', async () => {
|
||||||
process.extractDependencies.mockResolvedValue(mock<ExtractResult>());
|
process.extractDependencies.mockResolvedValue(mock<ExtractResult>());
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import { getAdminConfig, setAdminConfig } from '../../config/admin';
|
import { getGlobalConfig, setGlobalConfig } from '../../config/admin';
|
||||||
import type { RenovateConfig } from '../../config/types';
|
import type { RenovateConfig } from '../../config/types';
|
||||||
import { logger, setMeta } from '../../logger';
|
import { logger, setMeta } from '../../logger';
|
||||||
import { removeDanglingContainers } from '../../util/exec/docker';
|
import { removeDanglingContainers } from '../../util/exec/docker';
|
||||||
|
@ -30,14 +30,14 @@ export async function renovateRepository(
|
||||||
canRetry = true
|
canRetry = true
|
||||||
): Promise<ProcessResult> {
|
): Promise<ProcessResult> {
|
||||||
splitInit();
|
splitInit();
|
||||||
let config = setAdminConfig(repoConfig);
|
let config = setGlobalConfig(repoConfig);
|
||||||
await removeDanglingContainers();
|
await removeDanglingContainers();
|
||||||
setMeta({ repository: config.repository });
|
setMeta({ repository: config.repository });
|
||||||
logger.info({ renovateVersion }, 'Repository started');
|
logger.info({ renovateVersion }, 'Repository started');
|
||||||
logger.trace({ config });
|
logger.trace({ config });
|
||||||
let repoResult: ProcessResult;
|
let repoResult: ProcessResult;
|
||||||
queue.clear();
|
queue.clear();
|
||||||
const { localDir } = getAdminConfig();
|
const { localDir } = getGlobalConfig();
|
||||||
try {
|
try {
|
||||||
await fs.ensureDir(localDir);
|
await fs.ensureDir(localDir);
|
||||||
logger.debug('Using localDir: ' + localDir);
|
logger.debug('Using localDir: ' + localDir);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { RenovateConfig, getConfig, getName } from '../../../../test/util';
|
import { RenovateConfig, getConfig, getName } from '../../../../test/util';
|
||||||
import { setAdminConfig } from '../../../config/admin';
|
import { setGlobalConfig } from '../../../config/admin';
|
||||||
import { initializeCaches } from './cache';
|
import { initializeCaches } from './cache';
|
||||||
|
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
|
@ -7,7 +7,7 @@ describe(getName(), () => {
|
||||||
let config: RenovateConfig;
|
let config: RenovateConfig;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
config = { ...getConfig() };
|
config = { ...getConfig() };
|
||||||
setAdminConfig({ cacheDir: '' });
|
setGlobalConfig({ cacheDir: '' });
|
||||||
});
|
});
|
||||||
it('initializes', async () => {
|
it('initializes', async () => {
|
||||||
expect(await initializeCaches(config)).toBeUndefined();
|
expect(await initializeCaches(config)).toBeUndefined();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { getName, logger, mocked } from '../../../../test/util';
|
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 _secrets from '../../../config/secrets';
|
||||||
import * as _onboarding from '../onboarding/branch';
|
import * as _onboarding from '../onboarding/branch';
|
||||||
import * as _apis from './apis';
|
import * as _apis from './apis';
|
||||||
|
@ -24,10 +24,10 @@ const secrets = mocked(_secrets);
|
||||||
|
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
setAdminConfig({ localDir: '', cacheDir: '' });
|
setGlobalConfig({ localDir: '', cacheDir: '' });
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('initRepo', () => {
|
describe('initRepo', () => {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { getAdminConfig } from '../../../../config/admin';
|
import { getGlobalConfig } from '../../../../config/admin';
|
||||||
import { configFileNames } from '../../../../config/app-strings';
|
import { configFileNames } from '../../../../config/app-strings';
|
||||||
import type { RenovateConfig } from '../../../../config/types';
|
import type { RenovateConfig } from '../../../../config/types';
|
||||||
import { logger } from '../../../../logger';
|
import { logger } from '../../../../logger';
|
||||||
|
@ -26,7 +26,7 @@ export async function createOnboardingBranch(
|
||||||
const commitMessage = commitMessageFactory.create();
|
const commitMessage = commitMessageFactory.create();
|
||||||
|
|
||||||
// istanbul ignore if
|
// istanbul ignore if
|
||||||
if (getAdminConfig().dryRun) {
|
if (getGlobalConfig().dryRun) {
|
||||||
logger.info('DRY-RUN: Would commit files to onboarding branch');
|
logger.info('DRY-RUN: Would commit files to onboarding branch');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { mergeChildConfig } from '../../../../config';
|
import { mergeChildConfig } from '../../../../config';
|
||||||
import { getAdminConfig } from '../../../../config/admin';
|
import { getGlobalConfig } from '../../../../config/admin';
|
||||||
import type { RenovateConfig } from '../../../../config/types';
|
import type { RenovateConfig } from '../../../../config/types';
|
||||||
import {
|
import {
|
||||||
REPOSITORY_FORKED,
|
REPOSITORY_FORKED,
|
||||||
|
@ -66,7 +66,7 @@ export async function checkOnboardingBranch(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!getAdminConfig().dryRun) {
|
if (!getGlobalConfig().dryRun) {
|
||||||
await checkoutBranch(onboardingBranch);
|
await checkoutBranch(onboardingBranch);
|
||||||
}
|
}
|
||||||
const branchList = [onboardingBranch];
|
const branchList = [onboardingBranch];
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { getAdminConfig } from '../../../../config/admin';
|
import { getGlobalConfig } from '../../../../config/admin';
|
||||||
import { configFileNames } from '../../../../config/app-strings';
|
import { configFileNames } from '../../../../config/app-strings';
|
||||||
import type { RenovateConfig } from '../../../../config/types';
|
import type { RenovateConfig } from '../../../../config/types';
|
||||||
import { logger } from '../../../../logger';
|
import { logger } from '../../../../logger';
|
||||||
|
@ -43,7 +43,7 @@ export async function rebaseOnboardingBranch(
|
||||||
const commitMessage = commitMessageFactory.create();
|
const commitMessage = commitMessageFactory.create();
|
||||||
|
|
||||||
// istanbul ignore if
|
// istanbul ignore if
|
||||||
if (getAdminConfig().dryRun) {
|
if (getGlobalConfig().dryRun) {
|
||||||
logger.info('DRY-RUN: Would rebase files in onboarding branch');
|
logger.info('DRY-RUN: Would rebase files in onboarding branch');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {
|
||||||
partial,
|
partial,
|
||||||
platform,
|
platform,
|
||||||
} from '../../../../../test/util';
|
} from '../../../../../test/util';
|
||||||
import { setAdminConfig } from '../../../../config/admin';
|
import { setGlobalConfig } from '../../../../config/admin';
|
||||||
import { logger } from '../../../../logger';
|
import { logger } from '../../../../logger';
|
||||||
import type { PackageFile } from '../../../../manager/types';
|
import type { PackageFile } from '../../../../manager/types';
|
||||||
import { Pr } from '../../../../platform';
|
import { Pr } from '../../../../platform';
|
||||||
|
@ -32,7 +32,7 @@ describe(getName(), () => {
|
||||||
branches = [];
|
branches = [];
|
||||||
platform.massageMarkdown = jest.fn((input) => input);
|
platform.massageMarkdown = jest.fn((input) => input);
|
||||||
platform.createPr.mockResolvedValueOnce(partial<Pr>({}));
|
platform.createPr.mockResolvedValueOnce(partial<Pr>({}));
|
||||||
setAdminConfig();
|
setGlobalConfig();
|
||||||
});
|
});
|
||||||
let createPrBody: string;
|
let createPrBody: string;
|
||||||
it('returns if onboarded', async () => {
|
it('returns if onboarded', async () => {
|
||||||
|
@ -90,7 +90,7 @@ describe(getName(), () => {
|
||||||
expect(platform.createPr).toHaveBeenCalledTimes(1);
|
expect(platform.createPr).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
it('dryrun of updates PR when modified', async () => {
|
it('dryrun of updates PR when modified', async () => {
|
||||||
setAdminConfig({ dryRun: true });
|
setGlobalConfig({ dryRun: true });
|
||||||
config.baseBranch = 'some-branch';
|
config.baseBranch = 'some-branch';
|
||||||
platform.getBranchPr.mockResolvedValueOnce(
|
platform.getBranchPr.mockResolvedValueOnce(
|
||||||
partial<Pr>({
|
partial<Pr>({
|
||||||
|
@ -109,7 +109,7 @@ describe(getName(), () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('dryrun of creates PR', async () => {
|
it('dryrun of creates PR', async () => {
|
||||||
setAdminConfig({ dryRun: true });
|
setGlobalConfig({ dryRun: true });
|
||||||
await ensureOnboardingPr(config, packageFiles, branches);
|
await ensureOnboardingPr(config, packageFiles, branches);
|
||||||
expect(logger.info).toHaveBeenCalledWith(
|
expect(logger.info).toHaveBeenCalledWith(
|
||||||
'DRY-RUN: Would check branch renovate/configure'
|
'DRY-RUN: Would check branch renovate/configure'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { getAdminConfig } from '../../../../config/admin';
|
import { getGlobalConfig } from '../../../../config/admin';
|
||||||
import type { RenovateConfig } from '../../../../config/types';
|
import type { RenovateConfig } from '../../../../config/types';
|
||||||
import { logger } from '../../../../logger';
|
import { logger } from '../../../../logger';
|
||||||
import type { PackageFile } from '../../../../manager/types';
|
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', '');
|
prBody = prBody.replace('{{PACKAGE FILES}}\n', '');
|
||||||
}
|
}
|
||||||
let configDesc = '';
|
let configDesc = '';
|
||||||
if (getAdminConfig().dryRun) {
|
if (getGlobalConfig().dryRun) {
|
||||||
logger.info(`DRY-RUN: Would check branch ${config.onboardingBranch}`);
|
logger.info(`DRY-RUN: Would check branch ${config.onboardingBranch}`);
|
||||||
} else if (await isBranchModified(config.onboardingBranch)) {
|
} else if (await isBranchModified(config.onboardingBranch)) {
|
||||||
configDesc = emojify(
|
configDesc = emojify(
|
||||||
|
@ -114,7 +114,7 @@ If you need any further assistance then you can also [request help here](${confi
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// PR must need updating
|
// PR must need updating
|
||||||
if (getAdminConfig().dryRun) {
|
if (getGlobalConfig().dryRun) {
|
||||||
logger.info('DRY-RUN: Would update onboarding PR');
|
logger.info('DRY-RUN: Would update onboarding PR');
|
||||||
} else {
|
} else {
|
||||||
await platform.updatePr({
|
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');
|
logger.debug('Creating onboarding PR');
|
||||||
const labels: string[] = config.addLabels ?? [];
|
const labels: string[] = config.addLabels ?? [];
|
||||||
try {
|
try {
|
||||||
if (getAdminConfig().dryRun) {
|
if (getGlobalConfig().dryRun) {
|
||||||
logger.info('DRY-RUN: Would create onboarding PR');
|
logger.info('DRY-RUN: Would create onboarding PR');
|
||||||
} else {
|
} else {
|
||||||
const pr = await platform.createPr({
|
const pr = await platform.createPr({
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue