Skip to content
Snippets Groups Projects
Unverified Commit 1ed10fbe authored by Tobias Bieniek's avatar Tobias Bieniek Committed by GitHub
Browse files

feat(datasource/crate): Assign `dependencyUrl` property (#7261)

If I understand correctly the `dependencyUrl` property is supposed to link to the package on the package registry, which is crates.io in this case. This could potentially be used in the PR description if no homepage or source URL is available.
parent e8720115
No related merge requests found
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
exports[`datasource/crate getReleases processes real data: amethyst 1`] = ` exports[`datasource/crate getReleases processes real data: amethyst 1`] = `
Object { Object {
"dependencyUrl": "https://crates.io/crates/amethyst",
"releases": Array [ "releases": Array [
Object { Object {
"version": "0.1.0", "version": "0.1.0",
...@@ -144,6 +145,7 @@ Array [ ...@@ -144,6 +145,7 @@ Array [
exports[`datasource/crate getReleases processes real data: libc 1`] = ` exports[`datasource/crate getReleases processes real data: libc 1`] = `
Object { Object {
"dependencyUrl": "https://crates.io/crates/libc",
"releases": Array [ "releases": Array [
Object { Object {
"version": "0.1.0", "version": "0.1.0",
......
...@@ -38,6 +38,7 @@ export async function getReleases({ ...@@ -38,6 +38,7 @@ export async function getReleases({
const baseUrl = const baseUrl =
'https://raw.githubusercontent.com/rust-lang/crates.io-index/master/'; 'https://raw.githubusercontent.com/rust-lang/crates.io-index/master/';
const crateUrl = baseUrl + path; const crateUrl = baseUrl + path;
const dependencyUrl = `https://crates.io/crates/${lookupName}`;
try { try {
const lines = (await http.get(crateUrl)).body const lines = (await http.get(crateUrl)).body
.split('\n') // break into lines .split('\n') // break into lines
...@@ -45,6 +46,7 @@ export async function getReleases({ ...@@ -45,6 +46,7 @@ export async function getReleases({
.filter((line) => line.length !== 0) // remove empty lines .filter((line) => line.length !== 0) // remove empty lines
.map((line) => JSON.parse(line)); // parse .map((line) => JSON.parse(line)); // parse
const result: ReleaseResult = { const result: ReleaseResult = {
dependencyUrl,
releases: [], releases: [],
}; };
result.releases = lines result.releases = lines
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment