From 64f11c4ceee3eb38add28a1973886356ff6c8e0b Mon Sep 17 00:00:00 2001 From: matthewp Date: Fri, 9 Sep 2022 16:00:38 +0000 Subject: [PATCH] [ci] format --- packages/astro/src/cli/index.ts | 44 +++++++++++++++------------- packages/astro/src/core/config.ts | 4 +-- packages/astro/src/core/dev/index.ts | 2 +- packages/astro/src/core/messages.ts | 4 +-- 4 files changed, 29 insertions(+), 25 deletions(-) diff --git a/packages/astro/src/cli/index.ts b/packages/astro/src/cli/index.ts index 4d60ffc5fa..622505700a 100644 --- a/packages/astro/src/cli/index.ts +++ b/packages/astro/src/cli/index.ts @@ -1,17 +1,19 @@ /* eslint-disable no-console */ -import type { Arguments as Flags } from 'yargs-parser' import * as colors from 'kleur/colors'; +import { pathToFileURL } from 'url'; +import { normalizePath } from 'vite'; +import type { Arguments as Flags } from 'yargs-parser'; import yargs from 'yargs-parser'; import { z } from 'zod'; -import { normalizePath } from 'vite'; import add from '../core/add/index.js'; import build from '../core/build/index.js'; import { openConfig, resolveConfigPath, resolveFlags, resolveRoot } from '../core/config.js'; import devServer from '../core/dev/index.js'; import { collectErrorMetadata } from '../core/errors.js'; -import { debug, error, info, LogOptions, warn } from '../core/logger/core.js'; +import { debug, error, info, LogOptions } from '../core/logger/core.js'; import { enableVerboseLogging, nodeLogDestination } from '../core/logger/node.js'; import { formatConfigErrorMessage, formatErrorMessage, printHelp } from '../core/messages.js'; +import { appendForwardSlash } from '../core/path.js'; import preview from '../core/preview/index.js'; import { ASTRO_VERSION, createSafeError } from '../core/util.js'; import * as event from '../events/index.js'; @@ -19,8 +21,6 @@ import { eventConfigError, eventError, telemetry } from '../events/index.js'; import { check } from './check/index.js'; import { openInBrowser } from './open.js'; import * as telemetryHandler from './telemetry.js'; -import { appendForwardSlash } from '../core/path.js'; -import { pathToFileURL } from 'url' type Arguments = yargs.Arguments; type CLICommand = @@ -84,13 +84,18 @@ function resolveCommand(flags: Arguments): CLICommand { return 'help'; } -async function handleConfigError(e: any, { cwd, flags, logging }: { cwd?: string; flags?: Flags, logging: LogOptions }) { +async function handleConfigError( + e: any, + { cwd, flags, logging }: { cwd?: string; flags?: Flags; logging: LogOptions } +) { const path = await resolveConfigPath({ cwd, flags }); if (e instanceof Error) { if (path) { error(logging, 'astro', `Unable to load ${colors.bold(path)}\n`); } - console.error(formatErrorMessage(collectErrorMetadata(e, path ? pathToFileURL(path) : undefined)) + '\n') + console.error( + formatErrorMessage(collectErrorMetadata(e, path ? pathToFileURL(path) : undefined)) + '\n' + ); } } @@ -145,16 +150,16 @@ async function runCommand(cmd: string, flags: yargs.Arguments) { } } - let { astroConfig, userConfig } = await openConfig({ - cwd: root, - flags, - cmd, - logging, - }).catch(async (e) => { - await handleConfigError(e, { cwd: root, flags, logging }) - return {} as any; - }); - if (!astroConfig) return; + let { astroConfig, userConfig } = await openConfig({ + cwd: root, + flags, + cmd, + logging, + }).catch(async (e) => { + await handleConfigError(e, { cwd: root, flags, logging }); + return {} as any; + }); + if (!astroConfig) return; telemetry.record(event.eventCliSession(cmd, userConfig, flags)); // Common CLI Commands: @@ -184,7 +189,7 @@ async function runCommand(cmd: string, flags: yargs.Arguments) { ).test(normalizePath(changedFile))) ) { restartInFlight = true; - console.clear() + console.clear(); try { const newConfig = await openConfig({ cwd: root, @@ -198,11 +203,10 @@ async function runCommand(cmd: string, flags: yargs.Arguments) { await stop(); await startDevServer({ isRestart: true }); } catch (e) { - await handleConfigError(e, { cwd: root, flags, logging }) + await handleConfigError(e, { cwd: root, flags, logging }); await stop(); info(logging, 'astro', 'Continuing with previous valid configuration\n'); await startDevServer({ isRestart: true }); - } } }; diff --git a/packages/astro/src/core/config.ts b/packages/astro/src/core/config.ts index d56f99958f..611584b762 100644 --- a/packages/astro/src/core/config.ts +++ b/packages/astro/src/core/config.ts @@ -1,9 +1,9 @@ import type { RehypePlugin, RemarkPlugin, RemarkRehype } from '@astrojs/markdown-remark'; +import fs from 'fs'; import type * as Postcss from 'postcss'; import type { ILanguageRegistration, IThemeRegistration, Theme } from 'shiki'; import type { Arguments as Flags } from 'yargs-parser'; import type { AstroConfig, AstroUserConfig, CLIFlags, ViteUserConfig } from '../@types/astro'; -import fs from 'fs'; import load, { ProloadError, resolve } from '@proload/core'; import loadTypeScript from '@proload/plugin-tsm'; @@ -437,7 +437,7 @@ export async function resolveConfigPath( if (e instanceof ProloadError && flags.config) { throw new Error(`Unable to resolve --config "${flags.config}"! Does the file exist?`); } - throw e + throw e; } } diff --git a/packages/astro/src/core/dev/index.ts b/packages/astro/src/core/dev/index.ts index d7b0780acc..e8069db909 100644 --- a/packages/astro/src/core/dev/index.ts +++ b/packages/astro/src/core/dev/index.ts @@ -68,7 +68,7 @@ export default async function dev(config: AstroConfig, options: DevOptions): Pro devServerAddressInfo, site, https: !!viteConfig.server?.https, - isRestart + isRestart, }) ); diff --git a/packages/astro/src/core/messages.ts b/packages/astro/src/core/messages.ts index a2ce5c2042..f140e052fb 100644 --- a/packages/astro/src/core/messages.ts +++ b/packages/astro/src/core/messages.ts @@ -58,14 +58,14 @@ export function devStart({ config, https, site, - isRestart = false + isRestart = false, }: { startupTime: number; devServerAddressInfo: AddressInfo; config: AstroConfig; https: boolean; site: URL | undefined; - isRestart?: boolean + isRestart?: boolean; }): string { // PACKAGE_VERSION is injected at build-time const version = process.env.PACKAGE_VERSION ?? '0.0.0';