@review-vir/common 3.1.0 → 3.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.
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Defines the Markdown that identifies a code owners block in a pull request description.
3
+ *
4
+ * @category Main
5
+ */
6
+ export declare const codeOwnersMarkdown: Readonly<{
7
+ blockEnd: "<!-- code owners end -->";
8
+ blockStart: "<!-- code owners start -->";
9
+ heading: "## Code Owners";
10
+ }>;
11
+ /**
12
+ * Formats the code owners content that pull-request-vir writes into a pull request description.
13
+ *
14
+ * @category Main
15
+ */
16
+ export declare function createCodeOwnersMarkdownBlock(content: string): string;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Defines the Markdown that identifies a code owners block in a pull request description.
3
+ *
4
+ * @category Main
5
+ */
6
+ export const codeOwnersMarkdown = Object.freeze({
7
+ blockEnd: '<!-- code owners end -->',
8
+ blockStart: '<!-- code owners start -->',
9
+ heading: '## Code Owners',
10
+ });
11
+ /**
12
+ * Formats the code owners content that pull-request-vir writes into a pull request description.
13
+ *
14
+ * @category Main
15
+ */
16
+ export function createCodeOwnersMarkdownBlock(content) {
17
+ return [
18
+ codeOwnersMarkdown.blockStart,
19
+ codeOwnersMarkdown.heading,
20
+ content,
21
+ codeOwnersMarkdown.blockEnd,
22
+ ].join('\n');
23
+ }
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
+ export * from './code-owners-markdown.js';
1
2
  export * from './parse-description-users.js';
2
3
  export * from './parse-inserted-code-owners.js';
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
+ export * from './code-owners-markdown.js';
1
2
  export * from './parse-description-users.js';
2
3
  export * from './parse-inserted-code-owners.js';
@@ -16,8 +16,10 @@ export function parseDescriptionUsers({ triggerText, bodyText, }) {
16
16
  }
17
17
  const [, restrictedMatch,] = safeMatch(match, /((?:@[\w-]+[^\w@]*)+)/);
18
18
  const userTags = Array.from(restrictedMatch?.matchAll(/@[\w-]+/g) || []);
19
- return userTags.map((userTag) => removePrefix({
20
- value: userTag[0],
21
- prefix: '@',
22
- }));
19
+ return userTags.map((userTag) => {
20
+ return removePrefix({
21
+ value: userTag[0],
22
+ prefix: '@',
23
+ });
24
+ });
23
25
  }
@@ -5,7 +5,7 @@
5
5
  * line followed by a collapsible list of their owned files:
6
6
  *
7
7
  * <!-- code owners start -->
8
- * **Code owners**:
8
+ * ## Code Owners
9
9
  * (at)username1
10
10
  * <details>
11
11
  * <summary>Owned files</summary>
@@ -1,5 +1,6 @@
1
1
  import { removeDuplicates, removePrefix, safeMatch } from '@augment-vir/common';
2
- const insertedCodeOwnersRegExp = /<!-- code owners start -->([\S\s]*?)<!-- code owners end -->/i;
2
+ import { codeOwnersMarkdown } from './code-owners-markdown.js';
3
+ const insertedCodeOwnersRegExp = new RegExp(String.raw `${codeOwnersMarkdown.blockStart}([\S\s]*?)${codeOwnersMarkdown.blockEnd}`, 'i');
3
4
  const fileLinkLineRegExp = /^\s*-\s/;
4
5
  const userTagRegExp = /@[\w-]+/g;
5
6
  /**
@@ -9,7 +10,7 @@ const userTagRegExp = /@[\w-]+/g;
9
10
  * line followed by a collapsible list of their owned files:
10
11
  *
11
12
  * <!-- code owners start -->
12
- * **Code owners**:
13
+ * ## Code Owners
13
14
  * (at)username1
14
15
  * <details>
15
16
  * <summary>Owned files</summary>
@@ -39,8 +40,10 @@ export function parseInsertedCodeOwners(body) {
39
40
  .filter((line) => !fileLinkLineRegExp.test(line))
40
41
  .join('\n');
41
42
  const userTags = Array.from(ownerLines.matchAll(userTagRegExp));
42
- return removeDuplicates(userTags.map((userTag) => removePrefix({
43
- value: userTag[0],
44
- prefix: '@',
45
- })));
43
+ return removeDuplicates(userTags.map((userTag) => {
44
+ return removePrefix({
45
+ value: userTag[0],
46
+ prefix: '@',
47
+ });
48
+ }));
46
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@review-vir/common",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "description": "Common functionality that review-vir primary uses but other external packages need as well.",
5
5
  "keywords": [
6
6
  "review-vir",
@@ -35,11 +35,11 @@
35
35
  "test:docs": "virmator docs check"
36
36
  },
37
37
  "dependencies": {
38
- "@augment-vir/assert": "^32.2.1",
39
- "@augment-vir/common": "^32.2.1"
38
+ "@augment-vir/assert": "^32.5.0",
39
+ "@augment-vir/common": "^32.5.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@augment-vir/test": "^32.2.1",
42
+ "@augment-vir/test": "^32.5.0",
43
43
  "@web/dev-server-esbuild": "^2.0.0",
44
44
  "@web/test-runner": "^1.0.0",
45
45
  "@web/test-runner-commands": "^1.0.1",