Skip to content

Commit 889e90b

Browse files
committed
Uses GitHub prettier config
1 parent f052c0b commit 889e90b

29 files changed

+622
-740
lines changed

.github/actions/auth/src/index.ts

Lines changed: 45 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,96 @@
1-
import type { AuthContextOutput } from "./types.d.js";
2-
import process from "node:process";
3-
import core from "@actions/core";
4-
import playwright from "playwright";
1+
import type {AuthContextOutput} from './types.d.js'
2+
import process from 'node:process'
3+
import core from '@actions/core'
4+
import playwright from 'playwright'
55

66
export default async function () {
7-
core.info("Starting 'auth' action");
7+
core.info("Starting 'auth' action")
88

9-
let browser: playwright.Browser | undefined;
10-
let context: playwright.BrowserContext | undefined;
11-
let page: playwright.Page | undefined;
9+
let browser: playwright.Browser | undefined
10+
let context: playwright.BrowserContext | undefined
11+
let page: playwright.Page | undefined
1212
try {
1313
// Get inputs
14-
const loginUrl = core.getInput("login_url", { required: true });
15-
const username = core.getInput("username", { required: true });
16-
const password = core.getInput("password", { required: true });
17-
core.setSecret(password);
14+
const loginUrl = core.getInput('login_url', {required: true})
15+
const username = core.getInput('username', {required: true})
16+
const password = core.getInput('password', {required: true})
17+
core.setSecret(password)
1818

1919
// Launch a headless browser
2020
browser = await playwright.chromium.launch({
2121
headless: true,
22-
executablePath: process.env.CI ? "/usr/bin/google-chrome" : undefined,
23-
});
22+
executablePath: process.env.CI ? '/usr/bin/google-chrome' : undefined,
23+
})
2424
context = await browser.newContext({
2525
// Try HTTP Basic authentication
2626
httpCredentials: {
2727
username,
2828
password,
2929
},
30-
});
31-
page = await context.newPage();
30+
})
31+
page = await context.newPage()
3232

3333
// Navigate to login page
34-
core.info("Navigating to login page");
35-
await page.goto(loginUrl);
34+
core.info('Navigating to login page')
35+
await page.goto(loginUrl)
3636

3737
// Check for a login form.
3838
// If no login form is found, then either HTTP Basic auth succeeded, or the page does not require authentication.
39-
core.info("Checking for login form");
39+
core.info('Checking for login form')
4040
const [usernameField, passwordField] = await Promise.all([
4141
page.getByLabel(/user ?name/i).first(),
4242
page.getByLabel(/password/i).first(),
43-
]);
44-
const [usernameFieldExists, passwordFieldExists] = await Promise.all([
45-
usernameField.count(),
46-
passwordField.count(),
47-
]);
43+
])
44+
const [usernameFieldExists, passwordFieldExists] = await Promise.all([usernameField.count(), passwordField.count()])
4845
if (usernameFieldExists && passwordFieldExists) {
4946
// Try form authentication
50-
core.info("Filling username");
51-
await usernameField.fill(username);
52-
core.info("Filling password");
53-
await passwordField.fill(password);
54-
core.info("Logging in");
47+
core.info('Filling username')
48+
await usernameField.fill(username)
49+
core.info('Filling password')
50+
await passwordField.fill(password)
51+
core.info('Logging in')
5552
await page
5653
.getByLabel(/password/i)
57-
.locator("xpath=ancestor::form")
58-
.evaluate((form) => (form as HTMLFormElement).submit());
54+
.locator('xpath=ancestor::form')
55+
.evaluate(form => (form as HTMLFormElement).submit())
5956
} else {
60-
core.info("No login form detected");
57+
core.info('No login form detected')
6158
// This occurs if HTTP Basic auth succeeded, or if the page does not require authentication.
6259
}
6360

