use crate::plugins::registry::FrameworkDetector;
pub struct NextJsDetector;
impl NextJsDetector {
pub fn new() -> Self {
Self
}
}
impl Default for NextJsDetector {
fn default() -> Self {
Self::new()
}
}
impl FrameworkDetector for NextJsDetector {
fn name(&self) -> &'static str {
"nextjs"
}
fn get_entry_patterns(&self) -> Vec<String> {
vec![
"pages/**/*.tsx".to_string(),
"pages/**/*.ts".to_string(),
"pages/**/*.jsx".to_string(),
"pages/**/*.js".to_string(),
"src/pages/**/*.tsx".to_string(),
"src/pages/**/*.ts".to_string(),
"src/pages/**/*.jsx".to_string(),
"src/pages/**/*.js".to_string(),
"app/**/page.tsx".to_string(),
"app/**/page.ts".to_string(),
"app/**/page.jsx".to_string(),
"app/**/page.js".to_string(),
"app/**/layout.tsx".to_string(),
"app/**/layout.ts".to_string(),
"app/**/layout.jsx".to_string(),
"app/**/layout.js".to_string(),
"app/**/loading.tsx".to_string(),
"app/**/error.tsx".to_string(),
"app/**/not-found.tsx".to_string(),
"app/**/route.ts".to_string(),
"src/app/**/page.tsx".to_string(),
"src/app/**/page.ts".to_string(),
"src/app/**/layout.tsx".to_string(),
"src/app/**/route.ts".to_string(),
"pages/api/**/*.ts".to_string(),
"pages/api/**/*.js".to_string(),
"src/pages/api/**/*.ts".to_string(),
"app/api/**/route.ts".to_string(),
"src/app/api/**/route.ts".to_string(),
"next.config.js".to_string(),
"next.config.mjs".to_string(),
"next.config.ts".to_string(),
"middleware.ts".to_string(),
"middleware.js".to_string(),
"src/middleware.ts".to_string(),
]
}
fn get_special_exports(&self) -> Vec<&'static str> {
vec![
"getServerSideProps",
"getStaticProps",
"getStaticPaths",
"getInitialProps",
"generateMetadata",
"generateStaticParams",
"generateViewport",
"generateImageMetadata",
"GET",
"POST",
"PUT",
"DELETE",
"PATCH",
"HEAD",
"OPTIONS",
"config",
"runtime",
"preferredRegion",
"revalidate",
"dynamic",
"dynamicParams",
"fetchCache",
"middleware",
"matcher",
"default",
]
}
fn detect_from_dependencies(&self, deps: &[String]) -> bool {
deps.iter().any(|d| d == "next")
}
}