[ci] format

This commit is contained in:
FredKSchott 2022-06-29 21:56:28 +00:00 committed by fredkbot
parent 4bc6c7ceaa
commit a99a54d344
8 changed files with 36 additions and 35 deletions

View file

@ -1,24 +1,23 @@
/* eslint-disable no-console */
import { LogOptions } from '../core/logger/core.js';
import * as colors from 'kleur/colors';
import yargs from 'yargs-parser';
import { z } from 'zod';
import { telemetry } from '../events/index.js';
import * as event from '../events/index.js';
import add from '../core/add/index.js';
import build from '../core/build/index.js';
import { openConfig } from '../core/config.js';
import devServer from '../core/dev/index.js';
import { collectErrorMetadata } from '../core/errors.js';
import { LogOptions } from '../core/logger/core.js';
import { enableVerboseLogging, nodeLogDestination } from '../core/logger/node.js';
import { formatConfigErrorMessage, formatErrorMessage, printHelp } from '../core/messages.js';
import preview from '../core/preview/index.js';
import { createSafeError, ASTRO_VERSION } from '../core/util.js';
import { ASTRO_VERSION, createSafeError } from '../core/util.js';
import * as event from '../events/index.js';
import { eventConfigError, eventError, telemetry } from '../events/index.js';
import { check } from './check.js';
import { openInBrowser } from './open.js';
import * as telemetryHandler from './telemetry.js';
import { collectErrorMetadata } from '../core/errors.js';
import { eventError, eventConfigError } from '../events/index.js';
type Arguments = yargs.Arguments;
type CLICommand =

View file

@ -18,7 +18,7 @@ import type { AddressInfo } from 'net';
import os from 'os';
import { ZodError } from 'zod';
import type { AstroConfig } from '../@types/astro';
import { cleanErrorStack, collectErrorMetadata, ErrorWithMetadata } from './errors.js';
import { cleanErrorStack, ErrorWithMetadata } from './errors.js';
import { emoji, getLocalAddress, padMultilineString } from './util.js';
const PREFIX_PADDING = 6;

View file

@ -1,6 +1,6 @@
import { AstroTelemetry } from '@astrojs/telemetry';
import { ASTRO_VERSION } from '../core/util.js';
import { createRequire } from 'module';
import { ASTRO_VERSION } from '../core/util.js';
const require = createRequire(import.meta.url);
function getViteVersion() {
@ -11,8 +11,10 @@ function getViteVersion() {
return undefined;
}
export const telemetry = new AstroTelemetry({ astroVersion: ASTRO_VERSION, viteVersion: getViteVersion() });
export const telemetry = new AstroTelemetry({
astroVersion: ASTRO_VERSION,
viteVersion: getViteVersion(),
});
export * from './error.js';
export * from './session.js';

View file

@ -5,10 +5,10 @@ import type { TransformHook } from './styles';
import { transform } from '@astrojs/compiler';
import { fileURLToPath } from 'url';
import { AstroErrorCodes } from '../core/errors.js';
import { prependForwardSlash } from '../core/path.js';
import { viteID } from '../core/util.js';
import { transformWithVite } from './styles.js';
import { AstroErrorCodes } from '../core/errors.js';
type CompilationCache = Map<string, CompileResult>;
type CompileResult = TransformResult & { rawCSSDeps: Set<string> };
@ -121,18 +121,21 @@ async function compile({
return null;
}
},
}).catch((err) => {
// throw compiler errors here if encountered
err.code = err.code || AstroErrorCodes.UnknownCompilerError;
throw err;
}).then((result) => {
// throw CSS transform errors here if encountered
if (cssTransformError) {
(cssTransformError as any).code = (cssTransformError as any).code || AstroErrorCodes.UnknownCompilerCSSError;
throw cssTransformError;
}
return result;
});
})
.catch((err) => {
// throw compiler errors here if encountered
err.code = err.code || AstroErrorCodes.UnknownCompilerError;
throw err;
})
.then((result) => {
// throw CSS transform errors here if encountered
if (cssTransformError) {
(cssTransformError as any).code =
(cssTransformError as any).code || AstroErrorCodes.UnknownCompilerCSSError;
throw cssTransformError;
}
return result;
});
const compileResult: CompileResult = Object.create(transformResult, {
rawCSSDeps: {

View file

@ -97,5 +97,4 @@ describe('Error display', () => {
expect($('h1').text()).to.equal('No mismatch');
});
});
});

View file

