utils: deno fmt

This commit is contained in:
tree🌴 2024-01-31 01:57:12 +01:00
parent 2884a56045
commit 0cbbddd561
5 changed files with 106 additions and 89 deletions

View file

@ -1,23 +1,28 @@
import { parseFeed } from "https://deno.land/x/rss/mod.ts"; import { parseFeed } from "https://deno.land/x/rss/mod.ts";
import * as cheerio from "https://esm.sh/cheerio@1.0.0-rc.12"; import * as cheerio from "https://esm.sh/cheerio@1.0.0-rc.12";
const resp = await fetch("https://mirror.xyz/0x0f1F3DAf416B74DB3DE55Eb4D7513a80F4841073/feed/atom") const resp = await fetch(
const xml = await resp.text() "https://mirror.xyz/0x0f1F3DAf416B74DB3DE55Eb4D7513a80F4841073/feed/atom",
const feed = await parseFeed(xml) );
const xml = await resp.text();
const feed = await parseFeed(xml);
const articles = [] const articles = [];
for (const entry of feed.entries) { for (const entry of feed.entries) {
//console.log(entry) //console.log(entry)
const $ = cheerio.load(entry.content.value) const $ = cheerio.load(entry.content.value);
articles.push({ articles.push({
url: entry.id, url: entry.id,
title: entry.title.value, title: entry.title.value,
img: $("img").attr("src"), img: $("img").attr("src"),
date: entry.updated, date: entry.updated,
}) });
} }
//console.log(articles) //console.log(articles)
await Deno.writeTextFile("./src/articles.json", JSON.stringify(articles, null, 2)) await Deno.writeTextFile(
console.log(`File ./src/articles.json saved`) "./src/articles.json",
JSON.stringify(articles, null, 2),
);
console.log(`File ./src/articles.json saved`);

View file

@ -1,61 +1,65 @@
import "https://deno.land/std@0.206.0/dotenv/load.ts"; import "https://deno.land/std@0.206.0/dotenv/load.ts";
const contributorRepos = [ const contributorRepos = [
// main repos
"web3privacy/web3privacy",
"web3privacy/data",
"web3privacy/docs",
"web3privacy/web",
"web3privacy/brand",
// main repos // events workgroup
"web3privacy/web3privacy", "web3privacy/events",
"web3privacy/data",
"web3privacy/docs",
"web3privacy/web",
"web3privacy/brand",
// events workgroup // explorer
"web3privacy/events", "web3privacy/explorer",
"web3privacy/explorer-data",
"web3privacy/explorer-app",
// explorer // old - deprecated
"web3privacy/explorer", "web3privacy/w3ps1",
"web3privacy/explorer-data", "web3privacy/grants",
"web3privacy/explorer-app", "web3privacy/old-website",
"web3privacy/web3privacy-app-old",
];
// old - deprecated function isBlacklisted(login) {
"web3privacy/w3ps1", if (login.match(/\[bot\]$/)) {
"web3privacy/grants", return true;
"web3privacy/old-website", }
"web3privacy/web3privacy-app-old",
]
function isBlacklisted (login) {
if (login.match(/\[bot\]$/)) {
return true;
}
} }
async function getContributors () { async function getContributors() {
const output = []; const output = [];
for (const cr of contributorRepos) { for (const cr of contributorRepos) {
const response = await fetch(`https://api.github.com/repos/${cr}/contributors`, { const response = await fetch(
//headers: { `https://api.github.com/repos/${cr}/contributors`,
// "Authorization": `Token ${Deno.env.get('GITHUB_TOKEN')}` {
//} //headers: {
}); // "Authorization": `Token ${Deno.env.get('GITHUB_TOKEN')}`
const arr = await response.json(); //}
for (const item of arr) { },
if (isBlacklisted(item.login)) { );
continue; const arr = await response.json();
} for (const item of arr) {
if (isBlacklisted(item.login)) {
continue;
}
const found = output.find(i => i.login === item.login) const found = output.find((i) => i.login === item.login);
if (!found) { if (!found) {
output.push(item) output.push(item);
} else { } else {
found.contributions += item.contributions found.contributions += item.contributions;
} }
} }
} }
return output.sort((x, y) => y.contributions > x.contributions ? 1 : -1); return output.sort((x, y) => y.contributions > x.contributions ? 1 : -1);
} }
const contributors = await getContributors() const contributors = await getContributors();
await Deno.writeTextFile("./src/contributors.json", JSON.stringify(contributors, null, 2)) await Deno.writeTextFile(
console.log(`File ./src/contributors.json saved`) "./src/contributors.json",
JSON.stringify(contributors, null, 2),
);
console.log(`File ./src/contributors.json saved`);

