Skip to content

chore: bump prettier from 2.8.1 to 3.0.0 in /site #8477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion site/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>

<!--
▄█▀ ▀█▄
Expand Down
23 changes: 13 additions & 10 deletions site/jest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,19 @@ jest.mock("contexts/useProxyLatency", () => ({
if (!proxies) {
return {} as Record<string, ProxyLatencyReport>
}
return proxies.reduce((acc, proxy) => {
acc[proxy.id] = {
accurate: true,
// Return a constant latency of 8ms.
// If you make this random it could break stories.
latencyMS: 8,
at: new Date(),
}
return acc
}, {} as Record<string, ProxyLatencyReport>)
return proxies.reduce(
(acc, proxy) => {
acc[proxy.id] = {
accurate: true,
// Return a constant latency of 8ms.
// If you make this random it could break stories.
latencyMS: 8,
at: new Date(),
}
return acc
},
{} as Record<string, ProxyLatencyReport>,
)
}, [proxies])

return { proxyLatencies, refetch: jest.fn() }
Expand Down
2 changes: 1 addition & 1 deletion site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
"jest-websocket-mock": "2.4.0",
"jest_workaround": "0.1.14",
"msw": "1.2.2",
"prettier": "2.8.1",
"prettier": "3.0.0",
"resize-observer": "1.0.4",
"storybook": "7.0.26",
"storybook-addon-react-router-v6": "1.0.2",
Expand Down
4 changes: 2 additions & 2 deletions site/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,8 @@ export function waitForBuild(build: TypesGen.WorkspaceBuild) {
let latestJobInfo: TypesGen.ProvisionerJob | undefined = undefined

while (
!["succeeded", "canceled"].some((status) =>
latestJobInfo?.status.includes(status),
!["succeeded", "canceled"].some(
(status) => latestJobInfo?.status.includes(status),
)
) {
const { job } = await getWorkspaceBuildByNumber(
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/Filter/storyHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ export const getDefaultFilterProps = <TFilterProps>({
values,
},
menus,
} as TFilterProps)
}) as TFilterProps
11 changes: 7 additions & 4 deletions site/src/contexts/ProxyContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,13 @@ const selectByLatency = (
return undefined
}

const proxyMap = proxies.reduce((acc, proxy) => {
acc[proxy.id] = proxy
return acc
}, {} as Record<string, Region>)
const proxyMap = proxies.reduce(
(acc, proxy) => {
acc[proxy.id] = proxy
return acc
},
{} as Record<string, Region>,
)

const best = Object.keys(latencies)
.map((proxyId) => {
Expand Down
71 changes: 37 additions & 34 deletions site/src/contexts/useProxyLatency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,43 +87,46 @@ export const useProxyLatency = (
// proxyMap is a map of the proxy path_app_url to the proxy object.
// This is for the observer to know which requests are important to
// record.
const proxyChecks = proxies.reduce((acc, proxy) => {
// Only run the latency check on healthy proxies.
if (!proxy.healthy) {
return acc
}

// Do not run latency checks if a cached check exists below the latestFetchRequest Date.
// This prevents fetching latencies too often.
// 1. Fetch the latest stored latency for the given proxy.
// 2. If the latest latency is after the latestFetchRequest, then skip the latency check.
if (storedLatencies && storedLatencies[proxy.id]) {
const fetchRequestDate = new Date(latestFetchRequest)
const latest = storedLatencies[proxy.id].reduce((prev, next) =>
prev.at > next.at ? prev : next,
)

if (latest && latest.at > fetchRequestDate) {
// dispatch the cached latency. This latency already went through the
// guard logic below, so we can just dispatch it again directly.
dispatchProxyLatencies({
proxyID: proxy.id,
cached: true,
report: latest,
})
const proxyChecks = proxies.reduce(
(acc, proxy) => {
// Only run the latency check on healthy proxies.
if (!proxy.healthy) {
return acc
}
}

// Add a random query param to the url to make sure we don't get a cached response.
// This is important in case there is some caching layer between us and the proxy.
const url = new URL(
`/latency-check?cache_bust=${generateRandomString(6)}`,
proxy.path_app_url,
)
acc[url.toString()] = proxy
return acc
}, {} as Record<string, Region>)
// Do not run latency checks if a cached check exists below the latestFetchRequest Date.
// This prevents fetching latencies too often.
// 1. Fetch the latest stored latency for the given proxy.
// 2. If the latest latency is after the latestFetchRequest, then skip the latency check.
if (storedLatencies && storedLatencies[proxy.id]) {
const fetchRequestDate = new Date(latestFetchRequest)
const latest = storedLatencies[proxy.id].reduce((prev, next) =>
prev.at > next.at ? prev : next,
)

if (latest && latest.at > fetchRequestDate) {
// dispatch the cached latency. This latency already went through the
// guard logic below, so we can just dispatch it again directly.
dispatchProxyLatencies({
proxyID: proxy.id,
cached: true,
report: latest,
})
return acc
}
}

// Add a random query param to the url to make sure we don't get a cached response.
// This is important in case there is some caching layer between us and the proxy.
const url = new URL(
`/latency-check?cache_bust=${generateRandomString(6)}`,
proxy.path_app_url,
)
acc[url.toString()] = proxy
return acc
},
{} as Record<string, Region>,
)

// dispatchProxyLatenciesGuarded will assign the latency to the proxy
// via the reducer. But it will only do so if the performance entry is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const templatePermissions = (templateId: string) =>
},
action: "update",
},
} as const)
}) as const

