Merge pull request #92 from supercoww/star-script

Add script for updating stars
This commit is contained in:
Kevin Åberg Kultalahti
2021-08-30 20:13:43 +02:00
committed by GitHub
6 changed files with 3224 additions and 3592 deletions

180
package-lock.json generated
View File

@@ -5,12 +5,12 @@
"requires": true,
"packages": {
"": {
"name": "sveltesociety.dev",
"version": "0.0.1",
"dependencies": {
"svelte-highlight": "^3.2.0"
},
"devDependencies": {
"@octokit/graphql": "^4.7.0",
"@sveltejs/adapter-static": "next",
"@sveltejs/kit": "next",
"@typescript-eslint/eslint-plugin": "^4.19.0",
@@ -210,6 +210,68 @@
"node": ">= 8"
}
},
"node_modules/@octokit/endpoint": {
"version": "6.0.12",
"resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.12.tgz",
"integrity": "sha512-lF3puPwkQWGfkMClXb4k/eUT/nZKQfxinRWJrdZaJO85Dqwo/G0yOC434Jr2ojwafWJMYqFGFa5ms4jJUgujdA==",
"dev": true,
"dependencies": {
"@octokit/types": "^6.0.3",
"is-plain-object": "^5.0.0",
"universal-user-agent": "^6.0.0"
}
},
"node_modules/@octokit/graphql": {
"version": "4.7.0",
"resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.7.0.tgz",
"integrity": "sha512-diY0qMPyQjfu4rDu3kDhJ9qIZadIm4IISO3RJSv9ajYUWJUCO0AykbgzLcg1xclxtXgzY583u3gAv66M6zz5SA==",
"dev": true,
"dependencies": {
"@octokit/request": "^5.6.0",
"@octokit/types": "^6.0.3",
"universal-user-agent": "^6.0.0"
}
},
"node_modules/@octokit/openapi-types": {
"version": "9.7.0",
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-9.7.0.tgz",
"integrity": "sha512-TUJ16DJU8mekne6+KVcMV5g6g/rJlrnIKn7aALG9QrNpnEipFc1xjoarh0PKaAWf2Hf+HwthRKYt+9mCm5RsRg==",
"dev": true
},
"node_modules/@octokit/request": {
"version": "5.6.1",
"resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.6.1.tgz",
"integrity": "sha512-Ls2cfs1OfXaOKzkcxnqw5MR6drMA/zWX/LIS/p8Yjdz7QKTPQLMsB3R+OvoxE6XnXeXEE2X7xe4G4l4X0gRiKQ==",
"dev": true,
"dependencies": {
"@octokit/endpoint": "^6.0.1",
"@octokit/request-error": "^2.1.0",
"@octokit/types": "^6.16.1",
"is-plain-object": "^5.0.0",
"node-fetch": "^2.6.1",
"universal-user-agent": "^6.0.0"
}
},
"node_modules/@octokit/request-error": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.1.0.tgz",
"integrity": "sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg==",
"dev": true,
"dependencies": {
"@octokit/types": "^6.0.3",
"deprecation": "^2.0.0",
"once": "^1.4.0"
}
},
"node_modules/@octokit/types": {
"version": "6.25.0",
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.25.0.tgz",
"integrity": "sha512-bNvyQKfngvAd/08COlYIN54nRgxskmejgywodizQNyiKoXmWRAjKup2/LYwm+T9V0gsKH6tuld1gM0PzmOiB4Q==",
"dev": true,
"dependencies": {
"@octokit/openapi-types": "^9.5.0"
}
},
"node_modules/@rollup/pluginutils": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.1.1.tgz",
@@ -1122,6 +1184,12 @@
"integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=",
"dev": true
},
"node_modules/deprecation": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz",
"integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==",
"dev": true
},
"node_modules/detect-indent": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-6.1.0.tgz",
@@ -1986,6 +2054,15 @@
"node": ">=0.12.0"
}
},
"node_modules/is-plain-object": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz",
"integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/is-resolvable": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz",
@@ -2271,6 +2348,15 @@
"lodash": "^4.17.21"
}
},
"node_modules/node-fetch": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
"dev": true,
"engines": {
"node": "4.x || >=6.0.0"
}
},
"node_modules/node-releases": {
"version": "1.1.75",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.75.tgz",
@@ -3744,6 +3830,12 @@
"url": "https://opencollective.com/unified"
}
},
"node_modules/universal-user-agent": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz",
"integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==",
"dev": true
},
"node_modules/universalify": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
@@ -4019,6 +4111,68 @@
"fastq": "^1.6.0"
}
},
"@octokit/endpoint": {
"version": "6.0.12",
"resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.12.tgz",
"integrity": "sha512-lF3puPwkQWGfkMClXb4k/eUT/nZKQfxinRWJrdZaJO85Dqwo/G0yOC434Jr2ojwafWJMYqFGFa5ms4jJUgujdA==",
"dev": true,
"requires": {
"@octokit/types": "^6.0.3",
"is-plain-object": "^5.0.0",
"universal-user-agent": "^6.0.0"
}
},
"@octokit/graphql": {
"version": "4.7.0",
"resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.7.0.tgz",
"integrity": "sha512-diY0qMPyQjfu4rDu3kDhJ9qIZadIm4IISO3RJSv9ajYUWJUCO0AykbgzLcg1xclxtXgzY583u3gAv66M6zz5SA==",
"dev": true,
"requires": {
"@octokit/request": "^5.6.0",
"@octokit/types": "^6.0.3",
"universal-user-agent": "^6.0.0"
}
},
"@octokit/openapi-types": {
"version": "9.7.0",
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-9.7.0.tgz",
"integrity": "sha512-TUJ16DJU8mekne6+KVcMV5g6g/rJlrnIKn7aALG9QrNpnEipFc1xjoarh0PKaAWf2Hf+HwthRKYt+9mCm5RsRg==",
"dev": true
},
"@octokit/request": {
"version": "5.6.1",
"resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.6.1.tgz",
"integrity": "sha512-Ls2cfs1OfXaOKzkcxnqw5MR6drMA/zWX/LIS/p8Yjdz7QKTPQLMsB3R+OvoxE6XnXeXEE2X7xe4G4l4X0gRiKQ==",
"dev": true,
"requires": {
"@octokit/endpoint": "^6.0.1",
"@octokit/request-error": "^2.1.0",
"@octokit/types": "^6.16.1",
"is-plain-object": "^5.0.0",
"node-fetch": "^2.6.1",
"universal-user-agent": "^6.0.0"
}
},
"@octokit/request-error": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.1.0.tgz",
"integrity": "sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg==",
"dev": true,
"requires": {
"@octokit/types": "^6.0.3",
"deprecation": "^2.0.0",
"once": "^1.4.0"
}
},
"@octokit/types": {
"version": "6.25.0",
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.25.0.tgz",
"integrity": "sha512-bNvyQKfngvAd/08COlYIN54nRgxskmejgywodizQNyiKoXmWRAjKup2/LYwm+T9V0gsKH6tuld1gM0PzmOiB4Q==",
"dev": true,
"requires": {
"@octokit/openapi-types": "^9.5.0"
}
},
"@rollup/pluginutils": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.1.1.tgz",
@@ -4668,6 +4822,12 @@
"integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=",
"dev": true
},
"deprecation": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz",
"integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==",
"dev": true
},
"detect-indent": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-6.1.0.tgz",
@@ -5312,6 +5472,12 @@
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"dev": true
},
"is-plain-object": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz",
"integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==",
"dev": true
},
"is-resolvable": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz",
@@ -5550,6 +5716,12 @@
"lodash": "^4.17.21"
}
},
"node-fetch": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
"dev": true
},
"node-releases": {
"version": "1.1.75",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.75.tgz",
@@ -6529,6 +6701,12 @@
"@types/unist": "^2.0.2"
}
},
"universal-user-agent": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz",
"integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==",
"dev": true
},
"universalify": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",

