virtual-code-owners 2.2.0 → 2.2.3
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 +73 -19
- package/dist/convert-virtual-code-owners.js +19 -28
- package/dist/read-and-convert.js +4 -4
- package/dist/version.js +1 -1
- package/package.json +23 -14
package/README.md
CHANGED
|
@@ -22,8 +22,8 @@ or, if you want to be verbose
|
|
|
22
22
|
```
|
|
23
23
|
npx virtual-code-owners \
|
|
24
24
|
--virtual-code-owners .github/VIRTUAL-CODEOWNERS.txt \
|
|
25
|
-
--virtual-teams
|
|
26
|
-
--code-owners
|
|
25
|
+
--virtual-teams .github/virtual-teams.yml \
|
|
26
|
+
--code-owners .github/CODEOWNERS
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
## Why?
|
|
@@ -38,8 +38,33 @@ have the following choices:
|
|
|
38
38
|
though there are good people on many levels in bureaucracies, it might
|
|
39
39
|
eventually not pan out because #reasons.
|
|
40
40
|
- Maintain a CODEOWNERS file with code assigned to large lists of individuals.
|
|
41
|
-
An option, but laborious to maintain
|
|
42
|
-
|
|
41
|
+
An option, but laborious to maintain, even for smaller projects; for example:
|
|
42
|
+
|
|
43
|
+
```CODEOWNERS
|
|
44
|
+
# catch-all to ensure there at least _is_ a code owner, even when
|
|
45
|
+
# it's _everyone_
|
|
46
|
+
|
|
47
|
+
* @cloud-heroes-all
|
|
48
|
+
|
|
49
|
+
# admin & ci stuff => transversal
|
|
50
|
+
|
|
51
|
+
.github/ @abraham-lincoln @benjamin-franklin @koos-koets @luke-the-lucky-ch @mary-the-merry-ch @naomi-the-namegiver-ch
|
|
52
|
+
|
|
53
|
+
# generic stuff
|
|
54
|
+
|
|
55
|
+
apps/framework/ @abraham-lincoln @benjamin-franklin @koos-koets @luke-the-lucky-ch @mary-the-merry-ch @naomi-the-namegiver-ch
|
|
56
|
+
apps/ux-portal/ @abraham-lincoln @benjamin-franklin @charlotte-de-bourbon-ch @davy-davidson-ch @joe-dalton-ch @john-johnson-ch @koos-koets @luke-the-lucky-ch @mary-the-merry-ch @naomi-the-namegiver-ch
|
|
57
|
+
libs/components/ @charlotte-de-bourbon-ch @davy-davidson-ch @joe-dalton-ch @john-johnson-ch @koos-koets
|
|
58
|
+
|
|
59
|
+
# specific functionality
|
|
60
|
+
|
|
61
|
+
libs/ubc-sales/ @abraham-ableton-ch @boris-bubbleblower-ch @charlotte-charleston-ch @dagny-taggert-ch @gregory-gregson-ch @jane-doe-ch @karl-marx-ch
|
|
62
|
+
libs/ubc-after-sales/ @daisy-duck @donald-duck @john-doe-ch @pete-peterson-ch @william-the-fourth-ch
|
|
63
|
+
libs/ubc-pre-sales/ @averel-dalton-ch @jean-claude-ch @john-galt-ch @valerie-valerton-ch
|
|
64
|
+
libs/ubc-refund/ @abraham-ableton-ch @boris-bubbleblower-ch @charlotte-charleston-ch @dagny-taggert-ch @daisy-duck @donald-duck @gregory-gregson-ch @jane-doe-ch @john-doe-ch @karl-marx-ch @pete-peterson-ch @william-the-fourth-ch
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
This is where `virtual-code-owners` comes in.
|
|
43
68
|
|
|
44
69
|
## Formats
|
|
45
70
|
|
|
@@ -48,29 +73,44 @@ have the following choices:
|
|
|
48
73
|
`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.
|
|
49
74
|
The only difference between VIRTUAL-CODEOWNERS.txt and a CODEOWNERS file is that
|
|
50
75
|
the _teams_ the former uses might not exist yet, except in a `virtual-teams.yml`.
|
|
76
|
+
This enables you to write a _much_ easier to maintain list of code owners.
|
|
51
77
|
|
|
52
|
-
|
|
78
|
+
For example the CODEOWNERS file above can then look like this:
|
|
53
79
|
|
|
54
|
-
```
|
|
55
|
-
#! comments that start with #! won't appear in the CODEOWNERS output
|
|
80
|
+
```CODEOWNERS
|
|
81
|
+
#! comments that start with #! won't appear in the CODEOWNERS output
|
|
82
|
+
#!
|
|
56
83
|
#! this is not the CODEOWNERS file - to get that one run
|
|
57
84
|
#! npx virtual-code-owners
|
|
58
|
-
#! on this.
|
|
59
85
|
#!
|
|
60
|
-
#
|
|
86
|
+
# catch-all to ensure there at least _is_ a code owner, even when
|
|
87
|
+
# it's _everyone_
|
|
88
|
+
|
|
61
89
|
* @cloud-heroes-all
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
90
|
+
|
|
91
|
+
# admin & ci stuff => transversal
|
|
92
|
+
|
|
93
|
+
.github/ @ch/transversal
|
|
94
|
+
|
|
95
|
+
# generic stuff
|
|
96
|
+
|
|
97
|
+
apps/framework/ @ch/transversal
|
|
98
|
+
apps/ux-portal/ @ch/ux @ch/transversal
|
|
99
|
+
libs/components/ @ch/ux
|
|
100
|
+
|
|
101
|
+
# specific functionality
|
|
102
|
+
|
|
103
|
+
libs/ubc-sales/ @ch/sales
|
|
104
|
+
libs/ubc-after-sales/ @ch/after-sales
|
|
105
|
+
libs/ubc-pre-sales/ @ch/pre-sales
|
|
106
|
+
libs/ubc-refund/ @ch/sales @ch/after-sales
|
|
69
107
|
```
|
|
70
108
|
|
|
71
109
|
### virtual-teams.yml
|
|
72
110
|
|
|
73
|
-
A valid YAML file that contains a list of teams, with for each team its members
|
|
111
|
+
A valid YAML file that contains a list of teams, with for each team its members.
|
|
112
|
+
If a new team member joins, you can enter it here, run `npx virtual-code-owners`
|
|
113
|
+
to update CODEOWNERS.
|
|
74
114
|
|
|
75
115
|
```yaml
|
|
76
116
|
# yaml-language-server: $schema=https://raw.githubusercontent.com/sverweij/virtual-code-owners/main/src/virtual-teams.schema.json
|
|
@@ -78,20 +118,34 @@ ch/after-sales:
|
|
|
78
118
|
- john-doe-ch
|
|
79
119
|
- pete-peterson-ch
|
|
80
120
|
- william-the-fourth-ch
|
|
121
|
+
- daisy-duck
|
|
122
|
+
- donald-duck
|
|
81
123
|
ch/sales:
|
|
82
124
|
- gregory-gregson-ch
|
|
83
125
|
- jane-doe-ch
|
|
126
|
+
- abraham-ableton-ch
|
|
127
|
+
- boris-bubbleblower-ch
|
|
128
|
+
- charlotte-charleston-ch
|
|
129
|
+
- dagny-taggert-ch
|
|
130
|
+
- karl-marx-ch
|
|
84
131
|
ch/pre-sales:
|
|
85
132
|
- jean-claude-ch
|
|
86
133
|
- valerie-valerton-ch
|
|
87
134
|
- averel-dalton-ch
|
|
135
|
+
- john-galt-ch
|
|
88
136
|
ch/ux:
|
|
89
137
|
- davy-davidson-ch
|
|
90
138
|
- john-johnson-ch
|
|
91
139
|
- joe-dalton-ch
|
|
140
|
+
- koos-koets
|
|
141
|
+
- charlotte-de-bourbon-ch
|
|
92
142
|
ch/transversal:
|
|
143
|
+
- mary-the-merry-ch
|
|
93
144
|
- luke-the-lucky-ch
|
|
94
|
-
|
|
145
|
+
- naomi-the-namegiver-ch
|
|
146
|
+
- benjamin-franklin
|
|
147
|
+
- koos-koets
|
|
148
|
+
- abraham-lincoln
|
|
95
149
|
```
|
|
96
150
|
|
|
97
151
|
## FAQ
|
|
@@ -118,7 +172,7 @@ team name and _virtual-code-owners_ will leave the real name alone.
|
|
|
118
172
|
- _virtual-code-owners_ assumes the VIRTUAL-CODEOWNERS.txt is a valid CODEOWNERS
|
|
119
173
|
file and the virtual-teams.yml is a valid yaml file with teams names as keys
|
|
120
174
|
and team members as arrays under these. It will likely throw errors when this
|
|
121
|
-
assumption is not met, but the error-messages might
|
|
175
|
+
assumption is not met, but the error-messages might be cryptic.
|
|
122
176
|
|
|
123
177
|
### Why the `.txt` extension?
|
|
124
178
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EOL } from "node:os";
|
|
2
|
-
const
|
|
2
|
+
const DEFAULT_WARNING = `#${EOL}` +
|
|
3
3
|
`# DO NOT EDIT - this file is generated and your edits will be overwritten${EOL}` +
|
|
4
4
|
`#${EOL}` +
|
|
5
5
|
`# To make changes:${EOL}` +
|
|
@@ -8,14 +8,13 @@ const DEFAULT_GENERATED_WARNING = `#${EOL}` +
|
|
|
8
8
|
`# - and/ or add team members to .github/virtual-teams.yml${EOL}` +
|
|
9
9
|
`# - run 'npx virtual-code-owners'${EOL}` +
|
|
10
10
|
`#${EOL}${EOL}`;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
.join(EOL)}`;
|
|
11
|
+
export function convert(pCodeOwnersFileAsString, pTeamMap, pGeneratedWarning = DEFAULT_WARNING) {
|
|
12
|
+
return (pGeneratedWarning +
|
|
13
|
+
pCodeOwnersFileAsString
|
|
14
|
+
.split(EOL)
|
|
15
|
+
.filter(shouldAppearInResult)
|
|
16
|
+
.map(convertLine(pTeamMap))
|
|
17
|
+
.join(EOL));
|
|
19
18
|
}
|
|
20
19
|
function shouldAppearInResult(pLine) {
|
|
21
20
|
return !pLine.trimStart().startsWith("#!");
|
|
@@ -23,34 +22,26 @@ function shouldAppearInResult(pLine) {
|
|
|
23
22
|
function convertLine(pTeamMap) {
|
|
24
23
|
return (pUntreatedLine) => {
|
|
25
24
|
const lTrimmedLine = pUntreatedLine.trim();
|
|
26
|
-
|
|
25
|
+
const lSplitLine = lTrimmedLine.match(/^(?<filesPattern>[^\s]+\s+)(?<userNames>.*)$/);
|
|
26
|
+
if (lTrimmedLine.startsWith("#") || !lSplitLine?.groups) {
|
|
27
27
|
return pUntreatedLine;
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
29
|
+
const lUserNames = replaceTeamNames(lSplitLine.groups.userNames, pTeamMap);
|
|
30
|
+
return lSplitLine.groups.filesPattern + uniqAndSortUserNames(lUserNames);
|
|
32
31
|
};
|
|
33
32
|
}
|
|
34
|
-
function replaceTeamNames(
|
|
35
|
-
|
|
36
|
-
if (!lSplitLine?.groups) {
|
|
37
|
-
return pTrimmedLine;
|
|
38
|
-
}
|
|
39
|
-
let lUserNames = lSplitLine.groups.userNames.trim();
|
|
33
|
+
function replaceTeamNames(pUserNames, pTeamMap) {
|
|
34
|
+
let lReturnValue = pUserNames;
|
|
40
35
|
for (let lTeamName of Object.keys(pTeamMap)) {
|
|
41
|
-
|
|
36
|
+
lReturnValue = lReturnValue.replace(new RegExp(`(\\s|^)@${lTeamName}(\\s|$)`, "g"), `$1${stringifyTeamMembers(pTeamMap, lTeamName)}$2`);
|
|
42
37
|
}
|
|
43
|
-
return
|
|
38
|
+
return lReturnValue;
|
|
44
39
|
}
|
|
45
40
|
function stringifyTeamMembers(pTeamMap, pTeamName) {
|
|
46
41
|
return pTeamMap[pTeamName].map((pUserName) => `@${pUserName}`).join(" ");
|
|
47
42
|
}
|
|
48
|
-
function
|
|
49
|
-
|
|
50
|
-
if (pTrimmedLine.startsWith("#") || !lSplitLine?.groups) {
|
|
51
|
-
return pTrimmedLine;
|
|
52
|
-
}
|
|
53
|
-
return `${lSplitLine.groups.filesPattern}${Array.from(new Set(lSplitLine.groups.userNames.trim().split(/\s+/)))
|
|
43
|
+
function uniqAndSortUserNames(pUserNames) {
|
|
44
|
+
return Array.from(new Set(pUserNames.split(/\s+/)))
|
|
54
45
|
.sort()
|
|
55
|
-
.join(" ")
|
|
46
|
+
.join(" ");
|
|
56
47
|
}
|
package/dist/read-and-convert.js
CHANGED
|
@@ -2,12 +2,12 @@ import { readFileSync } from "node:fs";
|
|
|
2
2
|
import yaml from "js-yaml";
|
|
3
3
|
import { convert } from "./convert-virtual-code-owners.js";
|
|
4
4
|
export function readAndConvert(pVirtualCodeOwnersFileName, pVirtualTeamsFileName) {
|
|
5
|
-
const
|
|
5
|
+
const lVirtualCodeOwnersAsAString = readFileSync(pVirtualCodeOwnersFileName, {
|
|
6
6
|
encoding: "utf-8",
|
|
7
7
|
});
|
|
8
|
-
const
|
|
8
|
+
const lVirtualTeamsAsAString = readFileSync(pVirtualTeamsFileName, {
|
|
9
9
|
encoding: "utf-8",
|
|
10
10
|
});
|
|
11
|
-
const lTeamMap = yaml.load(
|
|
12
|
-
return convert(
|
|
11
|
+
const lTeamMap = yaml.load(lVirtualTeamsAsAString);
|
|
12
|
+
return convert(lVirtualCodeOwnersAsAString, lTeamMap);
|
|
13
13
|
}
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "2.2.
|
|
1
|
+
export const VERSION = "2.2.3";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "virtual-code-owners",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.3",
|
|
4
4
|
"description": "Merges a VIRTUAL-CODEOWNERS.txt and a virtual-teams.yml into CODEOWNERS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build": "rm -rf dist && ts-node --esm tools/get-version.ts > src/version.ts && tsc",
|
|
24
24
|
"check": "npm run format && npm run build && npm run depcruise -- --no-progress && npm test",
|
|
25
|
-
"depcruise": "depcruise src tools
|
|
26
|
-
"depcruise:graph": "depcruise src --include-only '^(src)' --
|
|
27
|
-
"depcruise:graph:dev": "depcruise src --prefix vscode://file/$(pwd)/ --
|
|
28
|
-
"depcruise:graph:diff:dev": "depcruise src --prefix vscode://file/$(pwd)/ --
|
|
29
|
-
"depcruise:graph:diff:mermaid": "depcruise src tools --
|
|
30
|
-
"depcruise:html": "depcruise src tools --
|
|
25
|
+
"depcruise": "depcruise src tools",
|
|
26
|
+
"depcruise:graph": "depcruise src --include-only '^(src)' --output-type dot | dot -T svg | depcruise-wrap-stream-in-html > dependency-graph.html",
|
|
27
|
+
"depcruise:graph:dev": "depcruise src --prefix vscode://file/$(pwd)/ --output-type dot | dot -T svg | depcruise-wrap-stream-in-html | browser",
|
|
28
|
+
"depcruise:graph:diff:dev": "depcruise src --prefix vscode://file/$(pwd)/ --output-type dot --reaches \"$(watskeburt $SHA -T regex)\"| dot -T svg | depcruise-wrap-stream-in-html | browser",
|
|
29
|
+
"depcruise:graph:diff:mermaid": "depcruise src tools --output-type mermaid --output-to - --reaches \"$(watskeburt $SHA -T regex)\"",
|
|
30
|
+
"depcruise:html": "depcruise src tools --output-type err-html --output-to dependency-violation-report.html",
|
|
31
31
|
"format": "prettier --loglevel warn --write \"**/*.{md,ts,json,yml}\"",
|
|
32
32
|
"prepare": "husky install",
|
|
33
33
|
"scm:stage": "git add .",
|
|
@@ -54,22 +54,31 @@
|
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/js-yaml": "4.0.5",
|
|
56
56
|
"@types/mocha": "10.0.1",
|
|
57
|
-
"@types/node": "18.15.
|
|
57
|
+
"@types/node": "18.15.11",
|
|
58
58
|
"c8": "7.13.0",
|
|
59
|
-
"dependency-cruiser": "
|
|
59
|
+
"dependency-cruiser": "^13.0.0-beta-2",
|
|
60
60
|
"husky": "8.0.3",
|
|
61
|
-
"lint-staged": "13.2.
|
|
61
|
+
"lint-staged": "13.2.1",
|
|
62
62
|
"mocha": "10.2.0",
|
|
63
|
-
"prettier": "2.8.
|
|
63
|
+
"prettier": "2.8.7",
|
|
64
64
|
"ts-node": "10.9.1",
|
|
65
|
-
"typescript": "5.0.
|
|
65
|
+
"typescript": "5.0.4",
|
|
66
66
|
"upem": "7.3.2",
|
|
67
|
-
"watskeburt": "0.10.
|
|
67
|
+
"watskeburt": "0.10.2"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"commander": "10.0.
|
|
70
|
+
"commander": "10.0.1",
|
|
71
71
|
"js-yaml": "4.1.0"
|
|
72
72
|
},
|
|
73
|
+
"upem": {
|
|
74
|
+
"policies": [
|
|
75
|
+
{
|
|
76
|
+
"package": "dependency-cruiser",
|
|
77
|
+
"policy": "wanted",
|
|
78
|
+
"because": "we're beta testing dependency-cruiser v13 and the _latest_ policy would bump down to v12 again"
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
},
|
|
73
82
|
"engines": {
|
|
74
83
|
"node": "^14.13.1||^16||>=18"
|
|
75
84
|
}
|