[ci] format
This commit is contained in:
parent
80034c6cbc
commit
4edccae534
6 changed files with 26 additions and 26 deletions
|
@ -82,7 +82,7 @@ class AstroBuilder {
|
||||||
client: new URL('./client/', this.config.dist),
|
client: new URL('./client/', this.config.dist),
|
||||||
server: new URL('./server/', this.config.dist),
|
server: new URL('./server/', this.config.dist),
|
||||||
serverEntry: 'entry.mjs',
|
serverEntry: 'entry.mjs',
|
||||||
staticMode: undefined
|
staticMode: undefined,
|
||||||
};
|
};
|
||||||
await runHookBuildStart({ config: this.config, buildConfig });
|
await runHookBuildStart({ config: this.config, buildConfig });
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ class AstroBuilder {
|
||||||
|
|
||||||
// You're done! Time to clean up.
|
// You're done! Time to clean up.
|
||||||
await viteServer.close();
|
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']) {
|
if (logging.level && levels[logging.level] <= levels['info']) {
|
||||||
const buildMode = this.config.buildOptions.experimentalSsr ? 'ssr' : 'static';
|
const buildMode = this.config.buildOptions.experimentalSsr ? 'ssr' : 'static';
|
||||||
|
|
|
@ -218,7 +218,12 @@ export function timerMessage(message: string, startTime: number = performance.no
|
||||||
* A warning that SSR is experimental. Remove when we can.
|
* A warning that SSR is experimental. Remove when we can.
|
||||||
*/
|
*/
|
||||||
export function warnIfUsingExperimentalSSR(opts: LogOptions, config: AstroConfig) {
|
export function warnIfUsingExperimentalSSR(opts: LogOptions, config: AstroConfig) {
|
||||||
if(isBuildingToSSR(config)) {
|
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.`);
|
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.`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) {
|
for (const integration of config.integrations) {
|
||||||
if (integration.hooks['astro:build:done']) {
|
if (integration.hooks['astro:build:done']) {
|
||||||
await integration.hooks['astro:build:done']({ pages: pages.map((p) => ({ pathname: p })), dir: config.dist, routes });
|
await integration.hooks['astro:build:done']({ pages: pages.map((p) => ({ pathname: p })), dir: config.dist, routes });
|
||||||
|
|
|
@ -6,7 +6,7 @@ export function getAdapter(site: string | undefined): AstroAdapter {
|
||||||
name: '@astrojs/netlify',
|
name: '@astrojs/netlify',
|
||||||
serverEntrypoint: '@astrojs/netlify/netlify-functions.js',
|
serverEntrypoint: '@astrojs/netlify/netlify-functions.js',
|
||||||
exports: ['handler'],
|
exports: ['handler'],
|
||||||
args: { site }
|
args: { site },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ function netlifyFunctions({ dist }: NetlifyFunctionsOptions = {}): AstroIntegrat
|
||||||
name: '@astrojs/netlify',
|
name: '@astrojs/netlify',
|
||||||
hooks: {
|
hooks: {
|
||||||
'astro:config:setup': ({ config }) => {
|
'astro:config:setup': ({ config }) => {
|
||||||
if(dist) {
|
if (dist) {
|
||||||
config.dist = dist;
|
config.dist = dist;
|
||||||
} else {
|
} else {
|
||||||
config.dist = new URL('./netlify/', config.projectRoot);
|
config.dist = new URL('./netlify/', config.projectRoot);
|
||||||
|
@ -31,7 +31,7 @@ function netlifyFunctions({ dist }: NetlifyFunctionsOptions = {}): AstroIntegrat
|
||||||
setAdapter(getAdapter(config.buildOptions.site));
|
setAdapter(getAdapter(config.buildOptions.site));
|
||||||
_config = config;
|
_config = config;
|
||||||
},
|
},
|
||||||
'astro:build:start': async({ buildConfig }) => {
|
'astro:build:start': async ({ buildConfig }) => {
|
||||||
entryFile = buildConfig.serverEntry.replace(/\.m?js/, '');
|
entryFile = buildConfig.serverEntry.replace(/\.m?js/, '');
|
||||||
buildConfig.client = _config.dist;
|
buildConfig.client = _config.dist;
|
||||||
buildConfig.server = new URL('./functions/', _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.
|
// Create the redirects file that is used for routing.
|
||||||
let _redirects = '';
|
let _redirects = '';
|
||||||
for(const route of routes) {
|
for (const route of routes) {
|
||||||
if(route.pathname) {
|
if (route.pathname) {
|
||||||
_redirects += `
|
_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');
|
await fs.promises.appendFile(_redirectsURL, _redirects, 'utf-8');
|
||||||
} else {
|
} else {
|
||||||
await fs.promises.writeFile(_redirectsURL, _redirects, 'utf-8');
|
await fs.promises.writeFile(_redirectsURL, _redirects, 'utf-8');
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export { netlifyFunctions, netlifyFunctions as default };
|
||||||
netlifyFunctions,
|
|
||||||
netlifyFunctions as default
|
|
||||||
};
|
|
||||||
|
|
|
@ -1,3 +1 @@
|
||||||
export {
|
export { netlifyFunctions as default } from './index.js';
|
||||||
netlifyFunctions as default
|
|
||||||
} from './index.js';
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { SSRManifest } from 'astro';
|
import { SSRManifest } from 'astro';
|
||||||
import type { Handler } from "@netlify/functions";
|
import type { Handler } from '@netlify/functions';
|
||||||
import { App } from 'astro/app';
|
import { App } from 'astro/app';
|
||||||
import { polyfill } from '@astrojs/webapi';
|
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 headers = new Headers(event.headers as any);
|
||||||
const request = new Request(new URL(event.path, site).toString(), {
|
const request = new Request(new URL(event.path, site).toString(), {
|
||||||
method: event.httpMethod,
|
method: event.httpMethod,
|
||||||
headers
|
headers,
|
||||||
});
|
});
|
||||||
|
|
||||||
if(!app.match(request)) {
|
if (!app.match(request)) {
|
||||||
return {
|
return {
|
||||||
statusCode: 404,
|
statusCode: 404,
|
||||||
body: 'Not found'
|
body: 'Not found',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,9 +35,9 @@ export const createExports = (manifest: SSRManifest, args: Args) => {
|
||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
headers: Object.fromEntries(response.headers.entries()),
|
headers: Object.fromEntries(response.headers.entries()),
|
||||||
body
|
body,
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
return { handler };
|
return { handler };
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue