Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
3d4a173
fix flag for .env not ignored på .gitignore
Chrilleweb Sep 28, 2025
6706b9f
interfaces for compare
Chrilleweb Sep 28, 2025
5312a28
async promise type
Chrilleweb Sep 28, 2025
8d6fc8e
compare tips in ui folder
Chrilleweb Sep 29, 2025
00cf411
printstats to ui folder
Chrilleweb Sep 29, 2025
2206561
added print dpups to ui folder
Chrilleweb Sep 29, 2025
1fd3eac
printHeader to compare
Chrilleweb Sep 29, 2025
b9de5ea
added autofix to ui folder
Chrilleweb Sep 29, 2025
83a406a
printIssues
Chrilleweb Sep 30, 2025
e2f66ff
all keys match to ui
Chrilleweb Sep 30, 2025
3c63b86
gitingore
Chrilleweb Sep 30, 2025
fc35c6e
prettier
Chrilleweb Sep 30, 2025
8f839ff
moved ui to ui folder frem gitignore
Chrilleweb Sep 30, 2025
ff8ad54
jsDocs
Chrilleweb Sep 30, 2025
99584ab
comments
Chrilleweb Sep 30, 2025
39c7ac3
more logic
Chrilleweb Oct 1, 2025
4b74fa1
gitignore
Chrilleweb Oct 1, 2025
052e74b
helper
Chrilleweb Oct 1, 2025
97f18c6
fixing small bug
Chrilleweb Oct 1, 2025
c3fb28f
better typescript
Chrilleweb Oct 1, 2025
bf69056
onlyFiltering function
Chrilleweb Oct 1, 2025
5b5aedc
find dupicate fucntion
Chrilleweb Oct 1, 2025
b7072ea
paseAndfilter helper function
Chrilleweb Oct 1, 2025
11f066b
noColor to shared ui folder
Chrilleweb Oct 1, 2025
e8f8a15
interface instead of type
Chrilleweb Oct 1, 2025
8221b36
print in scan
Chrilleweb Oct 2, 2025
723b065
skip comments fucniton + print header for scan
Chrilleweb Oct 2, 2025
d43874c
fixed skip comments
Chrilleweb Oct 2, 2025
2d3d716
scan
Chrilleweb Oct 2, 2025
792e179
print stats for scan and calculate stats
Chrilleweb Oct 2, 2025
eb94699
printMissingExample in scan mode
Chrilleweb Oct 2, 2025
fd54e96
proccess compareisonFile
Chrilleweb Oct 2, 2025
b21749c
fixed auto-fix
Chrilleweb Oct 2, 2025
cc231f1
fixed applyFixes function in scanUsage
Chrilleweb Oct 2, 2025
a736787
proccess aplly fixes
Chrilleweb Oct 3, 2025
da06d7c
removed comments
Chrilleweb Oct 3, 2025
4021a3f
print comparison
Chrilleweb Oct 3, 2025
b44e48e
printUniqueVariables
Chrilleweb Oct 3, 2025
b998adb
print variables + auto fix fix
Chrilleweb Oct 3, 2025
b37e7ff
print missing in scan
Chrilleweb Oct 3, 2025
3eb11f7
unsued print ui
Chrilleweb Oct 3, 2025
f96ea4c
print potental secres ui
Chrilleweb Oct 3, 2025
3524d37
print succes
Chrilleweb Oct 3, 2025
7943e75
shared folder
Chrilleweb Oct 3, 2025
a884224
printStrictmodeError
Chrilleweb Oct 3, 2025
b5fca44
removed chalk from scanOutPutToConsole
Chrilleweb Oct 3, 2025
c72fec9
test
Chrilleweb Oct 4, 2025
5912958
moved print to scanconsole
Chrilleweb Oct 4, 2025
bded1f5
isJson
Chrilleweb Oct 4, 2025
d050d51
printfix
Chrilleweb Oct 4, 2025
ebd1277
added comment
Chrilleweb Oct 4, 2025
a4b47e3
fixed oprtions file
Chrilleweb Oct 4, 2025
b466172
promt ui
Chrilleweb Oct 4, 2025
3e12d58
refactored codebase for better maintainability
Chrilleweb Oct 4, 2025
52358d9
small fixes
Chrilleweb Oct 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ This project follows [Keep a Changelog](https://keepachangelog.com/) and [Semant
### Fixed
-

## [2.2.8] - 2025-09-30
### Added
- Fix .env is not ignored by git when using --fix flag.

### Changed
- No breaking changes.

### Fixed
- Refactored codebase for better maintainability.

## [2.2.7] - 2025-09-28
### Added
- Added warning on .env not ignored by .gitignore on default.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dotenv-diff",
"version": "2.2.7",
"version": "2.2.8",
"type": "module",
"description": "Scan your codebase to find environment variables in use.",
"bin": {
Expand Down
61 changes: 21 additions & 40 deletions src/cli/run.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { Command } from 'commander';
import fs from 'fs';
import path from 'path';
import chalk from 'chalk';

import { normalizeOptions } from '../config/options.js';
import { discoverEnvFiles } from '../services/envDiscovery.js';
Expand All @@ -10,33 +9,8 @@ import { ensureFilesOrPrompt } from '../services/ensureFilesOrPrompt.js';
import { compareMany } from '../commands/compare.js';
import { type CompareJsonEntry, type Options } from '../config/types.js';
import { scanUsage } from '../commands/scanUsage.js';

/**
* Run the CLI program
* @param program The commander program instance
*/
export async function run(program: Command) {
program.parse(process.argv);
const opts = normalizeOptions(program.opts());

setupGlobalConfig(opts);

// Route to appropriate command
if (opts.compare) {
await runCompareMode(opts);
} else {
await runScanMode(opts);
}
}

/**
* Setup global configuration
*/
function setupGlobalConfig(opts: Options) {
if (opts.noColor) {
chalk.level = 0; // disable colors globally
}
}
import { printErrorNotFound } from '../ui/compare/printErrorNotFound.js';
import { setupGlobalConfig } from '../ui/shared/setupGlobalConfig.js';

/**
* Run scan-usage mode (default behavior)
Expand Down Expand Up @@ -162,18 +136,7 @@ async function handleMissingFiles(

if (opts.isCiMode) {
// In CI mode, just show errors and exit
if (!envExists) {
console.error(
chalk.red(`❌ Error: --env file not found: ${path.basename(envFlag)}`),
);
}
if (!exExists) {
console.error(
chalk.red(
`❌ Error: --example file not found: ${path.basename(exampleFlag)}`,
),
);
}
printErrorNotFound(envExists, exExists, envFlag, exampleFlag);
process.exit(1);
} else {
// Interactive mode - try to prompt for file creation
Expand Down Expand Up @@ -226,3 +189,21 @@ function outputResults(
}
process.exit(exitWithError ? 1 : 0);
}

/**
* Run the CLI program
* @param program The commander program instance
*/
export async function run(program: Command) {
program.parse(process.argv);
const opts = normalizeOptions(program.opts());

setupGlobalConfig(opts);

// Route to appropriate command
if (opts.compare) {
await runCompareMode(opts);
} else {
await runScanMode(opts);
}
}
Loading