Merge pull request #4603 from mermaid-js/sidv/optimiseDocs
Avoid downloading avtars everytime on docs:dev
This commit is contained in:
commit
194ef202ac
|
@ -89,6 +89,8 @@
|
||||||
"mult",
|
"mult",
|
||||||
"neurodiverse",
|
"neurodiverse",
|
||||||
"nextra",
|
"nextra",
|
||||||
|
"nikolay",
|
||||||
|
"nirname",
|
||||||
"orlandoni",
|
"orlandoni",
|
||||||
"pathe",
|
"pathe",
|
||||||
"pbrolin",
|
"pbrolin",
|
||||||
|
@ -102,9 +104,11 @@
|
||||||
"ranksep",
|
"ranksep",
|
||||||
"rect",
|
"rect",
|
||||||
"rects",
|
"rects",
|
||||||
|
"reda",
|
||||||
"redmine",
|
"redmine",
|
||||||
"rehype",
|
"rehype",
|
||||||
"roledescription",
|
"roledescription",
|
||||||
|
"rozhkov",
|
||||||
"sandboxed",
|
"sandboxed",
|
||||||
"sankey",
|
"sankey",
|
||||||
"setupgraphviewbox",
|
"setupgraphviewbox",
|
||||||
|
@ -121,6 +125,7 @@
|
||||||
"stylis",
|
"stylis",
|
||||||
"subhash-halder",
|
"subhash-halder",
|
||||||
"substate",
|
"substate",
|
||||||
|
"sulais",
|
||||||
"sveidqvist",
|
"sveidqvist",
|
||||||
"swimm",
|
"swimm",
|
||||||
"techn",
|
"techn",
|
||||||
|
@ -144,6 +149,7 @@
|
||||||
"vueuse",
|
"vueuse",
|
||||||
"xlink",
|
"xlink",
|
||||||
"yash",
|
"yash",
|
||||||
|
"yokozuna",
|
||||||
"zenuml"
|
"zenuml"
|
||||||
],
|
],
|
||||||
"patterns": [
|
"patterns": [
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
"docs:code": "typedoc src/defaultConfig.ts src/config.ts src/mermaidAPI.ts && prettier --write ./src/docs/config/setup",
|
"docs:code": "typedoc src/defaultConfig.ts src/config.ts src/mermaidAPI.ts && prettier --write ./src/docs/config/setup",
|
||||||
"docs:build": "rimraf ../../docs && pnpm docs:spellcheck && pnpm docs:code && ts-node-esm src/docs.mts",
|
"docs:build": "rimraf ../../docs && pnpm docs:spellcheck && pnpm docs:code && ts-node-esm src/docs.mts",
|
||||||
"docs:verify": "pnpm docs:spellcheck && pnpm docs:code && ts-node-esm src/docs.mts --verify",
|
"docs:verify": "pnpm docs:spellcheck && pnpm docs:code && ts-node-esm src/docs.mts --verify",
|
||||||
"docs:pre:vitepress": "rimraf src/vitepress && pnpm docs:code && ts-node-esm src/docs.mts --vitepress && pnpm --filter ./src/vitepress install --no-frozen-lockfile --ignore-scripts ",
|
"docs:pre:vitepress": "pnpm --filter ./src/docs prefetch && rimraf src/vitepress && pnpm docs:code && ts-node-esm src/docs.mts --vitepress && pnpm --filter ./src/vitepress install --no-frozen-lockfile --ignore-scripts",
|
||||||
"docs:build:vitepress": "pnpm docs:pre:vitepress && (cd src/vitepress && pnpm run build) && cpy --flat src/docs/landing/ ./src/vitepress/.vitepress/dist/landing",
|
"docs:build:vitepress": "pnpm docs:pre:vitepress && (cd src/vitepress && pnpm run build) && cpy --flat src/docs/landing/ ./src/vitepress/.vitepress/dist/landing",
|
||||||
"docs:dev": "pnpm docs:pre:vitepress && concurrently \"pnpm --filter ./src/vitepress dev\" \"ts-node-esm src/docs.mts --watch --vitepress\"",
|
"docs:dev": "pnpm docs:pre:vitepress && concurrently \"pnpm --filter ./src/vitepress dev\" \"ts-node-esm src/docs.mts --watch --vitepress\"",
|
||||||
"docs:dev:docker": "pnpm docs:pre:vitepress && concurrently \"pnpm --filter ./src/vitepress dev:docker\" \"ts-node-esm src/docs.mts --watch --vitepress\"",
|
"docs:dev:docker": "pnpm docs:pre:vitepress && concurrently \"pnpm --filter ./src/vitepress dev:docker\" \"ts-node-esm src/docs.mts --watch --vitepress\"",
|
||||||
|
|
|
@ -481,15 +481,15 @@ const transformHtml = (filename: string) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getGlobs = (globs: string[]): string[] => {
|
const getGlobs = (globs: string[]): string[] => {
|
||||||
globs.push(
|
globs.push('!**/dist/**', '!**/redirect.spec.ts', '!**/landing/**', '!**/node_modules/**');
|
||||||
'!**/dist/**',
|
|
||||||
'!**/redirect.spec.ts',
|
|
||||||
'!**/landing/**',
|
|
||||||
'!**/node_modules/**',
|
|
||||||
'!**/user-avatars/**'
|
|
||||||
);
|
|
||||||
if (!vitepress) {
|
if (!vitepress) {
|
||||||
globs.push('!**/.vitepress/**', '!**/vite.config.ts', '!src/docs/index.md', '!**/package.json');
|
globs.push(
|
||||||
|
'!**/.vitepress/**',
|
||||||
|
'!**/vite.config.ts',
|
||||||
|
'!src/docs/index.md',
|
||||||
|
'!**/package.json',
|
||||||
|
'!**/user-avatars/**'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return globs;
|
return globs;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,30 +1,5 @@
|
||||||
import contributorUsernamesJson from './contributor-names.json';
|
import contributorUsernamesJson from './contributor-names.json';
|
||||||
|
import { CoreTeam, knut, plainTeamMembers } from './teamMembers.js';
|
||||||
export interface Contributor {
|
|
||||||
name: string;
|
|
||||||
avatar: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SocialEntry {
|
|
||||||
icon: string | { svg: string };
|
|
||||||
link: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface CoreTeam {
|
|
||||||
name: string;
|
|
||||||
// required to download avatars from GitHub
|
|
||||||
github: string;
|
|
||||||
avatar?: string;
|
|
||||||
twitter?: string;
|
|
||||||
mastodon?: string;
|
|
||||||
sponsor?: string;
|
|
||||||
website?: string;
|
|
||||||
linkedIn?: string;
|
|
||||||
title?: string;
|
|
||||||
org?: string;
|
|
||||||
desc?: string;
|
|
||||||
links?: SocialEntry[];
|
|
||||||
}
|
|
||||||
|
|
||||||
const contributorUsernames: string[] = contributorUsernamesJson;
|
const contributorUsernames: string[] = contributorUsernamesJson;
|
||||||
|
|
||||||
|
@ -38,6 +13,7 @@ const websiteSVG = {
|
||||||
|
|
||||||
const createLinks = (tm: CoreTeam): CoreTeam => {
|
const createLinks = (tm: CoreTeam): CoreTeam => {
|
||||||
tm.avatar = `/user-avatars/${tm.github}.png`;
|
tm.avatar = `/user-avatars/${tm.github}.png`;
|
||||||
|
tm.title = tm.title ?? 'Developer';
|
||||||
tm.links = [{ icon: 'github', link: `https://github.com/${tm.github}` }];
|
tm.links = [{ icon: 'github', link: `https://github.com/${tm.github}` }];
|
||||||
if (tm.mastodon) {
|
if (tm.mastodon) {
|
||||||
tm.links.push({ icon: 'mastodon', link: tm.mastodon });
|
tm.links.push({ icon: 'mastodon', link: tm.mastodon });
|
||||||
|
@ -54,91 +30,6 @@ const createLinks = (tm: CoreTeam): CoreTeam => {
|
||||||
return tm;
|
return tm;
|
||||||
};
|
};
|
||||||
|
|
||||||
const knut: CoreTeam = {
|
|
||||||
github: 'knsv',
|
|
||||||
name: 'Knut Sveidqvist',
|
|
||||||
title: 'Creator',
|
|
||||||
twitter: 'knutsveidqvist',
|
|
||||||
sponsor: 'https://github.com/sponsors/knsv',
|
|
||||||
};
|
|
||||||
|
|
||||||
const plainTeamMembers: CoreTeam[] = [
|
|
||||||
{
|
|
||||||
github: 'NeilCuzon',
|
|
||||||
name: 'Neil Cuzon',
|
|
||||||
title: 'Developer',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
github: 'tylerlong',
|
|
||||||
name: 'Tyler Liu',
|
|
||||||
title: 'Developer',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
github: 'sidharthv96',
|
|
||||||
name: 'Sidharth Vinod',
|
|
||||||
title: 'Developer',
|
|
||||||
twitter: 'sidv42',
|
|
||||||
mastodon: 'https://techhub.social/@sidv',
|
|
||||||
sponsor: 'https://github.com/sponsors/sidharthv96',
|
|
||||||
linkedIn: 'sidharth-vinod',
|
|
||||||
website: 'https://sidharth.dev',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
github: 'ashishjain0512',
|
|
||||||
name: 'Ashish Jain',
|
|
||||||
title: 'Developer',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
github: 'mmorel-35',
|
|
||||||
name: 'Matthieu Morel',
|
|
||||||
title: 'Developer',
|
|
||||||
linkedIn: 'matthieumorel35',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
github: 'aloisklink',
|
|
||||||
name: 'Alois Klink',
|
|
||||||
title: 'Developer',
|
|
||||||
linkedIn: 'aloisklink',
|
|
||||||
website: 'https://aloisklink.com',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
github: 'pbrolin47',
|
|
||||||
name: 'Per Brolin',
|
|
||||||
title: 'Developer',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
github: 'Yash-Singh1',
|
|
||||||
name: 'Yash Singh',
|
|
||||||
title: 'Developer',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
github: 'GDFaber',
|
|
||||||
name: 'Marc Faber',
|
|
||||||
title: 'Developer',
|
|
||||||
linkedIn: 'marc-faber',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
github: 'MindaugasLaganeckas',
|
|
||||||
name: 'Mindaugas Laganeckas',
|
|
||||||
title: 'Developer',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
github: 'jgreywolf',
|
|
||||||
name: 'Justin Greywolf',
|
|
||||||
title: 'Developer',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
github: 'IOrlandoni',
|
|
||||||
name: 'Nacho Orlandoni',
|
|
||||||
title: 'Developer',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
github: 'huynhicode',
|
|
||||||
name: 'Steph Huynh',
|
|
||||||
title: 'Developer',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const teamMembers = plainTeamMembers.map((tm) => createLinks(tm));
|
const teamMembers = plainTeamMembers.map((tm) => createLinks(tm));
|
||||||
teamMembers.sort(
|
teamMembers.sort(
|
||||||
(a, b) => contributorUsernames.indexOf(a.github) - contributorUsernames.indexOf(b.github)
|
(a, b) => contributorUsernames.indexOf(a.github) - contributorUsernames.indexOf(b.github)
|
||||||
|
|
|
@ -19,6 +19,10 @@ async function download(url: string, fileName: URL) {
|
||||||
await writeFile(fileName, Buffer.from(await image.arrayBuffer()));
|
await writeFile(fileName, Buffer.from(await image.arrayBuffer()));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('failed to load', url, error);
|
console.error('failed to load', url, error);
|
||||||
|
// Exit the build process if we are in CI
|
||||||
|
if (process.env.CI) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +36,7 @@ async function fetchAvatars() {
|
||||||
download(`https://github.com/${name}.png?size=100`, getAvatarPath(name));
|
download(`https://github.com/${name}.png?size=100`, getAvatarPath(name));
|
||||||
});
|
});
|
||||||
|
|
||||||
await Promise.all(avatars);
|
await Promise.allSettled(avatars);
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchAvatars();
|
fetchAvatars();
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
// Adapted from https://github.dev/vitest-dev/vitest/blob/991ff33ab717caee85ef6cbe1c16dc514186b4cc/scripts/update-contributors.ts#L6
|
// Adapted from https://github.dev/vitest-dev/vitest/blob/991ff33ab717caee85ef6cbe1c16dc514186b4cc/scripts/update-contributors.ts#L6
|
||||||
|
|
||||||
import { writeFile } from 'node:fs/promises';
|
import { writeFile } from 'node:fs/promises';
|
||||||
|
import { knut, plainTeamMembers } from '../teamMembers.js';
|
||||||
|
import { existsSync } from 'node:fs';
|
||||||
|
|
||||||
const pathContributors = new URL('../contributor-names.json', import.meta.url);
|
const pathContributors = new URL('../contributor-names.json', import.meta.url);
|
||||||
|
|
||||||
|
@ -35,7 +37,15 @@ async function fetchContributors() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function generate() {
|
async function generate() {
|
||||||
const collaborators = await fetchContributors();
|
if (existsSync(pathContributors)) {
|
||||||
|
// Only fetch contributors once, when running locally.
|
||||||
|
// In CI, the file won't exist, so it'll fetch every time as expected.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Will fetch all contributors only in CI to speed up local development.
|
||||||
|
const collaborators = process.env.CI
|
||||||
|
? await fetchContributors()
|
||||||
|
: [knut, ...plainTeamMembers].map((m) => m.github);
|
||||||
await writeFile(pathContributors, JSON.stringify(collaborators, null, 2) + '\n', 'utf8');
|
await writeFile(pathContributors, JSON.stringify(collaborators, null, 2) + '\n', 'utf8');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,105 @@
|
||||||
|
export interface Contributor {
|
||||||
|
name: string;
|
||||||
|
avatar: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SocialEntry {
|
||||||
|
icon: string | { svg: string };
|
||||||
|
link: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CoreTeam {
|
||||||
|
name: string;
|
||||||
|
// required to download avatars from GitHub
|
||||||
|
github: string;
|
||||||
|
avatar?: string;
|
||||||
|
twitter?: string;
|
||||||
|
mastodon?: string;
|
||||||
|
sponsor?: string;
|
||||||
|
website?: string;
|
||||||
|
linkedIn?: string;
|
||||||
|
title?: string;
|
||||||
|
org?: string;
|
||||||
|
desc?: string;
|
||||||
|
links?: SocialEntry[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export const knut: CoreTeam = {
|
||||||
|
github: 'knsv',
|
||||||
|
name: 'Knut Sveidqvist',
|
||||||
|
title: 'Creator',
|
||||||
|
twitter: 'knutsveidqvist',
|
||||||
|
sponsor: 'https://github.com/sponsors/knsv',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const plainTeamMembers: CoreTeam[] = [
|
||||||
|
{
|
||||||
|
github: 'NeilCuzon',
|
||||||
|
name: 'Neil Cuzon',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
github: 'tylerlong',
|
||||||
|
name: 'Tyler Liu',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
github: 'sidharthv96',
|
||||||
|
name: 'Sidharth Vinod',
|
||||||
|
twitter: 'sidv42',
|
||||||
|
mastodon: 'https://techhub.social/@sidv',
|
||||||
|
sponsor: 'https://github.com/sponsors/sidharthv96',
|
||||||
|
linkedIn: 'sidharth-vinod',
|
||||||
|
website: 'https://sidharth.dev',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
github: 'ashishjain0512',
|
||||||
|
name: 'Ashish Jain',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
github: 'mmorel-35',
|
||||||
|
name: 'Matthieu Morel',
|
||||||
|
linkedIn: 'matthieumorel35',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
github: 'aloisklink',
|
||||||
|
name: 'Alois Klink',
|
||||||
|
linkedIn: 'aloisklink',
|
||||||
|
website: 'https://aloisklink.com',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
github: 'pbrolin47',
|
||||||
|
name: 'Per Brolin',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
github: 'Yash-Singh1',
|
||||||
|
name: 'Yash Singh',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
github: 'GDFaber',
|
||||||
|
name: 'Marc Faber',
|
||||||
|
linkedIn: 'marc-faber',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
github: 'MindaugasLaganeckas',
|
||||||
|
name: 'Mindaugas Laganeckas',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
github: 'jgreywolf',
|
||||||
|
name: 'Justin Greywolf',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
github: 'IOrlandoni',
|
||||||
|
name: 'Nacho Orlandoni',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
github: 'huynhicode',
|
||||||
|
name: 'Steph Huynh',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
github: 'Yokozuna59',
|
||||||
|
name: 'Reda Al Sulais',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
github: 'nirname',
|
||||||
|
name: 'Nikolay Rozhkov',
|
||||||
|
},
|
||||||
|
];
|
Loading…
Reference in New Issue