Skip to content

Commit cd77a75

Browse files
committed
add module types to statistics, types tweaks
1 parent 6a30926 commit cd77a75

4 files changed

Lines changed: 26 additions & 15 deletions

File tree

pages/api/libraries/statistic.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ export default function handler(_: NextApiRequest, res: NextApiResponse) {
3535
npm: 0,
3636
yarn: 0,
3737
},
38+
moduleType: {
39+
expo: 0,
40+
nitro: 0,
41+
turbo: 0,
42+
},
3843
lintTools: {
3944
oxlint: 0,
4045
oxfmt: 0,
@@ -132,6 +137,16 @@ export default function handler(_: NextApiRequest, res: NextApiResponse) {
132137
result.lintTools[tool]++;
133138
});
134139

140+
if (library.github.moduleType) {
141+
if (library.github.moduleType === 'expo') {
142+
result.moduleType.expo++;
143+
} else if (library.github.moduleType === 'nitro') {
144+
result.moduleType.nitro++;
145+
} else if (library.github.moduleType === 'turbo') {
146+
result.moduleType.turbo++;
147+
}
148+
}
149+
135150
if (library.github.packageManager) {
136151
if (library.github.packageManager.includes('bun')) {
137152
result.packageManager.bun++;

types/index.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ export type LibraryType = LibraryDataEntryType & {
100100
hasSecurity?: boolean;
101101
configPlugin?: boolean;
102102
moduleType?: ModuleType;
103-
packageManager?: string;
104-
lintTools?: LintTool[];
103+
packageManager?: PackageManagerType;
104+
lintTools?: LintToolType[];
105105
urls: {
106106
repo: string;
107107
homepage?: string | null;
@@ -253,13 +253,9 @@ export type StatisticResultType = {
253253
tvos: number;
254254
visionos: number;
255255
vegaos: number;
256-
lintTools: Record<LintTool, number>;
257-
packageManager: {
258-
bun: number;
259-
pnpm: number;
260-
npm: number;
261-
yarn: number;
262-
};
256+
packageManager: Record<PackageManagerType, number>;
257+
moduleType: Record<ModuleType, number>;
258+
lintTools: Record<LintToolType, number>;
263259
};
264260

265261
type NpmRegistryCommonData = {
@@ -425,6 +421,6 @@ export type PackageNavigationTab = {
425421
counter?: number | string;
426422
};
427423

424+
export type PackageManagerType = 'bun' | 'pnpm' | 'npm' | 'yarn';
428425
export type ModuleType = 'expo' | 'nitro' | 'turbo';
429-
430-
export type LintTool = 'oxlint' | 'oxfmt' | 'eslint' | 'prettier' | 'biome' | 'commitlint';
426+
export type LintToolType = 'oxlint' | 'oxfmt' | 'eslint' | 'prettier' | 'biome' | 'commitlint';

util/github/hasFiles.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type LintTool, type RepositoryTreeNode } from '~/types';
1+
import { type LintToolType, type RepositoryTreeNode } from '~/types';
22

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

@@ -132,7 +132,7 @@ const COMMITLINT_CONFIG_FILE_NAMES = new Set([
132132
]);
133133

134134
export function detectLintStack(rootFiles: RootFiles) {
135-
const lintTools: LintTool[] = [];
135+
const lintTools: LintToolType[] = [];
136136
if (hasMatchingFiles(rootFiles, OXLINT_CONFIG_FILE_NAMES)) {
137137
lintTools.push('oxlint');
138138
}

util/strings.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Children, isValidElement, type PropsWithChildren, type ReactNode } from 'react';
22

3-
import { type LintTool } from '~/types';
3+
import { type LintToolType } from '~/types';
44

55
export const NUMBER_FORMATTER = new Intl.NumberFormat('en-US', {
66
notation: 'compact',
@@ -63,7 +63,7 @@ export function formatPackageManager(pmRaw?: string) {
6363
}
6464
}
6565

66-
export function formatLintTools(lintTool: LintTool) {
66+
export function formatLintTools(lintTool: LintToolType) {
6767
switch (lintTool) {
6868
case 'oxlint':
6969
return 'Oxlint';

0 commit comments

Comments
 (0)