mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 23:16:26 +00:00
refactor: localDir -> cloneDir (#10158)
This commit is contained in:
parent
66863ea419
commit
0b287c763d
52 changed files with 131 additions and 131 deletions
|
@ -16,7 +16,7 @@ const repoAdminOptions = [
|
||||||
'exposeAllEnv',
|
'exposeAllEnv',
|
||||||
'migratePresets',
|
'migratePresets',
|
||||||
'privateKey',
|
'privateKey',
|
||||||
'localDir',
|
'cloneDir',
|
||||||
'cacheDir',
|
'cacheDir',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -98,14 +98,14 @@ export interface RepoAdminConfig {
|
||||||
exposeAllEnv?: boolean;
|
exposeAllEnv?: boolean;
|
||||||
migratePresets?: Record<string, string>;
|
migratePresets?: Record<string, string>;
|
||||||
privateKey?: string | Buffer;
|
privateKey?: string | Buffer;
|
||||||
localDir?: string;
|
cloneDir?: string;
|
||||||
cacheDir?: string;
|
cacheDir?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LegacyAdminConfig {
|
export interface LegacyAdminConfig {
|
||||||
endpoint?: string;
|
endpoint?: string;
|
||||||
|
|
||||||
localDir?: string;
|
cloneDir?: string;
|
||||||
|
|
||||||
logContext?: string;
|
logContext?: string;
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ describe(getName(), () => {
|
||||||
tmpDir = await dir();
|
tmpDir = await dir();
|
||||||
|
|
||||||
adminConfig = {
|
adminConfig = {
|
||||||
localDir: join(tmpDir.path, 'local'),
|
cloneDir: join(tmpDir.path, 'local'),
|
||||||
cacheDir: join(tmpDir.path, 'cache'),
|
cacheDir: join(tmpDir.path, 'cache'),
|
||||||
};
|
};
|
||||||
setAdminConfig(adminConfig);
|
setAdminConfig(adminConfig);
|
||||||
|
|
|
@ -28,7 +28,7 @@ function createGitDependency(repo: string, version: string): PackageDependency {
|
||||||
}
|
}
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoAdminConfig = {
|
||||||
localDir: '',
|
cloneDir: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
const config: ExtractConfig = {};
|
const config: ExtractConfig = {};
|
||||||
|
|
|
@ -30,7 +30,7 @@ jest.mock('./host-rules');
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoAdminConfig = {
|
||||||
// `join` fixes Windows CI
|
// `join` fixes Windows CI
|
||||||
localDir: join('/tmp/github/some/repo'),
|
cloneDir: join('/tmp/github/some/repo'),
|
||||||
cacheDir: join('/tmp/cache'),
|
cacheDir: join('/tmp/cache'),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ const config: UpdateArtifactsConfig = {};
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoAdminConfig = {
|
||||||
// `join` fixes Windows CI
|
// `join` fixes Windows CI
|
||||||
localDir: join('/tmp/github/some/repo'),
|
cloneDir: join('/tmp/github/some/repo'),
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('.updateArtifacts()', () => {
|
describe('.updateArtifacts()', () => {
|
||||||
|
|
|
@ -24,7 +24,7 @@ describe(getName(), () => {
|
||||||
config = {};
|
config = {};
|
||||||
const tmpDir = await dir();
|
const tmpDir = await dir();
|
||||||
adminConfig = {
|
adminConfig = {
|
||||||
localDir: join(tmpDir.path, 'local'),
|
cloneDir: join(tmpDir.path, 'local'),
|
||||||
cacheDir: join(tmpDir.path, 'cache'),
|
cacheDir: join(tmpDir.path, 'cache'),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ delete process.env.CP_HOME_DIR;
|
||||||
const config: UpdateArtifactsConfig = {};
|
const config: UpdateArtifactsConfig = {};
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoAdminConfig = {
|
||||||
localDir: join('/tmp/github/some/repo'),
|
cloneDir: join('/tmp/github/some/repo'),
|
||||||
cacheDir: join('/tmp/cache'),
|
cacheDir: join('/tmp/cache'),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -83,7 +83,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({
|
setAdminConfig({
|
||||||
localDir: '',
|
cloneDir: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
|
|
|
@ -7,7 +7,7 @@ const simplePodfile = loadFixture('Podfile.simple');
|
||||||
const complexPodfile = loadFixture('Podfile.complex');
|
const complexPodfile = loadFixture('Podfile.complex');
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoAdminConfig = {
|
||||||
localDir: '',
|
cloneDir: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
|
|
|
@ -35,7 +35,7 @@ const config: UpdateArtifactsConfig = {
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoAdminConfig = {
|
||||||
allowScripts: false,
|
allowScripts: false,
|
||||||
// `join` fixes Windows CI
|
// `join` fixes Windows CI
|
||||||
localDir: join('/tmp/github/some/repo'),
|
cloneDir: join('/tmp/github/some/repo'),
|
||||||
cacheDir: join('/tmp/renovate/cache'),
|
cacheDir: join('/tmp/renovate/cache'),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
describe('extractPackageFile()', () => {
|
describe('extractPackageFile()', () => {
|
||||||
it('extracts submodules', async () => {
|
it('extracts submodules', async () => {
|
||||||
setAdminConfig({ localDir: `${__dirname}/__fixtures__` });
|
setAdminConfig({ cloneDir: `${__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();
|
||||||
|
|
|
@ -88,9 +88,9 @@ export default async function extractPackageFile(
|
||||||
fileName: string,
|
fileName: string,
|
||||||
config: ManagerConfig
|
config: ManagerConfig
|
||||||
): Promise<PackageFile | null> {
|
): Promise<PackageFile | null> {
|
||||||
const { localDir } = getAdminConfig();
|
const { cloneDir } = getAdminConfig();
|
||||||
const git = Git(localDir);
|
const git = Git(cloneDir);
|
||||||
const gitModulesPath = upath.join(localDir, fileName);
|
const gitModulesPath = upath.join(cloneDir, fileName);
|
||||||
|
|
||||||
const depNames = await getModules(git, gitModulesPath);
|
const depNames = await getModules(git, gitModulesPath);
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ describe(getName(), () => {
|
||||||
upgrade = { depName: 'renovate' };
|
upgrade = { depName: 'renovate' };
|
||||||
|
|
||||||
const tmpDir = await dir();
|
const tmpDir = await dir();
|
||||||
adminConfig = { localDir: join(tmpDir.path) };
|
adminConfig = { cloneDir: join(tmpDir.path) };
|
||||||
setAdminConfig(adminConfig);
|
setAdminConfig(adminConfig);
|
||||||
});
|
});
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
|
|
|
@ -8,9 +8,9 @@ export default async function updateDependency({
|
||||||
fileContent,
|
fileContent,
|
||||||
upgrade,
|
upgrade,
|
||||||
}: UpdateDependencyConfig): Promise<string | null> {
|
}: UpdateDependencyConfig): Promise<string | null> {
|
||||||
const { localDir } = getAdminConfig();
|
const { cloneDir } = getAdminConfig();
|
||||||
const git = Git(localDir);
|
const git = Git(cloneDir);
|
||||||
const submoduleGit = Git(upath.join(localDir, upgrade.depName));
|
const submoduleGit = Git(upath.join(cloneDir, upgrade.depName));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await git.submoduleUpdate(['--init', upgrade.depName]);
|
await git.submoduleUpdate(['--init', upgrade.depName]);
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { extractAllPackageFiles } from './extract';
|
||||||
|
|
||||||
const config: ExtractConfig = {};
|
const config: ExtractConfig = {};
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = { localDir: '' };
|
const adminConfig: RepoAdminConfig = { cloneDir: '' };
|
||||||
|
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -40,7 +40,7 @@ replace github.com/pkg/errors => ../errors
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoAdminConfig = {
|
||||||
// `join` fixes Windows CI
|
// `join` fixes Windows CI
|
||||||
localDir: join('/tmp/github/some/repo'),
|
cloneDir: join('/tmp/github/some/repo'),
|
||||||
cacheDir: join('/tmp/renovate/cache'),
|
cacheDir: join('/tmp/renovate/cache'),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ jest.mock('../../util/git');
|
||||||
const fixtures = resolve(__dirname, './__fixtures__');
|
const fixtures = resolve(__dirname, './__fixtures__');
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoAdminConfig = {
|
||||||
localDir: resolve(fixtures, './testFiles'),
|
cloneDir: resolve(fixtures, './testFiles'),
|
||||||
};
|
};
|
||||||
|
|
||||||
const config: UpdateArtifactsConfig = {
|
const config: UpdateArtifactsConfig = {
|
||||||
|
@ -169,7 +169,7 @@ describe(getName(), () => {
|
||||||
it('gradlew failed', async () => {
|
it('gradlew failed', async () => {
|
||||||
const wrongCmdConfig = {
|
const wrongCmdConfig = {
|
||||||
...adminConfig,
|
...adminConfig,
|
||||||
localDir: resolve(fixtures, './wrongCmd'),
|
cloneDir: resolve(fixtures, './wrongCmd'),
|
||||||
};
|
};
|
||||||
|
|
||||||
await setExecConfig(wrongCmdConfig);
|
await setExecConfig(wrongCmdConfig);
|
||||||
|
@ -196,7 +196,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('gradlew not found', async () => {
|
it('gradlew not found', async () => {
|
||||||
setAdminConfig({ localDir: 'some-dir' });
|
setAdminConfig({ cloneDir: 'some-dir' });
|
||||||
const res = await dcUpdate.updateArtifacts({
|
const res = await dcUpdate.updateArtifacts({
|
||||||
packageFileName: 'gradle-wrapper.properties',
|
packageFileName: 'gradle-wrapper.properties',
|
||||||
updatedDeps: [],
|
updatedDeps: [],
|
||||||
|
@ -243,7 +243,7 @@ describe(getName(), () => {
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
await readString(
|
await readString(
|
||||||
adminConfig.localDir,
|
adminConfig.cloneDir,
|
||||||
`./gradle/wrapper/gradle-wrapper.properties`
|
`./gradle/wrapper/gradle-wrapper.properties`
|
||||||
)
|
)
|
||||||
).toEqual(newContent);
|
).toEqual(newContent);
|
||||||
|
|
|
@ -30,7 +30,7 @@ const exec: jest.Mock<typeof _exec> = _exec as any;
|
||||||
const fixtures = resolve(__dirname, './__fixtures__');
|
const fixtures = resolve(__dirname, './__fixtures__');
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoAdminConfig = {
|
||||||
localDir: resolve(fixtures, './testFiles'),
|
cloneDir: resolve(fixtures, './testFiles'),
|
||||||
};
|
};
|
||||||
|
|
||||||
const dockerAdminConfig = { ...adminConfig, binarySource: BinarySource.Docker };
|
const dockerAdminConfig = { ...adminConfig, binarySource: BinarySource.Docker };
|
||||||
|
@ -105,7 +105,7 @@ describe(getName(), () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('gradlew not found', async () => {
|
it('gradlew not found', async () => {
|
||||||
setAdminConfig({ ...adminConfig, localDir: 'some-dir' });
|
setAdminConfig({ ...adminConfig, cloneDir: 'some-dir' });
|
||||||
const res = await dcUpdate.updateArtifacts({
|
const res = await dcUpdate.updateArtifacts({
|
||||||
packageFileName: 'gradle-wrapper.properties',
|
packageFileName: 'gradle-wrapper.properties',
|
||||||
updatedDeps: [],
|
updatedDeps: [],
|
||||||
|
|
|
@ -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 { cloneDir: projectDir } = getAdminConfig();
|
||||||
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}`);
|
||||||
|
|
|
@ -11,7 +11,7 @@ import type {
|
||||||
export const GRADLE_DEPENDENCY_REPORT_FILENAME = 'gradle-renovate-report.json';
|
export const GRADLE_DEPENDENCY_REPORT_FILENAME = 'gradle-renovate-report.json';
|
||||||
|
|
||||||
export async function createRenovateGradlePlugin(
|
export async function createRenovateGradlePlugin(
|
||||||
localDir: string
|
cloneDir: string
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const content = `
|
const content = `
|
||||||
import groovy.json.JsonOutput
|
import groovy.json.JsonOutput
|
||||||
|
@ -47,16 +47,16 @@ gradle.buildFinished {
|
||||||
def json = JsonOutput.toJson(output)
|
def json = JsonOutput.toJson(output)
|
||||||
outputFile.write json
|
outputFile.write json
|
||||||
}`;
|
}`;
|
||||||
const gradleInitFile = join(localDir, 'renovate-plugin.gradle');
|
const gradleInitFile = join(cloneDir, 'renovate-plugin.gradle');
|
||||||
logger.debug(
|
logger.debug(
|
||||||
'Creating renovate-plugin.gradle file with renovate gradle plugin'
|
'Creating renovate-plugin.gradle file with renovate gradle plugin'
|
||||||
);
|
);
|
||||||
await writeFile(gradleInitFile, content);
|
await writeFile(gradleInitFile, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function readGradleReport(localDir: string): Promise<GradleProject[]> {
|
async function readGradleReport(cloneDir: string): Promise<GradleProject[]> {
|
||||||
const renovateReportFilename = join(
|
const renovateReportFilename = join(
|
||||||
localDir,
|
cloneDir,
|
||||||
GRADLE_DEPENDENCY_REPORT_FILENAME
|
GRADLE_DEPENDENCY_REPORT_FILENAME
|
||||||
);
|
);
|
||||||
if (!(await exists(renovateReportFilename))) {
|
if (!(await exists(renovateReportFilename))) {
|
||||||
|
@ -123,9 +123,9 @@ function buildDependency(
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function extractDependenciesFromUpdatesReport(
|
export async function extractDependenciesFromUpdatesReport(
|
||||||
localDir: string
|
cloneDir: string
|
||||||
): Promise<BuildDependency[]> {
|
): Promise<BuildDependency[]> {
|
||||||
const gradleProjectConfigurations = await readGradleReport(localDir);
|
const gradleProjectConfigurations = await readGradleReport(cloneDir);
|
||||||
|
|
||||||
const dependencies = gradleProjectConfigurations
|
const dependencies = gradleProjectConfigurations
|
||||||
.map(mergeDependenciesWithRepositories, [])
|
.map(mergeDependenciesWithRepositories, [])
|
||||||
|
|
|
@ -26,7 +26,7 @@ describe(getName(), () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
workingDir = await tmp.dir({ unsafeCleanup: true });
|
workingDir = await tmp.dir({ unsafeCleanup: true });
|
||||||
successFile = '';
|
successFile = '';
|
||||||
adminConfig = { localDir: workingDir.path };
|
adminConfig = { cloneDir: workingDir.path };
|
||||||
setAdminConfig(adminConfig);
|
setAdminConfig(adminConfig);
|
||||||
testRunConfig = { ...baseConfig };
|
testRunConfig = { ...baseConfig };
|
||||||
await fsExtra.copy(`${fixtures}/minimal-project`, workingDir.path);
|
await fsExtra.copy(`${fixtures}/minimal-project`, workingDir.path);
|
||||||
|
|
|
@ -29,7 +29,7 @@ jest.mock('../../util/exec/env');
|
||||||
const env = mocked(_env);
|
const env = mocked(_env);
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoAdminConfig = {
|
||||||
localDir: join('/foo/bar'),
|
cloneDir: join('/foo/bar'),
|
||||||
};
|
};
|
||||||
|
|
||||||
const dockerAdminConfig = {
|
const dockerAdminConfig = {
|
||||||
|
|
|
@ -93,11 +93,11 @@ 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 { cloneDir } = getAdminConfig();
|
||||||
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));
|
||||||
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)) {
|
if (['build.gradle', 'build.gradle.kts'].includes(packageFile)) {
|
||||||
rootBuildGradle = packageFile;
|
rootBuildGradle = packageFile;
|
||||||
|
@ -116,7 +116,7 @@ export async function extractAllPackageFiles(
|
||||||
}
|
}
|
||||||
logger.debug('Extracting dependencies from all gradle files');
|
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 createRenovateGradlePlugin(cwd);
|
||||||
await executeGradle(config, cwd, gradlew);
|
await executeGradle(config, cwd, gradlew);
|
||||||
|
|
|
@ -23,7 +23,7 @@ const exec: jest.Mock<typeof _exec> = _exec as any;
|
||||||
const env = mocked(_env);
|
const env = mocked(_env);
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
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 = {};
|
const config: UpdateArtifactsConfig = {};
|
||||||
|
|
|
@ -15,7 +15,7 @@ jest.mock('../../util/fs');
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoAdminConfig = {
|
||||||
// `join` fixes Windows CI
|
// `join` fixes Windows CI
|
||||||
localDir: join('/tmp/github/some/repo'),
|
cloneDir: join('/tmp/github/some/repo'),
|
||||||
};
|
};
|
||||||
|
|
||||||
const config: UpdateArtifactsConfig = {};
|
const config: UpdateArtifactsConfig = {};
|
||||||
|
|
|
@ -6,7 +6,7 @@ const sample = loadFixture('mix.exs');
|
||||||
|
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
setAdminConfig({ localDir: '' });
|
setAdminConfig({ cloneDir: '' });
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('extractPackageFile()', () => {
|
describe('extractPackageFile()', () => {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {
|
||||||
|
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
setAdminConfig({ localDir: getFixturePath('pnpm-monorepo/', '..') });
|
setAdminConfig({ cloneDir: getFixturePath('pnpm-monorepo/', '..') });
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('.extractPnpmFilters()', () => {
|
describe('.extractPnpmFilters()', () => {
|
||||||
|
|
|
@ -139,10 +139,10 @@ 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 { cloneDir } = getAdminConfig();
|
||||||
for (const packageFile of npmFiles) {
|
for (const packageFile of npmFiles) {
|
||||||
const basedir = upath.join(
|
const basedir = upath.join(
|
||||||
localDir,
|
cloneDir,
|
||||||
upath.dirname(packageFile.packageFile)
|
upath.dirname(packageFile.packageFile)
|
||||||
);
|
);
|
||||||
const npmrc: string = packageFile.npmrc || config.npmrc;
|
const npmrc: string = packageFile.npmrc || config.npmrc;
|
||||||
|
@ -170,7 +170,7 @@ export async function writeExistingFiles(
|
||||||
}
|
}
|
||||||
const { npmLock } = packageFile;
|
const { npmLock } = packageFile;
|
||||||
if (npmLock) {
|
if (npmLock) {
|
||||||
const npmLockPath = upath.join(localDir, npmLock);
|
const npmLockPath = upath.join(cloneDir, npmLock);
|
||||||
if (
|
if (
|
||||||
process.env.RENOVATE_REUSE_PACKAGE_LOCK === 'false' ||
|
process.env.RENOVATE_REUSE_PACKAGE_LOCK === 'false' ||
|
||||||
config.reuseLockFiles === false
|
config.reuseLockFiles === false
|
||||||
|
@ -232,12 +232,12 @@ export async function writeUpdatedPackageFiles(
|
||||||
logger.debug('No files found');
|
logger.debug('No files found');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { localDir } = getAdminConfig();
|
const { cloneDir } = getAdminConfig();
|
||||||
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}`);
|
||||||
await outputFile(
|
await outputFile(
|
||||||
upath.join(localDir, packageFile.name),
|
upath.join(cloneDir, packageFile.name),
|
||||||
packageFile.contents
|
packageFile.contents
|
||||||
);
|
);
|
||||||
continue; // eslint-disable-line
|
continue; // eslint-disable-line
|
||||||
|
@ -266,7 +266,7 @@ export async function writeUpdatedPackageFiles(
|
||||||
logger.warn({ err }, 'Error adding token to package files');
|
logger.warn({ err }, 'Error adding token to package files');
|
||||||
}
|
}
|
||||||
await outputFile(
|
await outputFile(
|
||||||
upath.join(localDir, packageFile.name),
|
upath.join(cloneDir, packageFile.name),
|
||||||
JSON.stringify(massagedFile)
|
JSON.stringify(massagedFile)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -332,7 +332,7 @@ async function resetNpmrcContent(
|
||||||
// istanbul ignore next
|
// istanbul ignore next
|
||||||
async function updateYarnOffline(
|
async function updateYarnOffline(
|
||||||
lockFileDir: string,
|
lockFileDir: string,
|
||||||
localDir: string,
|
cloneDir: string,
|
||||||
updatedArtifacts: UpdatedArtifacts[]
|
updatedArtifacts: UpdatedArtifacts[]
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
try {
|
try {
|
||||||
|
@ -372,7 +372,7 @@ async function updateYarnOffline(
|
||||||
const status = await getRepoStatus();
|
const status = await getRepoStatus();
|
||||||
for (const f of status.modified.concat(status.not_added)) {
|
for (const f of status.modified.concat(status.not_added)) {
|
||||||
if (resolvedPaths.some((p) => f.startsWith(p))) {
|
if (resolvedPaths.some((p) => f.startsWith(p))) {
|
||||||
const localModified = upath.join(localDir, f);
|
const localModified = upath.join(cloneDir, f);
|
||||||
updatedArtifacts.push({
|
updatedArtifacts.push({
|
||||||
name: f,
|
name: f,
|
||||||
contents: await readFile(localModified),
|
contents: await readFile(localModified),
|
||||||
|
@ -463,10 +463,10 @@ 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 { cloneDir } = getAdminConfig();
|
||||||
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(cloneDir, lockFileDir);
|
||||||
const npmrcContent = await getNpmrcContent(fullLockFileDir);
|
const npmrcContent = await getNpmrcContent(fullLockFileDir);
|
||||||
await updateNpmrcContent(
|
await updateNpmrcContent(
|
||||||
fullLockFileDir,
|
fullLockFileDir,
|
||||||
|
@ -529,7 +529,7 @@ export async function getAdditionalFiles(
|
||||||
|
|
||||||
for (const yarnLock of dirs.yarnLockDirs) {
|
for (const yarnLock of dirs.yarnLockDirs) {
|
||||||
const lockFileDir = upath.dirname(yarnLock);
|
const lockFileDir = upath.dirname(yarnLock);
|
||||||
const fullLockFileDir = upath.join(localDir, lockFileDir);
|
const fullLockFileDir = upath.join(cloneDir, lockFileDir);
|
||||||
const npmrcContent = await getNpmrcContent(fullLockFileDir);
|
const npmrcContent = await getNpmrcContent(fullLockFileDir);
|
||||||
await updateNpmrcContent(
|
await updateNpmrcContent(
|
||||||
fullLockFileDir,
|
fullLockFileDir,
|
||||||
|
@ -561,7 +561,7 @@ export async function getAdditionalFiles(
|
||||||
(upgrade) => upgrade.yarnLock === yarnLock
|
(upgrade) => upgrade.yarnLock === yarnLock
|
||||||
);
|
);
|
||||||
const res = await yarn.generateLockFile(
|
const res = await yarn.generateLockFile(
|
||||||
upath.join(localDir, lockFileDir),
|
upath.join(cloneDir, lockFileDir),
|
||||||
env,
|
env,
|
||||||
config,
|
config,
|
||||||
upgrades
|
upgrades
|
||||||
|
@ -607,7 +607,7 @@ export async function getAdditionalFiles(
|
||||||
name: lockFileName,
|
name: lockFileName,
|
||||||
contents: res.lockFile,
|
contents: res.lockFile,
|
||||||
});
|
});
|
||||||
await updateYarnOffline(lockFileDir, localDir, updatedArtifacts);
|
await updateYarnOffline(lockFileDir, cloneDir, updatedArtifacts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await resetNpmrcContent(fullLockFileDir, npmrcContent);
|
await resetNpmrcContent(fullLockFileDir, npmrcContent);
|
||||||
|
@ -618,7 +618,7 @@ export async function getAdditionalFiles(
|
||||||
|
|
||||||
for (const pnpmShrinkwrap of dirs.pnpmShrinkwrapDirs) {
|
for (const pnpmShrinkwrap of dirs.pnpmShrinkwrapDirs) {
|
||||||
const lockFileDir = upath.dirname(pnpmShrinkwrap);
|
const lockFileDir = upath.dirname(pnpmShrinkwrap);
|
||||||
const fullLockFileDir = upath.join(localDir, lockFileDir);
|
const fullLockFileDir = upath.join(cloneDir, lockFileDir);
|
||||||
const npmrcContent = await getNpmrcContent(fullLockFileDir);
|
const npmrcContent = await getNpmrcContent(fullLockFileDir);
|
||||||
await updateNpmrcContent(
|
await updateNpmrcContent(
|
||||||
fullLockFileDir,
|
fullLockFileDir,
|
||||||
|
@ -630,7 +630,7 @@ export async function getAdditionalFiles(
|
||||||
(upgrade) => upgrade.pnpmShrinkwrap === pnpmShrinkwrap
|
(upgrade) => upgrade.pnpmShrinkwrap === pnpmShrinkwrap
|
||||||
);
|
);
|
||||||
const res = await pnpm.generateLockFile(
|
const res = await pnpm.generateLockFile(
|
||||||
upath.join(localDir, lockFileDir),
|
upath.join(cloneDir, lockFileDir),
|
||||||
env,
|
env,
|
||||||
config,
|
config,
|
||||||
upgrades
|
upgrades
|
||||||
|
@ -697,7 +697,7 @@ export async function getAdditionalFiles(
|
||||||
const skipInstalls =
|
const skipInstalls =
|
||||||
lockFile === 'npm-shrinkwrap.json' ? false : config.skipInstalls;
|
lockFile === 'npm-shrinkwrap.json' ? false : config.skipInstalls;
|
||||||
const fullLearnaFileDir = upath.join(
|
const fullLearnaFileDir = upath.join(
|
||||||
localDir,
|
cloneDir,
|
||||||
getSubDirectory(lernaJsonFile)
|
getSubDirectory(lernaJsonFile)
|
||||||
);
|
);
|
||||||
const npmrcContent = await getNpmrcContent(fullLearnaFileDir);
|
const npmrcContent = await getNpmrcContent(fullLearnaFileDir);
|
||||||
|
@ -769,7 +769,7 @@ export async function getAdditionalFiles(
|
||||||
);
|
);
|
||||||
if (existingContent) {
|
if (existingContent) {
|
||||||
logger.trace('Found lock file');
|
logger.trace('Found lock file');
|
||||||
const lockFilePath = upath.join(localDir, filename);
|
const lockFilePath = upath.join(cloneDir, filename);
|
||||||
logger.trace('Checking against ' + lockFilePath);
|
logger.trace('Checking against ' + lockFilePath);
|
||||||
try {
|
try {
|
||||||
let newContent: string;
|
let newContent: string;
|
||||||
|
|
|
@ -35,7 +35,7 @@ const hostRules = mocked(_hostRules);
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoAdminConfig = {
|
||||||
// `join` fixes Windows CI
|
// `join` fixes Windows CI
|
||||||
localDir: join('/tmp/github/some/repo'),
|
cloneDir: join('/tmp/github/some/repo'),
|
||||||
cacheDir: join('/tmp/renovate/cache'),
|
cacheDir: join('/tmp/renovate/cache'),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -29,9 +29,9 @@ async function addSourceCmds(
|
||||||
config: UpdateArtifactsConfig,
|
config: UpdateArtifactsConfig,
|
||||||
nugetConfigFile: string
|
nugetConfigFile: string
|
||||||
): Promise<string[]> {
|
): Promise<string[]> {
|
||||||
const { localDir } = getAdminConfig();
|
const { cloneDir } = getAdminConfig();
|
||||||
const registries =
|
const registries =
|
||||||
(await getConfiguredRegistries(packageFileName, localDir)) ||
|
(await getConfiguredRegistries(packageFileName, cloneDir)) ||
|
||||||
getDefaultRegistries();
|
getDefaultRegistries();
|
||||||
const result = [];
|
const result = [];
|
||||||
for (const registry of registries) {
|
for (const registry of registries) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { extractPackageFile } from './extract';
|
||||||
const config: ExtractConfig = {};
|
const config: ExtractConfig = {};
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoAdminConfig = {
|
||||||
localDir: upath.resolve('lib/manager/nuget/__fixtures__'),
|
cloneDir: upath.resolve('lib/manager/nuget/__fixtures__'),
|
||||||
};
|
};
|
||||||
|
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
|
|
|
@ -71,8 +71,8 @@ export async function extractPackageFile(
|
||||||
): Promise<PackageFile | null> {
|
): Promise<PackageFile | null> {
|
||||||
logger.trace({ packageFile }, 'nuget.extractPackageFile()');
|
logger.trace({ packageFile }, 'nuget.extractPackageFile()');
|
||||||
|
|
||||||
const { localDir } = getAdminConfig();
|
const { cloneDir } = getAdminConfig();
|
||||||
const registries = await getConfiguredRegistries(packageFile, localDir);
|
const registries = await getConfiguredRegistries(packageFile, cloneDir);
|
||||||
const registryUrls = registries
|
const registryUrls = registries
|
||||||
? registries.map((registry) => registry.url)
|
? registries.map((registry) => registry.url)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
|
@ -32,12 +32,12 @@ export function getDefaultRegistries(): Registry[] {
|
||||||
|
|
||||||
export async function getConfiguredRegistries(
|
export async function getConfiguredRegistries(
|
||||||
packageFile: string,
|
packageFile: string,
|
||||||
localDir: string
|
cloneDir: string
|
||||||
): Promise<Registry[] | undefined> {
|
): 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
|
// 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'];
|
const nuGetConfigFileNames = ['nuget.config', 'NuGet.config', 'NuGet.Config'];
|
||||||
// normalize paths, otherwise startsWith can fail because of path delimitter mismatch
|
// 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, {
|
const nuGetConfigPath = await findUp(nuGetConfigFileNames, {
|
||||||
cwd: upath.dirname(upath.join(normalizedLocalDir, packageFile)),
|
cwd: upath.dirname(upath.join(normalizedLocalDir, packageFile)),
|
||||||
type: 'file',
|
type: 'file',
|
||||||
|
|
|
@ -19,7 +19,7 @@ describe('.updateArtifacts()', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
jest.resetModules();
|
jest.resetModules();
|
||||||
setAdminConfig({ localDir: '' });
|
setAdminConfig({ cloneDir: '' });
|
||||||
});
|
});
|
||||||
it('returns null if no updatedDeps were provided', async () => {
|
it('returns null if no updatedDeps were provided', async () => {
|
||||||
expect(
|
expect(
|
||||||
|
|
|
@ -18,7 +18,7 @@ describe(getName(), () => {
|
||||||
resetModule();
|
resetModule();
|
||||||
|
|
||||||
env.getChildProcessEnv.mockReturnValue(envMock.basic);
|
env.getChildProcessEnv.mockReturnValue(envMock.basic);
|
||||||
setAdminConfig({ localDir: '/tmp/foo/bar' });
|
setAdminConfig({ cloneDir: '/tmp/foo/bar' });
|
||||||
});
|
});
|
||||||
describe('parsePythonVersion', () => {
|
describe('parsePythonVersion', () => {
|
||||||
it('returns major and minor version numbers', () => {
|
it('returns major and minor version numbers', () => {
|
||||||
|
|
|
@ -20,7 +20,7 @@ const content = loadFixture(packageFile);
|
||||||
const jsonContent = loadFixture('setup.py.json');
|
const jsonContent = loadFixture('setup.py.json');
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoAdminConfig = {
|
||||||
localDir: '/tmp/github/some/repo',
|
cloneDir: '/tmp/github/some/repo',
|
||||||
cacheDir: '/tmp/renovate/cache',
|
cacheDir: '/tmp/renovate/cache',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ const env = mocked(_env);
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoAdminConfig = {
|
||||||
// `join` fixes Windows CI
|
// `join` fixes Windows CI
|
||||||
localDir: join('/tmp/github/some/repo'),
|
cloneDir: join('/tmp/github/some/repo'),
|
||||||
cacheDir: join('/tmp/renovate/cache'),
|
cacheDir: join('/tmp/renovate/cache'),
|
||||||
};
|
};
|
||||||
const dockerAdminConfig = { ...adminConfig, binarySource: BinarySource.Docker };
|
const dockerAdminConfig = { ...adminConfig, binarySource: BinarySource.Docker };
|
||||||
|
|
|
@ -29,7 +29,7 @@ const datasource = mocked(_datasource);
|
||||||
const hostRules = mocked(_hostRules);
|
const hostRules = mocked(_hostRules);
|
||||||
|
|
||||||
const adminConfig: RepoAdminConfig = {
|
const adminConfig: RepoAdminConfig = {
|
||||||
localDir: join('/tmp/github/some/repo'),
|
cloneDir: join('/tmp/github/some/repo'),
|
||||||
};
|
};
|
||||||
|
|
||||||
const config: UpdateArtifactsConfig = {};
|
const config: UpdateArtifactsConfig = {};
|
||||||
|
|
|
@ -197,7 +197,7 @@ export async function generateDockerCommand(
|
||||||
const preCommands = options.preCommands || [];
|
const preCommands = options.preCommands || [];
|
||||||
const postCommands = options.postCommands || [];
|
const postCommands = options.postCommands || [];
|
||||||
const {
|
const {
|
||||||
localDir,
|
cloneDir,
|
||||||
cacheDir,
|
cacheDir,
|
||||||
dockerUser,
|
dockerUser,
|
||||||
dockerChildPrefix,
|
dockerChildPrefix,
|
||||||
|
@ -212,7 +212,7 @@ export async function generateDockerCommand(
|
||||||
result.push(`--user=${dockerUser}`);
|
result.push(`--user=${dockerUser}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
result.push(...prepareVolumes([localDir, cacheDir, ...volumes]));
|
result.push(...prepareVolumes([cloneDir, cacheDir, ...volumes]));
|
||||||
|
|
||||||
if (envVars) {
|
if (envVars) {
|
||||||
result.push(
|
result.push(
|
||||||
|
|
|
@ -717,7 +717,7 @@ describe(getName(), () => {
|
||||||
callback(null, { stdout: '', stderr: '' });
|
callback(null, { stdout: '', stderr: '' });
|
||||||
return undefined;
|
return undefined;
|
||||||
});
|
});
|
||||||
setAdminConfig({ cacheDir, localDir: cwd, ...adminConfig });
|
setAdminConfig({ cacheDir, cloneDir: cwd, ...adminConfig });
|
||||||
await exec(cmd as string, inOpts);
|
await exec(cmd as string, inOpts);
|
||||||
|
|
||||||
expect(actualCmd).toEqual(outCommand);
|
expect(actualCmd).toEqual(outCommand);
|
||||||
|
|
|
@ -97,11 +97,11 @@ export async function exec(
|
||||||
const extraEnv = { ...opts.extraEnv, ...customEnvVariables };
|
const extraEnv = { ...opts.extraEnv, ...customEnvVariables };
|
||||||
let cwd;
|
let cwd;
|
||||||
// istanbul ignore if
|
// istanbul ignore if
|
||||||
const { localDir } = getAdminConfig();
|
const { cloneDir } = getAdminConfig();
|
||||||
if (cwdFile) {
|
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 childEnv = createChildEnv(env, extraEnv);
|
||||||
|
|
||||||
const execOptions: ExecOptions = { ...opts };
|
const execOptions: ExecOptions = { ...opts };
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
describe('readLocalFile', () => {
|
describe('readLocalFile', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
setAdminConfig({ localDir: '' });
|
setAdminConfig({ cloneDir: '' });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('reads buffer', async () => {
|
it('reads buffer', async () => {
|
||||||
|
@ -49,9 +49,9 @@ describe(getName(), () => {
|
||||||
describe('findLocalSiblingOrParent', () => {
|
describe('findLocalSiblingOrParent', () => {
|
||||||
it('returns path for file', async () => {
|
it('returns path for file', async () => {
|
||||||
await withDir(
|
await withDir(
|
||||||
async (localDir) => {
|
async (cloneDir) => {
|
||||||
setAdminConfig({
|
setAdminConfig({
|
||||||
localDir: localDir.path,
|
cloneDir: cloneDir.path,
|
||||||
});
|
});
|
||||||
|
|
||||||
await writeLocalFile('crates/one/Cargo.toml', '');
|
await writeLocalFile('crates/one/Cargo.toml', '');
|
||||||
|
|
|
@ -26,8 +26,8 @@ export async function readLocalFile(
|
||||||
fileName: string,
|
fileName: string,
|
||||||
encoding?: string
|
encoding?: string
|
||||||
): Promise<string | Buffer> {
|
): Promise<string | Buffer> {
|
||||||
const { localDir } = getAdminConfig();
|
const { cloneDir } = getAdminConfig();
|
||||||
const localFileName = join(localDir, fileName);
|
const localFileName = join(cloneDir, fileName);
|
||||||
try {
|
try {
|
||||||
const fileContent = await fs.readFile(localFileName, encoding);
|
const fileContent = await fs.readFile(localFileName, encoding);
|
||||||
return fileContent;
|
return fileContent;
|
||||||
|
@ -41,15 +41,15 @@ export async function writeLocalFile(
|
||||||
fileName: string,
|
fileName: string,
|
||||||
fileContent: string
|
fileContent: string
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const { localDir } = getAdminConfig();
|
const { cloneDir } = getAdminConfig();
|
||||||
const localFileName = join(localDir, fileName);
|
const localFileName = join(cloneDir, 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 { cloneDir } = getAdminConfig();
|
||||||
if (localDir) {
|
if (cloneDir) {
|
||||||
const localFileName = join(localDir, fileName);
|
const localFileName = join(cloneDir, fileName);
|
||||||
await fs.remove(localFileName);
|
await fs.remove(localFileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,8 +59,8 @@ export async function renameLocalFile(
|
||||||
fromFile: string,
|
fromFile: string,
|
||||||
toFile: string
|
toFile: string
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const { localDir } = getAdminConfig();
|
const { cloneDir } = getAdminConfig();
|
||||||
await fs.move(join(localDir, fromFile), join(localDir, toFile));
|
await fs.move(join(cloneDir, fromFile), join(cloneDir, toFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
// istanbul ignore next
|
// istanbul ignore next
|
||||||
|
@ -70,8 +70,8 @@ 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 { cloneDir } = getAdminConfig();
|
||||||
const localDirName = join(localDir, dirName);
|
const localDirName = join(cloneDir, dirName);
|
||||||
await fs.ensureDir(localDirName);
|
await fs.ensureDir(localDirName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,10 +97,10 @@ export function privateCacheDir(): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function localPathExists(pathName: string): Promise<boolean> {
|
export function localPathExists(pathName: string): Promise<boolean> {
|
||||||
const { localDir } = getAdminConfig();
|
const { cloneDir } = getAdminConfig();
|
||||||
// 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(cloneDir, pathName))
|
||||||
.then((s) => !!s)
|
.then((s) => !!s)
|
||||||
.catch(() => false);
|
.catch(() => false);
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ export function localPathExists(pathName: string): Promise<boolean> {
|
||||||
* Tries to find `otherFileName` in the directory where
|
* Tries to find `otherFileName` in the directory where
|
||||||
* `existingFileNameWithPath` is, then in its parent directory, then in the
|
* `existingFileNameWithPath` is, then in its parent directory, then in the
|
||||||
* grandparent, until we reach the top-level directory. All paths
|
* grandparent, until we reach the top-level directory. All paths
|
||||||
* must be relative to `localDir`.
|
* must be relative to `cloneDir`.
|
||||||
*/
|
*/
|
||||||
export async function findLocalSiblingOrParent(
|
export async function findLocalSiblingOrParent(
|
||||||
existingFileNameWithPath: string,
|
existingFileNameWithPath: string,
|
||||||
|
|
|
@ -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 });
|
setAdminConfig({ cloneDir: tmpDir.path });
|
||||||
await git.initRepo({
|
await git.initRepo({
|
||||||
url: origin.path,
|
url: origin.path,
|
||||||
gitAuthorName: 'Jest',
|
gitAuthorName: 'Jest',
|
||||||
|
|
|
@ -175,8 +175,8 @@ export async function initRepo(args: StorageConfig): Promise<void> {
|
||||||
config.ignoredAuthors = [];
|
config.ignoredAuthors = [];
|
||||||
config.additionalBranches = [];
|
config.additionalBranches = [];
|
||||||
config.branchIsModified = {};
|
config.branchIsModified = {};
|
||||||
const { localDir } = getAdminConfig();
|
const { cloneDir } = getAdminConfig();
|
||||||
git = Git(localDir);
|
git = Git(cloneDir);
|
||||||
gitInitialized = false;
|
gitInitialized = false;
|
||||||
await fetchBranchCommits();
|
await fetchBranchCommits();
|
||||||
}
|
}
|
||||||
|
@ -257,9 +257,9 @@ export async function syncGit(): Promise<void> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gitInitialized = true;
|
gitInitialized = true;
|
||||||
const { localDir } = getAdminConfig();
|
const { cloneDir } = getAdminConfig();
|
||||||
logger.debug('Initializing git repository into ' + localDir);
|
logger.debug('Initializing git repository into ' + cloneDir);
|
||||||
const gitHead = join(localDir, '.git/HEAD');
|
const gitHead = join(cloneDir, '.git/HEAD');
|
||||||
let clone = true;
|
let clone = true;
|
||||||
|
|
||||||
if (await fs.exists(gitHead)) {
|
if (await fs.exists(gitHead)) {
|
||||||
|
@ -283,7 +283,7 @@ export async function syncGit(): Promise<void> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (clone) {
|
if (clone) {
|
||||||
await fs.emptyDir(localDir);
|
await fs.emptyDir(cloneDir);
|
||||||
const cloneStart = Date.now();
|
const cloneStart = Date.now();
|
||||||
try {
|
try {
|
||||||
// clone only the default branch
|
// clone only the default branch
|
||||||
|
@ -696,8 +696,8 @@ export async function commitFiles({
|
||||||
await writePrivateKey();
|
await writePrivateKey();
|
||||||
privateKeySet = true;
|
privateKeySet = true;
|
||||||
}
|
}
|
||||||
const { localDir } = getAdminConfig();
|
const { cloneDir } = getAdminConfig();
|
||||||
await configSigningKey(localDir);
|
await configSigningKey(cloneDir);
|
||||||
try {
|
try {
|
||||||
await git.reset(ResetMode.HARD);
|
await git.reset(ResetMode.HARD);
|
||||||
await git.raw(['clean', '-fd']);
|
await git.raw(['clean', '-fd']);
|
||||||
|
@ -708,7 +708,7 @@ export async function commitFiles({
|
||||||
// istanbul ignore if
|
// istanbul ignore if
|
||||||
if (file.name === '|delete|') {
|
if (file.name === '|delete|') {
|
||||||
deleted.push(file.contents as string);
|
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);
|
fileNames.push(file.name);
|
||||||
await gitAdd(file.name);
|
await gitAdd(file.name);
|
||||||
} else {
|
} else {
|
||||||
|
@ -720,7 +720,7 @@ export async function commitFiles({
|
||||||
} else {
|
} else {
|
||||||
contents = file.contents;
|
contents = file.contents;
|
||||||
}
|
}
|
||||||
await fs.outputFile(join(localDir, file.name), contents);
|
await fs.outputFile(join(cloneDir, file.name), contents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// istanbul ignore if
|
// istanbul ignore if
|
||||||
|
|
|
@ -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: getAdminConfig().cloneDir,
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
|
|
|
@ -63,7 +63,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: RepoAdminConfig = { cloneDir: '', cacheDir: '' };
|
||||||
|
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
describe('processBranch', () => {
|
describe('processBranch', () => {
|
||||||
|
@ -781,7 +781,7 @@ describe(getName(), () => {
|
||||||
allowedPostUpgradeCommands: ['^echo {{{versioning}}}$'],
|
allowedPostUpgradeCommands: ['^echo {{{versioning}}}$'],
|
||||||
allowPostUpgradeCommandTemplating: true,
|
allowPostUpgradeCommandTemplating: true,
|
||||||
exposeAllEnv: true,
|
exposeAllEnv: true,
|
||||||
localDir: '/localDir',
|
cloneDir: '/cloneDir',
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = await branchWorker.processBranch({
|
const result = await branchWorker.processBranch({
|
||||||
|
@ -806,7 +806,7 @@ describe(getName(), () => {
|
||||||
|
|
||||||
expect(result).toMatchSnapshot();
|
expect(result).toMatchSnapshot();
|
||||||
expect(exec.exec).toHaveBeenCalledWith('echo semver', {
|
expect(exec.exec).toHaveBeenCalledWith('echo semver', {
|
||||||
cwd: '/localDir',
|
cwd: '/cloneDir',
|
||||||
});
|
});
|
||||||
const errorMessage = expect.stringContaining(
|
const errorMessage = expect.stringContaining(
|
||||||
"Post-upgrade command 'disallowed task' does not match allowed pattern '^echo {{{versioning}}}$'"
|
"Post-upgrade command 'disallowed task' does not match allowed pattern '^echo {{{versioning}}}$'"
|
||||||
|
@ -861,7 +861,7 @@ describe(getName(), () => {
|
||||||
allowedPostUpgradeCommands: ['^exit 1$'],
|
allowedPostUpgradeCommands: ['^exit 1$'],
|
||||||
allowPostUpgradeCommandTemplating: true,
|
allowPostUpgradeCommandTemplating: true,
|
||||||
exposeAllEnv: true,
|
exposeAllEnv: true,
|
||||||
localDir: '/localDir',
|
cloneDir: '/cloneDir',
|
||||||
});
|
});
|
||||||
|
|
||||||
exec.exec.mockRejectedValue(new Error('Meh, this went wrong!'));
|
exec.exec.mockRejectedValue(new Error('Meh, this went wrong!'));
|
||||||
|
@ -930,7 +930,7 @@ describe(getName(), () => {
|
||||||
allowedPostUpgradeCommands: ['^echo {{{versioning}}}$'],
|
allowedPostUpgradeCommands: ['^echo {{{versioning}}}$'],
|
||||||
allowPostUpgradeCommandTemplating: false,
|
allowPostUpgradeCommandTemplating: false,
|
||||||
exposeAllEnv: true,
|
exposeAllEnv: true,
|
||||||
localDir: '/localDir',
|
cloneDir: '/cloneDir',
|
||||||
});
|
});
|
||||||
const result = await branchWorker.processBranch({
|
const result = await branchWorker.processBranch({
|
||||||
...config,
|
...config,
|
||||||
|
@ -954,7 +954,7 @@ describe(getName(), () => {
|
||||||
|
|
||||||
expect(result).toMatchSnapshot();
|
expect(result).toMatchSnapshot();
|
||||||
expect(exec.exec).toHaveBeenCalledWith('echo {{{versioning}}}', {
|
expect(exec.exec).toHaveBeenCalledWith('echo {{{versioning}}}', {
|
||||||
cwd: '/localDir',
|
cwd: '/cloneDir',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1010,7 +1010,7 @@ describe(getName(), () => {
|
||||||
allowedPostUpgradeCommands: ['^echo {{{depName}}}$'],
|
allowedPostUpgradeCommands: ['^echo {{{depName}}}$'],
|
||||||
allowPostUpgradeCommandTemplating: true,
|
allowPostUpgradeCommandTemplating: true,
|
||||||
exposeAllEnv: true,
|
exposeAllEnv: true,
|
||||||
localDir: '/localDir',
|
cloneDir: '/cloneDir',
|
||||||
});
|
});
|
||||||
|
|
||||||
const inconfig: BranchConfig = {
|
const inconfig: BranchConfig = {
|
||||||
|
@ -1061,10 +1061,10 @@ describe(getName(), () => {
|
||||||
|
|
||||||
expect(result).toMatchSnapshot();
|
expect(result).toMatchSnapshot();
|
||||||
expect(exec.exec).toHaveBeenNthCalledWith(1, 'echo some-dep-name-1', {
|
expect(exec.exec).toHaveBeenNthCalledWith(1, 'echo some-dep-name-1', {
|
||||||
cwd: '/localDir',
|
cwd: '/cloneDir',
|
||||||
});
|
});
|
||||||
expect(exec.exec).toHaveBeenNthCalledWith(2, 'echo some-dep-name-2', {
|
expect(exec.exec).toHaveBeenNthCalledWith(2, 'echo some-dep-name-2', {
|
||||||
cwd: '/localDir',
|
cwd: '/cloneDir',
|
||||||
});
|
});
|
||||||
expect(exec.exec).toHaveBeenCalledTimes(2);
|
expect(exec.exec).toHaveBeenCalledTimes(2);
|
||||||
expect(
|
expect(
|
||||||
|
@ -1144,7 +1144,7 @@ describe(getName(), () => {
|
||||||
allowedPostUpgradeCommands: ['^echo hardcoded-string$'],
|
allowedPostUpgradeCommands: ['^echo hardcoded-string$'],
|
||||||
allowPostUpgradeCommandTemplating: true,
|
allowPostUpgradeCommandTemplating: true,
|
||||||
trustLevel: 'high',
|
trustLevel: 'high',
|
||||||
localDir: '/localDir',
|
cloneDir: '/cloneDir',
|
||||||
});
|
});
|
||||||
|
|
||||||
const inconfig: BranchConfig = {
|
const inconfig: BranchConfig = {
|
||||||
|
@ -1194,7 +1194,7 @@ describe(getName(), () => {
|
||||||
const result = await branchWorker.processBranch(inconfig);
|
const result = await branchWorker.processBranch(inconfig);
|
||||||
expect(result).toMatchSnapshot();
|
expect(result).toMatchSnapshot();
|
||||||
expect(exec.exec).toHaveBeenNthCalledWith(1, 'echo hardcoded-string', {
|
expect(exec.exec).toHaveBeenNthCalledWith(1, 'echo hardcoded-string', {
|
||||||
cwd: '/localDir',
|
cwd: '/cloneDir',
|
||||||
});
|
});
|
||||||
expect(exec.exec).toHaveBeenCalledTimes(1);
|
expect(exec.exec).toHaveBeenCalledTimes(1);
|
||||||
expect(
|
expect(
|
||||||
|
|
|
@ -32,7 +32,7 @@ describe(getName(), () => {
|
||||||
describe('writeUpdatedPackageFiles', () => {
|
describe('writeUpdatedPackageFiles', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
setAdminConfig({
|
setAdminConfig({
|
||||||
localDir: 'some-tmp-dir',
|
cloneDir: 'some-tmp-dir',
|
||||||
});
|
});
|
||||||
fs.outputFile = jest.fn();
|
fs.outputFile = jest.fn();
|
||||||
});
|
});
|
||||||
|
@ -71,7 +71,7 @@ describe(getName(), () => {
|
||||||
describe('getAdditionalFiles', () => {
|
describe('getAdditionalFiles', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
setAdminConfig({
|
setAdminConfig({
|
||||||
localDir: 'some-tmp-dir',
|
cloneDir: 'some-tmp-dir',
|
||||||
});
|
});
|
||||||
git.getFile.mockResolvedValueOnce('some lock file contents');
|
git.getFile.mockResolvedValueOnce('some lock file contents');
|
||||||
npm.generateLockFile = jest.fn();
|
npm.generateLockFile = jest.fn();
|
||||||
|
|
|
@ -29,11 +29,11 @@ export async function getRepositoryConfig(
|
||||||
globalConfig,
|
globalConfig,
|
||||||
is.string(repository) ? { repository } : repository
|
is.string(repository) ? { repository } : repository
|
||||||
);
|
);
|
||||||
repoConfig.localDir = upath.join(
|
repoConfig.cloneDir = upath.join(
|
||||||
repoConfig.baseDir,
|
repoConfig.baseDir,
|
||||||
`./repos/${repoConfig.platform}/${repoConfig.repository}`
|
`./repos/${repoConfig.platform}/${repoConfig.repository}`
|
||||||
);
|
);
|
||||||
await fs.ensureDir(repoConfig.localDir);
|
await fs.ensureDir(repoConfig.cloneDir);
|
||||||
delete repoConfig.baseDir;
|
delete repoConfig.baseDir;
|
||||||
return configParser.filterConfig(repoConfig, 'repository');
|
return configParser.filterConfig(repoConfig, 'repository');
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ describe(getName(), () => {
|
||||||
let config: RenovateConfig;
|
let config: RenovateConfig;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
config = getConfig();
|
config = getConfig();
|
||||||
setAdminConfig({ localDir: '' });
|
setAdminConfig({ cloneDir: '' });
|
||||||
});
|
});
|
||||||
it('runs', async () => {
|
it('runs', async () => {
|
||||||
process.extractDependencies.mockResolvedValue(mock<ExtractResult>());
|
process.extractDependencies.mockResolvedValue(mock<ExtractResult>());
|
||||||
|
|
|
@ -34,10 +34,10 @@ export async function renovateRepository(
|
||||||
logger.trace({ config });
|
logger.trace({ config });
|
||||||
let repoResult: ProcessResult;
|
let repoResult: ProcessResult;
|
||||||
queue.clear();
|
queue.clear();
|
||||||
const { localDir } = getAdminConfig();
|
const { cloneDir } = getAdminConfig();
|
||||||
try {
|
try {
|
||||||
await fs.ensureDir(localDir);
|
await fs.ensureDir(cloneDir);
|
||||||
logger.debug('Using localDir: ' + localDir);
|
logger.debug('Using cloneDir: ' + cloneDir);
|
||||||
config = await initRepo(config);
|
config = await initRepo(config);
|
||||||
addSplit('init');
|
addSplit('init');
|
||||||
const { branches, branchList, packageFiles } = await extractDependencies(
|
const { branches, branchList, packageFiles } = await extractDependencies(
|
||||||
|
@ -57,11 +57,11 @@ export async function renovateRepository(
|
||||||
const errorRes = await handleError(config, err);
|
const errorRes = await handleError(config, err);
|
||||||
repoResult = processResult(config, errorRes);
|
repoResult = processResult(config, errorRes);
|
||||||
}
|
}
|
||||||
if (localDir && !config.persistRepoData) {
|
if (cloneDir && !config.persistRepoData) {
|
||||||
try {
|
try {
|
||||||
await deleteLocalFile('.');
|
await deleteLocalFile('.');
|
||||||
} catch (err) /* istanbul ignore if */ {
|
} catch (err) /* istanbul ignore if */ {
|
||||||
logger.warn({ err }, 'localDir deletion error');
|
logger.warn({ err }, 'cloneDir deletion error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -24,7 +24,7 @@ const secrets = mocked(_secrets);
|
||||||
|
|
||||||
describe(getName(), () => {
|
describe(getName(), () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
setAdminConfig({ localDir: '', cacheDir: '' });
|
setAdminConfig({ cloneDir: '', cacheDir: '' });
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
setAdminConfig();
|
setAdminConfig();
|
||||||
|
|
Loading…
Reference in a new issue