diff --git a/.changeset/funny-onions-grin.md b/.changeset/funny-onions-grin.md deleted file mode 100644 index 902bcb1aee..0000000000 --- a/.changeset/funny-onions-grin.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@astrojs/sitemap': patch ---- - -Adds missing `xslURL` property to `SitemapOptions` type. diff --git a/.changeset/selfish-toes-carry.md b/.changeset/selfish-toes-carry.md deleted file mode 100644 index 2933b214bb..0000000000 --- a/.changeset/selfish-toes-carry.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'astro': patch ---- - -Fixes a false positive reported by the dev toolbar Audit app where a label was considered missing when associated with a button - -The `button` element can be [used with a label](https://www.w3.org/TR/2011/WD-html5-author-20110809/forms.html#category-label) (e.g. to create a switch) and should not be reported as an accessibility issue when used as a child of a `label`. diff --git a/.changeset/sharp-garlics-float.md b/.changeset/sharp-garlics-float.md deleted file mode 100644 index c619d91c86..0000000000 --- a/.changeset/sharp-garlics-float.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes a regression in the computation of `Astro.currentLocale` diff --git a/.changeset/slimy-kids-peel.md b/.changeset/slimy-kids-peel.md deleted file mode 100644 index 706d01d47c..0000000000 --- a/.changeset/slimy-kids-peel.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes an issue where the edge middleware couldn't correctly compute the client IP address when calling `ctx.clientAddress()` diff --git a/.gitignore b/.gitignore index 8e6d783543..d6a28ec1b1 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,8 @@ package-lock.json packages/astro/src/**/*.prebuilt.ts packages/astro/src/**/*.prebuilt-dev.ts -!packages/astro/vendor/vite/dist +packages/astro/test/units/_temp-fixtures/* +!packages/astro/test/units/_temp-fixtures/package.json packages/integrations/**/.netlify/ # exclude IntelliJ/WebStorm stuff diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2f2e637867..4464b99fbe 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,7 +12,7 @@ We welcome contributions of any size and skill level. As an open source project, ```shell node: "^>=18.17.1" -pnpm: "^9.3.0" +pnpm: "^9.12.1" # otherwise, your build will fail ``` diff --git a/biome.jsonc b/biome.jsonc index a949301439..227f37a08d 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -6,6 +6,7 @@ "**/dist/**", "**/smoke/**", "**/fixtures/**", + "**/_temp-fixtures/**", "**/vendor/**", "**/.vercel/**", ], diff --git a/examples/basics/package.json b/examples/basics/package.json index 67ac030aec..27e4b451c5 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.16.3" + "astro": "^4.16.5" } } diff --git a/examples/blog/package.json b/examples/blog/package.json index 5a875765e1..1af4f65f4c 100644 --- a/examples/blog/package.json +++ b/examples/blog/package.json @@ -12,8 +12,8 @@ }, "dependencies": { "@astrojs/mdx": "^3.1.8", - "@astrojs/rss": "^4.0.8", - "@astrojs/sitemap": "^3.2.0", - "astro": "^4.16.3" + "@astrojs/rss": "^4.0.9", + "@astrojs/sitemap": "^3.2.1", + "astro": "^4.16.5" } } diff --git a/examples/component/package.json b/examples/component/package.json index ed83162781..f46ebb32d1 100644 --- a/examples/component/package.json +++ b/examples/component/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.16.3" + "astro": "^4.16.5" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/container-with-vitest/package.json b/examples/container-with-vitest/package.json index 260cb00f6b..576b7c85a4 100644 --- a/examples/container-with-vitest/package.json +++ b/examples/container-with-vitest/package.json @@ -12,14 +12,14 @@ "test": "vitest run" }, "dependencies": { - "astro": "^4.16.3", + "astro": "^4.16.5", "@astrojs/react": "^3.6.2", "react": "^18.3.1", "react-dom": "^18.3.1", - "vitest": "^2.1.2" + "vitest": "^2.1.3" }, "devDependencies": { "@types/react": "^18.3.11", - "@types/react-dom": "^18.3.0" + "@types/react-dom": "^18.3.1" } } diff --git a/examples/framework-alpine/package.json b/examples/framework-alpine/package.json index e6c27023aa..3d280064a6 100644 --- a/examples/framework-alpine/package.json +++ b/examples/framework-alpine/package.json @@ -14,6 +14,6 @@ "@astrojs/alpinejs": "^0.4.0", "@types/alpinejs": "^3.13.10", "alpinejs": "^3.14.1", - "astro": "^4.16.3" + "astro": "^4.16.5" } } diff --git a/examples/framework-lit/package.json b/examples/framework-lit/package.json index 4c437bc5ea..8262577f7f 100644 --- a/examples/framework-lit/package.json +++ b/examples/framework-lit/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/lit": "^4.3.0", "@webcomponents/template-shadowroot": "^0.2.1", - "astro": "^4.16.3", - "lit": "^3.2.0" + "astro": "^4.16.5", + "lit": "^3.2.1" } } diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json index 3f8ab04edc..9f9f47a998 100644 --- a/examples/framework-multiple/package.json +++ b/examples/framework-multiple/package.json @@ -17,13 +17,13 @@ "@astrojs/svelte": "^5.7.2", "@astrojs/vue": "^4.5.2", "@types/react": "^18.3.11", - "@types/react-dom": "^18.3.0", - "astro": "^4.16.3", - "preact": "^10.24.2", + "@types/react-dom": "^18.3.1", + "astro": "^4.16.5", + "preact": "^10.24.3", "react": "^18.3.1", "react-dom": "^18.3.1", - "solid-js": "^1.9.1", + "solid-js": "^1.9.2", "svelte": "^4.2.19", - "vue": "^3.5.11" + "vue": "^3.5.12" } } diff --git a/examples/framework-preact/package.json b/examples/framework-preact/package.json index 95c4043779..6f427e5be2 100644 --- a/examples/framework-preact/package.json +++ b/examples/framework-preact/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.5.3", "@preact/signals": "^1.3.0", - "astro": "^4.16.3", - "preact": "^10.24.2" + "astro": "^4.16.5", + "preact": "^10.24.3" } } diff --git a/examples/framework-react/package.json b/examples/framework-react/package.json index 78f617437d..ce1d63c1a3 100644 --- a/examples/framework-react/package.json +++ b/examples/framework-react/package.json @@ -13,8 +13,8 @@ "dependencies": { "@astrojs/react": "^3.6.2", "@types/react": "^18.3.11", - "@types/react-dom": "^18.3.0", - "astro": "^4.16.3", + "@types/react-dom": "^18.3.1", + "astro": "^4.16.5", "react": "^18.3.1", "react-dom": "^18.3.1" } diff --git a/examples/framework-solid/package.json b/examples/framework-solid/package.json index 6d8db3a999..6256b97bde 100644 --- a/examples/framework-solid/package.json +++ b/examples/framework-solid/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/solid-js": "^4.4.2", - "astro": "^4.16.3", - "solid-js": "^1.9.1" + "astro": "^4.16.5", + "solid-js": "^1.9.2" } } diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json index a301c46dca..b55624cd7e 100644 --- a/examples/framework-svelte/package.json +++ b/examples/framework-svelte/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/svelte": "^5.7.2", - "astro": "^4.16.3", + "astro": "^4.16.5", "svelte": "^4.2.19" } } diff --git a/examples/framework-vue/package.json b/examples/framework-vue/package.json index 3d6858ee7e..b341eb34d9 100644 --- a/examples/framework-vue/package.json +++ b/examples/framework-vue/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/vue": "^4.5.2", - "astro": "^4.16.3", - "vue": "^3.5.11" + "astro": "^4.16.5", + "vue": "^3.5.12" } } diff --git a/examples/hackernews/package.json b/examples/hackernews/package.json index b3b5549f7e..18a9ab6a32 100644 --- a/examples/hackernews/package.json +++ b/examples/hackernews/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/node": "^8.3.4", - "astro": "^4.16.3" + "astro": "^4.16.5" } } diff --git a/examples/integration/package.json b/examples/integration/package.json index 760e5df099..0438e26b81 100644 --- a/examples/integration/package.json +++ b/examples/integration/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.16.3" + "astro": "^4.16.5" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/minimal/package.json b/examples/minimal/package.json index f2b36332d3..edaad3564d 100644 --- a/examples/minimal/package.json +++ b/examples/minimal/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.16.3" + "astro": "^4.16.5" } } diff --git a/examples/portfolio/package.json b/examples/portfolio/package.json index a0b9eee55e..23dff6f519 100644 --- a/examples/portfolio/package.json +++ b/examples/portfolio/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.16.3" + "astro": "^4.16.5" } } diff --git a/examples/ssr/package.json b/examples/ssr/package.json index 2f2c1698f7..95ae9ee64b 100644 --- a/examples/ssr/package.json +++ b/examples/ssr/package.json @@ -14,7 +14,7 @@ "dependencies": { "@astrojs/node": "^8.3.4", "@astrojs/svelte": "^5.7.2", - "astro": "^4.16.3", + "astro": "^4.16.5", "svelte": "^4.2.19" } } diff --git a/examples/starlog/package.json b/examples/starlog/package.json index 51b908d801..8b729b3eae 100644 --- a/examples/starlog/package.json +++ b/examples/starlog/package.json @@ -10,8 +10,8 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.16.3", - "sass": "^1.79.4", + "astro": "^4.16.5", + "sass": "^1.79.5", "sharp": "^0.33.3" } } diff --git a/examples/toolbar-app/package.json b/examples/toolbar-app/package.json index 68bc16f246..e6c015250e 100644 --- a/examples/toolbar-app/package.json +++ b/examples/toolbar-app/package.json @@ -15,6 +15,6 @@ "./app": "./dist/app.js" }, "devDependencies": { - "astro": "^4.16.3" + "astro": "^4.16.5" } } diff --git a/examples/with-markdoc/package.json b/examples/with-markdoc/package.json index b48f790764..6a76dc5657 100644 --- a/examples/with-markdoc/package.json +++ b/examples/with-markdoc/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/markdoc": "^0.11.5", - "astro": "^4.16.3" + "astro": "^4.16.5" } } diff --git a/examples/with-mdx/package.json b/examples/with-mdx/package.json index fb3a90eadc..da711b495b 100644 --- a/examples/with-mdx/package.json +++ b/examples/with-mdx/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/mdx": "^3.1.8", "@astrojs/preact": "^3.5.3", - "astro": "^4.16.3", - "preact": "^10.24.2" + "astro": "^4.16.5", + "preact": "^10.24.3" } } diff --git a/examples/with-nanostores/package.json b/examples/with-nanostores/package.json index fb700b3911..21864a386f 100644 --- a/examples/with-nanostores/package.json +++ b/examples/with-nanostores/package.json @@ -13,8 +13,8 @@ "dependencies": { "@astrojs/preact": "^3.5.3", "@nanostores/preact": "^0.5.2", - "astro": "^4.16.3", + "astro": "^4.16.5", "nanostores": "^0.11.3", - "preact": "^10.24.2" + "preact": "^10.24.3" } } diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index 0b43ff3689..04ab56e7a1 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -14,7 +14,7 @@ "@astrojs/mdx": "^3.1.8", "@astrojs/tailwind": "^5.1.2", "@types/canvas-confetti": "^1.6.4", - "astro": "^4.16.3", + "astro": "^4.16.5", "autoprefixer": "^10.4.20", "canvas-confetti": "^1.9.3", "postcss": "^8.4.47", diff --git a/examples/with-vitest/package.json b/examples/with-vitest/package.json index a0cf5747aa..38d5e4b73c 100644 --- a/examples/with-vitest/package.json +++ b/examples/with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest" }, "dependencies": { - "astro": "^4.16.3", - "vitest": "^2.1.2" + "astro": "^4.16.5", + "vitest": "^2.1.3" } } diff --git a/package.json b/package.json index a71f86973e..683384edf3 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "engines": { "node": "^18.17.1 || ^20.3.0 || >=21.0.0" }, - "packageManager": "pnpm@9.6.0", + "packageManager": "pnpm@9.12.1", "dependencies": { "astro-benchmark": "workspace:*" }, @@ -67,8 +67,8 @@ "prettier": "^3.3.3", "prettier-plugin-astro": "^0.14.1", "turbo": "^2.1.3", - "typescript": "~5.6.2", - "typescript-eslint": "^8.8.0" + "typescript": "~5.6.3", + "typescript-eslint": "^8.9.0" }, "pnpm": { "peerDependencyRules": { @@ -87,6 +87,9 @@ "allowAny": [ "astro" ] + }, + "patchedDependencies": { + "fs-fixture@2.4.0": "patches/fs-fixture@2.4.0.patch" } } } diff --git a/packages/astro-rss/CHANGELOG.md b/packages/astro-rss/CHANGELOG.md index be7c24e33f..6204e723c9 100644 --- a/packages/astro-rss/CHANGELOG.md +++ b/packages/astro-rss/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/rss +## 4.0.9 + +### Patch Changes + +- [#12157](https://github.com/withastro/astro/pull/12157) [`925cff3`](https://github.com/withastro/astro/commit/925cff31bc040874e73decd6a6b3a5ba84c60258) Thanks [@bholmesdev](https://github.com/bholmesdev)! - Improves README configuration reference. + ## 4.0.8 ### Patch Changes diff --git a/packages/astro-rss/README.md b/packages/astro-rss/README.md index d24c5dabc0..ac9d81c478 100644 --- a/packages/astro-rss/README.md +++ b/packages/astro-rss/README.md @@ -2,80 +2,13 @@ This package brings fast RSS feed generation to blogs and other content sites built with [Astro](https://astro.build/). For more information about RSS feeds in general, see [aboutfeeds.com](https://aboutfeeds.com/). -## Installation +## Installation and use -Install the `@astrojs/rss` package into any Astro project using your preferred package manager: - -```bash -# npm -npm i @astrojs/rss -# yarn -yarn add @astrojs/rss -# pnpm -pnpm i @astrojs/rss -``` - -## Example usage - -The `@astrojs/rss` package provides helpers for generating RSS feeds within [Astro endpoints][astro-endpoints]. This unlocks both static builds _and_ on-demand generation when using an [SSR adapter](https://docs.astro.build/en/guides/server-side-rendering/). - -For instance, say you need to generate an RSS feed for all posts under `src/content/blog/` using content collections. - -Start by [adding a `site` to your project's `astro.config` for link generation](https://docs.astro.build/en/reference/configuration-reference/#site). Then, create an `rss.xml.js` file under your project's `src/pages/` directory, and [use `getCollection()`](https://docs.astro.build/en/guides/content-collections/#getcollection) to generate a feed from all documents in the `blog` collection: - -```js -// src/pages/rss.xml.js -import rss from '@astrojs/rss'; -import { getCollection } from 'astro:content'; - -export async function GET(context) { - const posts = await getCollection('blog'); - return rss({ - title: 'Buzz’s Blog', - description: 'A humble Astronaut’s guide to the stars', - // Pull in your project "site" from the endpoint context - // https://docs.astro.build/en/reference/api-reference/#contextsite - site: context.site, - items: posts.map((post) => ({ - // Assumes all RSS feed item properties are in post frontmatter - ...post.data, - // Generate a `url` from each post `slug` - // This assumes all blog posts are rendered as `/blog/[slug]` routes - // https://docs.astro.build/en/guides/content-collections/#generating-pages-from-content-collections - link: `/blog/${post.slug}/`, - })), - }); -} -``` - -Read **[Astro's RSS docs][astro-rss]** for more on using content collections, and instructions for globbing entries in `/src/pages/`. +See the [`@astrojs/rss` guide in the Astro docs][docs] for installation and usage examples. ## `rss()` configuration options -The `rss` default export offers a number of configuration options. Here's a quick reference: - -```js -export function GET(context) { - return rss({ - // `` field in output xml - title: 'Buzz’s Blog', - // `<description>` field in output xml - description: 'A humble Astronaut’s guide to the stars', - // provide a base URL for RSS <item> links - site: context.site, - // list of `<item>`s in output xml - items: [], - // (optional) absolute path to XSL stylesheet in your project - stylesheet: '/rss-styles.xsl', - // (optional) inject custom xml - customData: '<language>en-us</language>', - // (optional) add arbitrary metadata to opening <rss> tag - xmlns: { h: 'http://www.w3.org/TR/html4/' }, - // (optional) add trailing slashes to URLs (default: true) - trailingSlash: false, - }); -} -``` +The `rss()` utility function offers a number of configuration options to generate your feed. ### title @@ -109,81 +42,9 @@ export const GET = (context) => Type: `RSSFeedItem[] (required)` -A list of formatted RSS feed items. See [Astro's RSS items documentation](https://docs.astro.build/en/guides/rss/#generating-items) for usage examples to choose the best option for you. +A list of formatted RSS feed items. -When providing a formatted RSS item list, see the [`RSSFeedItem` type reference](#rssfeeditem). - -### stylesheet - -Type: `string (optional)` - -An absolute path to an XSL stylesheet in your project. If you don’t have an RSS stylesheet in mind, we recommend the [Pretty Feed v3 default stylesheet](https://github.com/genmon/aboutfeeds/blob/main/tools/pretty-feed-v3.xsl), which you can download from GitHub and save into your project's `public/` directory. - -### customData - -Type: `string (optional)` - -A string of valid XML to be injected between your feed's `<description>` and `<item>` tags. This is commonly used to set a language for your feed: - -```js -import rss from '@astrojs/rss'; - -export const GET = () => rss({ - ... - customData: '<language>en-us</language>', - }); -``` - -### xmlns - -Type: `Record<string, string> (optional)` - -An object mapping a set of `xmlns` suffixes to strings of metadata on the opening `<rss>` tag. - -For example, this object: - -```js -rss({ - ... - xmlns: { h: 'http://www.w3.org/TR/html4/' }, -}) -``` - -Will inject the following XML: - -```xml -<rss xmlns:h="http://www.w3.org/TR/html4/"... -``` - -### content - -The `content` key contains the full content of the post as HTML. This allows you to make your entire post content available to RSS feed readers. - -**Note:** Whenever you're using HTML content in XML, we suggest using a package like [`sanitize-html`](https://www.npmjs.com/package/sanitize-html) in order to make sure that your content is properly sanitized, escaped, and encoded. - -[See our RSS documentation](https://docs.astro.build/en/guides/rss/#including-full-post-content) for examples using content collections and glob imports. - -### `trailingSlash` - -Type: `boolean (optional)` -Default: `true` - -By default, the library will add trailing slashes to the emitted URLs. To prevent this behavior, add `trailingSlash: false` to the `rss` function. - -```js -import rss from '@astrojs/rss'; - -export const GET = () => - rss({ - trailingSlash: false, - }); -``` - -## `RSSFeedItem` - -An `RSSFeedItem` is a single item in the list of items in your feed. It represents a story, with `link`, `title`, and `pubDate` fields. There are further optional fields defined below. You can also check the definitions for the fields in the [RSS spec](https://validator.w3.org/feed/docs/rss2.html#ltpubdategtSubelementOfLtitemgt). - -An example feed item might look like: +An `RSSFeedItem` is a single item in the list of items in your feed. An example feed item might look like: ```js const item = { @@ -196,59 +57,59 @@ const item = { }; ``` -### `title` +#### `title` Type: `string (optional)` The title of the item in the feed. Optional only if a description is set. Otherwise, required. -### `link` +#### `link` Type: `string (optional)` The URL of the item on the web. -### `pubDate` +#### `pubDate` Type: `Date (optional)` Indicates when the item was published. -### `description` +#### `description` Type: `string (optional)` A synopsis of your item when you are publishing the full content of the item in the `content` field. The `description` may alternatively be the full content of the item in the feed if you are not using the `content` field (entity-coded HTML is permitted). Optional only if a title is set. Otherwise, required. -### `content` +#### `content` Type: `string (optional)` The full text content of the item suitable for presentation as HTML. If used, you should also provide a short article summary in the `description` field. -See the [recommendations from the RSS spec for how to use and differentiate between `description` and `content`](https://www.rssboard.org/rss-profile#namespace-elements-content-encoded). +To render Markdown content from a glob result or from a content collection, see the [content rendering guide](https://docs.astro.build/en/guides/rss/#including-full-post-content). -### `categories` +#### `categories` Type: `string[] (optional)` A list of any tags or categories to categorize your content. They will be output as multiple `<category>` elements. -### `author` +#### `author` Type: `string (optional)` The email address of the item author. This is useful for indicating the author of a post on multi-author blogs. -### `commentsUrl` +#### `commentsUrl` Type: `string (optional)` The URL of a web page that contains comments on the item. -### `source` +#### `source` -Type: `object (optional)` +Type: `{ title: string, url: string } (optional)` An object that defines the `title` and `url` of the original feed for items that have been republished from another source. Both are required properties of `source` for proper attribution. @@ -266,31 +127,15 @@ const item = { }; ``` -#### `source.title` +#### `enclosure` -Type: `string (required)` - -The name of the original feed in which the item was published. (Note that this is the feed's title, not the individual article title.) - -#### `source.url` - -Type: `string (required)` - -The URL of the original feed in which the item was published. - -### `enclosure` - -Type: `object (optional)` +Type: `{ url: string, type: string, length: number } (optional)` An object to specify properties for an included media source (e.g. a podcast) with three required values: `url`, `length`, and `type`. ```js const item = { - title: 'Alpha Centauri: so close you can touch it', - link: '/blog/alpha-centuari', - pubDate: new Date('2023-06-04'), - description: - 'Alpha Centauri is a triple star system, containing Proxima Centauri, the closest star to our sun at only 4.24 light-years away.', + /* ... */ enclosure: { url: '/media/alpha-centauri.aac', length: 124568, @@ -299,25 +144,77 @@ const item = { }; ``` -#### `enclosure.url` +- `enclosure.url` is the URL where the media can be found. If the media is hosted outside of your own domain you must provide a full URL. +- `enclosure.length` is the size of the file found at the `url` in bytes. +- `enclosure.type` is the [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types) for the media item found at the `url`. -Type: `string (required)` +### stylesheet -The URL where the media can be found. If the media is hosted outside of your own domain you must provide a full URL. +Type: `string (optional)` -#### `enclosure.length` +An absolute path to an XSL stylesheet in your project. If you don’t have an RSS stylesheet in mind, we recommend the [Pretty Feed v3 default stylesheet](https://github.com/genmon/aboutfeeds/blob/main/tools/pretty-feed-v3.xsl), which you can download from GitHub and save into your project's `public/` directory. -Type: `number (required)` +### customData -The size of the file found at the `url` in bytes. +Type: `string (optional)` -#### `enclosure.type` +A string of valid XML to be injected between your feed's `<description>` and `<item>` tags. -Type: `string (required)` +This can be used to pass additional data outside of the standard RSS spec, and is commonly used to set a language for your feed: -The [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types) for the media item found at the `url`. +```js +import rss from '@astrojs/rss'; -## `rssSchema` +export const GET = () => rss({ + ... + customData: '<language>en-us</language>', + }); +``` + +### xmlns + +Type: `Record<string, string> (optional)` + +An object mapping a set of `xmlns` suffixes to strings values on the opening `<rss>` tag. + +Suffixes expand the available XML tags in your RSS feed, so your content may be read by third-party sources like podcast services or blogging platforms. You'll likely combine `xmlns` with the [`customData`](#customData) attribute to insert custom tags for a given platform. + +This example applies the `itunes` suffix to an RSS feed of podcasts, and uses `customData` to define tags for the author and episode details: + +```js +rss({ + // ... + xmlns: { + itunes: 'http://www.itunes.com/dtds/podcast-1.0.dtd', + }, + customData: '<itunes:author>MF Doom</itunes:author>', + items: episodes.map((episode) => ({ + // ... + customData: + `<itunes:episodeType>${episode.frontmatter.type}</itunes:episodeType>` + + `<itunes:duration>${episode.frontmatter.duration}</itunes:duration>` + + `<itunes:explicit>${episode.frontmatter.explicit || false}</itunes:explicit>`, + })), +}); +``` + +### `trailingSlash` + +Type: `boolean (optional)` +Default: `true` + +By default, trailing slashes will be added to the URLs of your feed entries. To prevent this behavior, add `trailingSlash: false` to the `rss` function. + +```js +import rss from '@astrojs/rss'; + +export const GET = () => + rss({ + trailingSlash: false, + }); +``` + +## The `rssSchema` validator When using content collections, you can configure your collection schema to enforce expected [`RSSFeedItem`](#items) properties. Import and apply `rssSchema` to ensure that each collection entry produces a valid RSS feed item: @@ -343,7 +240,7 @@ const blog = defineCollection({ }); ``` -## `pagesGlobToRssItems()` +## The `pagesGlobToRssItems()` function To create an RSS feed from documents in `src/pages/`, use the `pagesGlobToRssItems()` helper. This accepts an `import.meta.glob` result ([see Vite documentation](https://vite.dev/guide/features.html#glob-import)) and outputs an array of valid [`RSSFeedItem`s](#items). @@ -363,7 +260,7 @@ export async function GET(context) { } ``` -## `getRssString()` +## The `getRssString()` function As `rss()` returns a `Response`, you can also use `getRssString()` to get the RSS string directly and use it in your own response: @@ -385,7 +282,35 @@ export async function GET(context) { } ``` -For more on building with Astro, [visit the Astro docs][astro-rss]. +## Support -[astro-rss]: https://docs.astro.build/en/guides/rss/#using-astrojsrss-recommended +- Get help in the [Astro Discord][discord]. Post questions in our `#support` forum, or visit our dedicated `#dev` channel to discuss current development and more! + +- Check our [Astro Integration Documentation][astro-integration] for more on integrations. + +- Submit bug reports and feature requests as [GitHub issues][issues]. + +## Contributing + +This package is maintained by Astro's Core team. You're welcome to submit an issue or PR! These links will help you get started: + +- [Contributor Manual][contributing] +- [Code of Conduct][coc] +- [Community Guide][community] + +## License + +MIT + +Copyright (c) 2023–present [Astro][astro] + +[docs]: https://docs.astro.build/en/guides/rss/ [astro-endpoints]: https://docs.astro.build/en/core-concepts/astro-pages/#non-html-pages +[astro]: https://astro.build/ +[docs]: https://docs.astro.build/en/guides/integrations-guide/alpinejs/ +[contributing]: https://github.com/withastro/astro/blob/main/CONTRIBUTING.md +[coc]: https://github.com/withastro/.github/blob/main/CODE_OF_CONDUCT.md +[community]: https://github.com/withastro/.github/blob/main/COMMUNITY_GUIDE.md +[discord]: https://astro.build/chat/ +[issues]: https://github.com/withastro/astro/issues +[astro-integration]: https://docs.astro.build/en/guides/integrations-guide/ diff --git a/packages/astro-rss/package.json b/packages/astro-rss/package.json index 509f31ee38..8de405fd7c 100644 --- a/packages/astro-rss/package.json +++ b/packages/astro-rss/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/rss", "description": "Add RSS feeds to your Astro projects", - "version": "4.0.8", + "version": "4.0.9", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index 8312da15df..4246713f16 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,23 @@ # astro +## 4.16.5 + +### Patch Changes + +- [#12232](https://github.com/withastro/astro/pull/12232) [`ff68ba5`](https://github.com/withastro/astro/commit/ff68ba5e1ca00f06d1afd5fbf89acea3092bb660) Thanks [@martrapp](https://github.com/martrapp)! - Fixes an issue with cssesc in dev mode when setting `vite.ssr.noExternal: true` + +## 4.16.4 + +### Patch Changes + +- [#12223](https://github.com/withastro/astro/pull/12223) [`79ffa5d`](https://github.com/withastro/astro/commit/79ffa5d9f75c16465134aa4ed4a3d1d59908ba8b) Thanks [@ArmandPhilippot](https://github.com/ArmandPhilippot)! - Fixes a false positive reported by the dev toolbar Audit app where a label was considered missing when associated with a button + + The `button` element can be [used with a label](https://www.w3.org/TR/2011/WD-html5-author-20110809/forms.html#category-label) (e.g. to create a switch) and should not be reported as an accessibility issue when used as a child of a `label`. + +- [#12199](https://github.com/withastro/astro/pull/12199) [`c351352`](https://github.com/withastro/astro/commit/c3513523608f319b43c050e391be08e68b801329) Thanks [@ematipico](https://github.com/ematipico)! - Fixes a regression in the computation of `Astro.currentLocale` + +- [#12222](https://github.com/withastro/astro/pull/12222) [`fb55695`](https://github.com/withastro/astro/commit/fb5569583b11ef585cd0a79e97e7e9dc653f6afa) Thanks [@ematipico](https://github.com/ematipico)! - Fixes an issue where the edge middleware couldn't correctly compute the client IP address when calling `ctx.clientAddress()` + ## 4.16.3 ### Patch Changes diff --git a/packages/astro/e2e/fixtures/actions-blog/package.json b/packages/astro/e2e/fixtures/actions-blog/package.json index acd29d3d1c..5925b85c2e 100644 --- a/packages/astro/e2e/fixtures/actions-blog/package.json +++ b/packages/astro/e2e/fixtures/actions-blog/package.json @@ -15,10 +15,10 @@ "@astrojs/node": "^8.3.4", "@astrojs/react": "workspace:*", "@types/react": "^18.3.11", - "@types/react-dom": "^18.3.0", + "@types/react-dom": "^18.3.1", "astro": "workspace:*", "react": "^18.3.1", "react-dom": "^18.3.1", - "typescript": "^5.6.2" + "typescript": "^5.6.3" } } diff --git a/packages/astro/e2e/fixtures/actions-react-19/package.json b/packages/astro/e2e/fixtures/actions-react-19/package.json index 36a8757998..1664761cc7 100644 --- a/packages/astro/e2e/fixtures/actions-react-19/package.json +++ b/packages/astro/e2e/fixtures/actions-react-19/package.json @@ -19,7 +19,7 @@ "astro": "workspace:*", "react": "19.0.0-rc-fb9a90fa48-20240614", "react-dom": "19.0.0-rc-fb9a90fa48-20240614", - "typescript": "^5.6.2" + "typescript": "^5.6.3" }, "overrides": { "@types/react": "npm:types-react", diff --git a/packages/astro/e2e/fixtures/astro-component/package.json b/packages/astro/e2e/fixtures/astro-component/package.json index 745d5e75d3..382af0b40c 100644 --- a/packages/astro/e2e/fixtures/astro-component/package.json +++ b/packages/astro/e2e/fixtures/astro-component/package.json @@ -6,6 +6,6 @@ "@astrojs/preact": "workspace:*", "@e2e/astro-linked-lib": "link:../_deps/astro-linked-lib", "astro": "workspace:*", - "preact": "^10.24.2" + "preact": "^10.24.3" } } diff --git a/packages/astro/e2e/fixtures/astro-envs/package.json b/packages/astro/e2e/fixtures/astro-envs/package.json index 6781b26186..b35082d519 100644 --- a/packages/astro/e2e/fixtures/astro-envs/package.json +++ b/packages/astro/e2e/fixtures/astro-envs/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "vue": "^3.5.11" + "vue": "^3.5.12" } } diff --git a/packages/astro/e2e/fixtures/client-only/package.json b/packages/astro/e2e/fixtures/client-only/package.json index c5b69c55fa..928833d25d 100644 --- a/packages/astro/e2e/fixtures/client-only/package.json +++ b/packages/astro/e2e/fixtures/client-only/package.json @@ -11,11 +11,11 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.24.2", + "preact": "^10.24.3", "react": "^18.3.1", "react-dom": "^18.3.1", - "solid-js": "^1.9.1", + "solid-js": "^1.9.2", "svelte": "^4.2.19", - "vue": "^3.5.11" + "vue": "^3.5.12" } } diff --git a/packages/astro/e2e/fixtures/dev-toolbar/package.json b/packages/astro/e2e/fixtures/dev-toolbar/package.json index b816a6b52b..b4430b4257 100644 --- a/packages/astro/e2e/fixtures/dev-toolbar/package.json +++ b/packages/astro/e2e/fixtures/dev-toolbar/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.24.2" + "preact": "^10.24.3" } } diff --git a/packages/astro/e2e/fixtures/error-cyclic/package.json b/packages/astro/e2e/fixtures/error-cyclic/package.json index 47e2fc8302..bc798e2f2a 100644 --- a/packages/astro/e2e/fixtures/error-cyclic/package.json +++ b/packages/astro/e2e/fixtures/error-cyclic/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.24.2" + "preact": "^10.24.3" } } diff --git a/packages/astro/e2e/fixtures/error-sass/package.json b/packages/astro/e2e/fixtures/error-sass/package.json index aef74c1350..c65c48e5fc 100644 --- a/packages/astro/e2e/fixtures/error-sass/package.json +++ b/packages/astro/e2e/fixtures/error-sass/package.json @@ -4,6 +4,6 @@ "private": true, "dependencies": { "astro": "workspace:*", - "sass": "^1.79.4" + "sass": "^1.79.5" } } diff --git a/packages/astro/e2e/fixtures/errors/package.json b/packages/astro/e2e/fixtures/errors/package.json index 9e1d383205..5a4ccd2478 100644 --- a/packages/astro/e2e/fixtures/errors/package.json +++ b/packages/astro/e2e/fixtures/errors/package.json @@ -9,12 +9,12 @@ "@astrojs/svelte": "workspace:*", "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "preact": "^10.24.2", + "preact": "^10.24.3", "react": "^18.3.1", "react-dom": "^18.3.1", - "sass": "^1.79.4", - "solid-js": "^1.9.1", + "sass": "^1.79.5", + "solid-js": "^1.9.2", "svelte": "^4.2.19", - "vue": "^3.5.11" + "vue": "^3.5.12" } } diff --git a/packages/astro/e2e/fixtures/hmr/package.json b/packages/astro/e2e/fixtures/hmr/package.json index e8760c60da..8f40a00f25 100644 --- a/packages/astro/e2e/fixtures/hmr/package.json +++ b/packages/astro/e2e/fixtures/hmr/package.json @@ -4,6 +4,6 @@ "private": true, "devDependencies": { "astro": "workspace:*", - "sass": "^1.79.4" + "sass": "^1.79.5" } } diff --git a/packages/astro/e2e/fixtures/hydration-race/package.json b/packages/astro/e2e/fixtures/hydration-race/package.json index 90f7aa73a3..c91d50a706 100644 --- a/packages/astro/e2e/fixtures/hydration-race/package.json +++ b/packages/astro/e2e/fixtures/hydration-race/package.json @@ -9,6 +9,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.24.2" + "preact": "^10.24.3" } } diff --git a/packages/astro/e2e/fixtures/lit-component/package.json b/packages/astro/e2e/fixtures/lit-component/package.json index 0db0d41118..9b634ad10e 100644 --- a/packages/astro/e2e/fixtures/lit-component/package.json +++ b/packages/astro/e2e/fixtures/lit-component/package.json @@ -6,6 +6,6 @@ "@astrojs/lit": "workspace:*", "@webcomponents/template-shadowroot": "^0.2.1", "astro": "workspace:*", - "lit": "^3.2.0" + "lit": "^3.2.1" } } diff --git a/packages/astro/e2e/fixtures/multiple-frameworks/package.json b/packages/astro/e2e/fixtures/multiple-frameworks/package.json index 875a7211cf..fa11511d20 100644 --- a/packages/astro/e2e/fixtures/multiple-frameworks/package.json +++ b/packages/astro/e2e/fixtures/multiple-frameworks/package.json @@ -13,12 +13,12 @@ }, "dependencies": { "@webcomponents/template-shadowroot": "^0.2.1", - "lit": "^3.2.0", - "preact": "^10.24.2", + "lit": "^3.2.1", + "preact": "^10.24.3", "react": "^18.3.1", "react-dom": "^18.3.1", - "solid-js": "^1.9.1", + "solid-js": "^1.9.2", "svelte": "^4.2.19", - "vue": "^3.5.11" + "vue": "^3.5.12" } } diff --git a/packages/astro/e2e/fixtures/namespaced-component/package.json b/packages/astro/e2e/fixtures/namespaced-component/package.json index b38d4b25a0..348013a318 100644 --- a/packages/astro/e2e/fixtures/namespaced-component/package.json +++ b/packages/astro/e2e/fixtures/namespaced-component/package.json @@ -8,6 +8,6 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.24.2" + "preact": "^10.24.3" } } diff --git a/packages/astro/e2e/fixtures/nested-in-preact/package.json b/packages/astro/e2e/fixtures/nested-in-preact/package.json index e70a33ffe0..afcb316806 100644 --- a/packages/astro/e2e/fixtures/nested-in-preact/package.json +++ b/packages/astro/e2e/fixtures/nested-in-preact/package.json @@ -11,11 +11,11 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.24.2", + "preact": "^10.24.3", "react": "^18.3.1", "react-dom": "^18.3.1", - "solid-js": "^1.9.1", + "solid-js": "^1.9.2", "svelte": "^4.2.19", - "vue": "^3.5.11" + "vue": "^3.5.12" } } diff --git a/packages/astro/e2e/fixtures/nested-in-react/package.json b/packages/astro/e2e/fixtures/nested-in-react/package.json index 0a80918483..64c6f5991b 100644 --- a/packages/astro/e2e/fixtures/nested-in-react/package.json +++ b/packages/astro/e2e/fixtures/nested-in-react/package.json @@ -11,11 +11,11 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.24.2", + "preact": "^10.24.3", "react": "^18.3.1", "react-dom": "^18.3.1", - "solid-js": "^1.9.1", + "solid-js": "^1.9.2", "svelte": "^4.2.19", - "vue": "^3.5.11" + "vue": "^3.5.12" } } diff --git a/packages/astro/e2e/fixtures/nested-in-solid/package.json b/packages/astro/e2e/fixtures/nested-in-solid/package.json index b83410efb7..8264efe145 100644 --- a/packages/astro/e2e/fixtures/nested-in-solid/package.json +++ b/packages/astro/e2e/fixtures/nested-in-solid/package.json @@ -11,11 +11,11 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.24.2", + "preact": "^10.24.3", "react": "^18.3.1", "react-dom": "^18.3.1", - "solid-js": "^1.9.1", + "solid-js": "^1.9.2", "svelte": "^4.2.19", - "vue": "^3.5.11" + "vue": "^3.5.12" } } diff --git a/packages/astro/e2e/fixtures/nested-in-svelte/package.json b/packages/astro/e2e/fixtures/nested-in-svelte/package.json index ac04c05f93..68c1643a44 100644 --- a/packages/astro/e2e/fixtures/nested-in-svelte/package.json +++ b/packages/astro/e2e/fixtures/nested-in-svelte/package.json @@ -11,11 +11,11 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.24.2", + "preact": "^10.24.3", "react": "^18.3.1", "react-dom": "^18.3.1", - "solid-js": "^1.9.1", + "solid-js": "^1.9.2", "svelte": "^4.2.19", - "vue": "^3.5.11" + "vue": "^3.5.12" } } diff --git a/packages/astro/e2e/fixtures/nested-in-vue/package.json b/packages/astro/e2e/fixtures/nested-in-vue/package.json index 4f39141690..bdd2ec4bee 100644 --- a/packages/astro/e2e/fixtures/nested-in-vue/package.json +++ b/packages/astro/e2e/fixtures/nested-in-vue/package.json @@ -11,11 +11,11 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.24.2", + "preact": "^10.24.3", "react": "^18.3.1", "react-dom": "^18.3.1", - "solid-js": "^1.9.1", + "solid-js": "^1.9.2", "svelte": "^4.2.19", - "vue": "^3.5.11" + "vue": "^3.5.12" } } diff --git a/packages/astro/e2e/fixtures/nested-recursive/package.json b/packages/astro/e2e/fixtures/nested-recursive/package.json index 80dadbc381..d7b5585dcf 100644 --- a/packages/astro/e2e/fixtures/nested-recursive/package.json +++ b/packages/astro/e2e/fixtures/nested-recursive/package.json @@ -11,12 +11,12 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.24.2", + "preact": "^10.24.3", "react": "^18.3.1", "react-dom": "^18.3.1", - "solid-js": "^1.9.1", + "solid-js": "^1.9.2", "svelte": "^4.2.19", - "vue": "^3.5.11" + "vue": "^3.5.12" }, "scripts": { "dev": "astro dev" diff --git a/packages/astro/e2e/fixtures/preact-compat-component/package.json b/packages/astro/e2e/fixtures/preact-compat-component/package.json index 4383b63ca0..aa1d3370c8 100644 --- a/packages/astro/e2e/fixtures/preact-compat-component/package.json +++ b/packages/astro/e2e/fixtures/preact-compat-component/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.24.2" + "preact": "^10.24.3" } } diff --git a/packages/astro/e2e/fixtures/preact-component/package.json b/packages/astro/e2e/fixtures/preact-component/package.json index cb28ce2563..b3870b482a 100644 --- a/packages/astro/e2e/fixtures/preact-component/package.json +++ b/packages/astro/e2e/fixtures/preact-component/package.json @@ -6,6 +6,6 @@ "@astrojs/mdx": "workspace:*", "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.24.2" + "preact": "^10.24.3" } } diff --git a/packages/astro/e2e/fixtures/preact-lazy-component/package.json b/packages/astro/e2e/fixtures/preact-lazy-component/package.json index 162fea06f2..a92516e9f5 100644 --- a/packages/astro/e2e/fixtures/preact-lazy-component/package.json +++ b/packages/astro/e2e/fixtures/preact-lazy-component/package.json @@ -6,6 +6,6 @@ "@astrojs/mdx": "workspace:*", "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.24.2" + "preact": "^10.24.3" } } diff --git a/packages/astro/e2e/fixtures/solid-circular/package.json b/packages/astro/e2e/fixtures/solid-circular/package.json index 5bf22da0dc..416406d7b1 100644 --- a/packages/astro/e2e/fixtures/solid-circular/package.json +++ b/packages/astro/e2e/fixtures/solid-circular/package.json @@ -7,6 +7,6 @@ "astro": "workspace:*" }, "devDependencies": { - "solid-js": "^1.9.1" + "solid-js": "^1.9.2" } } diff --git a/packages/astro/e2e/fixtures/solid-component/package.json b/packages/astro/e2e/fixtures/solid-component/package.json index 779f7a50a3..73d7cc9ea0 100644 --- a/packages/astro/e2e/fixtures/solid-component/package.json +++ b/packages/astro/e2e/fixtures/solid-component/package.json @@ -6,6 +6,6 @@ "@astrojs/mdx": "workspace:*", "@astrojs/solid-js": "workspace:*", "astro": "workspace:*", - "solid-js": "^1.9.1" + "solid-js": "^1.9.2" } } diff --git a/packages/astro/e2e/fixtures/solid-recurse/package.json b/packages/astro/e2e/fixtures/solid-recurse/package.json index d2b652054b..cc9ddcce39 100644 --- a/packages/astro/e2e/fixtures/solid-recurse/package.json +++ b/packages/astro/e2e/fixtures/solid-recurse/package.json @@ -7,6 +7,6 @@ "astro": "workspace:*" }, "devDependencies": { - "solid-js": "^1.9.1" + "solid-js": "^1.9.2" } } diff --git a/packages/astro/e2e/fixtures/view-transitions/package.json b/packages/astro/e2e/fixtures/view-transitions/package.json index fc63d819a2..f8856b76b8 100644 --- a/packages/astro/e2e/fixtures/view-transitions/package.json +++ b/packages/astro/e2e/fixtures/view-transitions/package.json @@ -12,7 +12,7 @@ "react": "^18.3.1", "react-dom": "^18.3.1", "svelte": "^4.2.19", - "vue": "^3.5.11", - "solid-js": "^1.9.1" + "vue": "^3.5.12", + "solid-js": "^1.9.2" } } diff --git a/packages/astro/e2e/fixtures/vue-component/package.json b/packages/astro/e2e/fixtures/vue-component/package.json index 8aa347c93f..4f6f31dd6e 100644 --- a/packages/astro/e2e/fixtures/vue-component/package.json +++ b/packages/astro/e2e/fixtures/vue-component/package.json @@ -6,6 +6,6 @@ "@astrojs/mdx": "workspace:*", "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "vue": "^3.5.11" + "vue": "^3.5.12" } } diff --git a/packages/astro/package.json b/packages/astro/package.json index c0d9965650..7f6e52a304 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "4.16.3", + "version": "4.16.5", "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.", "type": "module", "author": "withastro", @@ -112,23 +112,24 @@ "build": "pnpm run prebuild && astro-scripts build \"src/**/*.{ts,js}\" --copy-wasm && tsc", "build:ci": "pnpm run prebuild && astro-scripts build \"src/**/*.{ts,js}\" --copy-wasm", "dev": "astro-scripts dev --copy-wasm --prebuild \"src/runtime/server/astro-island.ts\" --prebuild \"src/runtime/client/{idle,load,media,only,visible}.ts\" \"src/**/*.{ts,js}\"", - "test": "pnpm run test:node && pnpm run test:types", - "test:match": "pnpm run test:node --match", + "test": "pnpm run test:unit && pnpm run test:integration && pnpm run test:types", + "test:match": "astro-scripts test \"test/**/*.test.js\" --match", "test:e2e": "pnpm test:e2e:chrome && pnpm test:e2e:firefox", "test:e2e:match": "playwright test -g", "test:e2e:chrome": "playwright test", "test:e2e:firefox": "playwright test --config playwright.firefox.config.js", "test:types": "tsc --project tsconfig.tests.json", - "test:node": "astro-scripts test \"test/**/*.test.js\"" + "test:unit": "astro-scripts test \"test/units/**/*.test.js\" --teardown ./test/units/teardown.js", + "test:integration": "astro-scripts test \"test/*.test.js\"" }, "dependencies": { "@astrojs/compiler": "^2.10.3", "@astrojs/internal-helpers": "workspace:*", "@astrojs/markdown-remark": "workspace:*", "@astrojs/telemetry": "workspace:*", - "@babel/core": "^7.25.7", + "@babel/core": "^7.25.8", "@babel/plugin-transform-react-jsx": "^7.25.7", - "@babel/types": "^7.25.7", + "@babel/types": "^7.25.8", "@oslojs/encoding": "^1.1.0", "@rollup/pluginutils": "^5.1.2", "@types/babel__core": "^7.20.5", @@ -159,7 +160,7 @@ "http-cache-semantics": "^4.1.1", "js-yaml": "^4.1.0", "kleur": "^4.1.5", - "magic-string": "^0.30.11", + "magic-string": "^0.30.12", "magicast": "^0.3.5", "micromatch": "^4.0.8", "mrmime": "^2.0.0", @@ -173,11 +174,11 @@ "semver": "^7.6.3", "shiki": "^1.22.0", "tinyexec": "^0.3.0", - "tsconfck": "^3.1.3", + "tsconfck": "^3.1.4", "unist-util-visit": "^5.0.0", "vfile": "^6.0.3", - "vite": "^5.4.8", - "vitefu": "^1.0.2", + "vite": "^5.4.9", + "vitefu": "^1.0.3", "which-pm": "^3.0.0", "xxhash-wasm": "^1.0.2", "yargs-parser": "^21.1.1", @@ -190,12 +191,12 @@ }, "devDependencies": { "@astrojs/check": "^0.9.4", - "@playwright/test": "^1.47.2", + "@playwright/test": "^1.48.0", "@types/aria-query": "^5.0.4", "@types/common-ancestor-path": "^1.0.2", "@types/cssesc": "^3.0.2", "@types/debug": "^4.1.12", - "@types/diff": "^5.2.2", + "@types/diff": "^5.2.3", "@types/dlv": "^1.1.4", "@types/hast": "^3.0.4", "@types/html-escaper": "^3.0.2", @@ -209,10 +210,10 @@ "cheerio": "1.0.0", "eol": "^0.10.0", "execa": "^8.0.1", - "expect-type": "^1.0.0", + "expect-type": "^1.1.0", + "fs-fixture": "^2.4.0", "mdast-util-mdx": "^3.0.0", "mdast-util-mdx-jsx": "^3.1.3", - "memfs": "^4.12.0", "node-mocks-http": "^1.16.1", "parse-srcset": "^1.0.2", "rehype-autolink-headings": "^7.1.0", @@ -220,8 +221,8 @@ "rehype-toc": "^3.0.2", "remark-code-titles": "^0.1.2", "rollup": "^4.24.0", - "sass": "^1.79.4", - "undici": "^6.19.8", + "sass": "^1.79.5", + "undici": "^6.20.1", "unified": "^11.0.5" }, "engines": { diff --git a/packages/astro/performance/fixtures/md/package.json b/packages/astro/performance/fixtures/md/package.json index 4490f36095..c93d01e6ed 100644 --- a/packages/astro/performance/fixtures/md/package.json +++ b/packages/astro/performance/fixtures/md/package.json @@ -17,7 +17,7 @@ "@astrojs/react": "workspace:*", "@performance/utils": "workspace:*", "@types/react": "^18.3.11", - "@types/react-dom": "^18.3.0", + "@types/react-dom": "^18.3.1", "astro": "workspace:*", "react": "^18.3.1", "react-dom": "^18.3.1" diff --git a/packages/astro/performance/fixtures/mdoc/package.json b/packages/astro/performance/fixtures/mdoc/package.json index 39d5988242..c6476d731a 100644 --- a/packages/astro/performance/fixtures/mdoc/package.json +++ b/packages/astro/performance/fixtures/mdoc/package.json @@ -18,7 +18,7 @@ "@astrojs/react": "workspace:*", "@performance/utils": "workspace:*", "@types/react": "^18.3.11", - "@types/react-dom": "^18.3.0", + "@types/react-dom": "^18.3.1", "astro": "workspace:*", "react": "^18.3.1", "react-dom": "^18.3.1" diff --git a/packages/astro/performance/fixtures/mdx/package.json b/packages/astro/performance/fixtures/mdx/package.json index c74ee62299..cf36622457 100644 --- a/packages/astro/performance/fixtures/mdx/package.json +++ b/packages/astro/performance/fixtures/mdx/package.json @@ -18,7 +18,7 @@ "@astrojs/react": "workspace:*", "@performance/utils": "workspace:*", "@types/react": "^18.3.11", - "@types/react-dom": "^18.3.0", + "@types/react-dom": "^18.3.1", "astro": "workspace:*", "react": "^18.3.1", "react-dom": "^18.3.1" diff --git a/packages/astro/src/core/create-vite.ts b/packages/astro/src/core/create-vite.ts index f3174b5d32..87574eda2d 100644 --- a/packages/astro/src/core/create-vite.ts +++ b/packages/astro/src/core/create-vite.ts @@ -71,6 +71,8 @@ const ONLY_DEV_EXTERNAL = [ 'prismjs/components/index.js', // Imported by `astro/assets` -> `packages/astro/src/core/logger/core.ts` 'string-width', + // Imported by `astro:transitions` -> packages/astro/src/runtime/server/transition.ts + 'cssesc', ]; /** Return a base vite config as a common starting point for all Vite commands. */ diff --git a/packages/astro/src/vite-plugin-astro-server/plugin.ts b/packages/astro/src/vite-plugin-astro-server/plugin.ts index 3b75a3843e..55f12216dc 100644 --- a/packages/astro/src/vite-plugin-astro-server/plugin.ts +++ b/packages/astro/src/vite-plugin-astro-server/plugin.ts @@ -77,6 +77,9 @@ export default function createVitePluginAstroServer({ } process.on('unhandledRejection', handleUnhandledRejection); + viteServer.httpServer?.on('close', () => { + process.off('unhandledRejection', handleUnhandledRejection); + }); return () => { // Push this middleware to the front of the stack so that it can intercept responses. diff --git a/packages/astro/test/fixtures/0-css/package.json b/packages/astro/test/fixtures/0-css/package.json index a3a2751f8c..c460f11db1 100644 --- a/packages/astro/test/fixtures/0-css/package.json +++ b/packages/astro/test/fixtures/0-css/package.json @@ -10,6 +10,6 @@ "react": "^18.3.1", "react-dom": "^18.3.1", "svelte": "^4.2.19", - "vue": "^3.5.11" + "vue": "^3.5.12" } } diff --git a/packages/astro/test/fixtures/astro-basic/package.json b/packages/astro/test/fixtures/astro-basic/package.json index 570992714c..6f29652a57 100644 --- a/packages/astro/test/fixtures/astro-basic/package.json +++ b/packages/astro/test/fixtures/astro-basic/package.json @@ -6,6 +6,6 @@ "@astrojs/mdx": "workspace:*", "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.24.2" + "preact": "^10.24.3" } } diff --git a/packages/astro/test/fixtures/astro-children/package.json b/packages/astro/test/fixtures/astro-children/package.json index fab8742c80..14e6da06e2 100644 --- a/packages/astro/test/fixtures/astro-children/package.json +++ b/packages/astro/test/fixtures/astro-children/package.json @@ -7,8 +7,8 @@ "@astrojs/svelte": "workspace:*", "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "preact": "^10.24.2", + "preact": "^10.24.3", "svelte": "^4.2.19", - "vue": "^3.5.11" + "vue": "^3.5.12" } } diff --git a/packages/astro/test/fixtures/astro-envs/package.json b/packages/astro/test/fixtures/astro-envs/package.json index fa9cfa6e92..5a6ee80c8c 100644 --- a/packages/astro/test/fixtures/astro-envs/package.json +++ b/packages/astro/test/fixtures/astro-envs/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "vue": "^3.5.11" + "vue": "^3.5.12" } } diff --git a/packages/astro/test/fixtures/astro-expr/package.json b/packages/astro/test/fixtures/astro-expr/package.json index 035057918b..96656b9545 100644 --- a/packages/astro/test/fixtures/astro-expr/package.json +++ b/packages/astro/test/fixtures/astro-expr/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.24.2" + "preact": "^10.24.3" } } diff --git a/packages/astro/test/fixtures/astro-fallback/package.json b/packages/astro/test/fixtures/astro-fallback/package.json index 72f0c68f0b..84db68bc57 100644 --- a/packages/astro/test/fixtures/astro-fallback/package.json +++ b/packages/astro/test/fixtures/astro-fallback/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.24.2" + "preact": "^10.24.3" } } diff --git a/packages/astro/test/fixtures/astro-markdown-plugins/package.json b/packages/astro/test/fixtures/astro-markdown-plugins/package.json index bd48d532e2..f8ebb05a71 100644 --- a/packages/astro/test/fixtures/astro-markdown-plugins/package.json +++ b/packages/astro/test/fixtures/astro-markdown-plugins/package.json @@ -4,7 +4,7 @@ "private": true, "dependencies": { "astro": "workspace:*", - "hast-util-select": "^6.0.2", + "hast-util-select": "^6.0.3", "rehype-slug": "^6.0.0" } } diff --git a/packages/astro/test/fixtures/astro-slot-with-client/package.json b/packages/astro/test/fixtures/astro-slot-with-client/package.json index 6bbc0105a3..4169f78818 100644 --- a/packages/astro/test/fixtures/astro-slot-with-client/package.json +++ b/packages/astro/test/fixtures/astro-slot-with-client/package.json @@ -4,6 +4,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.24.2" + "preact": "^10.24.3" } } diff --git a/packages/astro/test/fixtures/astro-slots-nested/package.json b/packages/astro/test/fixtures/astro-slots-nested/package.json index 7a6d25adea..2d82ef5375 100644 --- a/packages/astro/test/fixtures/astro-slots-nested/package.json +++ b/packages/astro/test/fixtures/astro-slots-nested/package.json @@ -9,11 +9,11 @@ "@astrojs/svelte": "workspace:*", "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "preact": "^10.24.2", + "preact": "^10.24.3", "react": "^18.3.1", "react-dom": "^18.3.1", - "solid-js": "^1.9.1", + "solid-js": "^1.9.2", "svelte": "^4.2.19", - "vue": "^3.5.11" + "vue": "^3.5.12" } } diff --git a/packages/astro/test/fixtures/before-hydration/package.json b/packages/astro/test/fixtures/before-hydration/package.json index 00011b006d..7e3219bf5c 100644 --- a/packages/astro/test/fixtures/before-hydration/package.json +++ b/packages/astro/test/fixtures/before-hydration/package.json @@ -4,6 +4,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.24.2" + "preact": "^10.24.3" } } diff --git a/packages/astro/test/fixtures/build-assets/package.json b/packages/astro/test/fixtures/build-assets/package.json index f91e4073a2..9bc24fec7f 100644 --- a/packages/astro/test/fixtures/build-assets/package.json +++ b/packages/astro/test/fixtures/build-assets/package.json @@ -4,6 +4,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.24.2" + "preact": "^10.24.3" } } diff --git a/packages/astro/test/fixtures/component-library-shared/package.json b/packages/astro/test/fixtures/component-library-shared/package.json index 5bc0770332..ee8da2977a 100644 --- a/packages/astro/test/fixtures/component-library-shared/package.json +++ b/packages/astro/test/fixtures/component-library-shared/package.json @@ -18,7 +18,7 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.24.2", + "preact": "^10.24.3", "react": "^18.3.1" } } diff --git a/packages/astro/test/fixtures/component-library/package.json b/packages/astro/test/fixtures/component-library/package.json index 82496036cb..02f65ab8d2 100644 --- a/packages/astro/test/fixtures/component-library/package.json +++ b/packages/astro/test/fixtures/component-library/package.json @@ -8,7 +8,7 @@ "@astrojs/svelte": "workspace:*", "@test/component-library-shared": "workspace:*", "astro": "workspace:*", - "preact": "^10.24.2", + "preact": "^10.24.3", "react": "^18.3.1", "react-dom": "^18.3.1", "svelte": "^4.2.19" diff --git a/packages/astro/test/fixtures/container-custom-renderers/package.json b/packages/astro/test/fixtures/container-custom-renderers/package.json index 066497f86d..1699ea90f8 100644 --- a/packages/astro/test/fixtures/container-custom-renderers/package.json +++ b/packages/astro/test/fixtures/container-custom-renderers/package.json @@ -9,6 +9,6 @@ "astro": "workspace:*", "react": "^18.3.1", "react-dom": "^18.3.1", - "vue": "^3.5.11" + "vue": "^3.5.12" } } diff --git a/packages/astro/test/fixtures/content-layer-markdoc/package.json b/packages/astro/test/fixtures/content-layer-markdoc/package.json index 348577634d..07db171916 100644 --- a/packages/astro/test/fixtures/content-layer-markdoc/package.json +++ b/packages/astro/test/fixtures/content-layer-markdoc/package.json @@ -6,6 +6,6 @@ "@astrojs/markdoc": "workspace:*", "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.24.2" + "preact": "^10.24.3" } } \ No newline at end of file diff --git a/packages/astro/test/fixtures/content-mixed-errors/astro.config.mjs b/packages/astro/test/fixtures/content-mixed-errors/astro.config.mjs deleted file mode 100644 index 882e6515a6..0000000000 --- a/packages/astro/test/fixtures/content-mixed-errors/astro.config.mjs +++ /dev/null @@ -1,4 +0,0 @@ -import { defineConfig } from 'astro/config'; - -// https://astro.build/config -export default defineConfig({}); diff --git a/packages/astro/test/fixtures/content-mixed-errors/package.json b/packages/astro/test/fixtures/content-mixed-errors/package.json deleted file mode 100644 index d90bfabda5..0000000000 --- a/packages/astro/test/fixtures/content-mixed-errors/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "@test/content-mixed-errors", - "type": "module", - "version": "0.0.1", - "private": true, - "scripts": { - "dev": "astro dev", - "start": "astro dev", - "build": "astro build", - "preview": "astro preview", - "astro": "astro" - }, - "dependencies": { - "astro": "workspace:*" - } -} diff --git a/packages/astro/test/fixtures/content-mixed-errors/src/content/authors/placeholder.json b/packages/astro/test/fixtures/content-mixed-errors/src/content/authors/placeholder.json deleted file mode 100644 index 64ae1c04c5..0000000000 --- a/packages/astro/test/fixtures/content-mixed-errors/src/content/authors/placeholder.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name": "Placeholder" -} diff --git a/packages/astro/test/fixtures/content-mixed-errors/src/content/blog/placeholder.md b/packages/astro/test/fixtures/content-mixed-errors/src/content/blog/placeholder.md deleted file mode 100644 index f7f65691b4..0000000000 --- a/packages/astro/test/fixtures/content-mixed-errors/src/content/blog/placeholder.md +++ /dev/null @@ -1,3 +0,0 @@ ---- -title: Placeholder post ---- diff --git a/packages/astro/test/fixtures/content-mixed-errors/src/pages/authors.astro b/packages/astro/test/fixtures/content-mixed-errors/src/pages/authors.astro deleted file mode 100644 index 8352a3d27d..0000000000 --- a/packages/astro/test/fixtures/content-mixed-errors/src/pages/authors.astro +++ /dev/null @@ -1,10 +0,0 @@ ---- -import { getCollection } from 'astro:content'; -try { - await getCollection('authors') -} catch (e) { - return e -} ---- - -<h1>Worked</h1> diff --git a/packages/astro/test/fixtures/content-mixed-errors/src/pages/blog.astro b/packages/astro/test/fixtures/content-mixed-errors/src/pages/blog.astro deleted file mode 100644 index 0d5d2836ed..0000000000 --- a/packages/astro/test/fixtures/content-mixed-errors/src/pages/blog.astro +++ /dev/null @@ -1,7 +0,0 @@ ---- -import { getCollection } from 'astro:content'; - -await getCollection('blog') ---- - -<h1>Worked</h1> diff --git a/packages/astro/test/fixtures/entry-file-names/package.json b/packages/astro/test/fixtures/entry-file-names/package.json index e84379757e..e06b7b3970 100644 --- a/packages/astro/test/fixtures/entry-file-names/package.json +++ b/packages/astro/test/fixtures/entry-file-names/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/preact": "workspace:", "astro": "workspace:*", - "preact": "^10.24.2" + "preact": "^10.24.3" } } diff --git a/packages/astro/test/fixtures/fetch/package.json b/packages/astro/test/fixtures/fetch/package.json index 0239e4fa84..110f14dadc 100644 --- a/packages/astro/test/fixtures/fetch/package.json +++ b/packages/astro/test/fixtures/fetch/package.json @@ -7,8 +7,8 @@ "@astrojs/svelte": "workspace:*", "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "preact": "^10.24.2", + "preact": "^10.24.3", "svelte": "^4.2.19", - "vue": "^3.5.11" + "vue": "^3.5.12" } } diff --git a/packages/astro/test/fixtures/hydration-race/package.json b/packages/astro/test/fixtures/hydration-race/package.json index 2f1b3eeedd..b854e236c2 100644 --- a/packages/astro/test/fixtures/hydration-race/package.json +++ b/packages/astro/test/fixtures/hydration-race/package.json @@ -9,6 +9,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.24.2" + "preact": "^10.24.3" } } diff --git a/packages/astro/test/fixtures/jsx/package.json b/packages/astro/test/fixtures/jsx/package.json index 030ffa6262..75cb9b759e 100644 --- a/packages/astro/test/fixtures/jsx/package.json +++ b/packages/astro/test/fixtures/jsx/package.json @@ -12,11 +12,11 @@ "astro": "workspace:*" }, "dependencies": { - "preact": "^10.24.2", + "preact": "^10.24.3", "react": "^18.3.1", "react-dom": "^18.3.1", - "solid-js": "^1.9.1", + "solid-js": "^1.9.2", "svelte": "^4.2.19", - "vue": "^3.5.11" + "vue": "^3.5.12" } } diff --git a/packages/astro/test/fixtures/large-array/package.json b/packages/astro/test/fixtures/large-array/package.json index 26366b0b68..8208877568 100644 --- a/packages/astro/test/fixtures/large-array/package.json +++ b/packages/astro/test/fixtures/large-array/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/solid-js": "workspace:*", "astro": "workspace:*", - "solid-js": "^1.9.1" + "solid-js": "^1.9.2" } } diff --git a/packages/astro/test/fixtures/lit-element/package.json b/packages/astro/test/fixtures/lit-element/package.json index fdfb79ab76..92364f677a 100644 --- a/packages/astro/test/fixtures/lit-element/package.json +++ b/packages/astro/test/fixtures/lit-element/package.json @@ -6,6 +6,6 @@ "@astrojs/lit": "workspace:*", "@webcomponents/template-shadowroot": "^0.2.1", "astro": "workspace:*", - "lit": "^3.2.0" + "lit": "^3.2.1" } } diff --git a/packages/astro/test/fixtures/postcss/package.json b/packages/astro/test/fixtures/postcss/package.json index 82633c098b..78f9697ebf 100644 --- a/packages/astro/test/fixtures/postcss/package.json +++ b/packages/astro/test/fixtures/postcss/package.json @@ -9,11 +9,11 @@ "astro": "workspace:*", "autoprefixer": "^10.4.20", "postcss": "^8.4.47", - "solid-js": "^1.9.1", + "solid-js": "^1.9.2", "svelte": "^4.2.19", - "vue": "^3.5.11" + "vue": "^3.5.12" }, "devDependencies": { - "postcss-preset-env": "^10.0.6" + "postcss-preset-env": "^10.0.7" } } diff --git a/packages/astro/test/fixtures/preact-compat-component/package.json b/packages/astro/test/fixtures/preact-compat-component/package.json index 1f7a423e03..606c3fc155 100644 --- a/packages/astro/test/fixtures/preact-compat-component/package.json +++ b/packages/astro/test/fixtures/preact-compat-component/package.json @@ -6,6 +6,6 @@ "@astrojs/preact": "workspace:*", "@test/react-lib": "workspace:*", "astro": "workspace:*", - "preact": "^10.24.2" + "preact": "^10.24.3" } } diff --git a/packages/astro/test/fixtures/preact-component/package.json b/packages/astro/test/fixtures/preact-component/package.json index 7faca20221..b0f7fc81cf 100644 --- a/packages/astro/test/fixtures/preact-component/package.json +++ b/packages/astro/test/fixtures/preact-component/package.json @@ -6,6 +6,6 @@ "@astrojs/preact": "workspace:*", "@preact/signals": "1.3.0", "astro": "workspace:*", - "preact": "^10.24.2" + "preact": "^10.24.3" } } diff --git a/packages/astro/test/fixtures/react-and-solid/package.json b/packages/astro/test/fixtures/react-and-solid/package.json index 044faba698..f678b14b36 100644 --- a/packages/astro/test/fixtures/react-and-solid/package.json +++ b/packages/astro/test/fixtures/react-and-solid/package.json @@ -7,6 +7,6 @@ "astro": "workspace:*", "react": "^18.3.1", "react-dom": "^18.3.1", - "solid-js": "^1.9.1" + "solid-js": "^1.9.2" } } diff --git a/packages/astro/test/fixtures/reexport-astro-containing-client-component/package.json b/packages/astro/test/fixtures/reexport-astro-containing-client-component/package.json index e288b25f43..8081b703ce 100644 --- a/packages/astro/test/fixtures/reexport-astro-containing-client-component/package.json +++ b/packages/astro/test/fixtures/reexport-astro-containing-client-component/package.json @@ -4,6 +4,6 @@ "dependencies": { "@astrojs/preact": "workspace:", "astro": "workspace:", - "preact": "^10.24.2" + "preact": "^10.24.3" } } diff --git a/packages/astro/test/fixtures/slots-preact/package.json b/packages/astro/test/fixtures/slots-preact/package.json index 650d8b67f5..8bf2204cab 100644 --- a/packages/astro/test/fixtures/slots-preact/package.json +++ b/packages/astro/test/fixtures/slots-preact/package.json @@ -6,6 +6,6 @@ "@astrojs/mdx": "workspace:*", "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.24.2" + "preact": "^10.24.3" } } diff --git a/packages/astro/test/fixtures/slots-solid/package.json b/packages/astro/test/fixtures/slots-solid/package.json index e7ac4bd95e..871c4d9f45 100644 --- a/packages/astro/test/fixtures/slots-solid/package.json +++ b/packages/astro/test/fixtures/slots-solid/package.json @@ -6,6 +6,6 @@ "@astrojs/mdx": "workspace:*", "@astrojs/solid-js": "workspace:*", "astro": "workspace:*", - "solid-js": "^1.9.1" + "solid-js": "^1.9.2" } } diff --git a/packages/astro/test/fixtures/slots-vue/package.json b/packages/astro/test/fixtures/slots-vue/package.json index 6afdc965d9..4a68e0d2df 100644 --- a/packages/astro/test/fixtures/slots-vue/package.json +++ b/packages/astro/test/fixtures/slots-vue/package.json @@ -6,6 +6,6 @@ "@astrojs/mdx": "workspace:*", "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "vue": "^3.5.11" + "vue": "^3.5.12" } } diff --git a/packages/astro/test/fixtures/solid-component/deps/solid-jsx-component/package.json b/packages/astro/test/fixtures/solid-component/deps/solid-jsx-component/package.json index 0040fcf2e8..4d991d9481 100644 --- a/packages/astro/test/fixtures/solid-component/deps/solid-jsx-component/package.json +++ b/packages/astro/test/fixtures/solid-component/deps/solid-jsx-component/package.json @@ -10,6 +10,6 @@ } }, "dependencies": { - "solid-js": "^1.9.1" + "solid-js": "^1.9.2" } } diff --git a/packages/astro/test/fixtures/solid-component/package.json b/packages/astro/test/fixtures/solid-component/package.json index 7bb88a36d8..700d8b7c8b 100644 --- a/packages/astro/test/fixtures/solid-component/package.json +++ b/packages/astro/test/fixtures/solid-component/package.json @@ -4,9 +4,9 @@ "private": true, "dependencies": { "@astrojs/solid-js": "workspace:*", - "@solidjs/router": "^0.14.7", + "@solidjs/router": "^0.14.8", "@test/solid-jsx-component": "file:./deps/solid-jsx-component", "astro": "workspace:*", - "solid-js": "^1.9.1" + "solid-js": "^1.9.2" } } diff --git a/packages/astro/test/fixtures/ssr-env/package.json b/packages/astro/test/fixtures/ssr-env/package.json index a69cf64462..4c7beed027 100644 --- a/packages/astro/test/fixtures/ssr-env/package.json +++ b/packages/astro/test/fixtures/ssr-env/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/preact": "workspace:*", "astro": "workspace:*", - "preact": "^10.24.2" + "preact": "^10.24.3" } } diff --git a/packages/astro/test/fixtures/ssr-prerender-chunks/package.json b/packages/astro/test/fixtures/ssr-prerender-chunks/package.json index b9545f842d..ac3abf986c 100644 --- a/packages/astro/test/fixtures/ssr-prerender-chunks/package.json +++ b/packages/astro/test/fixtures/ssr-prerender-chunks/package.json @@ -6,7 +6,7 @@ "@astrojs/react": "workspace:*", "@test/ssr-prerender-chunks-test-adapter": "link:./deps/test-adapter", "@types/react": "^18.3.11", - "@types/react-dom": "^18.3.0", + "@types/react-dom": "^18.3.1", "astro": "workspace:*", "react": "^18.3.1", "react-dom": "^18.3.1" diff --git a/packages/astro/test/fixtures/ssr-scripts/package.json b/packages/astro/test/fixtures/ssr-scripts/package.json index 3fc6e9e631..feb8e5a04e 100644 --- a/packages/astro/test/fixtures/ssr-scripts/package.json +++ b/packages/astro/test/fixtures/ssr-scripts/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/preact": "workspace:", "astro": "workspace:*", - "preact": "^10.24.2" + "preact": "^10.24.3" } } diff --git a/packages/astro/test/fixtures/static-build-frameworks/package.json b/packages/astro/test/fixtures/static-build-frameworks/package.json index bcce91a405..79017a69b2 100644 --- a/packages/astro/test/fixtures/static-build-frameworks/package.json +++ b/packages/astro/test/fixtures/static-build-frameworks/package.json @@ -6,7 +6,7 @@ "@astrojs/preact": "workspace:*", "@astrojs/react": "workspace:*", "astro": "workspace:*", - "preact": "^10.24.2", + "preact": "^10.24.3", "react": "^18.3.1", "react-dom": "^18.3.1" } diff --git a/packages/astro/test/fixtures/static-build/package.json b/packages/astro/test/fixtures/static-build/package.json index 5ceba47844..8f8b9fd2c8 100644 --- a/packages/astro/test/fixtures/static-build/package.json +++ b/packages/astro/test/fixtures/static-build/package.json @@ -6,6 +6,6 @@ "@astrojs/preact": "workspace:*", "@test/static-build-pkg": "workspace:*", "astro": "workspace:*", - "preact": "^10.24.2" + "preact": "^10.24.3" } } diff --git a/packages/astro/test/fixtures/third-party-astro/package.json b/packages/astro/test/fixtures/third-party-astro/package.json index f0e513954d..fd9966d658 100644 --- a/packages/astro/test/fixtures/third-party-astro/package.json +++ b/packages/astro/test/fixtures/third-party-astro/package.json @@ -4,6 +4,6 @@ "private": true, "dependencies": { "astro": "workspace:*", - "astro-embed": "^0.7.2" + "astro-embed": "^0.7.4" } } diff --git a/packages/astro/test/fixtures/vue-component/package.json b/packages/astro/test/fixtures/vue-component/package.json index 3002c63ee7..3af44195ff 100644 --- a/packages/astro/test/fixtures/vue-component/package.json +++ b/packages/astro/test/fixtures/vue-component/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "vue": "^3.5.11" + "vue": "^3.5.12" } } diff --git a/packages/astro/test/fixtures/vue-jsx/package.json b/packages/astro/test/fixtures/vue-jsx/package.json index 685e336870..709f4d4666 100644 --- a/packages/astro/test/fixtures/vue-jsx/package.json +++ b/packages/astro/test/fixtures/vue-jsx/package.json @@ -5,6 +5,6 @@ "dependencies": { "@astrojs/vue": "workspace:*", "astro": "workspace:*", - "vue": "^3.5.11" + "vue": "^3.5.12" } } diff --git a/packages/astro/test/fixtures/vue-with-multi-renderer/package.json b/packages/astro/test/fixtures/vue-with-multi-renderer/package.json index 6ea658dc4b..d2e756c974 100644 --- a/packages/astro/test/fixtures/vue-with-multi-renderer/package.json +++ b/packages/astro/test/fixtures/vue-with-multi-renderer/package.json @@ -7,6 +7,6 @@ "@astrojs/vue": "workspace:*", "astro": "workspace:*", "svelte": "^4.2.19", - "vue": "^3.5.11" + "vue": "^3.5.12" } } diff --git a/packages/astro/test/units/_temp-fixtures/package.json b/packages/astro/test/units/_temp-fixtures/package.json new file mode 100644 index 0000000000..3ecea0bfe3 --- /dev/null +++ b/packages/astro/test/units/_temp-fixtures/package.json @@ -0,0 +1,8 @@ +{ + "name": "astro-temp-fixtures", + "description": "This directory contains nested directories of dynamically created unit test fixtures. The deps here can be used by them", + "dependencies": { + "@astrojs/mdx": "workspace:*", + "astro": "workspace:*" + } +} diff --git a/packages/astro/test/units/config/format.test.js b/packages/astro/test/units/config/format.test.js index 7b0c88d730..66938a03a5 100644 --- a/packages/astro/test/units/config/format.test.js +++ b/packages/astro/test/units/config/format.test.js @@ -1,25 +1,19 @@ import * as assert from 'node:assert/strict'; import { describe, it } from 'node:test'; -import { fileURLToPath } from 'node:url'; -import { createFs, runInContainer } from '../test-utils.js'; - -const root = new URL('../../fixtures/tailwindcss-ts/', import.meta.url); +import { createFixture, runInContainer } from '../test-utils.js'; describe('Astro config formats', () => { it('An mjs config can import TypeScript modules', async () => { - const fs = createFs( - { - '/src/pages/index.astro': ``, - '/src/stuff.ts': `export default 'works';`, - '/astro.config.mjs': ` + const fixture = await createFixture({ + '/src/pages/index.astro': ``, + '/src/stuff.ts': `export default 'works';`, + '/astro.config.mjs': `\ import stuff from './src/stuff.ts'; export default {} `, - }, - root, - ); + }); - await runInContainer({ fs, inlineConfig: { root: fileURLToPath(root) } }, () => { + await runInContainer({ inlineConfig: { root: fixture.path } }, () => { assert.equal( true, true, diff --git a/packages/astro/test/units/content-collections/frontmatter.test.js b/packages/astro/test/units/content-collections/frontmatter.test.js index 2a3cd31ec4..4f587a90fe 100644 --- a/packages/astro/test/units/content-collections/frontmatter.test.js +++ b/packages/astro/test/units/content-collections/frontmatter.test.js @@ -1,33 +1,16 @@ -import nodeFS from 'node:fs'; -import path from 'node:path'; import { describe, it } from 'node:test'; -import { fileURLToPath } from 'node:url'; import { attachContentServerListeners } from '../../../dist/content/index.js'; -import { createFs, runInContainer, triggerFSEvent } from '../test-utils.js'; - -const root = new URL('../../fixtures/alias/', import.meta.url); - -function getTypesDts() { - const typesdtsURL = new URL('../../../templates/content/types.d.ts', import.meta.url); - const relpath = path - .relative(fileURLToPath(root), fileURLToPath(typesdtsURL)) - .replace(/\\/g, '/'); - return { - [relpath]: nodeFS.readFileSync(typesdtsURL, 'utf-8'), - }; -} +import { createFixture, runInContainer } from '../test-utils.js'; describe('frontmatter', () => { it('errors in content/ does not crash server', async () => { - const fs = createFs( - { - ...getTypesDts(), - '/src/content/posts/blog.md': ` + const fixture = await createFixture({ + '/src/content/posts/blog.md': `\ --- title: One --- `, - '/src/content/config.ts': ` + '/src/content/config.ts': `\ import { defineCollection, z } from 'astro:content'; const posts = defineCollection({ @@ -38,7 +21,7 @@ describe('frontmatter', () => { posts }; `, - '/src/pages/index.astro': ` + '/src/pages/index.astro': `\ --- --- <html> @@ -48,14 +31,12 @@ describe('frontmatter', () => { </body> </html> `, - }, - root, - ); + }); - await runInContainer({ fs, inlineConfig: { root: fileURLToPath(root) } }, async (container) => { + await runInContainer({ inlineConfig: { root: fixture.path } }, async (container) => { await attachContentServerListeners(container); - fs.writeFileFromRootSync( + await fixture.writeFile( '/src/content/posts/blog.md', ` --- @@ -64,7 +45,6 @@ describe('frontmatter', () => { --- `, ); - triggerFSEvent(container, fs, '/src/content/posts/blog.md', 'change'); await new Promise((resolve) => setTimeout(resolve, 100)); // Note, if we got here, it didn't crash }); diff --git a/packages/astro/test/units/correct-path.js b/packages/astro/test/units/correct-path.js deleted file mode 100644 index 026baeaf69..0000000000 --- a/packages/astro/test/units/correct-path.js +++ /dev/null @@ -1,70 +0,0 @@ -/** - * correctPath.js <https://github.com/streamich/fs-monkey/blob/af36a890d8070b25b9eae7178824f653bad5621f/src/correctPath.js> - * Taken from: - * https://github.com/streamich/fs-monkeys - */ - -const isWin = process.platform === 'win32'; - -/*! - * removeTrailingSeparator <https://github.com/darsain/remove-trailing-separator> - * - * Inlined from: - * Copyright (c) darsain. - * Released under the ISC License. - */ -function removeTrailingSeparator(str) { - let i = str.length - 1; - if (i < 2) { - return str; - } - while (isSeparator(str, i)) { - i--; - } - return str.substr(0, i + 1); -} - -function isSeparator(str, i) { - let char = str[i]; - return i > 0 && (char === '/' || (isWin && char === '\\')); -} - -/*! - * normalize-path <https://github.com/jonschlinkert/normalize-path> - * - * Inlined from: - * Copyright (c) 2014-2017, Jon Schlinkert. - * Released under the MIT License. - */ -function normalizePath(str, stripTrailing) { - if (typeof str !== 'string') { - throw new TypeError('expected a string'); - } - str = str.replace(/[\\/]+/g, '/'); - if (stripTrailing !== false) { - str = removeTrailingSeparator(str); - } - return str; -} - -/*! - * unixify <https://github.com/jonschlinkert/unixify> - * - * Inlined from: - * Copyright (c) 2014, 2017, Jon Schlinkert. - * Released under the MIT License. - */ -export function unixify(filepath, stripTrailing = true) { - if (isWin) { - filepath = normalizePath(filepath, stripTrailing); - return filepath.replace(/^([a-zA-Z]+:|\.\/)/, ''); - } - return filepath; -} - -/* - * Corrects a windows path to unix format (including \\?\c:...) - */ -export function correctPath(filepath) { - return unixify(filepath.replace(/^\\\\\?\\.:\\/, '\\')); -} diff --git a/packages/astro/test/units/dev/base.test.js b/packages/astro/test/units/dev/base.test.js index e625df4789..f230ad563c 100644 --- a/packages/astro/test/units/dev/base.test.js +++ b/packages/astro/test/units/dev/base.test.js @@ -1,26 +1,19 @@ import * as assert from 'node:assert/strict'; import { describe, it } from 'node:test'; -import { fileURLToPath } from 'node:url'; -import { createFs, createRequestAndResponse, runInContainer } from '../test-utils.js'; - -const root = new URL('../../fixtures/alias/', import.meta.url); +import { createFixture, createRequestAndResponse, runInContainer } from '../test-utils.js'; describe('base configuration', () => { describe('with trailingSlash: "never"', () => { describe('index route', () => { it('Requests that include a trailing slash 404', async () => { - const fs = createFs( - { - '/src/pages/index.astro': `<h1>testing</h1>`, - }, - root, - ); + const fixture = await createFixture({ + '/src/pages/index.astro': `<h1>testing</h1>`, + }); await runInContainer( { - fs, inlineConfig: { - root: fileURLToPath(root), + root: fixture.path, base: '/docs', trailingSlash: 'never', }, @@ -38,18 +31,15 @@ describe('base configuration', () => { }); it('Requests that exclude a trailing slash 200', async () => { - const fs = createFs( - { - '/src/pages/index.astro': `<h1>testing</h1>`, - }, - root, - ); + const fixture = await createFixture({ + '/src/pages/index.astro': `<h1>testing</h1>`, + }); await runInContainer( { fs, inlineConfig: { - root: fileURLToPath(root), + root: fixture.path, base: '/docs', trailingSlash: 'never', }, @@ -69,18 +59,14 @@ describe('base configuration', () => { describe('sub route', () => { it('Requests that include a trailing slash 404', async () => { - const fs = createFs( - { - '/src/pages/sub/index.astro': `<h1>testing</h1>`, - }, - root, - ); + const fixture = await createFixture({ + '/src/pages/sub/index.astro': `<h1>testing</h1>`, + }); await runInContainer( { - fs, inlineConfig: { - root: fileURLToPath(root), + root: fixture.path, base: '/docs', trailingSlash: 'never', }, @@ -98,18 +84,14 @@ describe('base configuration', () => { }); it('Requests that exclude a trailing slash 200', async () => { - const fs = createFs( - { - '/src/pages/sub/index.astro': `<h1>testing</h1>`, - }, - root, - ); + const fixture = await createFixture({ + '/src/pages/sub/index.astro': `<h1>testing</h1>`, + }); await runInContainer( { - fs, inlineConfig: { - root: fileURLToPath(root), + root: fixture.path, base: '/docs', trailingSlash: 'never', }, diff --git a/packages/astro/test/units/dev/collections-mixed-content-errors.test.js b/packages/astro/test/units/dev/collections-mixed-content-errors.test.js index 3417650fc9..9da0c776f2 100644 --- a/packages/astro/test/units/dev/collections-mixed-content-errors.test.js +++ b/packages/astro/test/units/dev/collections-mixed-content-errors.test.js @@ -1,129 +1,146 @@ import * as assert from 'node:assert/strict'; import { describe, it } from 'node:test'; -import { fileURLToPath } from 'node:url'; import _sync from '../../../dist/core/sync/index.js'; -import { createFsWithFallback } from '../test-utils.js'; +import { createFixture } from '../test-utils.js'; -const root = new URL('../../fixtures/content-mixed-errors/', import.meta.url); - -async function sync({ fs }) { +async function sync(root) { try { - await _sync( - { - root: fileURLToPath(root), - logLevel: 'silent', - }, - { - fs, - }, - ); + await _sync({ + root, + logLevel: 'silent', + }); return 0; - } catch (_) { + } catch { return 1; } } +const baseFileTree = { + '/src/content/authors/placeholder.json': `{ "name": "Placeholder" }`, + '/src/content/blog/placeholder.md': `\ +--- +title: Placeholder post +--- +`, + '/src/pages/authors.astro': `\ +--- +import { getCollection } from 'astro:content'; +try { + await getCollection('authors') +} catch (e) { + return e +} +--- + +<h1>Worked</h1> +`, + '/src/pages/blog.astro': `\ +--- +import { getCollection } from 'astro:content'; + +await getCollection('blog') +--- + +<h1>Worked</h1>`, +}; + describe('Content Collections - mixed content errors', () => { it('raises "mixed content" error when content in data collection', async () => { - const fs = createFsWithFallback( - { - '/src/content/authors/ben.md': `--- + const fixture = await createFixture({ + ...baseFileTree, + '/src/content/authors/ben.md': `\ +--- name: Ben --- -# Ben`, - '/src/content/authors/tony.json': `{ "name": "Tony" }`, - '/src/content/config.ts': ` +# Ben +`, + '/src/content/authors/tony.json': `{ "name": "Tony" }`, + '/src/content/config.ts': `\ +import { z, defineCollection } from 'astro:content'; - import { z, defineCollection } from 'astro:content'; +const authors = defineCollection({ + type: 'data', + schema: z.object({ + name: z.string(), + }), +}); - const authors = defineCollection({ - type: 'data', - schema: z.object({ - name: z.string(), - }), - }); +export const collections = { authors }; +`, + }); - export const collections = { authors };`, - }, - root, - ); - - assert.equal(await sync({ fs }), 1); + assert.equal(await sync(fixture.path), 1); }); it('raises "mixed content" error when data in content collection', async () => { - const fs = createFsWithFallback( - { - '/src/content/blog/post.md': `--- + const fixture = await createFixture({ + ...baseFileTree, + '/src/content/blog/post.md': `\ +--- title: Post --- -# Post`, - '/src/content/blog/post.yaml': `title: YAML Post`, - '/src/content/config.ts': ` +# Post +`, + '/src/content/blog/post.yaml': `title: YAML Post`, + '/src/content/config.ts': `\ +import { z, defineCollection } from 'astro:content'; - import { z, defineCollection } from 'astro:content'; +const blog = defineCollection({ + type: 'content', + schema: z.object({ + title: z.string(), + }), +}); - const blog = defineCollection({ - type: 'content', - schema: z.object({ - title: z.string(), - }), - }); +export const collections = { blog }; +`, + }); - export const collections = { blog };`, - }, - root, - ); - - assert.equal(await sync({ fs }), 1); + assert.equal(await sync(fixture.path), 1); }); it('raises error when data collection configured as content collection', async () => { - const fs = createFsWithFallback( - { - '/src/content/banners/welcome.json': `{ "src": "/example", "alt": "Welcome" }`, - '/src/content/config.ts': ` + const fixture = await createFixture({ + ...baseFileTree, + '/src/content/banners/welcome.json': `{ "src": "/example", "alt": "Welcome" }`, + '/src/content/config.ts': `\ +import { z, defineCollection } from 'astro:content'; - import { z, defineCollection } from 'astro:content'; +const banners = defineCollection({ + schema: z.object({ + src: z.string(), + alt: z.string(), + }), +}); - const banners = defineCollection({ - schema: z.object({ - src: z.string(), - alt: z.string(), - }), - }); +export const collections = { banners }; +`, + }); - export const collections = { banners };`, - }, - root, - ); - - assert.equal(await sync({ fs }), 1); + assert.equal(await sync(fixture.path), 1); }); it('does not raise error for empty collection with config', async () => { - const fs = createFsWithFallback( - { - // Add placeholder to ensure directory exists - '/src/content/i18n/_placeholder.txt': 'Need content here', - '/src/content/config.ts': ` - import { z, defineCollection } from 'astro:content'; + const fixture = await createFixture({ + ...baseFileTree, + // Add placeholder to ensure directory exists + '/src/content/i18n/_placeholder.txt': 'Need content here', + '/src/content/config.ts': `\ +import { z, defineCollection } from 'astro:content'; - const i18n = defineCollection({ - type: 'data', - schema: z.object({ - greeting: z.string(), - }), - }); +const i18n = defineCollection({ + type: 'data', + schema: z.object({ + greeting: z.string(), + }), +}); - export const collections = { i18n };`, - }, - root, - ); +export const collections = { i18n }; +`, + }); - const res = await sync({ fs }); - assert.equal(res, 0); + assert.equal(await sync(fixture.path), 0); }); }); diff --git a/packages/astro/test/units/dev/collections-renderentry.test.js b/packages/astro/test/units/dev/collections-renderentry.test.js index 082cd6b2f7..6bd906c9c8 100644 --- a/packages/astro/test/units/dev/collections-renderentry.test.js +++ b/packages/astro/test/units/dev/collections-renderentry.test.js @@ -1,12 +1,39 @@ import * as assert from 'node:assert/strict'; import { describe, it } from 'node:test'; -import { fileURLToPath } from 'node:url'; import * as cheerio from 'cheerio'; import { attachContentServerListeners } from '../../../dist/content/server-listeners.js'; -import { createFsWithFallback, createRequestAndResponse, runInContainer } from '../test-utils.js'; +import { createFixture, createRequestAndResponse, runInContainer } from '../test-utils.js'; -const root = new URL('../../fixtures/content/', import.meta.url); +const baseFileTree = { + 'astro.config.mjs': `\ +import mdx from '@astrojs/mdx'; +export default { + integrations: [mdx()] +}; +`, + '/src/content/blog/promo/_launch-week-styles.css': `\ +body { + font-family: 'Comic Sans MS', sans-serif; +} +`, + '/src/content/blog/promo/launch-week.mdx': `\ +--- +title: 'Launch week!' +description: 'Join us for the exciting launch of SPACE BLOG' +publishedDate: 'Sat May 21 2022 00:00:00 GMT-0400 (Eastern Daylight Time)' +tags: ['announcement'] +--- + +import './_launch-week-styles.css'; + +Join us for the space blog launch! + +- THIS THURSDAY +- Houston, TX +- Dress code: **interstellar casual** ✨ +`, +}; /** @type {typeof runInContainer} */ async function runInContainerWithContentListeners(params, callback) { @@ -18,9 +45,9 @@ async function runInContainerWithContentListeners(params, callback) { describe('Content Collections - render()', () => { it('can be called in a page component', async () => { - const fs = createFsWithFallback( - { - '/src/content/config.ts': ` + const fixture = await createFixture({ + ...baseFileTree, + '/src/content/config.ts': ` import { z, defineCollection } from 'astro:content'; const blog = defineCollection({ @@ -32,7 +59,7 @@ describe('Content Collections - render()', () => { export const collections = { blog }; `, - '/src/pages/index.astro': ` + '/src/pages/index.astro': ` --- import { getCollection } from 'astro:content'; const blog = await getCollection('blog'); @@ -47,15 +74,12 @@ describe('Content Collections - render()', () => { </body> </html> `, - }, - root, - ); + }); await runInContainerWithContentListeners( { - fs, inlineConfig: { - root: fileURLToPath(root), + root: fixture.path, vite: { server: { middlewareMode: true } }, }, }, @@ -79,9 +103,9 @@ describe('Content Collections - render()', () => { }); it('can be used in a layout component', async () => { - const fs = createFsWithFallback( - { - '/src/components/Layout.astro': ` + const fixture = await createFixture({ + ...baseFileTree, + '/src/components/Layout.astro': ` --- import { getCollection } from 'astro:content'; const blog = await getCollection('blog'); @@ -99,7 +123,7 @@ describe('Content Collections - render()', () => { </html> `, - '/src/pages/index.astro': ` + '/src/pages/index.astro': ` --- import Layout from '../components/Layout.astro'; --- @@ -107,15 +131,12 @@ describe('Content Collections - render()', () => { <h1 slot="title">Index page</h2> </Layout> `, - }, - root, - ); + }); await runInContainerWithContentListeners( { - fs, inlineConfig: { - root: fileURLToPath(root), + root: fixture.path, vite: { server: { middlewareMode: true } }, }, }, @@ -139,9 +160,9 @@ describe('Content Collections - render()', () => { }); it('can be used in a slot', async () => { - const fs = createFsWithFallback( - { - '/src/content/config.ts': ` + const fixture = await createFixture({ + ...baseFileTree, + '/src/content/config.ts': ` import { z, defineCollection } from 'astro:content'; const blog = defineCollection({ @@ -153,7 +174,7 @@ describe('Content Collections - render()', () => { export const collections = { blog }; `, - '/src/components/Layout.astro': ` + '/src/components/Layout.astro': ` <html> <head></head> <body> @@ -164,7 +185,7 @@ describe('Content Collections - render()', () => { </body> </html> `, - '/src/pages/index.astro': ` + '/src/pages/index.astro': ` --- import Layout from '../components/Layout.astro'; import { getCollection } from 'astro:content'; @@ -177,15 +198,12 @@ describe('Content Collections - render()', () => { <Content slot="main" /> </Layout> `, - }, - root, - ); + }); await runInContainerWithContentListeners( { - fs, inlineConfig: { - root: fileURLToPath(root), + root: fixture.path, vite: { server: { middlewareMode: true } }, }, }, @@ -209,9 +227,9 @@ describe('Content Collections - render()', () => { }); it('can be called from any js/ts file', async () => { - const fs = createFsWithFallback( - { - '/src/content/config.ts': ` + const fixture = await createFixture({ + ...baseFileTree, + '/src/content/config.ts': ` import { z, defineCollection } from 'astro:content'; const blog = defineCollection({ @@ -223,7 +241,7 @@ describe('Content Collections - render()', () => { export const collections = { blog }; `, - '/src/launch-week.ts': ` + '/src/launch-week.ts': ` import { getCollection } from 'astro:content'; export let Content; @@ -234,7 +252,7 @@ describe('Content Collections - render()', () => { Content = mod.Content; `, - '/src/pages/index.astro': ` + '/src/pages/index.astro': ` --- import { Content } from '../launch-week.ts'; --- @@ -246,15 +264,12 @@ describe('Content Collections - render()', () => { </body> </html> `, - }, - root, - ); + }); await runInContainerWithContentListeners( { - fs, inlineConfig: { - root: fileURLToPath(root), + root: fixture.path, vite: { server: { middlewareMode: true } }, }, }, diff --git a/packages/astro/test/units/dev/dev.test.js b/packages/astro/test/units/dev/dev.test.js index c82232768a..74f1d1e92e 100644 --- a/packages/astro/test/units/dev/dev.test.js +++ b/packages/astro/test/units/dev/dev.test.js @@ -1,21 +1,12 @@ import * as assert from 'node:assert/strict'; import { describe, it } from 'node:test'; -import { fileURLToPath } from 'node:url'; import * as cheerio from 'cheerio'; -import { - createFs, - createRequestAndResponse, - runInContainer, - triggerFSEvent, -} from '../test-utils.js'; - -const root = new URL('../../fixtures/alias/', import.meta.url); +import { createFixture, createRequestAndResponse, runInContainer } from '../test-utils.js'; describe('dev container', () => { it('can render requests', async () => { - const fs = createFs( - { - '/src/pages/index.astro': ` + const fixture = await createFixture({ + '/src/pages/index.astro': ` --- const name = 'Testing'; --- @@ -26,11 +17,9 @@ describe('dev container', () => { </body> </html> `, - }, - root, - ); + }); - await runInContainer({ fs, inlineConfig: { root: fileURLToPath(root) } }, async (container) => { + await runInContainer({ inlineConfig: { root: fixture.path } }, async (container) => { const { req, res, text } = createRequestAndResponse({ method: 'GET', url: '/', @@ -43,89 +32,16 @@ describe('dev container', () => { }); }); - it('HMR only short circuits on previously cached modules', async () => { - const fs = createFs( - { - '/src/components/Header.astro': ` - <h1>{Astro.props.title}</h1> - `, - '/src/pages/index.astro': ` - --- - import Header from '../components/Header.astro'; - const name = 'Testing'; - --- - <html> - <head><title>{name} - -
- - - `, - }, - root, - ); - - await runInContainer({ fs, inlineConfig: { root: fileURLToPath(root) } }, async (container) => { - let r = createRequestAndResponse({ - method: 'GET', - url: '/', - }); - container.handle(r.req, r.res); - let html = await r.text(); - let $ = cheerio.load(html); - assert.equal($('body.one').length, 1); - - fs.writeFileFromRootSync( - '/src/components/Header.astro', - ` -

