virtual-code-owners 3.0.1 → 4.0.1
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 +3 -3
- package/dist/cli.js +2 -23
- package/dist/main.js +69 -0
- package/dist/version.js +1 -1
- package/package.json +4 -5
package/README.md
CHANGED
|
@@ -21,9 +21,9 @@ or, if you want to be verbose
|
|
|
21
21
|
|
|
22
22
|
```
|
|
23
23
|
npx virtual-code-owners \
|
|
24
|
-
--
|
|
25
|
-
--
|
|
26
|
-
--
|
|
24
|
+
--virtualCodeOwners .github/VIRTUAL-CODEOWNERS.txt \
|
|
25
|
+
--virtualTeams .github/virtual-teams.yml \
|
|
26
|
+
--codeOwners .github/CODEOWNERS
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
## Why?
|
package/dist/cli.js
CHANGED
|
@@ -1,24 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { readAndConvert } from "./read-and-convert.js";
|
|
5
|
-
import { writeFileSync } from "node:fs";
|
|
6
|
-
import { EOL } from "node:os";
|
|
7
|
-
program
|
|
8
|
-
.description("Merges a VIRTUAL-CODEOWNERS.txt and a virtual-teams.yml into CODEOWNERS")
|
|
9
|
-
.version(VERSION)
|
|
10
|
-
.option("-v, --virtual-code-owners [file-name]", "A CODEOWNERS file with team names in them that are defined in a virtual teams file", ".github/VIRTUAL-CODEOWNERS.txt")
|
|
11
|
-
.option("-t, --virtual-teams [file-name]", "A YAML file listing teams and their members", ".github/virtual-teams.yml")
|
|
12
|
-
.option("-c, --code-owners [file-name]", "The location of the CODEOWNERS file", ".github/CODEOWNERS")
|
|
13
|
-
.parse(process.argv);
|
|
14
|
-
try {
|
|
15
|
-
const lCodeOwnersContent = readAndConvert(program.opts().virtualCodeOwners, program.opts().virtualTeams);
|
|
16
|
-
writeFileSync(program.opts().codeOwners, lCodeOwnersContent, {
|
|
17
|
-
encoding: "utf-8",
|
|
18
|
-
});
|
|
19
|
-
console.error(`${EOL}Wrote ${program.opts().codeOwners}${EOL}`);
|
|
20
|
-
}
|
|
21
|
-
catch (pError) {
|
|
22
|
-
console.error(`ERROR: ${pError.message}`);
|
|
23
|
-
process.exitCode = 1;
|
|
24
|
-
}
|
|
2
|
+
import { main } from "./main.js";
|
|
3
|
+
main();
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { VERSION } from "./version.js";
|
|
2
|
+
import { readAndConvert } from "./read-and-convert.js";
|
|
3
|
+
import { writeFileSync } from "node:fs";
|
|
4
|
+
import { EOL } from "node:os";
|
|
5
|
+
import { parseArgs } from "node:util";
|
|
6
|
+
const HELP_MESSAGE = `Usage: virtual-code-owners [options]
|
|
7
|
+
|
|
8
|
+
Merges a VIRTUAL-CODEOWNERS.txt and a virtual-teams.yml into CODEOWNERS
|
|
9
|
+
|
|
10
|
+
Options:
|
|
11
|
+
-V, --version output the version number
|
|
12
|
+
-v, --virtualCodeOwners [file-name] A CODEOWNERS file with team names in them
|
|
13
|
+
that are defined in a virtual teams file
|
|
14
|
+
(default: ".github/VIRTUAL-CODEOWNERS.txt")
|
|
15
|
+
-t, --virtualTeams [file-name] A YAML file listing teams and their
|
|
16
|
+
members
|
|
17
|
+
(default: ".github/virtual-teams.yml")
|
|
18
|
+
-c, --codeOwners [file-name] The location of the CODEOWNERS file
|
|
19
|
+
(default: ".github/CODEOWNERS")
|
|
20
|
+
-h, --help display help for command`;
|
|
21
|
+
export function main(pArguments = process.argv.slice(2), pOutStream = process.stdout, pErrorStream = process.stderr) {
|
|
22
|
+
try {
|
|
23
|
+
let lOptions = getOptions(pArguments);
|
|
24
|
+
if (lOptions.help) {
|
|
25
|
+
pOutStream.write(`${HELP_MESSAGE}${EOL}`);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (lOptions.version) {
|
|
29
|
+
pOutStream.write(`${VERSION}${EOL}`);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const lCodeOwnersContent = readAndConvert(lOptions.virtualCodeOwners, lOptions.virtualTeams);
|
|
33
|
+
writeFileSync(lOptions.codeOwners, lCodeOwnersContent, {
|
|
34
|
+
encoding: "utf-8",
|
|
35
|
+
});
|
|
36
|
+
pErrorStream.write(`${EOL}Wrote ${lOptions.codeOwners}${EOL}${EOL}`);
|
|
37
|
+
}
|
|
38
|
+
catch (pError) {
|
|
39
|
+
pErrorStream.write(`${EOL}ERROR: ${pError.message}${EOL}${EOL}`);
|
|
40
|
+
process.exitCode = 1;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function getOptions(pArguments) {
|
|
44
|
+
return parseArgs({
|
|
45
|
+
args: pArguments,
|
|
46
|
+
options: {
|
|
47
|
+
virtualCodeOwners: {
|
|
48
|
+
type: "string",
|
|
49
|
+
short: "v",
|
|
50
|
+
default: ".github/VIRTUAL-CODEOWNERS.txt",
|
|
51
|
+
},
|
|
52
|
+
virtualTeams: {
|
|
53
|
+
type: "string",
|
|
54
|
+
short: "t",
|
|
55
|
+
default: ".github/virtual-teams.yml",
|
|
56
|
+
},
|
|
57
|
+
codeOwners: {
|
|
58
|
+
type: "string",
|
|
59
|
+
short: "c",
|
|
60
|
+
default: ".github/CODEOWNERS",
|
|
61
|
+
},
|
|
62
|
+
help: { type: "boolean", short: "h", default: false },
|
|
63
|
+
version: { type: "boolean", short: "V", default: false },
|
|
64
|
+
},
|
|
65
|
+
strict: true,
|
|
66
|
+
allowPositionals: true,
|
|
67
|
+
tokens: false,
|
|
68
|
+
}).values;
|
|
69
|
+
}
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "
|
|
1
|
+
export const VERSION = "4.0.1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "virtual-code-owners",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Merges a VIRTUAL-CODEOWNERS.txt and a virtual-teams.yml into CODEOWNERS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/js-yaml": "4.0.5",
|
|
56
56
|
"@types/mocha": "10.0.1",
|
|
57
|
-
"@types/node": "20.
|
|
57
|
+
"@types/node": "20.2.5",
|
|
58
58
|
"c8": "7.13.0",
|
|
59
|
-
"dependency-cruiser": "13.0.
|
|
59
|
+
"dependency-cruiser": "13.0.2",
|
|
60
60
|
"husky": "8.0.3",
|
|
61
61
|
"lint-staged": "13.2.2",
|
|
62
62
|
"mocha": "10.2.0",
|
|
@@ -67,10 +67,9 @@
|
|
|
67
67
|
"watskeburt": "0.11.2"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"commander": "10.0.1",
|
|
71
70
|
"js-yaml": "4.1.0"
|
|
72
71
|
},
|
|
73
72
|
"engines": {
|
|
74
|
-
"node": "^16.
|
|
73
|
+
"node": "^16.19.0||^18.11.0||>=20.0.0"
|
|
75
74
|
}
|
|
76
75
|
}
|