Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5fe1889
feat: move astro config validation after astro:config:setup
florian-lefebvre Mar 21, 2025
09ba9ce
feat: superRefine
florian-lefebvre Mar 21, 2025
d990b07
fix: test
florian-lefebvre Mar 21, 2025
f0abd11
feat: update test
florian-lefebvre Mar 21, 2025
27668d3
feat: update test
florian-lefebvre Mar 21, 2025
f7699d5
fix: test
florian-lefebvre Mar 21, 2025
fbaada2
Merge branch 'main' into feat/post-integrations-config-validation
florian-lefebvre Mar 21, 2025
d074a51
feat: feedback
florian-lefebvre Mar 21, 2025
de52147
Merge branch 'main' into feat/post-integrations-config-validation
florian-lefebvre Mar 26, 2025
634696f
feat: improve logging
florian-lefebvre Mar 26, 2025
60cffca
feat: refactor
florian-lefebvre Mar 26, 2025
0a3ce47
fix: no spread
florian-lefebvre Mar 26, 2025
4598ae7
feat: split schemas
florian-lefebvre Mar 26, 2025
a353e4a
chore: changeset
florian-lefebvre Mar 26, 2025
4fb9ec1
Merge branch 'main' into feat/post-integrations-config-validation
florian-lefebvre Mar 26, 2025
57c55bd
Update packages/astro/src/core/config/schemas/README.md
florian-lefebvre Mar 27, 2025
3159e7b
Merge branch 'main' into feat/post-integrations-config-validation
florian-lefebvre Mar 27, 2025
a021476
Update packages/astro/src/integrations/hooks.ts
florian-lefebvre Mar 28, 2025
0a0507e
Update packages/astro/src/core/config/schemas/README.md
florian-lefebvre Mar 28, 2025
f9eb6b1
Update .changeset/easy-vans-laugh.md
florian-lefebvre Apr 1, 2025
01e8518
Update .changeset/easy-vans-laugh.md
florian-lefebvre Apr 1, 2025
e68052d
Merge branch 'main' into feat/post-integrations-config-validation
florian-lefebvre Apr 1, 2025
ef18425
grammar nit in changeset
sarah11918 Apr 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/easy-vans-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'astro': minor
---

Updates when the configuration is validated to include integrations

From now on, Astro will validate the configuration before and after each integration `astro:config:setup` hook have run. This means `updateConfig()` calls will no longer accept invalid configuration.
7 changes: 7 additions & 0 deletions .changeset/three-masks-see.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'astro': minor
---

Improves integrations error handling

If an error is thrown from an integration hook, an error log will now provide information about the concerned integration and hook
2 changes: 1 addition & 1 deletion packages/astro/src/container/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import './polyfill.js';
import { posix } from 'node:path';
import { getDefaultClientDirectives } from '../core/client-directive/index.js';
import { ASTRO_CONFIG_DEFAULTS } from '../core/config/schema.js';
import { ASTRO_CONFIG_DEFAULTS } from '../core/config/schemas/index.js';
import { validateConfig } from '../core/config/validate.js';
import { createKey } from '../core/encryption.js';
import { Logger } from '../core/logger/core.js';
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/core/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class AstroBuilder {

/** Run the build logic. build() is marked private because usage should go through ".run()" */
private async build({ viteConfig }: { viteConfig: vite.InlineConfig }) {
await runHookBuildStart({ config: this.settings.config, logging: this.logger });
await runHookBuildStart({ config: this.settings.config, logger: this.logger });
this.validateConfig();

this.logger.info('build', `output: ${blue('"' + this.settings.config.output + '"')}`);
Expand Down Expand Up @@ -248,7 +248,7 @@ class AstroBuilder {
.flat()
.map((pageData) => pageData.route)
.concat(hasServerIslands ? getServerIslandRouteData(this.settings.config) : []),
logging: this.logger,
logger: this.logger,
});

if (this.logger.level && levels[this.logger.level()] <= levels['info']) {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export {
} from './config.js';
export { createNodeLogger } from './logging.js';
export { mergeConfig } from './merge.js';
export type { AstroConfigType } from './schema.js';
export type { AstroConfigType } from './schemas/index.js';
export { createSettings } from './settings.js';
export { loadTSConfig, updateTSConfigForFramework } from './tsconfig.js';
7 changes: 7 additions & 0 deletions packages/astro/src/core/config/schemas/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Config schemas

There are 3 zod schemas needed to validate the Astro config properly:

- `AstroConfigSchema` (base): a schema that matches the `AstroConfig` type
- `createRelativeSchema` (relative): a function that uses the base schema, and adds transformations relative to the project root. Transformations occur at runtime, and the paths are resolved against the `cwd` of the CLI.
- `AstroConfigRefinedSchema` (refined): a schema that handles extra validations. Due to constraints imposed by the Astro architecture, refinements can't run when the configuration is validated because the referiment changes the initial types of `AstroConfig`. The refinement phase can happen only after the user configuration is validated and every integration has run the hook `astro:config:setup`.
Loading