[ci] format

This commit is contained in:
FredKSchott 2022-04-02 18:30:48 +00:00 committed by GitHub Actions
parent 17c02925c5
commit bae719505d
9 changed files with 75 additions and 79 deletions

View file

@ -10,5 +10,5 @@ export default defineConfig({
// Learn more about this configuration here: // Learn more about this configuration here:
// https://docs.astro.build/en/guides/markdown-content/#syntax-highlighting // https://docs.astro.build/en/guides/markdown-content/#syntax-highlighting
}, },
} },
}); });

View file

@ -274,18 +274,18 @@ export interface AstroUserConfig {
* @kind heading * @kind heading
* @name Server Options * @name Server Options
* @description * @description
* *
* Customize the Astro dev server, used by both `astro dev` and `astro serve`. * Customize the Astro dev server, used by both `astro dev` and `astro serve`.
* *
* ```js * ```js
* { * {
* server: {port: 1234, host: true} * server: {port: 1234, host: true}
* } * }
* ``` * ```
* *
* To set different configuration based on the command run ("dev", "preview") a function can also be passed to this configuration option. * To set different configuration based on the command run ("dev", "preview") a function can also be passed to this configuration option.
* *
* ```js * ```js
* { * {
* // Example: Use the function syntax to customize based on command * // Example: Use the function syntax to customize based on command
* server: (command) => ({port: command === 'dev' ? 3000 : 4000}) * server: (command) => ({port: command === 'dev' ? 3000 : 4000})
@ -324,7 +324,7 @@ export interface AstroUserConfig {
* @kind heading * @kind heading
* @name Markdown Options * @name Markdown Options
*/ */
markdown?: { markdown?: {
/** /**
* @docs * @docs
* @name markdown.drafts * @name markdown.drafts
@ -353,7 +353,7 @@ export interface AstroUserConfig {
* @description * @description
* Shiki configuration options. See [the markdown configuration docs](https://docs.astro.build/en/guides/markdown-content/#shiki-configuration) for usage. * Shiki configuration options. See [the markdown configuration docs](https://docs.astro.build/en/guides/markdown-content/#shiki-configuration) for usage.
*/ */
shikiConfig?: ShikiConfig; shikiConfig?: ShikiConfig;
/** /**
* @docs * @docs
@ -365,7 +365,7 @@ export interface AstroUserConfig {
* - `shiki` - use the [Shiki](https://github.com/shikijs/shiki) highlighter * - `shiki` - use the [Shiki](https://github.com/shikijs/shiki) highlighter
* - `prism` - use the [Prism](https://prismjs.com/) highlighter * - `prism` - use the [Prism](https://prismjs.com/) highlighter
* - `false` - do not apply syntax highlighting. * - `false` - do not apply syntax highlighting.
* *
* ```js * ```js
* { * {
* markdown: { * markdown: {
@ -383,17 +383,17 @@ export interface AstroUserConfig {
* @type {Plugin[]} * @type {Plugin[]}
* @description * @description
* Pass a custom [Remark](https://github.com/remarkjs/remark) plugin to customize how your Markdown is built. * Pass a custom [Remark](https://github.com/remarkjs/remark) plugin to customize how your Markdown is built.
* *
* **Note:** Enabling custom `remarkPlugins` or `rehypePlugins` removes Astro's built-in support for [GitHub-flavored Markdown](https://github.github.com/gfm/) support, [Footnotes](https://github.com/remarkjs/remark-footnotes) syntax, [Smartypants](https://github.com/silvenon/remark-smartypants). You must explicitly add these plugins to your `astro.config.mjs` file, if desired. * **Note:** Enabling custom `remarkPlugins` or `rehypePlugins` removes Astro's built-in support for [GitHub-flavored Markdown](https://github.github.com/gfm/) support, [Footnotes](https://github.com/remarkjs/remark-footnotes) syntax, [Smartypants](https://github.com/silvenon/remark-smartypants). You must explicitly add these plugins to your `astro.config.mjs` file, if desired.
* *
* ```js * ```js
* { * {
* markdown: { * markdown: {
* // Example: The default set of remark plugins used by Astro * // Example: The default set of remark plugins used by Astro
* remarkPlugins: ['remark-code-titles', ['rehype-autolink-headings', { behavior: 'prepend' }]], * remarkPlugins: ['remark-code-titles', ['rehype-autolink-headings', { behavior: 'prepend' }]],
* }, * },
* }; * };
* ``` * ```
*/ */
remarkPlugins?: Plugin[]; remarkPlugins?: Plugin[];
/** /**
@ -402,17 +402,17 @@ export interface AstroUserConfig {
* @type {Plugin[]} * @type {Plugin[]}
* @description * @description
* Pass a custom [Rehype](https://github.com/remarkjs/remark-rehype) plugin to customize how your Markdown is built. * Pass a custom [Rehype](https://github.com/remarkjs/remark-rehype) plugin to customize how your Markdown is built.
* *
* **Note:** Enabling custom `remarkPlugins` or `rehypePlugins` removes Astro's built-in support for [GitHub-flavored Markdown](https://github.github.com/gfm/) support, [Footnotes](https://github.com/remarkjs/remark-footnotes) syntax, [Smartypants](https://github.com/silvenon/remark-smartypants). You must explicitly add these plugins to your `astro.config.mjs` file, if desired. * **Note:** Enabling custom `remarkPlugins` or `rehypePlugins` removes Astro's built-in support for [GitHub-flavored Markdown](https://github.github.com/gfm/) support, [Footnotes](https://github.com/remarkjs/remark-footnotes) syntax, [Smartypants](https://github.com/silvenon/remark-smartypants). You must explicitly add these plugins to your `astro.config.mjs` file, if desired.
* *
* ```js * ```js
* { * {
* markdown: { * markdown: {
* // Example: The default set of rehype plugins used by Astro * // Example: The default set of rehype plugins used by Astro
* rehypePlugins: [['rehype-toc', { headings: ['h2', 'h3'] }], [addClasses, { 'h1,h2,h3': 'title' }], 'rehype-slug'], * rehypePlugins: [['rehype-toc', { headings: ['h2', 'h3'] }], [addClasses, { 'h1,h2,h3': 'title' }], 'rehype-slug'],
* }, * },
* }; * };
* ``` * ```
*/ */
rehypePlugins?: Plugin[]; rehypePlugins?: Plugin[];
}; };
@ -424,29 +424,28 @@ export interface AstroUserConfig {
* @description * @description
* Add an adapter to build for SSR (server-side rendering). An adapter makes it easy to connect a deployed Astro app to a hosting provider or runtime environment. * Add an adapter to build for SSR (server-side rendering). An adapter makes it easy to connect a deployed Astro app to a hosting provider or runtime environment.
*/ */
adapter?: AstroIntegration; adapter?: AstroIntegration;
/**
* @docs
* @kind heading
* @name Integrations
* @description
*
* Extend Astro with custom integrations. Integrations are your one-stop-shop for adding framework support (like Solid.js), new features (like sitemaps), and new libraries (like Partytown and Turbolinks).
*
* Read our [Integrations Guide](/en/guides/integrations-guide/) for help getting started with Astro Integrations.
*
* ```js
* import react from '@astrojs/react';
* import tailwind from '@astrojs/tailwind';
* {
* // Example: Add React + Tailwind support to Astro
* integrations: [react(), tailwind()]
* }
* ```
*/
integrations?: Array<AstroIntegration | AstroIntegration[]>;
/**
* @docs
* @kind heading
* @name Integrations
* @description
*
* Extend Astro with custom integrations. Integrations are your one-stop-shop for adding framework support (like Solid.js), new features (like sitemaps), and new libraries (like Partytown and Turbolinks).
*
* Read our [Integrations Guide](/en/guides/integrations-guide/) for help getting started with Astro Integrations.
*
* ```js
* import react from '@astrojs/react';
* import tailwind from '@astrojs/tailwind';
* {
* // Example: Add React + Tailwind support to Astro
* integrations: [react(), tailwind()]
* }
* ```
*/
integrations?: Array<AstroIntegration | AstroIntegration[]>;
/** /**
* @docs * @docs
@ -482,7 +481,7 @@ export interface AstroUserConfig {
*/ */
vite?: vite.UserConfig & { ssr?: vite.SSROptions }; vite?: vite.UserConfig & { ssr?: vite.SSROptions };
experimental?: { experimental?: {
/** /**
* Enable experimental support for 3rd-party integrations. * Enable experimental support for 3rd-party integrations.
* Default: false * Default: false
@ -496,9 +495,6 @@ export interface AstroUserConfig {
ssr?: boolean; ssr?: boolean;
}; };
// Legacy options to be removed // Legacy options to be removed
/** @deprecated - Use "integrations" instead. Run Astro to learn more about migrating. */ /** @deprecated - Use "integrations" instead. Run Astro to learn more about migrating. */

View file

@ -184,7 +184,7 @@ async function clientBuild(opts: StaticBuildOptions, internals: BuildInternals,
// TODO: use vite.mergeConfig() here? // TODO: use vite.mergeConfig() here?
info(opts.logging, null, `\n${bgGreen(black(' building client '))}`); info(opts.logging, null, `\n${bgGreen(black(' building client '))}`);
const viteBuildConfig = { const viteBuildConfig = {
logLevel: 'info', logLevel: 'info',
mode: 'production', mode: 'production',

View file

@ -11,7 +11,7 @@ import load from '@proload/core';
import loadTypeScript from '@proload/plugin-tsm'; import loadTypeScript from '@proload/plugin-tsm';
import postcssrc from 'postcss-load-config'; import postcssrc from 'postcss-load-config';
import { arraify, isObject } from './util.js'; import { arraify, isObject } from './util.js';
import { appendForwardSlash, trimSlashes } from './path.js' import { appendForwardSlash, trimSlashes } from './path.js';
load.use([loadTypeScript]); load.use([loadTypeScript]);
@ -54,7 +54,7 @@ export const LegacyAstroConfigKeys = new Set([
'markdownOptions', 'markdownOptions',
'buildOptions', 'buildOptions',
'devOptions', 'devOptions',
'experimentalIntegrations' 'experimentalIntegrations',
]); ]);
export const AstroConfigSchema = z.object({ export const AstroConfigSchema = z.object({
@ -85,9 +85,9 @@ export const AstroConfigSchema = z.object({
.optional() .optional()
.transform((val) => (val ? appendForwardSlash(val) : val)) .transform((val) => (val ? appendForwardSlash(val) : val))
.refine((val) => !val || new URL(val).pathname.length <= 1, { .refine((val) => !val || new URL(val).pathname.length <= 1, {
message: '"site" must be a valid URL origin (ex: "https://example.com") but cannot contain a URL path (ex: "https://example.com/blog"). Use "base" to configure your deployed URL path', message:
'"site" must be a valid URL origin (ex: "https://example.com") but cannot contain a URL path (ex: "https://example.com/blog"). Use "base" to configure your deployed URL path',
}), }),
base: z base: z
.string() .string()
.optional() .optional()
@ -108,16 +108,17 @@ export const AstroConfigSchema = z.object({
.default({}), .default({}),
server: z.preprocess( server: z.preprocess(
// preprocess // preprocess
// NOTE: Uses the "error" command here because this is overwritten by the // NOTE: Uses the "error" command here because this is overwritten by the
// individualized schema parser with the correct command. // individualized schema parser with the correct command.
(val) => (typeof val === 'function' ? val({ command: 'error' }) : val), (val) => (typeof val === 'function' ? val({ command: 'error' }) : val),
// validate // validate
z.object({ z
host: z.union([z.string(), z.boolean()]).optional().default(false), .object({
port: z.number().optional().default(3000), host: z.union([z.string(), z.boolean()]).optional().default(false),
}) port: z.number().optional().default(3000),
.optional() })
.default({}), .optional()
.default({})
), ),
integrations: z.preprocess( integrations: z.preprocess(
// preprocess // preprocess
@ -207,7 +208,7 @@ export async function validateConfig(userConfig: any, root: string, cmd: string)
} }
} }
if (oldConfig) { if (oldConfig) {
throw new Error(`Legacy configuration detected. Please update your configuration to the new format!\nSee https://astro.build/config for more information.`) throw new Error(`Legacy configuration detected. Please update your configuration to the new format!\nSee https://astro.build/config for more information.`);
} }
/* eslint-enable no-console */ /* eslint-enable no-console */
@ -234,12 +235,13 @@ export async function validateConfig(userConfig: any, root: string, cmd: string)
// preprocess // preprocess
(val) => (typeof val === 'function' ? val({ command: cmd === 'dev' ? 'dev' : 'preview' }) : val), (val) => (typeof val === 'function' ? val({ command: cmd === 'dev' ? 'dev' : 'preview' }) : val),
// validate // validate
z.object({ z
host: z.union([z.string(), z.boolean()]).optional().default(false), .object({
port: z.number().optional().default(3000), host: z.union([z.string(), z.boolean()]).optional().default(false),
}) port: z.number().optional().default(3000),
.optional() })
.default({}), .optional()
.default({})
), ),
style: z style: z
.object({ .object({

View file

@ -82,7 +82,7 @@ export default function markdown({ config }: AstroPluginOptions): Plugin {
// Return the file's JS representation, including all Markdown // Return the file's JS representation, including all Markdown
// frontmatter and a deferred `import() of the compiled markdown content. // frontmatter and a deferred `import() of the compiled markdown content.
if (id.startsWith(VIRTUAL_MODULE_ID)) { if (id.startsWith(VIRTUAL_MODULE_ID)) {
const sitePathname = config.site ? appendForwardSlash(new URL(config.base, config.site).pathname) : '/'; const sitePathname = config.site ? appendForwardSlash(new URL(config.base, config.site).pathname) : '/';
const fileId = id.substring(VIRTUAL_MODULE_ID.length); const fileId = id.substring(VIRTUAL_MODULE_ID.length);
const fileUrl = fileId.includes('/pages/') ? fileId.replace(/^.*\/pages\//, sitePathname).replace(/(\/index)?\.md$/, '') : undefined; const fileUrl = fileId.includes('/pages/') ? fileId.replace(/^.*\/pages\//, sitePathname).replace(/(\/index)?\.md$/, '') : undefined;
const source = await fs.promises.readFile(fileId, 'utf8'); const source = await fs.promises.readFile(fileId, 'utf8');

View file

@ -7,7 +7,7 @@ describe('Astro.*', () => {
before(async () => { before(async () => {
fixture = await loadFixture({ fixture = await loadFixture({
root: './fixtures/astro-global/' root: './fixtures/astro-global/',
}); });
await fixture.build(); await fixture.build();
}); });

View file

@ -64,9 +64,7 @@ describe('astro cli', () => {
}); });
}); });
const hostToExposeFlags = [ const hostToExposeFlags = [['', '']];
['', ''],
];
hostToExposeFlags.forEach(([flag, flagValue]) => { hostToExposeFlags.forEach(([flag, flagValue]) => {
it(`astro ${cmd} ${flag} ${flagValue} - host to expose`, async () => { it(`astro ${cmd} ${flag} ${flagValue} - host to expose`, async () => {
const { local, network } = await cliServerLogSetupWithFixture([flag, flagValue], cmd); const { local, network } = await cliServerLogSetupWithFixture([flag, flagValue], cmd);

View file

@ -61,6 +61,6 @@ describe('Config Validation', () => {
expect(configError.message).to.include('Astro integrations are still experimental.'); expect(configError.message).to.include('Astro integrations are still experimental.');
}); });
it('allows third-party "integration" values with the --experimental-integrations flag', async () => { it('allows third-party "integration" values with the --experimental-integrations flag', async () => {
await validateConfig({ integrations: [{ name: '@my-plugin/a' }], experimental: { integrations: true }}, process.cwd()).catch((err) => err); await validateConfig({ integrations: [{ name: '@my-plugin/a' }], experimental: { integrations: true } }, process.cwd()).catch((err) => err);
}); });
}); });

View file

@ -13,8 +13,8 @@ describe('Using Astro.request in SSR', () => {
root: './fixtures/ssr-request/', root: './fixtures/ssr-request/',
adapter: testAdapter(), adapter: testAdapter(),
experimental: { experimental: {
ssr: true ssr: true,
} },
}); });
await fixture.build(); await fixture.build();
}); });