1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Doc: Update sponsors

This commit is contained in:
Laurent Cozic 2023-03-12 12:38:08 +00:00
parent 75ad454971
commit bcb578c933
3 changed files with 59 additions and 83 deletions

View File

@ -1,120 +1,61 @@
{
"github": [
{
"name": "nicholashead",
"id": "1168659"
"name": "tateisu"
},
{
"name": "avanderberg",
"id": "215668"
"name": "matmoly"
},
{
"name": "fbloise",
"id": "1439535"
"name": "KentBrockman"
},
{
"name": "thomasbroussard",
"id": "15859362"
"name": "CyberXZT"
},
{
"name": "dbrandonjohnson",
"id": "1307332"
"name": "avanderberg"
},
{
"name": "c-nagy",
"id": "3061769"
"name": "dbrandonjohnson"
},
{
"name": "mcejp",
"id": "29300939"
"name": "mcejp"
},
{
"name": "joesfer",
"id": "1248504"
"name": "chr15m"
},
{
"name": "chr15m",
"id": "67130"
"name": "maxtruxa"
},
{
"name": "piccobit",
"id": "5782817"
"name": "konishi-t"
},
{
"name": "chrootlogin",
"id": "4862947"
"name": "iamwillbar"
},
{
"name": "maxtruxa",
"id": "1788010"
"name": "marcdw1289"
},
{
"name": "Jesssullivan",
"id": "37297218"
"name": "kianenigma"
},
{
"name": "cabottech",
"id": "70780798"
"name": "taskcruncher"
},
{
"name": "h4sh5",
"id": "38898566"
"name": "fourstepper"
},
{
"name": "ravenscroftj",
"id": "47742"
"name": "sif"
},
{
"name": "thismarty",
"id": "73081837"
"name": "saarantras"
},
{
"name": "konishi-t",
"id": "24908652"
"name": "Hegghammer"
},
{
"name": "clmntsl",
"id": "82579431"
},
{
"name": "cuongtransc",
"id": "808091"
},
{
"name": "iamwillbar",
"id": "3266447"
},
{
"name": "marcdw1289",
"id": "42319182"
},
{
"name": "kianenigma",
"id": "5588131"
},
{
"name": "taskcruncher",
"id": "765564"
},
{
"name": "fourstepper",
"id": "49439044"
},
{
"name": "Polymathic-Company",
"id": "77214738"
},
{
"name": "sif",
"id": "327998"
},
{
"name": "skyrunner15",
"id": "54626606"
},
{
"name": "jknowles",
"id": "1310474"
"name": "jknowles"
}
],
"orgs": [

View File

@ -1,12 +1,44 @@
import { readFile } from 'fs-extra';
import { insertContentIntoFile, rootDir } from './tool-utils';
import markdownUtils, { MarkdownTableHeader, MarkdownTableJustify, MarkdownTableRow } from '@joplin/lib/markdownUtils';
import { GithubSponsor, OrgSponsor, Sponsors } from './website/utils/types';
import { GithubSponsor, GithubUser, OrgSponsor, Sponsors } from './website/utils/types';
import fetch from 'node-fetch';
const { escapeHtml } = require('@joplin/lib/string-utils');
const readmePath = `${rootDir}/README.md`;
const sponsorsPath = `${rootDir}/packages/tools/sponsors.json`;
const sleep = (ms: number) => {
return new Promise(resolve => setTimeout(resolve, ms));
};
const fetchWithRetry = async (url: string, opts: any = null) => {
if (!opts) opts = {};
let retry = opts && opts.retry || 3;
while (retry > 0) {
try {
return fetch(url, opts);
} catch (e) {
if (opts && opts.callback) {
opts.callback(retry);
}
retry = retry - 1;
if (retry === 0) {
throw e;
}
if (opts && opts.pause) {
if (opts && !opts.silent) console.log('pausing..');
await sleep(opts.pause);
if (opts && !opts.silent) console.log('done pausing...');
}
}
}
return null;
};
async function createGitHubSponsorTable(sponsors: GithubSponsor[]): Promise<string> {
sponsors = sponsors.slice();
@ -31,14 +63,16 @@ async function createGitHubSponsorTable(sponsors: GithubSponsor[]): Promise<stri
let sponsorIndex = 0;
for (let rowIndex = 0; rowIndex < 9999; rowIndex++) {
let sponsor = null;
let sponsor: GithubSponsor = null;
const row: MarkdownTableRow = {};
for (let colIndex = 0; colIndex < sponsorsPerRow; colIndex++) {
sponsor = sponsors[sponsorIndex];
sponsorIndex++;
if (!sponsor) break;
row[`col${colIndex}`] = `<img width="50" src="https://avatars2.githubusercontent.com/u/${sponsor.id}?s=96&v=4"/></br>[${sponsor.name}](https://github.com/${sponsor.name})`;
const userResponse = await fetchWithRetry(`https://api.github.com/users/${sponsor.name}`);
const user = await userResponse.json() as GithubUser;
row[`col${colIndex}`] = `<img width="50" src="https://avatars2.githubusercontent.com/u/${user.id}?s=96&v=4"/></br>[${sponsor.name}](https://github.com/${sponsor.name})`;
}
if (Object.keys(row)) rows.push(row);
@ -50,8 +84,6 @@ async function createGitHubSponsorTable(sponsors: GithubSponsor[]): Promise<stri
}
async function createOrgSponsorTable(sponsors: OrgSponsor[]): Promise<string> {
// sponsors = ArrayUtils.shuffle(sponsors);
const output: string[] = [];
for (const sponsor of sponsors) {

View File

@ -8,6 +8,9 @@ export enum Env {
export interface GithubSponsor {
name: string;
}
export interface GithubUser {
id: string;
}