{Astro.props.title}

- `, - ); - triggerFSEvent(container, fs, '/src/components/Header.astro', 'change'); - - fs.writeFileFromRootSync( - '/src/pages/index.astro', - ` - --- - import Header from '../components/Header.astro'; - const name = 'Testing'; - --- - - {name} - -
- - - `, - ); - triggerFSEvent(container, fs, '/src/pages/index.astro', 'change'); - - r = createRequestAndResponse({ - method: 'GET', - url: '/', - }); - container.handle(r.req, r.res); - html = await r.text(); - $ = cheerio.load(html); - assert.equal($('body.one').length, 0); - assert.equal($('body.two').length, 1); - }); - }); - it('Allows dynamic segments in injected routes', async () => { - const fs = createFs( - { - '/src/components/test.astro': `

{Astro.params.slug}

`, - '/src/pages/test-[slug].astro': `

{Astro.params.slug}

`, - }, - root, - ); + const fixture = await createFixture({ + '/src/components/test.astro': `

{Astro.params.slug}

`, + '/src/pages/test-[slug].astro': `

{Astro.params.slug}

`, + }); await runInContainer( { - fs, inlineConfig: { - root: fileURLToPath(root), + root: fixture.path, output: 'server', integrations: [ { @@ -164,19 +80,15 @@ describe('dev container', () => { }); it('Serves injected 404 route for any 404', async () => { - const fs = createFs( - { - '/src/components/404.astro': `

