Skip to content

Commit

Permalink
refactor: use AstroIntegrationLogger
Browse files Browse the repository at this point in the history
  • Loading branch information
jlarmstrongiv committed Sep 13, 2023
1 parent 4bc7c4a commit f7468c1
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 359 deletions.
3 changes: 0 additions & 3 deletions src/astro/logger/README.md

This file was deleted.

48 changes: 0 additions & 48 deletions src/astro/logger/console.ts

This file was deleted.

138 changes: 0 additions & 138 deletions src/astro/logger/core.ts

This file was deleted.

132 changes: 0 additions & 132 deletions src/astro/logger/node.ts

This file was deleted.

9 changes: 5 additions & 4 deletions src/integration/ensureValidConfigs/ensureValidConfigs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AstroConfig } from "astro";
import type { AstroConfig, AstroIntegrationLogger } from "astro";
import type { UpdateConfig } from "./UpdateConfig";
import type { I18nConfig } from "../../shared/configs";
import { ensureValidTrailingSlashAndFormat } from "./ensureValidTrailingSlashAndFormat";
Expand All @@ -8,9 +8,10 @@ import { createVirtualModules } from "./createVirtualModules";
export async function ensureValidConfigs(
config: AstroConfig,
updateConfig: UpdateConfig,
i18nConfig: I18nConfig
i18nConfig: I18nConfig,
logger: AstroIntegrationLogger
) {
ensureValidTrailingSlashAndFormat(config, updateConfig);
await ensureValidRedirectMiddleware(config, i18nConfig);
ensureValidTrailingSlashAndFormat(config, updateConfig, logger);
await ensureValidRedirectMiddleware(config, i18nConfig, logger);
createVirtualModules(config, updateConfig, i18nConfig);
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { AstroConfig } from "astro";
import type { AstroConfig, AstroIntegrationLogger } from "astro";
import type { I18nConfig } from "../../shared/configs";
import path from "path";
import fs from "fs-extra";
import dedent from "dedent";
import { logger } from "../../astro/logger/node";
import { removeLeadingForwardSlashWindows } from "../../astro/internal-helpers/path";

export async function ensureValidRedirectMiddleware(
config: AstroConfig,
i18nConfig: I18nConfig
i18nConfig: I18nConfig,
logger: AstroIntegrationLogger
) {
if (i18nConfig.redirectDefaultLocale) {
const configSrcDirPathname = path.normalize(
Expand All @@ -35,12 +35,11 @@ export async function ensureValidRedirectMiddleware(

// warn and create middleware if it does not exist
if (pathExists === false) {
logger.warn("astro-i18n-aut", `cannot find any Astro middleware files:`);
logger.warn(`cannot find any Astro middleware files:`);
middlewarePaths.forEach((middlewarePath) => {
logger.warn("astro-i18n-aut", `- ${middlewarePath}`);
logger.warn(`- ${middlewarePath}`);
});
logger.warn(
"astro-i18n-aut",
`creating ${defaultMiddlewarePath} with defaultLocale = "en"`
);
await fs.outputFile(
Expand Down
Loading

0 comments on commit f7468c1

Please sign in to comment.