[ci] format

This commit is contained in:
bholmesdev 2023-03-07 19:07:44 +00:00 committed by fredkbot
parent fec583909a
commit 05c5ef155f
10 changed files with 37 additions and 36 deletions

View file

@ -57,9 +57,7 @@ async function benchmark({ fixtures, templates, numPosts }) {
if (test.includes('simple')) { if (test.includes('simple')) {
const fixtures = formats; const fixtures = formats;
console.log( console.log(`\n${bold('Simple')} ${dim(`${numPosts} posts (${formatsToString(fixtures)})`)}`);
`\n${bold('Simple')} ${dim(`${numPosts} posts (${formatsToString(fixtures)})`)}`
);
process.env.ASTRO_PERFORMANCE_TEST_NAME = 'simple'; process.env.ASTRO_PERFORMANCE_TEST_NAME = 'simple';
await benchmark({ await benchmark({
fixtures, fixtures,

View file

@ -1015,8 +1015,8 @@ export interface AstroConfig extends z.output<typeof AstroConfigSchema> {
export interface ContentEntryType { export interface ContentEntryType {
extensions: string[]; extensions: string[];
getEntryInfo(params: { getEntryInfo(params: {
fileUrl: URL; fileUrl: URL;
contents: string; contents: string;
}): GetEntryInfoReturnType | Promise<GetEntryInfoReturnType>; }): GetEntryInfoReturnType | Promise<GetEntryInfoReturnType>;
contentModuleTypes?: string; contentModuleTypes?: string;
} }
@ -1031,7 +1031,7 @@ type GetEntryInfoReturnType = {
rawData: string; rawData: string;
body: string; body: string;
slug: string; slug: string;
} };
export interface AstroSettings { export interface AstroSettings {
config: AstroConfig; config: AstroConfig;

View file

@ -11,15 +11,14 @@ import { escapeViteEnvReferences, getFileInfo } from '../vite-plugin-utils/index
import { CONTENT_FLAG } from './consts.js'; import { CONTENT_FLAG } from './consts.js';
import { import {
ContentConfig, ContentConfig,
getContentEntryExts,
extractFrontmatterAssets, extractFrontmatterAssets,
getContentEntryExts,
getContentPaths, getContentPaths,
getEntryData, getEntryData,
getEntryInfo, getEntryInfo,
getEntrySlug, getEntrySlug,
getEntryType, getEntryType,
globalContentConfigObserver, globalContentConfigObserver,
parseFrontmatter,
} from './utils.js'; } from './utils.js';
function isContentFlagImport(viteId: string, contentEntryExts: string[]) { function isContentFlagImport(viteId: string, contentEntryExts: string[]) {

View file

@ -3,10 +3,10 @@ import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../constants.js';
import { fileURLToPath, pathToFileURL } from 'url'; import { fileURLToPath, pathToFileURL } from 'url';
import jsxRenderer from '../../jsx/renderer.js'; import jsxRenderer from '../../jsx/renderer.js';
import { markdownContentEntryType } from '../../vite-plugin-markdown/content-entry-type.js';
import { createDefaultDevConfig } from './config.js'; import { createDefaultDevConfig } from './config.js';
import { AstroTimer } from './timer.js'; import { AstroTimer } from './timer.js';
import { loadTSConfig } from './tsconfig.js'; import { loadTSConfig } from './tsconfig.js';
import { markdownContentEntryType } from '../../vite-plugin-markdown/content-entry-type.js';
export function createBaseSettings(config: AstroConfig): AstroSettings { export function createBaseSettings(config: AstroConfig): AstroSettings {
return { return {

View file

@ -1,15 +1,15 @@
import type { AstroIntegration, AstroConfig, ContentEntryType, HookParameters } from 'astro';
import { InlineConfig } from 'vite';
import type { Config } from '@markdoc/markdoc'; import type { Config } from '@markdoc/markdoc';
import Markdoc from '@markdoc/markdoc'; import Markdoc from '@markdoc/markdoc';
import type { AstroConfig, AstroIntegration, ContentEntryType, HookParameters } from 'astro';
import fs from 'node:fs';
import { fileURLToPath } from 'node:url';
import { InlineConfig } from 'vite';
import { import {
prependForwardSlash,
getAstroConfigPath, getAstroConfigPath,
MarkdocError, MarkdocError,
parseFrontmatter, parseFrontmatter,
prependForwardSlash,
} from './utils.js'; } from './utils.js';
import { fileURLToPath } from 'node:url';
import fs from 'node:fs';
type IntegrationWithPrivateHooks = { type IntegrationWithPrivateHooks = {
name: string; name: string;

View file

@ -1,9 +1,9 @@
import matter from 'gray-matter';
import path from 'node:path';
import type fsMod from 'node:fs';
import type { ErrorPayload as ViteErrorPayload } from 'vite';
import type { AstroInstance } from 'astro'; import type { AstroInstance } from 'astro';
import z from 'astro/zod'; import z from 'astro/zod';
import matter from 'gray-matter';
import type fsMod from 'node:fs';
import path from 'node:path';
import type { ErrorPayload as ViteErrorPayload } from 'vite';
/** /**
* Match YAML exception handling from Astro core errors * Match YAML exception handling from Astro core errors

View file

@ -11,7 +11,7 @@ import type { Options as RemarkRehypeOptions } from 'remark-rehype';
import { VFile } from 'vfile'; import { VFile } from 'vfile';
import type { Plugin as VitePlugin } from 'vite'; import type { Plugin as VitePlugin } from 'vite';
import { getRehypePlugins, getRemarkPlugins, recmaInjectImportMetaEnvPlugin } from './plugins.js'; import { getRehypePlugins, getRemarkPlugins, recmaInjectImportMetaEnvPlugin } from './plugins.js';
import { getFileInfo, parseFrontmatter, ignoreStringPlugins } from './utils.js'; import { getFileInfo, ignoreStringPlugins, parseFrontmatter } from './utils.js';
export type MdxOptions = Omit<typeof markdownConfigDefaults, 'remarkPlugins' | 'rehypePlugins'> & { export type MdxOptions = Omit<typeof markdownConfigDefaults, 'remarkPlugins' | 'rehypePlugins'> & {
extendMarkdownConfig: boolean; extendMarkdownConfig: boolean;
@ -23,20 +23,23 @@ export type MdxOptions = Omit<typeof markdownConfigDefaults, 'remarkPlugins' | '
remarkRehype: RemarkRehypeOptions; remarkRehype: RemarkRehypeOptions;
}; };
type IntegrationWithPrivateHooks = {
type IntegrationWithPrivateHooks = {
name: string; name: string;
hooks: Omit<AstroIntegration['hooks'], 'astro:config:setup'> & { hooks: Omit<AstroIntegration['hooks'], 'astro:config:setup'> & {
'astro:config:setup': (params: HookParameters<'astro:config:setup'> & { 'astro:config:setup': (
// `addPageExtension` and `contentEntryType` are not a public APIs params: HookParameters<'astro:config:setup'> & {
// Add type defs here // `addPageExtension` and `contentEntryType` are not a public APIs
addPageExtension: (extension: string) => void // Add type defs here
addContentEntryType: (contentEntryType: ContentEntryType) => void addPageExtension: (extension: string) => void;
}) => void | Promise<void>; addContentEntryType: (contentEntryType: ContentEntryType) => void;
}
) => void | Promise<void>;
}; };
}; };
export default function mdx(partialMdxOptions: Partial<MdxOptions> = {}): IntegrationWithPrivateHooks { export default function mdx(
partialMdxOptions: Partial<MdxOptions> = {}
): IntegrationWithPrivateHooks {
return { return {
name: '@astrojs/mdx', name: '@astrojs/mdx',
hooks: { hooks: {
@ -70,7 +73,9 @@ export default function mdx(partialMdxOptions: Partial<MdxOptions> = {}): Integr
const mdxOptions = applyDefaultOptions({ const mdxOptions = applyDefaultOptions({
options: partialMdxOptions, options: partialMdxOptions,
defaults: markdownConfigToMdxOptions(extendMarkdownConfig ? config.markdown : markdownConfigDefaults), defaults: markdownConfigToMdxOptions(
extendMarkdownConfig ? config.markdown : markdownConfigDefaults
),
}); });
const mdxPluginOpts: MdxRollupPluginOptions = { const mdxPluginOpts: MdxRollupPluginOptions = {
@ -188,7 +193,7 @@ export default function mdx(partialMdxOptions: Partial<MdxOptions> = {}): Integr
const defaultMdxOptions = { const defaultMdxOptions = {
extendMarkdownConfig: true, extendMarkdownConfig: true,
recmaPlugins: [], recmaPlugins: [],
} };
function markdownConfigToMdxOptions(markdownConfig: typeof markdownConfigDefaults): MdxOptions { function markdownConfigToMdxOptions(markdownConfig: typeof markdownConfigDefaults): MdxOptions {
return { return {
@ -196,7 +201,7 @@ function markdownConfigToMdxOptions(markdownConfig: typeof markdownConfigDefault
...markdownConfig, ...markdownConfig,
remarkPlugins: ignoreStringPlugins(markdownConfig.remarkPlugins), remarkPlugins: ignoreStringPlugins(markdownConfig.remarkPlugins),
rehypePlugins: ignoreStringPlugins(markdownConfig.rehypePlugins), rehypePlugins: ignoreStringPlugins(markdownConfig.rehypePlugins),
remarkRehype: markdownConfig.remarkRehype as any ?? {}, remarkRehype: (markdownConfig.remarkRehype as any) ?? {},
}; };
} }

View file

@ -4,12 +4,11 @@ import {
safelyGetAstroData, safelyGetAstroData,
} from '@astrojs/markdown-remark/dist/internal.js'; } from '@astrojs/markdown-remark/dist/internal.js';
import { nodeTypes } from '@mdx-js/mdx'; import { nodeTypes } from '@mdx-js/mdx';
import type { Options as MdxRollupPluginOptions } from '@mdx-js/rollup';
import type { PluggableList } from '@mdx-js/mdx/lib/core.js'; import type { PluggableList } from '@mdx-js/mdx/lib/core.js';
import type { Options as MdxRollupPluginOptions } from '@mdx-js/rollup';
import type { AstroConfig } from 'astro'; import type { AstroConfig } from 'astro';
import type { Literal, MemberExpression } from 'estree'; import type { Literal, MemberExpression } from 'estree';
import { visit as estreeVisit } from 'estree-util-visit'; import { visit as estreeVisit } from 'estree-util-visit';
import type { Image } from 'mdast';
import rehypeRaw from 'rehype-raw'; import rehypeRaw from 'rehype-raw';
import remarkGfm from 'remark-gfm'; import remarkGfm from 'remark-gfm';
import remarkSmartypants from 'remark-smartypants'; import remarkSmartypants from 'remark-smartypants';

View file

@ -1,9 +1,9 @@
import type { PluggableList } from '@mdx-js/mdx/lib/core.js';
import type { Options as AcornOpts } from 'acorn'; import type { Options as AcornOpts } from 'acorn';
import { parse } from 'acorn'; import { parse } from 'acorn';
import type { AstroConfig, SSRError } from 'astro'; import type { AstroConfig, SSRError } from 'astro';
import { bold, yellow } from 'kleur/colors';
import matter from 'gray-matter'; import matter from 'gray-matter';
import type { PluggableList } from '@mdx-js/mdx/lib/core.js'; import { bold, yellow } from 'kleur/colors';
import type { MdxjsEsm } from 'mdast-util-mdx'; import type { MdxjsEsm } from 'mdast-util-mdx';
function appendForwardSlash(path: string) { function appendForwardSlash(path: string) {