Open abchatra opened 5 years ago
let fs = require("fs")
let rp = require("request-promise-native");
let s = fs.readFileSync("targetConfig.json")
let config = JSON.parse(s);
let repos = config.packages.approvedRepos;
let orgs = config.packages.approvedOrgs;
async function reqAsync(query) {
var options = {
uri: query,
headers: {
'User-Agent': 'Request-Promise'
},
qs: {
access_token: '' // -> uri + '?access_token=xxxxx%20xxxxx'
},
resolveWithFullResponse: true,
json: true
}
resp = await rp(options)
.then(function (response) {
return {json: response.body, headers: response.headers};
})
.catch(function (err) {
console.log(err)
});
return resp;
}
function toRepoInfo(v) {
return {
id: v.id,
name: v.name,
full_name: v.full_name,
private: v.private,
description: v.description || "",
fork: v.fork,
archived: v.archived,
created_at: v.created_at,
updated_at: v.updated_at,
pushed_at: v.pushed_at,
size: v.size,
stargazers_count: v.stargazers_count || 0,
watchers_count: v.watchers_count || 0,
forks_count: v.forks_count || 0,
open_issues: v.open_issues || 0,
default_branch: v.default_branch,
license: v.license,
searchData: []
}
}
console.log(orgs)
async function queryGithub() {
let allItems = []
//timestamps is used for create partitions in the query, github throttles above 1000 results.
//Before Christmas 2018 microbit has 981 packages.
//This is a point fix, ideally we should only query whitelisted packages from targetconfig.json.
let timestamps = ["created:<2018-12-26", "created:>2018-12-25"];
let index = 0;
let query = `in:name,description,readme "for PXT/microbit"`
let org = "https://api.github.com/search/repositories" +
"?q=" + encodeURIComponent(query);
let url = org + "+" + encodeURIComponent(timestamps[index]) + "&per_page=100"
index++;
while (true) {
let resp = await reqAsync(url);
for (let v of resp.json.items) {
let vv = toRepoInfo(v)
if (repos.includes(vv.full_name)) {
allItems.push(vv)
} else {
let search = /[a-zA-Z-]*/.exec(vv.full_name);
if (orgs.includes(search[0])) {
allItems.push(vv)
}
}
}
let m = /<([^>]+)>;\s*rel="next"/.exec(resp.headers["link"])
if (m) {
url = m[1]
} else {
if (index < timestamps.length) {
url = org + "+" + encodeURIComponent(timestamps[index]) + "&per_page=100"
index++;
} else {
break
}
}
}
return allItems;
}
(async function () {
let allItems = await queryGithub();
console.log(allItems.length)
let count = 0;
for(let i = 0; i < allItems.length; i++) {
if (!allItems[i].license || allItems[i].license.key != "mit") {
console.log(allItems[i].full_name, allItems[i].license)
count++;
}
}
console.log("Missing MIT license:" + count);
})();
@microbit-mark @jaustin Is it possible to contact the owners and ask for the right license?
@microbit-mark @jaustin
Hello, just saw this so I added the MIT license for https://github.com/jdarling/pxt-pca9685 (pulled request from my forked repository).
I see in the post from Dec 28, 2018 that Sparkfun's Gamerbit does not have the right extension. I'm trying to use this extension in my classroom. Is there a work around? Can I use an older version of the makecode editor to get this hardware working? Thank you.
Following approved extensions don't have the MIT license:
No license:
Following extensions have some other license
[ ] srs/pxt-bitbot { key: 'apache-2.0', name: 'Apache License 2.0', spdx_id: 'Apache-2.0', url: 'https://api.github.com/licenses/apache-2.0', node_id: 'MDc6TGljZW5zZTI=' }
[ ] PiSupply/pxt-iot-lora-node { key: 'gpl-3.0', name: 'GNU General Public License v3.0', spdx_id: 'GPL-3.0', url: 'https://api.github.com/licenses/gpl-3.0', node_id: 'MDc6TGljZW5zZTk=' }