diff --git a/pages/api/libraries/statistic.ts b/pages/api/libraries/statistic.ts index d130b88a..405f55fc 100644 --- a/pages/api/libraries/statistic.ts +++ b/pages/api/libraries/statistic.ts @@ -35,6 +35,19 @@ export default function handler(_: NextApiRequest, res: NextApiResponse) { npm: 0, yarn: 0, }, + moduleType: { + expo: 0, + nitro: 0, + turbo: 0, + }, + lintTools: { + oxlint: 0, + oxfmt: 0, + eslint: 0, + prettier: 0, + biome: 0, + commitlint: 0, + }, }; DATASET.libraries.forEach(library => { @@ -120,6 +133,20 @@ export default function handler(_: NextApiRequest, res: NextApiResponse) { result.vegaos++; } + library.github.lintTools?.forEach(tool => { + result.lintTools[tool]++; + }); + + if (library.github.moduleType) { + if (library.github.moduleType === 'expo') { + result.moduleType.expo++; + } else if (library.github.moduleType === 'nitro') { + result.moduleType.nitro++; + } else if (library.github.moduleType === 'turbo') { + result.moduleType.turbo++; + } + } + if (library.github.packageManager) { if (library.github.packageManager.includes('bun')) { result.packageManager.bun++; diff --git a/scripts/fetch-github-data.ts b/scripts/fetch-github-data.ts index 8913f62f..374b806e 100644 --- a/scripts/fetch-github-data.ts +++ b/scripts/fetch-github-data.ts @@ -168,7 +168,6 @@ function createRepoDataWithResponse(json: any, monorepo: boolean): LibraryType[' try { const packageJson = JSON.parse(json.packageJson.text); - json.pasedPackageJson = packageJson; json.newArchitecture = Boolean(packageJson.codegenConfig); json.name = packageJson.name; json.isPackagePrivate = packageJson.private ?? false; @@ -177,6 +176,8 @@ function createRepoDataWithResponse(json: any, monorepo: boolean): LibraryType[' ? Object.keys(packageJson.dependencies).length : 0; json.packageManager = packageJson.packageManager ?? undefined; + json.lintTools = getLintToolsFromPackageJson(packageJson); + json.moduleType = detectModuleType(json.files, packageJson); if (monorepo) { json.homepageUrl = packageJson.homepage; @@ -196,7 +197,6 @@ function createRepoDataWithResponse(json: any, monorepo: boolean): LibraryType[' json.description = packageJson.description ?? json.description; json.homepageUrl = packageJson.homepage ?? json.homepageUrl; - json.lintTools = getLintToolsFromPackageJson(packageJson); if (!json.licenseInfo || json.licenseInfo?.key === 'other') { json.licenseInfo = getLicenseFromPackageJson(packageJson) ?? json.licenseInfo; @@ -263,7 +263,7 @@ function createRepoDataWithResponse(json: any, monorepo: boolean): LibraryType[' hasSecurity: hasSecurityFile(json.files) || hasSecurityFile(json.rootFiles), hasNativeCode: hasNativeCode(json.files), configPlugin: hasConfigPlugin(json.files), - moduleType: detectModuleType(json.files, json.pasedPackageJson), + moduleType: json.moduleType, packageManager: json.packageManager ?? detectPackageManager(json.files) ?? @@ -272,6 +272,6 @@ function createRepoDataWithResponse(json: any, monorepo: boolean): LibraryType[' ...json.lintTools, ...detectLintStack(json.files), ...detectLintStack(json.rootFiles), - ]), + ]).sort((a, b) => a.localeCompare(b)), }; } diff --git a/types/index.ts b/types/index.ts index 375e8d9c..17ac6c19 100644 --- a/types/index.ts +++ b/types/index.ts @@ -99,9 +99,9 @@ export type LibraryType = LibraryDataEntryType & { hasCC?: boolean; hasSecurity?: boolean; configPlugin?: boolean; - moduleType?: 'expo' | 'nitro' | 'turbo'; - packageManager?: string; - lintTools?: LintTool[]; + moduleType?: ModuleType; + packageManager?: PackageManagerType; + lintTools?: LintToolType[]; urls: { repo: string; homepage?: string | null; @@ -253,12 +253,9 @@ export type StatisticResultType = { tvos: number; visionos: number; vegaos: number; - packageManager: { - bun: number; - pnpm: number; - npm: number; - yarn: number; - }; + packageManager: Record; + moduleType: Record; + lintTools: Record; }; type NpmRegistryCommonData = { @@ -424,4 +421,6 @@ export type PackageNavigationTab = { counter?: number | string; }; -export type LintTool = 'oxlint' | 'oxfmt' | 'eslint' | 'prettier' | 'biome' | 'commitlint'; +export type PackageManagerType = 'bun' | 'pnpm' | 'npm' | 'yarn'; +export type ModuleType = 'expo' | 'nitro' | 'turbo'; +export type LintToolType = 'oxlint' | 'oxfmt' | 'eslint' | 'prettier' | 'biome' | 'commitlint'; diff --git a/util/github/detectModuleType.ts b/util/github/detectModuleType.ts index c422bede..4a871008 100644 --- a/util/github/detectModuleType.ts +++ b/util/github/detectModuleType.ts @@ -1,9 +1,9 @@ -import { type RepositoryTreeNode } from '~/types'; +import { type ModuleType, type RepositoryTreeNode } from '~/types'; export default function detectModuleType( rootFiles: { entries: RepositoryTreeNode[] } | null, packageJson: any -) { +): ModuleType | undefined { if (!rootFiles?.entries.length) { return undefined; } diff --git a/util/github/hasFiles.ts b/util/github/hasFiles.ts index 7e85a305..006103b6 100644 --- a/util/github/hasFiles.ts +++ b/util/github/hasFiles.ts @@ -1,4 +1,4 @@ -import { type LintTool, type RepositoryTreeNode } from '~/types'; +import { type LintToolType, type RepositoryTreeNode } from '~/types'; type RootFiles = { entries: RepositoryTreeNode[] } | null; @@ -94,6 +94,7 @@ const ESLINT_CONFIG_FILE_NAMES = new Set([ '.eslintrc.json', '.eslintrc.yaml', '.eslintrc.yml', + '.eslintignore', ]); const PRETTIER_CONFIG_FILE_NAMES = new Set([ '.prettierrc', @@ -108,6 +109,7 @@ const PRETTIER_CONFIG_FILE_NAMES = new Set([ 'prettier.config.js', 'prettier.config.cjs', 'prettier.config.mjs', + '.prettierignore', ]); const BIOME_CONFIG_FILE_NAMES = new Set(['biome.json', 'biome.jsonc']); const COMMITLINT_CONFIG_FILE_NAMES = new Set([ @@ -130,7 +132,7 @@ const COMMITLINT_CONFIG_FILE_NAMES = new Set([ ]); export function detectLintStack(rootFiles: RootFiles) { - const lintTools: LintTool[] = []; + const lintTools: LintToolType[] = []; if (hasMatchingFiles(rootFiles, OXLINT_CONFIG_FILE_NAMES)) { lintTools.push('oxlint'); } diff --git a/util/strings.ts b/util/strings.ts index f0bb5e62..4d9a0534 100644 --- a/util/strings.ts +++ b/util/strings.ts @@ -1,6 +1,6 @@ import { Children, isValidElement, type PropsWithChildren, type ReactNode } from 'react'; -import { type LintTool } from '~/types'; +import { type LintToolType } from '~/types'; export const NUMBER_FORMATTER = new Intl.NumberFormat('en-US', { notation: 'compact', @@ -63,7 +63,7 @@ export function formatPackageManager(pmRaw?: string) { } } -export function formatLintTools(lintTool: LintTool) { +export function formatLintTools(lintTool: LintToolType) { switch (lintTool) { case 'oxlint': return 'Oxlint';