@ -3,7 +3,6 @@ import { AstroErrorCodes } from '../dist/core/errors.js';
import * as events from '../dist/events/index.js';
describe('Events', () => {
describe('eventCliSession()', () => {
it('All top-level keys added', () => {
const config = {
@ -422,7 +421,7 @@ describe('Events', () => {
const [event] = events.eventConfigError({
err: { issues: [{ path: ['a', 'b', 'c'] }, { path: ['d', 'e', 'f'] }] },
cmd: 'COMMAND_NAME',
isFatal: true
isFatal: true,
});
expect(event).to.deep.equal({
eventName: 'ASTRO_CLI_ERROR',
@ -432,7 +431,7 @@ describe('Events', () => {
isConfig: true,
cliCommand: 'COMMAND_NAME',
configErrorPaths: ['a.b.c', 'd.e.f'],
}
},
});
});
});
@ -445,7 +444,7 @@ describe('Events', () => {
const [event] = events.eventError({
err: errorWithFullMetadata,
cmd: 'COMMAND_NAME',
isFatal: true
isFatal: true,
});
expect(event).to.deep.equal({
eventName: 'ASTRO_CLI_ERROR',
@ -455,7 +454,7 @@ describe('Events', () => {
isFatal: true,
cliCommand: 'COMMAND_NAME',
anonymousMessageHint: 'TEST ERROR MESSAGE',
}
},
});
});
@ -463,7 +462,7 @@ describe('Events', () => {
const [event] = events.eventError({
err: new Error('TEST ERROR MESSAGE'),
cmd: 'COMMAND_NAME',
isFatal: false
isFatal: false,
});
expect(event).to.deep.equal({
eventName: 'ASTRO_CLI_ERROR',
@ -473,7 +472,7 @@ describe('Events', () => {
isFatal: false,
cliCommand: 'COMMAND_NAME',
anonymousMessageHint: 'TEST ERROR MESSAGE',
}
},
});
});
@ -481,10 +480,9 @@ describe('Events', () => {
const [event] = events.eventError({
err: new Error('TEST ERROR MESSAGE: Sensitive data is "/Users/MYNAME/foo.astro"'),
cmd: 'COMMAND_NAME',
isFatal: true
isFatal: true,
});
expect(event.payload.anonymousMessageHint).to.equal('TEST ERROR MESSAGE');
});
});
});

View file

@ -46,7 +46,7 @@ export type SystemInfo = {
let meta: SystemInfo | undefined;
export function getSystemInfo(versions: {viteVersion: string, astroVersion: string}): SystemInfo {
export function getSystemInfo(versions: { viteVersion: string; astroVersion: string }): SystemInfo {
if (meta) {
return meta;
}

View file

@ -1,5 +1,5 @@
export { pathToPosix } from './lib/utils';
export { AbortController, AbortSignal, alert, atob, Blob, btoa, ByteLengthQueuingStrategy, cancelAnimationFrame, cancelIdleCallback, CanvasRenderingContext2D, CharacterData, clearTimeout, Comment, CountQueuingStrategy, CSSStyleSheet, CustomElementRegistry, CustomEvent, Document, DocumentFragment, DOMException, Element, Event, EventTarget, fetch, File, FormData, Headers, HTMLBodyElement, HTMLCanvasElement, HTMLDivElement, HTMLDocument, HTMLElement, HTMLHeadElement, HTMLHtmlElement, HTMLImageElement, HTMLSpanElement, HTMLStyleElement, HTMLTemplateElement, HTMLUnknownElement, Image, ImageData, IntersectionObserver, MediaQueryList, MutationObserver, Node, NodeFilter, NodeIterator, OffscreenCanvas, ReadableByteStreamController, ReadableStream, ReadableStreamBYOBReader, ReadableStreamBYOBRequest, ReadableStreamDefaultController, ReadableStreamDefaultReader, Request, requestAnimationFrame, requestIdleCallback, ResizeObserver, Response, setTimeout, ShadowRoot, structuredClone, StyleSheet, Text, TransformStream, TreeWalker, URLPattern, Window, WritableStream, WritableStreamDefaultController, WritableStreamDefaultWriter, } from './mod.js';
export { AbortController, AbortSignal, alert, atob, Blob, btoa, ByteLengthQueuingStrategy, cancelAnimationFrame, cancelIdleCallback, CanvasRenderingContext2D, CharacterData, clearTimeout, Comment, CountQueuingStrategy, CSSStyleSheet, CustomElementRegistry, CustomEvent, Document, DocumentFragment, DOMException, Element, Event, EventTarget, fetch, File, FormData, Headers, HTMLBodyElement, HTMLCanvasElement, HTMLDivElement, HTMLDocument, HTMLElement, HTMLHeadElement, HTMLHtmlElement, HTMLImageElement, HTMLSpanElement, HTMLStyleElement, HTMLTemplateElement, HTMLUnknownElement, Image, ImageData, IntersectionObserver, MediaQueryList, MutationObserver, Node, NodeFilter, NodeIterator, OffscreenCanvas, ReadableByteStreamController, ReadableStream, ReadableStreamBYOBReader, ReadableStreamBYOBRequest, ReadableStreamDefaultController, ReadableStreamDefaultReader, Request, requestAnimationFrame, requestIdleCallback, ResizeObserver, Response, setTimeout, ShadowRoot, structuredClone, StyleSheet, Text, TransformStream, TreeWalker, URLPattern, Window, WritableStream, WritableStreamDefaultController, WritableStreamDefaultWriter } from './mod.js';
export declare const polyfill: {
(target: any, options?: PolyfillOptions): any;
internals(target: any, name: string): any;