[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 */ /* eslint-disable no-console */
import { LogOptions } from '../core/logger/core.js';
import * as colors from 'kleur/colors'; import * as colors from 'kleur/colors';
import yargs from 'yargs-parser'; import yargs from 'yargs-parser';
import { z } from 'zod'; 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 add from '../core/add/index.js';
import build from '../core/build/index.js'; import build from '../core/build/index.js';
import { openConfig } from '../core/config.js'; import { openConfig } from '../core/config.js';
import devServer from '../core/dev/index.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 { enableVerboseLogging, nodeLogDestination } from '../core/logger/node.js';
import { formatConfigErrorMessage, formatErrorMessage, printHelp } from '../core/messages.js'; import { formatConfigErrorMessage, formatErrorMessage, printHelp } from '../core/messages.js';
import preview from '../core/preview/index.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 { check } from './check.js';
import { openInBrowser } from './open.js'; import { openInBrowser } from './open.js';
import * as telemetryHandler from './telemetry.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 Arguments = yargs.Arguments;
type CLICommand = type CLICommand =

View file

@ -18,7 +18,7 @@ import type { AddressInfo } from 'net';
import os from 'os'; import os from 'os';
import { ZodError } from 'zod'; import { ZodError } from 'zod';
import type { AstroConfig } from '../@types/astro'; 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'; import { emoji, getLocalAddress, padMultilineString } from './util.js';
const PREFIX_PADDING = 6; const PREFIX_PADDING = 6;

View file

@ -1,6 +1,6 @@
import { AstroTelemetry } from '@astrojs/telemetry'; import { AstroTelemetry } from '@astrojs/telemetry';
import { ASTRO_VERSION } from '../core/util.js';
import { createRequire } from 'module'; import { createRequire } from 'module';
import { ASTRO_VERSION } from '../core/util.js';
const require = createRequire(import.meta.url); const require = createRequire(import.meta.url);
function getViteVersion() { function getViteVersion() {
@ -11,8 +11,10 @@ function getViteVersion() {
return undefined; 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 './error.js';
export * from './session.js'; export * from './session.js';

View file

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

View file

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

View file

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

View file

@ -1,5 +1,5 @@
export { pathToPosix } from './lib/utils'; 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: { export declare const polyfill: {
(target: any, options?: PolyfillOptions): any; (target: any, options?: PolyfillOptions): any;
internals(target: any, name: string): any; internals(target: any, name: string): any;