virtual-code-owners 8.2.2 → 8.2.4

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2022-2024 Sander Verweij
3
+ Copyright (c) 2022-2025 Sander Verweij
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -53,19 +53,15 @@ function expandTeamsToUsersString(pUsers, pTeamMap) {
53
53
  .join(" ");
54
54
  }
55
55
  function expandTeamToUserNames(pUser, pTeamMap) {
56
- if (pUser.type === "virtual-team-name") {
57
- return stringifyTeamMembers(pTeamMap, pUser.bareName);
58
- }
59
- return [pUser.raw];
56
+ return pUser.type === "virtual-team-name"
57
+ ? stringifyTeamMembers(pTeamMap, pUser.bareName)
58
+ : [pUser.raw];
60
59
  }
61
60
  function stringifyTeamMembers(pTeamMap, pTeamName) {
62
61
  return (pTeamMap[pTeamName] ?? []).map(userNameToCodeOwner);
63
62
  }
64
63
  function userNameToCodeOwner(pUserName) {
65
- if (isEmailIshUsername(pUserName)) {
66
- return pUserName;
67
- }
68
- return `@${pUserName}`;
64
+ return isEmailIshUsername(pUserName) ? pUserName : `@${pUserName}`;
69
65
  }
70
66
  function compareUserNames(pLeftName, pRightName) {
71
67
  return pLeftName.toLowerCase() > pRightName.toLowerCase() ? 1 : -1;
package/dist/utensils.js CHANGED
@@ -1,4 +1,7 @@
1
1
  export function isEmailIshUsername(pUsername) {
2
- const lEmailIshUsernameRE = /^.+@.+$/;
3
- return Boolean(pUsername.match(lEmailIshUsernameRE));
2
+ return (
3
+ !pUsername.startsWith("@") &&
4
+ !pUsername.endsWith("@") &&
5
+ pUsername.includes("@")
6
+ );
4
7
  }
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "8.2.2";
1
+ export const VERSION = "8.2.4";
@@ -62,7 +62,7 @@ function parseSection(pUntreatedLine, pLineNo, pTeamMap) {
62
62
  const lTrimmedLine = pUntreatedLine.trim();
63
63
  const lCommentSplitLine = lTrimmedLine.split(/\s*#/);
64
64
  const lSection = lCommentSplitLine[0]?.match(
65
- /^(?<optionalIndicator>\^)?\[(?<name>[^\]]+)\](\[(?<minApprovers>[0-9]+)\])?(?<spaces>\s+)?(?<userNames>.+)?$/,
65
+ /^(?<optionalIndicator>\^)?\[(?<name>[^\]]+)\](\[(?<minApprovers>\d+)\])?(?<spaces>\s+)?(?<userNames>.+)?$/,
66
66
  );
67
67
  if (!lSection?.groups) {
68
68
  return {
@@ -116,8 +116,5 @@ function getUserNameType(pUserName, pBareName, pTeamMap) {
116
116
  return "invalid";
117
117
  }
118
118
  function getBareUserName(pUserName) {
119
- if (pUserName.startsWith("@")) {
120
- return pUserName.slice(1);
121
- }
122
- return pUserName;
119
+ return pUserName.startsWith("@") ? pUserName.slice(1) : pUserName;
123
120
  }
@@ -23,15 +23,11 @@ export default function readVirtualCodeOwners(
23
23
  }
24
24
  function reportAnomalies(pFileName, pAnomalies) {
25
25
  return pAnomalies
26
- .map((pAnomaly) => {
27
- if (pAnomaly.type === "invalid-line") {
28
- return `${pFileName}:${pAnomaly.line}:1 invalid line - neither a rule, section heading, comment nor empty: "${pAnomaly.raw}"`;
29
- } else {
30
- return (
31
- `${pFileName}:${pAnomaly.line}:1 invalid user or team name "${pAnomaly.raw}" (#${pAnomaly.userNumberWithinLine} on this line). ` +
32
- `It should either start with "@" or be an e-mail address.`
33
- );
34
- }
35
- })
26
+ .map((pAnomaly) =>
27
+ pAnomaly.type === "invalid-line"
28
+ ? `${pFileName}:${pAnomaly.line}:1 invalid line - neither a rule, section heading, comment nor empty: "${pAnomaly.raw}"`
29
+ : `${pFileName}:${pAnomaly.line}:1 invalid user or team name "${pAnomaly.raw}" (#${pAnomaly.userNumberWithinLine} on this line). ` +
30
+ `It should either start with "@" or be an e-mail address.`,
31
+ )
36
32
  .join(EOL);
37
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "virtual-code-owners",
3
- "version": "8.2.2",
3
+ "version": "8.2.4",
4
4
  "description": "CODEOWNERS with teams for teams that can't use GitHub teams",
5
5
  "type": "module",
6
6
  "bin": {
@@ -26,7 +26,7 @@
26
26
  "url": "https://github.com/sverweij/virtual-code-owners/issues"
27
27
  },
28
28
  "dependencies": {
29
- "yaml": "^2.5.1"
29
+ "yaml": "^2.7.0"
30
30
  },
31
31
  "engines": {
32
32
  "node": "^18.11.0||>=20.0.0"