Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multiple compatiable version on version switching #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.DS_Store
file/*
node_modules/
*.temp
87 changes: 54 additions & 33 deletions src/generate-site/extractCompatibilityMatrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions src/generate-site/template.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
}
}
}

function showLastCompatibility(event) {
const elements = document.getElementsByClassName('last-compatible')
for(let i = 0; i<elements.length; i++) {
Expand Down Expand Up @@ -85,7 +86,7 @@
</td>
{{#compatibilityMatrix}}
<td class="align-middle text-center version-column {{columnName}}">
{{#.}}
{{#items}}
{{#pluginVersion}}
<span class="text-nowrap">
{{#travisStatusPassed}}
Expand All @@ -112,7 +113,7 @@
{{#noData}}
<small class="muted">-</small>
{{/noData}}
{{/.}}
{{/items}}
</td>

{{/compatibilityMatrix}}
Expand Down