6461
// Output authenticated session state
65-
const { cookies, origins } = await context.storageState();
62+
const {cookies, origins} = await context.storageState()
6663
const authContextOutput: AuthContextOutput = {
6764
username,
6865
password,
6966
cookies,
7067
localStorage: origins.reduce(
71-
(acc, { origin, localStorage }) => {
68+
(acc, {origin, localStorage}) => {
7269
acc[origin] = localStorage.reduce(
73-
(acc, { name, value }) => {
74-
acc[name] = value;
75-
return acc;
70+
(acc, {name, value}) => {
71+
acc[name] = value
72+
return acc
7673
},
7774
{} as Record<string, string>,
78-
);
79-
return acc;
75+
)
76+
return acc
8077
},
8178
{} as Record<string, Record<string, string>>,
8279
),
83-
};
84-
core.setOutput("auth_context", JSON.stringify(authContextOutput));
85-
core.debug("Output: 'auth_context'");
80+
}
81+
core.setOutput('auth_context', JSON.stringify(authContextOutput))
82+
core.debug("Output: 'auth_context'")
8683
} catch (error) {
8784
if (page) {
88-
core.info(`Errored at page URL: ${page.url()}`);
85+
core.info(`Errored at page URL: ${page.url()}`)
8986
}
90-
core.setFailed(`${error}`);
91-
process.exit(1);
87+
core.setFailed(`${error}`)
88+
process.exit(1)
9289
} finally {
9390
// Clean up
94-
await context?.close();
95-
await browser?.close();
91+
await context?.close()
92+
await browser?.close()
9693
}
9794

98-
core.info("Finished 'auth' action");
95+
core.info("Finished 'auth' action")
9996
}
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
export type Cookie = {
2-
name: string;
3-
value: string;
4-
domain: string;
5-
path: string;
6-
expires?: number;
7-
httpOnly?: boolean;
8-
secure?: boolean;
9-
sameSite?: "Strict" | "Lax" | "None";
10-
};
2+
name: string
3+
value: string
4+
domain: string
5+
path: string
6+
expires?: number
7+
httpOnly?: boolean
8+
secure?: boolean
9+
sameSite?: 'Strict' | 'Lax' | 'None'
10+
}
1111

1212
export type LocalStorage = {
1313
[origin: string]: {
14-
[key: string]: string;
15-
};
16-
};
14+
[key: string]: string
15+
}
16+
}
1717

1818
export type AuthContextOutput = {
19-
username?: string;
20-
password?: string;
21-
cookies?: Cookie[];
22-
localStorage?: LocalStorage;
23-
};
19+
username?: string
20+
password?: string
21+
cookies?: Cookie[]
22+
localStorage?: LocalStorage
23+
}

.github/actions/file/src/Issue.ts

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1-
import type { Issue as IssueInput } from "./types.d.js";
1+
import type {Issue as IssueInput} from './types.d.js'
22

33
export class Issue implements IssueInput {
4-
#url!: string;
4+
#url!: string
55
#parsedUrl!: {
6-
owner: string;
7-
repository: string;
8-
issueNumber: number;
9-
};
10-
nodeId: string;
11-
id: number;
12-
title: string;
13-
state?: "open" | "reopened" | "closed";
14-
15-
constructor({ url, nodeId, id, title, state }: IssueInput) {
16-
this.url = url;
17-
this.nodeId = nodeId;
18-
this.id = id;
19-
this.title = title;
20-
this.state = state;
6+
owner: string
7+
repository: string
8+
issueNumber: number
9+
}
10+
nodeId: string
11+
id: number
12+
title: string
13+
state?: 'open' | 'reopened' | 'closed'
14+
15+
constructor({url, nodeId, id, title, state}: IssueInput) {
16+
this.url = url
17+
this.nodeId = nodeId
18+
this.id = id
19+
this.title = title
20+
this.state = state
2121
}
2222

2323
set url(newUrl: string) {
24-
this.#url = newUrl;
25-
this.#parsedUrl = this.#parseUrl();
24+
this.#url = newUrl
25+
this.#parsedUrl = this.#parseUrl()
2626
}
2727

2828
get url(): string {
29-
return this.#url;
29+
return this.#url
3030
}
3131

3232
get owner(): string {
33-
return this.#parsedUrl.owner;
33+
return this.#parsedUrl.owner
3434
}
3535

3636
get repository(): string {
37-
return this.#parsedUrl.repository;
37+
return this.#parsedUrl.repository
3838
}
3939

