Skip to content

Commit

Permalink
chore: format
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderniebuhr committed Aug 29, 2024
1 parent 4b17094 commit 2246e6e
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 77 deletions.
2 changes: 1 addition & 1 deletion packages/node/src/serve-static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
26 changes: 13 additions & 13 deletions packages/vercel/src/lib/redirects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('/');
}
Expand Down
84 changes: 42 additions & 42 deletions packages/vercel/src/serverless/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: <explanation>
`\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: <explanation>
`\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',
Expand Down Expand Up @@ -290,18 +290,18 @@ export default function vercelServerless({
logger.warn(
// biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
`\n` +
`\tVercel's hosting plans might have limits to the number of functions you can create.\n` +
// biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
`\tMake sure to check your plan carefully to avoid incurring additional costs.\n` +
// biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
`\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: <explanation>
`\tMake sure to check your plan carefully to avoid incurring additional costs.\n` +
// biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
`\tYou can set functionPerRoute: false to prevent surpassing the limit.\n`
);

logger.warn(
// biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
`\n` +
// biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
`\t\`functionPerRoute\` is deprecated and will be removed in a future version of the adapter.\n`
// biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
`\t\`functionPerRoute\` is deprecated and will be removed in a future version of the adapter.\n`
);
}

Expand Down Expand Up @@ -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),
}
: {}),
});

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -563,11 +563,11 @@ function getRuntime(process: NodeJS.Process, logger: AstroIntegrationLogger): Ru
// biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
// biome-ignore lint/style/useTemplate: <explanation>
`\n` +
`\tThe local Node.js version (${major}) is not supported by Vercel Serverless Functions.\n` +
// biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
`\tYour project will use Node.js 18 as the runtime instead.\n` +
// biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
`\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: <explanation>
`\tYour project will use Node.js 18 as the runtime instead.\n` +
// biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
`\tConsider switching your local version to 18.\n`
);
return 'nodejs18.x';
}
Expand Down Expand Up @@ -596,10 +596,10 @@ function getRuntime(process: NodeJS.Process, logger: AstroIntegrationLogger): Ru
// biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
// biome-ignore lint/style/useTemplate: <explanation>
`\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: <explanation>
`\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: <explanation>
`\tConsider upgrading your local version to 18.\n`
);
return `nodejs${major}.x`;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/vercel/src/speed-insights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const getConnectionSpeed = () => {
navigator['connection'] &&
// biome-ignore lint/complexity/useLiteralKeys: <explanation>
'effectiveType' in (navigator['connection'] as unknown as { effectiveType: string })
// biome-ignore lint/complexity/useLiteralKeys: <explanation>
? (navigator['connection'] as unknown as { effectiveType: string })['effectiveType']
? // biome-ignore lint/complexity/useLiteralKeys: <explanation>
(navigator['connection'] as unknown as { effectiveType: string })['effectiveType']
: '';
};

Expand Down
38 changes: 19 additions & 19 deletions packages/vercel/src/static/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,29 +128,29 @@ export default function vercelStatic({
{ handle: 'filesystem' },
...(routes.find((route) => route.pathname === '/404')
? [
{
// biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
src: `/.*`,
// biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
dest: `/404.html`,
status: 404,
},
]
{
// biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
src: `/.*`,
// biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
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),
}
: {}),
});
},
Expand Down

0 comments on commit 2246e6e

Please sign in to comment.