MCPcopy Create free account
hub / github.com/TanStack/devtools / detectFramework

Function detectFramework

packages/devtools/src/tabs/marketplace/plugin-utils.ts:6–33  ·  view source on GitHub ↗
(
  pkg: PackageJson,
  frameworks: typeof FRAMEWORKS,
)

Source from the content-addressed store, hash-verified

4import type { ActionType, FRAMEWORKS, PluginCard, PluginSection } from './types'
5
6export const detectFramework = (
7 pkg: PackageJson,
8 frameworks: typeof FRAMEWORKS,
9): string => {
10 const allDeps = {
11 ...pkg.dependencies,
12 ...pkg.devDependencies,
13 }
14
15 // Map of framework to their actual package names
16 const frameworkPackageMap: Record<string, Array<string>> = {
17 react: ['react', 'react-dom'],
18 vue: ['vue', '@vue/core'],
19 solid: ['solid-js'],
20 svelte: ['svelte'],
21 angular: ['@angular/core'],
22 }
23
24 // Check for actual framework packages
25 for (const framework of frameworks) {
26 const frameworkPackages = frameworkPackageMap[framework]
27 if (frameworkPackages && frameworkPackages.some((pkg) => allDeps[pkg])) {
28 return framework
29 }
30 }
31
32 return 'unknown'
33}
34
35export const isPluginRegistered = (
36 registeredPlugins: Set<string>,

Callers 3

getFilteredSectionsFunction · 0.90
updatePluginCardsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected