|
1 | 1 | /** |
2 | | - * This is a JavaScript file which loads `license-report` md-files from the external repositories. |
| 2 | + * This is a JavaScript file which loads Markdown content from the dependency report files |
| 3 | + * via Spine public repositories. |
3 | 4 | * |
4 | | - * Please see `/oss-licenses/index.html` for usage. |
| 5 | + * See `/oss-licenses/index.html` for usage. |
5 | 6 | */ |
6 | 7 | 'use strict'; |
7 | 8 |
|
|
12 | 13 | const repoAttr = 'repo'; |
13 | 14 | const repoName = 'repo-name'; |
14 | 15 |
|
| 16 | + // Spine repositories are migrated being migrated to listing their deps in this file. |
| 17 | + const reportFilePath = '/master/dependencies.md'; |
| 18 | + |
| 19 | + // Previously used report file path, as a fallback for non-migrated repos. |
| 20 | + const legacyFilePath = '/master/license-report.md'; |
| 21 | + |
15 | 22 | /** |
16 | 23 | * Loads the dependency report file from the repository. |
17 | 24 | * |
18 | | - * <p>There may be one of two report files present in the repo: `license-report.md` |
19 | | - * or `dependencies.md`. The latter is a newer version of the report, so it is loaded |
20 | | - * first. In case it is missing, `license-report.md` is loaded, as a fallback. |
| 25 | + * <p>There may be one of two report files present in the repo: |
| 26 | + * `license-report.md` or `dependencies.md`. |
| 27 | + * The latter is a newer version of the report, so it is loaded |
| 28 | + * as a priority. In case it is missing, `license-report.md` is loaded, as a fallback. |
21 | 29 | * Eventually, all Spine repositories will migrate to having `dependencies.md`. |
22 | 30 | * |
23 | 31 | * <p>The report sections describing the terms of use for dual-licensed dependencies, |
|
36 | 44 |
|
37 | 45 | if (loaded === 'false') { |
38 | 46 | const repositoryUrl = clickedElement.attr(repoAttr); |
39 | | - $.get( |
40 | | - repositoryUrl + '/master/license-report.md', |
41 | | - function (data) { |
42 | | - const html = converter.makeHtml(data); |
43 | | - mdDestinationEl.html(html); |
44 | | - clickedElement.attr(loadedAttr, 'true'); |
45 | | - makeCollapsibleTitle(mdDestinationEl, clickedElRepoName); |
46 | | - } |
47 | | - ); |
| 47 | + let processLoadedContent = function (data) { |
| 48 | + const html = converter.makeHtml(data); |
| 49 | + mdDestinationEl.html(html); |
| 50 | + clickedElement.attr(loadedAttr, 'true'); |
| 51 | + makeCollapsibleTitle(mdDestinationEl, clickedElRepoName); |
| 52 | + }; |
| 53 | + |
| 54 | + let reportUrl = repositoryUrl + reportFilePath; |
| 55 | + let legacyReportUrl = repositoryUrl + legacyFilePath; |
| 56 | + |
| 57 | + $.get(reportUrl, processLoadedContent) |
| 58 | + .fail(function () { |
| 59 | + $.get(legacyReportUrl, processLoadedContent) |
| 60 | + }); |
48 | 61 | } |
49 | 62 | }); |
50 | 63 |
|
51 | 64 | /** |
52 | | - * Makes a `license-report` content collapsible. |
| 65 | + * Makes the report content collapsible. |
53 | 66 | * |
54 | 67 | * @param mdDestinationEl `div` with the markdown content |
55 | 68 | * @param clickedElRepoName repository name from the link attribute |
|
0 commit comments