Skip to content

Commit

Permalink
refactor: toVersion -> newVersion (#8711)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Feb 16, 2021
1 parent 1e90a54 commit 32440f2
Show file tree
Hide file tree
Showing 73 changed files with 539 additions and 527 deletions.
2 changes: 1 addition & 1 deletion docs/usage/self-hosted-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The command to install dependencies is necessary because, by default, the instal
"postUpgradeTasks": {
"commands": [
"npm ci --ignore-scripts",
"npx ng update {{{depName}}} --from={{{currentVersion}}} --to={{{toVersion}}} --migrateOnly --allowDirty --force"
"npx ng update {{{depName}}} --from={{{currentVersion}}} --to={{{newVersion}}} --migrateOnly --allowDirty --force"
],
"fileFilters": ["**/**"]
}
Expand Down
2 changes: 1 addition & 1 deletion lib/config/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,7 @@ const options: RenovateOptions[] = [
'Extra description used after the commit message topic - typically the version.',
type: 'string',
default:
'to {{#if isMajor}}v{{{newMajor}}}{{else}}{{#if isSingleVersion}}v{{{toVersion}}}{{else}}{{{newValue}}}{{/if}}{{/if}}',
'to {{#if isMajor}}v{{{newMajor}}}{{else}}{{#if isSingleVersion}}v{{{newVersion}}}{{else}}{{{newValue}}}{{/if}}{{/if}}',
cli: false,
},
{
Expand Down
2 changes: 1 addition & 1 deletion lib/config/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,9 +507,9 @@ export function migrateConfig(
fromVersion: 'currentVersion',
newValueMajor: 'newMajor',
newValueMinor: 'newMinor',
newVersion: 'toVersion',
newVersionMajor: 'newMajor',
newVersionMinor: 'newMinor',
toVersion: 'newVersion',
};
if (is.string(migratedConfig[key])) {
for (const [from, to] of Object.entries(migratedTemplates)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/datasource/docker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const defaultConfig = {
commitMessageTopic: '{{{depName}}} Docker tag',
major: { enabled: false },
commitMessageExtra:
'to v{{#if isMajor}}{{{newMajor}}}{{else}}{{{toVersion}}}{{/if}}',
'to v{{#if isMajor}}{{{newMajor}}}{{else}}{{{newVersion}}}{{/if}}',
digest: {
branchTopic: '{{{depNameSanitized}}}-{{{currentValue}}}',
commitMessageExtra: 'to {{newDigestShort}}',
Expand Down
4 changes: 2 additions & 2 deletions lib/manager/batect-wrapper/artifacts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ const newWindowsWrapperContent = `Windows wrapper script for ${defaultTo}`;

function artifactForPath(
path: string,
toVersion: string = defaultTo
newVersion: string = defaultTo
): UpdateArtifact {
return {
packageFileName: path,
updatedDeps: ['batect/batect'],
newPackageFileContent: 'not used',
config: {
toVersion,
newVersion,
},
};
}
Expand Down
2 changes: 1 addition & 1 deletion lib/manager/batect-wrapper/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function updateArtifacts({
packageFileName,
config,
}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {
const version = config.toVersion;
const version = config.newVersion;

logger.debug({ version, packageFileName }, 'Updating Batect wrapper scripts');

Expand Down
9 changes: 5 additions & 4 deletions lib/manager/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ export interface UpdateArtifactsConfig extends ManagerConfig {
postUpdateOptions?: string[];
ignoreScripts?: boolean;
updateType?: UpdateType;
toVersion?: string;
newValue?: string;
newVersion?: string;
}

export interface PackageUpdateConfig {
Expand Down Expand Up @@ -149,7 +150,7 @@ export interface LookupUpdate {
newValue: string;
semanticCommitType?: string;
skippedOverVersions?: string[];
toVersion?: string;
newVersion?: string;
updateType?: UpdateType;
sourceUrl?: string;
}
Expand All @@ -171,7 +172,7 @@ export interface PackageDependency<T = Record<string, any>> extends Package<T> {
rangeStrategy?: RangeStrategy;
skipReason?: SkipReason;
sourceLine?: number;
toVersion?: string;
newVersion?: string;
updates?: LookupUpdate[];
replaceString?: string;
autoReplaceStringTemplate?: string;
Expand All @@ -196,7 +197,7 @@ export interface Upgrade<T = Record<string, any>>
newValue?: string;
packageFile?: string;
rangeStrategy?: RangeStrategy;
toVersion?: string;
newVersion?: string;
updateType?: UpdateType;
version?: string;
isLockFileMaintenance?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion lib/manager/git-submodules/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default async function updateDependency({

try {
await git.submoduleUpdate(['--init', upgrade.depName]);
await submoduleGit.checkout([upgrade.toVersion]);
await submoduleGit.checkout([upgrade.newVersion]);
return fileContent;
} catch (err) {
return null;
Expand Down
8 changes: 4 additions & 4 deletions lib/manager/gradle-wrapper/artifacts-real.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jest.mock('../../util/git');
const fixtures = resolve(__dirname, './__fixtures__');
const config = {
localDir: resolve(fixtures, './testFiles'),
toVersion: '5.6.4',
newValue: '5.6.4',
};

function readString(...paths: string[]): Promise<string> {
Expand Down Expand Up @@ -61,7 +61,7 @@ describe(getName(__filename), () => {
newPackageFileContent: await readString(
`./expectedFiles/gradle/wrapper/gradle-wrapper.properties`
),
config: { ...config, toVersion: '6.3' },
config: { ...config, newValue: '6.3' },
});

expect(res).toEqual(
Expand Down Expand Up @@ -99,7 +99,7 @@ describe(getName(__filename), () => {
packageFileName: 'gradle/wrapper/gradle-wrapper.properties',
updatedDeps: [],
newPackageFileContent: ``,
config: { ...config, toVersion: '6.3' },
config: { ...config, newValue: '6.3' },
});

expect(result).toHaveLength(1);
Expand Down Expand Up @@ -221,7 +221,7 @@ describe(getName(__filename), () => {
),
config: {
...config,
toVersion: '6.3',
newValue: '6.3',
currentValue: '5.6.4',
},
});
Expand Down
4 changes: 2 additions & 2 deletions lib/manager/gradle-wrapper/artifacts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const exec: jest.Mock<typeof _exec> = _exec as any;
const fixtures = resolve(__dirname, './__fixtures__');
const config = {
localDir: resolve(fixtures, './testFiles'),
toVersion: '5.6.4',
newValue: '5.6.4',
};
const dockerConfig = { ...config, binarySource: BinarySource.Docker };

Expand Down Expand Up @@ -76,7 +76,7 @@ describe(getName(__filename), () => {
newPackageFileContent: await readString(
`./expectedFiles/gradle/wrapper/gradle-wrapper.properties`
),
config: { ...config, toVersion: '6.3' },
config: { ...config, newValue: '6.3' },
});

expect(res).toEqual(
Expand Down
4 changes: 2 additions & 2 deletions lib/manager/gradle-wrapper/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ export async function updateArtifacts({
// need to reset version, otherwise we have a checksum mismatch
await writeLocalFile(
packageFileName,
newPackageFileContent.replace(config.toVersion, config.currentValue)
newPackageFileContent.replace(config.newValue, config.currentValue)
);
const checksum = await getDistributionChecksum(distributionUrl);
cmd += ` --gradle-distribution-sha256-sum ${checksum}`;
}
} else {
cmd += ` --gradle-version ${config.toVersion}`;
cmd += ` --gradle-version ${config.newValue}`;
}
logger.debug(`Updating gradle wrapper: "${cmd}"`);
const execOptions: ExecOptions = {
Expand Down
2 changes: 1 addition & 1 deletion lib/manager/npm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ export const defaultConfig = {
versioning: npmVersioning.id,
prBodyDefinitions: {
Change:
"[{{#if displayFrom}}`{{{displayFrom}}}` -> {{else}}{{#if currentValue}}`{{{currentValue}}}` -> {{/if}}{{/if}}{{#if displayTo}}`{{{displayTo}}}`{{else}}`{{{newValue}}}`{{/if}}]({{#if depName}}https://renovatebot.com/diffs/npm/{{replace '/' '%2f' depName}}/{{{currentVersion}}}/{{{toVersion}}}{{/if}})",
"[{{#if displayFrom}}`{{{displayFrom}}}` -> {{else}}{{#if currentValue}}`{{{currentValue}}}` -> {{/if}}{{/if}}{{#if displayTo}}`{{{displayTo}}}`{{else}}`{{{newValue}}}`{{/if}}]({{#if depName}}https://renovatebot.com/diffs/npm/{{replace '/' '%2f' depName}}/{{{currentVersion}}}/{{{newVersion}}}{{/if}})",
},
};
4 changes: 2 additions & 2 deletions lib/manager/npm/post-update/npm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('generateLockFile', () => {
const dockerMapDotfiles = true;
const postUpdateOptions = ['npmDedupe'];
const updates = [
{ depName: 'some-dep', toVersion: '1.0.1', isLockfileUpdate: false },
{ depName: 'some-dep', newVersion: '1.0.1', isLockfileUpdate: false },
];
const res = await npmHelper.generateLockFile(
'some-dir',
Expand All @@ -49,7 +49,7 @@ describe('generateLockFile', () => {
fs.readFile = jest.fn(() => 'package-lock-contents') as never;
const skipInstalls = true;
const updates = [
{ depName: 'some-dep', toVersion: '1.0.1', isLockfileUpdate: true },
{ depName: 'some-dep', newVersion: '1.0.1', isLockfileUpdate: true },
];
const res = await npmHelper.generateLockFile(
'some-dir',
Expand Down
2 changes: 1 addition & 1 deletion lib/manager/npm/post-update/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export async function generateLockFile(
const updateCmd =
`npm install ${cmdOptions}` +
lockUpdates
.map((update) => ` ${update.depName}@${update.toVersion}`)
.map((update) => ` ${update.depName}@${update.newVersion}`)
.join('');
commands.push(updateCmd);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/util/cache/repository/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ describe('lib/util/cache/repository', () => {
});
it('migrates', async () => {
fs.readFile.mockResolvedValueOnce(
'{"repository":"abc/def","branches":[{"upgrades":[{"fromVersion":"1.0.0"}]}]}' as any
'{"repository":"abc/def","branches":[{"upgrades":[{"fromVersion":"1.0.0","toVersion":"1.0.1"}]}]}' as any
);
await repositoryCache.initialize({
...config,
repositoryCache: 'enabled',
});
expect(repositoryCache.getCache().branches[0].upgrades[0]).toEqual({
currentVersion: '1.0.0',
newVersion: '1.0.1',
});
await repositoryCache.finalize();
});
Expand Down
6 changes: 5 additions & 1 deletion lib/util/cache/repository/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface BranchUpgradeCache {
lookupName?: string;
newDigest?: string;
newValue?: string;
toVersion?: string;
newVersion?: string;
sourceUrl?: string;
}

Expand Down Expand Up @@ -94,6 +94,10 @@ export function getCache(): Cache {
upgrade.currentVersion = upgrade.fromVersion;
delete upgrade.fromVersion;
}
if (upgrade.toVersion) {
upgrade.newVersion = upgrade.toVersion;
delete upgrade.toVersion;
}
}
}
return cache;
Expand Down
2 changes: 1 addition & 1 deletion lib/util/template/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const allowedFields = {
'The minor version of the new version. e.g. "1" if the new version if "3.1.0"',
newValue:
'The new value in the upgrade. Can be a range or version e.g. "^3.0.0" or "3.1.0"',
newVersion: 'The new version in the upgrade, e.g. "3.1.0"',
packageFile: 'The filename that the dependency was found in',
packageFileDir:
'The directory with full path where the packageFile was found',
Expand All @@ -87,7 +88,6 @@ export const allowedFields = {
repository: 'The current repository',
semanticPrefix: 'The fully generated semantic prefix for commit messages',
sourceUrl: 'The source URL for the package',
toVersion: 'The new version in the upgrade, e.g. "3.1.0"',
updateType: 'One of digest, pin, rollback, patch, minor, major',
upgrades: 'An array of upgrade objects in the branch',
url: 'The url of the release notes',
Expand Down

0 comments on commit 32440f2

Please sign in to comment.