const fetchTemplateSettings = async (orgId: string, name: string) => {
const template = await getTemplateByName(orgId, name)
Expand Down
51 changes: 27 additions & 24 deletions site/src/testHelpers/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,31 +149,34 @@ export const MockWorkspaceProxies: TypesGen.WorkspaceProxy[] = [
]

export const MockProxyLatencies: Record<string, ProxyLatencyReport> = {
...MockWorkspaceProxies.reduce((acc, proxy) => {
if (!proxy.healthy) {
...MockWorkspaceProxies.reduce(
(acc, proxy) => {
if (!proxy.healthy) {
return acc
}
acc[proxy.id] = {
// Make one of them inaccurate.
accurate: proxy.id !== "26e84c16-db24-4636-a62d-aa1a4232b858",
// This is a deterministic way to generate a latency to for each proxy.
// It will be the same for each run as long as the IDs don't change.
latencyMS:
(Number(
Array.from(proxy.id).reduce(
// Multiply each char code by some large prime number to increase the
// size of the number and allow use to get some decimal points.
(acc, char) => acc + char.charCodeAt(0) * 37,
0,
),
) /
// Cap at 250ms
100) %
250,
at: new Date(),
}
return acc
}
acc[proxy.id] = {
// Make one of them inaccurate.
accurate: proxy.id !== "26e84c16-db24-4636-a62d-aa1a4232b858",
// This is a deterministic way to generate a latency to for each proxy.
// It will be the same for each run as long as the IDs don't change.
latencyMS:
(Number(
Array.from(proxy.id).reduce(
// Multiply each char code by some large prime number to increase the
// size of the number and allow use to get some decimal points.
(acc, char) => acc + char.charCodeAt(0) * 37,
0,
),
) /
// Cap at 250ms
100) %
250,
at: new Date(),
}
return acc
}, {} as Record<string, ProxyLatencyReport>),
},
{} as Record<string, ProxyLatencyReport>,
),
}

export const MockBuildInfo: TypesGen.BuildInfoResponse = {
Expand Down
2 changes: 1 addition & 1 deletion site/src/xServices/workspace/workspaceXService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const permissionsToCheck = (
},
action: "read",
},
} as const)
}) as const

export const workspaceMachine = createMachine(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const permissionsToCheck = (workspace: TypesGen.Workspace) =>
},
action: "update",
},
} as const)
}) as const

export type WorkspaceScheduleEvent =
| {
Expand Down
2 changes: 1 addition & 1 deletion site/static/error.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{/* This template is used by application handlers to render friendly error
pages when there is a proxy error (for example, when the target app isn't
running). */}}
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
8 changes: 4 additions & 4 deletions site/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9435,10 +9435,10 @@ prelude-ls@^1.2.1:
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==

prettier@2.8.1:
version "2.8.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.1.tgz#4e1fd11c34e2421bc1da9aea9bd8127cd0a35efc"
integrity sha512-lqGoSJBQNJidqCHE80vqZJHWHRFoNYsSpP9AjFhlhi9ODCJA541svILes/+/1GM3VaL/abZi7cpFzOpdR9UPKg==
prettier@3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.0.0.tgz#e7b19f691245a21d618c68bc54dc06122f6105ae"
integrity sha512-zBf5eHpwHOGPC47h0zrPyNn+eAEIdEzfywMoYn2XPi0P44Zp0tSq64rq0xAREh4auw2cJZHo9QUob+NqCQky4g==

prettier@^2.8.0, prettier@^2.8.7:
version "2.8.8"
Expand Down