[ci] format
This commit is contained in:
parent
cd4be4822c
commit
d2148ce982
17 changed files with 78 additions and 74 deletions
|
@ -426,7 +426,7 @@ export interface AstroUserConfig {
|
|||
/**
|
||||
* @docs
|
||||
* @name adapter
|
||||
* @typeraw {AstroIntegration}
|
||||
* @typeraw {AstroIntegration}
|
||||
* @see output
|
||||
* @description
|
||||
*
|
||||
|
@ -442,31 +442,31 @@ export interface AstroUserConfig {
|
|||
* }
|
||||
* ```
|
||||
*/
|
||||
adapter?: AstroIntegration;
|
||||
adapter?: AstroIntegration;
|
||||
|
||||
/**
|
||||
* @docs
|
||||
* @name output
|
||||
* @type {('static' | 'server')}
|
||||
* @default `'static'`
|
||||
* @see adapter
|
||||
* @description
|
||||
*
|
||||
* Specifies the output target for builds.
|
||||
*
|
||||
* - 'static' - Building a static site to be deploy to any static host.
|
||||
* - 'server' - Building an app to be deployed to a host supporting SSR (server-side rendering).
|
||||
*
|
||||
* ```js
|
||||
* import { defineConfig } from 'astro/config';
|
||||
*
|
||||
* export default defineConfig({
|
||||
* output: 'static'
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
output?: 'static' | 'server';
|
||||
|
||||
/**
|
||||
* @docs
|
||||
* @name output
|
||||
* @type {('static' | 'server')}
|
||||
* @default `'static'`
|
||||
* @see adapter
|
||||
* @description
|
||||
*
|
||||
* Specifies the output target for builds.
|
||||
*
|
||||
* - 'static' - Building a static site to be deploy to any static host.
|
||||
* - 'server' - Building an app to be deployed to a host supporting SSR (server-side rendering).
|
||||
*
|
||||
* ```js
|
||||
* import { defineConfig } from 'astro/config';
|
||||
*
|
||||
* export default defineConfig({
|
||||
* output: 'static'
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
output?: 'static' | 'server';
|
||||
|
||||
/**
|
||||
* @docs
|
||||
* @kind heading
|
||||
|
@ -703,7 +703,7 @@ export interface AstroUserConfig {
|
|||
* ```
|
||||
*/
|
||||
vite?: ViteUserConfig;
|
||||
|
||||
|
||||
/**
|
||||
* @docs
|
||||
* @kind heading
|
||||
|
@ -714,15 +714,15 @@ export interface AstroUserConfig {
|
|||
* in the latest version, so that you can continue to upgrade and take advantage of new Astro releases.
|
||||
*/
|
||||
legacy?: {
|
||||
/**
|
||||
/**
|
||||
* @docs
|
||||
* @name legacy.astroFlavoredMarkdown
|
||||
* @type {boolean}
|
||||
* @default `false`
|
||||
* @since 1.0.0-rc
|
||||
* @description
|
||||
* Enable Astro's pre-v1.0 support for components and JSX expressions in `.md` Markdown files.
|
||||
* In Astro `1.0.0-rc`, this original behavior was removed as the default, in favor of our new [MDX integration](/en/guides/integrations-guide/mdx/).
|
||||
* Enable Astro's pre-v1.0 support for components and JSX expressions in `.md` Markdown files.
|
||||
* In Astro `1.0.0-rc`, this original behavior was removed as the default, in favor of our new [MDX integration](/en/guides/integrations-guide/mdx/).
|
||||
*/
|
||||
astroFlavoredMarkdown?: boolean;
|
||||
};
|
||||
|
|
|
@ -132,7 +132,12 @@ async function runCommand(cmd: string, flags: yargs.Arguments) {
|
|||
}
|
||||
}
|
||||
|
||||
let { astroConfig, userConfig, userConfigPath } = await openConfig({ cwd: root, flags, cmd, logging });
|
||||
let { astroConfig, userConfig, userConfigPath } = await openConfig({
|
||||
cwd: root,
|
||||
flags,
|
||||
cmd,
|
||||
logging,
|
||||
});
|
||||
telemetry.record(event.eventCliSession(cmd, userConfig, flags));
|
||||
|
||||
// Common CLI Commands:
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
import type { AstroTelemetry } from '@astrojs/telemetry';
|
||||
import type {
|
||||
AstroAdapter,
|
||||
AstroConfig,
|
||||
BuildConfig,
|
||||
ManifestData,
|
||||
RuntimeMode,
|
||||
} from '../../@types/astro';
|
||||
import type { AstroConfig, BuildConfig, ManifestData, RuntimeMode } from '../../@types/astro';
|
||||
import type { LogOptions } from '../logger/core';
|
||||
|
||||
import fs from 'fs';
|
||||
|
|
|
@ -6,7 +6,7 @@ import { fileURLToPath } from 'url';
|
|||
import * as vite from 'vite';
|
||||
import { BuildInternals, createBuildInternals } from '../../core/build/internal.js';
|
||||
import { prependForwardSlash } from '../../core/path.js';
|
||||
import { emptyDir, removeDir, isModeServerWithNoAdapter } from '../../core/util.js';
|
||||
import { emptyDir, isModeServerWithNoAdapter, removeDir } from '../../core/util.js';
|
||||
import { runHookBuildSetup } from '../../integrations/index.js';
|
||||
import { rollupPluginAstroBuildCSS } from '../../vite-plugin-build-css/index.js';
|
||||
import type { ViteConfigWithSSR } from '../create-vite';
|
||||
|
@ -25,7 +25,7 @@ export async function staticBuild(opts: StaticBuildOptions) {
|
|||
const { allPages, astroConfig } = opts;
|
||||
|
||||
// Verify this app is buildable.
|
||||
if(isModeServerWithNoAdapter(opts.astroConfig)) {
|
||||
if (isModeServerWithNoAdapter(opts.astroConfig)) {
|
||||
throw new Error(`Cannot use \`output: 'server'\` without an adapter.
|
||||
Install and configure the appropriate server adapter for your final deployment.
|
||||
Example:
|
||||
|
@ -36,7 +36,7 @@ Example:
|
|||
output: 'server',
|
||||
adapter: netlify(),
|
||||
}
|
||||
`)
|
||||
`);
|
||||
}
|
||||
|
||||
// The pages to be built for rendering purposes.
|
||||
|
@ -71,11 +71,7 @@ Example:
|
|||
|
||||
// Build your project (SSR application code, assets, client JS, etc.)
|
||||
timer.ssr = performance.now();
|
||||
info(
|
||||
opts.logging,
|
||||
'build',
|
||||
`Building ${astroConfig.output} entrypoints...`
|
||||
);
|
||||
info(opts.logging, 'build', `Building ${astroConfig.output} entrypoints...`);
|
||||
const ssrResult = (await ssrBuild(opts, internals, pageInput)) as RollupOutput;
|
||||
info(opts.logging, 'build', dim(`Completed in ${getTimeStat(timer.ssr, performance.now())}.`));
|
||||
|
||||
|
@ -156,7 +152,8 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp
|
|||
}),
|
||||
...(viteConfig.plugins || []),
|
||||
// SSR needs to be last
|
||||
opts.astroConfig.output === 'server' && vitePluginSSR(internals, opts.astroConfig._ctx.adapter!),
|
||||
opts.astroConfig.output === 'server' &&
|
||||
vitePluginSSR(internals, opts.astroConfig._ctx.adapter!),
|
||||
vitePluginAnalyzer(opts.astroConfig, internals),
|
||||
],
|
||||
publicDir: ssr ? false : viteConfig.publicDir,
|
||||
|
@ -287,9 +284,8 @@ async function copyFiles(fromFolder: URL, toFolder: URL) {
|
|||
|
||||
async function ssrMoveAssets(opts: StaticBuildOptions) {
|
||||
info(opts.logging, 'build', 'Rearranging server assets...');
|
||||
const serverRoot = opts.astroConfig.output === 'static'
|
||||
? opts.buildConfig.client
|
||||
: opts.buildConfig.server;
|
||||
const serverRoot =
|
||||
opts.astroConfig.output === 'static' ? opts.buildConfig.client : opts.buildConfig.server;
|
||||
const clientRoot = opts.buildConfig.client;
|
||||
const serverAssets = new URL('./assets/', serverRoot);
|
||||
const clientAssets = new URL('./assets/', clientRoot);
|
||||
|
|
|
@ -13,9 +13,9 @@ import { BUNDLED_THEMES } from 'shiki';
|
|||
import { fileURLToPath, pathToFileURL } from 'url';
|
||||
import { mergeConfig as mergeViteConfig } from 'vite';
|
||||
import { z } from 'zod';
|
||||
import { LogOptions } from './logger/core.js';
|
||||
import { appendForwardSlash, prependForwardSlash, trimSlashes } from './path.js';
|
||||
import { arraify, isObject } from './util.js';
|
||||
import { LogOptions, warn } from './logger/core.js';
|
||||
|
||||
load.use([loadTypeScript]);
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ export async function runHookConfigSetup({
|
|||
}): Promise<AstroConfig> {
|
||||
// An adapter is an integration, so if one is provided push it.
|
||||
if (_config.adapter) {
|
||||
_config.integrations.push(_config.adapter);
|
||||
_config.integrations.push(_config.adapter);
|
||||
}
|
||||
|
||||
let updatedConfig: AstroConfig = { ..._config };
|
||||
|
@ -89,7 +89,7 @@ export async function runHookConfigDone({ config }: { config: AstroConfig }) {
|
|||
}
|
||||
}
|
||||
|
||||
export async function runHookServerSetup({
|
||||
export async function runHookServerSetup({
|
||||
config,
|
||||
server,
|
||||
}: {
|
||||
|
|
|
@ -38,9 +38,8 @@ describe('AstroConfig - config.mode', () => {
|
|||
fixture = await loadFixture({
|
||||
// This is just a random fixture to test, doesn't matter.
|
||||
root: './fixtures/astro-basic/',
|
||||
output: 'server'
|
||||
output: 'server',
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('Throws during the build', async () => {
|
||||
|
@ -48,7 +47,7 @@ describe('AstroConfig - config.mode', () => {
|
|||
try {
|
||||
await fixture.build();
|
||||
built = true;
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceOf(Error);
|
||||
expect(err.message).to.match(/without an adapter/);
|
||||
}
|
||||
|
@ -67,7 +66,7 @@ describe('AstroConfig - config.mode', () => {
|
|||
fixture = await loadFixture({
|
||||
// This is just a random fixture to test, doesn't matter.
|
||||
root: './fixtures/astro-basic/',
|
||||
output: 'static'
|
||||
output: 'static',
|
||||
});
|
||||
await fixture.build();
|
||||
});
|
||||
|
@ -76,7 +75,7 @@ describe('AstroConfig - config.mode', () => {
|
|||
let html;
|
||||
try {
|
||||
html = await fixture.readFile('/index.html');
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
expect(false).to.equal(true, 'Couldnt find the file, which mean it did not build.');
|
||||
}
|
||||
expect(html.length).to.be.greaterThan(0);
|
||||
|
@ -92,7 +91,7 @@ describe('AstroConfig - config.mode', () => {
|
|||
// This is just a random fixture to test, doesn't matter.
|
||||
root: './fixtures/astro-basic/',
|
||||
adapter: testAdapter(),
|
||||
output: 'server'
|
||||
output: 'server',
|
||||
});
|
||||
await fixture.build();
|
||||
});
|
||||
|
|
|
@ -11,7 +11,7 @@ describe('Using the Partytown integration in SSR', () => {
|
|||
fixture = await loadFixture({
|
||||
root: './fixtures/ssr-partytown/',
|
||||
adapter: testAdapter(),
|
||||
output: 'server'
|
||||
output: 'server',
|
||||
});
|
||||
await fixture.build();
|
||||
});
|
||||
|
|
|
@ -11,7 +11,7 @@ describe('Using Astro.request in SSR', () => {
|
|||
fixture = await loadFixture({
|
||||
root: './fixtures/ssr-request/',
|
||||
adapter: testAdapter(),
|
||||
output: 'server'
|
||||
output: 'server',
|
||||
});
|
||||
await fixture.build();
|
||||
});
|
||||
|
|
|
@ -11,7 +11,7 @@ describe('Using Astro.response in SSR', () => {
|
|||
fixture = await loadFixture({
|
||||
root: './fixtures/ssr-response/',
|
||||
adapter: testAdapter(),
|
||||
output: 'server'
|
||||
output: 'server',
|
||||
});
|
||||
await fixture.build();
|
||||
});
|
||||
|
|
|
@ -13,7 +13,7 @@ describe('Streaming', () => {
|
|||
fixture = await loadFixture({
|
||||
root: './fixtures/streaming/',
|
||||
adapter: testAdapter(),
|
||||
output: 'server'
|
||||
output: 'server',
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -22,9 +22,13 @@ export default function createIntegration(): AstroIntegration {
|
|||
setAdapter(getAdapter());
|
||||
_config = config;
|
||||
|
||||
if(config.output === 'static') {
|
||||
console.warn(`[@astrojs/cloudflare] \`output: "server"\` is required to use this adapter.`);
|
||||
console.warn(`[@astrojs/cloudflare] Otherwise, this adapter is not required to deploy a static site to Cloudflare.`);
|
||||
if (config.output === 'static') {
|
||||
console.warn(
|
||||
`[@astrojs/cloudflare] \`output: "server"\` is required to use this adapter.`
|
||||
);
|
||||
console.warn(
|
||||
`[@astrojs/cloudflare] Otherwise, this adapter is not required to deploy a static site to Cloudflare.`
|
||||
);
|
||||
}
|
||||
},
|
||||
'astro:build:start': ({ buildConfig }) => {
|
||||
|
|
|
@ -32,9 +32,11 @@ export default function createIntegration(args?: Options): AstroIntegration {
|
|||
'astro:config:done': ({ setAdapter, config }) => {
|
||||
setAdapter(getAdapter(args));
|
||||
|
||||
if(config.output === 'static') {
|
||||
if (config.output === 'static') {
|
||||
console.warn(`[@astrojs/deno] \`output: "server"\` is required to use this adapter.`);
|
||||
console.warn(`[@astrojs/deno] Otherwise, this adapter is not required to deploy a static site to Deno.`);
|
||||
console.warn(
|
||||
`[@astrojs/deno] Otherwise, this adapter is not required to deploy a static site to Deno.`
|
||||
);
|
||||
}
|
||||
},
|
||||
'astro:build:start': ({ buildConfig }) => {
|
||||
|
|
|
@ -136,10 +136,12 @@ export function netlifyEdgeFunctions({ dist }: NetlifyEdgeFunctionsOptions = {})
|
|||
setAdapter(getAdapter());
|
||||
_config = config;
|
||||
|
||||
if(config.output === 'static') {
|
||||
if (config.output === 'static') {
|
||||
console.warn(`[@astrojs/netlify] \`output: "server"\` is required to use this adapter.`);
|
||||
console.warn(`[@astrojs/netlify] Otherwise, this adapter is not required to deploy a static site to Netlify.`);
|
||||
}
|
||||
console.warn(
|
||||
`[@astrojs/netlify] Otherwise, this adapter is not required to deploy a static site to Netlify.`
|
||||
);
|
||||
}
|
||||
},
|
||||
'astro:build:start': async ({ buildConfig }) => {
|
||||
_buildConfig = buildConfig;
|
||||
|
|
|
@ -36,9 +36,11 @@ function netlifyFunctions({
|
|||
setAdapter(getAdapter({ binaryMediaTypes }));
|
||||
_config = config;
|
||||
|
||||
if(config.output === 'static') {
|
||||
if (config.output === 'static') {
|
||||
console.warn(`[@astrojs/netlify] \`output: "server"\` is required to use this adapter.`);
|
||||
console.warn(`[@astrojs/netlify] Otherwise, this adapter is not required to deploy a static site to Netlify.`);
|
||||
console.warn(
|
||||
`[@astrojs/netlify] Otherwise, this adapter is not required to deploy a static site to Netlify.`
|
||||
);
|
||||
}
|
||||
},
|
||||
'astro:build:start': async ({ buildConfig }) => {
|
||||
|
|
|
@ -15,7 +15,7 @@ export default function createIntegration(): AstroIntegration {
|
|||
'astro:config:done': ({ setAdapter, config }) => {
|
||||
setAdapter(getAdapter());
|
||||
|
||||
if(config.output === 'static') {
|
||||
if (config.output === 'static') {
|
||||
console.warn(`[@astrojs/Node] \`output: "server"\` is required to use this adapter.`);
|
||||
}
|
||||
},
|
||||
|
|
2
packages/webapi/mod.d.ts
vendored
2
packages/webapi/mod.d.ts
vendored
|
@ -1,5 +1,5 @@
|
|||
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: {
|
||||
(target: any, options?: PolyfillOptions): any;
|
||||
internals(target: any, name: string): any;
|
||||
|
|
Loading…
Reference in a new issue