virtual-code-owners 4.0.0 → 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/dist/cli.js CHANGED
@@ -1,71 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import { VERSION } from "./version.js";
3
- import { readAndConvert } from "./read-and-convert.js";
4
- import { writeFileSync } from "node:fs";
5
- import { EOL } from "node:os";
6
- import { parseArgs } from "node:util";
7
- let lOptions;
8
- try {
9
- let lParsedArgs = parseArgs({
10
- args: process.argv.slice(2),
11
- options: {
12
- virtualCodeOwners: {
13
- type: "string",
14
- short: "v",
15
- default: ".github/VIRTUAL-CODEOWNERS.txt",
16
- },
17
- virtualTeams: {
18
- type: "string",
19
- short: "t",
20
- default: ".github/virtual-teams.yml",
21
- },
22
- codeOwners: { type: "string", short: "c", default: ".github/CODEOWNERS" },
23
- help: { type: "boolean", short: "h", default: false },
24
- version: { type: "boolean", short: "V", default: false },
25
- },
26
- strict: true,
27
- allowPositionals: true,
28
- tokens: false,
29
- });
30
- lOptions = lParsedArgs.values;
31
- if (lOptions.help) {
32
- showHelp();
33
- process.exit(0);
34
- }
35
- if (lOptions.version) {
36
- console.log(VERSION);
37
- process.exit(0);
38
- }
39
- }
40
- catch (pError) {
41
- console.error(`${EOL}ERROR: ${pError.message}${EOL}`);
42
- process.exit(1);
43
- }
44
- function showHelp() {
45
- console.log(`Usage: virtual-code-owners [options]
46
-
47
- Merges a VIRTUAL-CODEOWNERS.txt and a virtual-teams.yml into CODEOWNERS
48
-
49
- Options:
50
- -V, --version output the version number
51
- -v, --virtualCodeOwners [file-name] A CODEOWNERS file with team names in them
52
- that are defined in a virtual teams file
53
- (default: ".github/VIRTUAL-CODEOWNERS.txt")
54
- -t, --virtualTeams [file-name] A YAML file listing teams and their
55
- members
56
- (default: ".github/virtual-teams.yml")
57
- -c, --codeOwners [file-name] The location of the CODEOWNERS file
58
- (default: ".github/CODEOWNERS")
59
- -h, --help display help for command`);
60
- }
61
- try {
62
- const lCodeOwnersContent = readAndConvert(lOptions.virtualCodeOwners, lOptions.virtualTeams);
63
- writeFileSync(lOptions.codeOwners, lCodeOwnersContent, {
64
- encoding: "utf-8",
65
- });
66
- console.error(`${EOL}Wrote ${lOptions.codeOwners}${EOL}`);
67
- }
68
- catch (pError) {
69
- console.error(`ERROR: ${pError.message}`);
70
- process.exitCode = 1;
71
- }
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 = "4.0.0";
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": "4.0.0",
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.2.1",
57
+ "@types/node": "20.2.5",
58
58
  "c8": "7.13.0",
59
- "dependency-cruiser": "13.0.1",
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",