envclinic 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/LICENSE +21 -0
- package/README.md +163 -2
- package/dist/cli/index.js +3348 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.cjs +2249 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +280 -0
- package/dist/index.d.ts +280 -0
- package/dist/index.js +2204 -0
- package/dist/index.js.map +1 -0
- package/package.json +73 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cli/run.ts","../../package.json","../../src/analyzers/duplicates.ts","../../src/analyzers/empty.ts","../../src/analyzers/missing.ts","../../src/core/secrets-detector.ts","../../src/analyzers/security.ts","../../src/analyzers/syntax.ts","../../src/config/defaults.ts","../../src/analyzers/unused.ts","../../src/core/project.ts","../../src/config/loader.ts","../../src/core/files.ts","../../src/frameworks/detector.ts","../../src/config/schema.ts","../../src/core/glob.ts","../../src/core/parser.ts","../../src/core/scanner.ts","../../src/core/validator.ts","../../src/analyzers/validation.ts","../../src/core/gitignore.ts","../../src/core/generator.ts","../../src/core/type-generator.ts","../../src/core/variables.ts","../../src/core/outputs.ts","../../src/core/auditor.ts","../../src/core/writer.ts","../../src/cli/output/github.ts","../../src/cli/output/terminal.ts","../../src/cli/commands/common.ts","../../src/cli/commands/audit.ts","../../src/cli/commands/framework.ts","../../src/cli/commands/generate.ts","../../src/cli/commands/init.ts","../../src/cli/commands/subsets.ts","../../src/cli/commands/types.ts","../../src/cli/io.ts","../../src/cli/index.ts"],"sourcesContent":["import { Command, CommanderError } from \"commander\";\nimport pkg from \"../../package.json\";\nimport { auditCommand } from \"./commands/audit\";\nimport type { CliOptions } from \"./commands/common\";\nimport { frameworkCommand } from \"./commands/framework\";\nimport { generateCommand } from \"./commands/generate\";\nimport { initCommand } from \"./commands/init\";\nimport {\n checkCommand,\n secretsCommand,\n unusedCommand,\n validateCommand,\n} from \"./commands/subsets\";\nimport { typesCommand } from \"./commands/types\";\nimport { processIO, type IO } from \"./io\";\n\n/** Exit codes: 0 = ok, 1 = problems found (or action cancelled), 2 = usage or runtime error. */\nexport const EXIT_OK = 0;\nexport const EXIT_ISSUES = 1;\nexport const EXIT_FAILURE = 2;\n\nfunction collect(value: string, previous: string[]): string[] {\n return [\n ...previous,\n ...value\n .split(\",\")\n .map((part) => part.trim())\n .filter(Boolean),\n ];\n}\n\ntype Handler = (options: CliOptions, io: IO) => Promise<number> | number;\n\n/** Run the CLI with the given arguments (without `node` and the script path). */\nexport async function run(argv: string[], io: IO = processIO): Promise<number> {\n let exitCode = EXIT_OK;\n let wantsJson =\n argv.includes(\"--json\") ||\n argv.some((arg, i) => arg === \"json\" && argv[i - 1] === \"--format\");\n\n const program = new Command();\n program\n .name(\"envclinic\")\n .description(\"Audit, validate and secure environment configurations\")\n .version(pkg.version)\n .option(\"--cwd <dir>\", \"project directory (default: current directory)\")\n .option(\"--config <path>\", \"path to an envclinic config file\")\n .option(\"--json\", \"print machine-readable JSON\")\n .option(\"--format <format>\", \"output format: terminal, json or github\")\n .option(\"--quiet\", \"only print errors and a summary\")\n .option(\"--verbose\", \"print the resolved settings\")\n .option(\"--no-color\", \"disable colored output\")\n .exitOverride()\n .configureOutput({\n writeOut: (text) => io.out(text),\n writeErr: (text) => io.err(text),\n });\n\n const register = (command: Command, handler: Handler): Command =>\n command\n .allowExcessArguments(false)\n .action(async (_options: unknown, self: Command) => {\n const all = self.optsWithGlobals<CliOptions>();\n wantsJson = Boolean(all.json) || all.format === \"json\";\n exitCode = await handler(all, io);\n });\n\n const strict = (c: Command) =>\n c.option(\"--strict\", \"treat warnings as errors\");\n const ci = (c: Command) =>\n c.option(\n \"--ci\",\n \"non-interactive mode: no colors, GitHub annotations when running in Actions\",\n );\n const files = (c: Command) =>\n c.option(\n \"-f, --file <path>\",\n \"env file to audit; repeatable (default: .env)\",\n collect,\n [] as string[],\n );\n const ignore = (c: Command) =>\n c.option(\n \"--ignore <names>\",\n \"variable names to ignore, comma-separated; repeatable\",\n collect,\n [] as string[],\n );\n const processEnv = (c: Command) =>\n c.option(\n \"--process-env\",\n \"also validate the real process environment (it wins over env files)\",\n );\n\n register(\n processEnv(\n ignore(\n files(\n ci(\n strict(\n program\n .command(\"audit\", { isDefault: true })\n .description(\"Run the complete environment audit\")\n .option(\n \"--example <path>\",\n \"example file to compare against (default: .env.example or .env.sample)\",\n )\n .option(\n \"--no-scan\",\n \"do not scan source code (skips unused variables and hardcoded credentials)\",\n )\n .option(\n \"--fix\",\n \"add undocumented variables to the example file (asks for confirmation)\",\n )\n .option(\n \"--dry-run\",\n \"with --fix: show what would change without writing\",\n )\n .option(\"--yes\", \"with --fix: apply without asking\"),\n ),\n ),\n ),\n ),\n ),\n auditCommand,\n );\n\n register(\n processEnv(\n ignore(\n files(\n ci(\n strict(\n program\n .command(\"check\")\n .description(\n \"Check for missing, empty, duplicate and invalid variables, and validate the schema\",\n )\n .option(\"--example <path>\", \"example file to compare against\"),\n ),\n ),\n ),\n ),\n ),\n checkCommand,\n );\n\n register(\n ignore(\n ci(\n strict(\n program\n .command(\"secrets\")\n .description(\"Detect potentially exposed secrets and weak secrets\")\n .option(\"--env-only\", \"only check env files, not source code\"),\n ),\n ),\n ),\n secretsCommand,\n );\n\n register(\n ignore(\n ci(\n strict(\n program\n .command(\"unused\")\n .description(\"Detect potentially unused and undeclared variables\")\n .option(\n \"--dir <path>\",\n \"directory to scan; repeatable (default: project root)\",\n collect,\n [] as string[],\n ),\n ),\n ),\n ),\n unusedCommand,\n );\n\n register(\n processEnv(\n files(\n ci(\n strict(\n program\n .command(\"validate\")\n .description(\n \"Validate environment values against the schema in your config\",\n ),\n ),\n ),\n ),\n ),\n validateCommand,\n );\n\n register(\n program\n .command(\"generate\")\n .description(\"Generate or update .env.example (names only, never values)\")\n .option(\"-o, --output <path>\", \"file to write (default: .env.example)\")\n .option(\"--dry-run\", \"print the result without writing\")\n .option(\"--force\", \"replace the file if it exists\")\n .option(\"--merge\", \"add missing variables to the file if it exists\")\n .option(\n \"--exclude <names>\",\n \"variables to leave out, comma-separated; repeatable\",\n collect,\n [] as string[],\n )\n .option(\"--no-scan\", \"do not detect variables from source code\"),\n generateCommand,\n );\n\n register(\n program\n .command(\"types\")\n .description(\"Generate TypeScript declarations for environment variables\")\n .option(\"-o, --output <path>\", \"file to write (default: env.d.ts)\")\n .option(\"--dry-run\", \"print the result without writing\")\n .option(\"--force\", \"overwrite a file that was not generated by envclinic\")\n .option(\n \"--check\",\n \"exit with code 1 if the file is missing or out of date, without writing\",\n )\n .option(\"--no-scan\", \"do not detect variables from source code\"),\n typesCommand,\n );\n\n register(\n program\n .command(\"framework\")\n .description(\"Detect the framework and its environment conventions\"),\n frameworkCommand,\n );\n\n register(\n program\n .command(\"init\")\n .description(\"Create an envclinic config file\")\n .option(\"--yes\", \"accept the defaults without asking questions\")\n .option(\"--force\", \"replace an existing config file\")\n .option(\n \"--config-format <format>\",\n \"config file format: json or mjs\",\n \"json\",\n ),\n initCommand,\n );\n\n try {\n await program.parseAsync(argv, { from: \"user\" });\n return exitCode;\n } catch (error) {\n if (error instanceof CommanderError) {\n const informational =\n error.code === \"commander.helpDisplayed\" ||\n error.code === \"commander.version\" ||\n error.code === \"commander.help\";\n return informational ? EXIT_OK : EXIT_FAILURE;\n }\n const message = error instanceof Error ? error.message : \"Unexpected error\";\n if (wantsJson) {\n io.out(\n JSON.stringify({ success: false, error: message }, null, 2) + \"\\n\",\n );\n } else {\n io.err(`envclinic: ${message}\\n`);\n }\n return EXIT_FAILURE;\n }\n}\n","{\n \"name\": \"envclinic\",\n \"version\": \"0.1.0\",\n \"description\": \"Audit, validate and secure environment configurations\",\n \"keywords\": [\n \"env\",\n \"dotenv\",\n \"environment\",\n \"audit\",\n \"cli\",\n \"validation\",\n \"secrets\"\n ],\n \"license\": \"MIT\",\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"import\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/index.d.cts\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"./package.json\": \"./package.json\"\n },\n \"bin\": {\n \"envclinic\": \"./dist/cli/index.js\"\n },\n \"files\": [\n \"dist\",\n \"README.md\",\n \"LICENSE\",\n \"CHANGELOG.md\"\n ],\n \"engines\": {\n \"node\": \">=18\"\n },\n \"scripts\": {\n \"clean\": \"node -e \\\"require('node:fs').rmSync('dist',{recursive:true,force:true})\\\"\",\n \"build\": \"npm run clean && tsup\",\n \"dev\": \"tsup --watch\",\n \"test\": \"vitest run\",\n \"typecheck\": \"tsc --noEmit\",\n \"prepublishOnly\": \"npm run build && npm run test && npm run typecheck\",\n \"changeset\": \"changeset\",\n \"version\": \"changeset version\",\n \"release\": \"npm run build && changeset publish\"\n },\n \"dependencies\": {\n \"commander\": \"^12.1.0\",\n \"fast-glob\": \"^3.3.2\",\n \"picocolors\": \"^1.1.0\"\n },\n \"devDependencies\": {\n \"@changesets/cli\": \"^3.0.3\",\n \"@types/node\": \"^22.0.0\",\n \"tsup\": \"^8.3.0\",\n \"typescript\": \"^5.6.0\",\n \"vitest\": \"^2.1.0\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"sideEffects\": false,\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/reda-trouki/envclinic.git\"\n }\n}\n","import type { EnvEntry } from \"../core/parser\";\nimport type { RawIssue } from \"../types\";\n\n/** Report variables declared more than once in the same file. */\nexport function findDuplicates(file: string, entries: EnvEntry[]): RawIssue[] {\n const lines = new Map<string, number[]>();\n for (const entry of entries) {\n const existing = lines.get(entry.key);\n if (existing) existing.push(entry.line);\n else lines.set(entry.key, [entry.line]);\n }\n\n const issues: RawIssue[] = [];\n for (const [variable, where] of [...lines].sort(([a], [b]) => a.localeCompare(b))) {\n if (where.length < 2) continue;\n issues.push({\n code: \"duplicate-variable\",\n rule: \"duplicates\",\n file,\n variable,\n line: where[0],\n message: `${variable} is declared ${where.length} times in ${file} (lines ${where.join(\", \")})`,\n recommendation: `Keep a single declaration of ${variable}. Environment loaders disagree about which duplicate wins.`,\n });\n }\n return issues;\n}\n","import type { EnvEntry } from \"../core/parser\";\nimport type { RawIssue } from \"../types\";\n\n/** Variables declared with an empty value. Duplicated keys are reported once. */\nexport function findEmpty(file: string, entries: EnvEntry[]): RawIssue[] {\n const seen = new Set<string>();\n const issues: RawIssue[] = [];\n\n for (const entry of entries) {\n if (entry.value !== \"\" || seen.has(entry.key)) continue;\n seen.add(entry.key);\n issues.push({\n code: \"empty-variable\",\n rule: \"empty\",\n file,\n variable: entry.key,\n line: entry.line,\n message: `${entry.key} has an empty value in ${file}`,\n recommendation: `Set a value for ${entry.key}, or remove it if it is not needed.`,\n });\n }\n return issues;\n}\n","import type { RawIssue } from \"../types\";\n\nfunction sorted(keys: Iterable<string>): string[] {\n return [...keys].sort((a, b) => a.localeCompare(b));\n}\n\n/** Variables documented in the example file but absent from a source file. */\nexport function findMissing(\n exampleFile: string,\n exampleKeys: Set<string>,\n sourceFile: string,\n sourceKeys: Set<string>,\n): RawIssue[] {\n return sorted(exampleKeys)\n .filter((key) => !sourceKeys.has(key))\n .map((variable) => ({\n code: \"missing-variable\",\n rule: \"missing\" as const,\n file: sourceFile,\n variable,\n message: `${variable} is declared in ${exampleFile} but missing from ${sourceFile}`,\n recommendation: `Add ${variable} to ${sourceFile}, or remove it from ${exampleFile} if it is no longer needed.`,\n }));\n}\n\n/** Variables set in a source file but not documented in the example file. */\nexport function findUndocumented(\n exampleFile: string,\n exampleKeys: Set<string>,\n sourceFile: string,\n sourceKeys: Set<string>,\n): RawIssue[] {\n return sorted(sourceKeys)\n .filter((key) => !exampleKeys.has(key))\n .map((variable) => ({\n code: \"undocumented-variable\",\n rule: \"undocumented\" as const,\n file: sourceFile,\n variable,\n message: `${variable} is set in ${sourceFile} but not documented in ${exampleFile}`,\n recommendation: `Add ${variable}= (without a value) to ${exampleFile} so other developers know it exists.`,\n }));\n}\n","import type { CustomSecretPattern } from \"../types\";\n\nexport interface SecretPattern {\n id: string;\n description: string;\n pattern: RegExp;\n /** Natural severity of a match before rule levels and file context are applied. */\n severity: \"error\" | \"warning\";\n /** Only match values of variables whose name matches (env files only). */\n name?: RegExp;\n /** Env files only: never applied to source code. */\n envOnly?: boolean;\n}\n\nexport const BUILTIN_PATTERNS: SecretPattern[] = [\n {\n id: \"aws-access-key-id\",\n description: \"AWS access key ID\",\n pattern: /\\b(?:AKIA|ASIA|ABIA|ACCA)[0-9A-Z]{16}\\b/,\n severity: \"error\",\n },\n {\n id: \"aws-secret-access-key\",\n description: \"AWS secret access key\",\n pattern: /^[A-Za-z0-9/+=]{40}$/,\n name: /AWS_SECRET_ACCESS_KEY|AWS_SECRET_KEY/i,\n envOnly: true,\n severity: \"error\",\n },\n {\n id: \"github-token\",\n description: \"GitHub token\",\n pattern: /\\bgh[pousr]_[A-Za-z0-9]{36,255}\\b/,\n severity: \"error\",\n },\n {\n id: \"github-fine-grained-token\",\n description: \"GitHub fine-grained token\",\n pattern: /\\bgithub_pat_[A-Za-z0-9_]{22,255}\\b/,\n severity: \"error\",\n },\n {\n id: \"slack-token\",\n description: \"Slack token\",\n pattern: /\\bxox[abprs]-[A-Za-z0-9-]{10,}\\b/,\n severity: \"error\",\n },\n {\n id: \"stripe-secret-key\",\n description: \"Stripe secret key\",\n pattern: /\\b(?:sk|rk)_live_[0-9a-zA-Z]{16,}\\b/,\n severity: \"error\",\n },\n {\n id: \"google-api-key\",\n description: \"Google API key\",\n pattern: /\\bAIza[0-9A-Za-z_-]{35}\\b/,\n severity: \"error\",\n },\n {\n id: \"private-key\",\n description: \"private key\",\n pattern: /-----BEGIN (?:[A-Z0-9]+ )*PRIVATE KEY(?: BLOCK)?-----/,\n severity: \"error\",\n },\n {\n id: \"sendgrid-api-key\",\n description: \"SendGrid API key\",\n pattern: /\\bSG\\.[A-Za-z0-9_-]{16,}\\.[A-Za-z0-9_-]{16,}\\b/,\n severity: \"error\",\n },\n {\n id: \"npm-token\",\n description: \"npm access token\",\n pattern: /\\bnpm_[A-Za-z0-9]{36}\\b/,\n severity: \"error\",\n },\n {\n id: \"anthropic-api-key\",\n description: \"Anthropic API key\",\n pattern: /\\bsk-ant-[A-Za-z0-9_-]{20,}\\b/,\n severity: \"error\",\n },\n {\n id: \"openai-api-key\",\n description: \"OpenAI API key\",\n pattern: /\\bsk-(?:proj-)?[A-Za-z0-9_-]{40,}\\b/,\n severity: \"error\",\n },\n {\n id: \"twilio-api-key\",\n description: \"Twilio API key\",\n pattern: /\\bSK[0-9a-f]{32}\\b/,\n severity: \"error\",\n },\n {\n id: \"json-web-token\",\n description: \"JSON Web Token\",\n pattern:\n /\\beyJ[A-Za-z0-9_-]{10,}\\.eyJ[A-Za-z0-9_-]{10,}\\.[A-Za-z0-9_-]{10,}\\b/,\n severity: \"warning\",\n },\n {\n id: \"credentialed-url\",\n description: \"URL with embedded credentials\",\n pattern:\n /\\b[a-z][a-z0-9+.-]*:\\/\\/[^\\s:@/'\"`<>]+:([^\\s@/'\"`<>]+)@[^\\s'\"`<>]+/i,\n severity: \"warning\",\n },\n];\n\n/** Compile user-defined patterns. Invalid expressions are rejected by config validation. */\nexport function buildPatterns(\n custom: readonly CustomSecretPattern[] = [],\n): SecretPattern[] {\n return [\n ...BUILTIN_PATTERNS,\n ...custom.map(\n (entry): SecretPattern => ({\n id: entry.id,\n description: entry.description ?? entry.id,\n pattern: new RegExp(entry.pattern),\n severity: entry.severity ?? \"error\",\n }),\n ),\n ];\n}\n\nconst URL_PASSWORD_PLACEHOLDER =\n /^(?:pass(?:word)?|pwd|secret|changeme|change[-_]?me|example|xxx+|\\*+|\\.\\.\\.|<.*>|\\$\\{.*\\}|\\{\\{.*\\}\\}|%.*%|your[-_ ].*|password\\d*|postgres|root|admin|test|user|db|mysql)$/i;\n\n/** True when a credentialed URL's password is clearly a placeholder. */\nfunction isPlaceholderUrlPassword(value: string, pattern: RegExp): boolean {\n const match = pattern.exec(value);\n const password = match?.[1];\n return password === undefined || URL_PASSWORD_PLACEHOLDER.test(password);\n}\n\n/** Find the first pattern that matches an env variable's value. */\nexport function findValueMatch(\n value: string,\n name: string,\n patterns: readonly SecretPattern[],\n): SecretPattern | undefined {\n for (const pattern of patterns) {\n if (pattern.name !== undefined && !pattern.name.test(name)) continue;\n if (!pattern.pattern.test(value)) continue;\n if (\n pattern.id === \"credentialed-url\" &&\n isPlaceholderUrlPassword(value, pattern.pattern)\n )\n continue;\n return pattern;\n }\n return undefined;\n}\n\nexport interface TextMatch {\n pattern: SecretPattern;\n line: number;\n}\n\nconst MAX_LINE_LENGTH = 10_000;\nconst SUPPRESS_COMMENT = \"envclinic-ignore\";\n\n/**\n * Find credentials in source text. Only patterns that are meaningful without\n * a variable name are used. Matches are reported by line only; the matched\n * text is never returned. A line containing `envclinic-ignore` is skipped.\n */\nexport function scanTextForSecrets(\n content: string,\n patterns: readonly SecretPattern[],\n): TextMatch[] {\n const usable = patterns.filter(\n (pattern) => !pattern.envOnly && pattern.name === undefined,\n );\n const matches: TextMatch[] = [];\n const lines = content.split(\"\\n\");\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i] as string;\n if (line.length > MAX_LINE_LENGTH || line.includes(SUPPRESS_COMMENT))\n continue;\n for (const pattern of usable) {\n if (!pattern.pattern.test(line)) continue;\n if (\n pattern.id === \"credentialed-url\" &&\n isPlaceholderUrlPassword(line, pattern.pattern)\n )\n continue;\n matches.push({ pattern, line: i + 1 });\n }\n }\n return matches;\n}\n\n// --- Name and value heuristics ----------------------------------------------\n\nconst SECRET_NAME =\n /(?:^|_)(?:SECRET|PASSWORD|PASSWD|PASSPHRASE|TOKEN|PRIVATE_KEY|API_KEY|APIKEY|ACCESS_KEY|SECRET_KEY|SIGNING_KEY|ENCRYPTION_KEY|AUTH_KEY|CREDENTIALS?)(?:_|$)/i;\nconst NOT_A_SECRET_SUFFIX =\n /_(?:URL|URI|PATH|FILE|DIR|ENABLED|ENDPOINT|HEADER|TTL|EXPIRES|EXPIRES_IN|EXPIRY|ALGORITHM|TYPE|NAME|ID|LENGTH|ROUNDS|COST|PREFIX|FORMAT|REGION|HOST|PORT)$/i;\nconst PUBLIC_NAME = /PUBLIC|PUBLISHABLE/i;\n\n/** Does the variable name suggest a secret value? */\nexport function isSecretName(name: string): boolean {\n return (\n SECRET_NAME.test(name) &&\n !NOT_A_SECRET_SUFFIX.test(name) &&\n !PUBLIC_NAME.test(name)\n );\n}\n\nconst PLACEHOLDER_EXACT =\n /^(?:secret|password|passwd|pass|admin|root|test|testing|changeme|change[-_ ]?me|default|example|token|key|none|null|undefined|todo|xxx+|\\*+|1234\\d*|abc\\d*|qwerty|letmein|postgres|mysql|redis|dev|development)$/i;\nconst PLACEHOLDER_CONTAINS =\n /(?:change[-_ ]?me|your[-_ ]?(?:secret|key|token|password|api)|<[^>]+>|placeholder|replace[-_ ]?(?:me|this)|xxxxxx|dummy|\\.\\.\\.)/i;\nconst BOOLEANISH = /^(?:true|false|yes|no|on|off)$/i;\nconst REFERENCE = /^\\$\\{.*\\}$|^\\$[A-Za-z_]\\w*$/;\n\nexport function isPlaceholder(value: string): boolean {\n return PLACEHOLDER_EXACT.test(value) || PLACEHOLDER_CONTAINS.test(value);\n}\n\nexport function isReferenceOrFlag(value: string): boolean {\n return REFERENCE.test(value) || BOOLEANISH.test(value);\n}\n\n/** Shannon entropy in bits per character. */\nexport function shannonEntropy(value: string): number {\n if (value.length === 0) return 0;\n const counts = new Map<string, number>();\n for (const char of value) counts.set(char, (counts.get(char) ?? 0) + 1);\n let entropy = 0;\n for (const count of counts.values()) {\n const p = count / value.length;\n entropy -= p * Math.log2(p);\n }\n return entropy;\n}\n\nexport const MIN_SECRET_LENGTH = 12;\nexport const MIN_SECRET_ENTROPY = 3;\n\n/** Why a value is a weak secret, or undefined when it is acceptable. */\nexport function weakSecretReason(value: string): string | undefined {\n if (value === \"\" || isReferenceOrFlag(value)) return undefined;\n if (isPlaceholder(value)) return \"looks like a placeholder or common default\";\n if (value.length < MIN_SECRET_LENGTH)\n return `shorter than ${MIN_SECRET_LENGTH} characters`;\n if (shannonEntropy(value) < MIN_SECRET_ENTROPY) return \"low entropy\";\n return undefined;\n}\n","import type { EnvFileData } from \"../core/project\";\nimport {\n findValueMatch,\n isPlaceholder,\n isReferenceOrFlag,\n isSecretName,\n scanTextForSecrets,\n weakSecretReason,\n type SecretPattern,\n} from \"../core/secrets-detector\";\nimport type { GitStatus } from \"../core/gitignore\";\nimport type { RawIssue } from \"../types\";\n\nexport interface SecurityOptions {\n patterns: SecretPattern[];\n /** Variables exempt from secret checks. */\n isAllowed: (name: string) => boolean;\n /** Variables exempt from all checks (ignore.variables). */\n isIgnored: (name: string) => boolean;\n publicPrefixes: string[];\n}\n\nconst PUBLIC_SECRET_NAME = /SECRET|PASSWORD|PASSWD|PRIVATE/i;\nconst ROTATE =\n \"Remove it, store the value outside version control, and rotate it if it may ever have been committed or shared.\";\n\n/**\n * Check one env file for exposed or weak credentials.\n *\n * Findings carry only the variable name, file and line. The value is read to\n * classify it but is never copied into an issue.\n */\nexport function analyzeEnvFileSecrets(\n file: EnvFileData,\n git: GitStatus,\n options: SecurityOptions,\n): RawIssue[] {\n const issues: RawIssue[] = [];\n const example = file.role === \"example\";\n const reportedPublic = new Set<string>();\n\n for (const entry of file.entries) {\n const name = entry.key;\n if (options.isIgnored(name) || options.isAllowed(name)) continue;\n\n const prefix = options.publicPrefixes.find((candidate) =>\n name.startsWith(candidate),\n );\n const match =\n entry.value === \"\"\n ? undefined\n : findValueMatch(entry.value, name, options.patterns);\n\n if (prefix !== undefined && !reportedPublic.has(name)) {\n const nameLooksSecret = PUBLIC_SECRET_NAME.test(\n name.slice(prefix.length),\n );\n if (match !== undefined || nameLooksSecret) {\n reportedPublic.add(name);\n issues.push({\n code: \"public-secret\",\n rule: \"secrets\",\n severity: match !== undefined ? \"error\" : \"warning\",\n file: file.path,\n line: entry.line,\n variable: name,\n message: `${name} looks like a secret but its ${prefix} prefix exposes it to the browser bundle`,\n recommendation: `Rename it without the ${prefix} prefix and read it only on the server, or confirm that it is meant to be public.`,\n });\n }\n }\n\n if (entry.value === \"\") continue;\n\n if (match !== undefined) {\n const severity: \"error\" | \"warning\" | \"info\" =\n example || git === \"not-ignored\"\n ? match.severity\n : git === \"ignored\"\n ? \"info\"\n : match.severity === \"error\"\n ? \"warning\"\n : \"info\";\n const where = example\n ? \"in a template file that is normally committed\"\n : git === \"ignored\"\n ? \"in a git-ignored local file\"\n : git === \"not-ignored\"\n ? \"in a file that is not git-ignored\"\n : \"in an environment file\";\n issues.push({\n code: \"exposed-credential\",\n rule: \"secrets\",\n severity,\n file: file.path,\n line: entry.line,\n variable: name,\n message: `Potential exposed credential (${match.description}) ${where}`,\n recommendation: example\n ? `Replace it with an empty value. ${ROTATE}`\n : git === \"ignored\"\n ? \"Expected for local development. Make sure this file is never committed.\"\n : ROTATE,\n });\n continue;\n }\n\n if (example) {\n if (\n isSecretName(name) &&\n !isPlaceholder(entry.value) &&\n !isReferenceOrFlag(entry.value) &&\n entry.value.length >= 8\n ) {\n issues.push({\n code: \"secret-in-example\",\n rule: \"secrets\",\n severity: \"warning\",\n file: file.path,\n line: entry.line,\n variable: name,\n message: `${name} has a value in a template file that is normally committed`,\n recommendation:\n \"Template files should list names only. Replace the value with an empty one or an obvious placeholder.\",\n });\n }\n continue;\n }\n\n if (isSecretName(name)) {\n const reason = weakSecretReason(entry.value);\n if (reason !== undefined) {\n issues.push({\n code: \"weak-secret\",\n rule: \"weak\",\n severity: \"warning\",\n file: file.path,\n line: entry.line,\n variable: name,\n message: `Weak secret (${reason})`,\n recommendation: `Use a long random value, for example from \\`openssl rand -base64 32\\`.`,\n });\n }\n }\n }\n\n const hasValues = file.entries.some(\n (entry) => entry.value !== \"\" && !options.isIgnored(entry.key),\n );\n if (!example && git === \"not-ignored\" && hasValues) {\n issues.push({\n code: \"env-file-not-ignored\",\n rule: \"secrets\",\n severity: \"error\",\n file: file.path,\n message: `${file.path} contains values but is not listed in .gitignore, so it may be committed`,\n recommendation: `Add ${file.path} to .gitignore. If it was already committed, rotate its secrets and remove it from history.`,\n });\n }\n return issues;\n}\n\n/** Check one source file's text for hardcoded credentials. */\nexport function analyzeCodeSecrets(\n file: string,\n content: string,\n patterns: SecretPattern[],\n): RawIssue[] {\n const seen = new Set<string>();\n const issues: RawIssue[] = [];\n for (const match of scanTextForSecrets(content, patterns)) {\n const key = `${match.line}:${match.pattern.id}`;\n if (seen.has(key)) continue;\n seen.add(key);\n issues.push({\n code: \"exposed-credential\",\n rule: \"secrets\",\n severity: match.pattern.severity,\n file,\n line: match.line,\n message: `Potential exposed credential (${match.pattern.description}) in source code`,\n recommendation:\n \"Load it from an environment variable instead, and rotate it if it was ever committed. If this is a false positive, add `envclinic-ignore` to the line or the file to secrets.ignoreFiles.\",\n });\n }\n return issues;\n}\n","import type { ParsedEnv } from \"../core/parser\";\nimport type { RawIssue } from \"../types\";\n\nconst VALID_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\nexport function isValidName(key: string): boolean {\n return VALID_NAME.test(key);\n}\n\n/**\n * Report syntax problems and invalid variable names.\n *\n * Neither the offending line nor the invalid name is included in the issue:\n * a pasted key body or certificate line can parse as a \"variable name\", so\n * only the line number is reported.\n */\nexport function findSyntaxIssues(file: string, parsed: ParsedEnv): RawIssue[] {\n const issues: RawIssue[] = [];\n\n for (const problem of parsed.problems) {\n if (problem.kind === \"malformed-line\") {\n issues.push({\n code: \"malformed-line\",\n rule: \"syntax\",\n file,\n line: problem.line,\n message: `Line ${problem.line} of ${file} is not a valid KEY=value declaration`,\n recommendation: \"Use KEY=value, or start the line with # to make it a comment.\",\n });\n } else {\n issues.push({\n code: \"unterminated-quote\",\n rule: \"syntax\",\n file,\n line: problem.line,\n message: `Line ${problem.line} of ${file} has a quoted value that is never closed`,\n recommendation: \"Add the closing quote.\",\n });\n }\n }\n\n for (const entry of parsed.entries) {\n if (!isValidName(entry.key)) {\n issues.push({\n code: \"invalid-variable-name\",\n rule: \"names\",\n file,\n line: entry.line,\n message: `Line ${entry.line} of ${file} has an invalid variable name`,\n recommendation:\n \"Use only letters, digits and underscores, and do not start with a digit (for example MY_VARIABLE).\",\n });\n }\n }\n\n return issues.sort((a, b) => (a.line ?? 0) - (b.line ?? 0));\n}\n","import type { RuleLevel, RuleName } from \"../types\";\n\nexport const DEFAULT_SOURCE_FILES = [\".env\"];\n\nexport const EXAMPLE_FILE_CANDIDATES = [\".env.example\", \".env.sample\"];\n\nexport const DEFAULT_RULES: Record<RuleName, RuleLevel> = {\n missing: \"error\",\n undocumented: \"warning\",\n empty: \"warning\",\n duplicates: \"error\",\n names: \"warning\",\n syntax: \"warning\",\n unused: \"warning\",\n undeclared: \"warning\",\n secrets: \"error\",\n weak: \"warning\",\n validation: \"error\",\n types: \"warning\",\n};\n\nexport const DEFAULT_TYPES_OUTPUT = \"env.d.ts\";\nexport const DEFAULT_EXAMPLE_OUTPUT = \".env.example\";\n\n/**\n * Variables provided by the platform or tooling rather than the project.\n * They are never reported as undeclared and are not generated from code\n * references alone.\n */\nexport const BUILTIN_VARIABLES = new Set([\n \"NODE_ENV\", \"CI\", \"HOME\", \"PATH\", \"PWD\", \"USER\", \"SHELL\", \"TERM\", \"TZ\", \"LANG\", \"TMPDIR\",\n \"NEXT_RUNTIME\", \"MODE\", \"BASE_URL\", \"PROD\", \"DEV\", \"SSR\",\n]);\n\nexport function isBuiltinVariable(name: string): boolean {\n return BUILTIN_VARIABLES.has(name) || name.startsWith(\"npm_\") || name.startsWith(\"VERCEL_\");\n}\n","import { isBuiltinVariable } from \"../config/defaults\";\nimport type { ProjectContext } from \"../core/project\";\nimport type { SourceLocation } from \"../core/scanner\";\nimport type { RawIssue } from \"../types\";\n\nexport interface UsageData {\n filesScanned: number;\n /** Variables read with a literal name, with where. */\n references: Map<string, SourceLocation[]>;\n /** Places where the variable name could not be determined statically. */\n dynamic: SourceLocation[];\n}\n\nconst INTERPOLATION = /\\$\\{([A-Za-z_]\\w*)\\}/g;\n\n/** Variables referenced by other variables' values (`${NAME}` interpolation). */\nfunction interpolatedNames(project: ProjectContext): Set<string> {\n const used = new Set<string>();\n const files = project.example ? [...project.sourceFiles, project.example] : project.sourceFiles;\n for (const file of files) {\n for (const entry of file.entries) {\n if (entry.quote === \"single\") continue;\n for (const match of entry.value.matchAll(INTERPOLATION)) used.add(match[1] as string);\n }\n }\n return used;\n}\n\n/**\n * Variables declared in env files that no scanned source file reads.\n *\n * This is static analysis, so results are reported as \"potentially unused\":\n * dynamic access, aliases, framework conventions and tools outside the\n * scanned directories can all read variables this scan cannot see.\n * Nothing is ever deleted.\n */\nexport function findUnused(project: ProjectContext, usage: UsageData): RawIssue[] {\n if (usage.filesScanned === 0) return []; // nothing was scanned, so nothing can be concluded\n\n const used = interpolatedNames(project);\n const declared = new Map<string, string>(); // variable -> file it is declared in\n for (const file of [...project.sourceFiles, ...(project.example ? [project.example] : [])]) {\n for (const key of file.keys) if (!declared.has(key)) declared.set(key, file.path);\n }\n\n const issues: RawIssue[] = [];\n for (const [variable, file] of [...declared].sort(([a], [b]) => a.localeCompare(b))) {\n if (usage.references.has(variable) || used.has(variable) || project.isIgnored(variable)) continue;\n issues.push({\n code: \"unused-variable\",\n rule: \"unused\",\n file,\n variable,\n message: `${variable} is declared in ${file} but was not found in ${usage.filesScanned} scanned source file${usage.filesScanned === 1 ? \"\" : \"s\"} (potentially unused)`,\n recommendation: `Check whether ${variable} is still needed. It may be read dynamically or by a tool outside the scanned code. If it is, add it to ignore.variables.`,\n });\n }\n\n if (issues.length > 0 && usage.dynamic.length > 0) {\n const where = [...new Set(usage.dynamic.map((location) => location.file))];\n issues.push({\n code: \"dynamic-env-access\",\n severity: \"info\",\n message: `${usage.dynamic.length} dynamic environment access${usage.dynamic.length === 1 ? \"\" : \"es\"} found in ${where.length} file${where.length === 1 ? \"\" : \"s\"} (for example ${where[0]}), so some variables reported as unused may still be read`,\n recommendation: \"Review the potentially unused variables before removing anything.\",\n });\n }\n return issues;\n}\n\n/**\n * Variables read in source code that are neither set in an env file nor\n * documented in the example file.\n */\nexport function findUndeclared(project: ProjectContext, usage: UsageData): RawIssue[] {\n const known = new Set<string>();\n for (const file of [...project.sourceFiles, ...(project.example ? [project.example] : [])]) {\n for (const key of file.keys) known.add(key);\n }\n // Without any env file there is no baseline to compare against.\n if (project.sourceFiles.length === 0 && project.example === undefined) return [];\n\n const reference = project.example?.path ?? project.sourceFiles[0]?.path ?? \".env.example\";\n const issues: RawIssue[] = [];\n for (const [variable, locations] of [...usage.references].sort(([a], [b]) => a.localeCompare(b))) {\n if (known.has(variable) || project.isIgnored(variable) || isBuiltinVariable(variable)) continue;\n const first = locations[0] as SourceLocation;\n issues.push({\n code: \"undeclared-variable\",\n rule: \"undeclared\",\n file: first.file,\n line: first.line,\n variable,\n message: `${variable} is used in ${first.file}${locations.length > 1 ? ` (and ${locations.length - 1} more place${locations.length === 2 ? \"\" : \"s\"})` : \"\"} but is not set in any env file or documented in ${reference}`,\n recommendation: `Add ${variable}= to ${reference} so other developers know it is required, or add it to ignore.variables if the platform provides it.`,\n });\n }\n return issues;\n}\n","import path from \"node:path\";\nimport {\n DEFAULT_RULES,\n DEFAULT_SOURCE_FILES,\n EXAMPLE_FILE_CANDIDATES,\n} from \"../config/defaults\";\nimport { loadConfig } from \"../config/loader\";\nimport { validateConfig } from \"../config/schema\";\nimport { detectFramework, type FrameworkInfo } from \"../frameworks/detector\";\nimport type {\n AuditCheck,\n AuditOptions,\n EnvDoctorConfig,\n RawIssue,\n RuleLevel,\n RuleName,\n Schema,\n} from \"../types\";\nimport { displayPath, readEnvFile, type ReadResult } from \"./files\";\nimport { createNameMatcher } from \"./glob\";\nimport { parseEnv, type EnvEntry, type ParsedEnv } from \"./parser\";\nimport { isValidName } from \"../analyzers/syntax\";\nimport { DEFAULT_EXTENSIONS, type ScanOptions } from \"./scanner\";\n\nexport const ALL_CHECKS: AuditCheck[] = [\n \"files\",\n \"unused\",\n \"secrets\",\n \"validation\",\n \"types\",\n];\n\nexport interface EnvFileData {\n /** Display path relative to the project root. */\n path: string;\n absolute: string;\n role: \"source\" | \"example\";\n parsed: ParsedEnv;\n /** Declarations with valid variable names, in file order (duplicates included). */\n entries: EnvEntry[];\n keys: Set<string>;\n}\n\nexport interface ProjectContext {\n cwd: string;\n config: EnvDoctorConfig;\n configFile?: string;\n rules: Record<RuleName, RuleLevel>;\n strict: boolean;\n checks: Set<AuditCheck>;\n isIgnored: (name: string) => boolean;\n framework: FrameworkInfo;\n sourceFiles: EnvFileData[];\n example?: EnvFileData;\n /** Problems found while locating and reading env files. */\n loadIssues: RawIssue[];\n schema?: Schema;\n scanOptions: ScanOptions;\n /** Extra values to validate (process environment or programmatic). */\n env: Record<string, string | undefined>;\n}\n\ninterface LoadedFile {\n shown: string;\n absolute: string;\n result: ReadResult;\n}\n\nasync function load(cwd: string, relative: string): Promise<LoadedFile> {\n const absolute = path.resolve(cwd, relative);\n return {\n shown: displayPath(cwd, absolute),\n absolute,\n result: await readEnvFile(cwd, relative),\n };\n}\n\n/** Report why a file could not be read. Returns true if it was readable. */\nfunction reportUnreadable(file: LoadedFile, issues: RawIssue[]): boolean {\n const { result, shown } = file;\n switch (result.status) {\n case \"ok\":\n if (result.encoding !== \"utf-8\") {\n issues.push({\n code: \"non-utf8-file\",\n rule: \"syntax\",\n severity: \"warning\",\n file: shown,\n message: `${shown} is saved as ${result.encoding.toUpperCase()}, not UTF-8`,\n recommendation:\n \"It was read correctly, but most dotenv loaders expect UTF-8. Re-save it as UTF-8 (in PowerShell: `Set-Content -Encoding utf8 .env`, or use `Out-File -Encoding utf8` instead of `>`).\",\n });\n }\n return true;\n case \"unsafe\":\n issues.push({\n code: \"unsafe-path\",\n severity: \"error\",\n file: shown,\n message: `${shown} was skipped: ${result.reason}`,\n recommendation:\n \"Only files inside the project directory can be audited.\",\n });\n return false;\n case \"too-large\":\n issues.push({\n code: \"file-too-large\",\n severity: \"error\",\n file: shown,\n message: `${shown} was skipped because it is larger than 5 MB`,\n recommendation:\n \"Environment files should be small. Check that this is really an env file.\",\n });\n return false;\n case \"unreadable\":\n issues.push({\n code: \"file-unreadable\",\n severity: \"error\",\n file: shown,\n message: `${shown} could not be read`,\n recommendation: \"Check the file permissions.\",\n });\n return false;\n case \"missing\":\n return false;\n }\n}\n\nfunction toFileData(\n shown: string,\n absolute: string,\n role: \"source\" | \"example\",\n content: string,\n): EnvFileData {\n const parsed = parseEnv(content);\n const entries = parsed.entries.filter((entry) => isValidName(entry.key));\n return {\n path: shown,\n absolute,\n role,\n parsed,\n entries,\n keys: new Set(entries.map((entry) => entry.key)),\n };\n}\n\n/**\n * Locate and read the project's env files, load the config and detect the\n * framework. Nothing is analyzed yet, so generators and analyzers can share\n * the same data.\n */\nexport async function loadProject(\n options: AuditOptions = {},\n): Promise<ProjectContext> {\n const cwd = path.resolve(options.cwd ?? process.cwd());\n\n let config: EnvDoctorConfig;\n let configFile: string | undefined;\n if (options.config !== undefined) {\n config = validateConfig(options.config, \"the config option\");\n } else {\n const loaded = await loadConfig(cwd, options.configPath);\n config = loaded.config;\n configFile = loaded.file;\n }\n\n const rules = { ...DEFAULT_RULES, ...config.rules };\n const isIgnored = createNameMatcher([\n ...(config.ignore?.variables ?? []),\n ...(options.ignore ?? []),\n ]);\n\n const sourceExplicit = options.files !== undefined;\n const sourcePaths =\n options.files ?? config.files?.source ?? DEFAULT_SOURCE_FILES;\n const exampleExplicit = options.example !== undefined;\n const exampleCandidates =\n options.example !== undefined\n ? [options.example]\n : config.files?.example !== undefined\n ? [config.files.example]\n : EXAMPLE_FILE_CANDIDATES;\n\n const loadIssues: RawIssue[] = [];\n const sourceFiles: EnvFileData[] = [];\n\n // --- Example file -------------------------------------------------------\n let example: EnvFileData | undefined;\n let exampleLoaded: LoadedFile | undefined;\n for (const candidate of exampleCandidates) {\n const file = await load(cwd, candidate);\n if (file.result.status !== \"missing\") {\n exampleLoaded = file;\n break;\n }\n }\n\n if (exampleLoaded) {\n if (\n reportUnreadable(exampleLoaded, loadIssues) &&\n exampleLoaded.result.status === \"ok\"\n ) {\n example = toFileData(\n exampleLoaded.shown,\n exampleLoaded.absolute,\n \"example\",\n exampleLoaded.result.content,\n );\n }\n } else {\n const named = exampleExplicit || config.files?.example !== undefined;\n loadIssues.push({\n code: \"example-file-missing\",\n severity: exampleExplicit ? \"error\" : \"warning\",\n message: named\n ? `Example file ${displayPath(cwd, path.resolve(cwd, exampleCandidates[0] as string))} was not found`\n : \"No .env.example or .env.sample file was found\",\n recommendation:\n \"Create one that lists every variable your project needs (names only, never real values) so new developers know what to configure. `envclinic generate` can create it.\",\n });\n }\n\n // --- Source files -------------------------------------------------------\n const seen = new Set<string>(example ? [example.absolute] : []);\n for (const relative of sourcePaths) {\n const absolute = path.resolve(cwd, relative);\n if (seen.has(absolute)) continue;\n seen.add(absolute);\n\n const file = await load(cwd, relative);\n if (file.result.status === \"missing\") {\n loadIssues.push({\n code: \"source-file-missing\",\n severity: sourceExplicit ? \"error\" : \"info\",\n file: file.shown,\n message: sourceExplicit\n ? `${file.shown} was not found`\n : `${file.shown} was not found, so no values were compared`,\n recommendation: `Create ${file.shown} (for example by copying ${example?.path ?? \".env.example\"}), or pass --file to audit a different file.`,\n });\n continue;\n }\n if (!reportUnreadable(file, loadIssues) || file.result.status !== \"ok\")\n continue;\n sourceFiles.push(\n toFileData(file.shown, file.absolute, \"source\", file.result.content),\n );\n }\n\n if (\n sourceFiles.length === 0 &&\n example === undefined &&\n !loadIssues.some((issue) => issue.severity === \"error\")\n ) {\n loadIssues.push({\n code: \"no-env-files\",\n severity: \"error\",\n message: \"No environment files were found to audit\",\n recommendation:\n \"Create a .env file and a .env.example that documents it, or point to a file with --file.\",\n });\n }\n\n const framework = await detectFramework(cwd, config);\n\n const scanOptions: ScanOptions = {\n directories: options.scanDirectories ?? config.scan?.directories ?? [\".\"],\n ignore: config.scan?.ignore ?? [],\n extensions: config.scan?.extensions ?? DEFAULT_EXTENSIONS,\n };\n\n const env: Record<string, string | undefined> = {\n ...(options.processEnv ? process.env : {}),\n ...(options.env ?? {}),\n };\n\n const project: ProjectContext = {\n cwd,\n config,\n rules,\n strict: options.strict ?? false,\n checks: new Set(options.checks ?? ALL_CHECKS),\n isIgnored,\n framework,\n sourceFiles,\n loadIssues,\n scanOptions,\n env,\n };\n if (configFile !== undefined) project.configFile = configFile;\n if (example !== undefined) project.example = example;\n if (config.schema !== undefined) project.schema = config.schema;\n return project;\n}\n\n/** Every env file that was read: sources first, then the example. */\nexport function allFiles(project: ProjectContext): EnvFileData[] {\n return project.example\n ? [...project.sourceFiles, project.example]\n : [...project.sourceFiles];\n}\n\n/**\n * The effective environment from the source files (later files win, and the\n * last declaration within a file wins), overlaid with `project.env`.\n * Used only for validation; values are never printed.\n */\nexport function mergedEnvironment(project: ProjectContext): {\n values: Record<string, string | undefined>;\n /** The file and line that defined each variable (not set for process values). */\n origin: Map<string, { file: string; line: number }>;\n} {\n const values: Record<string, string | undefined> = {};\n const origin = new Map<string, { file: string; line: number }>();\n for (const file of project.sourceFiles) {\n for (const entry of file.entries) {\n values[entry.key] = entry.value;\n origin.set(entry.key, { file: file.path, line: entry.line });\n }\n }\n for (const [name, value] of Object.entries(project.env)) {\n if (value !== undefined) {\n values[name] = value;\n origin.delete(name);\n }\n }\n return { values, origin };\n}\n","import { promises as fs } from \"node:fs\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { EnvDoctorConfig } from \"../types\";\nimport { displayPath } from \"../core/files\";\nimport { ConfigError, validateConfig } from \"./schema\";\n\nconst CONFIG_FILE_NAMES = [\n \"envclinic.config.json\",\n \"envclinic.config.mjs\",\n \"envclinic.config.js\",\n \"envclinic.config.cjs\",\n \"envclinic.config.ts\",\n];\n\nexport interface LoadedConfig {\n config: EnvDoctorConfig;\n /** Display path of the file that was loaded, if any. */\n file?: string;\n}\n\n/**\n * Load the optional config file. With an explicit path the file must exist;\n * otherwise the first matching file in `cwd` is used, and no file means\n * defaults.\n *\n * JavaScript and TypeScript config files are executed by Node when imported\n * (the same trust model as any other tool config). `.ts` files work only on\n * Node versions that can import TypeScript natively; use `.json` or `.mjs`\n * otherwise.\n */\nexport async function loadConfig(\n cwd: string,\n explicitPath?: string,\n): Promise<LoadedConfig> {\n let absolute: string | undefined;\n\n if (explicitPath !== undefined) {\n absolute = path.resolve(cwd, explicitPath);\n if (!(await exists(absolute))) {\n throw new ConfigError(\n `Config file not found: ${displayPath(cwd, absolute)}`,\n );\n }\n } else {\n for (const name of CONFIG_FILE_NAMES) {\n const candidate = path.join(cwd, name);\n if (await exists(candidate)) {\n absolute = candidate;\n break;\n }\n }\n }\n\n if (absolute === undefined) return { config: {} };\n\n const shown = displayPath(cwd, absolute);\n const raw = await readRaw(absolute, shown);\n return { config: validateConfig(raw, shown), file: shown };\n}\n\nasync function readRaw(absolute: string, shown: string): Promise<unknown> {\n const ext = path.extname(absolute).toLowerCase();\n\n if (ext === \".json\") {\n let text: string;\n try {\n text = await fs.readFile(absolute, \"utf8\");\n } catch (error) {\n throw new ConfigError(\n `Could not read config file ${shown}: ${(error as Error).message}`,\n );\n }\n try {\n return JSON.parse(text);\n } catch (error) {\n throw new ConfigError(\n `Config file ${shown} is not valid JSON: ${(error as Error).message}`,\n );\n }\n }\n\n try {\n const mod = (await import(pathToFileURL(absolute).href)) as {\n default?: unknown;\n };\n return mod.default ?? mod;\n } catch (error) {\n const hint =\n ext === \".ts\"\n ? \" TypeScript config files need a Node.js version that can import .ts files; use envclinic.config.json or .mjs instead.\"\n : \"\";\n throw new ConfigError(\n `Could not load config file ${shown}: ${(error as Error).message}.${hint}`,\n );\n }\n}\n\nasync function exists(file: string): Promise<boolean> {\n try {\n await fs.access(file);\n return true;\n } catch {\n return false;\n }\n}\n","import { promises as fs } from \"node:fs\";\nimport path from \"node:path\";\n\n/** Env files larger than this are refused rather than read into memory. */\nexport const MAX_ENV_FILE_BYTES = 5 * 1024 * 1024;\n\nexport type TextEncoding = \"utf-8\" | \"utf-16le\" | \"utf-16be\";\n\n/**\n * Decode a file's bytes. Windows PowerShell's `>` and `echo ... > file` write UTF-16, which\n * would otherwise read as text full of NUL characters. A UTF-8 BOM is dropped by the parser.\n */\nexport function decodeText(buf: Buffer): { text: string; encoding: TextEncoding } {\n if (buf.length >= 2 && buf[0] === 0xff && buf[1] === 0xfe) {\n return { text: buf.subarray(2).toString(\"utf16le\"), encoding: \"utf-16le\" };\n }\n if (buf.length >= 2 && buf[0] === 0xfe && buf[1] === 0xff) {\n return { text: Buffer.from(buf.subarray(2)).swap16().toString(\"utf16le\"), encoding: \"utf-16be\" };\n }\n // No BOM: ASCII-heavy UTF-16 has a zero byte in every other position.\n if (buf.length >= 4 && buf.length % 2 === 0) {\n const sample = Math.min(buf.length, 512) & ~1;\n let evenZero = 0;\n let oddZero = 0;\n for (let i = 0; i < sample; i += 2) {\n if (buf[i] === 0) evenZero++;\n if (buf[i + 1] === 0) oddZero++;\n }\n const pairs = sample / 2;\n if (oddZero > pairs * 0.4 && evenZero === 0) return { text: buf.toString(\"utf16le\"), encoding: \"utf-16le\" };\n if (evenZero > pairs * 0.4 && oddZero === 0) return { text: Buffer.from(buf).swap16().toString(\"utf16le\"), encoding: \"utf-16be\" };\n }\n return { text: buf.toString(\"utf8\"), encoding: \"utf-8\" };\n}\n\nexport type ReadResult =\n | { status: \"ok\"; content: string; encoding: TextEncoding }\n | { status: \"missing\" }\n | { status: \"unsafe\"; reason: string }\n | { status: \"too-large\" }\n | { status: \"unreadable\" };\n\nexport function isInside(root: string, target: string): boolean {\n const rel = path.relative(root, target);\n if (rel === \"\") return true;\n if (rel === \"..\" || rel.startsWith(\"..\" + path.sep)) return false;\n return !path.isAbsolute(rel);\n}\n\n/** Path shown to the user: relative to the project root, with forward slashes. */\nexport function displayPath(root: string, absolute: string): string {\n const rel = path.relative(root, absolute);\n return (rel === \"\" ? \".\" : rel).split(path.sep).join(\"/\");\n}\n\n/**\n * Read an env file, refusing anything outside the project root. Symlinks are\n * resolved and must also point inside the root, so a malicious repository\n * cannot trick the tool into reading (and reporting on) files elsewhere.\n */\nexport async function readEnvFile(root: string, relative: string): Promise<ReadResult> {\n const absolute = path.resolve(root, relative);\n if (!isInside(root, absolute)) {\n return { status: \"unsafe\", reason: \"the path is outside the project directory\" };\n }\n\n try {\n await fs.lstat(absolute);\n } catch (error) {\n const code = (error as NodeJS.ErrnoException).code;\n return code === \"ENOENT\" || code === \"ENOTDIR\" ? { status: \"missing\" } : { status: \"unreadable\" };\n }\n\n let real: string;\n let realRoot: string;\n try {\n real = await fs.realpath(absolute);\n realRoot = await fs.realpath(root);\n } catch {\n return { status: \"unsafe\", reason: \"the path is a broken symbolic link\" };\n }\n if (!isInside(realRoot, real)) {\n return { status: \"unsafe\", reason: \"the file is a symbolic link that points outside the project directory\" };\n }\n\n try {\n const stat = await fs.stat(real);\n if (!stat.isFile()) return { status: \"unsafe\", reason: \"the path is not a regular file\" };\n if (stat.size > MAX_ENV_FILE_BYTES) return { status: \"too-large\" };\n const decoded = decodeText(await fs.readFile(real));\n return { status: \"ok\", content: decoded.text, encoding: decoded.encoding };\n } catch {\n return { status: \"unreadable\" };\n }\n}\n","import { promises as fs } from \"node:fs\";\nimport path from \"node:path\";\nimport type { EnvDoctorConfig, FrameworkId } from \"../types\";\n\nexport interface FrameworkInfo {\n /** The primary framework (forced by config, or the best detected match). */\n id: FrameworkId;\n name: string;\n /** How the framework conventionally exposes variables to code. */\n accessPatterns: string[];\n /** Prefixes whose variables end up in client bundles. */\n publicPrefixes: string[];\n /** Why each framework was detected (dependency or config file). */\n evidence: string[];\n /** Every framework that matched, primary first. */\n detected: FrameworkId[];\n /** True when the config file forced the framework. */\n forced: boolean;\n notes: string[];\n}\n\ninterface Definition {\n id: FrameworkId;\n name: string;\n dependencies: string[];\n files: string[];\n accessPatterns: string[];\n publicPrefixes: string[];\n notes: string;\n}\n\n/** In precedence order: the first match becomes the primary framework. */\nconst DEFINITIONS: Definition[] = [\n {\n id: \"nextjs\",\n name: \"Next.js\",\n dependencies: [\"next\"],\n files: [\"next.config.js\", \"next.config.mjs\", \"next.config.cjs\", \"next.config.ts\"],\n accessPatterns: [\"process.env\"],\n publicPrefixes: [\"NEXT_PUBLIC_\"],\n notes: \"Variables prefixed with NEXT_PUBLIC_ are inlined into the browser bundle.\",\n },\n {\n id: \"astro\",\n name: \"Astro\",\n dependencies: [\"astro\"],\n files: [\"astro.config.mjs\", \"astro.config.js\", \"astro.config.ts\", \"astro.config.cjs\"],\n accessPatterns: [\"import.meta.env\"],\n publicPrefixes: [\"PUBLIC_\"],\n notes: \"Variables prefixed with PUBLIC_ are available in client-side code.\",\n },\n {\n id: \"nestjs\",\n name: \"NestJS\",\n dependencies: [\"@nestjs/core\"],\n files: [\"nest-cli.json\"],\n accessPatterns: [\"process.env\"],\n publicPrefixes: [],\n notes: \"Server-side only. Variables are normally read through process.env or @nestjs/config.\",\n },\n {\n id: \"vite\",\n name: \"Vite\",\n dependencies: [\"vite\"],\n files: [\"vite.config.js\", \"vite.config.mjs\", \"vite.config.cjs\", \"vite.config.ts\", \"vite.config.mts\"],\n accessPatterns: [\"import.meta.env\"],\n publicPrefixes: [\"VITE_\"],\n notes: \"Only variables prefixed with VITE_ (or your envPrefix setting) are exposed to client code.\",\n },\n {\n id: \"react\",\n name: \"React\",\n dependencies: [\"react\", \"react-scripts\"],\n files: [],\n accessPatterns: [\"process.env\", \"import.meta.env\"],\n publicPrefixes: [],\n notes: \"Depends on the build tool. Create React App exposes REACT_APP_ variables.\",\n },\n {\n id: \"express\",\n name: \"Express\",\n dependencies: [\"express\"],\n files: [],\n accessPatterns: [\"process.env\"],\n publicPrefixes: [],\n notes: \"Server-side only. Variables are read through process.env.\",\n },\n];\n\nconst NODE: Definition = {\n id: \"node\",\n name: \"Node.js\",\n dependencies: [],\n files: [],\n accessPatterns: [\"process.env\"],\n publicPrefixes: [],\n notes: \"Plain Node.js conventions: variables are read through process.env.\",\n};\n\nasync function readDependencies(cwd: string): Promise<{ present: boolean; names: Set<string> }> {\n try {\n const stat = await fs.stat(path.join(cwd, \"package.json\"));\n if (stat.size > 1024 * 1024) return { present: true, names: new Set() };\n const parsed: unknown = JSON.parse(await fs.readFile(path.join(cwd, \"package.json\"), \"utf8\"));\n const names = new Set<string>();\n if (typeof parsed === \"object\" && parsed !== null) {\n for (const field of [\"dependencies\", \"devDependencies\", \"peerDependencies\", \"optionalDependencies\"]) {\n const section = (parsed as Record<string, unknown>)[field];\n if (typeof section === \"object\" && section !== null) {\n for (const name of Object.keys(section)) names.add(name);\n }\n }\n }\n return { present: true, names };\n } catch {\n return { present: false, names: new Set() };\n }\n}\n\nasync function exists(file: string): Promise<boolean> {\n try {\n await fs.access(file);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Detect the project's framework from package.json dependencies and\n * well-known config files. package.json is parsed as data; nothing in the\n * project is executed.\n *\n * Detection only informs reports (such as which prefixes are exposed to the\n * browser). It can be overridden with the `framework` and `publicPrefixes`\n * config options because projects do not always follow framework defaults.\n */\nexport async function detectFramework(\n cwd: string,\n config: Pick<EnvDoctorConfig, \"framework\" | \"publicPrefixes\"> = {},\n): Promise<FrameworkInfo> {\n const { present, names } = await readDependencies(cwd);\n const evidence: string[] = [];\n const matched: Definition[] = [];\n\n for (const definition of DEFINITIONS) {\n const reasons: string[] = [];\n for (const dependency of definition.dependencies) {\n if (names.has(dependency)) reasons.push(`dependency \"${dependency}\"`);\n }\n for (const file of definition.files) {\n if (await exists(path.join(cwd, file))) reasons.push(`file ${file}`);\n }\n if (reasons.length > 0) {\n matched.push(definition);\n evidence.push(...reasons.map((reason) => `${definition.name}: ${reason}`));\n }\n }\n\n const notes: string[] = [];\n let primary: Definition = matched[0] ?? NODE;\n if (matched.length === 0) {\n evidence.push(\n present\n ? \"No framework dependency found; assuming plain Node.js conventions.\"\n : \"No package.json found; assuming plain Node.js conventions.\",\n );\n }\n\n let forced = false;\n if (config.framework !== undefined && config.framework !== \"auto\") {\n const requested = config.framework;\n primary = [...DEFINITIONS, NODE].find((definition) => definition.id === requested) ?? primary;\n forced = true;\n evidence.unshift(`${primary.name}: forced by the \"framework\" config option`);\n }\n\n const reactScripts = names.has(\"react-scripts\");\n let prefixes: string[];\n if (forced) {\n prefixes = [...primary.publicPrefixes];\n if (primary.id === \"react\" && reactScripts) prefixes.push(\"REACT_APP_\");\n } else {\n prefixes = [...new Set([...matched.flatMap((definition) => definition.publicPrefixes), ...(reactScripts ? [\"REACT_APP_\"] : [])])];\n }\n if (config.publicPrefixes !== undefined) prefixes = [...config.publicPrefixes];\n\n notes.push(primary.notes);\n if (primary.id === \"react\" && !reactScripts) {\n notes.push(\"react-scripts was not found, so no client prefix is assumed. Set publicPrefixes if your build tool exposes one.\");\n }\n if (config.publicPrefixes !== undefined) {\n notes.push(\"Public prefixes come from the publicPrefixes config option.\");\n }\n\n const detected = [...new Set([primary.id, ...matched.map((definition) => definition.id)])];\n return {\n id: primary.id,\n name: primary.name,\n accessPatterns: [...primary.accessPatterns],\n publicPrefixes: prefixes,\n evidence,\n detected,\n forced,\n notes,\n };\n}\n\nexport const FRAMEWORK_IDS: FrameworkId[] = [...DEFINITIONS.map((definition) => definition.id), \"node\"];\n","import type { EnvDoctorConfig, RuleLevel, RuleName, Schema, SchemaField, SchemaType } from \"../types\";\nimport { FRAMEWORK_IDS } from \"../frameworks/detector\";\nimport { DEFAULT_RULES } from \"./defaults\";\n\nexport class ConfigError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ConfigError\";\n }\n}\n\nconst TOP_LEVEL_KEYS = [\n \"files\", \"scan\", \"rules\", \"ignore\", \"secrets\", \"schema\", \"framework\", \"publicPrefixes\", \"types\", \"generate\",\n];\nconst LEVELS: RuleLevel[] = [\"error\", \"warning\", \"off\"];\nconst SCHEMA_TYPES: SchemaType[] = [\"string\", \"number\", \"boolean\", \"url\", \"email\", \"enum\", \"integer\", \"custom\"];\nconst SCHEMA_FIELD_KEYS = [\n \"type\", \"required\", \"default\", \"description\", \"secret\", \"minLength\", \"maxLength\", \"min\", \"max\",\n \"pattern\", \"values\", \"protocols\", \"validate\",\n];\nconst VARIABLE_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nclass Validator {\n constructor(private readonly origin: string) {}\n\n fail(message: string): never {\n throw new ConfigError(`Invalid config in ${this.origin}: ${message}`);\n }\n\n object(value: unknown, name: string): Record<string, unknown> {\n if (!isObject(value)) this.fail(`\"${name}\" must be an object.`);\n return value;\n }\n\n known(obj: Record<string, unknown>, allowed: string[], prefix: string): void {\n for (const key of Object.keys(obj)) {\n if (!allowed.includes(key)) {\n this.fail(`unknown option \"${prefix}${key}\". Allowed: ${allowed.map((k) => prefix + k).join(\", \")}.`);\n }\n }\n }\n\n strings(value: unknown, name: string): string[] {\n if (!Array.isArray(value) || value.some((v) => typeof v !== \"string\" || v === \"\")) {\n this.fail(`\"${name}\" must be an array of non-empty strings.`);\n }\n return value as string[];\n }\n\n string(value: unknown, name: string): string {\n if (typeof value !== \"string\" || value === \"\") this.fail(`\"${name}\" must be a non-empty string.`);\n return value;\n }\n\n boolean(value: unknown, name: string): boolean {\n if (typeof value !== \"boolean\") this.fail(`\"${name}\" must be true or false.`);\n return value;\n }\n\n number(value: unknown, name: string): number {\n if (typeof value !== \"number\" || !Number.isFinite(value)) this.fail(`\"${name}\" must be a number.`);\n return value;\n }\n\n regex(value: unknown, name: string): string {\n const source = this.string(value, name);\n try {\n new RegExp(source);\n } catch {\n this.fail(`\"${name}\" is not a valid regular expression.`);\n }\n return source;\n }\n}\n\nfunction validateSchema(v: Validator, raw: unknown): Schema {\n const input = v.object(raw, \"schema\");\n const schema: Schema = {};\n\n for (const [name, entry] of Object.entries(input)) {\n const where = `schema.${name}`;\n if (!VARIABLE_NAME.test(name)) v.fail(`\"${where}\" is not a valid variable name.`);\n const obj = v.object(entry, where);\n v.known(obj, SCHEMA_FIELD_KEYS, `${where}.`);\n\n const type = obj.type;\n if (typeof type !== \"string\" || !SCHEMA_TYPES.includes(type as SchemaType)) {\n v.fail(`\"${where}.type\" must be one of ${SCHEMA_TYPES.map((t) => `\"${t}\"`).join(\", \")}.`);\n }\n const field: SchemaField = { type: type as SchemaType };\n\n if (obj.required !== undefined) field.required = v.boolean(obj.required, `${where}.required`);\n if (obj.secret !== undefined) field.secret = v.boolean(obj.secret, `${where}.secret`);\n if (obj.description !== undefined) field.description = v.string(obj.description, `${where}.description`);\n for (const key of [\"minLength\", \"maxLength\", \"min\", \"max\"] as const) {\n if (obj[key] !== undefined) field[key] = v.number(obj[key], `${where}.${key}`);\n }\n if (field.minLength !== undefined && field.maxLength !== undefined && field.minLength > field.maxLength) {\n v.fail(`\"${where}.minLength\" cannot be greater than \"${where}.maxLength\".`);\n }\n if (field.min !== undefined && field.max !== undefined && field.min > field.max) {\n v.fail(`\"${where}.min\" cannot be greater than \"${where}.max\".`);\n }\n if (obj.pattern !== undefined) field.pattern = v.regex(obj.pattern, `${where}.pattern`);\n if (obj.protocols !== undefined) field.protocols = v.strings(obj.protocols, `${where}.protocols`);\n\n if (obj.values !== undefined) field.values = v.strings(obj.values, `${where}.values`);\n if (field.type === \"enum\" && (field.values === undefined || field.values.length === 0)) {\n v.fail(`\"${where}.values\" is required for enum variables and must not be empty.`);\n }\n\n if (obj.validate !== undefined) {\n if (typeof obj.validate !== \"function\") v.fail(`\"${where}.validate\" must be a function.`);\n field.validate = obj.validate as SchemaField[\"validate\"];\n }\n if (field.type === \"custom\" && field.validate === undefined) {\n v.fail(`\"${where}.validate\" is required for custom variables (custom validators need a JavaScript config file).`);\n }\n\n if (obj.default !== undefined) {\n const d = obj.default;\n const expected = field.type === \"number\" || field.type === \"integer\" ? \"number\" : field.type === \"boolean\" ? \"boolean\" : \"string\";\n if (typeof d !== expected) v.fail(`\"${where}.default\" must be a ${expected} for ${field.type} variables.`);\n field.default = d as string | number | boolean;\n }\n schema[name] = field;\n }\n return schema;\n}\n\n/** Validate an untrusted config value and return it typed. Throws ConfigError. */\nexport function validateConfig(raw: unknown, origin: string): EnvDoctorConfig {\n const v = new Validator(origin);\n const input = v.object(raw, \"config\");\n v.known(input, TOP_LEVEL_KEYS, \"\");\n const config: EnvDoctorConfig = {};\n\n if (input.files !== undefined) {\n const files = v.object(input.files, \"files\");\n v.known(files, [\"source\", \"example\"], \"files.\");\n config.files = {};\n if (files.source !== undefined) config.files.source = v.strings(files.source, \"files.source\");\n if (files.example !== undefined) config.files.example = v.string(files.example, \"files.example\");\n }\n\n if (input.scan !== undefined) {\n const scan = v.object(input.scan, \"scan\");\n v.known(scan, [\"directories\", \"ignore\", \"extensions\"], \"scan.\");\n config.scan = {};\n if (scan.directories !== undefined) config.scan.directories = v.strings(scan.directories, \"scan.directories\");\n if (scan.ignore !== undefined) config.scan.ignore = v.strings(scan.ignore, \"scan.ignore\");\n if (scan.extensions !== undefined) {\n config.scan.extensions = v.strings(scan.extensions, \"scan.extensions\").map((e) => e.replace(/^\\./, \"\"));\n }\n }\n\n if (input.rules !== undefined) {\n const rules = v.object(input.rules, \"rules\");\n v.known(rules, Object.keys(DEFAULT_RULES), \"rules.\");\n config.rules = {};\n for (const [name, level] of Object.entries(rules)) {\n if (typeof level !== \"string\" || !LEVELS.includes(level as RuleLevel)) {\n v.fail(`\"rules.${name}\" must be one of ${LEVELS.map((l) => `\"${l}\"`).join(\", \")}.`);\n }\n config.rules[name as RuleName] = level as RuleLevel;\n }\n }\n\n if (input.ignore !== undefined) {\n const ignore = v.object(input.ignore, \"ignore\");\n v.known(ignore, [\"variables\"], \"ignore.\");\n config.ignore = {};\n if (ignore.variables !== undefined) config.ignore.variables = v.strings(ignore.variables, \"ignore.variables\");\n }\n\n if (input.secrets !== undefined) {\n const secrets = v.object(input.secrets, \"secrets\");\n v.known(secrets, [\"allow\", \"ignoreFiles\", \"patterns\"], \"secrets.\");\n config.secrets = {};\n if (secrets.allow !== undefined) config.secrets.allow = v.strings(secrets.allow, \"secrets.allow\");\n if (secrets.ignoreFiles !== undefined) config.secrets.ignoreFiles = v.strings(secrets.ignoreFiles, \"secrets.ignoreFiles\");\n if (secrets.patterns !== undefined) {\n const list: unknown = secrets.patterns;\n if (!Array.isArray(list)) return v.fail(`\"secrets.patterns\" must be an array.`);\n config.secrets.patterns = (list as unknown[]).map((entry, index) => {\n const where = `secrets.patterns[${index}]`;\n const obj = v.object(entry, where);\n v.known(obj, [\"id\", \"description\", \"pattern\", \"severity\"], `${where}.`);\n const pattern: NonNullable<NonNullable<EnvDoctorConfig[\"secrets\"]>[\"patterns\"]>[number] = {\n id: v.string(obj.id, `${where}.id`),\n pattern: v.regex(obj.pattern, `${where}.pattern`),\n };\n if (obj.description !== undefined) pattern.description = v.string(obj.description, `${where}.description`);\n if (obj.severity !== undefined) {\n const severity: unknown = obj.severity;\n if (severity !== \"error\" && severity !== \"warning\") {\n return v.fail(`\"${where}.severity\" must be \"error\" or \"warning\".`);\n }\n pattern.severity = severity;\n }\n return pattern;\n });\n }\n }\n\n if (input.schema !== undefined) config.schema = validateSchema(v, input.schema);\n\n if (input.framework !== undefined) {\n const allowed = [\"auto\", ...FRAMEWORK_IDS];\n if (typeof input.framework !== \"string\" || !allowed.includes(input.framework)) {\n v.fail(`\"framework\" must be one of ${allowed.map((f) => `\"${f}\"`).join(\", \")}.`);\n }\n config.framework = input.framework as EnvDoctorConfig[\"framework\"];\n }\n\n if (input.publicPrefixes !== undefined) {\n config.publicPrefixes = v.strings(input.publicPrefixes, \"publicPrefixes\");\n }\n\n if (input.types !== undefined) {\n const types = v.object(input.types, \"types\");\n v.known(types, [\"enabled\", \"output\"], \"types.\");\n config.types = {};\n if (types.enabled !== undefined) config.types.enabled = v.boolean(types.enabled, \"types.enabled\");\n if (types.output !== undefined) config.types.output = v.string(types.output, \"types.output\");\n }\n\n if (input.generate !== undefined) {\n const generate = v.object(input.generate, \"generate\");\n v.known(generate, [\"output\", \"exclude\"], \"generate.\");\n config.generate = {};\n if (generate.output !== undefined) config.generate.output = v.string(generate.output, \"generate.output\");\n if (generate.exclude !== undefined) config.generate.exclude = v.strings(generate.exclude, \"generate.exclude\");\n }\n\n return config;\n}\n\n/** Identity helper that gives config files type checking and autocomplete. */\nexport function defineConfig(config: EnvDoctorConfig): EnvDoctorConfig {\n return config;\n}\n","const SPECIAL = /[\\\\^$.|+(){}[\\]]/g;\n\nfunction escapeRegex(text: string): string {\n return text.replace(SPECIAL, \"\\\\$&\");\n}\n\n/**\n * Convert a simple glob (`*`, `**`, `?`) to a RegExp source (without anchors).\n * `**` crosses directory separators; `*` and `?` do not.\n */\nexport function globToRegexSource(glob: string): string {\n let out = \"\";\n for (let i = 0; i < glob.length; i++) {\n const c = glob[i] as string;\n if (c === \"*\") {\n if (glob[i + 1] === \"*\") {\n i++;\n if (glob[i + 1] === \"/\") {\n i++;\n out += \"(?:.*/)?\";\n } else {\n out += \".*\";\n }\n } else {\n out += \"[^/]*\";\n }\n } else if (c === \"?\") {\n out += \"[^/]\";\n } else {\n out += escapeRegex(c);\n }\n }\n return out;\n}\n\n/** Test a relative path (forward slashes) against a glob. */\nexport function matchesGlob(glob: string, relativePath: string): boolean {\n const normalized = glob.replace(/^\\.\\//, \"\");\n return new RegExp(`^${globToRegexSource(normalized)}$`).test(relativePath);\n}\n\n/**\n * Build a predicate for variable names from patterns where `*` matches any\n * run of characters. Everything else matches literally and case-sensitively.\n */\nexport function createNameMatcher(patterns: readonly string[]): (name: string) => boolean {\n const exact = new Set<string>();\n const regexes: RegExp[] = [];\n for (const pattern of patterns) {\n if (pattern.includes(\"*\")) {\n regexes.push(new RegExp(`^${pattern.split(\"*\").map(escapeRegex).join(\".*\")}$`));\n } else {\n exact.add(pattern);\n }\n }\n return (name) => exact.has(name) || regexes.some((regex) => regex.test(name));\n}\n","export type QuoteStyle = \"double\" | \"single\" | \"backtick\";\n\nexport interface EnvEntry {\n key: string;\n value: string;\n /** 1-based line where the declaration starts. */\n line: number;\n quote: QuoteStyle | null;\n exported: boolean;\n}\n\nexport interface ParseProblem {\n kind: \"malformed-line\" | \"unterminated-quote\";\n line: number;\n}\n\nexport interface ParsedEnv {\n entries: EnvEntry[];\n problems: ParseProblem[];\n}\n\nconst LINE_RE = /^[ \\t]*(export[ \\t]+)?([^\\s=]+)[ \\t]*=/;\n\nconst QUOTES: Record<string, QuoteStyle> = {\n '\"': \"double\",\n \"'\": \"single\",\n \"`\": \"backtick\",\n};\n\n/**\n * Parse the contents of a .env file.\n *\n * Handles comments, `export` prefixes, single/double/backtick quotes,\n * multiline quoted values, inline comments and CRLF line endings. Unlike\n * dotenv, it keeps every declaration (so duplicates can be reported) and\n * records line numbers. Problems never include the offending text, only the\n * line number, so malformed secrets cannot leak through error reporting.\n */\nexport function parseEnv(source: string): ParsedEnv {\n const text = source.replace(/^\\uFEFF/, \"\").replace(/\\r\\n?/g, \"\\n\");\n const entries: EnvEntry[] = [];\n const problems: ParseProblem[] = [];\n\n let i = 0;\n let line = 1;\n\n while (i < text.length) {\n let eol = text.indexOf(\"\\n\", i);\n if (eol === -1) eol = text.length;\n const raw = text.slice(i, eol);\n const trimmed = raw.trim();\n let next = eol + 1;\n\n if (trimmed !== \"\" && !trimmed.startsWith(\"#\")) {\n const match = LINE_RE.exec(raw);\n if (!match) {\n problems.push({ kind: \"malformed-line\", line });\n } else {\n const key = match[2] as string;\n const exported = match[1] !== undefined;\n let p = i + match[0].length;\n while (text[p] === \" \" || text[p] === \"\\t\") p++;\n\n const quoteChar = text[p];\n const style = quoteChar !== undefined ? QUOTES[quoteChar] : undefined;\n\n if (style && quoteChar !== undefined) {\n const end = findClosingQuote(text, p, quoteChar);\n if (end === -1) {\n problems.push({ kind: \"unterminated-quote\", line });\n entries.push({\n key,\n value: text.slice(p + 1, eol),\n line,\n quote: style,\n exported,\n });\n } else {\n let value = text.slice(p + 1, end);\n if (style === \"double\") value = unescapeDouble(value);\n entries.push({ key, value, line, quote: style, exported });\n let eol2 = text.indexOf(\"\\n\", end + 1);\n if (eol2 === -1) eol2 = text.length;\n next = eol2 + 1;\n }\n } else if (text[p] === \"=\") {\n // `NAME==...` is almost always pasted base64 (padding) or other\n // garbage, and its \"name\" may be a fragment of key material. Treat\n // the line as malformed so the name is never recorded or reported.\n problems.push({ kind: \"malformed-line\", line });\n } else {\n entries.push({\n key,\n value: parseUnquoted(text.slice(p, eol)),\n line,\n quote: null,\n exported,\n });\n }\n }\n }\n\n line += countNewlines(text, i, Math.min(next, text.length));\n i = next;\n }\n\n return { entries, problems };\n}\n\nfunction findClosingQuote(text: string, start: number, quote: string): number {\n for (let j = start + 1; j < text.length; j++) {\n const c = text[j];\n if (quote === '\"' && c === \"\\\\\") {\n j++;\n continue;\n }\n if (c === quote) return j;\n }\n return -1;\n}\n\nfunction unescapeDouble(value: string): string {\n return value.replace(/\\\\([nrt\"\\\\])/g, (_, c: string) => {\n if (c === \"n\") return \"\\n\";\n if (c === \"r\") return \"\\r\";\n if (c === \"t\") return \"\\t\";\n return c;\n });\n}\n\nfunction parseUnquoted(rest: string): string {\n if (rest.startsWith(\"#\")) return \"\";\n const comment = /[ \\t]#/.exec(rest);\n return (comment ? rest.slice(0, comment.index) : rest).trim();\n}\n\nfunction countNewlines(text: string, from: number, to: number): number {\n let count = 0;\n for (let k = from; k < to; k++) {\n if (text.charCodeAt(k) === 10) count++;\n }\n return count;\n}\n","import { promises as fs } from \"node:fs\";\nimport path from \"node:path\";\nimport fg from \"fast-glob\";\nimport { displayPath, isInside } from \"./files\";\nimport { ConfigError } from \"../config/schema\";\n\nexport const DEFAULT_EXTENSIONS = [\n \"js\",\n \"jsx\",\n \"mjs\",\n \"cjs\",\n \"ts\",\n \"tsx\",\n \"mts\",\n \"cts\",\n \"vue\",\n \"svelte\",\n \"astro\",\n];\n\nexport const DEFAULT_SCAN_IGNORE = [\n \"node_modules\",\n \".git\",\n \"dist\",\n \"build\",\n \"out\",\n \"coverage\",\n \".next\",\n \".nuxt\",\n \".svelte-kit\",\n \".output\",\n \".turbo\",\n \".cache\",\n \".vercel\",\n \".netlify\",\n \".parcel-cache\",\n \".yarn\",\n \".pnpm-store\",\n];\n\n/** Source files larger than this are skipped (usually bundles or generated code). */\nexport const MAX_SOURCE_FILE_BYTES = 1024 * 1024;\n\nexport interface SourceLocation {\n file: string;\n line: number;\n}\n\nexport interface ScanOptions {\n directories: string[];\n ignore: string[];\n extensions: string[];\n}\n\nexport interface SourceFile {\n /** Path relative to the project root, with forward slashes. */\n path: string;\n content: string;\n}\n\nexport interface ScanSummary {\n filesScanned: number;\n /** Files skipped because they were symlinks, too large or unreadable. */\n skipped: number;\n}\n\nfunction ignoreToGlob(entry: string): string {\n const cleaned = entry.replace(/^\\.\\//, \"\").replace(/\\/+$/, \"\");\n if (/[*?]/.test(cleaned)) return cleaned;\n if (cleaned.includes(\"/\")) return `${cleaned}/**`;\n return `**/${cleaned}/**`;\n}\n\n/** Find source files to scan. Never follows symlinks and never leaves the project root. */\nexport async function discoverSourceFiles(\n cwd: string,\n options: ScanOptions,\n): Promise<string[]> {\n const realRoot = await fs.realpath(cwd);\n const extensions =\n options.extensions.length === 1\n ? options.extensions[0]\n : `{${options.extensions.join(\",\")}}`;\n const ignore = [\n ...DEFAULT_SCAN_IGNORE.map(ignoreToGlob),\n ...options.ignore.map(ignoreToGlob),\n \"**/*.d.ts\",\n \"**/*.min.js\",\n \"**/envclinic.config.*\",\n ];\n\n const found = new Set<string>();\n for (const directory of options.directories) {\n const absolute = path.resolve(cwd, directory);\n if (!isInside(cwd, absolute)) {\n throw new ConfigError(\n `scan.directories entry \"${directory}\" is outside the project directory.`,\n );\n }\n let real: string;\n try {\n real = await fs.realpath(absolute);\n } catch {\n continue; // a missing directory simply has nothing to scan\n }\n if (!isInside(realRoot, real)) continue;\n\n const relative = displayPath(cwd, absolute);\n const base = relative === \".\" ? \"\" : `${fg.escapePath(relative)}/`;\n const entries = await fg(`${base}**/*.${extensions}`, {\n cwd,\n ignore,\n onlyFiles: true,\n followSymbolicLinks: false,\n dot: false,\n unique: true,\n });\n for (const entry of entries) found.add(entry);\n }\n return [...found].sort();\n}\n\n/**\n * Read every source file once and pass it to `visit`. Symlinks, oversized\n * files and unreadable files are skipped.\n */\nexport async function scanSources(\n cwd: string,\n options: ScanOptions,\n visit: (file: SourceFile) => void,\n): Promise<ScanSummary> {\n const files = await discoverSourceFiles(cwd, options);\n let filesScanned = 0;\n let skipped = 0;\n\n const BATCH = 64;\n for (let i = 0; i < files.length; i += BATCH) {\n const batch = files.slice(i, i + BATCH);\n const loaded = await Promise.all(\n batch.map(async (relative) => {\n const absolute = path.join(cwd, relative);\n try {\n const stat = await fs.lstat(absolute);\n if (!stat.isFile() || stat.size > MAX_SOURCE_FILE_BYTES)\n return undefined;\n return {\n path: relative,\n content: await fs.readFile(absolute, \"utf8\"),\n };\n } catch {\n return undefined;\n }\n }),\n );\n for (const file of loaded) {\n if (file === undefined) {\n skipped++;\n } else {\n filesScanned++;\n visit(file);\n }\n }\n }\n return { filesScanned, skipped };\n}\n\n// --- Reference extraction --------------------------------------------------\n\nexport interface ExtractedReferences {\n /** Variables read with a literal name. */\n names: Array<{ name: string; line: number }>;\n /** Places where the variable name is not known statically. */\n dynamic: Array<{ line: number }>;\n}\n\n// Not preceded by an identifier character, nor by member access (`foo.process.env`),\n// but spread syntax (`...process.env`) is fine.\nconst ENV_OBJECT =\n /(?<![\\w$])(?<![\\w$)\\]]\\s*\\.)(?:process\\.env|import\\.meta\\.env|Bun\\.env)(?![\\w$])/g;\nconst MEMBER = /^\\s*\\??\\.\\s*([A-Za-z_$][\\w$]*)/;\nconst BRACKET_LITERAL = /^\\s*\\??\\.?\\s*\\[\\s*([\"'`])([A-Za-z_][\\w]*)\\1\\s*\\]/;\nconst BRACKET_ANY = /^\\s*\\??\\.?\\s*\\[/;\nconst CAST_MEMBER = /^\\s+as\\s+[^)]*\\)\\s*\\??\\.\\s*([A-Za-z_$][\\w$]*)/;\nconst DENO_GET = /\\bDeno\\.env\\.get\\(\\s*([\"'`])([A-Za-z_]\\w*)\\1\\s*\\)/g;\nconst DESTRUCTURE = /\\{([^{}]*)\\}\\s*=\\s*$/;\n\n/**\n * Find environment variable reads in source text.\n *\n * Recognizes `process.env.X`, `process.env[\"X\"]`, `import.meta.env.X`,\n * `Bun.env.X`, `Deno.env.get(\"X\")` and destructuring such as\n * `const { X, Y } = process.env`. Anything it cannot resolve to a literal name\n * (computed keys, aliases, spreading the whole object) is reported as dynamic.\n */\nexport function extractReferences(content: string): ExtractedReferences {\n const result: ExtractedReferences = { names: [], dynamic: [] };\n if (!/process\\.env|import\\.meta\\.env|Bun\\.env|Deno\\.env/.test(content))\n return result;\n\n let lineStarts: number[] | undefined;\n const lineAt = (index: number): number => {\n if (lineStarts === undefined) {\n lineStarts = [0];\n for (let i = 0; i < content.length; i++) {\n if (content.charCodeAt(i) === 10) lineStarts.push(i + 1);\n }\n }\n let low = 0;\n let high = lineStarts.length - 1;\n while (low < high) {\n const mid = (low + high + 1) >> 1;\n if ((lineStarts[mid] as number) <= index) low = mid;\n else high = mid - 1;\n }\n return low + 1;\n };\n\n for (const match of content.matchAll(ENV_OBJECT)) {\n const start = match.index as number;\n const end = start + match[0].length;\n const rest = content.slice(end, end + 200);\n const line = lineAt(start);\n\n const member = MEMBER.exec(rest);\n if (member) {\n result.names.push({ name: member[1] as string, line });\n continue;\n }\n const literal = BRACKET_LITERAL.exec(rest);\n if (literal) {\n result.names.push({ name: literal[2] as string, line });\n continue;\n }\n if (BRACKET_ANY.test(rest)) {\n result.dynamic.push({ line });\n continue;\n }\n const cast = CAST_MEMBER.exec(rest);\n if (cast) {\n result.names.push({ name: cast[1] as string, line });\n continue;\n }\n\n const before = content.slice(Math.max(0, start - 1000), start);\n const destructure = DESTRUCTURE.exec(before);\n if (destructure) {\n let dynamic = false;\n for (const part of (destructure[1] as string).split(\",\")) {\n const piece = part.trim();\n if (piece === \"\") continue;\n if (piece.startsWith(\"...\")) {\n dynamic = true;\n continue;\n }\n const name = /^([A-Za-z_$][\\w$]*)/.exec(piece);\n if (name) result.names.push({ name: name[1] as string, line });\n }\n if (dynamic) result.dynamic.push({ line });\n continue;\n }\n\n // The whole object is used (aliased, spread, passed to a function...).\n result.dynamic.push({ line });\n }\n\n for (const match of content.matchAll(DENO_GET)) {\n result.names.push({\n name: match[2] as string,\n line: lineAt(match.index as number),\n });\n }\n return result;\n}\n","import type { Schema, SchemaField } from \"../types\";\n\nexport interface ValidationIssue {\n variable: string;\n code:\n | \"missing-required\"\n | \"invalid-type\"\n | \"invalid-enum\"\n | \"invalid-protocol\"\n | \"too-short\"\n | \"too-long\"\n | \"out-of-range\"\n | \"pattern-mismatch\"\n | \"custom-failed\";\n /** Describes the problem without ever including the value. */\n message: string;\n}\n\nexport interface ValidationResult {\n success: boolean;\n /** Parsed values with defaults applied. Optional variables without a value are omitted. */\n values: Record<string, string | number | boolean>;\n errors: ValidationIssue[];\n}\n\ntype Env = Record<string, string | undefined>;\n\nconst TRUE_VALUES = new Set([\"true\", \"1\", \"yes\", \"on\"]);\nconst FALSE_VALUES = new Set([\"false\", \"0\", \"no\", \"off\"]);\nconst EMAIL = /^[^\\s@]+@[^\\s@.]+(?:\\.[^\\s@.]+)+$/;\n\nexport function isRequired(field: SchemaField): boolean {\n return field.required ?? field.default === undefined;\n}\n\nfunction parseOne(\n name: string,\n field: SchemaField,\n raw: string,\n): { value: string | number | boolean } | { error: ValidationIssue } {\n const fail = (code: ValidationIssue[\"code\"], message: string) => ({ error: { variable: name, code, message } });\n\n switch (field.type) {\n case \"string\": {\n if (field.minLength !== undefined && raw.length < field.minLength) {\n return fail(\"too-short\", `${name} must be at least ${field.minLength} characters long`);\n }\n if (field.maxLength !== undefined && raw.length > field.maxLength) {\n return fail(\"too-long\", `${name} must be at most ${field.maxLength} characters long`);\n }\n if (field.pattern !== undefined && !new RegExp(field.pattern).test(raw)) {\n return fail(\"pattern-mismatch\", `${name} does not match the required pattern`);\n }\n return { value: raw };\n }\n case \"number\":\n case \"integer\": {\n const text = raw.trim();\n const integer = field.type === \"integer\";\n const valid = integer ? /^[+-]?\\d+$/.test(text) : text !== \"\" && Number.isFinite(Number(text));\n const number = Number(text);\n if (!valid || (integer && !Number.isSafeInteger(number))) {\n return fail(\"invalid-type\", `${name} must be ${integer ? \"an integer\" : \"a number\"}`);\n }\n if (field.min !== undefined && number < field.min) {\n return fail(\"out-of-range\", `${name} must be at least ${field.min}`);\n }\n if (field.max !== undefined && number > field.max) {\n return fail(\"out-of-range\", `${name} must be at most ${field.max}`);\n }\n return { value: number };\n }\n case \"boolean\": {\n const lowered = raw.trim().toLowerCase();\n if (TRUE_VALUES.has(lowered)) return { value: true };\n if (FALSE_VALUES.has(lowered)) return { value: false };\n return fail(\"invalid-type\", `${name} must be a boolean (true, false, 1, 0, yes, no, on or off)`);\n }\n case \"url\": {\n let url: URL;\n try {\n url = new URL(raw);\n } catch {\n return fail(\"invalid-type\", `${name} must be a valid URL`);\n }\n if (field.protocols !== undefined) {\n const protocol = url.protocol.replace(/:$/, \"\").toLowerCase();\n if (!field.protocols.map((p) => p.toLowerCase()).includes(protocol)) {\n return fail(\"invalid-protocol\", `${name} must use one of these protocols: ${field.protocols.join(\", \")}`);\n }\n }\n return { value: raw };\n }\n case \"email\":\n return EMAIL.test(raw) ? { value: raw } : fail(\"invalid-type\", `${name} must be a valid email address`);\n case \"enum\": {\n const values = field.values ?? [];\n return values.includes(raw)\n ? { value: raw }\n : fail(\"invalid-enum\", `${name} must be one of: ${values.join(\", \")}`);\n }\n case \"custom\": {\n let outcome: boolean | string | void;\n try {\n outcome = field.validate?.(raw);\n } catch {\n return fail(\"custom-failed\", `${name} failed custom validation`);\n }\n if (outcome === undefined || outcome === true) return { value: raw };\n return fail(\"custom-failed\", typeof outcome === \"string\" && outcome !== \"\" ? outcome : `${name} failed custom validation`);\n }\n }\n}\n\n/**\n * Validate environment values against a schema.\n *\n * Messages never contain the offending value. An empty value is treated the\n * same as a missing one. Variables not mentioned in the schema are ignored.\n */\nexport function validateEnv(schema: Schema, env: Env = process.env): ValidationResult {\n const values: ValidationResult[\"values\"] = {};\n const errors: ValidationIssue[] = [];\n\n for (const [name, field] of Object.entries(schema)) {\n const raw = env[name];\n if (raw === undefined || raw === \"\") {\n if (field.default !== undefined) {\n values[name] = field.default;\n } else if (isRequired(field)) {\n errors.push({ variable: name, code: \"missing-required\", message: `${name} is required but not set` });\n }\n continue;\n }\n const parsed = parseOne(name, field, raw);\n if (\"error\" in parsed) errors.push(parsed.error);\n else values[name] = parsed.value;\n }\n return { success: errors.length === 0, values, errors };\n}\n\nexport class EnvValidationError extends Error {\n readonly errors: ValidationIssue[];\n\n constructor(errors: ValidationIssue[]) {\n super(`Invalid environment variables:\\n${errors.map((e) => ` - ${e.message}`).join(\"\\n\")}`);\n this.name = \"EnvValidationError\";\n this.errors = errors;\n }\n}\n\ntype FieldValue<F extends SchemaField> = F[\"type\"] extends \"number\" | \"integer\"\n ? number\n : F[\"type\"] extends \"boolean\"\n ? boolean\n : F extends { values: readonly (infer V)[] }\n ? V\n : string;\n\n/** The typed result of validating a schema. Optional variables without a default may be undefined. */\nexport type InferEnv<S extends Schema> = {\n [K in keyof S]: S[K] extends { required: false }\n ? S[K] extends { default: string | number | boolean }\n ? FieldValue<S[K]>\n : FieldValue<S[K]> | undefined\n : FieldValue<S[K]>;\n};\n\n/** Identity helper that preserves literal types so `assertEnv` can infer a precise result. */\nexport function defineSchema<S extends Schema>(schema: S): S {\n return schema;\n}\n\n/**\n * Validate at application startup and return typed values, or throw an\n * EnvValidationError that lists every problem (without values).\n */\nexport function assertEnv<S extends Schema>(schema: S, env: Env = process.env): InferEnv<S> {\n const result = validateEnv(schema, env);\n if (!result.success) throw new EnvValidationError(result.errors);\n return result.values as InferEnv<S>;\n}\n","import { mergedEnvironment, type ProjectContext } from \"../core/project\";\nimport { validateEnv } from \"../core/validator\";\nimport type { RawIssue } from \"../types\";\n\n/**\n * Validate the merged environment against the configured schema.\n *\n * `skip` holds variables that other analyzers already reported as missing or\n * empty, so the same problem is not reported twice.\n */\nexport function findSchemaIssues(project: ProjectContext, skip: Set<string>): RawIssue[] {\n const schema = project.schema;\n if (schema === undefined) return [];\n\n const { values, origin } = mergedEnvironment(project);\n const hasInput = project.sourceFiles.length > 0 || Object.keys(project.env).length > 0;\n if (!hasInput) {\n return [\n {\n code: \"validation-skipped\",\n severity: \"info\",\n message: \"Schema validation was skipped because no environment files were found\",\n recommendation: \"Create the env file, pass --file, or use --process-env to validate the process environment.\",\n },\n ];\n }\n\n const issues: RawIssue[] = [];\n for (const error of validateEnv(schema, values).errors) {\n if (project.isIgnored(error.variable)) continue;\n if (error.code === \"missing-required\" && skip.has(error.variable)) continue;\n const where = origin.get(error.variable);\n const issue: RawIssue = {\n code: `schema-${error.code}`,\n rule: \"validation\",\n variable: error.variable,\n message: error.message,\n recommendation:\n error.code === \"missing-required\"\n ? `Set ${error.variable} in your environment, or mark it as required: false (or give it a default) in the schema.`\n : `Fix the value of ${error.variable} or update the schema if the rule is wrong.`,\n };\n if (where) {\n issue.file = where.file;\n issue.line = where.line;\n }\n issues.push(issue);\n }\n return issues;\n}\n","import { promises as fs } from \"node:fs\";\nimport path from \"node:path\";\nimport { globToRegexSource } from \"./glob\";\n\ninterface GitRule {\n negated: boolean;\n dirOnly: boolean;\n regex: RegExp;\n}\n\n/** Parse the lines of a .gitignore file into rules. */\nexport function parseGitignore(text: string): GitRule[] {\n const rules: GitRule[] = [];\n for (const rawLine of text.replace(/\\r\\n?/g, \"\\n\").split(\"\\n\")) {\n let line = rawLine.replace(/(?<!\\\\)\\s+$/, \"\");\n if (line === \"\" || line.startsWith(\"#\")) continue;\n\n let negated = false;\n if (line.startsWith(\"!\")) {\n negated = true;\n line = line.slice(1);\n } else if (line.startsWith(\"\\\\#\") || line.startsWith(\"\\\\!\")) {\n line = line.slice(1);\n }\n\n let dirOnly = false;\n if (line.endsWith(\"/\")) {\n dirOnly = true;\n line = line.slice(0, -1);\n }\n if (line === \"\") continue;\n\n const anchored = line.includes(\"/\");\n if (line.startsWith(\"/\")) line = line.slice(1);\n\n const body = globToRegexSource(line);\n // A rule also matches everything inside a matched directory.\n const tail = dirOnly ? \"/.*\" : \"(?:/.*)?\";\n const head = anchored ? \"^\" : \"^(?:.*/)?\";\n rules.push({ negated, dirOnly, regex: new RegExp(`${head}${body}${tail}$`) });\n }\n return rules;\n}\n\n/** Last matching rule wins. Returns undefined when no rule matches. */\nfunction evaluate(rules: GitRule[], relativePath: string): boolean | undefined {\n let result: boolean | undefined;\n for (const rule of rules) {\n if (rule.regex.test(relativePath)) result = !rule.negated;\n }\n return result;\n}\n\nasync function findGitRoot(start: string): Promise<string | undefined> {\n let dir = start;\n for (;;) {\n try {\n await fs.stat(path.join(dir, \".git\"));\n return dir;\n } catch {\n // keep walking up\n }\n const parent = path.dirname(dir);\n if (parent === dir) return undefined;\n dir = parent;\n }\n}\n\nasync function readIfExists(file: string): Promise<string | undefined> {\n try {\n return await fs.readFile(file, \"utf8\");\n } catch {\n return undefined;\n }\n}\n\nexport type GitStatus = \"ignored\" | \"not-ignored\" | \"no-repo\";\n\nexport interface GitChecker {\n status(absoluteFile: string): Promise<GitStatus>;\n}\n\n/**\n * Create a checker that tells whether files are covered by .gitignore.\n *\n * Reads `.gitignore` files from the repository root down to the file's\n * directory, plus `.git/info/exclude`. It does not run git, and does not\n * consult global ignore files, so a file ignored only globally is reported as\n * not ignored.\n */\nexport function createGitChecker(cwd: string): GitChecker {\n let rootPromise: Promise<string | undefined> | undefined;\n const cache = new Map<string, Promise<GitRule[]>>();\n\n const rulesFor = (file: string): Promise<GitRule[]> => {\n let cached = cache.get(file);\n if (!cached) {\n cached = readIfExists(file).then((text) => (text === undefined ? [] : parseGitignore(text)));\n cache.set(file, cached);\n }\n return cached;\n };\n\n return {\n async status(absoluteFile) {\n rootPromise ??= findGitRoot(cwd);\n const root = await rootPromise;\n if (root === undefined) return \"no-repo\";\n\n const rel = path.relative(root, absoluteFile).split(path.sep).join(\"/\");\n if (rel.startsWith(\"..\")) return \"no-repo\";\n\n let ignored: boolean | undefined;\n const exclude = evaluate(await rulesFor(path.join(root, \".git\", \"info\", \"exclude\")), rel);\n if (exclude !== undefined) ignored = exclude;\n\n const parts = rel.split(\"/\");\n let dir = root;\n for (let i = 0; i < parts.length; i++) {\n const sub = parts.slice(i).join(\"/\");\n const result = evaluate(await rulesFor(path.join(dir, \".gitignore\")), sub);\n if (result !== undefined) ignored = result;\n if (i < parts.length - 1) dir = path.join(dir, parts[i] as string);\n }\n return ignored ? \"ignored\" : \"not-ignored\";\n },\n };\n}\n","import { parseEnv } from \"./parser\";\nimport type { VariableInfo } from \"./variables\";\n\nconst CATEGORIES = [\n \"Database configuration\",\n \"Authentication\",\n \"External services\",\n \"Application\",\n \"Client-exposed variables\",\n \"Other\",\n] as const;\n\nexport type Category = (typeof CATEGORIES)[number];\n\nconst DATABASE =\n /(DATABASE|(^|_)DB(_|$)|POSTGRES|MYSQL|MONGO|REDIS|SQLITE|PRISMA|PGHOST|PGUSER|PGPASSWORD|PGDATABASE|PGPORT)/i;\nconst AUTH = /(JWT|AUTH|SESSION|OAUTH|COOKIE|CSRF|SALT|BCRYPT|(^|_)SECRET$)/i;\nconst EXTERNAL =\n /(STRIPE|AWS|(^|_)S3(_|$)|SENDGRID|TWILIO|SMTP|MAIL|SENTRY|OPENAI|ANTHROPIC|GITHUB|GOOGLE|FIREBASE|CLOUDINARY|SLACK|DISCORD|PAYPAL|MAPBOX|ALGOLIA|DATADOG|VERCEL|NETLIFY|AZURE|GCP|(^|_)R2(_|$)|SUPABASE)/i;\nconst APPLICATION =\n /(^PORT$|HOST|NODE_ENV|^APP_|(^|_)URL$|ORIGIN|CORS|LOG|DEBUG|(^|_)ENV$)/i;\n\n/** Group a variable for the generated template. */\nexport function categorize(\n name: string,\n publicPrefixes: readonly string[],\n): Category {\n if (publicPrefixes.some((prefix) => name.startsWith(prefix)))\n return \"Client-exposed variables\";\n if (DATABASE.test(name)) return \"Database configuration\";\n if (AUTH.test(name)) return \"Authentication\";\n if (EXTERNAL.test(name)) return \"External services\";\n if (APPLICATION.test(name)) return \"Application\";\n return \"Other\";\n}\n\n/** Comment lines describing a variable, taken from the schema when there is one. */\nfunction describe(info: VariableInfo): string[] {\n const field = info.schema;\n if (field === undefined) return [];\n const lines: string[] = [];\n if (field.description) lines.push(`# ${field.description}`);\n\n const facts: string[] = [\n field.type === \"enum\" && field.values\n ? `one of: ${field.values.join(\", \")}`\n : field.type,\n ];\n facts.push(\n field.default !== undefined || field.required === false\n ? \"optional\"\n : \"required\",\n );\n // Defaults of secrets are never written out.\n if (field.default !== undefined && !field.secret)\n facts.push(`default: ${String(field.default)}`);\n lines.push(`# ${facts.join(\", \")}`);\n return lines;\n}\n\nfunction renderVariable(info: VariableInfo): string[] {\n return [...describe(info), `${info.name}=`];\n}\n\n/** Render a fresh template. Values are always empty. */\nexport function renderExample(\n variables: readonly VariableInfo[],\n publicPrefixes: readonly string[],\n): string {\n if (variables.length === 0) return \"\";\n const groups = new Map<Category, VariableInfo[]>();\n for (const info of variables) {\n const category = categorize(info.name, publicPrefixes);\n const list = groups.get(category);\n if (list) list.push(info);\n else groups.set(category, [info]);\n }\n\n const blocks: string[] = [];\n for (const category of CATEGORIES) {\n const list = groups.get(category);\n if (!list) continue;\n blocks.push([`# ${category}`, ...list.flatMap(renderVariable)].join(\"\\n\"));\n }\n return blocks.join(\"\\n\\n\") + \"\\n\";\n}\n\nexport interface MergeResult {\n content: string;\n /** Names that were appended. */\n added: string[];\n}\n\n/**\n * Add variables that an existing template lacks, leaving everything already\n * in it (comments, order, values) untouched.\n */\nexport function renderMerge(\n existing: string,\n variables: readonly VariableInfo[],\n): MergeResult {\n const present = new Set(parseEnv(existing).entries.map((entry) => entry.key));\n const missing = variables.filter((info) => !present.has(info.name));\n if (missing.length === 0) return { content: existing, added: [] };\n\n const base = existing.replace(/\\s+$/, \"\");\n const addition = [\n \"# Added by envclinic\",\n ...missing.flatMap(renderVariable),\n ].join(\"\\n\");\n return {\n content: `${base}${base === \"\" ? \"\" : \"\\n\\n\"}${addition}\\n`,\n added: missing.map((info) => info.name),\n };\n}\n","import type { FrameworkInfo } from \"../frameworks/detector\";\nimport { isRequired } from \"./validator\";\nimport type { VariableInfo } from \"./variables\";\n\n/** First line of every generated file. Used to recognise files envclinic may overwrite. */\nexport const GENERATED_MARKER = \"// Generated by envclinic\";\n\n/**\n * Declared by @types/node or by frameworks themselves, so declaring them\n * again can cause conflicting-declaration errors. Skipped unless the schema\n * describes them.\n */\nconst RESERVED = new Set([\"NODE_ENV\", \"TZ\"]);\n\nfunction isRequiredVariable(\n info: VariableInfo,\n hasSource: boolean,\n hasExample: boolean,\n): boolean {\n if (info.schema) return isRequired(info.schema);\n if (hasSource && hasExample) return info.inSource && info.inExample;\n if (hasSource) return info.inSource;\n if (hasExample) return info.inExample;\n return false;\n}\n\nfunction tsType(info: VariableInfo): string {\n const field = info.schema;\n if (field?.type === \"enum\" && field.values && field.values.length > 0) {\n return field.values.map((value) => JSON.stringify(value)).join(\" | \");\n }\n // Environment values are always strings at runtime, whatever the schema type.\n return \"string\";\n}\n\nfunction comment(info: VariableInfo, indent: string): string[] {\n const field = info.schema;\n if (field === undefined) return [];\n const parts: string[] = [];\n if (field.description) parts.push(field.description.replace(/\\*\\//g, \"*\\\\/\"));\n if (\n field.type === \"number\" ||\n field.type === \"integer\" ||\n field.type === \"boolean\"\n ) {\n parts.push(`Parse as ${field.type} (the value is a string at runtime).`);\n }\n return parts.length === 0 ? [] : [`${indent}/** ${parts.join(\" \")} */`];\n}\n\nexport interface TypeGenerationInput {\n variables: readonly VariableInfo[];\n framework: FrameworkInfo;\n hasSourceFiles: boolean;\n hasExample: boolean;\n}\n\n/**\n * Render TypeScript declarations for the project's environment variables.\n *\n * Output contains names and types only, never values. A variable is required\n * when the schema says so; without a schema it is required when it is\n * declared in the env file(s) and documented in the example file.\n */\nexport function renderTypes(input: TypeGenerationInput): string {\n const { framework } = input;\n const useImportMeta = framework.id === \"vite\" || framework.id === \"astro\";\n\n const processEnv: string[] = [];\n const importMetaEnv: string[] = [];\n\n for (const info of input.variables) {\n if (RESERVED.has(info.name) && !info.schema) continue;\n const required = isRequiredVariable(\n info,\n input.hasSourceFiles,\n input.hasExample,\n );\n const isPublic = framework.publicPrefixes.some((prefix) =>\n info.name.startsWith(prefix),\n );\n\n if (useImportMeta && isPublic) {\n importMetaEnv.push(\n ...comment(info, \" \"),\n ` readonly ${info.name}${required ? \"\" : \"?\"}: ${tsType(info)};`,\n );\n } else {\n processEnv.push(\n ...comment(info, \" \"),\n ` ${info.name}${required ? \"\" : \"?\"}: ${tsType(info)};`,\n );\n }\n }\n\n const out: string[] = [\n `${GENERATED_MARKER}. Do not edit by hand; run \\`npx envclinic types\\` to regenerate.`,\n \"// These declarations improve editor autocomplete only. They do not validate values at runtime.\",\n ];\n if (processEnv.length > 0) {\n out.push(\n \"\",\n \"declare namespace NodeJS {\",\n \" interface ProcessEnv {\",\n ...processEnv,\n \" }\",\n \"}\",\n );\n }\n if (importMetaEnv.length > 0) {\n out.push(\n \"\",\n \"interface ImportMetaEnv {\",\n ...importMetaEnv,\n \"}\",\n \"\",\n \"interface ImportMeta {\",\n \" readonly env: ImportMetaEnv;\",\n \"}\",\n );\n }\n if (processEnv.length === 0 && importMetaEnv.length === 0) {\n out.push(\"\", \"export {};\");\n }\n return out.join(\"\\n\") + \"\\n\";\n}\n","import { isBuiltinVariable } from \"../config/defaults\";\nimport type { SchemaField } from \"../types\";\nimport type { UsageData } from \"../analyzers/unused\";\nimport type { ProjectContext } from \"./project\";\n\nexport interface VariableInfo {\n name: string;\n inSource: boolean;\n inExample: boolean;\n usedInCode: boolean;\n schema?: SchemaField;\n}\n\n/**\n * Collect every variable the project knows about: declared in env files,\n * documented in the example, described by the schema, or read in source code.\n *\n * Variables only seen in code that look platform-provided (NODE_ENV, CI...)\n * are left out. Names are returned sorted.\n */\nexport function collectVariables(\n project: ProjectContext,\n usage: UsageData | undefined,\n exclude: (name: string) => boolean = () => false,\n): VariableInfo[] {\n const map = new Map<string, VariableInfo>();\n const get = (name: string): VariableInfo => {\n let info = map.get(name);\n if (!info) {\n info = { name, inSource: false, inExample: false, usedInCode: false };\n map.set(name, info);\n }\n return info;\n };\n\n for (const file of project.sourceFiles) for (const key of file.keys) get(key).inSource = true;\n if (project.example) for (const key of project.example.keys) get(key).inExample = true;\n for (const [name, field] of Object.entries(project.schema ?? {})) get(name).schema = field;\n\n if (usage) {\n for (const name of usage.references.keys()) {\n const existing = map.get(name);\n if (!existing && isBuiltinVariable(name)) continue;\n get(name).usedInCode = true;\n }\n }\n\n return [...map.values()]\n .filter((info) => !project.isIgnored(info.name) && !exclude(info.name))\n .sort((a, b) => a.name.localeCompare(b.name));\n}\n","import { DEFAULT_EXAMPLE_OUTPUT, DEFAULT_TYPES_OUTPUT } from \"../config/defaults\";\nimport type { UsageData } from \"../analyzers/unused\";\nimport { createNameMatcher } from \"./glob\";\nimport { renderExample } from \"./generator\";\nimport type { ProjectContext } from \"./project\";\nimport { renderTypes } from \"./type-generator\";\nimport { collectVariables, type VariableInfo } from \"./variables\";\n\nexport function typesOutputPath(project: ProjectContext, override?: string): string {\n return override ?? project.config.types?.output ?? DEFAULT_TYPES_OUTPUT;\n}\n\nexport function exampleOutputPath(project: ProjectContext, override?: string): string {\n return override ?? project.config.generate?.output ?? DEFAULT_EXAMPLE_OUTPUT;\n}\n\n/** The variables a generated `.env.example` should list. */\nexport function exampleVariables(project: ProjectContext, usage: UsageData | undefined, exclude: string[] = []): VariableInfo[] {\n const matcher = createNameMatcher([...(project.config.generate?.exclude ?? []), ...exclude]);\n return collectVariables(project, usage, matcher);\n}\n\nexport function buildExampleContent(project: ProjectContext, usage: UsageData | undefined, exclude: string[] = []): string {\n return renderExample(exampleVariables(project, usage, exclude), project.framework.publicPrefixes);\n}\n\n/** The TypeScript declarations for the project. */\nexport function buildTypesContent(project: ProjectContext, usage: UsageData | undefined): string {\n return renderTypes({\n variables: collectVariables(project, usage),\n framework: project.framework,\n hasSourceFiles: project.sourceFiles.length > 0,\n hasExample: project.example !== undefined,\n });\n}\n","import { findDuplicates } from \"../analyzers/duplicates\";\nimport { findEmpty } from \"../analyzers/empty\";\nimport { findMissing, findUndocumented } from \"../analyzers/missing\";\nimport {\n analyzeCodeSecrets,\n analyzeEnvFileSecrets,\n} from \"../analyzers/security\";\nimport { findSyntaxIssues } from \"../analyzers/syntax\";\nimport {\n findUndeclared,\n findUnused,\n type UsageData,\n} from \"../analyzers/unused\";\nimport { findSchemaIssues } from \"../analyzers/validation\";\nimport type {\n AuditIssue,\n AuditOptions,\n AuditResult,\n RawIssue,\n Severity,\n} from \"../types\";\nimport { createGitChecker } from \"./gitignore\";\nimport { createNameMatcher, matchesGlob } from \"./glob\";\nimport { buildTypesContent, typesOutputPath } from \"./outputs\";\nimport { allFiles, loadProject, type ProjectContext } from \"./project\";\nimport { readEnvFile } from \"./files\";\nimport { buildPatterns } from \"./secrets-detector\";\nimport { extractReferences, scanSources, type SourceLocation } from \"./scanner\";\n\nconst SEVERITY_RANK: Record<Severity, number> = {\n error: 0,\n warning: 1,\n info: 2,\n};\n\n/** Issues that only matter when the \"files\" check is selected. */\nconst FILE_PRESENCE_CODES = new Set([\n \"source-file-missing\",\n \"example-file-missing\",\n \"no-env-files\",\n \"non-utf8-file\",\n]);\n\nexport interface ScanOutcome {\n usage: UsageData;\n /** Credentials found in source code. */\n secrets: RawIssue[];\n}\n\n/**\n * Read the project's source files once, collecting environment variable\n * references and (optionally) hardcoded credentials.\n */\nexport async function scanProject(\n project: ProjectContext,\n options: { secrets: boolean },\n): Promise<ScanOutcome> {\n const patterns = buildPatterns(project.config.secrets?.patterns);\n const ignoreFiles = project.config.secrets?.ignoreFiles ?? [];\n const references = new Map<string, SourceLocation[]>();\n const dynamic: SourceLocation[] = [];\n const secrets: RawIssue[] = [];\n\n const summary = await scanSources(\n project.cwd,\n project.scanOptions,\n (file) => {\n const extracted = extractReferences(file.content);\n for (const { name, line } of extracted.names) {\n const list = references.get(name);\n const location = { file: file.path, line };\n if (list) list.push(location);\n else references.set(name, [location]);\n }\n for (const { line } of extracted.dynamic)\n dynamic.push({ file: file.path, line });\n\n if (\n options.secrets &&\n !ignoreFiles.some((glob) => matchesGlob(glob, file.path))\n ) {\n secrets.push(...analyzeCodeSecrets(file.path, file.content, patterns));\n }\n },\n );\n\n return {\n usage: { filesScanned: summary.filesScanned, references, dynamic },\n secrets,\n };\n}\n\nfunction normalize(text: string): string {\n return text.replace(/\\r\\n/g, \"\\n\");\n}\n\nasync function checkTypesFile(\n project: ProjectContext,\n usage: UsageData | undefined,\n): Promise<RawIssue[]> {\n const output = typesOutputPath(project);\n const expected = buildTypesContent(project, usage);\n const current = await readEnvFile(project.cwd, output);\n\n if (current.status === \"missing\") {\n return [\n {\n code: \"types-missing\",\n rule: \"types\",\n severity: \"warning\",\n file: output,\n message: `types.enabled is set but ${output} does not exist`,\n recommendation: \"Run `npx envclinic types` to generate it.\",\n },\n ];\n }\n if (current.status !== \"ok\") {\n return [\n {\n code: \"types-unreadable\",\n rule: \"types\",\n severity: \"warning\",\n file: output,\n message: `${output} could not be checked (${current.status === \"unsafe\" ? current.reason : current.status})`,\n },\n ];\n }\n if (normalize(current.content) !== expected) {\n return [\n {\n code: \"types-outdated\",\n rule: \"types\",\n severity: \"warning\",\n file: output,\n message: `${output} is out of date with your environment variables`,\n recommendation: \"Run `npx envclinic types` to regenerate it.\",\n },\n ];\n }\n return [];\n}\n\n/** Run the selected checks against a loaded project and collect raw issues. */\nexport async function collectIssues(\n project: ProjectContext,\n options: Pick<AuditOptions, \"scan\" | \"codeSecrets\"> = {},\n): Promise<{ raw: RawIssue[]; usage?: UsageData }> {\n const { checks } = project;\n const raw: RawIssue[] = project.loadIssues.filter(\n (issue) => checks.has(\"files\") || !FILE_PRESENCE_CODES.has(issue.code),\n );\n const files = allFiles(project);\n\n if (checks.has(\"files\")) {\n for (const file of files) {\n raw.push(\n ...findSyntaxIssues(file.path, file.parsed),\n ...findDuplicates(file.path, file.entries),\n );\n }\n for (const file of project.sourceFiles) {\n raw.push(...findEmpty(file.path, file.entries));\n if (project.example) {\n raw.push(\n ...findMissing(\n project.example.path,\n project.example.keys,\n file.path,\n file.keys,\n ),\n ...findUndocumented(\n project.example.path,\n project.example.keys,\n file.path,\n file.keys,\n ),\n );\n }\n }\n }\n\n const scanEnabled = options.scan !== false;\n const codeSecrets =\n scanEnabled && options.codeSecrets !== false && checks.has(\"secrets\");\n const needsUsage =\n scanEnabled &&\n (checks.has(\"unused\") ||\n (checks.has(\"types\") && project.config.types?.enabled === true));\n let usage: UsageData | undefined;\n let codeSecretIssues: RawIssue[] = [];\n if (needsUsage || codeSecrets) {\n const outcome = await scanProject(project, { secrets: codeSecrets });\n usage = outcome.usage;\n codeSecretIssues = outcome.secrets;\n }\n\n if (checks.has(\"unused\") && usage) {\n raw.push(...findUnused(project, usage), ...findUndeclared(project, usage));\n }\n\n if (checks.has(\"secrets\")) {\n const git = createGitChecker(project.cwd);\n const securityOptions = {\n patterns: buildPatterns(project.config.secrets?.patterns),\n isAllowed: createNameMatcher(project.config.secrets?.allow ?? []),\n isIgnored: project.isIgnored,\n publicPrefixes: project.framework.publicPrefixes,\n };\n // A variable that is both in .env and the example is exposed once, not twice.\n const reportedPublic = new Set<string>();\n for (const file of files) {\n for (const issue of analyzeEnvFileSecrets(\n file,\n await git.status(file.absolute),\n securityOptions,\n )) {\n if (issue.code === \"public-secret\" && issue.variable !== undefined) {\n if (reportedPublic.has(issue.variable)) continue;\n reportedPublic.add(issue.variable);\n }\n raw.push(issue);\n }\n }\n raw.push(...codeSecretIssues);\n }\n\n if (checks.has(\"validation\")) {\n const already = new Set(\n raw\n .filter(\n (issue) =>\n issue.code === \"missing-variable\" ||\n issue.code === \"empty-variable\",\n )\n .map((issue) => issue.variable as string),\n );\n raw.push(...findSchemaIssues(project, already));\n }\n\n if (\n checks.has(\"types\") &&\n project.config.types?.enabled === true &&\n scanEnabled\n ) {\n raw.push(...(await checkTypesFile(project, usage)));\n }\n\n return usage === undefined ? { raw } : { raw, usage };\n}\n\n/** Apply rule levels, ignores and strict mode to raw issues. */\nexport function resolveIssues(\n project: ProjectContext,\n raw: RawIssue[],\n): AuditIssue[] {\n const issues: AuditIssue[] = [];\n for (const item of raw) {\n if (item.variable !== undefined && project.isIgnored(item.variable))\n continue;\n\n let severity: Severity;\n if (item.rule !== undefined) {\n const level = project.rules[item.rule];\n if (level === \"off\") continue;\n // The rule level can lower an issue's natural severity but never raise it.\n const natural = item.severity ?? \"error\";\n severity =\n SEVERITY_RANK[level] > SEVERITY_RANK[natural] ? level : natural;\n } else {\n severity = item.severity ?? \"info\";\n }\n if (project.strict && severity === \"warning\") severity = \"error\";\n\n const { rule: _rule, severity: _severity, ...rest } = item;\n issues.push({ ...rest, severity });\n }\n return issues.sort(\n (a, b) => SEVERITY_RANK[a.severity] - SEVERITY_RANK[b.severity],\n );\n}\n\n/**\n * Audit the environment of a project.\n *\n * Runs all checks by default: env file comparison (missing, undocumented,\n * empty, duplicate, invalid names), potentially unused and undeclared\n * variables, secret detection, schema validation and types freshness.\n * Use `checks` to run a subset.\n */\nexport async function audit(options: AuditOptions = {}): Promise<AuditResult> {\n return auditProject(await loadProject(options), options);\n}\n\n/** Run the selected checks against an already loaded project. */\nexport async function auditProject(\n project: ProjectContext,\n options: Pick<AuditOptions, \"scan\" | \"codeSecrets\"> = {},\n): Promise<AuditResult> {\n const { raw, usage } = await collectIssues(project, options);\n const issues = resolveIssues(project, raw);\n\n const files = allFiles(project)\n .map((file) => ({\n path: file.path,\n role: file.role,\n variables: file.keys.size,\n }))\n .sort(\n (a, b) => Number(a.role === \"example\") - Number(b.role === \"example\"),\n );\n const variables = new Set(\n allFiles(project).flatMap((file) => [...file.keys]),\n );\n\n const errors = issues.filter((issue) => issue.severity === \"error\").length;\n const warnings = issues.filter(\n (issue) => issue.severity === \"warning\",\n ).length;\n\n const result: AuditResult = {\n success: errors === 0,\n summary: {\n filesScanned: files.length,\n sourceFilesScanned: usage?.filesScanned ?? 0,\n variablesFound: variables.size,\n errors,\n warnings,\n infos: issues.length - errors - warnings,\n },\n files,\n issues,\n framework: {\n id: project.framework.id,\n name: project.framework.name,\n evidence: project.framework.evidence,\n },\n };\n if (project.configFile !== undefined) result.configFile = project.configFile;\n return result;\n}\n","import { promises as fs } from \"node:fs\";\nimport path from \"node:path\";\nimport { decodeText, displayPath, isInside } from \"./files\";\n\nexport type WriteStatus = \"written\" | \"unchanged\" | \"refused\";\n\nexport interface WriteResult {\n status: WriteStatus;\n /** Display path of the target. */\n path: string;\n /** Why the write was refused. */\n reason?: string;\n}\n\nconst TEMPLATE_NAME = /(example|sample|template|dist|defaults?)/i;\n\n/**\n * Real env files hold actual values (`.env`, `.env.local`, `prod.env`...).\n * envclinic never writes to them; only template names are allowed.\n */\nexport function isProtectedEnvFileName(file: string): boolean {\n const base = path.basename(file);\n const looksLikeEnv = /^\\.env(\\.|$)/i.test(base) || /\\.env$/i.test(base);\n return looksLikeEnv && !TEMPLATE_NAME.test(base);\n}\n\n/** Resolve a target path to an absolute one, or explain why it is not allowed. */\nexport async function resolveWriteTarget(\n cwd: string,\n relative: string,\n): Promise<{ ok: true; absolute: string } | { ok: false; reason: string }> {\n const absolute = path.resolve(cwd, relative);\n if (!isInside(cwd, absolute) || absolute === path.resolve(cwd)) {\n return { ok: false, reason: \"the path is outside the project directory\" };\n }\n if (isProtectedEnvFileName(absolute)) {\n return {\n ok: false,\n reason:\n \"envclinic never writes to real environment files; choose a template name such as .env.example\",\n };\n }\n\n // The nearest existing ancestor must really be inside the project (no symlink escapes).\n const realRoot = await fs.realpath(cwd);\n let ancestor = path.dirname(absolute);\n for (;;) {\n try {\n const real = await fs.realpath(ancestor);\n if (!isInside(realRoot, real))\n return {\n ok: false,\n reason: \"the directory resolves outside the project directory\",\n };\n break;\n } catch {\n const parent = path.dirname(ancestor);\n if (parent === ancestor)\n return { ok: false, reason: \"the directory could not be resolved\" };\n ancestor = parent;\n }\n }\n return { ok: true, absolute };\n}\n\nexport async function readExisting(\n absolute: string,\n): Promise<string | undefined> {\n try {\n const stat = await fs.lstat(absolute);\n if (!stat.isFile()) return undefined;\n return decodeText(await fs.readFile(absolute)).text;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Write a file inside the project safely: the path must stay within the\n * project, symlinks and real env files are refused, existing files are only\n * replaced when `overwrite` is true, and the content is written to a temporary\n * file first and renamed into place so a crash never leaves a half-written file.\n */\nexport async function writeProjectFile(\n cwd: string,\n relative: string,\n content: string,\n options: { overwrite: boolean },\n): Promise<WriteResult> {\n const shown = displayPath(cwd, path.resolve(cwd, relative));\n const target = await resolveWriteTarget(cwd, relative);\n if (!target.ok)\n return { status: \"refused\", path: shown, reason: target.reason };\n const { absolute } = target;\n\n let exists = false;\n try {\n const stat = await fs.lstat(absolute);\n exists = true;\n if (stat.isSymbolicLink())\n return {\n status: \"refused\",\n path: shown,\n reason: \"the target is a symbolic link\",\n };\n if (!stat.isFile())\n return {\n status: \"refused\",\n path: shown,\n reason: \"the target is not a regular file\",\n };\n } catch {\n // does not exist yet\n }\n\n if (exists) {\n const current = await fs.readFile(absolute, \"utf8\");\n if (current.replace(/\\r\\n/g, \"\\n\") === content)\n return { status: \"unchanged\", path: shown };\n if (!options.overwrite)\n return {\n status: \"refused\",\n path: shown,\n reason: \"the file already exists\",\n };\n }\n\n await fs.mkdir(path.dirname(absolute), { recursive: true });\n const temporary = `${absolute}.${process.pid}.${Date.now()}.tmp`;\n try {\n await fs.writeFile(temporary, content, { flag: \"wx\" });\n await fs.rename(temporary, absolute);\n } catch (error) {\n await fs.rm(temporary, { force: true });\n return {\n status: \"refused\",\n path: shown,\n reason: `could not write the file (${(error as NodeJS.ErrnoException).code ?? \"unknown error\"})`,\n };\n }\n return { status: \"written\", path: shown };\n}\n","import type { AuditIssue, AuditResult } from \"../../types\";\n\nfunction escapeData(text: string): string {\n return text.replace(/%/g, \"%25\").replace(/\\r/g, \"%0D\").replace(/\\n/g, \"%0A\");\n}\n\nfunction escapeProperty(text: string): string {\n return escapeData(text).replace(/:/g, \"%3A\").replace(/,/g, \"%2C\");\n}\n\nconst LEVEL = { error: \"error\", warning: \"warning\", info: \"notice\" } as const;\n\nexport function formatAnnotation(issue: AuditIssue): string {\n const properties: string[] = [];\n if (issue.file !== undefined) {\n properties.push(`file=${escapeProperty(issue.file)}`);\n if (issue.line !== undefined) properties.push(`line=${issue.line}`);\n }\n properties.push(`title=${escapeProperty(`envclinic: ${issue.code}`)}`);\n return `::${LEVEL[issue.severity]} ${properties.join(\",\")}::${escapeData(issue.message)}`;\n}\n\n/** GitHub Actions workflow commands, one annotation per issue. Messages never contain values. */\nexport function formatGithub(result: AuditResult): string {\n return result.issues.map((issue) => formatAnnotation(issue) + \"\\n\").join(\"\");\n}\n","import { createColors } from \"picocolors\";\nimport type { AuditIssue, AuditResult, Severity } from \"../../types\";\n\nexport interface TerminalOptions {\n color: boolean;\n /** Only show errors and the summary line. */\n quiet: boolean;\n}\n\ninterface Section {\n title: string;\n match: (code: string) => boolean;\n security?: boolean;\n}\n\nconst oneOf =\n (...codes: string[]) =>\n (code: string) =>\n codes.includes(code);\n\nconst SECTIONS: Section[] = [\n {\n title: \"Files\",\n match: oneOf(\n \"no-env-files\",\n \"source-file-missing\",\n \"example-file-missing\",\n \"unsafe-path\",\n \"file-too-large\",\n \"file-unreadable\",\n \"non-utf8-file\",\n ),\n },\n { title: \"Missing variables\", match: oneOf(\"missing-variable\") },\n { title: \"Undocumented variables\", match: oneOf(\"undocumented-variable\") },\n { title: \"Empty variables\", match: oneOf(\"empty-variable\") },\n { title: \"Duplicate declarations\", match: oneOf(\"duplicate-variable\") },\n {\n title: \"Invalid names and syntax\",\n match: oneOf(\n \"invalid-variable-name\",\n \"malformed-line\",\n \"unterminated-quote\",\n ),\n },\n {\n title: \"Potentially unused variables\",\n match: oneOf(\"unused-variable\", \"dynamic-env-access\"),\n },\n { title: \"Undeclared variables\", match: oneOf(\"undeclared-variable\") },\n {\n title: \"Security audit\",\n security: true,\n match: oneOf(\n \"exposed-credential\",\n \"weak-secret\",\n \"public-secret\",\n \"env-file-not-ignored\",\n \"secret-in-example\",\n ),\n },\n {\n title: \"Schema validation\",\n match: (code) =>\n code.startsWith(\"schema-\") || code === \"validation-skipped\",\n },\n {\n title: \"TypeScript declarations\",\n match: oneOf(\"types-missing\", \"types-outdated\", \"types-unreadable\"),\n },\n];\n\nconst BOX_WIDTH = 38;\n\nfunction plural(count: number, word: string): string {\n return `${count} ${word}${count === 1 ? \"\" : \"s\"}`;\n}\n\nfunction center(text: string, width: number): string {\n const total = Math.max(0, width - text.length);\n const left = Math.floor(total / 2);\n return \" \".repeat(left) + text + \" \".repeat(total - left);\n}\n\nfunction header(): string[] {\n return [\n `╭${\"─\".repeat(BOX_WIDTH)}╮`,\n `│${center(\"ENV DOCTOR\", BOX_WIDTH)}│`,\n `│${center(\"Environment Configuration\", BOX_WIDTH)}│`,\n `╰${\"─\".repeat(BOX_WIDTH)}╯`,\n ];\n}\n\n/** Render an audit result for a terminal. Never includes variable values. */\nexport function formatTerminal(\n result: AuditResult,\n options: TerminalOptions,\n): string {\n const pc = createColors(options.color);\n const icon: Record<Severity, string> = {\n error: pc.red(\"✘\"),\n warning: pc.yellow(\"⚠\"),\n info: pc.cyan(\"ℹ\"),\n };\n const label: Record<Severity, string> = {\n error: pc.red(pc.bold(\"[CRITICAL]\")),\n warning: pc.yellow(pc.bold(\"[WARNING]\")),\n info: pc.cyan(pc.bold(\"[INFO]\")),\n };\n\n const { summary } = result;\n const lines: string[] = [];\n\n const summaryLine =\n summary.errors === 0 && summary.warnings === 0\n ? `${pc.green(\"✔\")} No problems found`\n : [\n plural(summary.errors, \"error\"),\n plural(summary.warnings, \"warning\"),\n ].join(\", \");\n\n if (options.quiet) {\n for (const issue of result.issues.filter((i) => i.severity === \"error\")) {\n lines.push(`${icon.error} ${issue.message}`);\n }\n lines.push(summaryLine);\n return lines.join(\"\\n\") + \"\\n\";\n }\n\n lines.push(...header(), \"\");\n\n if (result.framework) {\n lines.push(`${pc.green(\"✔\")} Framework detected: ${result.framework.name}`);\n lines.push(\"\");\n }\n\n if (result.files.length > 0) {\n lines.push(pc.bold(\"Files analyzed\"));\n for (const file of result.files) {\n lines.push(\n ` ${pc.green(\"✔\")} ${file.path} ${pc.dim(`(${file.role}, ${plural(file.variables, \"variable\")})`)}`,\n );\n }\n lines.push(\"\");\n }\n\n const claimed = new Set<AuditIssue>();\n const sections: Array<{\n title: string;\n issues: AuditIssue[];\n security: boolean;\n }> = [];\n for (const section of SECTIONS) {\n const issues = result.issues.filter((issue) => section.match(issue.code));\n issues.forEach((issue) => claimed.add(issue));\n if (issues.length > 0)\n sections.push({\n title: section.title,\n issues,\n security: section.security === true,\n });\n }\n const other = result.issues.filter((issue) => !claimed.has(issue));\n if (other.length > 0)\n sections.push({ title: \"Other\", issues: other, security: false });\n\n for (const section of sections) {\n lines.push(pc.bold(`${section.title} (${section.issues.length})`));\n for (const issue of section.issues) {\n if (section.security) {\n lines.push(` ${label[issue.severity]} ${issue.message}`);\n if (issue.file)\n lines.push(\n ` File: ${issue.file}${issue.line !== undefined ? `:${issue.line}` : \"\"}`,\n );\n if (issue.variable) lines.push(` Variable: ${issue.variable}`);\n if (issue.variable && issue.code !== \"env-file-not-ignored\")\n lines.push(\" Value: ********\");\n } else {\n lines.push(` ${icon[issue.severity]} ${issue.message}`);\n }\n if (issue.recommendation)\n lines.push(` ${pc.dim(`→ ${issue.recommendation}`)}`);\n }\n lines.push(\"\");\n }\n\n lines.push(pc.bold(\"Summary\"));\n const scanned =\n summary.sourceFilesScanned > 0\n ? `, ${plural(summary.sourceFilesScanned, \"source file\")} scanned`\n : \"\";\n lines.push(\n ` ${plural(summary.filesScanned, \"env file\")} analyzed, ${plural(summary.variablesFound, \"variable\")} found${scanned}`,\n );\n lines.push(` ${summaryLine}`);\n lines.push(\"\", pc.dim(\"Run envclinic audit --help for options.\"));\n\n return lines.join(\"\\n\") + \"\\n\";\n}\n","import type { AuditCheck, AuditOptions, AuditResult } from \"../../types\";\nimport type { IO } from \"../io\";\nimport { formatGithub } from \"../output/github\";\nimport { formatTerminal } from \"../output/terminal\";\n\n/** A mistake in how the CLI was invoked (exit code 2). */\nexport class UsageError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"UsageError\";\n }\n}\n\n/** Every option any command accepts, merged from the global and command level. */\nexport interface CliOptions {\n cwd?: string;\n config?: string;\n json?: boolean;\n format?: string;\n quiet?: boolean;\n verbose?: boolean;\n /** Commander sets this to false for --no-color. */\n color?: boolean;\n strict?: boolean;\n ci?: boolean;\n file?: string[];\n example?: string;\n ignore?: string[];\n /** Commander sets this to false for --no-scan. */\n scan?: boolean;\n envOnly?: boolean;\n dir?: string[];\n processEnv?: boolean;\n fix?: boolean;\n dryRun?: boolean;\n yes?: boolean;\n force?: boolean;\n merge?: boolean;\n output?: string;\n exclude?: string[];\n check?: boolean;\n configFormat?: string;\n}\n\nexport type OutputFormat = \"terminal\" | \"json\" | \"github\";\n\nexport function resolveFormat(options: CliOptions): OutputFormat {\n if (options.json) return \"json\";\n const format = options.format ?? \"terminal\";\n if (format !== \"terminal\" && format !== \"json\" && format !== \"github\") {\n throw new UsageError(`Unknown format \"${format}\". Use terminal, json or github.`);\n }\n return format;\n}\n\nexport function toAuditOptions(options: CliOptions, checks?: AuditCheck[]): AuditOptions {\n const result: AuditOptions = { strict: options.strict ?? false };\n if (checks !== undefined) result.checks = checks;\n if (options.cwd !== undefined) result.cwd = options.cwd;\n if (options.config !== undefined) result.configPath = options.config;\n if (options.file !== undefined && options.file.length > 0) result.files = options.file;\n if (options.example !== undefined) result.example = options.example;\n if (options.ignore !== undefined && options.ignore.length > 0) result.ignore = options.ignore;\n if (options.scan === false) result.scan = false;\n if (options.envOnly) result.codeSecrets = false;\n if (options.dir !== undefined && options.dir.length > 0) result.scanDirectories = options.dir;\n if (options.processEnv) result.processEnv = true;\n return result;\n}\n\n/** Print a status message without polluting machine-readable output. */\nexport function note(io: IO, options: CliOptions, text: string): void {\n if (resolveFormat(options) === \"terminal\") io.out(text + \"\\n\");\n else io.err(text + \"\\n\");\n}\n\nexport function printAudit(result: AuditResult, options: CliOptions, io: IO): void {\n const format = resolveFormat(options);\n if (format === \"json\") {\n io.out(JSON.stringify(result, null, 2) + \"\\n\");\n return;\n }\n if (format === \"github\") {\n io.out(formatGithub(result));\n return;\n }\n const color = options.color !== false && !options.ci && io.color;\n io.out(formatTerminal(result, { color, quiet: Boolean(options.quiet) }));\n // In GitHub Actions, also surface the issues as annotations on the pull request.\n if (options.ci && io.env.GITHUB_ACTIONS === \"true\") io.out(formatGithub(result));\n}\n\nexport function exitCodeFor(result: AuditResult): number {\n return result.success ? 0 : 1;\n}\n","import { auditProject, collectIssues, resolveIssues } from \"../../core/auditor\";\nimport { renderMerge } from \"../../core/generator\";\nimport { loadProject, type ProjectContext } from \"../../core/project\";\nimport {\n readExisting,\n resolveWriteTarget,\n writeProjectFile,\n} from \"../../core/writer\";\nimport { collectVariables } from \"../../core/variables\";\nimport type { AuditCheck } from \"../../types\";\nimport type { IO } from \"../io\";\nimport {\n exitCodeFor,\n note,\n printAudit,\n toAuditOptions,\n UsageError,\n type CliOptions,\n} from \"./common\";\n\nconst ALL: AuditCheck[] | undefined = undefined;\n\n/**\n * The only automatic fix: add variables that are used or set but missing\n * from the example file. Names are appended with empty values, existing\n * content is untouched, and real env files are never modified.\n */\nasync function applyFix(\n project: ProjectContext,\n options: CliOptions,\n io: IO,\n): Promise<number | undefined> {\n const { raw, usage } = await collectIssues(\n project,\n options.scan === false ? { scan: false } : {},\n );\n const issues = resolveIssues(project, raw);\n const names = [\n ...new Set(\n issues\n .filter(\n (issue) =>\n issue.code === \"undocumented-variable\" ||\n issue.code === \"undeclared-variable\",\n )\n .map((issue) => issue.variable as string),\n ),\n ].sort();\n\n if (names.length === 0) {\n note(io, options, \"Nothing to fix automatically.\");\n return undefined;\n }\n if (project.example === undefined) {\n note(\n io,\n options,\n \"--fix needs an existing example file. Run `envclinic generate` to create one.\",\n );\n return undefined;\n }\n\n const example = project.example;\n const variables = collectVariables(project, usage).filter((info) =>\n names.includes(info.name),\n );\n const target = await resolveWriteTarget(project.cwd, example.path);\n if (!target.ok)\n throw new UsageError(`Cannot modify ${example.path}: ${target.reason}.`);\n const existing = await readExisting(target.absolute);\n if (existing === undefined)\n throw new UsageError(`Cannot read ${example.path}.`);\n const merged = renderMerge(existing, variables);\n\n note(\n io,\n options,\n `Fix: add ${names.length} variable${names.length === 1 ? \"\" : \"s\"} to ${example.path} (names only, empty values): ${names.join(\", \")}`,\n );\n if (options.dryRun) {\n note(io, options, \"Dry run: no files were changed.\");\n return undefined;\n }\n\n if (!options.yes) {\n if (!io.prompter.interactive) {\n throw new UsageError(\n \"--fix modifies files. Re-run with --yes to apply it without a prompt, or use --dry-run to preview.\",\n );\n }\n if (\n !(await io.prompter.confirm(\n `Apply this change to ${example.path}?`,\n false,\n ))\n ) {\n note(io, options, \"Cancelled. No files were changed.\");\n return 1;\n }\n }\n\n const written = await writeProjectFile(\n project.cwd,\n example.path,\n merged.content,\n { overwrite: true },\n );\n if (written.status === \"refused\")\n throw new UsageError(\n `Could not update ${example.path}: ${written.reason}.`,\n );\n note(io, options, `Updated ${example.path}.`);\n return undefined;\n}\n\n/** Run the audit command. Returns the process exit code. */\nexport async function auditCommand(\n options: CliOptions,\n io: IO,\n): Promise<number> {\n const auditOptions = toAuditOptions(options, ALL);\n let project = await loadProject(auditOptions);\n\n if (options.fix || options.dryRun) {\n if (options.fix) {\n const early = await applyFix(project, options, io);\n if (early !== undefined) return early;\n if (!options.dryRun) project = await loadProject(auditOptions); // re-read what changed\n }\n }\n\n const result = await auditProject(project, auditOptions);\n\n if (options.verbose && !options.json) {\n io.err(`cwd: ${project.cwd}\\n`);\n io.err(`config: ${project.configFile ?? \"none (using defaults)\"}\\n`);\n io.err(`framework: ${project.framework.name}\\n`);\n io.err(`strict: ${options.strict ? \"yes\" : \"no\"}\\n`);\n }\n\n printAudit(result, options, io);\n return exitCodeFor(result);\n}\n","import { createColors } from \"picocolors\";\nimport { loadProject } from \"../../core/project\";\nimport type { IO } from \"../io\";\nimport { resolveFormat, toAuditOptions, type CliOptions } from \"./common\";\n\n/** Show the detected framework and its environment variable conventions. */\nexport async function frameworkCommand(options: CliOptions, io: IO): Promise<number> {\n const project = await loadProject(toAuditOptions(options, []));\n const info = project.framework;\n\n if (resolveFormat(options) === \"json\") {\n io.out(JSON.stringify(info, null, 2) + \"\\n\");\n return 0;\n }\n\n const pc = createColors(options.color !== false && io.color);\n const lines = [\n `${pc.green(\"✔\")} Framework detected: ${pc.bold(info.name)}${info.forced ? \" (set in config)\" : \"\"}`,\n \"\",\n ` Access patterns: ${info.accessPatterns.join(\", \")}`,\n ` Public prefixes: ${info.publicPrefixes.length > 0 ? info.publicPrefixes.join(\", \") : \"none (nothing is assumed to reach the browser)\"}`,\n ];\n if (info.detected.length > 1) lines.push(` Also detected: ${info.detected.slice(1).join(\", \")}`);\n lines.push(\"\", pc.bold(\"Evidence\"), ...info.evidence.map((item) => ` - ${item}`));\n if (info.notes.length > 0) lines.push(\"\", pc.bold(\"Notes\"), ...info.notes.map((note) => ` - ${note}`));\n io.out(lines.join(\"\\n\") + \"\\n\");\n return 0;\n}\n","import { renderExample, renderMerge } from \"../../core/generator\";\nimport { scanProject } from \"../../core/auditor\";\nimport { exampleOutputPath, exampleVariables } from \"../../core/outputs\";\nimport { loadProject } from \"../../core/project\";\nimport {\n readExisting,\n resolveWriteTarget,\n writeProjectFile,\n} from \"../../core/writer\";\nimport type { IO } from \"../io\";\nimport { note, toAuditOptions, UsageError, type CliOptions } from \"./common\";\n\ntype Mode = \"create\" | \"merge\" | \"overwrite\";\n\n/** Generate or update `.env.example`. Contains variable names only, never values. */\nexport async function generateCommand(\n options: CliOptions,\n io: IO,\n): Promise<number> {\n const project = await loadProject(toAuditOptions(options, []));\n const usage =\n options.scan === false\n ? undefined\n : (await scanProject(project, { secrets: false })).usage;\n const variables = exampleVariables(project, usage, options.exclude ?? []);\n\n if (variables.length === 0) {\n note(\n io,\n options,\n \"Nothing to generate: no environment variables were found in env files, the schema or source code.\",\n );\n return 1;\n }\n\n const output = exampleOutputPath(project, options.output);\n const target = await resolveWriteTarget(project.cwd, output);\n if (!target.ok)\n throw new UsageError(`Cannot write ${output}: ${target.reason}.`);\n const existing = await readExisting(target.absolute);\n\n let mode: Mode = \"create\";\n if (existing !== undefined) {\n if (options.force) mode = \"overwrite\";\n else if (options.merge) mode = \"merge\";\n else if (options.dryRun) mode = \"merge\";\n else if (io.prompter.interactive) {\n const choice = await io.prompter.select(\n `${output} already exists. What should envclinic do?`,\n [\n {\n value: \"merge\" as const,\n label:\n \"Add only the missing variables (keeps your comments and order)\",\n },\n { value: \"overwrite\" as const, label: \"Replace the file\" },\n { value: \"cancel\" as const, label: \"Cancel\" },\n ],\n \"merge\",\n );\n if (choice === \"cancel\") {\n note(io, options, \"Cancelled. No files were changed.\");\n return 1;\n }\n mode = choice;\n } else {\n throw new UsageError(\n `${output} already exists. Use --merge to add missing variables, --force to replace it, or --dry-run to preview.`,\n );\n }\n }\n\n let content: string;\n let summary: string;\n if (mode === \"merge\" && existing !== undefined) {\n const merged = renderMerge(existing, variables);\n content = merged.content;\n summary =\n merged.added.length === 0\n ? `${output} already lists every variable.`\n : `Added ${merged.added.length} variable${merged.added.length === 1 ? \"\" : \"s\"} to ${output}: ${merged.added.join(\", \")}`;\n } else {\n content = renderExample(variables, project.framework.publicPrefixes);\n summary = `${mode === \"overwrite\" ? \"Replaced\" : \"Created\"} ${output} with ${variables.length} variable${variables.length === 1 ? \"\" : \"s\"}.`;\n }\n\n if (options.dryRun) {\n io.out(content);\n io.err(`Dry run: ${output} was not written.\\n`);\n return 0;\n }\n\n const written = await writeProjectFile(project.cwd, output, content, {\n overwrite: mode !== \"create\",\n });\n if (written.status === \"refused\")\n throw new UsageError(`Could not write ${output}: ${written.reason}.`);\n note(\n io,\n options,\n written.status === \"unchanged\"\n ? `${output} is already up to date.`\n : summary,\n );\n return 0;\n}\n","import { promises as fs } from \"node:fs\";\nimport path from \"node:path\";\nimport { DEFAULT_RULES } from \"../../config/defaults\";\nimport { loadProject } from \"../../core/project\";\nimport {\n readExisting,\n resolveWriteTarget,\n writeProjectFile,\n} from \"../../core/writer\";\nimport type { EnvDoctorConfig, RuleLevel, RuleName } from \"../../types\";\nimport type { IO } from \"../io\";\nimport { note, toAuditOptions, UsageError, type CliOptions } from \"./common\";\n\ntype Preset = \"recommended\" | \"strict\" | \"minimal\";\n\nconst SOURCE_DIRECTORIES = [\n \"src\",\n \"app\",\n \"pages\",\n \"lib\",\n \"server\",\n \"components\",\n];\n\nconst PRESETS: Record<Preset, Partial<Record<RuleName, RuleLevel>>> = {\n recommended: {},\n strict: {\n undocumented: \"error\",\n empty: \"error\",\n unused: \"error\",\n undeclared: \"error\",\n weak: \"error\",\n },\n minimal: {\n undocumented: \"off\",\n empty: \"off\",\n unused: \"off\",\n undeclared: \"off\",\n weak: \"off\",\n names: \"off\",\n syntax: \"off\",\n },\n};\n\nasync function existingEnvFiles(cwd: string): Promise<string[]> {\n try {\n const entries = await fs.readdir(cwd, { withFileTypes: true });\n return entries\n .filter((entry) => entry.isFile() && /^\\.env(\\.|$)/.test(entry.name))\n .map((entry) => entry.name)\n .sort();\n } catch {\n return [];\n }\n}\n\nasync function existingDirectories(cwd: string): Promise<string[]> {\n const found: string[] = [];\n for (const name of SOURCE_DIRECTORIES) {\n try {\n if ((await fs.stat(path.join(cwd, name))).isDirectory()) found.push(name);\n } catch {\n // not there\n }\n }\n return found;\n}\n\nconst csv = (text: string): string[] =>\n text\n .split(\",\")\n .map((part) => part.trim())\n .filter(Boolean);\n\nfunction renderConfig(config: EnvDoctorConfig, format: \"json\" | \"mjs\"): string {\n const body = JSON.stringify(config, null, 2);\n if (format === \"json\") return body + \"\\n\";\n // A JSDoc type instead of `import { defineConfig }`: editors still autocomplete, but the file\n // loads even when envclinic is not installed locally (for example when run through npx).\n return `/** @type {import(\"envclinic\").EnvDoctorConfig} */\\nexport default ${body};\\n`;\n}\n\n/** Interactive setup that writes an envclinic config file. */\nexport async function initCommand(\n options: CliOptions,\n io: IO,\n): Promise<number> {\n const format = options.configFormat ?? \"json\";\n if (format !== \"json\" && format !== \"mjs\")\n throw new UsageError(`Unknown config format \"${format}\". Use json or mjs.`);\n if (!options.yes && !io.prompter.interactive) {\n throw new UsageError(\n \"init asks questions, but there is no terminal. Re-run with --yes to accept the defaults.\",\n );\n }\n\n const project = await loadProject(toAuditOptions(options, []));\n const envFiles = await existingEnvFiles(project.cwd);\n const directories = await existingDirectories(project.cwd);\n const sourceDefault = envFiles.filter(\n (name) => !/(example|sample|template)/i.test(name),\n );\n const exampleDefault =\n project.example?.path ??\n envFiles.find((name) => /example|sample/i.test(name)) ??\n \".env.example\";\n\n let sources =\n sourceDefault.length > 0\n ? sourceDefault.filter((name) => name === \".env\" || name === \".env.local\")\n : [\".env\"];\n if (sources.length === 0) sources = [\".env\"];\n let example = exampleDefault;\n let scanDirectories = directories.length > 0 ? directories : [\".\"];\n let preset: Preset = \"recommended\";\n let typesEnabled = false;\n\n if (!options.yes) {\n const ask = io.prompter;\n note(\n io,\n options,\n `Detected framework: ${project.framework.name}. Env files found: ${envFiles.length > 0 ? envFiles.join(\", \") : \"none\"}.`,\n );\n sources = csv(\n await ask.input(\n \"Env files to audit (comma separated)\",\n sources.join(\", \"),\n ),\n );\n if (sources.length === 0) sources = [\".env\"];\n example = await ask.input(\n \"Example file that documents your variables\",\n example,\n );\n scanDirectories = csv(\n await ask.input(\n \"Directories with source code to scan (comma separated)\",\n scanDirectories.join(\", \"),\n ),\n );\n if (scanDirectories.length === 0) scanDirectories = [\".\"];\n preset = await ask.select<Preset>(\n \"How strict should the audit be?\",\n [\n {\n value: \"recommended\",\n label:\n \"Recommended: missing and duplicate variables fail, the rest warn\",\n },\n {\n value: \"strict\",\n label: \"Strict: unused, undeclared, empty and weak secrets fail too\",\n },\n {\n value: \"minimal\",\n label: \"Minimal: only missing variables, duplicates and secrets\",\n },\n ],\n \"recommended\",\n );\n typesEnabled = await ask.confirm(\n \"Report when the generated TypeScript declarations (env.d.ts) are out of date?\",\n false,\n );\n }\n\n const config: EnvDoctorConfig = {\n files: { source: sources, example },\n scan: { directories: scanDirectories },\n rules: { ...DEFAULT_RULES, ...PRESETS[preset] },\n ignore: { variables: [] },\n };\n if (typesEnabled) config.types = { enabled: true, output: \"env.d.ts\" };\n\n const file = `envclinic.config.${format}`;\n const target = await resolveWriteTarget(project.cwd, file);\n if (!target.ok)\n throw new UsageError(`Cannot write ${file}: ${target.reason}.`);\n\n let overwrite = false;\n if ((await readExisting(target.absolute)) !== undefined) {\n if (options.force) overwrite = true;\n else if (\n !options.yes &&\n io.prompter.interactive &&\n (await io.prompter.confirm(`${file} already exists. Replace it?`, false))\n )\n overwrite = true;\n else\n throw new UsageError(\n `${file} already exists. Use --force to replace it.`,\n );\n }\n\n const written = await writeProjectFile(\n project.cwd,\n file,\n renderConfig(config, format),\n { overwrite },\n );\n if (written.status === \"refused\")\n throw new UsageError(`Could not write ${file}: ${written.reason}.`);\n note(\n io,\n options,\n `Created ${file}.\\nNext: run \\`npx envclinic\\` to audit your project.`,\n );\n return 0;\n}\n","import { auditProject } from \"../../core/auditor\";\nimport { loadProject } from \"../../core/project\";\nimport type { AuditCheck } from \"../../types\";\nimport type { IO } from \"../io\";\nimport {\n exitCodeFor,\n printAudit,\n toAuditOptions,\n UsageError,\n type CliOptions,\n} from \"./common\";\n\nasync function runSubset(\n options: CliOptions,\n io: IO,\n checks: AuditCheck[],\n): Promise<number> {\n const auditOptions = toAuditOptions(options, checks);\n const result = await auditProject(\n await loadProject(auditOptions),\n auditOptions,\n );\n printAudit(result, options, io);\n return exitCodeFor(result);\n}\n\n/** Missing, empty, duplicate and invalid variables, plus schema validation. */\nexport function checkCommand(options: CliOptions, io: IO): Promise<number> {\n return runSubset(options, io, [\"files\", \"validation\"]);\n}\n\n/** Potentially exposed credentials and weak secrets. */\nexport function secretsCommand(options: CliOptions, io: IO): Promise<number> {\n return runSubset(options, io, [\"secrets\"]);\n}\n\n/** Potentially unused and undeclared variables. */\nexport function unusedCommand(options: CliOptions, io: IO): Promise<number> {\n if (options.scan === false)\n throw new UsageError(\n \"`unused` needs to scan source code, so --no-scan cannot be used with it.\",\n );\n return runSubset(options, io, [\"unused\"]);\n}\n\n/** Validate environment values against the schema from the config file. */\nexport async function validateCommand(\n options: CliOptions,\n io: IO,\n): Promise<number> {\n const auditOptions = toAuditOptions(options, [\"validation\"]);\n const project = await loadProject(auditOptions);\n\n if (project.schema === undefined) {\n throw new UsageError(\n \"No schema found. Add a `schema` to your envclinic config file (see docs/configuration.md).\",\n );\n }\n if (\n project.sourceFiles.length === 0 &&\n Object.keys(project.env).length === 0\n ) {\n throw new UsageError(\n \"Nothing to validate: no environment file was found. Pass --file, or use --process-env to validate the process environment.\",\n );\n }\n\n const result = await auditProject(project, auditOptions);\n printAudit(result, options, io);\n return exitCodeFor(result);\n}\n","import { scanProject } from \"../../core/auditor\";\nimport { buildTypesContent, typesOutputPath } from \"../../core/outputs\";\nimport { loadProject } from \"../../core/project\";\nimport { GENERATED_MARKER } from \"../../core/type-generator\";\nimport {\n readExisting,\n resolveWriteTarget,\n writeProjectFile,\n} from \"../../core/writer\";\nimport type { IO } from \"../io\";\nimport { note, toAuditOptions, UsageError, type CliOptions } from \"./common\";\n\n/** Generate TypeScript declarations (names and types only, never values). */\nexport async function typesCommand(\n options: CliOptions,\n io: IO,\n): Promise<number> {\n const project = await loadProject(toAuditOptions(options, []));\n const usage =\n options.scan === false\n ? undefined\n : (await scanProject(project, { secrets: false })).usage;\n const content = buildTypesContent(project, usage);\n\n const output = typesOutputPath(project, options.output);\n const target = await resolveWriteTarget(project.cwd, output);\n if (!target.ok)\n throw new UsageError(`Cannot write ${output}: ${target.reason}.`);\n const existing = await readExisting(target.absolute);\n\n if (options.check) {\n if (existing === undefined) {\n note(\n io,\n options,\n `${output} does not exist. Run \\`envclinic types\\` to generate it.`,\n );\n return 1;\n }\n if (existing.replace(/\\r\\n/g, \"\\n\") !== content) {\n note(\n io,\n options,\n `${output} is out of date. Run \\`envclinic types\\` to regenerate it.`,\n );\n return 1;\n }\n note(io, options, `${output} is up to date.`);\n return 0;\n }\n\n if (\n existing !== undefined &&\n !options.force &&\n !existing.trimStart().startsWith(GENERATED_MARKER)\n ) {\n throw new UsageError(\n `${output} was not generated by envclinic, so it will not be overwritten. Use --output to pick another path or --force to replace it.`,\n );\n }\n\n if (options.dryRun) {\n io.out(content);\n io.err(`Dry run: ${output} was not written.\\n`);\n return 0;\n }\n\n const written = await writeProjectFile(project.cwd, output, content, {\n overwrite: true,\n });\n if (written.status === \"refused\")\n throw new UsageError(`Could not write ${output}: ${written.reason}.`);\n note(\n io,\n options,\n written.status === \"unchanged\"\n ? `${output} is already up to date.`\n : `Wrote ${output}.`,\n );\n return 0;\n}\n","import { createInterface } from \"node:readline/promises\";\n\nexport interface Choice<T extends string> {\n value: T;\n label: string;\n}\n\nexport interface Prompter {\n /** False when there is no terminal to ask on (CI, pipes). Commands must not prompt then. */\n interactive: boolean;\n confirm(message: string, defaultValue?: boolean): Promise<boolean>;\n select<T extends string>(message: string, choices: Choice<T>[], defaultValue: T): Promise<T>;\n input(message: string, defaultValue?: string): Promise<string>;\n}\n\nexport interface IO {\n out: (text: string) => void;\n err: (text: string) => void;\n /** Whether stdout can show colors. */\n color: boolean;\n env: Record<string, string | undefined>;\n prompter: Prompter;\n}\n\n/** A prompter for runs without a terminal: nothing can be asked. */\nexport const nonInteractivePrompter: Prompter = {\n interactive: false,\n confirm: async (_message, defaultValue = false) => defaultValue,\n select: async (_message, _choices, defaultValue) => defaultValue,\n input: async (_message, defaultValue = \"\") => defaultValue,\n};\n\n/** Questions go to stderr so stdout stays clean for piping. */\nfunction createReadlinePrompter(): Prompter {\n const ask = async (question: string): Promise<string> => {\n const rl = createInterface({ input: process.stdin, output: process.stderr });\n try {\n return (await rl.question(question)).trim();\n } finally {\n rl.close();\n }\n };\n\n return {\n interactive: true,\n async confirm(message, defaultValue = false) {\n const answer = (await ask(`${message} ${defaultValue ? \"[Y/n]\" : \"[y/N]\"} `)).toLowerCase();\n if (answer === \"\") return defaultValue;\n return answer === \"y\" || answer === \"yes\";\n },\n async select(message, choices, defaultValue) {\n const lines = choices.map((choice, index) => ` ${index + 1}) ${choice.label}${choice.value === defaultValue ? \" (default)\" : \"\"}`);\n const answer = await ask(`${message}\\n${lines.join(\"\\n\")}\\n> `);\n const byNumber = choices[Number(answer) - 1];\n if (byNumber) return byNumber.value;\n const byValue = choices.find((choice) => choice.value === answer.toLowerCase());\n return byValue ? byValue.value : defaultValue;\n },\n async input(message, defaultValue = \"\") {\n const answer = await ask(`${message}${defaultValue ? ` (${defaultValue})` : \"\"}: `);\n return answer === \"\" ? defaultValue : answer;\n },\n };\n}\n\nconst canPrompt = Boolean(process.stdin.isTTY) && Boolean(process.stderr.isTTY) && !process.env.CI;\n\nexport const processIO: IO = {\n out: (text) => {\n process.stdout.write(text);\n },\n err: (text) => {\n process.stderr.write(text);\n },\n color: Boolean(process.stdout.isTTY) && !process.env.NO_COLOR && process.env.TERM !== \"dumb\",\n env: process.env,\n prompter: canPrompt ? createReadlinePrompter() : nonInteractivePrompter,\n};\n","import { run } from \"./run\";\n\nrun(process.argv.slice(2)).then((code) => {\n process.exitCode = code;\n});\n"],"mappings":";;;AAAA,SAAS,SAAS,sBAAsB;;;ACAxC;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,UAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,SAAW;AAAA,EACX,MAAQ;AAAA,EACR,MAAQ;AAAA,EACR,QAAU;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AAI;AAAA,IAClC;AACA,WAAO;AAAA,EACT;AACF;;;AqC/QA,IAAI,QAAQ,KAAK,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS;AACxC,UAAQ,WAAW;AACrB,CAAC;","names":["path","fs","path","fs","path","path","exists","fs","comment","fs","path","fs","path","path","fs","path","fs","path","fs","path","path","fs","exists","createColors","createColors","note","fs","path","fs","path"]}
|