[ci] format

This commit is contained in:
matthewp 2022-07-19 20:11:53 +00:00 committed by fredkbot
parent 5a23483efb
commit 4ee997da43
10 changed files with 33 additions and 27 deletions

View file

@ -10,8 +10,8 @@ import type { RouteInfo, SSRManifest as Manifest } from './types';
import mime from 'mime';
import { call as callEndpoint } from '../endpoint/index.js';
import { error } from '../logger/core.js';
import { consoleLogDestination } from '../logger/console.js';
import { error } from '../logger/core.js';
import { joinPaths, prependForwardSlash } from '../path.js';
import { render } from '../render/core.js';
import { RouteCache } from '../render/route-cache.js';
@ -131,7 +131,7 @@ export class App {
error(this.#logging, 'ssr', err);
return new Response(null, {
status: 500,
statusText: 'Internal server error'
statusText: 'Internal server error',
});
}
}

View file

@ -148,7 +148,6 @@ class AstroBuilder {
throw err;
}
// Write any additionally generated assets to disk.
this.timer.assetsStart = performance.now();
Object.keys(assets).map((k) => {

View file

@ -144,8 +144,7 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp
}),
...(viteConfig.plugins || []),
// SSR needs to be last
isBuildingToSSR(opts.astroConfig) &&
vitePluginSSR(internals, opts.astroConfig._ctx.adapter!),
isBuildingToSSR(opts.astroConfig) && vitePluginSSR(internals, opts.astroConfig._ctx.adapter!),
vitePluginAnalyzer(opts.astroConfig, internals),
],
publicDir: ssr ? false : viteConfig.publicDir,

View file

@ -19,10 +19,7 @@ const resolvedVirtualModuleId = '\0' + virtualModuleId;
const manifestReplace = '@@ASTRO_MANIFEST_REPLACE@@';
const replaceExp = new RegExp(`['"](${manifestReplace})['"]`, 'g');
export function vitePluginSSR(
internals: BuildInternals,
adapter: AstroAdapter
): VitePlugin {
export function vitePluginSSR(internals: BuildInternals, adapter: AstroAdapter): VitePlugin {
return {
name: '@astrojs/vite-plugin-astro-ssr',
enforce: 'post',

View file

@ -159,9 +159,13 @@ export function createResult(args: CreateResultArgs): SSRResult {
get clientAddress() {
if (!(clientAddressSymbol in request)) {
if (args.adapterName) {
throw new Error(`Astro.clientAddress is not available in the ${args.adapterName} adapter. File an issue with the adapter to add support.`);
throw new Error(
`Astro.clientAddress is not available in the ${args.adapterName} adapter. File an issue with the adapter to add support.`
);
} else {
throw new Error(`Astro.clientAddress is not available in your environment. Ensure that you are using an SSR adapter that supports this feature.`)
throw new Error(
`Astro.clientAddress is not available in your environment. Ensure that you are using an SSR adapter that supports this feature.`
);
}
}

View file

@ -81,7 +81,7 @@ describe('Astro.clientAddress', () => {
const response = await app.render(request);
expect(response.status).to.equal(500);
});
})
});
describe('SSG', () => {
/** @type {import('./test-utils').Fixture} */
@ -99,9 +99,12 @@ describe('Astro.clientAddress', () => {
await fixture.build();
expect(false).to.equal(true, 'Build should not have completed');
} catch (err) {
expect(err.message).to.match(/Astro\.clientAddress/, 'Error message mentions Astro.clientAddress');
expect(err.message).to.match(
/Astro\.clientAddress/,
'Error message mentions Astro.clientAddress'
);
}
})
});
});
describe('Development', () => {
@ -125,6 +128,6 @@ describe('Astro.clientAddress', () => {
let res = await fixture.fetch('/');
expect(res.status).to.equal(500);
});
})
});
});
});

View file

@ -20,7 +20,11 @@ export function createExports(manifest: SSRManifest) {
}
if (app.match(request)) {
Reflect.set(request, Symbol.for('astro.clientAddress'), request.headers.get('cf-connecting-ip'));
Reflect.set(
request,
Symbol.for('astro.clientAddress'),
request.headers.get('cf-connecting-ip')
);
return app.render(request);
}