feat: pass logger to integrations
This commit is contained in:
parent
25e04a2ecb
commit
95110f4aec
7 changed files with 228 additions and 100 deletions
|
@ -22,6 +22,7 @@ import type { AstroCookies } from '../core/cookies';
|
||||||
import type { LogOptions } from '../core/logger/core';
|
import type { LogOptions } from '../core/logger/core';
|
||||||
import type { AstroComponentFactory, AstroComponentInstance } from '../runtime/server';
|
import type { AstroComponentFactory, AstroComponentInstance } from '../runtime/server';
|
||||||
import type { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../core/constants.js';
|
import type { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../core/constants.js';
|
||||||
|
import { AstroIntegrationLogger } from '../core/logger/core';
|
||||||
export type {
|
export type {
|
||||||
MarkdownHeading,
|
MarkdownHeading,
|
||||||
MarkdownMetadata,
|
MarkdownMetadata,
|
||||||
|
@ -1856,7 +1857,8 @@ export interface AstroIntegration {
|
||||||
name: string;
|
name: string;
|
||||||
/** The different hooks available to extend. */
|
/** The different hooks available to extend. */
|
||||||
hooks: {
|
hooks: {
|
||||||
'astro:config:setup'?: (options: {
|
'astro:config:setup'?: (
|
||||||
|
options: {
|
||||||
config: AstroConfig;
|
config: AstroConfig;
|
||||||
command: 'dev' | 'build' | 'preview';
|
command: 'dev' | 'build' | 'preview';
|
||||||
isRestart: boolean;
|
isRestart: boolean;
|
||||||
|
@ -1870,15 +1872,27 @@ export interface AstroIntegration {
|
||||||
// This may require some refactoring of `scripts`, `styles`, and `links` into something
|
// This may require some refactoring of `scripts`, `styles`, and `links` into something
|
||||||
// more generalized. Consider the SSR use-case as well.
|
// more generalized. Consider the SSR use-case as well.
|
||||||
// injectElement: (stage: vite.HtmlTagDescriptor, element: string) => void;
|
// injectElement: (stage: vite.HtmlTagDescriptor, element: string) => void;
|
||||||
}) => void | Promise<void>;
|
},
|
||||||
'astro:config:done'?: (options: {
|
bag: AstroIntegrationBag
|
||||||
|
) => void | Promise<void>;
|
||||||
|
'astro:config:done'?: (
|
||||||
|
options: {
|
||||||
config: AstroConfig;
|
config: AstroConfig;
|
||||||
setAdapter: (adapter: AstroAdapter) => void;
|
setAdapter: (adapter: AstroAdapter) => void;
|
||||||
}) => void | Promise<void>;
|
},
|
||||||
'astro:server:setup'?: (options: { server: vite.ViteDevServer }) => void | Promise<void>;
|
bag: AstroIntegrationBag
|
||||||
'astro:server:start'?: (options: { address: AddressInfo }) => void | Promise<void>;
|
) => void | Promise<void>;
|
||||||
'astro:server:done'?: () => void | Promise<void>;
|
'astro:server:setup'?: (
|
||||||
'astro:build:ssr'?: (options: {
|
options: { server: vite.ViteDevServer },
|
||||||
|
bag: AstroIntegrationBag
|
||||||
|
) => void | Promise<void>;
|
||||||
|
'astro:server:start'?: (
|
||||||
|
options: { address: AddressInfo },
|
||||||
|
bag: AstroIntegrationBag
|
||||||
|
) => void | Promise<void>;
|
||||||
|
'astro:server:done'?: (bag: AstroIntegrationBag) => void | Promise<void>;
|
||||||
|
'astro:build:ssr'?: (
|
||||||
|
options: {
|
||||||
manifest: SerializedSSRManifest;
|
manifest: SerializedSSRManifest;
|
||||||
/**
|
/**
|
||||||
* This maps a {@link RouteData} to an {@link URL}, this URL represents
|
* This maps a {@link RouteData} to an {@link URL}, this URL represents
|
||||||
|
@ -1889,23 +1903,41 @@ export interface AstroIntegration {
|
||||||
* File path of the emitted middleware
|
* File path of the emitted middleware
|
||||||
*/
|
*/
|
||||||
middlewareEntryPoint: URL | undefined;
|
middlewareEntryPoint: URL | undefined;
|
||||||
}) => void | Promise<void>;
|
},
|
||||||
'astro:build:start'?: () => void | Promise<void>;
|
bag: AstroIntegrationBag
|
||||||
'astro:build:setup'?: (options: {
|
) => void | Promise<void>;
|
||||||
|
'astro:build:start'?: (bag: AstroIntegrationBag) => void | Promise<void>;
|
||||||
|
'astro:build:setup'?: (
|
||||||
|
options: {
|
||||||
vite: vite.InlineConfig;
|
vite: vite.InlineConfig;
|
||||||
pages: Map<string, PageBuildData>;
|
pages: Map<string, PageBuildData>;
|
||||||
target: 'client' | 'server';
|
target: 'client' | 'server';
|
||||||
updateConfig: (newConfig: vite.InlineConfig) => void;
|
updateConfig: (newConfig: vite.InlineConfig) => void;
|
||||||
}) => void | Promise<void>;
|
},
|
||||||
'astro:build:generated'?: (options: { dir: URL }) => void | Promise<void>;
|
bag: AstroIntegrationBag
|
||||||
'astro:build:done'?: (options: {
|
) => void | Promise<void>;
|
||||||
|
'astro:build:generated'?: (
|
||||||
|
options: { dir: URL },
|
||||||
|
bag: AstroIntegrationBag
|
||||||
|
) => void | Promise<void>;
|
||||||
|
'astro:build:done'?: (
|
||||||
|
options: {
|
||||||
pages: { pathname: string }[];
|
pages: { pathname: string }[];
|
||||||
dir: URL;
|
dir: URL;
|
||||||
routes: RouteData[];
|
routes: RouteData[];
|
||||||
}) => void | Promise<void>;
|
},
|
||||||
|
bag: AstroIntegrationBag
|
||||||
|
) => void | Promise<void>;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A set of utilities that are passed at each hook
|
||||||
|
*/
|
||||||
|
export type AstroIntegrationBag = {
|
||||||
|
logger: AstroIntegrationLogger;
|
||||||
|
};
|
||||||
|
|
||||||
export type MiddlewareNext<R> = () => Promise<R>;
|
export type MiddlewareNext<R> = () => Promise<R>;
|
||||||
export type MiddlewareHandler<R> = (
|
export type MiddlewareHandler<R> = (
|
||||||
context: APIContext,
|
context: APIContext,
|
||||||
|
|
|
@ -15,7 +15,7 @@ export const consoleLogDestination = {
|
||||||
|
|
||||||
function getPrefix() {
|
function getPrefix() {
|
||||||
let prefix = '';
|
let prefix = '';
|
||||||
let type = event.type;
|
let type = event.label;
|
||||||
if (type) {
|
if (type) {
|
||||||
// hide timestamp when type is undefined
|
// hide timestamp when type is undefined
|
||||||
prefix += dim(dateTimeFormat.format(new Date()) + ' ');
|
prefix += dim(dateTimeFormat.format(new Date()) + ' ');
|
||||||
|
|
|
@ -6,7 +6,6 @@ interface LogWritable<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
export type LoggerLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent'; // same as Pino
|
export type LoggerLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent'; // same as Pino
|
||||||
export type LoggerEvent = 'info' | 'warn' | 'error';
|
|
||||||
|
|
||||||
export interface LogOptions {
|
export interface LogOptions {
|
||||||
dest: LogWritable<LogMessage>;
|
dest: LogWritable<LogMessage>;
|
||||||
|
@ -29,7 +28,7 @@ export const dateTimeFormat = new Intl.DateTimeFormat([], {
|
||||||
});
|
});
|
||||||
|
|
||||||
export interface LogMessage {
|
export interface LogMessage {
|
||||||
type: string | null;
|
label: string | null;
|
||||||
level: LoggerLevel;
|
level: LoggerLevel;
|
||||||
message: string;
|
message: string;
|
||||||
}
|
}
|
||||||
|
@ -43,11 +42,11 @@ export const levels: Record<LoggerLevel, number> = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Full logging API */
|
/** Full logging API */
|
||||||
export function log(opts: LogOptions, level: LoggerLevel, type: string | null, message: string) {
|
export function log(opts: LogOptions, level: LoggerLevel, label: string | null, message: string) {
|
||||||
const logLevel = opts.level;
|
const logLevel = opts.level;
|
||||||
const dest = opts.dest;
|
const dest = opts.dest;
|
||||||
const event: LogMessage = {
|
const event: LogMessage = {
|
||||||
type,
|
label,
|
||||||
level,
|
level,
|
||||||
message,
|
message,
|
||||||
};
|
};
|
||||||
|
@ -61,18 +60,18 @@ export function log(opts: LogOptions, level: LoggerLevel, type: string | null, m
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Emit a user-facing message. Useful for UI and other console messages. */
|
/** Emit a user-facing message. Useful for UI and other console messages. */
|
||||||
export function info(opts: LogOptions, type: string | null, message: string) {
|
export function info(opts: LogOptions, label: string | null, message: string) {
|
||||||
return log(opts, 'info', type, message);
|
return log(opts, 'info', label, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Emit a warning message. Useful for high-priority messages that aren't necessarily errors. */
|
/** Emit a warning message. Useful for high-priority messages that aren't necessarily errors. */
|
||||||
export function warn(opts: LogOptions, type: string | null, message: string) {
|
export function warn(opts: LogOptions, label: string | null, message: string) {
|
||||||
return log(opts, 'warn', type, message);
|
return log(opts, 'warn', label, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Emit a error message, Useful when Astro can't recover from some error. */
|
/** Emit a error message, Useful when Astro can't recover from some error. */
|
||||||
export function error(opts: LogOptions, type: string | null, message: string) {
|
export function error(opts: LogOptions, label: string | null, message: string) {
|
||||||
return log(opts, 'error', type, message);
|
return log(opts, 'error', label, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
type LogFn = typeof info | typeof warn | typeof error;
|
type LogFn = typeof info | typeof warn | typeof error;
|
||||||
|
@ -127,3 +126,53 @@ export function timerMessage(message: string, startTime: number = Date.now()) {
|
||||||
timeDiff < 750 ? `${Math.round(timeDiff)}ms` : `${(timeDiff / 1000).toFixed(1)}s`;
|
timeDiff < 750 ? `${Math.round(timeDiff)}ms` : `${(timeDiff / 1000).toFixed(1)}s`;
|
||||||
return `${message} ${dim(timeDisplay)}`;
|
return `${message} ${dim(timeDisplay)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class Logger {
|
||||||
|
options: LogOptions;
|
||||||
|
constructor(options: LogOptions) {
|
||||||
|
this.options = options;
|
||||||
|
}
|
||||||
|
|
||||||
|
info(label: string, message: string) {
|
||||||
|
info(this.options, label, message);
|
||||||
|
}
|
||||||
|
warn(label: string, message: string) {
|
||||||
|
warn(this.options, label, message);
|
||||||
|
}
|
||||||
|
error(label: string, message: string) {
|
||||||
|
error(this.options, label, message);
|
||||||
|
}
|
||||||
|
debug(label: string, message: string) {
|
||||||
|
debug(this.options, label, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class AstroIntegrationLogger {
|
||||||
|
options: LogOptions;
|
||||||
|
label: string;
|
||||||
|
|
||||||
|
constructor(logging: LogOptions, label: string) {
|
||||||
|
this.options = logging;
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new logger instances with a new label, but the same log options.
|
||||||
|
*/
|
||||||
|
fork(label: string): AstroIntegrationLogger {
|
||||||
|
return new AstroIntegrationLogger(this.options, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
info(message: string) {
|
||||||
|
info(this.options, this.label, message);
|
||||||
|
}
|
||||||
|
warn(message: string) {
|
||||||
|
warn(this.options, this.label, message);
|
||||||
|
}
|
||||||
|
error(message: string) {
|
||||||
|
error(this.options, this.label, message);
|
||||||
|
}
|
||||||
|
debug(message: string) {
|
||||||
|
debug(this.options, this.label, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -21,19 +21,19 @@ export const nodeLogDestination = new Writable({
|
||||||
|
|
||||||
function getPrefix() {
|
function getPrefix() {
|
||||||
let prefix = '';
|
let prefix = '';
|
||||||
let type = event.type;
|
let label = event.label;
|
||||||
if (type) {
|
if (label) {
|
||||||
// hide timestamp when type is undefined
|
// hide timestamp when type is undefined
|
||||||
prefix += dim(dateTimeFormat.format(new Date()) + ' ');
|
prefix += dim(dateTimeFormat.format(new Date()) + ' ');
|
||||||
if (event.level === 'info') {
|
if (event.level === 'info') {
|
||||||
type = bold(cyan(`[${type}]`));
|
label = bold(cyan(`[${label}]`));
|
||||||
} else if (event.level === 'warn') {
|
} else if (event.level === 'warn') {
|
||||||
type = bold(yellow(`[${type}]`));
|
label = bold(yellow(`[${label}]`));
|
||||||
} else if (event.level === 'error') {
|
} else if (event.level === 'error') {
|
||||||
type = bold(red(`[${type}]`));
|
label = bold(red(`[${label}]`));
|
||||||
}
|
}
|
||||||
|
|
||||||
prefix += `${type} `;
|
prefix += `${label} `;
|
||||||
}
|
}
|
||||||
return reset(prefix);
|
return reset(prefix);
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ export const nodeLogOptions: Required<LogOptions> = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface LogMessage {
|
export interface LogMessage {
|
||||||
type: string | null;
|
label: string | null;
|
||||||
level: LoggerLevel;
|
level: LoggerLevel;
|
||||||
message: string;
|
message: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ import type { SerializedSSRManifest } from '../core/app/types';
|
||||||
import type { PageBuildData } from '../core/build/types';
|
import type { PageBuildData } from '../core/build/types';
|
||||||
import { buildClientDirectiveEntrypoint } from '../core/client-directive/index.js';
|
import { buildClientDirectiveEntrypoint } from '../core/client-directive/index.js';
|
||||||
import { mergeConfig } from '../core/config/index.js';
|
import { mergeConfig } from '../core/config/index.js';
|
||||||
import { info, type LogOptions } from '../core/logger/core.js';
|
import { info, type LogOptions, AstroIntegrationLogger } from '../core/logger/core.js';
|
||||||
import { isServerLikeOutput } from '../prerender/utils.js';
|
import { isServerLikeOutput } from '../prerender/utils.js';
|
||||||
|
|
||||||
async function withTakingALongTimeMsg<T>({
|
async function withTakingALongTimeMsg<T>({
|
||||||
|
@ -38,6 +38,19 @@ async function withTakingALongTimeMsg<T>({
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Internally used to store instances of loggers.
|
||||||
|
const Loggers = new Map<string, AstroIntegrationLogger>();
|
||||||
|
|
||||||
|
function getLogger(adapterName: string, logging: LogOptions) {
|
||||||
|
if (Loggers.has(adapterName)) {
|
||||||
|
// SAFETY: we check the existence in the if block
|
||||||
|
return Loggers.get(adapterName)!;
|
||||||
|
}
|
||||||
|
const logger = new AstroIntegrationLogger(logging, adapterName);
|
||||||
|
Loggers.set(adapterName, logger);
|
||||||
|
return logger;
|
||||||
|
}
|
||||||
|
|
||||||
export async function runHookConfigSetup({
|
export async function runHookConfigSetup({
|
||||||
settings,
|
settings,
|
||||||
command,
|
command,
|
||||||
|
@ -72,6 +85,8 @@ export async function runHookConfigSetup({
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
if (integration.hooks?.['astro:config:setup']) {
|
if (integration.hooks?.['astro:config:setup']) {
|
||||||
|
const logger = getLogger(integration.name, logging);
|
||||||
|
|
||||||
const hooks: HookParameters<'astro:config:setup'> = {
|
const hooks: HookParameters<'astro:config:setup'> = {
|
||||||
config: updatedConfig,
|
config: updatedConfig,
|
||||||
command,
|
command,
|
||||||
|
@ -144,7 +159,7 @@ export async function runHookConfigSetup({
|
||||||
|
|
||||||
await withTakingALongTimeMsg({
|
await withTakingALongTimeMsg({
|
||||||
name: integration.name,
|
name: integration.name,
|
||||||
hookResult: integration.hooks['astro:config:setup'](hooks),
|
hookResult: integration.hooks['astro:config:setup'](hooks, { logger }),
|
||||||
logging,
|
logging,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -167,10 +182,12 @@ export async function runHookConfigDone({
|
||||||
logging: LogOptions;
|
logging: LogOptions;
|
||||||
}) {
|
}) {
|
||||||
for (const integration of settings.config.integrations) {
|
for (const integration of settings.config.integrations) {
|
||||||
|
const logger = getLogger(integration.name, logging);
|
||||||
if (integration?.hooks?.['astro:config:done']) {
|
if (integration?.hooks?.['astro:config:done']) {
|
||||||
await withTakingALongTimeMsg({
|
await withTakingALongTimeMsg({
|
||||||
name: integration.name,
|
name: integration.name,
|
||||||
hookResult: integration.hooks['astro:config:done']({
|
hookResult: integration.hooks['astro:config:done'](
|
||||||
|
{
|
||||||
config: settings.config,
|
config: settings.config,
|
||||||
setAdapter(adapter) {
|
setAdapter(adapter) {
|
||||||
if (settings.adapter && settings.adapter.name !== adapter.name) {
|
if (settings.adapter && settings.adapter.name !== adapter.name) {
|
||||||
|
@ -180,7 +197,9 @@ export async function runHookConfigDone({
|
||||||
}
|
}
|
||||||
settings.adapter = adapter;
|
settings.adapter = adapter;
|
||||||
},
|
},
|
||||||
}),
|
},
|
||||||
|
{ logger }
|
||||||
|
),
|
||||||
logging,
|
logging,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -198,9 +217,10 @@ export async function runHookServerSetup({
|
||||||
}) {
|
}) {
|
||||||
for (const integration of config.integrations) {
|
for (const integration of config.integrations) {
|
||||||
if (integration?.hooks?.['astro:server:setup']) {
|
if (integration?.hooks?.['astro:server:setup']) {
|
||||||
|
const logger = getLogger(integration.name, logging);
|
||||||
await withTakingALongTimeMsg({
|
await withTakingALongTimeMsg({
|
||||||
name: integration.name,
|
name: integration.name,
|
||||||
hookResult: integration.hooks['astro:server:setup']({ server }),
|
hookResult: integration.hooks['astro:server:setup']({ server }, { logger }),
|
||||||
logging,
|
logging,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -217,10 +237,12 @@ export async function runHookServerStart({
|
||||||
logging: LogOptions;
|
logging: LogOptions;
|
||||||
}) {
|
}) {
|
||||||
for (const integration of config.integrations) {
|
for (const integration of config.integrations) {
|
||||||
|
const logger = getLogger(integration.name, logging);
|
||||||
|
|
||||||
if (integration?.hooks?.['astro:server:start']) {
|
if (integration?.hooks?.['astro:server:start']) {
|
||||||
await withTakingALongTimeMsg({
|
await withTakingALongTimeMsg({
|
||||||
name: integration.name,
|
name: integration.name,
|
||||||
hookResult: integration.hooks['astro:server:start']({ address }),
|
hookResult: integration.hooks['astro:server:start']({ address }, { logger }),
|
||||||
logging,
|
logging,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -235,10 +257,12 @@ export async function runHookServerDone({
|
||||||
logging: LogOptions;
|
logging: LogOptions;
|
||||||
}) {
|
}) {
|
||||||
for (const integration of config.integrations) {
|
for (const integration of config.integrations) {
|
||||||
|
const logger = getLogger(integration.name, logging);
|
||||||
|
|
||||||
if (integration?.hooks?.['astro:server:done']) {
|
if (integration?.hooks?.['astro:server:done']) {
|
||||||
await withTakingALongTimeMsg({
|
await withTakingALongTimeMsg({
|
||||||
name: integration.name,
|
name: integration.name,
|
||||||
hookResult: integration.hooks['astro:server:done'](),
|
hookResult: integration.hooks['astro:server:done']({ logger }),
|
||||||
logging,
|
logging,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -254,9 +278,11 @@ export async function runHookBuildStart({
|
||||||
}) {
|
}) {
|
||||||
for (const integration of config.integrations) {
|
for (const integration of config.integrations) {
|
||||||
if (integration?.hooks?.['astro:build:start']) {
|
if (integration?.hooks?.['astro:build:start']) {
|
||||||
|
const logger = getLogger(integration.name, logging);
|
||||||
|
|
||||||
await withTakingALongTimeMsg({
|
await withTakingALongTimeMsg({
|
||||||
name: integration.name,
|
name: integration.name,
|
||||||
hookResult: integration.hooks['astro:build:start'](),
|
hookResult: integration.hooks['astro:build:start']({ logger }),
|
||||||
logging,
|
logging,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -280,16 +306,21 @@ export async function runHookBuildSetup({
|
||||||
|
|
||||||
for (const integration of config.integrations) {
|
for (const integration of config.integrations) {
|
||||||
if (integration?.hooks?.['astro:build:setup']) {
|
if (integration?.hooks?.['astro:build:setup']) {
|
||||||
|
const logger = getLogger(integration.name, logging);
|
||||||
|
|
||||||
await withTakingALongTimeMsg({
|
await withTakingALongTimeMsg({
|
||||||
name: integration.name,
|
name: integration.name,
|
||||||
hookResult: integration.hooks['astro:build:setup']({
|
hookResult: integration.hooks['astro:build:setup'](
|
||||||
|
{
|
||||||
vite,
|
vite,
|
||||||
pages,
|
pages,
|
||||||
target,
|
target,
|
||||||
updateConfig: (newConfig) => {
|
updateConfig: (newConfig) => {
|
||||||
updatedConfig = mergeConfig(updatedConfig, newConfig);
|
updatedConfig = mergeConfig(updatedConfig, newConfig);
|
||||||
},
|
},
|
||||||
}),
|
},
|
||||||
|
{ logger }
|
||||||
|
),
|
||||||
logging,
|
logging,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -315,13 +346,18 @@ export async function runHookBuildSsr({
|
||||||
}: RunHookBuildSsr) {
|
}: RunHookBuildSsr) {
|
||||||
for (const integration of config.integrations) {
|
for (const integration of config.integrations) {
|
||||||
if (integration?.hooks?.['astro:build:ssr']) {
|
if (integration?.hooks?.['astro:build:ssr']) {
|
||||||
|
const logger = getLogger(integration.name, logging);
|
||||||
|
|
||||||
await withTakingALongTimeMsg({
|
await withTakingALongTimeMsg({
|
||||||
name: integration.name,
|
name: integration.name,
|
||||||
hookResult: integration.hooks['astro:build:ssr']({
|
hookResult: integration.hooks['astro:build:ssr'](
|
||||||
|
{
|
||||||
manifest,
|
manifest,
|
||||||
entryPoints,
|
entryPoints,
|
||||||
middlewareEntryPoint,
|
middlewareEntryPoint,
|
||||||
}),
|
},
|
||||||
|
{ logger }
|
||||||
|
),
|
||||||
logging,
|
logging,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -338,10 +374,12 @@ export async function runHookBuildGenerated({
|
||||||
const dir = isServerLikeOutput(config) ? config.build.client : config.outDir;
|
const dir = isServerLikeOutput(config) ? config.build.client : config.outDir;
|
||||||
|
|
||||||
for (const integration of config.integrations) {
|
for (const integration of config.integrations) {
|
||||||
|
const logger = getLogger(integration.name, logging);
|
||||||
|
|
||||||
if (integration?.hooks?.['astro:build:generated']) {
|
if (integration?.hooks?.['astro:build:generated']) {
|
||||||
await withTakingALongTimeMsg({
|
await withTakingALongTimeMsg({
|
||||||
name: integration.name,
|
name: integration.name,
|
||||||
hookResult: integration.hooks['astro:build:generated']({ dir }),
|
hookResult: integration.hooks['astro:build:generated']({ dir }, { logger }),
|
||||||
logging,
|
logging,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -361,13 +399,18 @@ export async function runHookBuildDone({ config, pages, routes, logging }: RunHo
|
||||||
|
|
||||||
for (const integration of config.integrations) {
|
for (const integration of config.integrations) {
|
||||||
if (integration?.hooks?.['astro:build:done']) {
|
if (integration?.hooks?.['astro:build:done']) {
|
||||||
|
const logger = getLogger(integration.name, logging);
|
||||||
|
|
||||||
await withTakingALongTimeMsg({
|
await withTakingALongTimeMsg({
|
||||||
name: integration.name,
|
name: integration.name,
|
||||||
hookResult: integration.hooks['astro:build:done']({
|
hookResult: integration.hooks['astro:build:done'](
|
||||||
|
{
|
||||||
pages: pages.map((p) => ({ pathname: p })),
|
pages: pages.map((p) => ({ pathname: p })),
|
||||||
dir,
|
dir,
|
||||||
routes,
|
routes,
|
||||||
}),
|
},
|
||||||
|
{ logger }
|
||||||
|
),
|
||||||
logging,
|
logging,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,7 +175,7 @@ describe('Static build', () => {
|
||||||
let found = false;
|
let found = false;
|
||||||
for (const log of logs) {
|
for (const log of logs) {
|
||||||
if (
|
if (
|
||||||
log.type === 'ssg' &&
|
log.label === 'ssg' &&
|
||||||
/[hH]eaders are not exposed in static \(SSG\) output mode/.test(log.message)
|
/[hH]eaders are not exposed in static \(SSG\) output mode/.test(log.message)
|
||||||
) {
|
) {
|
||||||
found = true;
|
found = true;
|
||||||
|
|
|
@ -18752,21 +18752,25 @@ packages:
|
||||||
file:packages/astro/test/fixtures/css-assets/packages/font-awesome:
|
file:packages/astro/test/fixtures/css-assets/packages/font-awesome:
|
||||||
resolution: {directory: packages/astro/test/fixtures/css-assets/packages/font-awesome, type: directory}
|
resolution: {directory: packages/astro/test/fixtures/css-assets/packages/font-awesome, type: directory}
|
||||||
name: '@test/astro-font-awesome-package'
|
name: '@test/astro-font-awesome-package'
|
||||||
|
version: 0.0.1
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
file:packages/astro/test/fixtures/multiple-renderers/renderers/one:
|
file:packages/astro/test/fixtures/multiple-renderers/renderers/one:
|
||||||
resolution: {directory: packages/astro/test/fixtures/multiple-renderers/renderers/one, type: directory}
|
resolution: {directory: packages/astro/test/fixtures/multiple-renderers/renderers/one, type: directory}
|
||||||
name: '@test/astro-renderer-one'
|
name: '@test/astro-renderer-one'
|
||||||
|
version: 1.0.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
file:packages/astro/test/fixtures/multiple-renderers/renderers/two:
|
file:packages/astro/test/fixtures/multiple-renderers/renderers/two:
|
||||||
resolution: {directory: packages/astro/test/fixtures/multiple-renderers/renderers/two, type: directory}
|
resolution: {directory: packages/astro/test/fixtures/multiple-renderers/renderers/two, type: directory}
|
||||||
name: '@test/astro-renderer-two'
|
name: '@test/astro-renderer-two'
|
||||||
|
version: 1.0.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
file:packages/astro/test/fixtures/solid-component/deps/solid-jsx-component:
|
file:packages/astro/test/fixtures/solid-component/deps/solid-jsx-component:
|
||||||
resolution: {directory: packages/astro/test/fixtures/solid-component/deps/solid-jsx-component, type: directory}
|
resolution: {directory: packages/astro/test/fixtures/solid-component/deps/solid-jsx-component, type: directory}
|
||||||
name: '@test/solid-jsx-component'
|
name: '@test/solid-jsx-component'
|
||||||
|
version: 0.0.0
|
||||||
dependencies:
|
dependencies:
|
||||||
solid-js: 1.7.6
|
solid-js: 1.7.6
|
||||||
dev: false
|
dev: false
|
||||||
|
|
Loading…
Reference in a new issue