Skip to content

Commit 92fc030

Browse files
refactor(core): rename logger internal types (#16271)
Co-authored-by: Princesseuh <3019731+Princesseuh@users.noreply.github.com>
1 parent ba18015 commit 92fc030

100 files changed

Lines changed: 707 additions & 449 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/astro/e2e/test-utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export async function scrollToElement(el) {
113113
/**
114114
* Create a spy logger that captures log messages into provided arrays
115115
* @param {{info?: Array, warn?: Array, error?: Array, debug?: Array}} options - Optional arrays to push messages into
116-
* @returns {import('../dist/core/logger/core').Logger}
116+
* @returns {import('../dist/core/logger/core').AstroLogger}
117117
*/
118118
export function createLoggerSpy(options = {}) {
119119
const infoLogs = options.info || [];
@@ -135,7 +135,7 @@ export function createLoggerSpy(options = {}) {
135135
debugLogs.push(...messages.map((message) => ({ label, message })));
136136
},
137137
options: {
138-
dest: { write: () => true },
138+
destination: { write: () => true },
139139
level: 'info',
140140
},
141141
level: () => 'info',

packages/astro/src/assets/build/generate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { StaticBuildOptions } from '../../core/build/types.js';
66
import { getTimeStat } from '../../core/build/util.js';
77
import { AstroError } from '../../core/errors/errors.js';
88
import { AstroErrorData } from '../../core/errors/index.js';
9-
import type { Logger } from '../../core/logger/core.js';
9+
import type { AstroLogger } from '../../core/logger/core.js';
1010
import { isRemotePath, removeLeadingForwardSlash } from '../../core/path.js';
1111
import type { MapValue } from '../../type-utils.js';
1212
import type { AstroConfig } from '../../types/public/config.js';
@@ -31,7 +31,7 @@ interface GenerationDataCached {
3131
type GenerationData = GenerationDataUncached | GenerationDataCached;
3232

3333
type AssetEnv = {
34-
logger: Logger;
34+
logger: AstroLogger;
3535
isSSR: boolean;
3636
count: { total: number; current: number };
3737
useCache: boolean;

packages/astro/src/assets/fonts/core/compute-font-families-assets.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Logger } from '../../../core/logger/core.js';
1+
import type { AstroLogger } from '../../../core/logger/core.js';
22
import type { FontResolver, StringMatcher } from '../definitions.js';
33
import type {
44
Collaborator,
@@ -24,7 +24,7 @@ export async function computeFontFamiliesAssets({
2424
}: {
2525
resolvedFamilies: Array<ResolvedFontFamily>;
2626
fontResolver: FontResolver;
27-
logger: Logger;
27+
logger: AstroLogger;
2828
bold: (input: string) => string;
2929
defaults: Defaults;
3030
stringMatcher: StringMatcher;

packages/astro/src/assets/fonts/core/get-or-create-font-family-assets.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Logger } from '../../../core/logger/core.js';
1+
import type { AstroLogger } from '../../../core/logger/core.js';
22
import type { FontFamilyAssetsByUniqueKey, ResolvedFontFamily } from '../types.js';
33

44
export function getOrCreateFontFamilyAssets({
@@ -8,7 +8,7 @@ export function getOrCreateFontFamilyAssets({
88
family,
99
}: {
1010
fontFamilyAssetsByUniqueKey: FontFamilyAssetsByUniqueKey;
11-
logger: Logger;
11+
logger: AstroLogger;
1212
bold: (input: string) => string;
1313
family: ResolvedFontFamily;
1414
}) {

packages/astro/src/assets/fonts/vite-plugin-fonts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { getAlgorithm, shouldTrackCspHashes } from '../../core/csp/common.js';
77
import { generateCspDigest } from '../../core/encryption.js';
88
import { collectErrorMetadata } from '../../core/errors/dev/utils.js';
99
import { AstroError, AstroErrorData, isAstroError } from '../../core/errors/index.js';
10-
import type { Logger } from '../../core/logger/core.js';
10+
import type { AstroLogger } from '../../core/logger/core.js';
1111
import { formatErrorMessage } from '../../core/messages/runtime.js';
1212
import { appendForwardSlash, joinPaths, prependForwardSlash } from '../../core/path.js';
1313
import { getClientOutputDirectory } from '../../prerender/utils.js';
@@ -54,7 +54,7 @@ import type {
5454
interface Options {
5555
settings: AstroSettings;
5656
sync: boolean;
57-
logger: Logger;
57+
logger: AstroLogger;
5858
}
5959

6060
export function fontsPlugin({ settings, sync, logger }: Options): Plugin {

packages/astro/src/assets/vite-plugin-assets.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import MagicString from 'magic-string';
44
import picomatch from 'picomatch';
55
import type * as vite from 'vite';
66
import { AstroError, AstroErrorData } from '../core/errors/index.js';
7-
import type { Logger } from '../core/logger/core.js';
7+
import type { AstroLogger } from '../core/logger/core.js';
88
import {
99
appendForwardSlash,
1010
joinPaths,
@@ -119,7 +119,7 @@ const addStaticImageFactory = (
119119
interface Options {
120120
settings: AstroSettings;
121121
sync: boolean;
122-
logger: Logger;
122+
logger: AstroLogger;
123123
fs: typeof fsMod;
124124
}
125125

packages/astro/src/cli/add/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
presets,
2323
updateTSConfigForFramework,
2424
} from '../../core/config/tsconfig.js';
25-
import type { Logger } from '../../core/logger/core.js';
25+
import type { AstroLogger } from '../../core/logger/core.js';
2626
import * as msg from '../../core/messages/runtime.js';
2727
import { printHelp } from '../../core/messages/runtime.js';
2828
import { appendForwardSlash } from '../../core/path.js';
@@ -652,7 +652,7 @@ async function updateAstroConfig({
652652
configURL: URL;
653653
mod: ProxifiedModule<any>;
654654
flags: Flags;
655-
logger: Logger;
655+
logger: AstroLogger;
656656
logAdapterInstructions: boolean;
657657
}): Promise<UpdateResult> {
658658
const input = await fs.readFile(fileURLToPath(configURL), { encoding: 'utf-8' });
@@ -713,7 +713,7 @@ async function updatePackageJsonOverrides({
713713
}: {
714714
configURL: URL;
715715
flags: Flags;
716-
logger: Logger;
716+
logger: AstroLogger;
717717
overrides: Record<string, string>;
718718
}): Promise<UpdateResult> {
719719
const pkgURL = new URL('./package.json', configURL);
@@ -774,7 +774,7 @@ async function updatePackageJsonScripts({
774774
}: {
775775
configURL: URL;
776776
flags: Flags;
777-
logger: Logger;
777+
logger: AstroLogger;
778778
scripts: Record<string, string>;
779779
}): Promise<UpdateResult> {
780780
const pkgURL = new URL('./package.json', configURL);
@@ -877,7 +877,7 @@ async function tryToInstallIntegrations({
877877
integrations: IntegrationInfo[];
878878
cwd?: string;
879879
flags: Flags;
880-
logger: Logger;
880+
logger: AstroLogger;
881881
}): Promise<UpdateResult> {
882882
const packageManager = await detect({
883883
cwd,
@@ -950,7 +950,7 @@ async function tryToInstallIntegrations({
950950
async function validateIntegrations(
951951
integrations: string[],
952952
flags: yargsParser.Arguments,
953-
logger: Logger,
953+
logger: AstroLogger,
954954
): Promise<IntegrationInfo[]> {
955955
// First, validate all package names to prevent command injection
956956
for (const integration of integrations) {
@@ -1069,7 +1069,7 @@ async function validateIntegrations(
10691069

10701070
async function updateTSConfig(
10711071
cwd = process.cwd(),
1072-
logger: Logger,
1072+
logger: AstroLogger,
10731073
integrationsInfo: IntegrationInfo[],
10741074
flags: Flags,
10751075
options?: { addIncludes?: string[] },
@@ -1193,7 +1193,7 @@ async function askToContinue({
11931193
logger,
11941194
}: {
11951195
flags: Flags;
1196-
logger: Logger;
1196+
logger: AstroLogger;
11971197
}): Promise<boolean> {
11981198
if (flags.yes || flags.y) return true;
11991199
if (!hasHintedAboutYesFlag) {
@@ -1237,7 +1237,7 @@ function getDiffContent(input: string, output: string): string | null {
12371237

12381238
async function setupIntegrationConfig(opts: {
12391239
root: URL;
1240-
logger: Logger;
1240+
logger: AstroLogger;
12411241
flags: Flags;
12421242
integrationName: string;
12431243
possibleConfigFiles: string[];

packages/astro/src/cli/create-key/core/create-key.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import type { Logger } from '../../../core/logger/core.js';
1+
import type { AstroLogger } from '../../../core/logger/core.js';
22
import { defineCommand } from '../../domain/command.js';
33
import type { KeyGenerator } from '../definitions.js';
44

55
interface Options {
6-
logger: Logger;
6+
logger: AstroLogger;
77
keyGenerator: KeyGenerator;
88
}
99

packages/astro/src/cli/docs/core/open-docs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import type { Logger } from '../../../core/logger/core.js';
1+
import type { AstroLogger } from '../../../core/logger/core.js';
22
import type { CommandExecutor, OperatingSystemProvider } from '../../definitions.js';
33
import { defineCommand } from '../../domain/command.js';
44
import type { CloudIdeProvider } from '../definitions.js';
55

66
interface Options {
77
url: string;
88
operatingSystemProvider: OperatingSystemProvider;
9-
logger: Logger;
9+
logger: AstroLogger;
1010
commandExecutor: CommandExecutor;
1111
cloudIdeProvider: CloudIdeProvider;
1212
}

packages/astro/src/cli/flags.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Arguments } from 'yargs-parser';
2-
import type { Logger, LogOptions } from '../core/logger/core.js';
2+
import type { AstroLogger, AstroLogOptions } from '../core/logger/core.js';
33
import { createNodeLogger, nodeLogDestination } from '../core/logger/node.js';
44
import type { AstroInlineConfig } from '../types/public/config.js';
55

@@ -40,9 +40,9 @@ export function flagsToAstroInlineConfig(flags: Flags): AstroInlineConfig {
4040
* The `logging` is usually created from an `AstroInlineConfig`, but some flows like `add`
4141
* doesn't read the AstroConfig directly, so we create a `logging` object from the CLI flags instead.
4242
*/
43-
export function createLoggerFromFlags(flags: Flags): Logger {
44-
const logging: LogOptions = {
45-
dest: nodeLogDestination,
43+
export function createLoggerFromFlags(flags: Flags): AstroLogger {
44+
const logging: AstroLogOptions = {
45+
destination: nodeLogDestination,
4646
level: 'info',
4747
};
4848

0 commit comments

Comments
 (0)