@review-vir/common 1.0.0

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 ADDED
@@ -0,0 +1,5 @@
1
+ # @review-vir/common
2
+
3
+ Code used within multiple git code review tools, especially [review-vir](https://review-vir.github.io/review-vir) itself.
4
+
5
+ See https://review-vir.github.io/review-vir/common for docs.
@@ -0,0 +1,15 @@
1
+ import {join, resolve} from 'path';
2
+ import type {TypeDocOptions} from 'typedoc';
3
+ import {baseTypedocConfig} from 'virmator/dist/compiled-base-configs/base-typedoc';
4
+
5
+ const repoRoot = resolve(__dirname, '..');
6
+ const indexTsFile = join(repoRoot, 'src', 'index.ts');
7
+
8
+ export const typeDocConfig: Partial<TypeDocOptions> = {
9
+ ...baseTypedocConfig,
10
+ out: join(repoRoot, 'dist-pages'),
11
+ entryPoints: [
12
+ indexTsFile,
13
+ ],
14
+ intentionallyNotExported: [],
15
+ };
@@ -0,0 +1,23 @@
1
+ import {dirname} from 'path';
2
+ import {fileURLToPath, pathToFileURL} from 'url';
3
+ import {getWebTestRunnerConfigWithCoveragePercent} from 'virmator/base-configs/base-web-test-runner.mjs';
4
+
5
+ const baseConfig = getWebTestRunnerConfigWithCoveragePercent({
6
+ coveragePercent: 100,
7
+ packageRootDirPath: dirname(dirname(fileURLToPath(import.meta.url))),
8
+ extraScreenshotOptions: {},
9
+ });
10
+
11
+ /** @type {import('@web/test-runner').TestRunnerConfig} */
12
+ const webTestRunnerConfig = {
13
+ ...baseConfig,
14
+ concurrency: 1,
15
+ port: 8001,
16
+ };
17
+
18
+ export default webTestRunnerConfig;
19
+
20
+ // check if the current file is being run directly as a script
21
+ if (import.meta.url === pathToFileURL(process.argv[1]).href) {
22
+ console.info(JSON.stringify(webTestRunnerConfig, null, 4));
23
+ }
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@review-vir/common",
3
+ "version": "1.0.0",
4
+ "homepage": "https://github.com/review-vir/review-vir",
5
+ "bugs": {
6
+ "url": "https://github.com/review-vir/review-vir/issues"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/review-vir/review-vir"
11
+ },
12
+ "license": "(MIT or CC0 1.0)",
13
+ "author": {
14
+ "name": "electrovir",
15
+ "url": "https://github.com/electrovir"
16
+ },
17
+ "module": "dist/index.js",
18
+ "types": "dist/index.d.ts",
19
+ "scripts": {
20
+ "build": "npm run docs && mkdir -p ../../dist-pages/common && cp -r ./dist-pages/* ../../dist-pages/common/",
21
+ "compile": "tsc -b -f --pretty",
22
+ "docs": "virmator docs",
23
+ "start": "virmator frontend",
24
+ "test": "virmator test-web",
25
+ "test:all": "concurrently --colors --kill-others-on-fail -c auto --names test,docs \"npm run test:coverage\" \"npm run test:docs\"",
26
+ "test:coverage": "npm run test coverage",
27
+ "test:docs": "virmator docs check",
28
+ "test:types": "npm run compile"
29
+ },
30
+ "dependencies": {
31
+ "@augment-vir/common": "^28.0.2"
32
+ },
33
+ "devDependencies": {
34
+ "@augment-vir/browser-testing": "^28.0.2",
35
+ "@open-wc/testing": "^4.0.0",
36
+ "@types/mocha": "^10.0.6",
37
+ "@web/dev-server-esbuild": "^1.0.2",
38
+ "@web/test-runner": "^0.18.2",
39
+ "@web/test-runner-commands": "^0.9.0",
40
+ "@web/test-runner-playwright": "^0.11.0",
41
+ "@web/test-runner-visual-regression": "^0.9.0",
42
+ "istanbul-smart-text-reporter": "^1.1.4",
43
+ "markdown-code-example-inserter": "^1.0.0",
44
+ "typedoc": "^0.25.13"
45
+ },
46
+ "publishConfig": {
47
+ "access": "public"
48
+ }
49
+ }
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './parse-primary-reviewers.js';
@@ -0,0 +1,36 @@
1
+ import {itCases} from '@augment-vir/browser-testing';
2
+ import {parsePrimaryReviewers} from './parse-primary-reviewers';
3
+
4
+ describe(parsePrimaryReviewers.name, () => {
5
+ itCases(parsePrimaryReviewers, [
6
+ {
7
+ it: 'handles "reviewer"',
8
+ input: {bodyText: 'primary reviewer @my-name'},
9
+ expect: ['my-name'],
10
+ },
11
+ {
12
+ it: 'handles "reviewers"',
13
+ input: {bodyText: 'primary reviewers @my-name'},
14
+ expect: ['my-name'],
15
+ },
16
+ {
17
+ it: 'handles an actual pull request body',
18
+ input: {
19
+ bodyText:
20
+ 'https://my-ticket-url.com/ticket-number\nPrimary reviewer:\n@my-name1\n@my-name2\nChanges\n\nadd primary reviewer support\n\nHow to test\nNothing to test.',
21
+ },
22
+ expect: [
23
+ 'my-name1',
24
+ 'my-name2',
25
+ ],
26
+ },
27
+ {
28
+ it: 'handles no reviewers',
29
+ input: {
30
+ bodyText:
31
+ 'https://my-ticket-url.com/ticket-number\nPrimary rev name1\n@my-name2\nChanges\n\nadd primary reviewer support\n\nHow to test\nNothing to test.',
32
+ },
33
+ expect: [],
34
+ },
35
+ ]);
36
+ });
@@ -0,0 +1,26 @@
1
+ import {removePrefix, safeMatch} from '@augment-vir/common';
2
+
3
+ /**
4
+ * Accepts a pull request text body, expected to be in plain text format (not markdown) and parses
5
+ * out tagged primary reviewers from strings that look like:
6
+ *
7
+ * `primary reviewer: @username, @otherUsername`
8
+ *
9
+ * Which will return the following output:
10
+ *
11
+ * `['username', 'otherUsername']`
12
+ */
13
+ export function parsePrimaryReviewers({bodyText}: {bodyText: string}): string[] {
14
+ const [
15
+ ,
16
+ match,
17
+ ] = safeMatch(bodyText, /primary reviewers?((?:[^@]*@[\w\-_\d]+(?:[\s\n]|$))+)/i);
18
+
19
+ if (!match) {
20
+ return [];
21
+ }
22
+
23
+ const userTags = Array.from(match.matchAll(/@[\w\-\d]+/g));
24
+
25
+ return userTags.map((userTag) => removePrefix({value: userTag[0], prefix: '@'}));
26
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "outDir": "dist/",
4
+ "rootDir": "src/"
5
+ },
6
+ "exclude": [
7
+ "./configs",
8
+ "./coverage",
9
+ "./dist",
10
+ "./dist-*",
11
+ "./node_modules",
12
+ "./test-files",
13
+ "./ts.out"
14
+ ],
15
+ "extends": "../../configs/tsconfig.base.json"
16
+ }