Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions pages/api/libraries/statistic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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++;
Expand Down
8 changes: 4 additions & 4 deletions scripts/fetch-github-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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) ??
Expand All @@ -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)),
};
}
19 changes: 9 additions & 10 deletions types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -253,12 +253,9 @@ export type StatisticResultType = {
tvos: number;
visionos: number;
vegaos: number;
packageManager: {
bun: number;
pnpm: number;
npm: number;
yarn: number;
};
packageManager: Record<PackageManagerType, number>;
moduleType: Record<ModuleType, number>;
lintTools: Record<LintToolType, number>;
};

type NpmRegistryCommonData = {
Expand Down Expand Up @@ -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';
4 changes: 2 additions & 2 deletions util/github/detectModuleType.ts
Original file line number Diff line number Diff line change
@@ -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;
}
Expand Down
6 changes: 4 additions & 2 deletions util/github/hasFiles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type LintTool, type RepositoryTreeNode } from '~/types';
import { type LintToolType, type RepositoryTreeNode } from '~/types';

type RootFiles = { entries: RepositoryTreeNode[] } | null;

Expand Down Expand Up @@ -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',
Expand All @@ -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([
Expand All @@ -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');
}
Expand Down
4 changes: 2 additions & 2 deletions util/strings.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -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';
Expand Down