[ci] format

This commit is contained in:
matthewp 2022-03-25 16:08:51 +00:00 committed by GitHub Actions
parent 80034c6cbc
commit 4edccae534
6 changed files with 26 additions and 26 deletions

View file

@ -82,7 +82,7 @@ class AstroBuilder {
client: new URL('./client/', this.config.dist),
server: new URL('./server/', this.config.dist),
serverEntry: 'entry.mjs',
staticMode: undefined
staticMode: undefined,
};
await runHookBuildStart({ config: this.config, buildConfig });
@ -173,7 +173,7 @@ class AstroBuilder {
// You're done! Time to clean up.
await viteServer.close();
await runHookBuildDone({ config: this.config, pages: pageNames, routes: Object.values(allPages).map(pd => pd.route) });
await runHookBuildDone({ config: this.config, pages: pageNames, routes: Object.values(allPages).map((pd) => pd.route) });
if (logging.level && levels[logging.level] <= levels['info']) {
const buildMode = this.config.buildOptions.experimentalSsr ? 'ssr' : 'static';

View file

@ -218,7 +218,12 @@ export function timerMessage(message: string, startTime: number = performance.no
* A warning that SSR is experimental. Remove when we can.
*/
export function warnIfUsingExperimentalSSR(opts: LogOptions, config: AstroConfig) {
if(isBuildingToSSR(config)) {
warn(opts, 'warning', bold(`Warning:`), ` SSR support is still experimental and subject to API changes. If using in production pin your dependencies to prevent accidental breakage.`);
if (isBuildingToSSR(config)) {
warn(
opts,
'warning',
bold(`Warning:`),
` SSR support is still experimental and subject to API changes. If using in production pin your dependencies to prevent accidental breakage.`
);
}
}

View file

@ -91,7 +91,7 @@ export async function runHookBuildStart({ config, buildConfig }: { config: Astro
}
}
export async function runHookBuildDone({ config, pages, routes }: { config: AstroConfig; pages: string[], routes: RouteData[] }) {
export async function runHookBuildDone({ config, pages, routes }: { config: AstroConfig; pages: string[]; routes: RouteData[] }) {
for (const integration of config.integrations) {
if (integration.hooks['astro:build:done']) {
await integration.hooks['astro:build:done']({ pages: pages.map((p) => ({ pathname: p })), dir: config.dist, routes });

View file

@ -6,7 +6,7 @@ export function getAdapter(site: string | undefined): AstroAdapter {
name: '@astrojs/netlify',
serverEntrypoint: '@astrojs/netlify/netlify-functions.js',
exports: ['handler'],
args: { site }
args: { site },
};
}
@ -21,7 +21,7 @@ function netlifyFunctions({ dist }: NetlifyFunctionsOptions = {}): AstroIntegrat
name: '@astrojs/netlify',
hooks: {
'astro:config:setup': ({ config }) => {
if(dist) {
if (dist) {
config.dist = dist;
} else {
config.dist = new URL('./netlify/', config.projectRoot);
@ -31,7 +31,7 @@ function netlifyFunctions({ dist }: NetlifyFunctionsOptions = {}): AstroIntegrat
setAdapter(getAdapter(config.buildOptions.site));
_config = config;
},
'astro:build:start': async({ buildConfig }) => {
'astro:build:start': async ({ buildConfig }) => {
entryFile = buildConfig.serverEntry.replace(/\.m?js/, '');
buildConfig.client = _config.dist;
buildConfig.server = new URL('./functions/', _config.dist);
@ -41,24 +41,21 @@ function netlifyFunctions({ dist }: NetlifyFunctionsOptions = {}): AstroIntegrat
// Create the redirects file that is used for routing.
let _redirects = '';
for(const route of routes) {
if(route.pathname) {
for (const route of routes) {
if (route.pathname) {
_redirects += `
${route.pathname} /.netlify/functions/${entryFile} 200`
${route.pathname} /.netlify/functions/${entryFile} 200`;
}
}
if(fs.existsSync(_redirects)) {
if (fs.existsSync(_redirects)) {
await fs.promises.appendFile(_redirectsURL, _redirects, 'utf-8');
} else {
await fs.promises.writeFile(_redirectsURL, _redirects, 'utf-8');
}
}
},
},
};
}
export {
netlifyFunctions,
netlifyFunctions as default
};
export { netlifyFunctions, netlifyFunctions as default };

View file

@ -1,3 +1 @@
export {
netlifyFunctions as default
} from './index.js';
export { netlifyFunctions as default } from './index.js';

View file

@ -1,5 +1,5 @@
import { SSRManifest } from 'astro';
import type { Handler } from "@netlify/functions";
import type { Handler } from '@netlify/functions';
import { App } from 'astro/app';
import { polyfill } from '@astrojs/webapi';
@ -19,13 +19,13 @@ export const createExports = (manifest: SSRManifest, args: Args) => {
const headers = new Headers(event.headers as any);
const request = new Request(new URL(event.path, site).toString(), {
method: event.httpMethod,
headers
headers,
});
if(!app.match(request)) {
if (!app.match(request)) {
return {
statusCode: 404,
body: 'Not found'
body: 'Not found',
};
}
@ -35,9 +35,9 @@ export const createExports = (manifest: SSRManifest, args: Args) => {
return {
statusCode: 200,
headers: Object.fromEntries(response.headers.entries()),
body
body,
};
}
};
return { handler };
};