Skip to content

Commit 8e53fe7

Browse files
committed
Add TypeDoc integration and update README for new functionality
1 parent 4d5fc80 commit 8e53fe7

File tree

6 files changed

+47
-73
lines changed

6 files changed

+47
-73
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This action is designed to format and test Web Component repositories on pull re
1010
- prettier
1111
- playwright
1212
- web-test-runner
13+
- typedoc
1314

1415
### Usage
1516

dist/index.js

Lines changed: 22 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { getBooleanInput, getInput, setFailed, debug } from "@actions/core";
22
import { exec } from "@actions/exec";
33
import { getOctokit, context } from "@actions/github";
44
import { eslint, litAnalyzer } from "./scripts/analyze";
5-
import { playwright, testing } from "./scripts/testing";
5+
import { playwright, testing, typeDoc } from "./scripts/testing";
66
import { comment } from "./scripts/comment";
77
import { cwd, chdir } from "process";
88
// import { coverage } from './scripts/coverage'
@@ -185,7 +185,7 @@ export async function run(): Promise<void> {
185185
? await eslint({
186186
label: "ESLint",
187187
// TODO: change to -format json
188-
command: "npx eslint -f unix '" + wcSrcDirectory + "'",
188+
command: "npx eslint -f unix " + wcSrcDirectory,
189189
})
190190
: undefined;
191191

@@ -240,9 +240,9 @@ export async function run(): Promise<void> {
240240
// stderr: (data) => {
241241
// outputStr += data.toString();
242242
// },
243-
const tsDocStr: StepResponse | undefined = doTests
244-
? await commandComment({
245-
label: "TSDoc",
243+
const typeDocStr: StepResponse | undefined = doTests
244+
? await typeDoc({
245+
label: "TypeDoc",
246246
command: "npx typedoc --logLevel Warn",
247247
})
248248
: undefined;
@@ -285,7 +285,7 @@ export async function run(): Promise<void> {
285285
prettierStr,
286286
playwrightStr,
287287
testingStr,
288-
tsDocStr,
288+
typeDocStr,
289289
checkModifiedFilesStr,
290290
updateChangesStr,
291291
);

src/scripts/comment.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const comment = async (
2121
prettierStr: StepResponse | undefined,
2222
playwrightStr: StepResponse | undefined,
2323
testingStr: StepResponse | undefined,
24-
tsDocStr: StepResponse | undefined,
24+
typeDocStr: StepResponse | undefined,
2525
checkModifiedFilesStr: StepResponse | undefined,
2626
updateChangesStr: StepResponse | undefined,
2727
): Promise<StepResponse> => {
@@ -36,7 +36,7 @@ export const comment = async (
3636
${prettierStr !== undefined ? li(prettierStr.output) : ""}
3737
${playwrightStr !== undefined ? li(playwrightStr.output) : ""}
3838
${testingStr !== undefined ? li(testingStr.output) : ""}
39-
${tsDocStr !== undefined ? li(tsDocStr.output) : ""}
39+
${typeDocStr !== undefined ? li(typeDocStr.output) : ""}
4040
${checkModifiedFilesStr !== undefined ? li(checkModifiedFilesStr.output) : ""}
4141
${updateChangesStr !== undefined ? li(updateChangesStr.output) : ""}
4242
</ul>`;

src/scripts/testing.ts

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
Command,
77
commandComment,
88
runBashCommand,
9+
runCommand,
910
StepResponse,
1011
} from "src/main";
1112
import convert from "xml-js";
@@ -88,35 +89,20 @@ export const testing = async (
8889
outputStr += "</table>";
8990
}
9091
return await buildComment(response, outputStr, command.label);
92+
};
9193

92-
// const commands = [
93-
// // { label: "Testing", command: "npm run test -- --coverage" },
94-
// {
95-
// label: "Install PlayWright Browsers",
96-
// command: "npx playwright install --with-deps",
97-
// },
98-
// { label: "Testing", command: "npm run test -- --coverage" },
99-
// { label: "TSDoc", command: "npm run docs" },
100-
// ];
101-
102-
// const [commentBody, errorMessages] = await buildComment(commands);
94+
export const typeDoc = async (command: Command): Promise<StepResponse> => {
95+
const [response, commandOutput] = await runCommand(command);
96+
let outputStr =
97+
"<table><tr><th>File</th><th>Line</th><th>Column</th><th>Message</th></tr>";
98+
outputStr += commandOutput.split("\n").forEach((line) => {
99+
let match = line.match(/(.*):(\d+):(\d+) - (.*)/);
100+
if (match) {
101+
const [_, filePath, line, column, message] = match;
102+
return `<tr><td>${filePath}</td><td>${line}</td><td>${column}</td><td>${message}</td></tr>`;
103+
}
104+
});
105+
outputStr += "</table>";
103106

104-
// if (errorMessages) {
105-
// setFailed(errorMessages.trim());
106-
// return { output: commentBody.trim(), error: true };
107-
// } else {
108-
// return { output: commentBody.trim(), error: false };
109-
// }
107+
return await buildComment(response, outputStr, command.label);
110108
};
111-
112-
// function parseXmlToJson(xml: string) {
113-
// const json: { [key: string]: any } = {};
114-
// for (const res of xml.matchAll(
115-
// /(?:<(\w*)(?:\s[^>]*)*>)((?:(?!<\1).)*)(?:<\/\1>)|<(\w*)(?:\s*)*\/>/gm,
116-
// )) {
117-
// const key = res[1] || res[3];
118-
// const value = res[2] && parseXmlToJson(res[2]);
119-
// json[key] = (value && Object.keys(value).length ? value : res[2]) || null;
120-
// }
121-
// return json;
122-
// }

0 commit comments

Comments
 (0)