From 7330550c20a84f0aaed4db24961a18d8159f85ea Mon Sep 17 00:00:00 2001 From: Touhidur Rahman Date: Tue, 12 Sep 2023 16:50:54 +0200 Subject: [PATCH] Add multiple compatiable version on version switching --- .gitignore | 2 + .../extractCompatibilityMatrix.js | 87 ++++++++++++------- src/generate-site/template.mustache | 5 +- 3 files changed, 59 insertions(+), 35 deletions(-) diff --git a/.gitignore b/.gitignore index 1c7b014..f320f9f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ +.DS_Store +file/* node_modules/ *.temp \ No newline at end of file diff --git a/src/generate-site/extractCompatibilityMatrix.js b/src/generate-site/extractCompatibilityMatrix.js index a48c3ec..d2fba3e 100644 --- a/src/generate-site/extractCompatibilityMatrix.js +++ b/src/generate-site/extractCompatibilityMatrix.js @@ -62,61 +62,82 @@ const extractData = async (filePath, releaseVersions) => { releases.sort(function (a, b) { return new Date(b.date) - new Date(a.date) }) const compatibilityMatrix = releaseVersions.map(({ version, branchName }, index) => { - const matchingRelease = releases.find(r => { + + const matchingRelease = releases.filter(r => { return r.compatibility.match(version) - }) - if (!matchingRelease) { + }); + + if (matchingRelease.length <= 0) { for (let i = index; i < releaseVersions.length; i++) { const anyMatch = releases.find(r => { return r.compatibility.match(releaseVersions[i].version) }) if (anyMatch) { - return { + + return [{ columnName: version, lastCompatible: `${anyMatch.version} for ${releaseVersions[i].version}` - } + }] } } - return { columnName: version, noData: true } + + return { + columnName: version, + noData: true, + } } + const hasBranch = branchName && remoteBranches[homepage][branchName] && `${homepage}/tree/${branchName}` - const compatibilityValues = + let compatibilityValuesList = []; + + for (let k = 0; k < matchingRelease.length; k++) + { + let compatibilityValues = { columnName: version, - pluginVersion: matchingRelease.version, - date: matchingRelease.date, - url: matchingRelease.url, + pluginVersion: matchingRelease[k].version, + date: matchingRelease[k].date, + url: matchingRelease[k].url, hasBranch } - if (hasBranch) { - const pluginRepo = homepage.replace('https://github.com/', '') - try { - const result = request('get', 'https://api.travis-ci.com/repos/' + `${pluginRepo}/branches/${branchName}`, { - headers: { - Accept: 'application/vnd.travis-ci.2.1+json', - Host: 'api.travis-ci.com' - } - } - ) - const json = JSON.parse(result.getBody().toString()) - if (json && json.branch && json.branch.state !== '') { - compatibilityValues.travisLink = `https://app.travis-ci.com/github/${pluginRepo}/builds/` + json.branch.id - if (json.branch.state === 'passed') { - compatibilityValues.travisStatusPassed = true + + if (hasBranch) { + const pluginRepo = homepage.replace('https://github.com/', '') + try { + const result = request('get', 'https://api.travis-ci.com/repos/' + `${pluginRepo}/branches/${branchName}`, { + headers: { + Accept: 'application/vnd.travis-ci.2.1+json', + Host: 'api.travis-ci.com' + } } - if (json.branch.state === 'errored') { - compatibilityValues.travisStatusErrored = true + ) + const json = JSON.parse(result.getBody().toString()) + if (json && json.branch && json.branch.state !== '') { + compatibilityValues.travisLink = `https://app.travis-ci.com/github/${pluginRepo}/builds/` + json.branch.id + if (json.branch.state === 'passed') { + compatibilityValues.travisStatusPassed = true + } + if (json.branch.state === 'errored') { + compatibilityValues.travisStatusErrored = true + } } + } catch (e) { + debug(e.toString()) } - } catch (e) { - debug(e.toString()) } + + if (!compatibilityValues.travisStatusErrored && !compatibilityValues.travisStatusPassed) { + compatibilityValues.travisStatusUndefined = true + } + + compatibilityValuesList.push(compatibilityValues); } - if (!compatibilityValues.travisStatusErrored && !compatibilityValues.travisStatusPassed) { - compatibilityValues.travisStatusUndefined = true - } - return compatibilityValues + + return { + columnName: version, + items: compatibilityValuesList, + }; }) return { diff --git a/src/generate-site/template.mustache b/src/generate-site/template.mustache index e30a4d8..3fc09cc 100644 --- a/src/generate-site/template.mustache +++ b/src/generate-site/template.mustache @@ -26,6 +26,7 @@ } } } + function showLastCompatibility(event) { const elements = document.getElementsByClassName('last-compatible') for(let i = 0; i {{#compatibilityMatrix}} - {{#.}} + {{#items}} {{#pluginVersion}} {{#travisStatusPassed}} @@ -112,7 +113,7 @@ {{#noData}} - {{/noData}} - {{/.}} + {{/items}} {{/compatibilityMatrix}}