diff --git a/lib/config/templates/default/pr-body.hbs b/lib/config/templates/default/pr-body.hbs index 8ffa64f2c0bddc6fb1cfe080b6f65766af38d0a3..c0d69bfaac975dd7b8703a42ec1546ff0f06e87d 100644 --- a/lib/config/templates/default/pr-body.hbs +++ b/lib/config/templates/default/pr-body.hbs @@ -1,4 +1,8 @@ This Pull Request {{#if isRollback}}rolls back{{else}}updates{{/if}} dependency {{#if repositoryUrl}}[{{depName}}]({{repositoryUrl}}){{else}}{{depName}}{{/if}} from `{{#unless isRange}}{{#unless isPin}}v{{/unless}}{{/unless}}{{currentVersion}}` to `{{#unless isRange}}v{{/unless}}{{newVersion}}`{{#if isRollback}}. This is necessary and important because `v{{currentVersion}}` cannot be found in the npm registry - probably because of it being unpublished.{{/if}} +{{#if hasTypes}} + +This PR also includes an upgrade to the corresponding [@types/{{depName}}](https://npmjs.com/package/@types/{{depName}}) package. +{{/if}} {{#if releases.length}} {{#if schedule}} diff --git a/lib/workers/repository/updates/branchify.js b/lib/workers/repository/updates/branchify.js index 53be83bd85cfcb4a58b15e471c61c107b4d1770c..be5e22758d923ade741ab66920eef38f4b4e2756 100644 --- a/lib/workers/repository/updates/branchify.js +++ b/lib/workers/repository/updates/branchify.js @@ -41,11 +41,17 @@ function branchifyUpgrades(config) { } logger.debug(`Returning ${Object.keys(branchUpgrades).length} branch(es)`); for (const branchName of Object.keys(branchUpgrades)) { - logger.debug('loop'); + logger.setMeta({ + repository: config.repository, + branch: branchName, + }); const branch = generateBranchConfig(branchUpgrades[branchName]); branch.branchName = branchName; branches.push(branch); } + logger.setMeta({ + repository: config.repository, + }); logger.debug(`config.repoIsOnboarded=${config.repoIsOnboarded}`); const branchList = config.repoIsOnboarded ? branches.map(upgrade => upgrade.branchName) diff --git a/lib/workers/repository/updates/determine.js b/lib/workers/repository/updates/determine.js index e441f2a694f0fab5e9f503f8d86b50b772e7a99f..bd1920f6a604d320d5d9b029c40835d97497b652 100644 --- a/lib/workers/repository/updates/determine.js +++ b/lib/workers/repository/updates/determine.js @@ -52,6 +52,7 @@ async function determineRepoUpgrades(config) { semanticCommits, depNameSanitized: upgrade.depName ? upgrade.depName + .replace('@types/', '') .replace('@', '') .replace('/', '-') .replace(/\s+/g, '-') diff --git a/lib/workers/repository/updates/generate.js b/lib/workers/repository/updates/generate.js index 8c405e3c30eb0744e786d06c9c752d35e8a6cd5e..1b28e47c6ac6bb487cbaff5b80579f71f2096fff 100644 --- a/lib/workers/repository/updates/generate.js +++ b/lib/workers/repository/updates/generate.js @@ -1,6 +1,8 @@ const handlebars = require('handlebars'); function generateBranchConfig(branchUpgrades) { + logger.debug(`generateBranchConfig()`); + logger.trace({ config: branchUpgrades }); const config = { upgrades: [], }; @@ -56,6 +58,17 @@ function generateBranchConfig(branchUpgrades) { logger.debug(`${upgrade.branchName}, ${upgrade.prTitle}`); config.upgrades.push(upgrade); } + if ( + depNames.length === 2 && + !hasGroupName && + config.upgrades[0].depName.startsWith('@types/') && + config.upgrades[0].depName.endsWith(config.upgrades[1].depName) + ) { + logger.debug('Found @types - reversing upgrades to use depName in PR'); + config.upgrades.reverse(); + config.upgrades[0].recreateClosed = false; + config.hasTypes = true; + } // Now assign first upgrade's config as branch config return { ...config, ...config.upgrades[0] }; } diff --git a/test/workers/repository/updates/generate.spec.js b/test/workers/repository/updates/generate.spec.js index fce6db8d031abc156c069c9ab02c039b60688589..a4dd11bc64d8c2544d77147b5baeffac85c20a0e 100644 --- a/test/workers/repository/updates/generate.spec.js +++ b/test/workers/repository/updates/generate.spec.js @@ -158,5 +158,30 @@ describe('workers/repository/updates/generate', () => { const res = generateBranchConfig(branch); expect(res.prTitle).toEqual('chore(package): some-title'); }); + it('handles @types specially', () => { + const branch = [ + { + depName: '@types/some-dep', + groupName: null, + branchName: 'some-branch', + prTitle: 'some-title', + lazyGrouping: true, + newVersion: '0.5.7', + group: {}, + }, + { + depName: 'some-dep', + groupName: null, + branchName: 'some-branch', + prTitle: 'some-title', + lazyGrouping: true, + newVersion: '0.6.0', + group: {}, + }, + ]; + const res = generateBranchConfig(branch); + expect(res.recreateClosed).toBe(false); + expect(res.groupName).toBeUndefined(); + }); }); });