use regex::Regex;
pub struct WebPatterns {
external_patterns: Vec<Regex>,
cache_patterns: Vec<Regex>,
extensions: Vec<String>,
}
impl WebPatterns {
pub fn new() -> Self {
let external_patterns = vec![
Regex::new(r"bower_components").unwrap(),
Regex::new(r"dist/").unwrap(),
Regex::new(r"build/").unwrap(),
Regex::new(r"out/").unwrap(),
Regex::new(r"public/").unwrap(),
Regex::new(r"static/").unwrap(),
Regex::new(r"assets/").unwrap(),
Regex::new(r"\.next/").unwrap(),
Regex::new(r"\.nuxt/").unwrap(),
Regex::new(r"\.output/").unwrap(),
Regex::new(r"\.svelte-kit/").unwrap(),
Regex::new(r"\.astro/").unwrap(),
Regex::new(r"\.docusaurus/").unwrap(),
Regex::new(r"_site/").unwrap(),
Regex::new(r"\.vercel/").unwrap(),
Regex::new(r"\.netlify/").unwrap(),
Regex::new(r"\.firebase/").unwrap(),
Regex::new(r"\.surge/").unwrap(),
Regex::new(r"vendor/").unwrap(),
Regex::new(r"libs/").unwrap(),
Regex::new(r"lib/").unwrap(),
Regex::new(r"\.generated/").unwrap(),
Regex::new(r"generated/").unwrap(),
];
let cache_patterns = vec![
Regex::new(r"\.cache/").unwrap(),
Regex::new(r"\.tmp/").unwrap(),
Regex::new(r"tmp/").unwrap(),
Regex::new(r"temp/").unwrap(),
Regex::new(r"\.sass-cache/").unwrap(),
Regex::new(r"\.postcss-cache/").unwrap(),
Regex::new(r"\.stylelint-cache/").unwrap(),
Regex::new(r"\.parcel-cache/").unwrap(),
Regex::new(r"\.webpack/").unwrap(),
Regex::new(r"\.rollup\.cache/").unwrap(),
Regex::new(r"\.vite/").unwrap(),
Regex::new(r"\.turbo/").unwrap(),
Regex::new(r"\.swc/").unwrap(),
Regex::new(r"\.esbuild/").unwrap(),
Regex::new(r"\.jest/").unwrap(),
Regex::new(r"\.vitest/").unwrap(),
Regex::new(r"\.playwright/").unwrap(),
Regex::new(r"\.cypress/").unwrap(),
Regex::new(r"\.angular/").unwrap(),
Regex::new(r"\.ember-cli/").unwrap(),
Regex::new(r"\.storybook-cache/").unwrap(),
Regex::new(r"\.eslintcache").unwrap(),
Regex::new(r"\.prettiercache").unwrap(),
Regex::new(r"\.stylelintcache").unwrap(),
];
let extensions = vec![
"html".to_string(), "htm".to_string(), "xhtml".to_string(),
"shtml".to_string(), "dhtml".to_string(),
"css".to_string(), "scss".to_string(), "sass".to_string(),
"less".to_string(), "styl".to_string(), "stylus".to_string(),
"vue".to_string(), "svelte".to_string(), "astro".to_string(),
"lit".to_string(), "riot".to_string(),
"ejs".to_string(), "hbs".to_string(), "handlebars".to_string(),
"mustache".to_string(), "pug".to_string(), "jade".to_string(),
"twig".to_string(), "liquid".to_string(), "nunjucks".to_string(),
"webmanifest".to_string(), "webapp".to_string(),
"mjs".to_string(), "cjs".to_string(),
"wasm".to_string(), "wat".to_string(),
"svg".to_string(),
];
Self {
external_patterns,
cache_patterns,
extensions,
}
}
pub fn get_external_patterns(&self) -> &[Regex] {
&self.external_patterns
}
pub fn get_cache_patterns(&self) -> &[Regex] {
&self.cache_patterns
}
pub fn get_extensions(&self) -> &[String] {
&self.extensions
}
pub fn get_script_names() -> Vec<&'static str> {
vec![
"index.html", "index.htm", "default.html", "main.html",
"webpack.config.js", "webpack.config.ts", "webpack.config.mjs",
"rollup.config.js", "rollup.config.ts", "rollup.config.mjs",
"vite.config.js", "vite.config.ts", "vite.config.mjs",
"esbuild.config.js", "esbuild.config.mjs",
"parcel.config.js", "parcel.config.json",
"postcss.config.js", "postcss.config.mjs", "postcss.config.json",
"tailwind.config.js", "tailwind.config.ts", "tailwind.config.mjs",
"unocss.config.js", "unocss.config.ts",
"windicss.config.js", "windicss.config.ts",
".stylelintrc", ".stylelintrc.js", ".stylelintrc.json",
".postcssrc", ".postcssrc.js", ".postcssrc.json",
"browserslist", ".browserslistrc",
"next.config.js", "next.config.mjs", "next.config.ts",
"nuxt.config.js", "nuxt.config.ts",
"gatsby.config.js", "gatsby.config.ts",
"svelte.config.js", "svelte.config.ts",
"astro.config.js", "astro.config.ts", "astro.config.mjs",
"remix.config.js", "remix.config.ts",
"angular.json", ".angular-cli.json",
"ember-cli-build.js",
"jest.config.js", "jest.config.ts", "jest.config.mjs",
"vitest.config.js", "vitest.config.ts", "vitest.config.mjs",
"playwright.config.js", "playwright.config.ts",
"cypress.config.js", "cypress.config.ts",
"karma.conf.js", "karma.conf.ts",
".storybook/main.js", ".storybook/main.ts",
"storybook.config.js", "storybook.config.ts",
"manifest.json", "manifest.webmanifest",
"browserconfig.xml", "site.webmanifest",
"sw.js", "service-worker.js", "workbox-config.js",
"serve.json", "static.json", "now.json", "vercel.json",
"netlify.toml", "_redirects", "_headers",
"web.config", ".htaccess", "robots.txt", "sitemap.xml",
]
}
}