[ci] format
This commit is contained in:
parent
31ec847972
commit
e9c8e6a2c0
9 changed files with 24 additions and 22 deletions
|
@ -3,7 +3,7 @@ import { testFactory, getErrorOverlayContent } from './test-utils.js';
|
|||
|
||||
const test = testFactory({
|
||||
experimentalErrorOverlay: true,
|
||||
root: './fixtures/error-cyclic/'
|
||||
root: './fixtures/error-cyclic/',
|
||||
});
|
||||
|
||||
let devServer;
|
||||
|
|
|
@ -3,7 +3,7 @@ import { testFactory, getErrorOverlayContent } from './test-utils.js';
|
|||
|
||||
const test = testFactory({
|
||||
experimentalErrorOverlay: true,
|
||||
root: './fixtures/error-react-spectrum/'
|
||||
root: './fixtures/error-react-spectrum/',
|
||||
});
|
||||
|
||||
let devServer;
|
||||
|
|
|
@ -3,7 +3,7 @@ import { testFactory, getErrorOverlayContent } from './test-utils.js';
|
|||
|
||||
const test = testFactory({
|
||||
experimentalErrorOverlay: true,
|
||||
root: './fixtures/error-sass/'
|
||||
root: './fixtures/error-sass/',
|
||||
});
|
||||
|
||||
let devServer;
|
||||
|
|
|
@ -3,7 +3,7 @@ import { getErrorOverlayContent, testFactory } from './test-utils.js';
|
|||
|
||||
const test = testFactory({
|
||||
experimentalErrorOverlay: true,
|
||||
root: './fixtures/errors/'
|
||||
root: './fixtures/errors/',
|
||||
});
|
||||
|
||||
let devServer;
|
||||
|
|
|
@ -100,7 +100,10 @@ export function resolveFlags(flags: Partial<Flags>): CLIFlags {
|
|||
host:
|
||||
typeof flags.host === 'string' || typeof flags.host === 'boolean' ? flags.host : undefined,
|
||||
drafts: typeof flags.drafts === 'boolean' ? flags.drafts : undefined,
|
||||
experimentalErrorOverlay: typeof flags.experimentalErrorOverlay === 'boolean' ? flags.experimentalErrorOverlay : undefined,
|
||||
experimentalErrorOverlay:
|
||||
typeof flags.experimentalErrorOverlay === 'boolean'
|
||||
? flags.experimentalErrorOverlay
|
||||
: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -3,13 +3,13 @@ import type * as Postcss from 'postcss';
|
|||
import type { ILanguageRegistration, IThemeRegistration, Theme } from 'shiki';
|
||||
import type { AstroUserConfig, ViteUserConfig } from '../../@types/astro';
|
||||
|
||||
import { OutgoingHttpHeaders } from 'http';
|
||||
import postcssrc from 'postcss-load-config';
|
||||
import { BUNDLED_THEMES } from 'shiki';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { z } from 'zod';
|
||||
import { appendForwardSlash, prependForwardSlash, trimSlashes } from '../path.js';
|
||||
import { isObject } from '../util.js';
|
||||
import { OutgoingHttpHeaders } from 'http';
|
||||
|
||||
const ASTRO_CONFIG_DEFAULTS: AstroUserConfig & any = {
|
||||
root: '.',
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
import { escape } from 'html-escaper';
|
||||
import { bold, underline } from 'kleur/colors';
|
||||
import * as fs from 'node:fs';
|
||||
import { isAbsolute, join } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import stripAnsi from 'strip-ansi';
|
||||
import { escape } from 'html-escaper';
|
||||
import type { BuildResult } from 'esbuild';
|
||||
import type { ESBuildTransformResult } from 'vite';
|
||||
import type { SSRError } from '../../../@types/astro.js';
|
||||
import { AggregateError, ErrorWithMetadata } from '../errors.js';
|
||||
import { codeFrame } from '../printer.js';
|
||||
import { normalizeLF } from '../utils.js';
|
||||
import { bold, underline } from 'kleur/colors';
|
||||
|
||||
type EsbuildMessage = ESBuildTransformResult['warnings'][number];
|
||||
|
||||
|
|
|
@ -561,25 +561,25 @@ function getOverlayCode() {
|
|||
}
|
||||
|
||||
export function patchOverlay(code: string, config: AstroConfig) {
|
||||
if(config.experimentalErrorOverlay) {
|
||||
if (config.experimentalErrorOverlay) {
|
||||
return code.replace('class ErrorOverlay', getOverlayCode() + '\nclass ViteErrorOverlay');
|
||||
} else {
|
||||
// Legacy overlay
|
||||
return (
|
||||
code
|
||||
// Transform links in the message to clickable links
|
||||
.replace(
|
||||
"this.text('.message-body', message.trim());",
|
||||
`const urlPattern = /(\\b(https?|ftp):\\/\\/[-A-Z0-9+&@#\\/%?=~_|!:,.;]*[-A-Z0-9+&@#\\/%=~_|])/gim;
|
||||
// Transform links in the message to clickable links
|
||||
.replace(
|
||||
"this.text('.message-body', message.trim());",
|
||||
`const urlPattern = /(\\b(https?|ftp):\\/\\/[-A-Z0-9+&@#\\/%?=~_|!:,.;]*[-A-Z0-9+&@#\\/%=~_|])/gim;
|
||||
function escapeHtml(unsafe){return unsafe.replace(/</g, "<").replace(/>/g, ">");}
|
||||
const escapedMessage = escapeHtml(message);
|
||||
this.root.querySelector(".message-body").innerHTML = escapedMessage.trim().replace(urlPattern, '<a href="$1" target="_blank">$1</a>');`
|
||||
)
|
||||
.replace('</style>', '.message-body a {\n color: #ededed;\n}\n</style>')
|
||||
// Hide `.tip` in Vite's ErrorOverlay
|
||||
.replace(/\.tip \{[^}]*\}/gm, '.tip {\n display: none;\n}')
|
||||
// Replace [vite] messages with [astro]
|
||||
.replace(/\[vite\]/g, '[astro]')
|
||||
)
|
||||
)
|
||||
.replace('</style>', '.message-body a {\n color: #ededed;\n}\n</style>')
|
||||
// Hide `.tip` in Vite's ErrorOverlay
|
||||
.replace(/\.tip \{[^}]*\}/gm, '.tip {\n display: none;\n}')
|
||||
// Replace [vite] messages with [astro]
|
||||
.replace(/\[vite\]/g, '[astro]')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import type * as vite from 'vite';
|
|||
import type { AstroSettings, ManifestData } from '../@types/astro';
|
||||
|
||||
import type fs from 'fs';
|
||||
import { patchOverlay } from '../core/errors/overlay.js';
|
||||
import { LogOptions } from '../core/logger/core.js';
|
||||
import { createViteLoader } from '../core/module-loader/index.js';
|
||||
import { createDevelopmentEnvironment } from '../core/render/dev/index.js';
|
||||
|
@ -9,7 +10,6 @@ import { createRouteManifest } from '../core/routing/index.js';
|
|||
import { baseMiddleware } from './base.js';
|
||||
import { createController } from './controller.js';
|
||||
import { handleRequest } from './request.js';
|
||||
import { patchOverlay } from '../core/errors/overlay.js';
|
||||
|
||||
export interface AstroPluginOptions {
|
||||
settings: AstroSettings;
|
||||
|
|
Loading…
Reference in a new issue