[ci] format
This commit is contained in:
parent
cd4be4822c
commit
d2148ce982
17 changed files with 78 additions and 74 deletions
|
@ -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));
|
telemetry.record(event.eventCliSession(cmd, userConfig, flags));
|
||||||
|
|
||||||
// Common CLI Commands:
|
// Common CLI Commands:
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
import type { AstroTelemetry } from '@astrojs/telemetry';
|
import type { AstroTelemetry } from '@astrojs/telemetry';
|
||||||
import type {
|
import type { AstroConfig, BuildConfig, ManifestData, RuntimeMode } from '../../@types/astro';
|
||||||
AstroAdapter,
|
|
||||||
AstroConfig,
|
|
||||||
BuildConfig,
|
|
||||||
ManifestData,
|
|
||||||
RuntimeMode,
|
|
||||||
} from '../../@types/astro';
|
|
||||||
import type { LogOptions } from '../logger/core';
|
import type { LogOptions } from '../logger/core';
|
||||||
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { fileURLToPath } from 'url';
|
||||||
import * as vite from 'vite';
|
import * as vite from 'vite';
|
||||||
import { BuildInternals, createBuildInternals } from '../../core/build/internal.js';
|
import { BuildInternals, createBuildInternals } from '../../core/build/internal.js';
|
||||||
import { prependForwardSlash } from '../../core/path.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 { runHookBuildSetup } from '../../integrations/index.js';
|
||||||
import { rollupPluginAstroBuildCSS } from '../../vite-plugin-build-css/index.js';
|
import { rollupPluginAstroBuildCSS } from '../../vite-plugin-build-css/index.js';
|
||||||
import type { ViteConfigWithSSR } from '../create-vite';
|
import type { ViteConfigWithSSR } from '../create-vite';
|
||||||
|
@ -25,7 +25,7 @@ export async function staticBuild(opts: StaticBuildOptions) {
|
||||||
const { allPages, astroConfig } = opts;
|
const { allPages, astroConfig } = opts;
|
||||||
|
|
||||||
// Verify this app is buildable.
|
// Verify this app is buildable.
|
||||||
if(isModeServerWithNoAdapter(opts.astroConfig)) {
|
if (isModeServerWithNoAdapter(opts.astroConfig)) {
|
||||||
throw new Error(`Cannot use \`output: 'server'\` without an adapter.
|
throw new Error(`Cannot use \`output: 'server'\` without an adapter.
|
||||||
Install and configure the appropriate server adapter for your final deployment.
|
Install and configure the appropriate server adapter for your final deployment.
|
||||||
Example:
|
Example:
|
||||||
|
@ -36,7 +36,7 @@ Example:
|
||||||
output: 'server',
|
output: 'server',
|
||||||
adapter: netlify(),
|
adapter: netlify(),
|
||||||
}
|
}
|
||||||
`)
|
`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The pages to be built for rendering purposes.
|
// The pages to be built for rendering purposes.
|
||||||
|
@ -71,11 +71,7 @@ Example:
|
||||||
|
|
||||||
// Build your project (SSR application code, assets, client JS, etc.)
|
// Build your project (SSR application code, assets, client JS, etc.)
|
||||||
timer.ssr = performance.now();
|
timer.ssr = performance.now();
|
||||||
info(
|
info(opts.logging, 'build', `Building ${astroConfig.output} entrypoints...`);
|
||||||
opts.logging,
|
|
||||||
'build',
|
|
||||||
`Building ${astroConfig.output} entrypoints...`
|
|
||||||
);
|
|
||||||
const ssrResult = (await ssrBuild(opts, internals, pageInput)) as RollupOutput;
|
const ssrResult = (await ssrBuild(opts, internals, pageInput)) as RollupOutput;
|
||||||
info(opts.logging, 'build', dim(`Completed in ${getTimeStat(timer.ssr, performance.now())}.`));
|
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 || []),
|
...(viteConfig.plugins || []),
|
||||||
// SSR needs to be last
|
// 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),
|
vitePluginAnalyzer(opts.astroConfig, internals),
|
||||||
],
|
],
|
||||||
publicDir: ssr ? false : viteConfig.publicDir,
|
publicDir: ssr ? false : viteConfig.publicDir,
|
||||||
|
@ -287,9 +284,8 @@ async function copyFiles(fromFolder: URL, toFolder: URL) {
|
||||||
|
|
||||||
async function ssrMoveAssets(opts: StaticBuildOptions) {
|
async function ssrMoveAssets(opts: StaticBuildOptions) {
|
||||||
info(opts.logging, 'build', 'Rearranging server assets...');
|
info(opts.logging, 'build', 'Rearranging server assets...');
|
||||||
const serverRoot = opts.astroConfig.output === 'static'
|
const serverRoot =
|
||||||
? opts.buildConfig.client
|
opts.astroConfig.output === 'static' ? opts.buildConfig.client : opts.buildConfig.server;
|
||||||
: opts.buildConfig.server;
|
|
||||||
const clientRoot = opts.buildConfig.client;
|
const clientRoot = opts.buildConfig.client;
|
||||||
const serverAssets = new URL('./assets/', serverRoot);
|
const serverAssets = new URL('./assets/', serverRoot);
|
||||||
const clientAssets = new URL('./assets/', clientRoot);
|
const clientAssets = new URL('./assets/', clientRoot);
|
||||||
|
|
|
@ -13,9 +13,9 @@ import { BUNDLED_THEMES } from 'shiki';
|
||||||
import { fileURLToPath, pathToFileURL } from 'url';
|
import { fileURLToPath, pathToFileURL } from 'url';
|
||||||
import { mergeConfig as mergeViteConfig } from 'vite';
|
import { mergeConfig as mergeViteConfig } from 'vite';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
import { LogOptions } from './logger/core.js';
|
||||||
import { appendForwardSlash, prependForwardSlash, trimSlashes } from './path.js';
|
import { appendForwardSlash, prependForwardSlash, trimSlashes } from './path.js';
|
||||||
import { arraify, isObject } from './util.js';
|
import { arraify, isObject } from './util.js';
|
||||||
import { LogOptions, warn } from './logger/core.js';
|
|
||||||
|
|
||||||
load.use([loadTypeScript]);
|
load.use([loadTypeScript]);
|
||||||
|
|
||||||
|
|
|
@ -38,9 +38,8 @@ describe('AstroConfig - config.mode', () => {
|
||||||
fixture = await loadFixture({
|
fixture = await loadFixture({
|
||||||
// This is just a random fixture to test, doesn't matter.
|
// This is just a random fixture to test, doesn't matter.
|
||||||
root: './fixtures/astro-basic/',
|
root: './fixtures/astro-basic/',
|
||||||
output: 'server'
|
output: 'server',
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Throws during the build', async () => {
|
it('Throws during the build', async () => {
|
||||||
|
@ -48,7 +47,7 @@ describe('AstroConfig - config.mode', () => {
|
||||||
try {
|
try {
|
||||||
await fixture.build();
|
await fixture.build();
|
||||||
built = true;
|
built = true;
|
||||||
} catch(err) {
|
} catch (err) {
|
||||||
expect(err).to.be.an.instanceOf(Error);
|
expect(err).to.be.an.instanceOf(Error);
|
||||||
expect(err.message).to.match(/without an adapter/);
|
expect(err.message).to.match(/without an adapter/);
|
||||||
}
|
}
|
||||||
|
@ -67,7 +66,7 @@ describe('AstroConfig - config.mode', () => {
|
||||||
fixture = await loadFixture({
|
fixture = await loadFixture({
|
||||||
// This is just a random fixture to test, doesn't matter.
|
// This is just a random fixture to test, doesn't matter.
|
||||||
root: './fixtures/astro-basic/',
|
root: './fixtures/astro-basic/',
|
||||||
output: 'static'
|
output: 'static',
|
||||||
});
|
});
|
||||||
await fixture.build();
|
await fixture.build();
|
||||||
});
|
});
|
||||||
|
@ -76,7 +75,7 @@ describe('AstroConfig - config.mode', () => {
|
||||||
let html;
|
let html;
|
||||||
try {
|
try {
|
||||||
html = await fixture.readFile('/index.html');
|
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(false).to.equal(true, 'Couldnt find the file, which mean it did not build.');
|
||||||
}
|
}
|
||||||
expect(html.length).to.be.greaterThan(0);
|
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.
|
// This is just a random fixture to test, doesn't matter.
|
||||||
root: './fixtures/astro-basic/',
|
root: './fixtures/astro-basic/',
|
||||||
adapter: testAdapter(),
|
adapter: testAdapter(),
|
||||||
output: 'server'
|
output: 'server',
|
||||||
});
|
});
|
||||||
await fixture.build();
|
await fixture.build();
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,7 +11,7 @@ describe('Using the Partytown integration in SSR', () => {
|
||||||
fixture = await loadFixture({
|
fixture = await loadFixture({
|
||||||
root: './fixtures/ssr-partytown/',
|
root: './fixtures/ssr-partytown/',
|
||||||
adapter: testAdapter(),
|
adapter: testAdapter(),
|
||||||
output: 'server'
|
output: 'server',
|
||||||
});
|
});
|
||||||
await fixture.build();
|
await fixture.build();
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,7 +11,7 @@ describe('Using Astro.request in SSR', () => {
|
||||||
fixture = await loadFixture({
|
fixture = await loadFixture({
|
||||||
root: './fixtures/ssr-request/',
|
root: './fixtures/ssr-request/',
|
||||||
adapter: testAdapter(),
|
adapter: testAdapter(),
|
||||||
output: 'server'
|
output: 'server',
|
||||||
});
|
});
|
||||||
await fixture.build();
|
await fixture.build();
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,7 +11,7 @@ describe('Using Astro.response in SSR', () => {
|
||||||
fixture = await loadFixture({
|
fixture = await loadFixture({
|
||||||
root: './fixtures/ssr-response/',
|
root: './fixtures/ssr-response/',
|
||||||
adapter: testAdapter(),
|
adapter: testAdapter(),
|
||||||
output: 'server'
|
output: 'server',
|
||||||
});
|
});
|
||||||
await fixture.build();
|
await fixture.build();
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,7 +13,7 @@ describe('Streaming', () => {
|
||||||
fixture = await loadFixture({
|
fixture = await loadFixture({
|
||||||
root: './fixtures/streaming/',
|
root: './fixtures/streaming/',
|
||||||
adapter: testAdapter(),
|
adapter: testAdapter(),
|
||||||
output: 'server'
|
output: 'server',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,13 @@ export default function createIntegration(): AstroIntegration {
|
||||||
setAdapter(getAdapter());
|
setAdapter(getAdapter());
|
||||||
_config = config;
|
_config = config;
|
||||||
|
|
||||||
if(config.output === 'static') {
|
if (config.output === 'static') {
|
||||||
console.warn(`[@astrojs/cloudflare] \`output: "server"\` is required to use this adapter.`);
|
console.warn(
|
||||||
console.warn(`[@astrojs/cloudflare] Otherwise, this adapter is not required to deploy a static site to Cloudflare.`);
|
`[@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 }) => {
|
'astro:build:start': ({ buildConfig }) => {
|
||||||
|
|
|
@ -32,9 +32,11 @@ export default function createIntegration(args?: Options): AstroIntegration {
|
||||||
'astro:config:done': ({ setAdapter, config }) => {
|
'astro:config:done': ({ setAdapter, config }) => {
|
||||||
setAdapter(getAdapter(args));
|
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] \`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 }) => {
|
'astro:build:start': ({ buildConfig }) => {
|
||||||
|
|
|
@ -136,9 +136,11 @@ export function netlifyEdgeFunctions({ dist }: NetlifyEdgeFunctionsOptions = {})
|
||||||
setAdapter(getAdapter());
|
setAdapter(getAdapter());
|
||||||
_config = config;
|
_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] \`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 }) => {
|
'astro:build:start': async ({ buildConfig }) => {
|
||||||
|
|
|
@ -36,9 +36,11 @@ function netlifyFunctions({
|
||||||
setAdapter(getAdapter({ binaryMediaTypes }));
|
setAdapter(getAdapter({ binaryMediaTypes }));
|
||||||
_config = config;
|
_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] \`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 }) => {
|
'astro:build:start': async ({ buildConfig }) => {
|
||||||
|
|
|
@ -15,7 +15,7 @@ export default function createIntegration(): AstroIntegration {
|
||||||
'astro:config:done': ({ setAdapter, config }) => {
|
'astro:config:done': ({ setAdapter, config }) => {
|
||||||
setAdapter(getAdapter());
|
setAdapter(getAdapter());
|
||||||
|
|
||||||
if(config.output === 'static') {
|
if (config.output === 'static') {
|
||||||
console.warn(`[@astrojs/Node] \`output: "server"\` is required to use this adapter.`);
|
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 { 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: {
|
export declare const polyfill: {
|
||||||
(target: any, options?: PolyfillOptions): any;
|
(target: any, options?: PolyfillOptions): any;
|
||||||
internals(target: any, name: string): any;
|
internals(target: any, name: string): any;
|
||||||
|
|
Loading…
Reference in a new issue