diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index bffb357a..00000000 --- a/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "next/core-web-vitals" -} diff --git a/.github/workflows/scripts/wait-for-netlify-deploy.js b/.github/workflows/scripts/wait-for-netlify-deploy.js index 07e53789..89cc5a0b 100644 --- a/.github/workflows/scripts/wait-for-netlify-deploy.js +++ b/.github/workflows/scripts/wait-for-netlify-deploy.js @@ -1,24 +1,22 @@ - - [ - "PR_NUMBER", - "BRANCH_NAME", - "NETLIFY_SITE_ID", - "NETLIFY_TOKEN", - "UPDATED_AT", - "COMMIT_SHA" + "PR_NUMBER", + "BRANCH_NAME", + "NETLIFY_SITE_ID", + "NETLIFY_TOKEN", + "UPDATED_AT", + "COMMIT_SHA", ].forEach((v) => { - if (!(process.env[v])) { - throw new Error(`Env var: '${v}' was not provided`) - } -}) + if (!process.env[v]) { + throw new Error(`Env var: '${v}' was not provided`); + } +}); const { - PR_NUMBER, - BRANCH_NAME, - NETLIFY_SITE_ID, - NETLIFY_TOKEN, - UPDATED_AT, - COMMIT_SHA + PR_NUMBER, + BRANCH_NAME, + NETLIFY_SITE_ID, + NETLIFY_TOKEN, + UPDATED_AT, + COMMIT_SHA, } = process.env; // Six minutes @@ -26,66 +24,78 @@ const MAX_NUM_TRIES = 120; const DELAY_TIME_MS = 5000; async function main() { + let numTries = 0; + while (numTries <= MAX_NUM_TRIES) { + numTries++; + await new Promise((res) => setTimeout(res, DELAY_TIME_MS)); + console.info(`Attempt #${numTries}`); + + const pageNum = 1; + const result = await fetch( + `https://api.netlify.com/api/v1/sites/${NETLIFY_SITE_ID}/deploys?branch=${BRANCH_NAME}&page=${pageNum}`, + { + headers: { + Authorization: `Bearer ${NETLIFY_TOKEN}`, + }, + } + ); + + if (!result.ok) { + throw new Error(`Result was not ok: ${result.statusText}`); + } - let numTries = 0; - while (numTries <= MAX_NUM_TRIES) { - numTries++; - await new Promise((res) => setTimeout(res, DELAY_TIME_MS)) - console.info(`Attempt #${numTries}`); - - let pageNum = 1; - const result = await fetch(`https://api.netlify.com/api/v1/sites/${NETLIFY_SITE_ID}/deploys?branch=${BRANCH_NAME}&page=${pageNum}`, { - headers: { - "Authorization": `Bearer ${NETLIFY_TOKEN}` - } - }); - - if (!result.ok) { - throw new Error(`Result was not ok: ${result.statusText}`) - } - - const json = await result.json(); - - if (json.length === 100) { - throw new Error("Result length was 100, you have there is probably another page of results") - } - - const filteredResults = json.filter((v) => v.review_id === parseInt(PR_NUMBER) && v.commit_ref === COMMIT_SHA); - console.info(`Found ${filteredResults.length} results with matching review_id and commit_ref`); - - - const filteredResults2 = filteredResults.filter((v) => { - return new Date(v.created_at) > new Date(UPDATED_AT); - }) - - console.info(`Found ${filteredResults2.length} results with matching created_at greater than UPDATED_AT (${UPDATED_AT})`); + const json = await result.json(); - if (filteredResults2.length > 1) { - throw new Error(`Expect only one deploy to exist, got ${filteredResults2.length}`) - } + if (json.length === 100) { + throw new Error( + "Result length was 100, you have there is probably another page of results" + ); + } + const filteredResults = json.filter( + (v) => + v.review_id === Number.parseInt(PR_NUMBER) && + v.commit_ref === COMMIT_SHA + ); + console.info( + `Found ${filteredResults.length} results with matching review_id and commit_ref` + ); + + const filteredResults2 = filteredResults.filter((v) => { + return new Date(v.created_at) > new Date(UPDATED_AT); + }); + + console.info( + `Found ${filteredResults2.length} results with matching created_at greater than UPDATED_AT (${UPDATED_AT})` + ); + + if (filteredResults2.length > 1) { + throw new Error( + `Expect only one deploy to exist, got ${filteredResults2.length}` + ); + } - if (filteredResults2.length === 0) { - console.info("No matching results, deploy isn't created yet."); - continue; - } + if (filteredResults2.length === 0) { + console.info("No matching results, deploy isn't created yet."); + continue; + } - const singleResult = filteredResults2[0]; - const resultStatus = singleResult.state; + const singleResult = filteredResults2[0]; + const resultStatus = singleResult.state; - console.info(`Result state is '${resultStatus}'`) + console.info(`Result state is '${resultStatus}'`); - if (resultStatus === "ready") { - console.info(`Deploy URL: ${singleResult.deploy_ssl_url}`) - process.exit(0); - } + if (resultStatus === "ready") { + console.info(`Deploy URL: ${singleResult.deploy_ssl_url}`); + process.exit(0); + } - if (result.status === "error") { - throw new Error("Deploy had an error status") - } + if (result.status === "error") { + throw new Error("Deploy had an error status"); } + } - throw new Error("Maximum retries exceeded.") + throw new Error("Maximum retries exceeded."); } -main(); +main(); diff --git a/.gitignore b/.gitignore index aa7722e8..7d8d99b8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.DS_Store node_modules /.cache diff --git a/.vscode/settings.json b/.vscode/settings.json index f5749be1..706e51d6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,61 +1,60 @@ { - "cSpell.words": [ - "Barfloo", - "blackbox", - "Bloggs", - "brianlow", - "CDKTF", - "codemirror", - "datetimes", - "Deduped", - "devs", - "divs", - "dockerise", - "dockerised", - "Dockerising", - "easymde", - "Foobar", - "Fooby", - "FOUCs", - "frontmatter", - "harfiles", - "importmap", - "interactable", - "jsonplaceholder", - "logmetadata", - "MDE's", - "MITM", - "Mockbin", - "nextjs", - "Oldweb", - "openapi", - "petstore", - "Rehype", - "relitigate", - "Sendgrid", - "statefulness", - "supervisord", - "tanstack", - "testid", - "testids", - "textareas", - "texteditor", - "thunks", - "timezones", - "Todos", - "toolings", - "tsconfigs", - "webp" - ], + "cSpell.words": [ + "Barfloo", + "blackbox", + "Bloggs", + "brianlow", + "CDKTF", + "codemirror", + "datetimes", + "Deduped", + "devs", + "divs", + "dockerise", + "dockerised", + "Dockerising", + "easymde", + "Foobar", + "Fooby", + "FOUCs", + "frontmatter", + "harfiles", + "importmap", + "interactable", + "jsonplaceholder", + "logmetadata", + "MDE's", + "MITM", + "Mockbin", + "nextjs", + "Oldweb", + "openapi", + "petstore", + "Rehype", + "relitigate", + "Sendgrid", + "statefulness", + "supervisord", + "tanstack", + "testid", + "testids", + "textareas", + "texteditor", + "thunks", + "timezones", + "Todos", + "toolings", + "tsconfigs", + "webp" + ], - "[mdx]": { - "editor.defaultFormatter": "unifiedjs.vscode-mdx", - "editor.inlineSuggest.enabled": false, - "editor.quickSuggestions": { - "other": "off", - "comments": "off", - "strings": "off" - } + "[mdx]": { + "editor.defaultFormatter": "unifiedjs.vscode-mdx", + "editor.inlineSuggest.enabled": false, + "editor.quickSuggestions": { + "other": "off", + "comments": "off", + "strings": "off" } - -} \ No newline at end of file + } +} diff --git a/biome.json b/biome.json new file mode 100644 index 00000000..1cab8338 --- /dev/null +++ b/biome.json @@ -0,0 +1,41 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", + "vcs": { + "enabled": true, + "clientKind": "git", + "useIgnoreFile": true + }, + "organizeImports": { + "enabled": true + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "a11y": { + "recommended": true + } + } + }, + "formatter": { + "enabled": true, + "indentStyle": "space", + "indentWidth": 2 + }, + "javascript": { + "formatter": { + "quoteStyle": "double", + "trailingCommas": "es5" + } + }, + "files": { + "ignore": [ + "node_modules", + ".next", + "src/generated", + "public", + "next-env.d.ts", + "tsconfig.tsbuildinfo" + ] + } +} diff --git a/buildTimeUtils/generateListOfArticles.ts b/buildTimeUtils/generateListOfArticles.ts index 07323f8d..6422c693 100644 --- a/buildTimeUtils/generateListOfArticles.ts +++ b/buildTimeUtils/generateListOfArticles.ts @@ -1,60 +1,55 @@ -import { readdir, writeFile, appendFile} from 'node:fs/promises'; +import { appendFile, readdir, writeFile } from "node:fs/promises"; -const PATH_TO_ARTICLES_COMPONENT = "app/generated/ListOfArticles.tsx"; -const PATH_TO_BLOG_POSTS = "app/routes/posts" +const PATH_TO_ARTICLES_COMPONENT = "app/generated/ListOfArticles.tsx"; +const PATH_TO_BLOG_POSTS = "app/routes/posts"; async function generateListOfArticles() { - try { - const files = await readdir(PATH_TO_BLOG_POSTS); + const files = await readdir(PATH_TO_BLOG_POSTS); - - await writeFile(PATH_TO_ARTICLES_COMPONENT, ` + await writeFile( + PATH_TO_ARTICLES_COMPONENT, + ` export const ListOfArticles = () => { - return