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 * as cheerio from "https://esm.sh/cheerio@1.0.0-rc.12";
const resp = await fetch("https://mirror.xyz/0x0f1F3DAf416B74DB3DE55Eb4D7513a80F4841073/feed/atom")
const xml = await resp.text()
const feed = await parseFeed(xml)
const resp = await fetch(
"https://mirror.xyz/0x0f1F3DAf416B74DB3DE55Eb4D7513a80F4841073/feed/atom",
);
const xml = await resp.text();
const feed = await parseFeed(xml);
const articles = []
const articles = [];
for (const entry of feed.entries) {
//console.log(entry)
const $ = cheerio.load(entry.content.value)
const $ = cheerio.load(entry.content.value);
articles.push({
url: entry.id,
title: entry.title.value,
img: $("img").attr("src"),
date: entry.updated,
})
});
}
//console.log(articles)
await Deno.writeTextFile("./src/articles.json", JSON.stringify(articles, null, 2))
console.log(`File ./src/articles.json saved`)
await Deno.writeTextFile(
"./src/articles.json",
JSON.stringify(articles, null, 2),
);
console.log(`File ./src/articles.json saved`);

View file

@ -1,7 +1,6 @@
import "https://deno.land/std@0.206.0/dotenv/load.ts";
const contributorRepos = [
// main repos
"web3privacy/web3privacy",
"web3privacy/data",
@ -22,8 +21,7 @@ const contributorRepos = [
"web3privacy/grants",
"web3privacy/old-website",
"web3privacy/web3privacy-app-old",
]
];
function isBlacklisted(login) {
if (login.match(/\[bot\]$/)) {
@ -34,28 +32,34 @@ function isBlacklisted (login) {
async function getContributors() {
const output = [];
for (const cr of contributorRepos) {
const response = await fetch(`https://api.github.com/repos/${cr}/contributors`, {
const response = await fetch(
`https://api.github.com/repos/${cr}/contributors`,
{
//headers: {
// "Authorization": `Token ${Deno.env.get('GITHUB_TOKEN')}`
//}
});
},
);
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) {
output.push(item)
output.push(item);
} else {
found.contributions += item.contributions
found.contributions += item.contributions;
}
}
}
return output.sort((x, y) => y.contributions > x.contributions ? 1 : -1);
}
const contributors = await getContributors()
await Deno.writeTextFile("./src/contributors.json", JSON.stringify(contributors, null, 2))
console.log(`File ./src/contributors.json saved`)
const contributors = await getContributors();
await Deno.writeTextFile(
"./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 data = await response.json()
await Deno.writeTextFile("./src/core.json", JSON.stringify(data, null, 2))
console.log(`File ./src/core.json saved`)
const response = await fetch("https://data.web3privacy.info/");
const data = await response.json();
await Deno.writeTextFile("./src/core.json", JSON.stringify(data, null, 2));
console.log(`File ./src/core.json saved`);

View file

@ -1,15 +1,18 @@
const resp = await fetch("https://explorer-data.web3privacy.info/");
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 explorer = {
projects: data.projects.length,
contributors: respContribsData.length,
}
};
await Deno.writeTextFile("./src/explorer.json", JSON.stringify(explorer, null, 2))
console.log(`File ./src/explorer.json saved`)
await Deno.writeTextFile(
"./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 * 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 xml = await resp.text()
const feed = await parseFeed(xml)
const resp = await fetch(
"https://www.youtube.com/feeds/videos.xml?channel_id=UCaO_vLpj164um5maEsCuEbw",
);
const xml = await resp.text();
const feed = await parseFeed(xml);
const talks = []
const talks = [];
for (const entry of feed.entries) {
console.log(entry)
console.log(entry);
//const $ = cheerio.load(entry.content.value)
talks.push({
url: entry.links[0].href,
title: entry.title.value,
img: entry["media:group"]["media:thumbnail"].url.replace("hqdefault", "maxresdefault"),
img: entry["media:group"]["media:thumbnail"].url.replace(
"hqdefault",
"maxresdefault",
),
date: entry.published,
})
});
}
//console.log(articles)
await Deno.writeTextFile("./src/talks.json", JSON.stringify(talks, null, 2))
console.log(`File ./src/talks.json saved`)
await Deno.writeTextFile("./src/talks.json", JSON.stringify(talks, null, 2));
console.log(`File ./src/talks.json saved`);