{numeral(totalCommits).format('0,0a')}
commits past year
diff --git a/src/lib/createConfig.ts b/src/lib/createConfig.ts
new file mode 100644
index 0000000..7b044a5
--- /dev/null
+++ b/src/lib/createConfig.ts
@@ -0,0 +1,11 @@
+import type { Config } from '../types';
+import { config } from '../config';
+
+export const appConfig: Config = {
+ requestDelay: process.env.REQUEST_DELAY ? Number(process.env.REQUEST_DELAY) : config.requestDelay,
+ urls: config.urls,
+ lowCommitCount: process.env.LOW_COMMIT_COUNT
+ ? Number(process.env.LOW_COMMIT_COUNT)
+ : config.lowCommitCount,
+ chunkSize: process.env.CHUNK_SIZE ? Number(process.env.CHUNK_SIZE) : config.chunkSize
+};
diff --git a/src/lib/fetch-github.ts b/src/lib/fetch-github.ts
index 9bf4bdc..d09692a 100644
--- a/src/lib/fetch-github.ts
+++ b/src/lib/fetch-github.ts
@@ -2,7 +2,7 @@ import type { GithubQueryResult, GithubRepo, Project } from './types/types';
import { TOKEN_GITHUB } from '$env/static/private';
import { delay, extractGithubRepoUrls } from './index';
import { createQuery } from './query';
-import { config } from '../config';
+import { appConfig } from './createConfig';
export async function fetchAllGithubRepositories(allProjects: Project[]) {
const githubRepoUrls = extractGithubRepoUrls(allProjects);
@@ -10,15 +10,15 @@ export async function fetchAllGithubRepositories(allProjects: Project[]) {
const urls = [...githubRepoUrls];
let data: GithubRepo[] = [];
- for (let i = 0; i < urls.length; i += config.chunkSize) {
- const chunk = urls.slice(i, i + config.chunkSize);
+ for (let i = 0; i < urls.length; i += appConfig.chunkSize) {
+ const chunk = urls.slice(i, i + appConfig.chunkSize);
const query = await createQuery(chunk);
const result = await fetchRepoInfoFromGithub(query);
data = data.concat(result);
- if (config.requestDelay > 0) {
- await delay(config.requestDelay);
- console.log('delay:', config.requestDelay);
+ if (appConfig.requestDelay > 0) {
+ await delay(appConfig.requestDelay);
+ console.log('delay:', appConfig.requestDelay);
}
// if (import.meta.env.DEV) {
// break;
diff --git a/src/lib/query.ts b/src/lib/query.ts
index 3712f4c..706b175 100644
--- a/src/lib/query.ts
+++ b/src/lib/query.ts
@@ -1,4 +1,4 @@
-import { config } from '../config';
+import { appConfig } from '../lib/createConfig';
interface MonthInfo {
name: string;
@@ -41,7 +41,7 @@ export async function createQuery(urls: string[]) {
search(
type:REPOSITORY,
query: "${searchString}",
- first: ${config.chunkSize + 10}
+ first: ${appConfig.chunkSize + 10}
) {
repos: edges {
repo: node {
diff --git a/src/lib/repositories.ts b/src/lib/repositories.ts
index cde4db1..cd6aff7 100644
--- a/src/lib/repositories.ts
+++ b/src/lib/repositories.ts
@@ -1,7 +1,7 @@
import type { AllCategories, Category, Project } from './types/types';
import slugify from '@sindresorhus/slugify';
import { removeTrailingSlashes } from './index';
-import { config } from '../config';
+import { appConfig } from '../lib/createConfig';
export interface ProjectsAndCategories {
projects: Project[];
@@ -140,7 +140,7 @@ async function combineSources(urls: string[]): Promise
{
export async function getProjectsFromAwesomeList(): Promise {
const start = performance.now();
- const markdown = await combineSources(config.urls);
+ const markdown = await combineSources(appConfig.urls);
const { projects } = extractRepositories(markdown);
const end = performance.now();
console.log(
@@ -150,7 +150,7 @@ export async function getProjectsFromAwesomeList(): Promise {
}
export async function getAllCategories(): Promise {
- const markdown = await combineSources(config.urls);
+ const markdown = await combineSources(appConfig.urls);
const { categories } = extractRepositories(markdown);
return categories;
}