refactor: localDir -> cloneDir (#10158)

This commit is contained in:
Rhys Arkins 2021-05-26 10:30:23 +02:00 committed by GitHub
parent 66863ea419
commit 0b287c763d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
52 changed files with 131 additions and 131 deletions

View file

@ -16,7 +16,7 @@ const repoAdminOptions = [
'exposeAllEnv',
'migratePresets',
'privateKey',
'localDir',
'cloneDir',
'cacheDir',
];

View file

@ -98,14 +98,14 @@ export interface RepoAdminConfig {
exposeAllEnv?: boolean;
migratePresets?: Record<string, string>;
privateKey?: string | Buffer;
localDir?: string;
cloneDir?: string;
cacheDir?: string;
}
export interface LegacyAdminConfig {
endpoint?: string;
localDir?: string;
cloneDir?: string;
logContext?: string;

View file

@ -83,7 +83,7 @@ describe(getName(), () => {
tmpDir = await dir();
adminConfig = {
localDir: join(tmpDir.path, 'local'),
cloneDir: join(tmpDir.path, 'local'),
cacheDir: join(tmpDir.path, 'cache'),
};
setAdminConfig(adminConfig);

View file

@ -28,7 +28,7 @@ function createGitDependency(repo: string, version: string): PackageDependency {
}
const adminConfig: RepoAdminConfig = {
localDir: '',
cloneDir: '',
};
const config: ExtractConfig = {};

View file

@ -30,7 +30,7 @@ jest.mock('./host-rules');
const adminConfig: RepoAdminConfig = {
// `join` fixes Windows CI
localDir: join('/tmp/github/some/repo'),
cloneDir: join('/tmp/github/some/repo'),
cacheDir: join('/tmp/cache'),
};

View file

@ -26,7 +26,7 @@ const config: UpdateArtifactsConfig = {};
const adminConfig: RepoAdminConfig = {
// `join` fixes Windows CI
localDir: join('/tmp/github/some/repo'),
cloneDir: join('/tmp/github/some/repo'),
};
describe('.updateArtifacts()', () => {

View file

@ -24,7 +24,7 @@ describe(getName(), () => {
config = {};
const tmpDir = await dir();
adminConfig = {
localDir: join(tmpDir.path, 'local'),
cloneDir: join(tmpDir.path, 'local'),
cacheDir: join(tmpDir.path, 'cache'),
};

View file

@ -30,7 +30,7 @@ delete process.env.CP_HOME_DIR;
const config: UpdateArtifactsConfig = {};
const adminConfig: RepoAdminConfig = {
localDir: join('/tmp/github/some/repo'),
cloneDir: join('/tmp/github/some/repo'),
cacheDir: join('/tmp/cache'),
};
@ -83,7 +83,7 @@ describe('.updateArtifacts()', () => {
it('returns null for invalid local directory', async () => {
const execSnapshots = mockExecAll(exec);
setAdminConfig({
localDir: '',
cloneDir: '',
});
expect(

View file

@ -7,7 +7,7 @@ const simplePodfile = loadFixture('Podfile.simple');
const complexPodfile = loadFixture('Podfile.complex');
const adminConfig: RepoAdminConfig = {
localDir: '',
cloneDir: '',
};
describe(getName(), () => {

View file

@ -35,7 +35,7 @@ const config: UpdateArtifactsConfig = {
const adminConfig: RepoAdminConfig = {
allowScripts: false,
// `join` fixes Windows CI
localDir: join('/tmp/github/some/repo'),
cloneDir: join('/tmp/github/some/repo'),
cacheDir: join('/tmp/renovate/cache'),
};

View file

@ -44,7 +44,7 @@ describe(getName(), () => {
});
describe('extractPackageFile()', () => {
it('extracts submodules', async () => {
setAdminConfig({ localDir: `${__dirname}/__fixtures__` });
setAdminConfig({ cloneDir: `${__dirname}/__fixtures__` });
hostRules.add({ matchHost: 'github.com', token: 'abc123' });
let res: PackageFile;
expect(await extractPackageFile('', '.gitmodules.1', {})).toBeNull();

View file

@ -88,9 +88,9 @@ export default async function extractPackageFile(
fileName: string,
config: ManagerConfig
): Promise<PackageFile | null> {
const { localDir } = getAdminConfig();
const git = Git(localDir);
const gitModulesPath = upath.join(localDir, fileName);
const { cloneDir } = getAdminConfig();
const git = Git(cloneDir);
const gitModulesPath = upath.join(cloneDir, fileName);
const depNames = await getModules(git, gitModulesPath);

View file

@ -18,7 +18,7 @@ describe(getName(), () => {
upgrade = { depName: 'renovate' };
const tmpDir = await dir();
adminConfig = { localDir: join(tmpDir.path) };
adminConfig = { cloneDir: join(tmpDir.path) };
setAdminConfig(adminConfig);
});
afterAll(() => {

View file

@ -8,9 +8,9 @@ export default async function updateDependency({
fileContent,
upgrade,
}: UpdateDependencyConfig): Promise<string | null> {
const { localDir } = getAdminConfig();
const git = Git(localDir);
const submoduleGit = Git(upath.join(localDir, upgrade.depName));
const { cloneDir } = getAdminConfig();
const git = Git(cloneDir);
const submoduleGit = Git(upath.join(cloneDir, upgrade.depName));
try {
await git.submoduleUpdate(['--init', upgrade.depName]);

View file

@ -6,7 +6,7 @@ import { extractAllPackageFiles } from './extract';
const config: ExtractConfig = {};
const adminConfig: RepoAdminConfig = { localDir: '' };
const adminConfig: RepoAdminConfig = { cloneDir: '' };
describe(getName(), () => {
beforeEach(() => {

View file

@ -40,7 +40,7 @@ replace github.com/pkg/errors => ../errors
const adminConfig: RepoAdminConfig = {
// `join` fixes Windows CI
localDir: join('/tmp/github/some/repo'),
cloneDir: join('/tmp/github/some/repo'),
cacheDir: join('/tmp/renovate/cache'),
};

View file

@ -16,7 +16,7 @@ jest.mock('../../util/git');
const fixtures = resolve(__dirname, './__fixtures__');
const adminConfig: RepoAdminConfig = {
localDir: resolve(fixtures, './testFiles'),
cloneDir: resolve(fixtures, './testFiles'),
};
const config: UpdateArtifactsConfig = {
@ -169,7 +169,7 @@ describe(getName(), () => {
it('gradlew failed', async () => {
const wrongCmdConfig = {
...adminConfig,
localDir: resolve(fixtures, './wrongCmd'),
cloneDir: resolve(fixtures, './wrongCmd'),
};
await setExecConfig(wrongCmdConfig);
@ -196,7 +196,7 @@ describe(getName(), () => {
});
it('gradlew not found', async () => {
setAdminConfig({ localDir: 'some-dir' });
setAdminConfig({ cloneDir: 'some-dir' });
const res = await dcUpdate.updateArtifacts({
packageFileName: 'gradle-wrapper.properties',
updatedDeps: [],
@ -243,7 +243,7 @@ describe(getName(), () => {
expect(
await readString(
adminConfig.localDir,
adminConfig.cloneDir,
`./gradle/wrapper/gradle-wrapper.properties`
)
).toEqual(newContent);

View file

@ -30,7 +30,7 @@ const exec: jest.Mock<typeof _exec> = _exec as any;
const fixtures = resolve(__dirname, './__fixtures__');
const adminConfig: RepoAdminConfig = {
localDir: resolve(fixtures, './testFiles'),
cloneDir: resolve(fixtures, './testFiles'),
};
const dockerAdminConfig = { ...adminConfig, binarySource: BinarySource.Docker };
@ -105,7 +105,7 @@ describe(getName(), () => {
});
it('gradlew not found', async () => {
setAdminConfig({ ...adminConfig, localDir: 'some-dir' });
setAdminConfig({ ...adminConfig, cloneDir: 'some-dir' });
const res = await dcUpdate.updateArtifacts({
packageFileName: 'gradle-wrapper.properties',
updatedDeps: [],

View file

@ -55,7 +55,7 @@ export async function updateArtifacts({
config,
}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {
try {
const { localDir: projectDir } = getAdminConfig();
const { cloneDir: projectDir } = getAdminConfig();
logger.debug({ updatedDeps }, 'gradle-wrapper.updateArtifacts()');
const gradlew = gradleWrapperFileName(config);
const gradlewPath = resolve(projectDir, `./${gradlew}`);

View file

@ -11,7 +11,7 @@ import type {
export const GRADLE_DEPENDENCY_REPORT_FILENAME = 'gradle-renovate-report.json';
export async function createRenovateGradlePlugin(
localDir: string
cloneDir: string
): Promise<void> {
const content = `
import groovy.json.JsonOutput
@ -47,16 +47,16 @@ gradle.buildFinished {
def json = JsonOutput.toJson(output)
outputFile.write json
}`;
const gradleInitFile = join(localDir, 'renovate-plugin.gradle');
const gradleInitFile = join(cloneDir, 'renovate-plugin.gradle');
logger.debug(
'Creating renovate-plugin.gradle file with renovate gradle plugin'
);
await writeFile(gradleInitFile, content);
}
async function readGradleReport(localDir: string): Promise<GradleProject[]> {
async function readGradleReport(cloneDir: string): Promise<GradleProject[]> {
const renovateReportFilename = join(
localDir,
cloneDir,
GRADLE_DEPENDENCY_REPORT_FILENAME
);
if (!(await exists(renovateReportFilename))) {
@ -123,9 +123,9 @@ function buildDependency(
}
export async function extractDependenciesFromUpdatesReport(
localDir: string
cloneDir: string
): Promise<BuildDependency[]> {
const gradleProjectConfigurations = await readGradleReport(localDir);
const gradleProjectConfigurations = await readGradleReport(cloneDir);
const dependencies = gradleProjectConfigurations
.map(mergeDependenciesWithRepositories, [])

View file

@ -26,7 +26,7 @@ describe(getName(), () => {
beforeEach(async () => {
workingDir = await tmp.dir({ unsafeCleanup: true });
successFile = '';
adminConfig = { localDir: workingDir.path };
adminConfig = { cloneDir: workingDir.path };
setAdminConfig(adminConfig);
testRunConfig = { ...baseConfig };
await fsExtra.copy(`${fixtures}/minimal-project`, workingDir.path);

View file

@ -29,7 +29,7 @@ jest.mock('../../util/exec/env');
const env = mocked(_env);
const adminConfig: RepoAdminConfig = {
localDir: join('/foo/bar'),
cloneDir: join('/foo/bar'),
};
const dockerAdminConfig = {

View file

@ -93,11 +93,11 @@ export async function extractAllPackageFiles(
): Promise<PackageFile[] | null> {
let rootBuildGradle: string | undefined;
let gradlew: Stats | null;
const { localDir } = getAdminConfig();
const { cloneDir } = getAdminConfig();
for (const packageFile of packageFiles) {
const dirname = upath.dirname(packageFile);
const gradlewPath = upath.join(dirname, gradleWrapperFileName(config));
gradlew = await stat(upath.join(localDir, gradlewPath)).catch(() => null);
gradlew = await stat(upath.join(cloneDir, gradlewPath)).catch(() => null);
if (['build.gradle', 'build.gradle.kts'].includes(packageFile)) {
rootBuildGradle = packageFile;
@ -116,7 +116,7 @@ export async function extractAllPackageFiles(
}
logger.debug('Extracting dependencies from all gradle files');
const cwd = upath.join(localDir, upath.dirname(rootBuildGradle));
const cwd = upath.join(cloneDir, upath.dirname(rootBuildGradle));
await createRenovateGradlePlugin(cwd);
await executeGradle(config, cwd, gradlew);

View file

@ -23,7 +23,7 @@ const exec: jest.Mock<typeof _exec> = _exec as any;
const env = mocked(_env);
const adminConfig: RepoAdminConfig = {
localDir: join('/tmp/github/some/repo'), // `join` fixes Windows CI
cloneDir: join('/tmp/github/some/repo'), // `join` fixes Windows CI
};
const config: UpdateArtifactsConfig = {};

View file

@ -15,7 +15,7 @@ jest.mock('../../util/fs');
const adminConfig: RepoAdminConfig = {
// `join` fixes Windows CI
localDir: join('/tmp/github/some/repo'),
cloneDir: join('/tmp/github/some/repo'),
};
const config: UpdateArtifactsConfig = {};

View file

@ -6,7 +6,7 @@ const sample = loadFixture('mix.exs');
describe(getName(), () => {
beforeEach(() => {
setAdminConfig({ localDir: '' });
setAdminConfig({ cloneDir: '' });
});
describe('extractPackageFile()', () => {

View file

@ -10,7 +10,7 @@ import {
describe(getName(), () => {
beforeAll(() => {
setAdminConfig({ localDir: getFixturePath('pnpm-monorepo/', '..') });
setAdminConfig({ cloneDir: getFixturePath('pnpm-monorepo/', '..') });
});
describe('.extractPnpmFilters()', () => {

View file

@ -139,10 +139,10 @@ export async function writeExistingFiles(
{ packageFiles: npmFiles.map((n) => n.packageFile) },
'Writing package.json files'
);
const { localDir } = getAdminConfig();
const { cloneDir } = getAdminConfig();
for (const packageFile of npmFiles) {
const basedir = upath.join(
localDir,
cloneDir,
upath.dirname(packageFile.packageFile)
);
const npmrc: string = packageFile.npmrc || config.npmrc;
@ -170,7 +170,7 @@ export async function writeExistingFiles(
}
const { npmLock } = packageFile;
if (npmLock) {
const npmLockPath = upath.join(localDir, npmLock);
const npmLockPath = upath.join(cloneDir, npmLock);
if (
process.env.RENOVATE_REUSE_PACKAGE_LOCK === 'false' ||
config.reuseLockFiles === false
@ -232,12 +232,12 @@ export async function writeUpdatedPackageFiles(
logger.debug('No files found');
return;
}
const { localDir } = getAdminConfig();
const { cloneDir } = getAdminConfig();
for (const packageFile of config.updatedPackageFiles) {
if (packageFile.name.endsWith('package-lock.json')) {
logger.debug(`Writing package-lock file: ${packageFile.name}`);
await outputFile(
upath.join(localDir, packageFile.name),
upath.join(cloneDir, packageFile.name),
packageFile.contents
);
continue; // eslint-disable-line
@ -266,7 +266,7 @@ export async function writeUpdatedPackageFiles(
logger.warn({ err }, 'Error adding token to package files');
}
await outputFile(
upath.join(localDir, packageFile.name),
upath.join(cloneDir, packageFile.name),
JSON.stringify(massagedFile)
);
}
@ -332,7 +332,7 @@ async function resetNpmrcContent(
// istanbul ignore next
async function updateYarnOffline(
lockFileDir: string,
localDir: string,
cloneDir: string,
updatedArtifacts: UpdatedArtifacts[]
): Promise<void> {
try {
@ -372,7 +372,7 @@ async function updateYarnOffline(
const status = await getRepoStatus();
for (const f of status.modified.concat(status.not_added)) {
if (resolvedPaths.some((p) => f.startsWith(p))) {
const localModified = upath.join(localDir, f);
const localModified = upath.join(cloneDir, f);
updatedArtifacts.push({
name: f,
contents: await readFile(localModified),
@ -463,10 +463,10 @@ export async function getAdditionalFiles(
} catch (err) {
logger.warn({ err }, 'Error getting token for packageFile');
}
const { localDir } = getAdminConfig();
const { cloneDir } = getAdminConfig();
for (const npmLock of dirs.npmLockDirs) {
const lockFileDir = upath.dirname(npmLock);
const fullLockFileDir = upath.join(localDir, lockFileDir);
const fullLockFileDir = upath.join(cloneDir, lockFileDir);
const npmrcContent = await getNpmrcContent(fullLockFileDir);
await updateNpmrcContent(
fullLockFileDir,
@ -529,7 +529,7 @@ export async function getAdditionalFiles(
for (const yarnLock of dirs.yarnLockDirs) {
const lockFileDir = upath.dirname(yarnLock);
const fullLockFileDir = upath.join(localDir, lockFileDir);
const fullLockFileDir = upath.join(cloneDir, lockFileDir);
const npmrcContent = await getNpmrcContent(fullLockFileDir);
await updateNpmrcContent(
fullLockFileDir,
@ -561,7 +561,7 @@ export async function getAdditionalFiles(
(upgrade) => upgrade.yarnLock === yarnLock
);
const res = await yarn.generateLockFile(
upath.join(localDir, lockFileDir),
upath.join(cloneDir, lockFileDir),
env,
config,
upgrades
@ -607,7 +607,7 @@ export async function getAdditionalFiles(
name: lockFileName,
contents: res.lockFile,
});
await updateYarnOffline(lockFileDir, localDir, updatedArtifacts);
await updateYarnOffline(lockFileDir, cloneDir, updatedArtifacts);
}
}
await resetNpmrcContent(fullLockFileDir, npmrcContent);
@ -618,7 +618,7 @@ export async function getAdditionalFiles(
for (const pnpmShrinkwrap of dirs.pnpmShrinkwrapDirs) {
const lockFileDir = upath.dirname(pnpmShrinkwrap);
const fullLockFileDir = upath.join(localDir, lockFileDir);
const fullLockFileDir = upath.join(cloneDir, lockFileDir);
const npmrcContent = await getNpmrcContent(fullLockFileDir);
await updateNpmrcContent(
fullLockFileDir,
@ -630,7 +630,7 @@ export async function getAdditionalFiles(
(upgrade) => upgrade.pnpmShrinkwrap === pnpmShrinkwrap
);
const res = await pnpm.generateLockFile(
upath.join(localDir, lockFileDir),
upath.join(cloneDir, lockFileDir),
env,
config,
upgrades
@ -697,7 +697,7 @@ export async function getAdditionalFiles(
const skipInstalls =
lockFile === 'npm-shrinkwrap.json' ? false : config.skipInstalls;
const fullLearnaFileDir = upath.join(
localDir,
cloneDir,
getSubDirectory(lernaJsonFile)
);
const npmrcContent = await getNpmrcContent(fullLearnaFileDir);
@ -769,7 +769,7 @@ export async function getAdditionalFiles(
);
if (existingContent) {
logger.trace('Found lock file');
const lockFilePath = upath.join(localDir, filename);
const lockFilePath = upath.join(cloneDir, filename);
logger.trace('Checking against ' + lockFilePath);
try {
let newContent: string;

View file

@ -35,7 +35,7 @@ const hostRules = mocked(_hostRules);
const adminConfig: RepoAdminConfig = {
// `join` fixes Windows CI
localDir: join('/tmp/github/some/repo'),
cloneDir: join('/tmp/github/some/repo'),
cacheDir: join('/tmp/renovate/cache'),
};

View file

@ -29,9 +29,9 @@ async function addSourceCmds(
config: UpdateArtifactsConfig,
nugetConfigFile: string
): Promise<string[]> {
const { localDir } = getAdminConfig();
const { cloneDir } = getAdminConfig();
const registries =
(await getConfiguredRegistries(packageFileName, localDir)) ||
(await getConfiguredRegistries(packageFileName, cloneDir)) ||
getDefaultRegistries();
const result = [];
for (const registry of registries) {

View file

@ -8,7 +8,7 @@ import { extractPackageFile } from './extract';
const config: ExtractConfig = {};
const adminConfig: RepoAdminConfig = {
localDir: upath.resolve('lib/manager/nuget/__fixtures__'),
cloneDir: upath.resolve('lib/manager/nuget/__fixtures__'),
};
describe(getName(), () => {

View file

@ -71,8 +71,8 @@ export async function extractPackageFile(
): Promise<PackageFile | null> {
logger.trace({ packageFile }, 'nuget.extractPackageFile()');
const { localDir } = getAdminConfig();
const registries = await getConfiguredRegistries(packageFile, localDir);
const { cloneDir } = getAdminConfig();
const registries = await getConfiguredRegistries(packageFile, cloneDir);
const registryUrls = registries
? registries.map((registry) => registry.url)
: undefined;

View file

@ -32,12 +32,12 @@ export function getDefaultRegistries(): Registry[] {
export async function getConfiguredRegistries(
packageFile: string,
localDir: string
cloneDir: string
): Promise<Registry[] | undefined> {
// Valid file names taken from https://github.com/NuGet/NuGet.Client/blob/f64621487c0b454eda4b98af853bf4a528bef72a/src/NuGet.Core/NuGet.Configuration/Settings/Settings.cs#L34
const nuGetConfigFileNames = ['nuget.config', 'NuGet.config', 'NuGet.Config'];
// normalize paths, otherwise startsWith can fail because of path delimitter mismatch
const normalizedLocalDir = upath.normalizeSafe(localDir);
const normalizedLocalDir = upath.normalizeSafe(cloneDir);
const nuGetConfigPath = await findUp(nuGetConfigFileNames, {
cwd: upath.dirname(upath.join(normalizedLocalDir, packageFile)),
type: 'file',

View file

@ -19,7 +19,7 @@ describe('.updateArtifacts()', () => {
beforeEach(() => {
jest.resetAllMocks();
jest.resetModules();
setAdminConfig({ localDir: '' });
setAdminConfig({ cloneDir: '' });
});
it('returns null if no updatedDeps were provided', async () => {
expect(

View file

@ -18,7 +18,7 @@ describe(getName(), () => {
resetModule();
env.getChildProcessEnv.mockReturnValue(envMock.basic);
setAdminConfig({ localDir: '/tmp/foo/bar' });
setAdminConfig({ cloneDir: '/tmp/foo/bar' });
});
describe('parsePythonVersion', () => {
it('returns major and minor version numbers', () => {

View file

@ -20,7 +20,7 @@ const content = loadFixture(packageFile);
const jsonContent = loadFixture('setup.py.json');
const adminConfig: RepoAdminConfig = {
localDir: '/tmp/github/some/repo',
cloneDir: '/tmp/github/some/repo',
cacheDir: '/tmp/renovate/cache',
};

View file

@ -26,7 +26,7 @@ const env = mocked(_env);
const adminConfig: RepoAdminConfig = {
// `join` fixes Windows CI
localDir: join('/tmp/github/some/repo'),
cloneDir: join('/tmp/github/some/repo'),
cacheDir: join('/tmp/renovate/cache'),
};
const dockerAdminConfig = { ...adminConfig, binarySource: BinarySource.Docker };

View file

@ -29,7 +29,7 @@ const datasource = mocked(_datasource);
const hostRules = mocked(_hostRules);
const adminConfig: RepoAdminConfig = {
localDir: join('/tmp/github/some/repo'),
cloneDir: join('/tmp/github/some/repo'),
};
const config: UpdateArtifactsConfig = {};

View file

@ -197,7 +197,7 @@ export async function generateDockerCommand(
const preCommands = options.preCommands || [];
const postCommands = options.postCommands || [];
const {
localDir,
cloneDir,
cacheDir,
dockerUser,
dockerChildPrefix,
@ -212,7 +212,7 @@ export async function generateDockerCommand(
result.push(`--user=${dockerUser}`);
}
result.push(...prepareVolumes([localDir, cacheDir, ...volumes]));
result.push(...prepareVolumes([cloneDir, cacheDir, ...volumes]));
if (envVars) {
result.push(

View file

@ -717,7 +717,7 @@ describe(getName(), () => {
callback(null, { stdout: '', stderr: '' });
return undefined;
});
setAdminConfig({ cacheDir, localDir: cwd, ...adminConfig });
setAdminConfig({ cacheDir, cloneDir: cwd, ...adminConfig });
await exec(cmd as string, inOpts);
expect(actualCmd).toEqual(outCommand);

View file

@ -97,11 +97,11 @@ export async function exec(
const extraEnv = { ...opts.extraEnv, ...customEnvVariables };
let cwd;
// istanbul ignore if
const { localDir } = getAdminConfig();
const { cloneDir } = getAdminConfig();
if (cwdFile) {
cwd = join(localDir, dirname(cwdFile));
cwd = join(cloneDir, dirname(cwdFile));
}
cwd = cwd || opts.cwd || localDir;
cwd = cwd || opts.cwd || cloneDir;
const childEnv = createChildEnv(env, extraEnv);
const execOptions: ExecOptions = { ...opts };

View file

@ -12,7 +12,7 @@ import {
describe(getName(), () => {
describe('readLocalFile', () => {
beforeEach(() => {
setAdminConfig({ localDir: '' });
setAdminConfig({ cloneDir: '' });
});
it('reads buffer', async () => {
@ -49,9 +49,9 @@ describe(getName(), () => {
describe('findLocalSiblingOrParent', () => {
it('returns path for file', async () => {
await withDir(
async (localDir) => {
async (cloneDir) => {
setAdminConfig({
localDir: localDir.path,
cloneDir: cloneDir.path,
});
await writeLocalFile('crates/one/Cargo.toml', '');

View file

@ -26,8 +26,8 @@ export async function readLocalFile(
fileName: string,
encoding?: string
): Promise<string | Buffer> {
const { localDir } = getAdminConfig();
const localFileName = join(localDir, fileName);
const { cloneDir } = getAdminConfig();
const localFileName = join(cloneDir, fileName);
try {
const fileContent = await fs.readFile(localFileName, encoding);
return fileContent;
@ -41,15 +41,15 @@ export async function writeLocalFile(
fileName: string,
fileContent: string
): Promise<void> {
const { localDir } = getAdminConfig();
const localFileName = join(localDir, fileName);
const { cloneDir } = getAdminConfig();
const localFileName = join(cloneDir, fileName);
await fs.outputFile(localFileName, fileContent);
}
export async function deleteLocalFile(fileName: string): Promise<void> {
const { localDir } = getAdminConfig();
if (localDir) {
const localFileName = join(localDir, fileName);
const { cloneDir } = getAdminConfig();
if (cloneDir) {
const localFileName = join(cloneDir, fileName);
await fs.remove(localFileName);
}
}
@ -59,8 +59,8 @@ export async function renameLocalFile(
fromFile: string,
toFile: string
): Promise<void> {
const { localDir } = getAdminConfig();
await fs.move(join(localDir, fromFile), join(localDir, toFile));
const { cloneDir } = getAdminConfig();
await fs.move(join(cloneDir, fromFile), join(cloneDir, toFile));
}
// istanbul ignore next
@ -70,8 +70,8 @@ export async function ensureDir(dirName: string): Promise<void> {
// istanbul ignore next
export async function ensureLocalDir(dirName: string): Promise<void> {
const { localDir } = getAdminConfig();
const localDirName = join(localDir, dirName);
const { cloneDir } = getAdminConfig();
const localDirName = join(cloneDir, dirName);
await fs.ensureDir(localDirName);
}
@ -97,10 +97,10 @@ export function privateCacheDir(): string {
}
export function localPathExists(pathName: string): Promise<boolean> {
const { localDir } = getAdminConfig();
const { cloneDir } = getAdminConfig();
// Works for both files as well as directories
return fs
.stat(join(localDir, pathName))
.stat(join(cloneDir, pathName))
.then((s) => !!s)
.catch(() => false);
}
@ -109,7 +109,7 @@ export function localPathExists(pathName: string): Promise<boolean> {
* Tries to find `otherFileName` in the directory where
* `existingFileNameWithPath` is, then in its parent directory, then in the
* grandparent, until we reach the top-level directory. All paths
* must be relative to `localDir`.
* must be relative to `cloneDir`.
*/
export async function findLocalSiblingOrParent(
existingFileNameWithPath: string,

View file

@ -71,7 +71,7 @@ describe(getName(), () => {
await repo.clone(base.path, '.', ['--bare']);
await repo.addConfig('commit.gpgsign', 'false');
tmpDir = await tmp.dir({ unsafeCleanup: true });
setAdminConfig({ localDir: tmpDir.path });
setAdminConfig({ cloneDir: tmpDir.path });
await git.initRepo({
url: origin.path,
gitAuthorName: 'Jest',

View file

@ -175,8 +175,8 @@ export async function initRepo(args: StorageConfig): Promise<void> {
config.ignoredAuthors = [];
config.additionalBranches = [];
config.branchIsModified = {};
const { localDir } = getAdminConfig();
git = Git(localDir);
const { cloneDir } = getAdminConfig();
git = Git(cloneDir);
gitInitialized = false;
await fetchBranchCommits();
}
@ -257,9 +257,9 @@ export async function syncGit(): Promise<void> {
return;
}
gitInitialized = true;
const { localDir } = getAdminConfig();
logger.debug('Initializing git repository into ' + localDir);
const gitHead = join(localDir, '.git/HEAD');
const { cloneDir } = getAdminConfig();
logger.debug('Initializing git repository into ' + cloneDir);
const gitHead = join(cloneDir, '.git/HEAD');
let clone = true;
if (await fs.exists(gitHead)) {
@ -283,7 +283,7 @@ export async function syncGit(): Promise<void> {
}
}
if (clone) {
await fs.emptyDir(localDir);
await fs.emptyDir(cloneDir);
const cloneStart = Date.now();
try {
// clone only the default branch
@ -696,8 +696,8 @@ export async function commitFiles({
await writePrivateKey();
privateKeySet = true;
}
const { localDir } = getAdminConfig();
await configSigningKey(localDir);
const { cloneDir } = getAdminConfig();
await configSigningKey(cloneDir);
try {
await git.reset(ResetMode.HARD);
await git.raw(['clean', '-fd']);
@ -708,7 +708,7 @@ export async function commitFiles({
// istanbul ignore if
if (file.name === '|delete|') {
deleted.push(file.contents as string);
} else if (await isDirectory(join(localDir, file.name))) {
} else if (await isDirectory(join(cloneDir, file.name))) {
fileNames.push(file.name);
await gitAdd(file.name);
} else {
@ -720,7 +720,7 @@ export async function commitFiles({
} else {
contents = file.contents;
}
await fs.outputFile(join(localDir, file.name), contents);
await fs.outputFile(join(cloneDir, file.name), contents);
}
}
// istanbul ignore if

View file

@ -62,7 +62,7 @@ export async function postUpgradeCommandsExecutor(
logger.debug({ cmd: compiledCmd }, 'Executing post-upgrade task');
const execResult = await exec(compiledCmd, {
cwd: getAdminConfig().localDir,
cwd: getAdminConfig().cloneDir,
});
logger.debug(

View file

@ -63,7 +63,7 @@ const sanitize = mocked(_sanitize);
const fs = mocked(_fs);
const limits = mocked(_limits);
const adminConfig: RepoAdminConfig = { localDir: '', cacheDir: '' };
const adminConfig: RepoAdminConfig = { cloneDir: '', cacheDir: '' };
describe(getName(), () => {
describe('processBranch', () => {
@ -781,7 +781,7 @@ describe(getName(), () => {
allowedPostUpgradeCommands: ['^echo {{{versioning}}}$'],
allowPostUpgradeCommandTemplating: true,
exposeAllEnv: true,
localDir: '/localDir',
cloneDir: '/cloneDir',
});
const result = await branchWorker.processBranch({
@ -806,7 +806,7 @@ describe(getName(), () => {
expect(result).toMatchSnapshot();
expect(exec.exec).toHaveBeenCalledWith('echo semver', {
cwd: '/localDir',
cwd: '/cloneDir',
});
const errorMessage = expect.stringContaining(
"Post-upgrade command 'disallowed task' does not match allowed pattern '^echo {{{versioning}}}$'"
@ -861,7 +861,7 @@ describe(getName(), () => {
allowedPostUpgradeCommands: ['^exit 1$'],
allowPostUpgradeCommandTemplating: true,
exposeAllEnv: true,
localDir: '/localDir',
cloneDir: '/cloneDir',
});
exec.exec.mockRejectedValue(new Error('Meh, this went wrong!'));
@ -930,7 +930,7 @@ describe(getName(), () => {
allowedPostUpgradeCommands: ['^echo {{{versioning}}}$'],
allowPostUpgradeCommandTemplating: false,
exposeAllEnv: true,
localDir: '/localDir',
cloneDir: '/cloneDir',
});
const result = await branchWorker.processBranch({
...config,
@ -954,7 +954,7 @@ describe(getName(), () => {
expect(result).toMatchSnapshot();
expect(exec.exec).toHaveBeenCalledWith('echo {{{versioning}}}', {
cwd: '/localDir',
cwd: '/cloneDir',
});
});
@ -1010,7 +1010,7 @@ describe(getName(), () => {
allowedPostUpgradeCommands: ['^echo {{{depName}}}$'],
allowPostUpgradeCommandTemplating: true,
exposeAllEnv: true,
localDir: '/localDir',
cloneDir: '/cloneDir',
});
const inconfig: BranchConfig = {
@ -1061,10 +1061,10 @@ describe(getName(), () => {
expect(result).toMatchSnapshot();
expect(exec.exec).toHaveBeenNthCalledWith(1, 'echo some-dep-name-1', {
cwd: '/localDir',
cwd: '/cloneDir',
});
expect(exec.exec).toHaveBeenNthCalledWith(2, 'echo some-dep-name-2', {
cwd: '/localDir',
cwd: '/cloneDir',
});
expect(exec.exec).toHaveBeenCalledTimes(2);
expect(
@ -1144,7 +1144,7 @@ describe(getName(), () => {
allowedPostUpgradeCommands: ['^echo hardcoded-string$'],
allowPostUpgradeCommandTemplating: true,
trustLevel: 'high',
localDir: '/localDir',
cloneDir: '/cloneDir',
});
const inconfig: BranchConfig = {
@ -1194,7 +1194,7 @@ describe(getName(), () => {
const result = await branchWorker.processBranch(inconfig);
expect(result).toMatchSnapshot();
expect(exec.exec).toHaveBeenNthCalledWith(1, 'echo hardcoded-string', {
cwd: '/localDir',
cwd: '/cloneDir',
});
expect(exec.exec).toHaveBeenCalledTimes(1);
expect(

View file

@ -32,7 +32,7 @@ describe(getName(), () => {
describe('writeUpdatedPackageFiles', () => {
beforeEach(() => {
setAdminConfig({
localDir: 'some-tmp-dir',
cloneDir: 'some-tmp-dir',
});
fs.outputFile = jest.fn();
});
@ -71,7 +71,7 @@ describe(getName(), () => {
describe('getAdditionalFiles', () => {
beforeEach(() => {
setAdminConfig({
localDir: 'some-tmp-dir',
cloneDir: 'some-tmp-dir',
});
git.getFile.mockResolvedValueOnce('some lock file contents');
npm.generateLockFile = jest.fn();

View file

@ -29,11 +29,11 @@ export async function getRepositoryConfig(
globalConfig,
is.string(repository) ? { repository } : repository
);
repoConfig.localDir = upath.join(
repoConfig.cloneDir = upath.join(
repoConfig.baseDir,
`./repos/${repoConfig.platform}/${repoConfig.repository}`
);
await fs.ensureDir(repoConfig.localDir);
await fs.ensureDir(repoConfig.cloneDir);
delete repoConfig.baseDir;
return configParser.filterConfig(repoConfig, 'repository');
}

View file

@ -18,7 +18,7 @@ describe(getName(), () => {
let config: RenovateConfig;
beforeEach(() => {
config = getConfig();
setAdminConfig({ localDir: '' });
setAdminConfig({ cloneDir: '' });
});
it('runs', async () => {
process.extractDependencies.mockResolvedValue(mock<ExtractResult>());

View file

@ -34,10 +34,10 @@ export async function renovateRepository(
logger.trace({ config });
let repoResult: ProcessResult;
queue.clear();
const { localDir } = getAdminConfig();
const { cloneDir } = getAdminConfig();
try {
await fs.ensureDir(localDir);
logger.debug('Using localDir: ' + localDir);
await fs.ensureDir(cloneDir);
logger.debug('Using cloneDir: ' + cloneDir);
config = await initRepo(config);
addSplit('init');
const { branches, branchList, packageFiles } = await extractDependencies(
@ -57,11 +57,11 @@ export async function renovateRepository(
const errorRes = await handleError(config, err);
repoResult = processResult(config, errorRes);
}
if (localDir && !config.persistRepoData) {
if (cloneDir && !config.persistRepoData) {
try {
await deleteLocalFile('.');
} catch (err) /* istanbul ignore if */ {
logger.warn({ err }, 'localDir deletion error');
logger.warn({ err }, 'cloneDir deletion error');
}
}
try {

View file

@ -24,7 +24,7 @@ const secrets = mocked(_secrets);
describe(getName(), () => {
beforeEach(() => {
setAdminConfig({ localDir: '', cacheDir: '' });
setAdminConfig({ cloneDir: '', cacheDir: '' });
});
afterEach(() => {
setAdminConfig();