From 2246e6e263ba5d4c67912894c011dc64cd906634 Mon Sep 17 00:00:00 2001 From: Alexander Niebuhr Date: Thu, 29 Aug 2024 08:19:52 +0200 Subject: [PATCH] chore: format --- packages/node/src/serve-static.ts | 2 +- packages/vercel/src/lib/redirects.ts | 26 +++---- packages/vercel/src/serverless/adapter.ts | 84 +++++++++++------------ packages/vercel/src/speed-insights.ts | 4 +- packages/vercel/src/static/adapter.ts | 38 +++++----- 5 files changed, 77 insertions(+), 77 deletions(-) diff --git a/packages/node/src/serve-static.ts b/packages/node/src/serve-static.ts index 9221594d..f4fa1fa5 100644 --- a/packages/node/src/serve-static.ts +++ b/packages/node/src/serve-static.ts @@ -29,7 +29,7 @@ export function createStaticHandler(app: NodeApp, options: Options) { let isDirectory = false; try { isDirectory = fs.lstatSync(filePath).isDirectory(); - } catch { } + } catch {} const { trailingSlash = 'ignore' } = options; diff --git a/packages/vercel/src/lib/redirects.ts b/packages/vercel/src/lib/redirects.ts index 54c883b3..59a00688 100644 --- a/packages/vercel/src/lib/redirects.ts +++ b/packages/vercel/src/lib/redirects.ts @@ -49,19 +49,19 @@ function getMatchPattern(segments: RoutePart[][]) { return segment[0].spread ? '(?:\\/(.*?))?' : segment - .map((part) => { - if (part) - return part.dynamic - ? '([^/]+?)' - : part.content - .normalize() - .replace(/\?/g, '%3F') - .replace(/#/g, '%23') - .replace(/%5B/g, '[') - .replace(/%5D/g, ']') - .replace(/[*+?^${}()|[\]\\]/g, '\\$&'); - }) - .join(''); + .map((part) => { + if (part) + return part.dynamic + ? '([^/]+?)' + : part.content + .normalize() + .replace(/\?/g, '%3F') + .replace(/#/g, '%23') + .replace(/%5B/g, '[') + .replace(/%5D/g, ']') + .replace(/[*+?^${}()|[\]\\]/g, '\\$&'); + }) + .join(''); }) .join('/'); } diff --git a/packages/vercel/src/serverless/adapter.ts b/packages/vercel/src/serverless/adapter.ts index 1d7e64de..c589c926 100644 --- a/packages/vercel/src/serverless/adapter.ts +++ b/packages/vercel/src/serverless/adapter.ts @@ -246,10 +246,10 @@ export default function vercelServerless({ if (vercelConfig.trailingSlash === true && config.trailingSlash === 'always') { logger.warn( '\n' + - `\tYour "vercel.json" \`trailingSlash\` configuration (set to \`true\`) will conflict with your Astro \`trailinglSlash\` configuration (set to \`"always"\`).\n` + - // biome-ignore lint/style/noUnusedTemplateLiteral: - `\tThis would cause infinite redirects under certain conditions and throw an \`ERR_TOO_MANY_REDIRECTS\` error.\n` + - `\tTo prevent this, your Astro configuration is updated to \`"ignore"\` during builds.\n` + `\tYour "vercel.json" \`trailingSlash\` configuration (set to \`true\`) will conflict with your Astro \`trailinglSlash\` configuration (set to \`"always"\`).\n` + + // biome-ignore lint/style/noUnusedTemplateLiteral: + `\tThis would cause infinite redirects under certain conditions and throw an \`ERR_TOO_MANY_REDIRECTS\` error.\n` + + `\tTo prevent this, your Astro configuration is updated to \`"ignore"\` during builds.\n` ); updateConfig({ trailingSlash: 'ignore', @@ -290,18 +290,18 @@ export default function vercelServerless({ logger.warn( // biome-ignore lint/style/noUnusedTemplateLiteral: `\n` + - `\tVercel's hosting plans might have limits to the number of functions you can create.\n` + - // biome-ignore lint/style/noUnusedTemplateLiteral: - `\tMake sure to check your plan carefully to avoid incurring additional costs.\n` + - // biome-ignore lint/style/noUnusedTemplateLiteral: - `\tYou can set functionPerRoute: false to prevent surpassing the limit.\n` + `\tVercel's hosting plans might have limits to the number of functions you can create.\n` + + // biome-ignore lint/style/noUnusedTemplateLiteral: + `\tMake sure to check your plan carefully to avoid incurring additional costs.\n` + + // biome-ignore lint/style/noUnusedTemplateLiteral: + `\tYou can set functionPerRoute: false to prevent surpassing the limit.\n` ); logger.warn( // biome-ignore lint/style/noUnusedTemplateLiteral: `\n` + - // biome-ignore lint/style/noUnusedTemplateLiteral: - `\t\`functionPerRoute\` is deprecated and will be removed in a future version of the adapter.\n` + // biome-ignore lint/style/noUnusedTemplateLiteral: + `\t\`functionPerRoute\` is deprecated and will be removed in a future version of the adapter.\n` ); } @@ -426,31 +426,31 @@ export default function vercelServerless({ ...routeDefinitions, ...(fourOhFourRoute ? [ - { - src: '/.*', - dest: fourOhFourRoute.prerender - ? '/404.html' - : _middlewareEntryPoint - ? MIDDLEWARE_PATH - : NODE_PATH, - status: 404, - }, - ] + { + src: '/.*', + dest: fourOhFourRoute.prerender + ? '/404.html' + : _middlewareEntryPoint + ? MIDDLEWARE_PATH + : NODE_PATH, + status: 404, + }, + ] : []), ], ...(imageService || imagesConfig ? { - images: imagesConfig - ? { - ...imagesConfig, - domains: [...imagesConfig.domains, ..._config.image.domains], - remotePatterns: [ - ...(imagesConfig.remotePatterns ?? []), - ..._config.image.remotePatterns, - ], - } - : getDefaultImageConfig(_config.image), - } + images: imagesConfig + ? { + ...imagesConfig, + domains: [...imagesConfig.domains, ..._config.image.domains], + remotePatterns: [ + ...(imagesConfig.remotePatterns ?? []), + ..._config.image.remotePatterns, + ], + } + : getDefaultImageConfig(_config.image), + } : {}), }); @@ -483,7 +483,7 @@ class VercelBuilder { readonly logger: AstroIntegrationLogger, readonly maxDuration?: number, readonly runtime = getRuntime(process, logger) - ) { } + ) {} async buildServerlessFolder(entry: URL, functionName: string) { const { config, includeFiles, excludeFiles, logger, NTF_CACHE, runtime, maxDuration } = this; @@ -563,11 +563,11 @@ function getRuntime(process: NodeJS.Process, logger: AstroIntegrationLogger): Ru // biome-ignore lint/style/noUnusedTemplateLiteral: // biome-ignore lint/style/useTemplate: `\n` + - `\tThe local Node.js version (${major}) is not supported by Vercel Serverless Functions.\n` + - // biome-ignore lint/style/noUnusedTemplateLiteral: - `\tYour project will use Node.js 18 as the runtime instead.\n` + - // biome-ignore lint/style/noUnusedTemplateLiteral: - `\tConsider switching your local version to 18.\n` + `\tThe local Node.js version (${major}) is not supported by Vercel Serverless Functions.\n` + + // biome-ignore lint/style/noUnusedTemplateLiteral: + `\tYour project will use Node.js 18 as the runtime instead.\n` + + // biome-ignore lint/style/noUnusedTemplateLiteral: + `\tConsider switching your local version to 18.\n` ); return 'nodejs18.x'; } @@ -596,10 +596,10 @@ function getRuntime(process: NodeJS.Process, logger: AstroIntegrationLogger): Ru // biome-ignore lint/style/noUnusedTemplateLiteral: // biome-ignore lint/style/useTemplate: `\n` + - `\tYour project is being built for Node.js ${major} as the runtime.\n` + - `\tThis version is deprecated by Vercel Serverless Functions, and scheduled to be disabled on ${removeDate}.\n` + - // biome-ignore lint/style/noUnusedTemplateLiteral: - `\tConsider upgrading your local version to 18.\n` + `\tYour project is being built for Node.js ${major} as the runtime.\n` + + `\tThis version is deprecated by Vercel Serverless Functions, and scheduled to be disabled on ${removeDate}.\n` + + // biome-ignore lint/style/noUnusedTemplateLiteral: + `\tConsider upgrading your local version to 18.\n` ); return `nodejs${major}.x`; } diff --git a/packages/vercel/src/speed-insights.ts b/packages/vercel/src/speed-insights.ts index e8634a27..84aadfc7 100644 --- a/packages/vercel/src/speed-insights.ts +++ b/packages/vercel/src/speed-insights.ts @@ -11,8 +11,8 @@ const getConnectionSpeed = () => { navigator['connection'] && // biome-ignore lint/complexity/useLiteralKeys: 'effectiveType' in (navigator['connection'] as unknown as { effectiveType: string }) - // biome-ignore lint/complexity/useLiteralKeys: - ? (navigator['connection'] as unknown as { effectiveType: string })['effectiveType'] + ? // biome-ignore lint/complexity/useLiteralKeys: + (navigator['connection'] as unknown as { effectiveType: string })['effectiveType'] : ''; }; diff --git a/packages/vercel/src/static/adapter.ts b/packages/vercel/src/static/adapter.ts index bb576299..4a5bdf96 100644 --- a/packages/vercel/src/static/adapter.ts +++ b/packages/vercel/src/static/adapter.ts @@ -128,29 +128,29 @@ export default function vercelStatic({ { handle: 'filesystem' }, ...(routes.find((route) => route.pathname === '/404') ? [ - { - // biome-ignore lint/style/noUnusedTemplateLiteral: - src: `/.*`, - // biome-ignore lint/style/noUnusedTemplateLiteral: - dest: `/404.html`, - status: 404, - }, - ] + { + // biome-ignore lint/style/noUnusedTemplateLiteral: + src: `/.*`, + // biome-ignore lint/style/noUnusedTemplateLiteral: + dest: `/404.html`, + status: 404, + }, + ] : []), ], ...(imageService || imagesConfig ? { - images: imagesConfig - ? { - ...imagesConfig, - domains: [...imagesConfig.domains, ..._config.image.domains], - remotePatterns: [ - ...(imagesConfig.remotePatterns ?? []), - ..._config.image.remotePatterns, - ], - } - : getDefaultImageConfig(_config.image), - } + images: imagesConfig + ? { + ...imagesConfig, + domains: [...imagesConfig.domains, ..._config.image.domains], + remotePatterns: [ + ...(imagesConfig.remotePatterns ?? []), + ..._config.image.remotePatterns, + ], + } + : getDefaultImageConfig(_config.image), + } : {}), }); },