Skip to content

Commit

Permalink
feat(npm): use repository directory from listing
Browse files Browse the repository at this point in the history
Closes #3096
  • Loading branch information
rarkins committed Jan 22, 2019
1 parent e578bff commit 869225d
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 9 deletions.
3 changes: 3 additions & 0 deletions lib/datasource/npm/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ async function getDependency(name, maxRetries = 5) {
'dist-tags': res['dist-tags'],
'renovate-config': latestVersion['renovate-config'],
};
if (res.repository && res.repository.directory) {
dep.sourceDirectory = res.repository.directory;
}
if (latestVersion.deprecated) {
dep.deprecationMessage = `On registry \`${regUrl}\`, the "latest" version (v${
dep.latestVersion
Expand Down
9 changes: 7 additions & 2 deletions lib/workers/pr/pr-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,18 @@ function getNonEmptyColumns(definitions, rows) {
async function getPrBody(config) {
config.upgrades.forEach(upgrade => {
/* eslint-disable no-param-reassign */
const { homepage, sourceUrl, changelogUrl } = upgrade;
const { homepage, sourceUrl, sourceDirectory, changelogUrl } = upgrade;
const references = [];
if (homepage) {
references.push(`[homepage](${homepage})`);
}
if (sourceUrl) {
references.push(`[source](${sourceUrl})`);
let fullUrl = sourceUrl;
if (sourceDirectory) {
fullUrl =
sourceUrl.replace(/\/?$/, '/') + sourceDirectory.replace('^/?/', '');
}
references.push(`[source](${fullUrl})`);
}
if (changelogUrl) {
references.push(`[changelog](${changelogUrl})`);
Expand Down
2 changes: 1 addition & 1 deletion test/_fixtures/npm/coffeelint.json

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions test/datasource/npm/__snapshots__/index.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Object {
"version": "0.0.2",
},
],
"sourceDirectory": "src/a",
"sourceUrl": "https://github.com/renovateapp/dummy",
"tags": Object {
"latest": "0.0.1",
Expand Down Expand Up @@ -46,6 +47,7 @@ Object {
"version": "0.0.2",
},
],
"sourceDirectory": "src/a",
"sourceUrl": "https://github.com/renovateapp/dummy",
"tags": Object {
"latest": "0.0.1",
Expand All @@ -71,6 +73,7 @@ Object {
"version": "0.0.2",
},
],
"sourceDirectory": "src/a",
"sourceUrl": "https://github.com/renovateapp/dummy",
"tags": Object {
"latest": "0.0.1",
Expand Down Expand Up @@ -98,6 +101,7 @@ Object {
"version": "0.0.2",
},
],
"sourceDirectory": "src/a",
"sourceUrl": "https://github.com/renovateapp/dummy",
"tags": Object {
"latest": "0.0.1",
Expand Down Expand Up @@ -125,6 +129,7 @@ Object {
"version": "0.0.2",
},
],
"sourceDirectory": "src/a",
"sourceUrl": "https://github.com/renovateapp/dummy",
"tags": Object {
"latest": "0.0.1",
Expand Down Expand Up @@ -202,6 +207,7 @@ Object {
"version": "0.0.2",
},
],
"sourceDirectory": "src/a",
"sourceUrl": "https://github.com/renovateapp/dummy",
"tags": Object {
"latest": "0.0.1",
Expand Down Expand Up @@ -229,6 +235,7 @@ Object {
"version": "0.0.2",
},
],
"sourceDirectory": "src/a",
"sourceUrl": "https://github.com/renovateapp/dummy",
"tags": Object {
"latest": "0.0.1",
Expand Down Expand Up @@ -256,6 +263,7 @@ Object {
"version": "0.0.2",
},
],
"sourceDirectory": "src/a",
"sourceUrl": "https://github.com/renovateapp/dummy",
"tags": Object {
"latest": "0.0.1",
Expand Down
1 change: 1 addition & 0 deletions test/datasource/npm/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('api/npm', () => {
repository: {
type: 'git',
url: 'git://github.com/renovateapp/dummy.git',
directory: 'src/a',
},
'dist-tags': {
latest: '0.0.1',
Expand Down
12 changes: 6 additions & 6 deletions test/workers/pr/__snapshots__/index.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Array [
| Package | Type | Update | Change | References |
|---|---|---|---|---|
| dummy | devDependencies | pin | \`1.0.0\` -> \`1.1.0\` | [homepage](https://dummy.com), [source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md) |
| dummy | devDependencies | pin | \`1.0.0\` -> \`1.1.0\` | [homepage](https://dummy.com), [source](https://github.com/renovateapp/dummy/packages/a), [changelog](https://github.com/renovateapp/dummy/changelog.md) |
:pushpin: **Important**: Renovate will wait until you have merged this Pin PR before creating any *upgrade* PRs for the affected packages. Add the preset \`:preserveSemverRanges\` your config if you instead don't wish to pin dependencies.
Expand Down Expand Up @@ -78,7 +78,7 @@ Array [
| Package | Type | Update | Change | References |
|---|---|---|---|---|
| dummy | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` | [homepage](https://dummy.com), [source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md) |
| dummy | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` | [homepage](https://dummy.com), [source](https://github.com/renovateapp/dummy/packages/a), [changelog](https://github.com/renovateapp/dummy/changelog.md) |
---
Expand Down Expand Up @@ -122,7 +122,7 @@ Array [
| Package | Type | Update | Change | References |
|---|---|---|---|---|
| dummy | devDependencies | lockFileMaintenance | \`1.0.0\` -> \`1.1.0\` | [homepage](https://dummy.com), [source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md) |
| dummy | devDependencies | lockFileMaintenance | \`1.0.0\` -> \`1.1.0\` | [homepage](https://dummy.com), [source](https://github.com/renovateapp/dummy/packages/a), [changelog](https://github.com/renovateapp/dummy/changelog.md) |
| a | | | \`aaaaaaa\` | |
| b | | pin | \`some_new_value@bbbbbbb\` | |
| c | | | | |
Expand Down Expand Up @@ -183,7 +183,7 @@ Array [
| Package | Type | Update | Change | References |
|---|---|---|---|---|
| dummy | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` | [homepage](https://dummy.com), [source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md) |
| dummy | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` | [homepage](https://dummy.com), [source](https://github.com/renovateapp/dummy/packages/a), [changelog](https://github.com/renovateapp/dummy/changelog.md) |
---
Expand Down Expand Up @@ -225,7 +225,7 @@ Object {
| Package | Type | Update | Change | References |
|---|---|---|---|---|
| dummy | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` | [homepage](https://dummy.com), [source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md) |
| dummy | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` | [homepage](https://dummy.com), [source](https://github.com/renovateapp/dummy/packages/a), [changelog](https://github.com/renovateapp/dummy/changelog.md) |
---
Expand Down Expand Up @@ -267,7 +267,7 @@ Object {
| Package | Type | Update | Change | References |
|---|---|---|---|---|
| dummy | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` | [homepage](https://dummy.com), [source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md) |
| dummy | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` | [homepage](https://dummy.com), [source](https://github.com/renovateapp/dummy/packages/a), [changelog](https://github.com/renovateapp/dummy/changelog.md) |
---
Expand Down
1 change: 1 addition & 0 deletions test/workers/pr/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ describe('workers/pr', () => {
config.updateType = 'minor';
config.homepage = 'https://dummy.com';
config.sourceUrl = 'https://github.com/renovateapp/dummy';
config.sourceDirectory = 'packages/a';
config.changelogUrl = 'https://github.com/renovateapp/dummy/changelog.md';
platform.createPr.mockReturnValue({ displayNumber: 'New Pull Request' });
config.upgrades = [config];
Expand Down

0 comments on commit 869225d

Please sign in to comment.