-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(incident 2024-05-05): initialize healthchecks CLI to scan for failed…
… docs pages
- Loading branch information
Showing
11 changed files
with
282 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name: vercel | ||
auth: bearer | ||
default-environment: Prod | ||
environments: | ||
Prod: https://api.vercel.com | ||
error-discrimination: | ||
strategy: property | ||
property-name: error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
types: | ||
ListDomainsResponse: | ||
properties: | ||
domains: list<Domain> | ||
|
||
Domain: | ||
properties: | ||
name: string | ||
|
||
service: | ||
base-path: /v9/projects/{projectId}/domains | ||
path-parameters: | ||
projectId: string | ||
auth: true | ||
endpoints: | ||
list: | ||
docs: | | ||
See Vercel's docs over here: https://vercel.com/docs/rest-api/endpoints/domains#list-all-the-domains | ||
method: GET | ||
path: /diff | ||
request: | ||
name: ListDomainsRequest | ||
query-parameters: | ||
limit: | ||
type: string | ||
docs: | | ||
The limit of domains to return. | ||
teamId: | ||
type: string | ||
docs: The team id to filter by | ||
response: ListDomainsResponse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
default-group: sdk | ||
groups: | ||
sdk: | ||
generators: | ||
- name: fernapi/fern-typescript-node-sdk | ||
version: 0.12.8-rc0 | ||
output: | ||
location: npm | ||
url: npm.buildwithfern.com | ||
package-name: "@fern-fern/vercel" | ||
config: | ||
skipResponseValidation: true | ||
namespaceExport: Vercel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { VercelClient } from "@fern-fern/vercel"; | ||
|
||
const VERCEL = new VercelClient({ | ||
token: process.env.VERCEL_TOKEN ?? "", | ||
}); | ||
|
||
const CUSTOM_SUBPATHS = [ | ||
"https://www.assemblyai.com/docs/api-reference/", | ||
"https://primer.io/docs/api", | ||
"https://astronomer.io/docs/api", | ||
"https://buildwithfern.com/learn", | ||
]; | ||
|
||
/** | ||
* Returns all the live fern docs urls | ||
*/ | ||
export async function getAllFernDocsWebsites(): Promise<string[]> { | ||
const listDomainsResponse = await VERCEL.v9.domains.list("fern-prod", { | ||
limit: "100", | ||
teamId: "team_6FKOM5nw037hv8g2mTk3gaH7", | ||
}); | ||
return [...CUSTOM_SUBPATHS, ...listDomainsResponse.domains.map((customDomain) => customDomain.name)]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { AllPagesLoadRule } from "./rule"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { getAllUrlsFromDocsConfig } from "@fern-ui/fdr-utils"; | ||
import { Rule, RuleArgs, RuleResult } from "../runRules"; | ||
|
||
export class AllPagesLoadRule implements Rule { | ||
name = "all-pages-load"; | ||
description = "Check that all URLs are reachable"; | ||
|
||
public async run({ fdr, url }: RuleArgs): Promise<RuleResult> { | ||
const getDocsForUrlResponse = await fdr.docs.v2.read.getDocsForUrl({ | ||
url, | ||
}); | ||
if (!getDocsForUrlResponse.ok) { | ||
return { | ||
name: this.name, | ||
success: false, | ||
message: `Failed to load docs for ${url} from FDR`, | ||
}; | ||
} | ||
const urls = getAllUrlsFromDocsConfig( | ||
getDocsForUrlResponse.body.baseUrl.domain, | ||
getDocsForUrlResponse.body.baseUrl.basePath, | ||
getDocsForUrlResponse.body.definition.config.navigation, | ||
getDocsForUrlResponse.body.definition.apis, | ||
); | ||
|
||
const responses = await Promise.all( | ||
urls.map(async (url) => { | ||
return { | ||
res: await fetch(`https://${url}`, { | ||
redirect: "manual", | ||
}), | ||
url, | ||
}; | ||
}), | ||
); | ||
const failedURLs = responses.filter((promise) => promise.res.status >= 400).map((res) => res.url); | ||
|
||
if (failedURLs.length > 0) { | ||
return { | ||
name: this.name, | ||
success: false, | ||
message: `The following URLs do not load: ${failedURLs.join(", ")}`, | ||
}; | ||
} | ||
|
||
return { | ||
name: this.name, | ||
success: true, | ||
message: "All URLs are reachable", | ||
}; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.