View file

@ -1,4 +1,4 @@
const response = await fetch("https://data.web3privacy.info/") const response = await fetch("https://data.web3privacy.info/");
const data = await response.json() const data = await response.json();
await Deno.writeTextFile("./src/core.json", JSON.stringify(data, null, 2)) await Deno.writeTextFile("./src/core.json", JSON.stringify(data, null, 2));
console.log(`File ./src/core.json saved`) console.log(`File ./src/core.json saved`);

View file

@ -1,15 +1,18 @@
const resp = await fetch("https://explorer-data.web3privacy.info/"); const resp = await fetch("https://explorer-data.web3privacy.info/");
const data = await resp.json(); const data = await resp.json();
const respContribs = await fetch(`https://api.github.com/repos/web3privacy/explorer-data/contributors`) const respContribs = await fetch(
`https://api.github.com/repos/web3privacy/explorer-data/contributors`,
);
const respContribsData = await respContribs.json(); const respContribsData = await respContribs.json();
const explorer = { const explorer = {
projects: data.projects.length, projects: data.projects.length,
contributors: respContribsData.length, contributors: respContribsData.length,
} };
await Deno.writeTextFile("./src/explorer.json", JSON.stringify(explorer, null, 2)) await Deno.writeTextFile(
console.log(`File ./src/explorer.json saved`) "./src/explorer.json",
JSON.stringify(explorer, null, 2),
);
console.log(`File ./src/explorer.json saved`);

View file

@ -1,23 +1,28 @@
import { parseFeed } from "https://deno.land/x/rss/mod.ts"; import { parseFeed } from "https://deno.land/x/rss/mod.ts";
import * as cheerio from "https://esm.sh/cheerio@1.0.0-rc.12"; import * as cheerio from "https://esm.sh/cheerio@1.0.0-rc.12";
const resp = await fetch("https://www.youtube.com/feeds/videos.xml?channel_id=UCaO_vLpj164um5maEsCuEbw") const resp = await fetch(
const xml = await resp.text() "https://www.youtube.com/feeds/videos.xml?channel_id=UCaO_vLpj164um5maEsCuEbw",
const feed = await parseFeed(xml) );
const xml = await resp.text();
const feed = await parseFeed(xml);
const talks = [] const talks = [];
for (const entry of feed.entries) { for (const entry of feed.entries) {
console.log(entry) console.log(entry);
//const $ = cheerio.load(entry.content.value) //const $ = cheerio.load(entry.content.value)
talks.push({ talks.push({
url: entry.links[0].href, url: entry.links[0].href,
title: entry.title.value, title: entry.title.value,
img: entry["media:group"]["media:thumbnail"].url.replace("hqdefault", "maxresdefault"), img: entry["media:group"]["media:thumbnail"].url.replace(
date: entry.published, "hqdefault",
}) "maxresdefault",
),
date: entry.published,
});
} }
//console.log(articles) //console.log(articles)
await Deno.writeTextFile("./src/talks.json", JSON.stringify(talks, null, 2)) await Deno.writeTextFile("./src/talks.json", JSON.stringify(talks, null, 2));
console.log(`File ./src/talks.json saved`) console.log(`File ./src/talks.json saved`);