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}}