From 87b31fbf6ecaeea6757fa630f4b3a9f12d76335c Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Mon, 29 Apr 2024 19:08:59 +0200 Subject: [PATCH] chore(astro): move error-map (#10898) --- packages/astro/src/content/index.ts | 1 - packages/astro/src/content/utils.ts | 5 +---- packages/astro/src/core/errors/index.ts | 1 + .../{content/error-map.ts => core/errors/zod-error-map.ts} | 0 .../test/{units/content-collections => }/error-map.test.js | 6 +++--- 5 files changed, 5 insertions(+), 8 deletions(-) rename packages/astro/src/{content/error-map.ts => core/errors/zod-error-map.ts} (100%) rename packages/astro/test/{units/content-collections => }/error-map.test.js (94%) diff --git a/packages/astro/src/content/index.ts b/packages/astro/src/content/index.ts index dcbbeb55cc..815f77f2a6 100644 --- a/packages/astro/src/content/index.ts +++ b/packages/astro/src/content/index.ts @@ -1,5 +1,4 @@ export { CONTENT_FLAG, PROPAGATED_ASSET_FLAG } from './consts.js'; -export { errorMap } from './error-map.js'; export { attachContentServerListeners } from './server-listeners.js'; export { createContentTypesGenerator } from './types-generator.js'; export { diff --git a/packages/astro/src/content/utils.ts b/packages/astro/src/content/utils.ts index 4bec3dd8d5..f4356ab27c 100644 --- a/packages/astro/src/content/utils.ts +++ b/packages/astro/src/content/utils.ts @@ -12,12 +12,9 @@ import type { ContentEntryType, DataEntryType, } from '../@types/astro.js'; -import { AstroError, AstroErrorData } from '../core/errors/index.js'; - -import { MarkdownError } from '../core/errors/index.js'; +import { AstroError, AstroErrorData, MarkdownError, errorMap } from '../core/errors/index.js'; import { isYAMLException } from '../core/errors/utils.js'; import { CONTENT_FLAGS, CONTENT_TYPES_FILE, PROPAGATED_ASSET_FLAG } from './consts.js'; -import { errorMap } from './error-map.js'; import { createImage } from './runtime-assets.js'; /** diff --git a/packages/astro/src/core/errors/index.ts b/packages/astro/src/core/errors/index.ts index 31071cac30..5a871ca290 100644 --- a/packages/astro/src/core/errors/index.ts +++ b/packages/astro/src/core/errors/index.ts @@ -11,3 +11,4 @@ export { export type { ErrorLocation, ErrorWithMetadata } from './errors.js'; export { codeFrame } from './printer.js'; export { createSafeError, positionAt } from './utils.js'; +export { errorMap } from './zod-error-map.js'; \ No newline at end of file diff --git a/packages/astro/src/content/error-map.ts b/packages/astro/src/core/errors/zod-error-map.ts similarity index 100% rename from packages/astro/src/content/error-map.ts rename to packages/astro/src/core/errors/zod-error-map.ts diff --git a/packages/astro/test/units/content-collections/error-map.test.js b/packages/astro/test/error-map.test.js similarity index 94% rename from packages/astro/test/units/content-collections/error-map.test.js rename to packages/astro/test/error-map.test.js index 0595fd58a2..5a91bd96e8 100644 --- a/packages/astro/test/units/content-collections/error-map.test.js +++ b/packages/astro/test/error-map.test.js @@ -1,8 +1,8 @@ import * as assert from 'node:assert/strict'; import { describe, it } from 'node:test'; -import { errorMap } from '../../../dist/content/index.js'; -import { z } from '../../../zod.mjs'; -import { fixLineEndings } from '../../test-utils.js'; +import { errorMap } from '../dist/core/errors/zod-error-map.js'; +import { z } from '../zod.mjs'; +import { fixLineEndings } from './test-utils.js'; describe('Content Collections - error map', () => { it('Prefixes messages with object key', () => {