Fetch gh contributors and store
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
"version": "1.12.9",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
"build": "vite build",
|
||||
"dev": "npm run patch:github && vite dev",
|
||||
"build": "npm run patch:github && vite build",
|
||||
"preview": "vite preview",
|
||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||
@@ -12,6 +12,7 @@
|
||||
"eslint": "eslint .",
|
||||
"format": "prettier --write .",
|
||||
"patch:shaka": "node ./scripts/patchShaka.mjs",
|
||||
"patch:github": "node ./scripts/githubContributors.mjs",
|
||||
"postinstall": "npm run patch:shaka"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -75,4 +76,4 @@
|
||||
"svelte-infinite-loading": "^1.4.0",
|
||||
"youtubei.js": "^16.0.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import fetch from 'node-fetch';
|
||||
import * as url from 'node:url';
|
||||
|
||||
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
||||
|
||||
const apiUrl = 'https://api.github.com/repos/Materialious/Materialious/contributors';
|
||||
const outputDir = path.join(__dirname, '../static/localApi');
|
||||
const outputFile = 'ghContributors.json';
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
const response = await fetch(apiUrl);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
// Ensure the output directory exists
|
||||
if (!fs.existsSync(outputDir)) {
|
||||
fs.mkdirSync(outputDir, { recursive: true });
|
||||
}
|
||||
|
||||
// Write the data to a JSON file
|
||||
fs.writeFileSync(path.join(__dirname, outputDir, outputFile), JSON.stringify(data));
|
||||
console.log('Github contributors fetched and written to', path.join(outputDir, outputFile));
|
||||
} catch (error) {
|
||||
console.error('Error fetching data:', error);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
let ghContributors: { login: string; avatar_url: string; type: 'Bot' | 'User' }[] = $state([]);
|
||||
onMount(() => {
|
||||
fetch('https://api.github.com/repos/Materialious/Materialious/contributors', {
|
||||
fetch(`${document.location.origin}/localApi/ghContributors.json`, {
|
||||
priority: 'low'
|
||||
}).then(async (resp) => {
|
||||
if (!resp.ok) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,23 +0,0 @@
|
||||
{
|
||||
"sourceLanguageTag": "en",
|
||||
"languageTags": [
|
||||
"en",
|
||||
"de",
|
||||
"es",
|
||||
"nl",
|
||||
"pt-BR",
|
||||
"ru",
|
||||
"sh",
|
||||
"tr"
|
||||
],
|
||||
"modules": [
|
||||
"https://cdn.jsdelivr.net/npm/@inlang/plugin-i18next@latest/dist/index.js"
|
||||
],
|
||||
"plugin.inlang.i18next": {
|
||||
"pathPattern": "./materialious/src/lib/i18n/locales/{languageTag}.json",
|
||||
"variableReferencePattern": [
|
||||
"{{",
|
||||
"}}"
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user