Skip to content

Commit

Permalink
feat(license): show old license if changed, support no license, renam…
Browse files Browse the repository at this point in the history
…e get util
  • Loading branch information
espy authored and Realtin committed Jul 4, 2019
1 parent 61be8fa commit f536030
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 70 deletions.
10 changes: 5 additions & 5 deletions content/update-pr.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const _ = require('lodash')
const md = require('./template')

module.exports = ({
version, dependencyLink, dependency, monorepoGroupName, release, diffCommits, oldVersionResolved, type, packageUpdateList, license, licenseHasChanged, publisher
version, dependencyLink, dependency, monorepoGroupName, release, diffCommits, oldVersionResolved, type, packageUpdateList, license, licenseHasChanged, previousLicense, publisher
}) => {
const hasReleaseInfo = release && diffCommits
return md`
Expand All @@ -17,16 +17,16 @@ ${monorepoGroupName && `\nThis monorepo update includes releases of one or more
}
---
publisher: ${publisher}
${licenseHasChanged ? `License has changed from the prevoius release.` : ''}
license: ${license}
**Publisher:** ${publisher}
**License:** ${licenseHasChanged ? `This package’s license has changed from **${previousLicense}** to **${license}** in this release` : `${license}`}
---
${hasReleaseInfo
? _.compact([release, diffCommits])
: `[Find out more about this release](${dependencyLink}).`
}
---
<details>
<summary>FAQ and help</summary>
Expand Down
5 changes: 3 additions & 2 deletions jobs/create-group-version-branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const {
hasTooManyPackageJSONs,
getSatisfyingVersions,
getOldVersionResolved,
getLicenseAndAuthorFromVersions
getLicenseAndPublisherFromVersions
} = require('../utils/utils')
const {
isPartOfMonorepo,
Expand Down Expand Up @@ -362,7 +362,7 @@ module.exports = async function (

const dependencyLink = getFormattedDependencyURL({ repositoryURL: transforms[0].repoURL })

const { license, licenseHasChanged, publisher } = getLicenseAndAuthorFromVersions({ versions, version, oldVersionResolved })
const { license, previousLicense, licenseHasChanged, publisher } = getLicenseAndPublisherFromVersions({ versions, version, oldVersionResolved })

// maybe adapt PR body
const body = prContent({
Expand All @@ -376,6 +376,7 @@ module.exports = async function (
diffCommits,
packageUpdateList,
license,
previousLicense,
licenseHasChanged,
publisher
})
Expand Down
7 changes: 4 additions & 3 deletions jobs/create-version-branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const { createTransformFunction,
hasTooManyPackageJSONs,
getSatisfyingVersions,
getOldVersionResolved,
getLicenseAndAuthorFromVersions
getLicenseAndPublisherFromVersions
} = require('../utils/utils')

const prContent = require('../content/update-pr')
Expand All @@ -35,7 +35,7 @@ module.exports = async function (
accountId,
repositoryId,
type,
// The following 4 don’t matter anymore, sincversionse we fetch them anew for every dependency anyway
// The following 4 don’t matter anymore, since we fetch them anew for every dependency anyway
version,
oldVersion,
oldVersionResolved,
Expand Down Expand Up @@ -337,7 +337,7 @@ module.exports = async function (
dependency: dependencyKey,
prTitles: config.prTitles })

const { license, licenseHasChanged, publisher } = getLicenseAndAuthorFromVersions({ versions, version, oldVersionResolved })
const { license, previousLicense, licenseHasChanged, publisher } = getLicenseAndPublisherFromVersions({ versions, version, oldVersionResolved })

const body = prContent({
dependencyLink,
Expand All @@ -350,6 +350,7 @@ module.exports = async function (
type,
packageUpdateList,
license,
previousLicense,
licenseHasChanged,
publisher
})
Expand Down
36 changes: 18 additions & 18 deletions test/jobs/__snapshots__/create-group-version-branch.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ This monorepo update includes releases of one or more dependencies which all bel
---
publisher: finn
**Publisher:** finn
**License:** MIT
license: MIT
[Find out more about this release](https://github.com/dep/dep).
---
[Find out more about this release](https://github.com/dep/dep).
<details>
<summary>FAQ and help</summary>
Expand Down Expand Up @@ -58,12 +58,12 @@ This monorepo update includes releases of one or more dependencies which all bel
---
publisher: finn
**Publisher:** finn
**License:** MIT
license: MIT
[Find out more about this release](https://github.com/dep/dep).
---
[Find out more about this release](https://github.com/dep/dep).
<details>
<summary>FAQ and help</summary>
Expand Down Expand Up @@ -100,12 +100,12 @@ This monorepo update includes releases of one or more dependencies which all bel
---
publisher: finn
**Publisher:** finn
**License:** MIT
license: MIT
[Find out more about this release](https://github.com/dep/dep).
---
[Find out more about this release](https://github.com/dep/dep).
<details>
<summary>FAQ and help</summary>
Expand Down Expand Up @@ -140,12 +140,12 @@ This monorepo update includes releases of one or more dependencies which all bel
---
publisher: finn
**Publisher:** finn
**License:** MIT
license: MIT
[Find out more about this release](https://github.com/dep/dep).
---
[Find out more about this release](https://github.com/dep/dep).
<details>
<summary>FAQ and help</summary>
Expand Down Expand Up @@ -180,12 +180,12 @@ This monorepo update includes releases of one or more dependencies which all bel
---
publisher: finn
**Publisher:** finn
**License:** MIT
license: MIT
[Find out more about this release](https://github.com/dep/dep).
---
[Find out more about this release](https://github.com/dep/dep).
<details>
<summary>FAQ and help</summary>
Expand Down Expand Up @@ -235,12 +235,12 @@ If you don’t accept this pull request, your project will work just like it did
---
publisher: finn
**Publisher:** finn
**License:** MIT
license: MIT
[Find out more about this release]().
---
[Find out more about this release]().
<details>
<summary>FAQ and help</summary>
Expand Down
59 changes: 32 additions & 27 deletions test/jobs/__snapshots__/create-version-branch.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ This monorepo update includes releases of one or more dependencies which all bel
---
publisher: finn
**Publisher:** finn
**License:** MIT
license: MIT
[Find out more about this release](https://github.com/orgname/colors).
---
[Find out more about this release](https://github.com/orgname/colors).
<details>
<summary>FAQ and help</summary>
Expand All @@ -52,8 +52,8 @@ exports[`create version branch for dependencies from monorepos new pull request
"
## There have been updates to the *numbers* monorepo:
- The \`devDependency\` [numbers](https://www.npmjs.com/package/numbers) was updated from \`2.1.0\` to \`2.2.0\`.
- The \`dependency\` [numbers-four](https://www.npmjs.com/package/numbers-four) was updated from \`1.2.0\` to \`1.3.0\`.
- The \`devDependency\` [numbers](https://github.com/dep/dep) was updated from \`2.1.0\` to \`2.2.0\`.
- The \`dependency\` [numbers-four](https://github.com/dep/dep) was updated from \`1.2.0\` to \`1.3.0\`.
These versions are **not covered** by your **current version range**.
Expand All @@ -63,7 +63,12 @@ This monorepo update includes releases of one or more dependencies which all bel
---
[Find out more about this release]().
**Publisher:** finn
**License:** No license
[Find out more about this release](https://github.com/dep/dep).
---
<details>
<summary>FAQ and help</summary>
Expand Down Expand Up @@ -96,12 +101,12 @@ This monorepo update includes releases of one or more dependencies which all bel
---
publisher: finn
**Publisher:** finn
**License:** MIT
license: MIT
[Find out more about this release](https://github.com/orgname/flowers).
---
[Find out more about this release](https://github.com/orgname/flowers).
<details>
<summary>FAQ and help</summary>
Expand Down Expand Up @@ -131,12 +136,12 @@ This monorepo update includes releases of one or more dependencies which all bel
---
publisher: finn
**Publisher:** finn
**License:** MIT
license: MIT
[Find out more about this release](https://github.com/orgname/colors).
---
[Find out more about this release](https://github.com/orgname/colors).
<details>
<summary>FAQ and help</summary>
Expand Down Expand Up @@ -168,12 +173,12 @@ This monorepo update includes releases of one or more dependencies which all bel
---
publisher: finn
**Publisher:** finn
**License:** MIT
license: MIT
[Find out more about this release](https://github.com/jest/jest).
---
[Find out more about this release](https://github.com/jest/jest).
<details>
<summary>FAQ and help</summary>
Expand All @@ -200,12 +205,12 @@ If you don’t accept this pull request, your project will work just like it did
---
publisher: finn
**Publisher:** finn
**License:** MIT
license: MIT
[Find out more about this release](https://github.com/best/best).
---
[Find out more about this release](https://github.com/best/best).
<details>
<summary>FAQ and help</summary>
Expand All @@ -230,12 +235,12 @@ If you don’t accept this pull request, your project will work just like it did
---
publisher: finn
**Publisher:** finn
**License:** This package’s license has changed from **BYOL** to **MIT** in this release
license: MIT
[Find out more about this release](https://github.com/finnpauls/dep).
---
[Find out more about this release](https://github.com/finnpauls/dep).
<details>
<summary>FAQ and help</summary>
Expand All @@ -260,12 +265,12 @@ If you don’t accept this pull request, your project will work just like it did
---
publisher: finn
**Publisher:** finn
**License:** MIT
license: MIT
[Find out more about this release](https://github.com/finnpauls/dep).
---
[Find out more about this release](https://github.com/finnpauls/dep).
<details>
<summary>FAQ and help</summary>
Expand All @@ -290,12 +295,12 @@ If you don’t accept this pull request, your project will work just like it did
---
publisher: finn
**Publisher:** finn
**License:** MIT
license: MIT
[Find out more about this release](https://github.com/finnpauls/dep).
---
[Find out more about this release](https://github.com/finnpauls/dep).
<details>
<summary>FAQ and help</summary>
Expand Down
16 changes: 12 additions & 4 deletions test/jobs/create-version-branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const versionInfos = {
}
}

describe.only('create version branch', () => {
describe('create version branch', () => {
beforeEach(() => {
delete process.env.IS_ENTERPRISE
cleanCache('../../lib/env')
Expand Down Expand Up @@ -281,7 +281,7 @@ describe.only('create version branch', () => {
oldVersion: '^1.0.0',
oldVersionResolved: '1.0.0',
versions: {
'1.0.0': versionInfos,
'1.0.0': { ...versionInfos, license: 'BYOL' },
'2.0.0': versionInfos
}
})
Expand Down Expand Up @@ -2169,7 +2169,6 @@ describe('create version branch for dependencies from monorepos', () => {
versions: {
'1.0.0': {
gitHead: 'deadbeef100',
'license': 'MIT',
'_npmUser': {
name: 'finn',
email: '[email protected]'
Expand All @@ -2180,7 +2179,16 @@ describe('create version branch for dependencies from monorepos', () => {
repository: {
url: 'https://github.com/numbers/monorepo'
},
'license': 'MIT',
'_npmUser': {
name: 'finn',
email: '[email protected]'
}
},
'2.2.0': {
gitHead: 'deadbeef220',
repository: {
url: 'https://github.com/numbers/monorepo'
},
'_npmUser': {
name: 'finn',
email: '[email protected]'
Expand Down
Loading

0 comments on commit f536030

Please sign in to comment.