|
| 1 | +import type { HookName } from "../types/detection.js"; |
| 2 | + |
| 3 | +/** Segment used to identify node_modules paths in require.cache keys. */ |
| 4 | +export const NODE_MODULES_SEGMENT = "/node_modules/"; |
| 5 | + |
| 6 | +/** Hooks installed during Brakit setup. */ |
| 7 | +export const INSTALLED_HOOKS: readonly HookName[] = ["fetch", "console", "error"]; |
| 8 | + |
| 9 | +/** |
| 10 | + * Known public package names for stack detection. |
| 11 | + * Matched against package.json dependencies and require.cache at runtime. |
| 12 | + * Only public npm package names — no versions, paths, or private scopes. |
| 13 | + */ |
| 14 | +export const KNOWN_DEPENDENCY_NAMES = [ |
| 15 | + // -- Frameworks (meta) -- |
| 16 | + "next", "@remix-run/dev", "nuxt", "astro", |
| 17 | + // -- Frameworks (backend) -- |
| 18 | + "@nestjs/core", "@adonisjs/core", "sails", |
| 19 | + "express", "fastify", "hono", "koa", "@hapi/hapi", |
| 20 | + "elysia", "h3", "nitro", "@trpc/server", |
| 21 | + // -- Bundlers -- |
| 22 | + "vite", |
| 23 | + // -- ORM / query builders -- |
| 24 | + "prisma", "@prisma/client", "drizzle-orm", "typeorm", "sequelize", |
| 25 | + "mongoose", "kysely", "knex", "@mikro-orm/core", "objection", |
| 26 | + // -- DB drivers -- |
| 27 | + "pg", "mysql2", "mongodb", "better-sqlite3", |
| 28 | + "@libsql/client", "@planetscale/database", |
| 29 | + "ioredis", "redis", |
| 30 | + // -- Auth -- |
| 31 | + "lucia", "next-auth", "@auth/core", "passport", |
| 32 | + // -- Queues / messaging -- |
| 33 | + "bullmq", "amqplib", "kafkajs", |
| 34 | + // -- Validation -- |
| 35 | + "zod", "joi", "yup", "arktype", "valibot", |
| 36 | + // -- HTTP clients -- |
| 37 | + "axios", "got", "ky", "undici", |
| 38 | + // -- Realtime -- |
| 39 | + "socket.io", "ws", |
| 40 | + // -- CSS / styling -- |
| 41 | + "tailwindcss", |
| 42 | + // -- Testing -- |
| 43 | + "vitest", "jest", "mocha", |
| 44 | + // -- Runtime indicators -- |
| 45 | + "bun-types", "@types/bun", |
| 46 | +] as const; |
| 47 | + |
| 48 | +/** |
| 49 | + * Config file paths → tool labels for stack detection. |
| 50 | + * Detection checks file existence only (existsSync), never reads contents. |
| 51 | + */ |
| 52 | +export const KNOWN_CONFIG_FILES = { |
| 53 | + "next.config.js": "nextjs", |
| 54 | + "next.config.mjs": "nextjs", |
| 55 | + "next.config.ts": "nextjs", |
| 56 | + "nuxt.config.ts": "nuxt", |
| 57 | + "nuxt.config.js": "nuxt", |
| 58 | + "astro.config.mjs": "astro", |
| 59 | + "astro.config.ts": "astro", |
| 60 | + "vite.config.ts": "vite", |
| 61 | + "vite.config.js": "vite", |
| 62 | + "drizzle.config.ts": "drizzle-orm", |
| 63 | + "drizzle.config.js": "drizzle-orm", |
| 64 | + "prisma/schema.prisma": "prisma", |
| 65 | + "knexfile.js": "knex", |
| 66 | + "knexfile.ts": "knex", |
| 67 | + "mikro-orm.config.ts": "@mikro-orm/core", |
| 68 | + "nest-cli.json": "@nestjs/core", |
| 69 | + "tailwind.config.js": "tailwindcss", |
| 70 | + "tailwind.config.ts": "tailwindcss", |
| 71 | +} as const; |
| 72 | + |
| 73 | +/** Pre-built Set for O(1) lookups during require.cache scanning. */ |
| 74 | +export const KNOWN_DEPENDENCY_SET: ReadonlySet<string> = new Set(KNOWN_DEPENDENCY_NAMES); |
0 commit comments