Skip to content

Commit 2a057f8

Browse files
author
Antigravity
committed
Fixing .docgap.yaml configuration file name and adding docgap executable to top level folder.
1 parent f98b2eb commit 2a057f8

File tree

5 files changed

+19
-24
lines changed

5 files changed

+19
-24
lines changed

apps/cli/src/index.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const cli = cac('docgap');
88

99
cli
1010
.command('check [cwd]', 'Check documentation drift in the specified directory')
11-
.option('--config <path>', 'Path to config file (default: docgap.config.json)')
11+
.option('--config <path>', 'Path to config file (default: .docgap.yaml)')
1212
.option('--strict', 'Exit with code 1 if any drift is detected (useful for CI/CD)')
1313
.option('--coverage', 'Enable coverage reporting for documented entities')
1414
.example(' docgap check')
@@ -23,7 +23,7 @@ cli
2323
// Default command alias to check for convenience (optional, but good DX)
2424
cli
2525
.command('[cwd]', 'Check documentation drift (default)')
26-
.option('--config <path>', 'Path to config file (default: docgap.config.json)')
26+
.option('--config <path>', 'Path to config file (default: .docgap.yaml)')
2727
.option('--strict', 'Exit with code 1 if any drift is detected (useful for CI/CD)')
2828
.option('--coverage', 'Enable coverage reporting for documented entities')
2929
.action(async (cwd, options) => {
@@ -58,7 +58,17 @@ export function bootstrap() {
5858
// Only run if called directly
5959
import { fileURLToPath } from 'url';
6060
// Export for testing
61-
export const _isMain = (argv1: string, metaUrl: string) => argv1 === fileURLToPath(metaUrl);
61+
import { realpathSync } from 'fs';
62+
63+
// Export for testing
64+
export const _isMain = (argv1: string, metaUrl: string) => {
65+
const scriptPath = fileURLToPath(metaUrl);
66+
try {
67+
return argv1 === scriptPath || realpathSync(argv1) === scriptPath;
68+
} catch {
69+
return argv1 === scriptPath;
70+
}
71+
};
6272

6373
// istanbul ignore next
6474
/* v8 ignore next 3 */

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"packageManager": "[email protected]",
1212
"devDependencies": {
13+
"@docgap/cli": "workspace:*",
1314
"@vitest/coverage-v8": "^1.1.3",
1415
"vitest": "^1.1.3"
1516
}

packages/core/src/index.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,7 @@ async function loadConfig(cwd: string): Promise<DocGapConfig> {
4949
try {
5050
return await loadConfigFromPath(configPath);
5151
} catch (error) {
52-
// Fallback to json if needed or throw
53-
const jsonPath = path.join(cwd, 'docgap.config.json');
54-
try {
55-
return await loadConfigFromPath(jsonPath);
56-
} catch {
57-
throw new Error(`Failed to load config from ${configPath} or ${jsonPath}: ${error}`);
58-
}
52+
throw new Error(`Failed to load config from ${configPath}: ${error}`);
5953
}
6054
}
6155

packages/core/tests/unit/index.test.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,7 @@ rules: []
9595
expect(fg).toHaveBeenLastCalledWith(['s1', 's2'], expect.anything());
9696
});
9797

98-
it('falls back to json config if yaml fails', async () => {
99-
// yaml fails
100-
vi.mocked(fs.readFile).mockRejectedValueOnce(new Error('no yaml'));
101-
// json succeeds
102-
vi.mocked(fs.readFile).mockResolvedValueOnce(JSON.stringify({
103-
rules: []
104-
}));
105-
vi.mocked(fg).mockResolvedValue([]);
106-
107-
await runAnalysis('/cwd');
108-
expect(fs.readFile).toHaveBeenCalledTimes(2);
109-
});
110-
111-
it('throws if both yaml and json fail', async () => {
98+
it('throws if yaml fails', async () => {
11299
vi.mocked(fs.readFile).mockRejectedValue(new Error('no file'));
113100

114101
await expect(runAnalysis('/cwd')).rejects.toThrow('Failed to load config');

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)