Skip to content

Commit 819e1aa

Browse files
author
Raul Melo
authored
Add validate command (#45)
1 parent 3803e63 commit 819e1aa

19 files changed

+204
-64
lines changed

.changeset/chilly-clowns-start.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@codeowners-flow/cli': minor
3+
---
4+
5+
Enhance string formatting while generating CODEOWNERS

.changeset/light-keys-crash.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@codeowners-flow/cli': minor
3+
---
4+
5+
Add new "validate" command.
6+
7+
With `codeowners-flow validate`, you can validate your CODEOWNERS file against a set of rules and ensure that it meets the required format and structure.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@codeowners-flow/cli': minor
3+
---
4+
5+
Fix init boilerplate to import "defineConfig" from CLI

.github/CODEOWNERS

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@
22
# Instead, modify the `codeowners.config.mjs` file located at the root of your project.
33

44
# -------------------- START -------------------- #
5-
# Everything else will be fallback to @company/core-team to approve
65
## Matching patterns...
7-
* @company/core-team @company/infra-team
8-
# -------------------- END -------------------- #
9-
10-
# -------------------- START -------------------- #
11-
## Matching patterns...
12-
apps/website-frontend @company/website-team @company/core-team @company/infra-team
13-
## Except...
14-
apps/website-frontend/github
6+
* @company-team
157
# -------------------- END -------------------- #

bun.lock

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

packages/cli/eslint.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
import config from '@codeowners-flow/eslint';
22

3-
export default config;
3+
export default [
4+
...config,
5+
{
6+
ignores: ['src/__fixtures__/codeowners.config.mjs'],
7+
},
8+
];

packages/cli/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"dependencies": {
5252
"@manypkg/find-root": "2.2.3",
5353
"cosmiconfig": "9.0.0",
54+
"dedent": "1.5.3",
5455
"meow": "13.2.0",
5556
"zod": "3.24.2",
5657
"zod-validation-error": "3.4.0"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export default {
2+
outDir: '.github',
3+
rules: [
4+
{
5+
patterns: ['*'],
6+
owners: [
7+
{
8+
name: '@company-team',
9+
},
10+
],
11+
},
12+
],
13+
};

packages/cli/src/config/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export async function loadUserConfig(
1818
rootDir: string,
1919
configRelativePath?: string,
2020
) {
21+
console.log('configRelativePath', configRelativePath);
2122
try {
2223
const result = configRelativePath
2324
? await explorer.load(path.resolve(rootDir, configRelativePath))

packages/cli/src/generate-codeowners.test.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ vi.mock('./config/index.js', () => ({
77
}));
88

99
const mockWriteFileSync = vi.fn();
10-
vi.mock('node:fs', () => ({
10+
vi.mock('node:fs/promises', () => ({
1111
default: {
12-
writeFileSync: (...args: any) => mockWriteFileSync(...args),
12+
writeFile: (...args: any) => mockWriteFileSync(...args),
1313
},
1414
}));
1515

@@ -57,8 +57,7 @@ describe('fn: generateCodeOwners', () => {
5757
# -------------------- START -------------------- #
5858
## Matching patterns...
5959
packages/core/**/* @team/core
60-
# -------------------- END -------------------- #
61-
"
60+
# -------------------- END -------------------- #"
6261
`);
6362
});
6463

@@ -73,8 +72,7 @@ describe('fn: generateCodeOwners', () => {
7372
# -------------------- START -------------------- #
7473
## Matching patterns...
7574
packages/core/**/* @team/core
76-
# -------------------- END -------------------- #
77-
",
75+
# -------------------- END -------------------- #",
7876
"ownersPath": "/root/test/CODEOWNERS",
7977
}
8078
`);

0 commit comments

Comments
 (0)