4040
get issueNumber(): number {
41-
return this.#parsedUrl.issueNumber;
41+
return this.#parsedUrl.issueNumber
4242
}
4343

4444
/**
@@ -47,17 +47,15 @@ export class Issue implements IssueInput {
4747
* @throws The provided URL is unparseable due to its unexpected format.
4848
*/
4949
#parseUrl(): {
50-
owner: string;
51-
repository: string;
52-
issueNumber: number;
50+
owner: string
51+
repository: string
52+
issueNumber: number
5353
} {
54-
const { owner, repository, issueNumber } =
55-
/\/(?<owner>[^/]+)\/(?<repository>[^/]+)\/issues\/(?<issueNumber>\d+)(?:[/?#]|$)/.exec(
56-
this.#url,
57-
)?.groups || {};
54+
const {owner, repository, issueNumber} =
55+
/\/(?<owner>[^/]+)\/(?<repository>[^/]+)\/issues\/(?<issueNumber>\d+)(?:[/?#]|$)/.exec(this.#url)?.groups || {}
5856
if (!owner || !repository || !issueNumber) {
59-
throw new Error(`Could not parse issue URL: ${this.#url}`);
57+
throw new Error(`Could not parse issue URL: ${this.#url}`)
6058
}
61-
return { owner, repository, issueNumber: Number(issueNumber) };
59+
return {owner, repository, issueNumber: Number(issueNumber)}
6260
}
6361
}
Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
import type { Octokit } from "@octokit/core";
2-
import { Issue } from "./Issue.js";
1+
import type {Octokit} from '@octokit/core'
2+
import {Issue} from './Issue.js'
33

4-
export async function closeIssue(
5-
octokit: Octokit,
6-
{ owner, repository, issueNumber }: Issue,
7-
) {
8-
return octokit.request(
9-
`PATCH /repos/${owner}/${repository}/issues/${issueNumber}`,
10-
{
11-
owner,
12-
repository,
13-
issue_number: issueNumber,
14-
state: "closed",
15-
},
16-
);
4+
export async function closeIssue(octokit: Octokit, {owner, repository, issueNumber}: Issue) {
5+
return octokit.request(`PATCH /repos/${owner}/${repository}/issues/${issueNumber}`, {
6+
owner,
7+
repository,
8+
issue_number: issueNumber,
9+
state: 'closed',
10+
})
1711
}
Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
1-
import type { Finding } from "./types.d.js";
1+
import type {Finding} from './types.d.js'
22

33
export function generateIssueBody(finding: Finding): string {
44
const solutionLong = finding.solutionLong
5-
?.split("\n")
5+
?.split('\n')
66
.map((line: string) =>
7-
!line.trim().startsWith("Fix any") &&
8-
!line.trim().startsWith("Fix all") &&
9-
line.trim() !== ""
7+
!line.trim().startsWith('Fix any') && !line.trim().startsWith('Fix all') && line.trim() !== ''
108
? `- ${line}`
119
: line,
1210
)
13-
.join("\n");
11+
.join('\n')
1412
const acceptanceCriteria = `## Acceptance Criteria
1513
- [ ] The specific axe violation reported in this issue is no longer reproducible.
1614
- [ ] The fix MUST meet WCAG 2.1 guidelines OR the accessibility standards specified by the repository or organization.
1715
- [ ] A test SHOULD be added to ensure this specific axe violation does not regress.
1816
- [ ] This PR MUST NOT introduce any new accessibility issues or regressions.
19-
`;
17+
`
2018
const body = `## What
2119
An accessibility scan flagged the element \`${finding.html}\` on ${finding.url} because ${finding.problemShort}. Learn more about why this was flagged by visiting ${finding.problemUrl}.
2220
2321
To fix this, ${finding.solutionShort}.
24-
${solutionLong ? `\nSpecifically:\n\n${solutionLong}` : ""}
22+
${solutionLong ? `\nSpecifically:\n\n${solutionLong}` : ''}
2523
2624
${acceptanceCriteria}
27-
`;
25+
`
2826

29-
return body;
27+
return body
3028
}

0 commit comments

Comments
 (0)