diff --git a/scripts/updateAllIssues.js b/scripts/updateAllIssues.js
index 9426437..08a1ffd 100644
--- a/scripts/updateAllIssues.js
+++ b/scripts/updateAllIssues.js
@@ -1,67 +1,80 @@
-const githubToken = ''; //https://github.com/settings/tokens
-const test = true;
+const githubToken = ""; // https://github.com/settings/tokens
+const test = false;
-const toGet = 'checkError';
-const toSet = 'checkError2';
+const toGet = "checkError2";
+const toSet = "checkError";
const checkOkCheck = true;
-const issueTitle = 'Think about to fix the issues found by adapter checker';
+const issueTitle = "Think about to fix the issues found by adapter checker";
-const adapterTestLink = 'https://e7tj1cpjna.execute-api.eu-west-1.amazonaws.com/?url=';
+const adapterTestLink = "https://e7tj1cpjna.execute-api.eu-west-1.amazonaws.com/?url=";
-let adapterList;
+let adapterList, dicoveryList;
const start = async function () {
+ console.log("Adapter Liste wird geladen...");
adapterList = await getAdapterList();
+ console.log("Adapter Liste geladen!")
if (adapterList) {
- if (!adapterList[toSet]) {
- adapterList[toSet] = {};
- }
- const $listeSuccess = $('#listSuccess');
- $listeSuccess.append(`
ignored: ${adapterList.ignore.length}/`);
- $listeSuccess.append(`noIoPackage: ${adapterList.noIoPackage.length}/`);
- $listeSuccess.append(`checkErrorOld:${Object.keys(adapterList.checkErrorOld).length}/`);
- $listeSuccess.append(`${toGet}: ${Object.keys(adapterList[toGet]).length}/`);
- $listeSuccess.append(`${toSet}: ${Object.keys(adapterList[toSet]).length}/`);
- $listeSuccess.append(`checkOk: ${adapterList.checkOk.length}/`);
+ if(!adapterList[toSet]) adapterList[toSet] = {};
+ if(!adapterList.dependVISwwwOnly) adapterList.dependVISwwwOnly = [];
+ if(!adapterList.dependVIS) adapterList.dependVIS = [];
+ if(!adapterList.noRestartVIS2) adapterList.noRestartVIS2 = [];
+
+ $('#listeSuccess').append("ignored: " + adapterList["ignore"].length + "/");
+ $('#listeSuccess').append("noIoPackage: " + adapterList["noIoPackage"].length + "/");
+ $('#listeSuccess').append("checkErrorOld: " + Object.keys(adapterList["checkErrorOld"]).length + "/");
+ $('#listeSuccess').append("" + toGet + ": " + Object.keys(adapterList[toGet]).length + "/");
+ $('#listeSuccess').append("" + toSet + ": " + Object.keys(adapterList[toSet]).length + "/");
+ $('#listeSuccess').append("checkOk: " + adapterList.checkOk.length + "/");
+ $('#listeSuccess').append("dependVISwwwOnly: " + adapterList.dependVISwwwOnly.length + "/");
+ $('#listeSuccess').append("dependVIS: " + adapterList.dependVIS.length + "/");
+ $('#listeSuccess').append("noRestartVIS2: " + adapterList.noRestartVIS2.length + "/");
+
+ console.log("Die Arbeit beginnt");
await startFunc();
await delay(10000);
+ console.log("Die Arbeit ist fertig!!");
+
console.log(JSON.stringify(adapterList));
$('#ignore').text(adapterList.ignore.length);
$('#noIoPackage').text(adapterList.noIoPackage.length);
$('#checkOk').text(adapterList.checkOk.length);
+ $('#dependVISwwwOnly').text(adapterList.dependVISwwwOnly.length);
+ $('#dependVIS').text(adapterList.dependVIS.length);
+ $('#noRestartVIS2').text(adapterList.noRestartVIS2.length);
$('#checkErrorOld').text(Object.keys(adapterList.checkErrorOld).length);
$('#' + toSet).text(Object.keys(adapterList[toSet]).length);
$('#' + toGet).text(Object.keys(adapterList[toGet]).length);
$('#result').text(JSON.stringify(adapterList));
} else {
- $('#list').append(`ERROR ${Object.keys(adapterList[toGet]).length} ${Object.keys(adapterList[toSet]).length}`);
+ $('#liste').append("ERROR " + Object.keys(adapterList[toGet]).length + " " + Object.keys(adapterList[toSet]).length + "");
}
};
(function ($) {
$.extend({
- // Case insensitive $.inArray (http://api.jquery.com/jquery.inarray/)
+ // Case insensative $.inArray (http://api.jquery.com/jquery.inarray/)
// $.inArrayIn(value, array [, fromIndex])
- // value (type: String)
- // The value to search for
- // array (type: Array)
- // An array through which to search.
- // fromIndex (type: Number)
- // The index of the array at which to begin the search.
- // The default is 0, which will search the whole array.
+ // value (type: String)
+ // The value to search for
+ // array (type: Array)
+ // An array through which to search.
+ // fromIndex (type: Number)
+ // The index of the array at which to begin the search.
+ // The default is 0, which will search the whole array.
inArrayIn: function (elem, arr, i) {
- // not looking for a string anyway, use default method
+ // not looking for a string anyways, use default method
if (typeof elem !== 'string') {
return $.inArray.apply(this, arguments);
}
// confirm array is populated
if (arr) {
- const len = arr.length;
+ var len = arr.length;
i = i ? (i < 0 ? Math.max(0, len + i) : i) : 0;
elem = elem.toLowerCase();
for (; i < len; i++) {
- if (i in arr && arr[i].toLowerCase() === elem) {
+ if (i in arr && arr[i].toLowerCase() == elem) {
return i;
}
}
@@ -75,91 +88,131 @@ const start = async function () {
const delay = ms => new Promise(res => setTimeout(res, ms));
const startFunc = async function () {
+
if (adapterList) {
- await findAllAdapters(adapterList);
- if (checkOkCheck) {
- adapterList.checkOk.forEach(fullName => {
- adapterList[toGet][fullName] = {};
- adapterList[toGet][fullName].issue = null;
+ console.log("Suche neue Adapter");
+ const oldGet = Object.keys(adapterList[toGet]).length;
+ await findAllAdapters("asc");
+ await findAllAdapters("desc");
+ console.log("Suche neuer Adapter beendet - " + (Object.keys(adapterList[toGet]).length - oldGet) + " Adapter gefunden");
+
+ if(checkOkCheck){
+ adapterList.checkOk.forEach(function (full_name) {
+ adapterList[toGet][full_name] = {};
+ adapterList[toGet][full_name].issue = null;
});
adapterList.checkOk = [];
}
+ adapterList.noIoPackage = [];
+ adapterList.noRestartVIS2 = [];
+ adapterList.dependVIS = [];
+ adapterList.dependVISwwwOnly = [];
+
+ for (const origfullname in adapterList[toGet]) {
+ const full_name = await getFullname(origfullname);
+ if(full_name) {
+ console.log("Teste " + full_name + " ...");
+ const testLink = "https://raw.githubusercontent.com/" + full_name;
+ const testResult = await doTheTest(testLink);
+
+ console.log("Teste io-Package vis" + full_name + " ...");
+ let check = await checkVis("https://raw.githubusercontent.com/" + full_name + "/master/io-package.json", full_name);
+ if(!check){
+ await checkVis("https://raw.githubusercontent.com/" + full_name + "/main/io-package.json", full_name);
+ }
- for (const fullName in adapterList[toGet]) {
- if (!adapterList[toGet].hasOwnProperty(fullName)) {
- continue;
- }
- const testLink = `https://raw.githubusercontent.com/${fullName}`;
- const testResult = await doTheTest(testLink);
-
- let issueNr = adapterList[toGet][fullName].issue;
- let issuesList = [];
- if (issueNr) {
- issuesList = adapterList[toGet][fullName].errorList;
- if (adapterList[toGet][fullName].status !== 'open') {
- issueNr = null;
+ let issueNr = adapterList[toGet][origfullname].issue;
+ let issuesList = [];
+ if (issueNr) {
+ issuesList = adapterList[toGet][origfullname].errorList;
}
- }
- if (testResult && testResult.errors && testResult.errors.length > 0) {
- try {
- let issueBody = 'I am an automatic service that looks for possible errors in ioBroker and creates an issue for it. The link below leads directly to the test:\r\n\r\n';
- issueBody += `https://adapter-check.iobroker.in/?q=${testLink}\r\n\r\n`;
- const errorList = [];
- const warningList = [];
- testResult.errors.forEach(issue => {
- issueBody += `- [ ] ${issue}\r\n`;
- errorList.push(issue.substring(1, 5));
- });
- if (testResult.warnings && testResult.warnings.length > 0) {
- issueBody += '\r\nI have also found warnings that may be fixed if possible.\r\n\r\n';
- testResult.warnings.forEach(issue => {
- issueBody += `- [ ] ${issue}\r\n`;
- warningList.push(issue.substring(1, 5));
- });
+ if ((testResult && testResult.errors && testResult.errors.length > 0) || adapterList.noRestartVIS2.includes(full_name) || adapterList.dependVIS.includes(full_name) || adapterList.dependVISwwwOnly.includes(full_name)) {
+ try {
+ console.log("Issue wird angelegt " + full_name + " ...");
+ let issueBody = "I am an automatic service that looks for possible errors in ioBroker and creates an issue for it. The link below leads directly to the test:\r\n\r\n";
+ issueBody += "https://adapter-check.iobroker.in/?q=" + testLink + "\r\n\r\n";
+ const errorList = [];
+ const warningList = [];
+
+ if(testResult) {
+ testResult.errors.forEach(function (issue) {
+ issueBody += "- [ ] " + issue + "\r\n";
+ errorList.push(issue.substring(1, 5));
+ });
+ if (testResult.warnings && testResult.warnings.length > 0) {
+ issueBody += "\r\nI have also found warnings that may be fixed if possible.\r\n\r\n";
+ testResult.warnings.forEach(function (issue) {
+ issueBody += "- [ ] " + issue + "\r\n";
+ warningList.push(issue.substring(1, 5));
+ });
+ }
+ }
+
+ if(adapterList.noRestartVIS2.includes(full_name)){
+ issueBody += "\r\nI noticed that in the io-package under “restartAdapters” only vis is available. If your widget also runs with vis-2, you might want to add “vis-2” to the list too.\r\n\r\n";
+ }
+
+ if(adapterList.dependVIS.includes(full_name)){
+ issueBody += "\r\nI found vis as “dependencies” in the io package. Please remove this dependency.\r\n\r\n";
+ }
+ if(adapterList.dependVISwwwOnly.includes(full_name)){
+ issueBody += "\r\nI found vis as “dependencies” in the io package. If your widget also runs with vis-2, then remove that.\r\n\r\n";
+ }
+
+ issueBody += "\r\nThanks,\r\nyour automatic adapter checker.";
+ issueBody += addComminityText(full_name);
+
+ const errorNotChanged = issueNr !== null && (errorList.length === issuesList.length && errorList.sort().every(function (value, index) {
+ return value === issuesList.sort()[index];
+ }));
+
+ if (test) {
+ testIssueCreation(origfullname, full_name, testResult.errors.length, errorNotChanged, testResult.warnings);
+ } else if (githubToken && !errorNotChanged) {
+ createIssue(origfullname, full_name, issueBody, testResult.errors.length, issueNr, errorList, warningList);
+ } else if (githubToken && errorNotChanged) {
+ let dateIssue = adapterList[toGet][origfullname].createdDate;
+ if (!dateIssue) {
+ dateIssue = "2019-02-01T15:08:12Z";
+ adapterList[toGet][origfullname].createdDate = dateIssue;
+ }
+
+ if ((new Date() - new Date(dateIssue)) > 15768000000) {
+ createHelpComment(origfullname, full_name, issueNr);
+ } else {
+ adapterList[toSet][full_name] = adapterList[toGet][origfullname];
+ delete adapterList[toGet][origfullname];
+ }
+ $('#liste').append("" + (full_name === origfullname ? full_name : origfullname + " => " + full_name) + " no error changes");
+ } else {
+ testIssueCreation("NO TOKEN - " + full_name, "NO TOKEN - " + full_name, testResult.errors.length);
+ }
+ } catch (e) {
+ console.error(full_name + " - " + e);
}
-
- issueBody += '\r\nThanks,\r\nyour automatic adapter checker.';
- issueBody += addCommunityText(fullName);
-
- const errorNotChanged = issueNr !== null &&
- (errorList.length === issuesList.length && errorList
- .sort()
- .every((value, index) => value === issuesList.sort()[index])
- );
-
- if (test) {
- testIssueCreation(fullName, testResult.errors.length, errorNotChanged, testResult.warnings);
- } else if (githubToken && !errorNotChanged) {
- createIssue(fullName, issueBody, testResult.errors.length, issueNr, errorList, warningList);
- } else if (githubToken && errorNotChanged) {
- adapterList[toSet][fullName] = adapterList[toGet][fullName];
- delete adapterList[toGet][fullName];
- $('#list').append(`${fullName} no error changes`);
- } else {
- testIssueCreation(`NO TOKEN - ${fullName}`, testResult.errors.length);
+ } else if (testResult && testResult.errors && testResult.errors.length === 0) {
+ if (!test && githubToken) {
+ closeIssue(origfullname, full_name, issueNr);
}
- } catch (e) {
- console.error(`${fullName} - ${e}`);
- }
- } else if (testResult && testResult.errors && testResult.errors.length === 0) {
- if (!test && githubToken) {
- closeIssue(fullName, issueNr);
+ $('#liste').append("" + (full_name === origfullname ? full_name : origfullname + " => " + full_name) + " fixed - checked but no error found");
}
- $('#list').append(`${fullName} fixed - checked but no error found`);
}
}
+
}
};
-$('button').on('click', () => start());
+$("button").on("click", function () {
+ start();
+});
-function addCommunityText(fullName) {
- if (!fullName.startsWith('ioBroker/') && !fullName.startsWith('iobroker-community-adapters/')) {
- return '\r\n\r\nP.S.: There is a community in Github, which supports the maintenance and further development of adapters. There you will find many experienced developers who are always ready to assist anyone. New developers are always welcome there. For more informations visit: https://github.com/iobroker-community-adapters/info';
+function addComminityText(full_name) {
+ if (!full_name.startsWith("ioBroker/") && !full_name.startsWith("iobroker-community-adapters/")) {
+ return "\r\n\r\nP.S.: There is a community in Github, which supports the maintenance and further development of adapters. There you will find many experienced developers who are always ready to assist anyone. New developers are always welcome there. For more informations visit: https://github.com/iobroker-community-adapters/info";
} else {
- return '';
+ return "";
}
}
@@ -169,44 +222,49 @@ function GithubInteractor(token) {
const interactor = new GithubInteractor(githubToken);
-function createIssue(repo, issueBody, count, issueNr, errorList, warningList) {
+function createIssue(orgRepo, repo, issueBody, count, issueNr, errorList, warningList) {
if (issueNr) {
- const url = `https://api.github.com/repos/${repo}/issues/${issueNr}`;
+ const url = "https://api.github.com/repos/" + repo + "/issues/" + issueNr;
$.ajax({
url: url,
- type: 'PATCH',
- beforeSend: xhr => xhr.setRequestHeader('Authorization', `token ${interactor.token}`),
- error: (xhr, status, error) => {
- const err = JSON.parse(xhr.responseText);
- $('#list').append(`${repo} - issue failed (${status}: ${error}, ${err})`);
+ type: "PATCH",
+ beforeSend: function (xhr) {
+ xhr.setRequestHeader("Authorization", "token " + interactor.token);
+ },
+ error: function (xhr, status, error) {
+ createIssue(orgRepo, repo, issueBody, count, null, errorList, warningList);
},
- success: issue => {
+ success: function (issue) {
adapterList[toSet][repo] = {};
adapterList[toSet][repo].errorList = errorList;
adapterList[toSet][repo].warningList = warningList;
adapterList[toSet][repo].issue = issue.number;
adapterList[toSet][repo].errorCount = count;
adapterList[toSet][repo].status = issue.state;
- adapterList[toSet][repo].createdDate = issue.created_at;
- delete adapterList[toGet][repo];
- $('#listSuccess').append(`${repo} (${count} errors) - issue updated`);
+ adapterList[toSet][repo].createdDate = (adapterList[toGet][orgRepo].createdDate ? adapterList[toGet][orgRepo].createdDate : issue.created_at);
+ adapterList[toSet][repo].help = adapterList[toGet][orgRepo].help === true;
+ delete adapterList[toGet][orgRepo];
+ $('#listeSuccess').append("" + (repo === orgRepo ? repo : orgRepo + " => " + repo) + " (" + count + " errors) - issue updated");
},
data: JSON.stringify({
- body: issueBody
+ body: issueBody,
+ state: "open"
})
});
} else {
- const url = `https://api.github.com/repos/${repo}/issues`;
+ const url = "https://api.github.com/repos/" + repo + "/issues";
$.ajax({
url: url,
- type: 'POST',
- beforeSend: xhr => xhr.setRequestHeader('Authorization', `token ${interactor.token}`),
- error: (xhr, status, error) => {
+ type: "POST",
+ beforeSend: function (xhr) {
+ xhr.setRequestHeader("Authorization", "token " + interactor.token);
+ },
+ error: function (xhr, status, error) {
const err = JSON.parse(xhr.responseText);
- $('#list').append(`${repo} - issue failed (${status}: ${error}, ${err})`);
+ $('#liste').append("" + (repo === orgRepo ? repo : orgRepo + " => " + repo) + " - issue failed (" + status + ": " + error + ") " + err + "");
},
- success: issue => {
+ success: function (issue) {
adapterList[toSet][repo] = {};
adapterList[toSet][repo].errorList = errorList;
adapterList[toSet][repo].warningList = warningList;
@@ -214,8 +272,9 @@ function createIssue(repo, issueBody, count, issueNr, errorList, warningList) {
adapterList[toSet][repo].errorCount = count;
adapterList[toSet][repo].status = issue.state;
adapterList[toSet][repo].createdDate = issue.created_at;
- delete adapterList[toGet][repo];
- $('#listSuccess').append(`${repo} (${count} errors) - new issue created`);
+ adapterList[toSet][repo].help = false;
+ delete adapterList[toGet][orgRepo];
+ $('#listeSuccess').append("" + (repo === orgRepo ? repo : orgRepo + " => " + repo) + " (" + count + " errors) - new issue created");
},
data: JSON.stringify({
title: issueTitle,
@@ -225,96 +284,158 @@ function createIssue(repo, issueBody, count, issueNr, errorList, warningList) {
}
}
-function closeIssue(repo, issueNr) {
+function closeIssue(orgRepo, repo, issueNr) {
+
if (issueNr) {
- const urlComment = `https://api.github.com/repos/${repo}/issues/${issueNr}/comments`;
- const issueBody = 'Thanks, that all bugs have been fixed.';
+ const urlComment = "https://api.github.com/repos/" + repo + "/issues/" + issueNr + "/comments";
+ const issueBody = "Thanks, that all bugs have been fixed.";
$.ajax({
url: urlComment,
- type: 'POST',
- beforeSend: xhr => xhr.setRequestHeader('Authorization', `token ${interactor.token}`),
- error: (xhr, status, error) => {
+ type: "POST",
+ beforeSend: function (xhr) {
+ xhr.setRequestHeader("Authorization", "token " + interactor.token);
+ },
+ error: function (xhr, status, error) {
const err = JSON.parse(xhr.responseText);
- $('#list').append(`${repo} - issue failed (${status}: ${error}, ${err})`);
+ $('#liste').append("" + (repo === orgRepo ? repo : orgRepo + " => " + repo) + " - issue failed (" + status + ": " + error + ") " + err + "");
},
- success: () => {
+ success: function (issue) {
adapterList.checkOk.push(repo);
- delete adapterList[toGet][repo];
+ delete adapterList[toGet][orgRepo];
},
data: JSON.stringify({
body: issueBody
})
});
- const urlIssue = `https://api.github.com/repos/${repo}/issues/${issueNr}`;
+ var urlIssue = "https://api.github.com/repos/" + repo + "/issues/" + issueNr;
$.ajax({
url: urlIssue,
- type: 'PATCH',
- beforeSend: xhr => xhr.setRequestHeader('Authorization', 'token ' + interactor.token),
+ type: "PATCH",
+ beforeSend: function (xhr) {
+ xhr.setRequestHeader("Authorization", "token " + interactor.token);
+ },
data: JSON.stringify({
- state: 'closed'
+ state: "closed"
})
});
+
} else {
adapterList.checkOk.push(repo);
- delete adapterList[toGet][repo];
+ delete adapterList[toGet][orgRepo];
+ }
+}
+
+function createHelpComment(orgRepo, repo, issueNr) {
+
+ if (issueNr && !adapterList[toGet][repo].help) {
+ var urlComment = "https://api.github.com/repos/" + repo + "/issues/" + issueNr + "/comments";
+ const issueBody = "Do you need help fixing the bugs?";
+ $.ajax({
+ url: urlComment,
+ type: "POST",
+ beforeSend: function (xhr) {
+ xhr.setRequestHeader("Authorization", "token " + interactor.token);
+ },
+ error: function (xhr, status, error) {
+ const err = JSON.parse(xhr.responseText);
+ $('#liste').append("" + (repo === orgRepo ? repo : orgRepo + " => " + repo) + " - issue failed (" + status + ": " + error + ") - " + err + "");
+ },
+ success: function (issue) {
+ adapterList[toSet][repo] = adapterList[toGet][orgRepo];
+ adapterList[toSet][repo].status = "open";
+ adapterList[toSet][repo].createdDate = new Date().toISOString();
+ adapterList[toSet][repo].help = true;
+ delete adapterList[toGet][orgRepo];
+ },
+ data: JSON.stringify({
+ body: issueBody
+ })
+ });
+
+ const urlIssue = "https://api.github.com/repos/" + repo + "/issues/" + issueNr;
+ $.ajax({
+ url: urlIssue,
+ type: "PATCH",
+ beforeSend: function (xhr) {
+ xhr.setRequestHeader("Authorization", "token " + interactor.token);
+ },
+ data: JSON.stringify({
+ state: "open"
+ })
+ });
}
}
async function getAdapterList() {
- const link = 'https://raw.githubusercontent.com/ioBrokerChecker/testData/master/data.json';
+ const link = "https://raw.githubusercontent.com/ioBrokerChecker/testData/master/data.json";
try {
- const response = await fetch(link, { cache: 'no-cache' });
- return await response.json();
+ return await (await fetch(link, {cache: "no-cache"})).json();
} catch (e) {
+ console.log(e);
return null;
}
}
-function checkIgnores(fullName) {
- return $.inArrayIn(fullName, adapterList.ignore) !== -1 || $.inArrayIn(fullName, Object.keys(adapterList[toGet])) !== -1 || $.inArrayIn(fullName, adapterList.checkOk) !== -1 || $.inArrayIn(fullName, Object.keys(adapterList.checkErrorOld)) !== -1 || $.inArrayIn(fullName, Object.keys(adapterList[toSet])) !== -1 || $.inArrayIn(fullName, adapterList.noIoPackage) !== -1;
+function checkIgnores(full_name) {
+ return $.inArrayIn(full_name, adapterList.ignore) !== -1 || $.inArrayIn(full_name, Object.keys(adapterList[toGet])) !== -1 || $.inArrayIn(full_name, adapterList.checkOk) !== -1 || $.inArrayIn(full_name, Object.keys(adapterList.checkErrorOld)) !== -1 || $.inArrayIn(full_name, Object.keys(adapterList[toSet])) !== -1 || $.inArrayIn(full_name, adapterList.noIoPackage) !== -1;
}
-async function findAllAdapters() {
- const firstQL = getQueryForRepos();
+async function findAllAdapters(sort) {
+ const firstQL = getQueryForRepos(sort);
let repos = await getDataV4(firstQL);
if (repos && repos.data && repos.data.search) {
- for (const repoNode of repos.data.search.edges) {
- const fullName = repoNode.node.nameWithOwner;
- if (!repoNode.node.hasIssuesEnabled || repoNode.node.isArchived || checkIgnores(fullName)) {
- true;
+ repos.data.search.edges.forEach(async function (repoNode) {
+ const full_name = repoNode.node.nameWithOwner;
+ if (!repoNode.node.hasIssuesEnabled || repoNode.node.isArchived || checkIgnores(full_name)) {
+ return true;
}
- const check = await checkIoPackage(`https://raw.githubusercontent.com/${fullName}/master/io-package.json`, fullName);
+ console.log("Check " + full_name);
+ let check = await checkIoPackage("https://raw.githubusercontent.com/" + full_name + "/master/io-package.json", full_name);
+ if(!check){
+ check = await checkIoPackage("https://raw.githubusercontent.com/" + full_name + "/main/io-package.json", full_name);
+ }
+
if (check) {
- adapterList[toGet][fullName] = {};
- adapterList[toGet][fullName].issue = null;
+ console.log(full_name + " als Adapter erkannt");
+ adapterList[toGet][full_name] = {};
+ adapterList[toGet][full_name].issue = null;
+ }else{
+ console.log(full_name + " ist kein Adapter");
+ adapterList.noIoPackage.push(full_name);
}
- }
+ });
let hasNext = repos.data.search.pageInfo.hasNextPage;
let cursor = repos.data.search.pageInfo.endCursor;
while (hasNext) {
- const nextQL = getQueryForRepos(cursor);
+ const nextQL = getQueryForRepos(sort, cursor);
repos = await getDataV4(nextQL);
if (repos && repos.data && repos.data.search) {
- for (let e = 0; e < repos.data.search.edges.length; e++) {
- const repoNode = repos.data.search.edges[e];
- const fullName = repoNode.node.nameWithOwner;
- if (!repoNode.node.hasIssuesEnabled || repoNode.node.isArchived || checkIgnores(fullName)) {
+ repos.data.search.edges.forEach(async function (repoNode) {
+ const full_name = repoNode.node.nameWithOwner;
+ if (!repoNode.node.hasIssuesEnabled || repoNode.node.isArchived || checkIgnores(full_name)) {
return true;
}
- const check = await checkIoPackage(`https://raw.githubusercontent.com/${fullName}/master/io-package.json`, fullName);
+ let check = await checkIoPackage("https://raw.githubusercontent.com/" + full_name + "/master/io-package.json", full_name);
+ if(!check){
+ check = await checkIoPackage("https://raw.githubusercontent.com/" + full_name + "/main/io-package.json", full_name);
+ }
if (check) {
- adapterList[toGet][fullName] = {};
- adapterList[toGet][fullName].issue = null;
+ console.log(full_name + " als Adapter erkannt");
+ adapterList[toGet][full_name] = {};
+ adapterList[toGet][full_name].issue = null;
+ }else{
+ console.log(full_name + " ist kein Adapter");
+ adapterList.noIoPackage.push(full_name);
}
- }
+ });
hasNext = repos.data.search.pageInfo.hasNextPage;
cursor = repos.data.search.pageInfo.endCursor;
} else {
hasNext = false;
- cursor = '';
+ cursor = "";
}
}
}
@@ -325,11 +446,39 @@ async function checkIoPackage(ioPackageLink, adapter) {
const ioPackage = await (await fetch(ioPackageLink)).json();
const isAdapter = ioPackage && ioPackage.common;
if (!isAdapter) {
- adapterList.noIoPackage.push(adapter);
return false;
}
} catch (e) {
- adapterList.noIoPackage.push(adapter);
+ return false;
+ }
+ return true;
+}
+
+async function checkVis(ioPackageLink, adapter) {
+ try {
+ const ioPackage = await (await fetch(ioPackageLink)).json();
+ const isAdapter = ioPackage && ioPackage.common;
+ if (!isAdapter) {
+ return false;
+ }
+ if (ioPackage.common.restartAdapters && ioPackage.common.restartAdapters.includes("vis") && !ioPackage.common.restartAdapters.includes("vis-2")) {
+ adapterList.noRestartVIS2.push(adapter);
+ }
+ if (ioPackage.common.dependencies && ioPackage.common.dependencies.includes("vis")){
+ if(ioPackage.common.onlyWWW){
+ adapterList.dependVISwwwOnly.push(adapter);
+ }else {
+ adapterList.dependVIS.push(adapter);
+ }
+ }
+ if (ioPackage.common.globalDependencies && ioPackage.common.globalDependencies.includes("vis")){
+ if(ioPackage.common.onlyWWW){
+ adapterList.dependVISwwwOnly.push(adapter);
+ }else {
+ adapterList.dependVIS.push(adapter);
+ }
+ }
+ } catch (e) {
return false;
}
return true;
@@ -343,12 +492,12 @@ async function doTheTest(testLink) {
}
}
-function testIssueCreation(repo, count, notChanged, warnings, closed) {
+function testIssueCreation(orgRepo, repo, count, notChanged, warnings) {
let countW = 0;
if (warnings) {
countW = warnings.length;
}
- $('#list').append(`${repo} (${count} err & ${countW} war) - issue ${notChanged ? 'is the same' : 'has been changed (UPDATE)'} `);
+ $('#liste').append("" + (repo === orgRepo?repo: orgRepo + " => " + repo) + " (" + count + " err & " + countW + " war) - issue " + (notChanged ? "is the same" : "has been changed (UPDATE)") + " ");
}
async function getDataV4(query) {
@@ -356,26 +505,39 @@ async function getDataV4(query) {
method: 'POST',
headers: new Headers({
'Content-Type': 'application/json',
- 'Authorization': `bearer ${interactor.token}`
+ 'Authorization': 'bearer ' + interactor.token
}),
body: JSON.stringify({query: query})
})).json();
}
-function getQueryForRepos(cursor) {
+function getQueryForRepos(sort, cursor) {
let query = getRepoSearchQL;
if (cursor) {
- query = query.replace('$cursor', `, after: "${cursor}"`);
+ query = query.replace("$cursor", ', after: "' + cursor + '"');
} else {
- query = query.replace('$cursor', '');
+ query = query.replace("$cursor", "");
}
+ query = query.replace("$dings", sort);
return query;
}
+async function getFullname(fullname){
+ let query = checkRepoNameQL;
+ const names = fullname.split("/");
+ query = query.replace("$name", names[1]).replace("$owner", names[0]);
+ const repo = await getDataV4(query);
+ if(repo && repo["data"] && repo["data"]["repository"]){
+ return repo["data"]["repository"]["nameWithOwner"];
+ }
+
+ return null;
+}
+
const getRepoSearchQL = `
query {
- search(first: 100, type: REPOSITORY, query: "iobroker"$cursor) {
+ search(first: 100, type: REPOSITORY, query: "iobroker sort:updated-$dings"$cursor) {
repositoryCount
edges {
node {
@@ -393,3 +555,10 @@ query {
}
}
}`;
+
+const checkRepoNameQL = `
+query {
+ repository(name: "$name", owner: "$owner") {
+ nameWithOwner
+ }
+}`;