virtual-code-owners 6.1.0 → 6.1.2

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.
@@ -23,8 +23,7 @@ export default function generateLabelerYml(pCodeOwners, pTeamMap, pGeneratedWarn
23
23
  function getPatternsForTeam(pCodeOwners, pTeamName) {
24
24
  return (pCodeOwners
25
25
  .filter((pLine) => {
26
- const isARule = pLine.type === "rule";
27
- return (isARule &&
26
+ return (pLine.type === "rule" &&
28
27
  lineContainsTeamName(pLine, pTeamName));
29
28
  })
30
29
  .map((pLine) => pLine.filesPattern));
package/dist/main.js CHANGED
@@ -28,7 +28,7 @@ Options:
28
28
  --dryRun Just validate inputs, don't generate
29
29
  outputs (default: false)
30
30
  -h, --help display help for command`;
31
- export function cli(pArguments = process.argv.slice(2), pOutStream = process.stdout, pErrorStream = process.stderr) {
31
+ export function cli(pArguments = process.argv.slice(2), pOutStream = process.stdout, pErrorStream = process.stderr, pErrorExitCode = 1) {
32
32
  try {
33
33
  const lOptions = getOptions(pArguments);
34
34
  if (lOptions.help) {
@@ -43,7 +43,7 @@ export function cli(pArguments = process.argv.slice(2), pOutStream = process.std
43
43
  }
44
44
  catch (pError) {
45
45
  pErrorStream.write(`${EOL}ERROR: ${pError.message}${EOL}${EOL}`);
46
- process.exitCode = 1;
46
+ process.exitCode = pErrorExitCode;
47
47
  }
48
48
  }
49
49
  function getOptions(pArguments) {
@@ -8,10 +8,10 @@ export default function readTeamMap(pVirtualTeamsFileName) {
8
8
  encoding: "utf-8",
9
9
  });
10
10
  const lTeamMap = parseYaml(lVirtualTeamsAsAString);
11
- validateTeamMap(lTeamMap, pVirtualTeamsFileName);
11
+ assertTeamMapValid(lTeamMap, pVirtualTeamsFileName);
12
12
  return lTeamMap;
13
13
  }
14
- function validateTeamMap(pTeamMap, pVirtualTeamsFileName) {
14
+ function assertTeamMapValid(pTeamMap, pVirtualTeamsFileName) {
15
15
  const ajv = new Ajv({
16
16
  allErrors: true,
17
17
  verbose: true,
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "6.1.0";
1
+ export const VERSION = "6.1.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "virtual-code-owners",
3
- "version": "6.1.0",
3
+ "version": "6.1.2",
4
4
  "description": "Makes your CODEOWNERS file liveable again",
5
5
  "type": "module",
6
6
  "exports": {
@@ -30,7 +30,8 @@
30
30
  "types": "types/types.d.ts",
31
31
  "bin": "dist/cli.js",
32
32
  "files": [
33
- "dist",
33
+ "dist/",
34
+ "types/",
34
35
  "package.json",
35
36
  "README.md",
36
37
  "LICENSE"
@@ -44,10 +45,10 @@
44
45
  "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",
45
46
  "depcruise:graph:diff:mermaid": "depcruise src tools --output-type mermaid --output-to - --reaches \"$(watskeburt $SHA -T regex)\"",
46
47
  "depcruise:html": "depcruise src tools --output-type err-html --output-to dependency-violation-report.html",
47
- "format": "prettier --loglevel warn --write \"**/*.{md,ts,json,yml}\"",
48
+ "format": "prettier --log-level warn --write \"**/*.{md,ts,json,yml}\"",
48
49
  "prepare": "husky install",
49
50
  "scm:stage": "git add .",
50
- "test": "NODE_OPTIONS=--no-warnings c8 mocha",
51
+ "test": "c8 node --no-warnings --loader 'ts-node/esm' --test-reporter ./tools/dot-with-summary.reporter.js --test src/*.test.ts",
51
52
  "update-dependencies": "npm run upem:update && npm run upem:install && npm run check",
52
53
  "upem-outdated": "npm outdated --json --long | upem --dry-run",
53
54
  "upem:install": "npm install",
@@ -68,18 +69,16 @@
68
69
  "url": "https://github.com/sverweij/virtual-code-owners/issues"
69
70
  },
70
71
  "devDependencies": {
71
- "@types/mocha": "10.0.1",
72
- "@types/node": "20.3.1",
73
- "c8": "8.0.0",
74
- "dependency-cruiser": "13.0.3",
72
+ "@types/node": "20.5.6",
73
+ "c8": "8.0.1",
74
+ "dependency-cruiser": "13.1.4",
75
75
  "husky": "8.0.3",
76
- "lint-staged": "13.2.2",
77
- "mocha": "10.2.0",
78
- "prettier": "2.8.8",
76
+ "lint-staged": "14.0.1",
77
+ "prettier": "3.0.2",
79
78
  "ts-node": "10.9.1",
80
- "typescript": "5.1.3",
79
+ "typescript": "5.2.2",
81
80
  "upem": "8.0.0",
82
- "watskeburt": "0.11.3"
81
+ "watskeburt": "1.0.1"
83
82
  },
84
83
  "dependencies": {
85
84
  "ajv": "8.12.0",
@@ -0,0 +1,6 @@
1
+ import type { ITeamMap, IVirtualCodeOwnersCST } from "./types.js";
2
+ export default function generateCodeOwners(
3
+ pVirtualCodeOwners: IVirtualCodeOwnersCST,
4
+ pTeamMap: ITeamMap,
5
+ pGeneratedWarning?: string,
6
+ ): string;
@@ -0,0 +1,6 @@
1
+ import type { ITeamMap, IVirtualCodeOwnersCST } from "./types.js";
2
+ export default function generateLabelerYml(
3
+ pCodeOwners: IVirtualCodeOwnersCST,
4
+ pTeamMap: ITeamMap,
5
+ pGeneratedWarning?: string,
6
+ ): string;
@@ -0,0 +1,18 @@
1
+ import type { IAnomaly, ITeamMap, IVirtualCodeOwnersCST } from "./types.js";
2
+ /**
3
+ * parses (virtual) codeowners as a string into a virtual codeowners CST
4
+ * which can be used to do further rocessing on (e.g. generate codeowners,
5
+ * validate etc.)
6
+ *
7
+ * @param pVirtualCodeOwnersAsString CODEOWNERS or VIRTUAL-CODE-OWNERS.txt file to parse
8
+ * @param pTeamMap a virtual team map ()
9
+ * @returns a virtual code owners CST
10
+ */
11
+ export declare function parse(
12
+ pVirtualCodeOwnersAsString: string,
13
+ pTeamMap?: ITeamMap,
14
+ ): IVirtualCodeOwnersCST;
15
+
16
+ export declare function getAnomalies(
17
+ pVirtualCodeOwners: IVirtualCodeOwnersCST,
18
+ ): IAnomaly[];
@@ -0,0 +1,44 @@
1
+ export interface ITeamMap {
2
+ [teamName: string]: string[];
3
+ }
4
+
5
+ export type IVirtualCodeOwnersCST = IVirtualCodeOwnerLine[];
6
+ export type IVirtualCodeOwnerLine = IBoringCSTLine | IInterestingCSTLine;
7
+ export interface IBoringCSTLine {
8
+ type: "comment" | "ignorable-comment" | "empty" | "unknown";
9
+ line: number;
10
+ raw: string;
11
+ }
12
+ export interface IInterestingCSTLine {
13
+ type: "rule";
14
+ line: number;
15
+ filesPattern: string;
16
+ spaces: string;
17
+ users: IUser[];
18
+ raw: string;
19
+ }
20
+ export type UserType =
21
+ | "virtual-team-name"
22
+ | "e-mail-address"
23
+ | "other-user-or-team"
24
+ | "invalid";
25
+ export type IUser = {
26
+ type: UserType;
27
+ userNumberWithinLine: number;
28
+ bareName: string;
29
+ raw: string;
30
+ };
31
+
32
+ export type IAnomaly = ILineAnomaly | IUserAnomaly;
33
+ export interface ILineAnomaly {
34
+ type: "invalid-line";
35
+ line: number;
36
+ raw: string;
37
+ }
38
+ export interface IUserAnomaly {
39
+ type: "invalid-user";
40
+ line: number;
41
+ userNumberWithinLine: number;
42
+ bareName: string;
43
+ raw: string;
44
+ }