[ci] format

This commit is contained in:
matthewp 2022-09-16 15:31:14 +00:00 committed by fredkbot
parent f3a81d82f6
commit 64aa903f04
19 changed files with 64 additions and 65 deletions

View file

@ -882,7 +882,7 @@ export interface AstroSettings {
renderers: AstroRenderer[];
scripts: {
stage: InjectedScriptStage;
content: string
content: string;
}[];
tsConfig: TsConfigJson | undefined;
tsConfigPath: string | undefined;

View file

@ -7,7 +7,14 @@ import yargs from 'yargs-parser';
import { z } from 'zod';
import add from '../core/add/index.js';
import build from '../core/build/index.js';
import { openConfig, resolveConfigPath, resolveFlags, resolveRoot, createSettings, loadTSConfig } from '../core/config/index.js';
import {
createSettings,
loadTSConfig,
openConfig,
resolveConfigPath,
resolveFlags,
resolveRoot,
} from '../core/config/index.js';
import devServer from '../core/dev/index.js';
import { collectErrorMetadata } from '../core/errors.js';
import { debug, error, info, LogOptions } from '../core/logger/core.js';
@ -210,7 +217,7 @@ async function runCommand(cmd: string, flags: yargs.Arguments) {
settings = createSettings({
config: astroConfig,
tsConfig: tsconfig?.config,
tsConfigPath: tsconfig?.path
tsConfigPath: tsconfig?.path,
});
await stop();
await startDevServer({ isRestart: true });

View file

@ -62,7 +62,11 @@ class AstroBuilder {
debug('build', 'Initial setup...');
const { logging } = this;
this.timer.init = performance.now();
this.settings = await runHookConfigSetup({ settings: this.settings, command: 'build', logging });
this.settings = await runHookConfigSetup({
settings: this.settings,
command: 'build',
logging,
});
this.manifest = createRouteManifest({ settings: this.settings }, this.logging);
const viteConfig = await createVite(

View file

@ -151,8 +151,7 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp
}),
...(viteConfig.plugins || []),
// SSR needs to be last
settings.config.output === 'server' &&
vitePluginSSR(internals, settings.adapter!),
settings.config.output === 'server' && vitePluginSSR(internals, settings.adapter!),
vitePluginAnalyzer(internals),
],
publicDir: ssr ? false : viteConfig.publicDir,

View file

@ -1,5 +1,4 @@
import type { GetModuleInfo, OutputChunk } from 'rollup';
import type { AstroConfig } from '../../@types/astro';
import type { BuildInternals } from './internal';
import type { PageBuildData, StaticBuildOptions } from './types';

View file

@ -103,7 +103,11 @@ export async function injectManifest(buildOpts: StaticBuildOptions, internals: B
const staticFiles = internals.staticFiles;
const manifest = buildManifest(buildOpts, internals, Array.from(staticFiles));
await runHookBuildSsr({ config: buildOpts.settings.config, manifest, logging: buildOpts.logging });
await runHookBuildSsr({
config: buildOpts.settings.config,
manifest,
logging: buildOpts.logging,
});
const chunk = internals.ssrEntryChunk;
const code = chunk.code;

View file

@ -1,9 +1,9 @@
import type { Arguments as Flags } from 'yargs-parser';
import type { AstroConfig, AstroUserConfig, CLIFlags } from '../../@types/astro';
import fs from 'fs';
import load, { ProloadError, resolve } from '@proload/core';
import loadTypeScript from '@proload/plugin-tsm';
import fs from 'fs';
import * as colors from 'kleur/colors';
import path from 'path';
import { fileURLToPath, pathToFileURL } from 'url';
@ -27,7 +27,6 @@ export const LEGACY_ASTRO_CONFIG_KEYS = new Set([
'devOptions',
]);
/** Turn raw config values into normalized values */
export async function validateConfig(
userConfig: any,
@ -85,7 +84,7 @@ export async function validateConfig(
/* eslint-enable no-console */
const AstroConfigRelativeSchema = createRelativeSchema(cmd, fileProtocolRoot);
// First-Pass Validation
const result = await AstroConfigRelativeSchema.parseAsync(userConfig);

View file

@ -1,8 +1,3 @@
export type {
AstroConfigSchema
} from './schema';
export {
openConfig,
resolveConfigPath,
@ -10,11 +5,6 @@ export {
resolveRoot,
validateConfig,
} from './config.js';
export {
createSettings
} from './settings.js';
export {
loadTSConfig
} from './tsconfig.js';
export type { AstroConfigSchema } from './schema';
export { createSettings } from './settings.js';
export { loadTSConfig } from './tsconfig.js';

View file

@ -1,8 +1,5 @@
import type {
AstroConfig,
AstroSettings,
} from '../../@types/astro';
import type { TsConfigJson } from 'tsconfig-resolver';
import type { AstroConfig, AstroSettings } from '../../@types/astro';
import jsxRenderer from '../../jsx/renderer.js';
@ -12,11 +9,7 @@ export interface CreateSettings {
tsConfigPath?: string;
}
export function createSettings({
config,
tsConfig,
tsConfigPath,
}: CreateSettings): AstroSettings {
export function createSettings({ config, tsConfig, tsConfigPath }: CreateSettings): AstroSettings {
return {
config,
tsConfig,

View file

@ -28,7 +28,10 @@ export interface DevServer {
}
/** `astro dev` */
export default async function dev(settings: AstroSettings, options: DevOptions): Promise<DevServer> {
export default async function dev(
settings: AstroSettings,
options: DevOptions
): Promise<DevServer> {
const devStart = performance.now();
applyPolyfill();
await options.telemetry.record([]);
@ -58,7 +61,9 @@ export default async function dev(settings: AstroSettings, options: DevOptions):
await viteServer.listen(port);
const devServerAddressInfo = viteServer.httpServer!.address() as AddressInfo;
const site = settings.config.site ? new URL(settings.config.base, settings.config.site) : undefined;
const site = settings.config.site
? new URL(settings.config.base, settings.config.site)
: undefined;
info(
options.logging,
null,
@ -80,7 +85,11 @@ export default async function dev(settings: AstroSettings, options: DevOptions):
warn(options.logging, null, msg.fsStrictWarning());
}
await runHookServerStart({ config: settings.config, address: devServerAddressInfo, logging: options.logging });
await runHookServerStart({
config: settings.config,
address: devServerAddressInfo,
logging: options.logging,
});
return {
address: devServerAddressInfo,

View file

@ -1,8 +1,8 @@
import { fileURLToPath } from 'url';
import type { ViteDevServer } from 'vite';
import type {
AstroSettings,
AstroRenderer,
AstroSettings,
ComponentInstance,
RouteData,
RuntimeMode,
@ -191,7 +191,9 @@ export async function render(
request,
route,
routeCache,
site: settings.config.site ? new URL(settings.config.base, settings.config.site).toString() : undefined,
site: settings.config.site
? new URL(settings.config.base, settings.config.site).toString()
: undefined,
ssr: settings.config.output === 'server',
streaming: true,
});

View file

@ -1,8 +1,6 @@
import type { ModuleInfo } from 'rollup';
import slash from 'slash';
import { fileURLToPath } from 'url';
import vite from 'vite';
import type { AstroConfig, SSRElement } from '../../../@types/astro';
import type { SSRElement } from '../../../@types/astro';
import type { PluginMetadata as AstroPluginMetadata } from '../../../vite-plugin-astro/types';
import { viteID } from '../../util.js';
import { createModuleScriptElementWithSrc } from '../ssr-element.js';
@ -27,10 +25,7 @@ export async function getScriptsForURL(
return elements;
}
function addHoistedScripts(
set: Set<SSRElement>,
info: ModuleInfo | null,
) {
function addHoistedScripts(set: Set<SSRElement>, info: ModuleInfo | null) {
if (!info?.meta?.astro) {
return;
}

View file

@ -196,11 +196,7 @@ export function createRouteManifest(
): ManifestData {
const components: string[] = [];
const routes: RouteData[] = [];
const validPageExtensions: Set<string> = new Set([
'.astro',
'.md',
...settings.pageExtensions,
]);
const validPageExtensions: Set<string> = new Set(['.astro', '.md', ...settings.pageExtensions]);
const validEndpointExtensions: Set<string> = new Set(['.js', '.ts']);
function walk(dir: string, parentSegments: RoutePart[][], parentParams: string[]) {

View file

@ -3,8 +3,8 @@ import type { AddressInfo } from 'net';
import type { ViteDevServer } from 'vite';
import {
AstroConfig,
AstroSettings,
AstroRenderer,
AstroSettings,
BuildConfig,
HookParameters,
RouteData,
@ -47,7 +47,7 @@ export async function runHookConfigSetup({
if (settings.config.adapter) {
settings.config.integrations.push(settings.config.adapter);
}
let updatedConfig: AstroConfig = { ...settings.config };
let updatedSettings: AstroSettings = { ...settings, config: updatedConfig };
for (const integration of settings.config.integrations) {

View file

@ -50,9 +50,7 @@ function getReferencedPrivateKeys(source: string, privateEnv: Record<string, any
return references;
}
export default function envVitePlugin({
settings,
}: EnvPluginOptions): vite.PluginOption {
export default function envVitePlugin({ settings }: EnvPluginOptions): vite.PluginOption {
let privateEnv: Record<string, any> | null;
let config: vite.ResolvedConfig;
let replacements: Record<string, string>;

View file

@ -1,7 +1,7 @@
import type { TransformResult } from 'rollup';
import type { TsConfigJson } from 'tsconfig-resolver';
import type { Plugin, ResolvedConfig } from 'vite';
import type { AstroSettings, AstroRenderer } from '../@types/astro';
import type { AstroRenderer, AstroSettings } from '../@types/astro';
import type { LogOptions } from '../core/logger/core.js';
import type { PluginMetadata } from '../vite-plugin-astro/types';

View file

@ -6,7 +6,11 @@ import ancestor from 'common-ancestor-path';
import MagicString from 'magic-string';
import { isPage } from '../core/util.js';
export default function astroScriptsPostPlugin({ settings }: { settings: AstroSettings }): VitePlugin {
export default function astroScriptsPostPlugin({
settings,
}: {
settings: AstroSettings;
}): VitePlugin {
function normalizeFilename(filename: string) {
if (filename.startsWith('/@fs')) {
filename = filename.slice('/@fs'.length);

View file

@ -99,7 +99,7 @@ export async function loadFixture(inlineConfig) {
let settings = createSettings({
config,
tsConfig: tsconfig?.config,
tsConfigPath: tsconfig?.path
tsConfigPath: tsconfig?.path,
});
if (config.integrations.find((integration) => integration.name === '@astrojs/mdx')) {
// Enable default JSX integration. It needs to come first, so unshift rather than push!

View file

@ -11,7 +11,7 @@ describe('config.server', () => {
cwd: flags.root || cwd,
flags,
cmd: 'dev',
logging
logging,
});
}
@ -20,7 +20,7 @@ describe('config.server', () => {
const projectRootURL = new URL('../../fixtures/astro-basic/', import.meta.url);
const { astroConfig } = await openConfigWithFlags({
root: fileURLToPath(projectRootURL),
host: true
host: true,
});
expect(astroConfig.server.host).to.equal(true);
@ -34,7 +34,7 @@ describe('config.server', () => {
const configFileURL = 'my-config.mjs';
const { astroConfig } = await openConfigWithFlags({
root: fileURLToPath(projectRootURL),
config: configFileURL
config: configFileURL,
});
expect(astroConfig.server.port).to.equal(8080);
});
@ -46,7 +46,7 @@ describe('config.server', () => {
const configFileURL = './my-config.mjs';
const { astroConfig } = await openConfigWithFlags({
root: fileURLToPath(projectRootURL),
config: configFileURL
config: configFileURL,
});
expect(astroConfig.server.port).to.equal(8080);
});
@ -59,13 +59,13 @@ describe('config.server', () => {
try {
await openConfigWithFlags({
root: fileURLToPath(projectRootURL),
config: configFileURL
config: configFileURL,
});
expect(false).to.equal(true, 'this should not have resolved');
} catch(err) {
} catch (err) {
expect(err.message).to.match(/Unable to resolve/);
}
});
});
});
})
});