Custom 404

`, - '/src/pages/page.astro': `

Regular page

`, - }, - root, - ); + const fixture = await createFixture({ + '/src/components/404.astro': `

Custom 404

`, + '/src/pages/page.astro': `

Regular page

`, + }); await runInContainer( { - fs, inlineConfig: { - root: fileURLToPath(root), + root: fixture.path, output: 'server', integrations: [ { @@ -226,10 +138,14 @@ describe('dev container', () => { }); it('items in public/ are not available from root when using a base', async () => { + const fixture = await createFixture({ + '/public/test.txt': `Test`, + }); + await runInContainer( { inlineConfig: { - root: fileURLToPath(root), + root: fixture.path, base: '/sub/', }, }, @@ -260,7 +176,11 @@ describe('dev container', () => { }); it('items in public/ are available from root when not using a base', async () => { - await runInContainer({ inlineConfig: { root: fileURLToPath(root) } }, async (container) => { + const fixture = await createFixture({ + '/public/test.txt': `Test`, + }); + + await runInContainer({ inlineConfig: { root: fixture.path } }, async (container) => { // Try the root path let r = createRequestAndResponse({ method: 'GET', diff --git a/packages/astro/test/units/dev/head-injection.test.js b/packages/astro/test/units/dev/head-injection.test.js index 0796ba45f7..fa61cea58a 100644 --- a/packages/astro/test/units/dev/head-injection.test.js +++ b/packages/astro/test/units/dev/head-injection.test.js @@ -1,14 +1,13 @@ import * as assert from 'node:assert/strict'; import { describe, it } from 'node:test'; -import { fileURLToPath } from 'node:url'; import * as cheerio from 'cheerio'; -import { createFs, createRequestAndResponse, runInContainer } from '../test-utils.js'; +import { createFixture, createRequestAndResponse, runInContainer } from '../test-utils.js'; const root = new URL('../../fixtures/alias/', import.meta.url); describe('head injection', () => { it('Dynamic injection from component created in the page frontmatter', async () => { - const fs = createFs( + const fixture = await createFixture( { '/src/components/Other.astro': `