View File

@@ -10,6 +10,7 @@
"format": "prettier --write ."
},
"devDependencies": {
"@octokit/graphql": "^4.7.0",
"@sveltejs/adapter-static": "next",
"@sveltejs/kit": "next",
"@typescript-eslint/eslint-plugin": "^4.19.0",
@@ -26,9 +27,9 @@
"prettier-plugin-svelte": "^2.2.0",
"svelte": "^3.38.2",
"svelte-preprocess": "^4.7.4",
"tailwindcss": "^2.2.4",
"tslib": "^2.0.0",
"typescript": "^4.0.0",
"tailwindcss": "^2.2.4"
"typescript": "^4.0.0"
},
"type": "module",
"dependencies": {

92
scripts/updateStars.js Normal file
View File

@@ -0,0 +1,92 @@
/**
* Script for updating github stars of repositories
* Usage: GH_TOKEN=secret node scripts/updateStars.js
*
* GH_TOKEN - personal access token with repo scope
*/
import fs from 'fs';
import { graphql } from '@octokit/graphql';
import prettier from 'prettier';
const files = [
'src/routes/components/components.json',
'src/routes/templates/templates.json',
'src/routes/tooling/tools.json'
];
if (!process.env.GH_TOKEN) {
console.error('Error: env variable GH_TOKEN not set');
process.exit(1);
}
const getGithubRepo = ({ url }) => {
const match = url.match(/github.com\/([^#/]+)\/([^#/]+)/);
if (match) {
const [, owner, name] = match;
return `${owner}/${name}`;
}
};
const repos = files.flatMap(
(file) =>
JSON.parse(fs.readFileSync(file))
.map(getGithubRepo)
.filter((x) => x) // filter undefined
);
const uniqueRepos = [...new Set(repos)].map((repo) => {
const [owner, name] = repo.split('/');
return { owner, name };
});
const repoQuery = (repo, id) => `
r${id}: repository(owner: "${repo.owner}", name: "${repo.name}") {
...frag
}
`;
const response = await graphql(
/* GraphQL */ `
{
${uniqueRepos.map(repoQuery).join('')}
}
fragment frag on Repository {
owner {
login
}
name
stargazerCount
}
`,
{
headers: {
authorization: `token ${process.env.GH_TOKEN}`
}
}
);
const repoData = Object.fromEntries(
Object.values(response).map((repo) => [`${repo.owner.login}/${repo.name}`, repo])
);
for (const file of files) {
const data = JSON.parse(fs.readFileSync(file));
for (const item of data) {
const repo = getGithubRepo(item);
if (repo && repoData[repo]) {
item.stars = repoData[repo].stargazerCount;
}
}
prettySave(file, JSON.stringify(data), 'json');
}
/**
* Format with prettier and save
*/
function prettySave(filePath, text, parser = 'babel') {
prettier.resolveConfig(filePath).then((options) => {
const formatted = prettier.format(text, { ...options, parser });
fs.writeFileSync(filePath, formatted);
});
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -6,7 +6,7 @@
"description": "Compile Svelte components with Rollup",
"url": "https://github.com/sveltejs/rollup-plugin-svelte",
"tags": ["official"],
"stars": 396
"stars": 400
},
{
"addedOn": "2021-08-09T10:14:05.723Z",
@@ -15,7 +15,7 @@
"description": "Webpack loader for svelte components",
"url": "https://github.com/sveltejs/svelte-loader",
"tags": ["official"],
"stars": 486
"stars": 491
},
{
"addedOn": "2021-08-09T10:14:05.723Z",
@@ -24,7 +24,7 @@
"description": "This is the official svelte plugin for vite",
"url": "https://github.com/sveltejs/vite-plugin-svelte",
"tags": ["official"],
"stars": 193
"stars": 213
},
{
"addedOn": "2021-08-09T10:14:05.723Z",
@@ -33,7 +33,7 @@
"description": "An esbuild plugin to compile Svelte components",
"url": "https://github.com/EMH333/esbuild-svelte",
"tags": [],
"stars": 100
"stars": 106
},
{
"addedOn": "2021-08-09T10:14:05.723Z",
@@ -51,7 +51,7 @@
"description": "A parcel plugin that enables svelte support",
"url": "https://github.com/DeMoorJasper/parcel-plugin-svelte",
"tags": [],
"stars": 217
"stars": 216
},
{
"addedOn": "2021-08-09T10:14:05.723Z",
@@ -105,7 +105,7 @@
"description": "An extension that allows inspection of Svelte component hierarchy and state in the Firefox and Chrome developer tools",
"url": "https://github.com/RedHatter/svelte-devtools",
"tags": [],
"stars": 548
"stars": 553
},
{
"addedOn": "2021-08-09T10:14:05.723Z",
@@ -114,7 +114,7 @@
"description": "A ✨ magical ✨ Svelte preprocessor with sensible defaults and support for: PostCSS, SCSS, Less, Stylus, Coffeescript, TypeScript, Pug and much more",
"url": "https://github.com/sveltejs/svelte-preprocess",
"tags": ["official"],
"stars": 1100
"stars": 1119
},
{
"addedOn": "2021-08-09T10:14:05.723Z",
@@ -132,7 +132,7 @@
"description": "Svelte preprocessor support for modular-css",
"url": "https://github.com/tivac/modular-css/tree/main/packages/svelte",
"tags": [],
"stars": 239
"stars": 240
},
{
"addedOn": "2021-08-09T10:14:05.723Z",
@@ -177,7 +177,7 @@
"description": "An ESLint plugin for Svelte v3 components.",
"url": "https://github.com/sveltejs/eslint-plugin-svelte3",
"tags": ["official"],
"stars": 284
"stars": 289
},
{
"addedOn": "2021-08-09T10:14:05.723Z",
@@ -186,7 +186,7 @@
"description": "Format your svelte components using prettier.",
"url": "https://github.com/sveltejs/prettier-plugin-svelte",
"tags": ["official"],
"stars": 375
"stars": 381
},
{
"addedOn": "2021-08-09T10:14:05.723Z",
@@ -213,7 +213,7 @@
"description": "Vim syntax highlighting and indentation for Svelte 3 components.",
"url": "https://github.com/evanleck/vim-svelte",
"tags": [],
"stars": 187
"stars": 192
},
{
"addedOn": "2021-08-09T10:14:05.723Z",
@@ -231,7 +231,7 @@
"description": "Svelte support for (Neo)Vim",
"url": "https://github.com/coc-extensions/coc-svelte",
"tags": [],
"stars": 95
"stars": 97
},
{
"addedOn": "2021-08-09T10:14:05.723Z",
@@ -240,7 +240,7 @@
"description": "Emacs major mode including support for Svelte",
"url": "https://github.com/fxbois/web-mode",
"tags": [],
"stars": 1448
"stars": 1454
},
{
"addedOn": "2021-08-09T10:14:05.723Z",