virtual-code-owners 6.0.0 → 6.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/README.md +15 -5
- package/dist/generate-codeowners.js +4 -1
- package/dist/main.js +16 -6
- package/dist/read-virtual-code-owners.js +1 -1
- package/dist/version.js +1 -1
- package/dist/virtual-teams.schema.json +1 -1
- package/package.json +5 -5
- /package/dist/{parse.js → parse-virtual-code-owners.js} +0 -0
package/README.md
CHANGED
|
@@ -71,7 +71,7 @@ This is where `virtual-code-owners` comes in.
|
|
|
71
71
|
|
|
72
72
|
### VIRTUAL-CODEOWNERS.txt
|
|
73
73
|
|
|
74
|
-
`
|
|
74
|
+
`VIRTUAL-CODEOWNERS.txt` is a regular, valid GitHub [CODEOWNERS](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners) file.
|
|
75
75
|
The only difference between VIRTUAL-CODEOWNERS.txt and a CODEOWNERS file is that
|
|
76
76
|
the _teams_ the former uses might not exist yet, except in a `virtual-teams.yml`.
|
|
77
77
|
This enables you to write a _much_ easier to maintain list of code owners.
|
|
@@ -189,10 +189,10 @@ file that will check that for you.
|
|
|
189
189
|
- ~~Currently only works for _user names_ to identify team members - not for e-mail
|
|
190
190
|
addresses.~~
|
|
191
191
|
Works with both user names and e-mail addresses
|
|
192
|
-
- _virtual-code-owners_
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
192
|
+
- Although _virtual-code-owners_ performs basic validations on the CODEOWNER
|
|
193
|
+
format and tries to emit clear and actionable error messages about them, it
|
|
194
|
+
might not catch all of them - e.g. it doesn't check if the users in
|
|
195
|
+
virtual-teams.yml actually exist.
|
|
196
196
|
|
|
197
197
|
### Why the `.txt` extension?
|
|
198
198
|
|
|
@@ -236,3 +236,13 @@ npx virtual-code-owners --emitLabeler
|
|
|
236
236
|
|
|
237
237
|
If you have an alternate file location for the `labeler.yml` you can specify that
|
|
238
238
|
with virtual-code-owner's `--labelerLocation` parameter.
|
|
239
|
+
|
|
240
|
+
### Can I just run virtual-code-owners to validate VIRTUAL-CODEOWNERS.txt & virtual-teams.yml?
|
|
241
|
+
|
|
242
|
+
So _without_ generating any output?
|
|
243
|
+
|
|
244
|
+
Yes. Use the `--dryRun` command line option:
|
|
245
|
+
|
|
246
|
+
```
|
|
247
|
+
npx virtual-code-owners --dryRun
|
|
248
|
+
```
|
|
@@ -20,7 +20,7 @@ export default function generateCodeOwners(pVirtualCodeOwners, pTeamMap, pGenera
|
|
|
20
20
|
function generateLine(pCSTLine, pTeamMap) {
|
|
21
21
|
if (pCSTLine.type === "rule") {
|
|
22
22
|
const lUserNames = uniq(pCSTLine.users.flatMap((pUser) => expandTeamToUserNames(pUser, pTeamMap)))
|
|
23
|
-
.sort()
|
|
23
|
+
.sort(compareUserNames)
|
|
24
24
|
.join(" ");
|
|
25
25
|
return pCSTLine.filesPattern + pCSTLine.spaces + lUserNames;
|
|
26
26
|
}
|
|
@@ -41,6 +41,9 @@ function userNameToCodeOwner(pUserName) {
|
|
|
41
41
|
}
|
|
42
42
|
return `@${pUserName}`;
|
|
43
43
|
}
|
|
44
|
+
function compareUserNames(pLeftName, pRightName) {
|
|
45
|
+
return pLeftName.toLowerCase() > pRightName.toLowerCase() ? 1 : -1;
|
|
46
|
+
}
|
|
44
47
|
function uniq(pUserNames) {
|
|
45
48
|
return Array.from(new Set(pUserNames));
|
|
46
49
|
}
|
package/dist/main.js
CHANGED
|
@@ -25,6 +25,8 @@ Options:
|
|
|
25
25
|
(default: false)
|
|
26
26
|
--labelerLocation [file-name] The location of the labeler.yml file
|
|
27
27
|
(default: ".github/labeler.yml")
|
|
28
|
+
--dryRun Just validate inputs, don't generate
|
|
29
|
+
outputs (default: false)
|
|
28
30
|
-h, --help display help for command`;
|
|
29
31
|
export function cli(pArguments = process.argv.slice(2), pOutStream = process.stdout, pErrorStream = process.stderr) {
|
|
30
32
|
try {
|
|
@@ -72,6 +74,10 @@ function getOptions(pArguments) {
|
|
|
72
74
|
type: "string",
|
|
73
75
|
default: ".github/labeler.yml",
|
|
74
76
|
},
|
|
77
|
+
dryRun: {
|
|
78
|
+
type: "boolean",
|
|
79
|
+
default: false,
|
|
80
|
+
},
|
|
75
81
|
help: { type: "boolean", short: "h", default: false },
|
|
76
82
|
version: { type: "boolean", short: "V", default: false },
|
|
77
83
|
},
|
|
@@ -84,14 +90,18 @@ function main(pOptions, pErrorStream) {
|
|
|
84
90
|
const lTeamMap = readTeamMap(pOptions.virtualTeams);
|
|
85
91
|
const lVirtualCodeOwners = readVirtualCodeOwners(pOptions.virtualCodeOwners, lTeamMap);
|
|
86
92
|
const lCodeOwnersContent = generateCodeOwners(lVirtualCodeOwners, lTeamMap);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
});
|
|
90
|
-
if (pOptions.emitLabeler) {
|
|
91
|
-
const lLabelerContent = generateLabelerYml(lVirtualCodeOwners, lTeamMap);
|
|
92
|
-
writeFileSync(pOptions.labelerLocation, lLabelerContent, {
|
|
93
|
+
if (!pOptions.dryRun) {
|
|
94
|
+
writeFileSync(pOptions.codeOwners, lCodeOwnersContent, {
|
|
93
95
|
encoding: "utf-8",
|
|
94
96
|
});
|
|
97
|
+
}
|
|
98
|
+
if (pOptions.emitLabeler) {
|
|
99
|
+
const lLabelerContent = generateLabelerYml(lVirtualCodeOwners, lTeamMap);
|
|
100
|
+
if (!pOptions.dryRun) {
|
|
101
|
+
writeFileSync(pOptions.labelerLocation, lLabelerContent, {
|
|
102
|
+
encoding: "utf-8",
|
|
103
|
+
});
|
|
104
|
+
}
|
|
95
105
|
pErrorStream.write(`${EOL}Wrote '${pOptions.codeOwners}' AND '${pOptions.labelerLocation}'${EOL}${EOL}`);
|
|
96
106
|
}
|
|
97
107
|
else {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { EOL } from "node:os";
|
|
3
|
-
import { getAnomalies, parse as parseVirtualCodeOwners } from "./parse.js";
|
|
3
|
+
import { getAnomalies, parse as parseVirtualCodeOwners, } from "./parse-virtual-code-owners.js";
|
|
4
4
|
export default function readVirtualCodeOwners(pVirtualCodeOwnersFileName, pTeamMap) {
|
|
5
5
|
const lVirtualCodeOwnersAsAString = readFileSync(pVirtualCodeOwnersFileName, {
|
|
6
6
|
encoding: "utf-8",
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "6.
|
|
1
|
+
export const VERSION = "6.1.0";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
3
|
"title": "virtual teams schema for virtual-code-owners",
|
|
4
4
|
"description": "a list of teams and their team members",
|
|
5
|
-
"$id": "org.js.virtual-code-owners/
|
|
5
|
+
"$id": "org.js.virtual-code-owners/6.0.0",
|
|
6
6
|
"type": "object",
|
|
7
7
|
"additionalProperties": {
|
|
8
8
|
"type": "array",
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "virtual-code-owners",
|
|
3
|
-
"version": "6.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "6.1.0",
|
|
4
|
+
"description": "Makes your CODEOWNERS file liveable again",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
"parse": [
|
|
8
8
|
{
|
|
9
|
-
"import": "./dist/parse.js",
|
|
10
|
-
"types": "./types/parse.d.ts"
|
|
9
|
+
"import": "./dist/parse-virtual-code-owners.js",
|
|
10
|
+
"types": "./types/parse-virtual-code-owners.d.ts"
|
|
11
11
|
},
|
|
12
|
-
"./dist/parse.js"
|
|
12
|
+
"./dist/parse-virtual-code-owners.js"
|
|
13
13
|
],
|
|
14
14
|
"generateCodeOwners": [
|
|
15
15
|
{
|
|
File without changes
|