From 20c7765be539365002defb14bfd6b22c076b8b73 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Wed, 14 Aug 2024 14:59:04 +0200 Subject: [PATCH 01/30] chore: optimize check (#11704) --- packages/astro/src/core/dev/restart.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/astro/src/core/dev/restart.ts b/packages/astro/src/core/dev/restart.ts index 235454cb5a70..ee0ba995c446 100644 --- a/packages/astro/src/core/dev/restart.ts +++ b/packages/astro/src/core/dev/restart.ts @@ -51,7 +51,7 @@ function shouldRestartContainer( const settingsPath = vite.normalizePath( fileURLToPath(new URL('settings.json', settings.dotAstroDir)), ); - if (settingsPath.match(normalizedChangedFile)) { + if (settingsPath.endsWith(normalizedChangedFile)) { shouldRestart = settings.preferences.ignoreNextPreferenceReload ? false : true; settings.preferences.ignoreNextPreferenceReload = false; From df78c79ea0f4a76b5965c7175fd3656a5639dbf6 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Wed, 14 Aug 2024 13:00:16 +0000 Subject: [PATCH 02/30] [ci] format --- packages/astro/src/@types/astro.ts | 6 +++--- packages/astro/src/content/data-store.ts | 2 +- packages/astro/src/content/types-generator.ts | 8 ++++---- packages/astro/src/core/sync/write-files.ts | 2 +- packages/astro/templates/content/types.d.ts | 2 -- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 2cf4160609b1..850b1227b88e 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -1,3 +1,5 @@ +import type { OutgoingHttpHeaders } from 'node:http'; +import type { AddressInfo } from 'node:net'; import type { MarkdownHeading, MarkdownVFile, @@ -7,8 +9,6 @@ import type { ShikiConfig, } from '@astrojs/markdown-remark'; import type * as babel from '@babel/core'; -import type { OutgoingHttpHeaders } from 'node:http'; -import type { AddressInfo } from 'node:net'; import type * as rollup from 'rollup'; import type * as vite from 'vite'; import type { @@ -2261,7 +2261,7 @@ export interface AstroUserConfig { * updatedDate: z.coerce.date().optional(), * }) * }); - * + * * const dogs = defineCollection({ * // The path is relative to the project root, or an absolute path. * loader: file("src/data/dogs.json"), diff --git a/packages/astro/src/content/data-store.ts b/packages/astro/src/content/data-store.ts index f416082f9db0..e3b00f998924 100644 --- a/packages/astro/src/content/data-store.ts +++ b/packages/astro/src/content/data-store.ts @@ -1,6 +1,6 @@ +import { promises as fs, type PathLike, existsSync } from 'fs'; import type { MarkdownHeading } from '@astrojs/markdown-remark'; import * as devalue from 'devalue'; -import { existsSync, promises as fs, type PathLike } from 'fs'; import { imageSrcToImportId, importIdToSymbolName } from '../assets/utils/resolveImports.js'; import { AstroError, AstroErrorData } from '../core/errors/index.js'; import { CONTENT_MODULE_FLAG, DEFERRED_MODULE } from './consts.js'; diff --git a/packages/astro/src/content/types-generator.ts b/packages/astro/src/content/types-generator.ts index 6fa0db94beb2..973a892fa17f 100644 --- a/packages/astro/src/content/types-generator.ts +++ b/packages/astro/src/content/types-generator.ts @@ -1,10 +1,10 @@ -import glob from 'fast-glob'; -import { bold, cyan } from 'kleur/colors'; import type fsMod from 'node:fs'; import * as path from 'node:path'; import { fileURLToPath, pathToFileURL } from 'node:url'; +import glob from 'fast-glob'; +import { bold, cyan } from 'kleur/colors'; import { type ViteDevServer, normalizePath } from 'vite'; -import { z, type ZodSchema } from 'zod'; +import { type ZodSchema, z } from 'zod'; import { zodToJsonSchema } from 'zod-to-json-schema'; import { printNode, zodToTs } from 'zod-to-ts'; import type { AstroSettings, ContentEntryType } from '../@types/astro.js'; @@ -473,7 +473,7 @@ async function writeContentFiles({ collection.type === 'unknown' ? // Add empty / unknown collections to the data type map by default // This ensures `getCollection('empty-collection')` doesn't raise a type error - (collectionConfig?.type ?? 'data') + collectionConfig?.type ?? 'data' : collection.type; const collectionEntryKeys = Object.keys(collection.entries).sort(); diff --git a/packages/astro/src/core/sync/write-files.ts b/packages/astro/src/core/sync/write-files.ts index 56ab131f1be7..395bd54f2b12 100644 --- a/packages/astro/src/core/sync/write-files.ts +++ b/packages/astro/src/core/sync/write-files.ts @@ -4,9 +4,9 @@ import { fileURLToPath } from 'node:url'; import { bold } from 'kleur/colors'; import { normalizePath } from 'vite'; import type { AstroSettings } from '../../@types/astro.js'; +import { AstroError, AstroErrorData } from '../errors/index.js'; import type { Logger } from '../logger/core.js'; import { REFERENCE_FILE } from './constants.js'; -import { AstroError, AstroErrorData } from '../errors/index.js'; export async function writeFiles(settings: AstroSettings, fs: typeof fsMod, logger: Logger) { try { diff --git a/packages/astro/templates/content/types.d.ts b/packages/astro/templates/content/types.d.ts index 9f277576a4bf..f83f28177698 100644 --- a/packages/astro/templates/content/types.d.ts +++ b/packages/astro/templates/content/types.d.ts @@ -1,5 +1,4 @@ declare module 'astro:content' { - interface RenderResult { Content: import('astro/runtime/server/index.js').AstroComponentFactory; headings: import('astro').MarkdownHeading[]; @@ -9,7 +8,6 @@ declare module 'astro:content' { '.md': Promise; } - export interface RenderedContent { html: string; metadata?: { From 69a7a5f1325256aac7577c0120388472478733d7 Mon Sep 17 00:00:00 2001 From: Sarah Rainsberger Date: Wed, 14 Aug 2024 11:09:14 -0300 Subject: [PATCH 03/30] [docs] updates link in Content Layer API (#11706) --- packages/astro/src/@types/astro.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 850b1227b88e..fcff6557cec3 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -2220,7 +2220,7 @@ export interface AstroUserConfig { * * The Content Layer API is a new way to handle content and data in Astro. It is similar to and builds upon [content collections](/en/guides/content-collections/), taking them beyond local files in `src/content/` and allowing you to fetch content from anywhere, including remote APIs, by adding a `loader` to your collection. * - * Your existing content collections can be [migrated to the Content Layer API](#migrating-a-content-collection-to-content-layer) with a few small changes. However, it is not necessary to update all your collections at once to add a new collection powered by the Content Layer API. You may have collections using both the existing and new APIs defined in `src/content/config.ts` at the same time. + * Your existing content collections can be [migrated to the Content Layer API](#migrating-an-existing-content-collection-to-use-the-content-layer-api) with a few small changes. However, it is not necessary to update all your collections at once to add a new collection powered by the Content Layer API. You may have collections using both the existing and new APIs defined in `src/content/config.ts` at the same time. * * The Content Layer API is designed to be more powerful and more performant, helping sites scale to thousands of pages. Data is cached between builds and updated incrementally. Markdown parsing is also 5-10 times faster, with similar scale reductions in memory, and MDX is 2-3 times faster. * From 3d8ae767fd4952af7332542b58fe98886eb2e99e Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Wed, 14 Aug 2024 13:30:31 -0400 Subject: [PATCH 04/30] Prevent externalized adapters from breaking build (#11709) * Prevent externalized adapters from breaking build * Add a changeset * Implement in both types of build plugins * linting :( --- .changeset/new-boats-flash.md | 5 +++ .../src/core/build/plugins/plugin-ssr.ts | 44 ++++++++++++++++--- .../astro/test/ssr-split-manifest.test.js | 11 ++--- 3 files changed, 46 insertions(+), 14 deletions(-) create mode 100644 .changeset/new-boats-flash.md diff --git a/.changeset/new-boats-flash.md b/.changeset/new-boats-flash.md new file mode 100644 index 000000000000..4ef58bba4538 --- /dev/null +++ b/.changeset/new-boats-flash.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix adapter causing Netlify to break diff --git a/packages/astro/src/core/build/plugins/plugin-ssr.ts b/packages/astro/src/core/build/plugins/plugin-ssr.ts index 70997e40ea67..b84d5050c492 100644 --- a/packages/astro/src/core/build/plugins/plugin-ssr.ts +++ b/packages/astro/src/core/build/plugins/plugin-ssr.ts @@ -19,6 +19,26 @@ import { getComponentFromVirtualModulePageName, getVirtualModulePageName } from export const SSR_VIRTUAL_MODULE_ID = '@astrojs-ssr-virtual-entry'; export const RESOLVED_SSR_VIRTUAL_MODULE_ID = '\0' + SSR_VIRTUAL_MODULE_ID; +const ADAPTER_VIRTUAL_MODULE_ID = '@astrojs-ssr-adapter'; +const RESOLVED_ADAPTER_VIRTUAL_MODULE_ID = '\0' + ADAPTER_VIRTUAL_MODULE_ID; + +function vitePluginAdapter(adapter: AstroAdapter): VitePlugin { + return { + name: '@astrojs/vite-plugin-astro-adapter', + enforce: 'post', + resolveId(id) { + if (id === ADAPTER_VIRTUAL_MODULE_ID) { + return RESOLVED_ADAPTER_VIRTUAL_MODULE_ID; + } + }, + async load(id) { + if(id === RESOLVED_ADAPTER_VIRTUAL_MODULE_ID) { + return `export * from '${adapter.serverEntrypoint}';`; + } + }, + }; +} + function vitePluginSSR( internals: BuildInternals, adapter: AstroAdapter, @@ -39,7 +59,7 @@ function vitePluginSSR( const adapterServerEntrypoint = options.settings.adapter?.serverEntrypoint; if (adapterServerEntrypoint) { - inputs.add(adapterServerEntrypoint); + inputs.add(ADAPTER_VIRTUAL_MODULE_ID); } inputs.add(SSR_VIRTUAL_MODULE_ID); @@ -119,14 +139,19 @@ export function pluginSSR( targets: ['server'], hooks: { 'build:before': () => { - let vitePlugin = + const adapter = options.settings.adapter!; + let ssrPlugin = ssr && functionPerRouteEnabled === false - ? vitePluginSSR(internals, options.settings.adapter!, options) + ? vitePluginSSR(internals, adapter, options) : undefined; + const vitePlugin = [vitePluginAdapter(adapter)]; + if(ssrPlugin) { + vitePlugin.unshift(ssrPlugin); + } return { enforce: 'after-user-plugins', - vitePlugin, + vitePlugin: vitePlugin, }; }, 'build:post': async () => { @@ -231,10 +256,15 @@ export function pluginSSRSplit( targets: ['server'], hooks: { 'build:before': () => { - let vitePlugin = + const adapter = options.settings.adapter!; + let ssrPlugin = ssr && functionPerRouteEnabled - ? vitePluginSSRSplit(internals, options.settings.adapter!, options) + ? vitePluginSSRSplit(internals, adapter, options) : undefined; + const vitePlugin = [vitePluginAdapter(adapter)]; + if(ssrPlugin) { + vitePlugin.unshift(ssrPlugin); + } return { enforce: 'after-user-plugins', @@ -251,7 +281,7 @@ function generateSSRCode(settings: AstroSettings, adapter: AstroAdapter, middlew const imports = [ `import { renderers } from '${RENDERERS_MODULE_ID}';`, - `import * as serverEntrypointModule from '${adapter.serverEntrypoint}';`, + `import * as serverEntrypointModule from '${ADAPTER_VIRTUAL_MODULE_ID}';`, `import { manifest as defaultManifest } from '${SSR_MANIFEST_VIRTUAL_MODULE_ID}';`, edgeMiddleware ? `` : `import { onRequest as middleware } from '${middlewareId}';`, settings.config.experimental.serverIslands diff --git a/packages/astro/test/ssr-split-manifest.test.js b/packages/astro/test/ssr-split-manifest.test.js index 06a6fe8c6a5c..fc55ce1ba821 100644 --- a/packages/astro/test/ssr-split-manifest.test.js +++ b/packages/astro/test/ssr-split-manifest.test.js @@ -1,6 +1,5 @@ import assert from 'node:assert/strict'; import { existsSync, readFileSync } from 'node:fs'; -import { resolve } from 'node:path'; import { before, describe, it } from 'node:test'; import { fileURLToPath } from 'node:url'; import * as cheerio from 'cheerio'; @@ -62,12 +61,10 @@ describe('astro:ssr-manifest, split', () => { }); it('should correctly emit the the pre render page', async () => { - const text = readFileSync( - resolve('./test/fixtures/ssr-split-manifest/dist/client/prerender/index.html'), - { - encoding: 'utf8', - }, - ); + const indexUrl = new URL('./fixtures/ssr-split-manifest/dist/client/prerender/index.html', import.meta.url); + const text = readFileSync(indexUrl, { + encoding: 'utf8', + }); assert.equal(text.includes('Pre render me'), true); }); From 3adb473cdf3cd2fc2ba90c7bb256fb677b442042 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Wed, 14 Aug 2024 17:31:27 +0000 Subject: [PATCH 05/30] [ci] format --- packages/astro/src/core/build/plugins/plugin-ssr.ts | 6 +++--- packages/astro/test/ssr-split-manifest.test.js | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/astro/src/core/build/plugins/plugin-ssr.ts b/packages/astro/src/core/build/plugins/plugin-ssr.ts index b84d5050c492..e9eda1dc90c2 100644 --- a/packages/astro/src/core/build/plugins/plugin-ssr.ts +++ b/packages/astro/src/core/build/plugins/plugin-ssr.ts @@ -32,7 +32,7 @@ function vitePluginAdapter(adapter: AstroAdapter): VitePlugin { } }, async load(id) { - if(id === RESOLVED_ADAPTER_VIRTUAL_MODULE_ID) { + if (id === RESOLVED_ADAPTER_VIRTUAL_MODULE_ID) { return `export * from '${adapter.serverEntrypoint}';`; } }, @@ -145,7 +145,7 @@ export function pluginSSR( ? vitePluginSSR(internals, adapter, options) : undefined; const vitePlugin = [vitePluginAdapter(adapter)]; - if(ssrPlugin) { + if (ssrPlugin) { vitePlugin.unshift(ssrPlugin); } @@ -262,7 +262,7 @@ export function pluginSSRSplit( ? vitePluginSSRSplit(internals, adapter, options) : undefined; const vitePlugin = [vitePluginAdapter(adapter)]; - if(ssrPlugin) { + if (ssrPlugin) { vitePlugin.unshift(ssrPlugin); } diff --git a/packages/astro/test/ssr-split-manifest.test.js b/packages/astro/test/ssr-split-manifest.test.js index fc55ce1ba821..af0234c6a5cd 100644 --- a/packages/astro/test/ssr-split-manifest.test.js +++ b/packages/astro/test/ssr-split-manifest.test.js @@ -61,7 +61,10 @@ describe('astro:ssr-manifest, split', () => { }); it('should correctly emit the the pre render page', async () => { - const indexUrl = new URL('./fixtures/ssr-split-manifest/dist/client/prerender/index.html', import.meta.url); + const indexUrl = new URL( + './fixtures/ssr-split-manifest/dist/client/prerender/index.html', + import.meta.url, + ); const text = readFileSync(indexUrl, { encoding: 'utf8', }); From 057241f3a6cd55bf942d2a2f37723c5d2e1127d7 Mon Sep 17 00:00:00 2001 From: Yan <61414485+yanthomasdev@users.noreply.github.com> Date: Wed, 14 Aug 2024 17:47:39 -0300 Subject: [PATCH 06/30] Fix typos in 4.14 error references (#11711) --- packages/astro/src/core/errors/errors-data.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/astro/src/core/errors/errors-data.ts b/packages/astro/src/core/errors/errors-data.ts index aa19b6dc3b0e..24b9ad687aea 100644 --- a/packages/astro/src/core/errors/errors-data.ts +++ b/packages/astro/src/core/errors/errors-data.ts @@ -1294,11 +1294,11 @@ export const RewriteWithBodyUsed = { /** * @docs * @description - * An unknown error occured while reading or writing files to disk. It can be caused by many things, eg. missing permissions or a file not existing we attempt to read. + * An unknown error occurred while reading or writing files to disk. It can be caused by many things, eg. missing permissions or a file not existing we attempt to read. */ export const UnknownFilesystemError = { name: 'UnknownFilesystemError', - title: 'An unknown error occured while reading or writing files to disk.', + title: 'An unknown error occurred while reading or writing files to disk.', hint: 'It can be caused by many things, eg. missing permissions or a file not existing we attempt to read. Check the error cause for more details.', } satisfies ErrorData; From b860a9998ddad9f1f9f87a02b1a65d8907a99b38 Mon Sep 17 00:00:00 2001 From: Yan <61414485+yanthomasdev@users.noreply.github.com> Date: Wed, 14 Aug 2024 17:48:12 -0300 Subject: [PATCH 07/30] Small wording/nit improvements to 4.14 release types docs (#11710) Co-authored-by: Sarah Rainsberger --- packages/astro/src/@types/astro.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index fcff6557cec3..83c1392f412b 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -2237,7 +2237,7 @@ export interface AstroUserConfig { * * #### Fetching data with a `loader` * - * The Content Layer API allows you to fetch your content from outside of the `src/content/` folder (whether stored locally in your project or remotely), and uses a `loader` property to retrieve your data. + * The Content Layer API allows you to fetch your content from outside of the `src/content/` folder (whether stored locally in your project or remotely) and uses a `loader` property to retrieve your data. * * The `loader` is defined in the collection's schema and returns an array of entries. Astro provides two built-in loader functions (`glob()` and `file()`) for fetching your local content, as well as access to the API to [construct your own loader and fetch remote data](#creating-a-loader). * @@ -2292,10 +2292,10 @@ export interface AstroUserConfig { * const labradorData = await getEntry('dogs', 'labrador-retriever'); * ``` * - * Entries generated from Markdown, MDX or Markdoc can be rendered directly to a page using the `render()` function. + * Entries generated from Markdown, MDX, or Markdoc can be rendered directly to a page using the `render()` function. * * :::note - * The syntax for rendering collection entries is different from current content collections syntax. + * The syntax for rendering collection entries is different from the current content collections syntax. * ::: * * ```astro title="src/pages/[slug].astro" @@ -2336,7 +2336,7 @@ export interface AstroUserConfig { * export const collections = { countries }; * ``` * - * For more advanced loading logic, you can define an object loader. This allows incremental updates and conditional loading, and gives full access to the data store. See the API in [the Content Layer API RFC](https://github.com/withastro/roadmap/blob/content-layer/proposals/0047-content-layer.md#loaders). + * For more advanced loading logic, you can define an object loader. This allows incremental updates and conditional loading while also giving full access to the data store. See the API in [the Content Layer API RFC](https://github.com/withastro/roadmap/blob/content-layer/proposals/0047-content-layer.md#loaders). * * #### Migrating an existing content collection to use the Content Layer API * From 4a2cb3d1a97d7ff24491377fa9f730d8d544e59f Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Thu, 15 Aug 2024 11:41:21 +0800 Subject: [PATCH 08/30] Upgrade to turbo v2 (#11705) --- package.json | 2 +- pnpm-lock.yaml | 60 +++++++++++++------------- turbo.json | 111 +++++++++++++++++++++++++++++-------------------- 3 files changed, 96 insertions(+), 77 deletions(-) diff --git a/package.json b/package.json index 5f2eb056c986..6958dee90d3e 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "only-allow": "^1.2.1", "prettier": "^3.3.3", "prettier-plugin-astro": "^0.14.1", - "turbo": "^1.13.4", + "turbo": "^2.0.12", "typescript": "~5.5.4", "typescript-eslint": "^8.0.1" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 01db0912ed26..6f548f03058b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -52,8 +52,8 @@ importers: specifier: ^0.14.1 version: 0.14.1 turbo: - specifier: ^1.13.4 - version: 1.13.4 + specifier: ^2.0.12 + version: 2.0.12 typescript: specifier: ~5.5.4 version: 5.5.4 @@ -8281,7 +8281,7 @@ packages: resolution: {integrity: sha512-L3sHRo1pXXEqX8VU28kfgUY+YGsk09hPqZiZmLacNib6XNTCM8ubYeT7ryXQw8asB1sKgcU5lkB7ONug08aB8w==} concat-map@0.0.1: - resolution: {integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=} + resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} consola@3.2.3: resolution: {integrity: sha512-I5qxpzLv+sJhTVEoLYNcTW+bThDCPsit0vLNKShZx6rLtpilNpmmeTPaeqJb9ZE9dV3DGaeby6Vuhrw38WjeyQ==} @@ -11224,38 +11224,38 @@ packages: tslib@2.6.2: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} - turbo-darwin-64@1.13.4: - resolution: {integrity: sha512-A0eKd73R7CGnRinTiS7txkMElg+R5rKFp9HV7baDiEL4xTG1FIg/56Vm7A5RVgg8UNgG2qNnrfatJtb+dRmNdw==} + turbo-darwin-64@2.0.12: + resolution: {integrity: sha512-NAgfgbXxX/JScWQmmQnGbPuFZq7LIswHfcMk5JwyBXQM/xmklNOxxac7MnGGIOf19Z2f6S3qHy17VIj0SeGfnA==} cpu: [x64] os: [darwin] - turbo-darwin-arm64@1.13.4: - resolution: {integrity: sha512-eG769Q0NF6/Vyjsr3mKCnkG/eW6dKMBZk6dxWOdrHfrg6QgfkBUk0WUUujzdtVPiUIvsh4l46vQrNVd9EOtbyA==} + turbo-darwin-arm64@2.0.12: + resolution: {integrity: sha512-cP02uer5KSJ+fXL+OfRRk5hnVjV0c60hxDgNcJxrZpfhun7HHoKDDR7w2xhQntiA45aC6ZZEXRqMKpj6GAmKbg==} cpu: [arm64] os: [darwin] - turbo-linux-64@1.13.4: - resolution: {integrity: sha512-Bq0JphDeNw3XEi+Xb/e4xoKhs1DHN7OoLVUbTIQz+gazYjigVZvtwCvgrZI7eW9Xo1eOXM2zw2u1DGLLUfmGkQ==} + turbo-linux-64@2.0.12: + resolution: {integrity: sha512-+mQgGfg1eq5qF+wenK/FKJaNMNAo5DQLC4htQy+8osW+fx6U+8+6UlPQPaycAWDEqwOI7NwuqkeHfkEQLQUTyQ==} cpu: [x64] os: [linux] - turbo-linux-arm64@1.13.4: - resolution: {integrity: sha512-BJcXw1DDiHO/okYbaNdcWN6szjXyHWx9d460v6fCHY65G8CyqGU3y2uUTPK89o8lq/b2C8NK0yZD+Vp0f9VoIg==} + turbo-linux-arm64@2.0.12: + resolution: {integrity: sha512-KFyEZDXfPU1DK4zimxdCcqAcK7IIttX4mfsgB7NsSEOmH0dhHOih/YFYiyEDC1lTRx0C2RlzQ0Kjjdz48AN5Eg==} cpu: [arm64] os: [linux] - turbo-windows-64@1.13.4: - resolution: {integrity: sha512-OFFhXHOFLN7A78vD/dlVuuSSVEB3s9ZBj18Tm1hk3aW1HTWTuAw0ReN6ZNlVObZUHvGy8d57OAGGxf2bT3etQw==} + turbo-windows-64@2.0.12: + resolution: {integrity: sha512-kJj4KCkZTkDTDCqsSw1m1dbO4WeoQq1mYUm/thXOH0OkeqYbSMt0EyoTcJOgKUDsrMnzZD2gPfYrlYHtV69lVA==} cpu: [x64] os: [win32] - turbo-windows-arm64@1.13.4: - resolution: {integrity: sha512-u5A+VOKHswJJmJ8o8rcilBfU5U3Y1TTAfP9wX8bFh8teYF1ghP0EhtMRLjhtp6RPa+XCxHHVA2CiC3gbh5eg5g==} + turbo-windows-arm64@2.0.12: + resolution: {integrity: sha512-TY3ROxguDilN2olCwcZMaePdW01Xhma0pZU7bNhsQEqca9RGAmsZBuzfGnTMcWPmv4tpnb/PlX1hrt1Hod/44Q==} cpu: [arm64] os: [win32] - turbo@1.13.4: - resolution: {integrity: sha512-1q7+9UJABuBAHrcC4Sxp5lOqYS5mvxRrwa33wpIyM18hlOCpRD/fTJNxZ0vhbMcJmz15o9kkVm743mPn7p6jpQ==} + turbo@2.0.12: + resolution: {integrity: sha512-8s2KwqjwQj7z8Z53SUZSKVkQOZ2/Sl4D2F440oaBY/k2lGju60dW6srEpnn8/RIDeICZmQn3pQHF79Jfnc5Skw==} hasBin: true type-check@0.4.0: @@ -17872,32 +17872,32 @@ snapshots: tslib@2.6.2: {} - turbo-darwin-64@1.13.4: + turbo-darwin-64@2.0.12: optional: true - turbo-darwin-arm64@1.13.4: + turbo-darwin-arm64@2.0.12: optional: true - turbo-linux-64@1.13.4: + turbo-linux-64@2.0.12: optional: true - turbo-linux-arm64@1.13.4: + turbo-linux-arm64@2.0.12: optional: true - turbo-windows-64@1.13.4: + turbo-windows-64@2.0.12: optional: true - turbo-windows-arm64@1.13.4: + turbo-windows-arm64@2.0.12: optional: true - turbo@1.13.4: + turbo@2.0.12: optionalDependencies: - turbo-darwin-64: 1.13.4 - turbo-darwin-arm64: 1.13.4 - turbo-linux-64: 1.13.4 - turbo-linux-arm64: 1.13.4 - turbo-windows-64: 1.13.4 - turbo-windows-arm64: 1.13.4 + turbo-darwin-64: 2.0.12 + turbo-darwin-arm64: 2.0.12 + turbo-linux-64: 2.0.12 + turbo-linux-arm64: 2.0.12 + turbo-windows-64: 2.0.12 + turbo-windows-arm64: 2.0.12 type-check@0.4.0: dependencies: diff --git a/turbo.json b/turbo.json index ffced482bb5d..c873e24c9495 100644 --- a/turbo.json +++ b/turbo.json @@ -1,48 +1,67 @@ { - "$schema": "https://turborepo.org/schema.json", - "pipeline": { - "build": { - "dependsOn": ["^build"], - "inputs": [ - "**/*", - "!test/**/*", - "!e2e/**/*", - "!performance/**/*", - "!.astro/**/*", - "!.cache/**/*", - "!mod.js", - "!mod.js.map" - ], - "outputs": ["dist/**/*", "!vendor/**", "mod.js", "mod.js.map"], - "outputMode": "new-only" - }, - "build:ci": { - "dependsOn": ["^build:ci"], - "inputs": [ - "**/*", - "!test/**/*", - "!e2e/**/*", - "!performance/**/*", - "!.astro/**/*", - "!.cache/**/*", - "!mod.js", - "!mod.js.map" - ], - "outputs": ["dist/**/*", "!vendor/**", "mod.js", "mod.js.map"], - "outputMode": "new-only" - }, - "dev": { - "cache": false, - "persistent": true - }, - "test": { - "dependsOn": ["^test"], - "env": ["RUNNER_OS", "NODE_VERSION"], - "outputMode": "new-only" - }, - "test:hosted": { - "outputMode": "new-only", - "cache": false - } - } + "$schema": "https://turborepo.org/schema.json", + "tasks": { + "build": { + "dependsOn": [ + "^build" + ], + "inputs": [ + "**/*", + "!test/**/*", + "!e2e/**/*", + "!performance/**/*", + "!.astro/**/*", + "!.cache/**/*", + "!mod.js", + "!mod.js.map" + ], + "outputs": [ + "dist/**/*", + "!vendor/**", + "mod.js", + "mod.js.map" + ], + "outputLogs": "new-only" + }, + "build:ci": { + "dependsOn": [ + "^build:ci" + ], + "inputs": [ + "**/*", + "!test/**/*", + "!e2e/**/*", + "!performance/**/*", + "!.astro/**/*", + "!.cache/**/*", + "!mod.js", + "!mod.js.map" + ], + "outputs": [ + "dist/**/*", + "!vendor/**", + "mod.js", + "mod.js.map" + ], + "outputLogs": "new-only" + }, + "dev": { + "cache": false, + "persistent": true + }, + "test": { + "dependsOn": [ + "^test" + ], + "env": [ + "RUNNER_OS", + "NODE_VERSION" + ], + "outputLogs": "new-only" + }, + "test:hosted": { + "cache": false, + "outputLogs": "new-only" + } + } } From 791d809cbc22ed30dda1195ca026daa46a54b551 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Thu, 15 Aug 2024 04:34:25 -0400 Subject: [PATCH 09/30] Server Islands - Handle base + trailingSlash ignore (#11712) * Server Islands - Handle base + trailingSlash ignore * Add a changeset --- .changeset/kind-bees-admire.md | 5 +++++ .../fixtures/server-islands/astro.config.mjs | 2 +- packages/astro/e2e/server-islands.test.js | 20 +++++++++++++++++++ .../runtime/server/render/server-islands.ts | 3 ++- 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 .changeset/kind-bees-admire.md diff --git a/.changeset/kind-bees-admire.md b/.changeset/kind-bees-admire.md new file mode 100644 index 000000000000..7aa359f58bee --- /dev/null +++ b/.changeset/kind-bees-admire.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix mixed use of base + trailingSlash in Server Islands diff --git a/packages/astro/e2e/fixtures/server-islands/astro.config.mjs b/packages/astro/e2e/fixtures/server-islands/astro.config.mjs index 4bec97b9e1ad..2175a1bf8fe9 100644 --- a/packages/astro/e2e/fixtures/server-islands/astro.config.mjs +++ b/packages/astro/e2e/fixtures/server-islands/astro.config.mjs @@ -9,7 +9,7 @@ export default defineConfig({ output: 'hybrid', adapter: nodejs({ mode: 'standalone' }), integrations: [react(), mdx()], - trailingSlash: 'always', + trailingSlash: process.env.TRAILING_SLASH ?? 'always', experimental: { serverIslands: true, } diff --git a/packages/astro/e2e/server-islands.test.js b/packages/astro/e2e/server-islands.test.js index b37495b28812..2e68937b98e1 100644 --- a/packages/astro/e2e/server-islands.test.js +++ b/packages/astro/e2e/server-islands.test.js @@ -52,6 +52,26 @@ test.describe('Server islands', () => { }); }); + test.describe('Development - trailingSlash: ignore', () => { + let devServer; + + test.beforeAll(async ({ astro }) => { + process.env.TRAILING_SLASH = 'ignore'; + devServer = await astro.startDevServer(); + }); + + test.afterAll(async () => { + await devServer.stop(); + }); + + test('Load content from the server', async ({ page, astro }) => { + await page.goto(astro.resolveUrl('/base/')); + let el = page.locator('#island'); + + await expect(el, 'element rendered').toBeVisible(); + await expect(el, 'should have content').toHaveText('I am an island'); + }); + }); test.describe('Production', () => { let previewServer; diff --git a/packages/astro/src/runtime/server/render/server-islands.ts b/packages/astro/src/runtime/server/render/server-islands.ts index 58cce4e14814..153c01c6563d 100644 --- a/packages/astro/src/runtime/server/render/server-islands.ts +++ b/packages/astro/src/runtime/server/render/server-islands.ts @@ -64,7 +64,8 @@ export function renderServerIsland( const propsEncrypted = await encryptString(key, JSON.stringify(props)); const hostId = crypto.randomUUID(); - const serverIslandUrl = `${result.base}_server-islands/${componentId}${result.trailingSlash === 'always' ? '/' : ''}`; + const slash = result.base.endsWith('/') ? '' : '/'; + const serverIslandUrl = `${result.base}${slash}_server-islands/${componentId}${result.trailingSlash === 'always' ? '/' : ''}`; destination.write(` + + diff --git a/packages/astro/e2e/server-islands.test.js b/packages/astro/e2e/server-islands.test.js index 2e68937b98e1..1c4e2a7e8051 100644 --- a/packages/astro/e2e/server-islands.test.js +++ b/packages/astro/e2e/server-islands.test.js @@ -50,6 +50,12 @@ test.describe('Server islands', () => { await expect(el).toHaveCount(2); }); + + test('Missing server island start comment doesn\'t cause browser to lock up', async ({ page, astro }) => { + await page.goto(astro.resolveUrl('/base/')); + let el = page.locator('#first'); + await expect(el).toHaveCount(1); + }); }); test.describe('Development - trailingSlash: ignore', () => { diff --git a/packages/astro/src/runtime/server/render/server-islands.ts b/packages/astro/src/runtime/server/render/server-islands.ts index 153c01c6563d..0a072113447b 100644 --- a/packages/astro/src/runtime/server/render/server-islands.ts +++ b/packages/astro/src/runtime/server/render/server-islands.ts @@ -86,9 +86,10 @@ if(response.status === 200 && response.headers.get('content-type') === 'text/htm let html = await response.text(); // Swap! - while(script.previousSibling?.nodeType !== 8 && - script.previousSibling?.data !== 'server-island-start') { - script.previousSibling?.remove(); + while(script.previousSibling && + script.previousSibling.nodeType !== 8 && + script.previousSibling.data !== 'server-island-start') { + script.previousSibling.remove(); } script.previousSibling?.remove(); From 934165e21b8b51868db70bbdbc7ffda63b77aefd Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Thu, 15 Aug 2024 12:04:50 +0000 Subject: [PATCH 14/30] [ci] format --- packages/astro/e2e/server-islands.test.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/astro/e2e/server-islands.test.js b/packages/astro/e2e/server-islands.test.js index 1c4e2a7e8051..496cf229cc50 100644 --- a/packages/astro/e2e/server-islands.test.js +++ b/packages/astro/e2e/server-islands.test.js @@ -51,7 +51,10 @@ test.describe('Server islands', () => { await expect(el).toHaveCount(2); }); - test('Missing server island start comment doesn\'t cause browser to lock up', async ({ page, astro }) => { + test("Missing server island start comment doesn't cause browser to lock up", async ({ + page, + astro, + }) => { await page.goto(astro.resolveUrl('/base/')); let el = page.locator('#first'); await expect(el).toHaveCount(1); From 88a6ccb8c63ab93f17e5733db85b2ab351393af1 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Thu, 15 Aug 2024 14:44:30 +0100 Subject: [PATCH 15/30] chore(readme): adds the netlify adapter (#11726) --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9b5e734aa852..0827fb9739d9 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Join us on [Discord](https://astro.build/chat) to meet other maintainers. We'll ## Directory | Package | Release Notes | -| ------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +|--------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [astro](packages/astro) | [![astro version](https://img.shields.io/npm/v/astro.svg?label=%20)](packages/astro/CHANGELOG.md) | | [create-astro](packages/create-astro) | [![create-astro version](https://img.shields.io/npm/v/create-astro.svg?label=%20)](packages/create-astro/CHANGELOG.md) | | [@astrojs/react](packages/integrations/react) | [![@astrojs/react version](https://img.shields.io/npm/v/@astrojs/react.svg?label=%20)](packages/integrations/react/CHANGELOG.md) | @@ -70,6 +70,7 @@ Join us on [Discord](https://astro.build/chat) to meet other maintainers. We'll | [@astrojs/mdx](packages/integrations/mdx) | [![@astrojs/mdx version](https://img.shields.io/npm/v/@astrojs/mdx.svg?label=%20)](packages/integrations/mdx/CHANGELOG.md) | | [@astrojs/db](packages/db) | [![@astrojs/db version](https://img.shields.io/npm/v/@astrojs/db.svg?label=%20)](packages/db/CHANGELOG.md) | | [@astrojs/rss](packages/astro-rss) | [![@astrojs/rss version](https://img.shields.io/npm/v/@astrojs/rss.svg?label=%20)](packages/astro-rss/CHANGELOG.md) | +| [@astrojs/netlify](https://github.com/withastro/adapters/blob/main/packages/netlify) | [![@astrojs/netlify version](https://img.shields.io/npm/v/@astrojs/netlify.svg?label=%20)](https://github.com/withastro/adapters/blob/main/packages/netlify/CHANGELOG.md) | [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/6178/badge)](https://bestpractices.coreinfrastructure.org/projects/6178) From 4844e1b5fbe2216078e14e316996e06e3c899c93 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Thu, 15 Aug 2024 14:45:12 +0100 Subject: [PATCH 16/30] chore: updates the supported features of test adapter (#11724) --- packages/astro/test/test-adapter.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/astro/test/test-adapter.js b/packages/astro/test/test-adapter.js index 8c4643367d20..fc5249561279 100644 --- a/packages/astro/test/test-adapter.js +++ b/packages/astro/test/test-adapter.js @@ -108,6 +108,10 @@ export default function ({ supportedAstroFeatures: { serverOutput: 'stable', envGetSecret: 'experimental', + staticOutput: 'stable', + hybridOutput: 'stable', + assets: 'stable', + i18nDomains: 'stable', }, ...extendAdapter, }); From 9bf9f5a7b0cf0f5d8edd25d562e292349c685303 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Thu, 15 Aug 2024 13:46:00 +0000 Subject: [PATCH 17/30] [ci] format --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0827fb9739d9..62589bac80ce 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Join us on [Discord](https://astro.build/chat) to meet other maintainers. We'll ## Directory | Package | Release Notes | -|--------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| ------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [astro](packages/astro) | [![astro version](https://img.shields.io/npm/v/astro.svg?label=%20)](packages/astro/CHANGELOG.md) | | [create-astro](packages/create-astro) | [![create-astro version](https://img.shields.io/npm/v/create-astro.svg?label=%20)](packages/create-astro/CHANGELOG.md) | | [@astrojs/react](packages/integrations/react) | [![@astrojs/react version](https://img.shields.io/npm/v/@astrojs/react.svg?label=%20)](packages/integrations/react/CHANGELOG.md) | From 6c1560fb0d19ce659bc9f9090f8050254d5c03f3 Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Thu, 15 Aug 2024 15:26:00 +0100 Subject: [PATCH 18/30] fix: separate data store into mutable and immutable versions (#11725) * fix: separate data store into mutable and immutable versions * Add jsdoc --- .changeset/fresh-tigers-cheat.md | 5 + packages/astro/src/content/content-layer.ts | 6 +- packages/astro/src/content/data-store.ts | 375 +----------------- packages/astro/src/content/loaders/types.ts | 2 +- .../astro/src/content/mutable-data-store.ts | 370 +++++++++++++++++ packages/astro/src/content/utils.ts | 8 + packages/astro/src/core/dev/dev.ts | 10 +- packages/astro/src/core/sync/index.ts | 10 +- 8 files changed, 410 insertions(+), 376 deletions(-) create mode 100644 .changeset/fresh-tigers-cheat.md create mode 100644 packages/astro/src/content/mutable-data-store.ts diff --git a/.changeset/fresh-tigers-cheat.md b/.changeset/fresh-tigers-cheat.md new file mode 100644 index 000000000000..32dbccebd1de --- /dev/null +++ b/.changeset/fresh-tigers-cheat.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Prevents content layer importing node builtins in runtime diff --git a/packages/astro/src/content/content-layer.ts b/packages/astro/src/content/content-layer.ts index 9a6d4ed37542..4861f3f61aa1 100644 --- a/packages/astro/src/content/content-layer.ts +++ b/packages/astro/src/content/content-layer.ts @@ -12,12 +12,12 @@ import { DATA_STORE_FILE, MODULES_IMPORTS_FILE, } from './consts.js'; -import type { DataStore } from './data-store.js'; import type { LoaderContext } from './loaders/types.js'; +import type { MutableDataStore } from './mutable-data-store.js'; import { getEntryDataAndImages, globalContentConfigObserver, posixRelative } from './utils.js'; export interface ContentLayerOptions { - store: DataStore; + store: MutableDataStore; settings: AstroSettings; logger: Logger; watcher?: FSWatcher; @@ -25,7 +25,7 @@ export interface ContentLayerOptions { export class ContentLayer { #logger: Logger; - #store: DataStore; + #store: MutableDataStore; #settings: AstroSettings; #watcher?: FSWatcher; #lastConfigDigest?: string; diff --git a/packages/astro/src/content/data-store.ts b/packages/astro/src/content/data-store.ts index e3b00f998924..76cefc411a76 100644 --- a/packages/astro/src/content/data-store.ts +++ b/packages/astro/src/content/data-store.ts @@ -1,11 +1,5 @@ -import { promises as fs, type PathLike, existsSync } from 'fs'; import type { MarkdownHeading } from '@astrojs/markdown-remark'; import * as devalue from 'devalue'; -import { imageSrcToImportId, importIdToSymbolName } from '../assets/utils/resolveImports.js'; -import { AstroError, AstroErrorData } from '../core/errors/index.js'; -import { CONTENT_MODULE_FLAG, DEFERRED_MODULE } from './consts.js'; - -const SAVE_DEBOUNCE_MS = 500; export interface RenderedContent { /** Rendered HTML string. If present then `render(entry)` will return a component that renders this HTML. */ @@ -41,75 +35,39 @@ export interface DataEntry = Record>(); - - #file?: PathLike; - - #assetsFile?: PathLike; - #modulesFile?: PathLike; - - #saveTimeout: NodeJS.Timeout | undefined; - #assetsSaveTimeout: NodeJS.Timeout | undefined; - #modulesSaveTimeout: NodeJS.Timeout | undefined; - - #dirty = false; - #assetsDirty = false; - #modulesDirty = false; +/** + * A read-only data store for content collections. This is used to retrieve data from the content layer at runtime. + * To add or modify data, use {@link MutableDataStore} instead. + */ - #assetImports = new Set(); - #moduleImports = new Map(); +export class DataStore { + protected _collections = new Map>(); constructor() { - this.#collections = new Map(); + this._collections = new Map(); } get(collectionName: string, key: string): T | undefined { - return this.#collections.get(collectionName)?.get(String(key)); + return this._collections.get(collectionName)?.get(String(key)); } entries(collectionName: string): Array<[id: string, T]> { - const collection = this.#collections.get(collectionName) ?? new Map(); + const collection = this._collections.get(collectionName) ?? new Map(); return [...collection.entries()]; } values(collectionName: string): Array { - const collection = this.#collections.get(collectionName) ?? new Map(); + const collection = this._collections.get(collectionName) ?? new Map(); return [...collection.values()]; } keys(collectionName: string): Array { - const collection = this.#collections.get(collectionName) ?? new Map(); + const collection = this._collections.get(collectionName) ?? new Map(); return [...collection.keys()]; } - set(collectionName: string, key: string, value: unknown) { - const collection = this.#collections.get(collectionName) ?? new Map(); - collection.set(String(key), value); - this.#collections.set(collectionName, collection); - this.#saveToDiskDebounced(); - } - - delete(collectionName: string, key: string) { - const collection = this.#collections.get(collectionName); - if (collection) { - collection.delete(String(key)); - this.#saveToDiskDebounced(); - } - } - - clear(collectionName: string) { - this.#collections.delete(collectionName); - this.#saveToDiskDebounced(); - } - - clearAll() { - this.#collections.clear(); - this.#saveToDiskDebounced(); - } - has(collectionName: string, key: string) { - const collection = this.#collections.get(collectionName); + const collection = this._collections.get(collectionName); if (collection) { return collection.has(String(key)); } @@ -117,234 +75,11 @@ export class DataStore { } hasCollection(collectionName: string) { - return this.#collections.has(collectionName); + return this._collections.has(collectionName); } collections() { - return this.#collections; - } - - addAssetImport(assetImport: string, filePath: string) { - const id = imageSrcToImportId(assetImport, filePath); - if (id) { - this.#assetImports.add(id); - // We debounce the writes to disk because addAssetImport is called for every image in every file, - // and can be called many times in quick succession by a filesystem watcher. We only want to write - // the file once, after all the imports have been added. - this.#writeAssetsImportsDebounced(); - } - } - - addAssetImports(assets: Array, filePath: string) { - assets.forEach((asset) => this.addAssetImport(asset, filePath)); - } - - addModuleImport(fileName: string) { - const id = contentModuleToId(fileName); - if (id) { - this.#moduleImports.set(fileName, id); - // We debounce the writes to disk because addAssetImport is called for every image in every file, - // and can be called many times in quick succession by a filesystem watcher. We only want to write - // the file once, after all the imports have been added. - this.#writeModulesImportsDebounced(); - } - } - - async writeAssetImports(filePath: PathLike) { - this.#assetsFile = filePath; - - if (this.#assetImports.size === 0) { - try { - await fs.writeFile(filePath, 'export default new Map();'); - } catch (err) { - throw new AstroError(AstroErrorData.UnknownFilesystemError, { cause: err }); - } - } - - if (!this.#assetsDirty && existsSync(filePath)) { - return; - } - // Import the assets, with a symbol name that is unique to the import id. The import - // for each asset is an object with path, format and dimensions. - // We then export them all, mapped by the import id, so we can find them again in the build. - const imports: Array = []; - const exports: Array = []; - this.#assetImports.forEach((id) => { - const symbol = importIdToSymbolName(id); - imports.push(`import ${symbol} from '${id}';`); - exports.push(`[${JSON.stringify(id)}, ${symbol}]`); - }); - const code = /* js */ ` -${imports.join('\n')} -export default new Map([${exports.join(', ')}]); - `; - try { - await fs.writeFile(filePath, code); - } catch (err) { - throw new AstroError(AstroErrorData.UnknownFilesystemError, { cause: err }); - } - this.#assetsDirty = false; - } - - async writeModuleImports(filePath: PathLike) { - this.#modulesFile = filePath; - - if (this.#moduleImports.size === 0) { - try { - await fs.writeFile(filePath, 'export default new Map();'); - } catch (err) { - throw new AstroError(AstroErrorData.UnknownFilesystemError, { cause: err }); - } - } - - if (!this.#modulesDirty && existsSync(filePath)) { - return; - } - - // Import the assets, with a symbol name that is unique to the import id. The import - // for each asset is an object with path, format and dimensions. - // We then export them all, mapped by the import id, so we can find them again in the build. - const lines: Array = []; - for (const [fileName, specifier] of this.#moduleImports) { - lines.push(`['${fileName}', () => import('${specifier}')]`); - } - const code = ` -export default new Map([\n${lines.join(',\n')}]); - `; - try { - await fs.writeFile(filePath, code); - } catch (err) { - throw new AstroError(AstroErrorData.UnknownFilesystemError, { cause: err }); - } - this.#modulesDirty = false; - } - - #writeAssetsImportsDebounced() { - this.#assetsDirty = true; - if (this.#assetsFile) { - if (this.#assetsSaveTimeout) { - clearTimeout(this.#assetsSaveTimeout); - } - this.#assetsSaveTimeout = setTimeout(() => { - this.#assetsSaveTimeout = undefined; - this.writeAssetImports(this.#assetsFile!); - }, SAVE_DEBOUNCE_MS); - } - } - - #writeModulesImportsDebounced() { - this.#modulesDirty = true; - if (this.#modulesFile) { - if (this.#modulesSaveTimeout) { - clearTimeout(this.#modulesSaveTimeout); - } - this.#modulesSaveTimeout = setTimeout(() => { - this.#modulesSaveTimeout = undefined; - this.writeModuleImports(this.#modulesFile!); - }, SAVE_DEBOUNCE_MS); - } - } - - #saveToDiskDebounced() { - this.#dirty = true; - // Only save to disk if it has already been saved once - if (this.#file) { - if (this.#saveTimeout) { - clearTimeout(this.#saveTimeout); - } - this.#saveTimeout = setTimeout(() => { - this.#saveTimeout = undefined; - this.writeToDisk(this.#file!); - }, SAVE_DEBOUNCE_MS); - } - } - - scopedStore(collectionName: string): ScopedDataStore { - return { - get: = Record>(key: string) => - this.get>(collectionName, key), - entries: () => this.entries(collectionName), - values: () => this.values(collectionName), - keys: () => this.keys(collectionName), - set: ({ id: key, data, body, filePath, deferredRender, digest, rendered }) => { - if (!key) { - throw new Error(`ID must be a non-empty string`); - } - const id = String(key); - if (digest) { - const existing = this.get(collectionName, id); - if (existing && existing.digest === digest) { - return false; - } - } - const entry: DataEntry = { - id, - data, - }; - // We do it like this so we don't waste space stringifying - // the fields if they are not set - if (body) { - entry.body = body; - } - if (filePath) { - if (filePath.startsWith('/')) { - throw new Error(`File path must be relative to the site root. Got: ${filePath}`); - } - entry.filePath = filePath; - } - if (digest) { - entry.digest = digest; - } - if (rendered) { - entry.rendered = rendered; - } - if (deferredRender) { - entry.deferredRender = deferredRender; - if (filePath) { - this.addModuleImport(filePath); - } - } - this.set(collectionName, id, entry); - return true; - }, - delete: (key: string) => this.delete(collectionName, key), - clear: () => this.clear(collectionName), - has: (key: string) => this.has(collectionName, key), - addAssetImport: (assetImport: string, fileName: string) => - this.addAssetImport(assetImport, fileName), - addAssetImports: (assets: Array, fileName: string) => - this.addAssetImports(assets, fileName), - addModuleImport: (fileName: string) => this.addModuleImport(fileName), - }; - } - /** - * Returns a MetaStore for a given collection, or if no collection is provided, the default meta collection. - */ - metaStore(collectionName = ':meta'): MetaStore { - const collectionKey = `meta:${collectionName}`; - return { - get: (key: string) => this.get(collectionKey, key), - set: (key: string, data: string) => this.set(collectionKey, key, data), - delete: (key: string) => this.delete(collectionKey, key), - has: (key: string) => this.has(collectionKey, key), - }; - } - - toString() { - return devalue.stringify(this.#collections); - } - - async writeToDisk(filePath: PathLike) { - if (!this.#dirty) { - return; - } - try { - await fs.writeFile(filePath, this.toString()); - this.#file = filePath; - this.#dirty = false; - } catch (err) { - throw new AstroError(AstroErrorData.UnknownFilesystemError, { cause: err }); - } + return this._collections; } /** @@ -363,81 +98,9 @@ export default new Map([\n${lines.join(',\n')}]); static async fromMap(data: Map>) { const store = new DataStore(); - store.#collections = data; + store._collections = data; return store; } - - static async fromString(data: string) { - const map = devalue.parse(data); - return DataStore.fromMap(map); - } - - static async fromFile(filePath: string | URL) { - try { - if (existsSync(filePath)) { - const data = await fs.readFile(filePath, 'utf-8'); - return DataStore.fromString(data); - } - } catch {} - return new DataStore(); - } -} - -export interface ScopedDataStore { - get: = Record>( - key: string, - ) => DataEntry | undefined; - entries: () => Array<[id: string, DataEntry]>; - set: >(opts: { - /** The ID of the entry. Must be unique per collection. */ - id: string; - /** The data to store. */ - data: TData; - /** The raw body of the content, if applicable. */ - body?: string; - /** The file path of the content, if applicable. Relative to the site root. */ - filePath?: string; - /** A content digest, to check if the content has changed. */ - digest?: number | string; - /** The rendered content, if applicable. */ - rendered?: RenderedContent; - /** - * If an entry is a deferred, its rendering phase is delegated to a virtual module during the runtime phase. - */ - deferredRender?: boolean; - }) => boolean; - values: () => Array; - keys: () => Array; - delete: (key: string) => void; - clear: () => void; - has: (key: string) => boolean; - /** - * @internal Adds asset imports to the store. This is used to track image imports for the build. This API is subject to change. - */ - addAssetImports: (assets: Array, fileName: string) => void; - /** - * @internal Adds an asset import to the store. This is used to track image imports for the build. This API is subject to change. - */ - addAssetImport: (assetImport: string, fileName: string) => void; - /** - * Adds a single asset to the store. This asset will be transformed - * by Vite, and the URL will be available in the final build. - * @param fileName - * @param specifier - * @returns - */ - addModuleImport: (fileName: string) => void; -} - -/** - * A key-value store for metadata strings. Useful for storing things like sync tokens. - */ - -export interface MetaStore { - get: (key: string) => string | undefined; - set: (key: string, value: string) => void; - has: (key: string) => boolean; - delete: (key: string) => void; } function dataStoreSingleton() { @@ -455,13 +118,5 @@ function dataStoreSingleton() { }; } -// TODO: find a better place to put this image -export function contentModuleToId(fileName: string) { - const params = new URLSearchParams(DEFERRED_MODULE); - params.set('fileName', fileName); - params.set(CONTENT_MODULE_FLAG, 'true'); - return `${DEFERRED_MODULE}?${params.toString()}`; -} - /** @internal */ export const globalDataStore = dataStoreSingleton(); diff --git a/packages/astro/src/content/loaders/types.ts b/packages/astro/src/content/loaders/types.ts index f372967277b7..26be0495a281 100644 --- a/packages/astro/src/content/loaders/types.ts +++ b/packages/astro/src/content/loaders/types.ts @@ -1,7 +1,7 @@ import type { FSWatcher } from 'vite'; import type { ZodSchema } from 'zod'; import type { AstroIntegrationLogger, AstroSettings } from '../../@types/astro.js'; -import type { MetaStore, ScopedDataStore } from '../data-store.js'; +import type { MetaStore, ScopedDataStore } from '../mutable-data-store.js'; export interface ParseDataOptions> { /** The ID of the entry. Unique per collection */ diff --git a/packages/astro/src/content/mutable-data-store.ts b/packages/astro/src/content/mutable-data-store.ts new file mode 100644 index 000000000000..200951848046 --- /dev/null +++ b/packages/astro/src/content/mutable-data-store.ts @@ -0,0 +1,370 @@ +import { promises as fs, type PathLike, existsSync } from 'node:fs'; +import * as devalue from 'devalue'; +import { imageSrcToImportId, importIdToSymbolName } from '../assets/utils/resolveImports.js'; +import { AstroError, AstroErrorData } from '../core/errors/index.js'; +import { type DataEntry, DataStore, type RenderedContent } from './data-store.js'; +import { contentModuleToId } from './utils.js'; + +const SAVE_DEBOUNCE_MS = 500; + +/** + * Extends the DataStore with the ability to change entries and write them to disk. + * This is kept as a separate class to avoid needing node builtins at runtime, when read-only access is all that is needed. + */ +export class MutableDataStore extends DataStore { + #file?: PathLike; + + #assetsFile?: PathLike; + #modulesFile?: PathLike; + + #saveTimeout: NodeJS.Timeout | undefined; + #assetsSaveTimeout: NodeJS.Timeout | undefined; + #modulesSaveTimeout: NodeJS.Timeout | undefined; + + #dirty = false; + #assetsDirty = false; + #modulesDirty = false; + + #assetImports = new Set(); + #moduleImports = new Map(); + + set(collectionName: string, key: string, value: unknown) { + const collection = this._collections.get(collectionName) ?? new Map(); + collection.set(String(key), value); + this._collections.set(collectionName, collection); + this.#saveToDiskDebounced(); + } + + delete(collectionName: string, key: string) { + const collection = this._collections.get(collectionName); + if (collection) { + collection.delete(String(key)); + this.#saveToDiskDebounced(); + } + } + + clear(collectionName: string) { + this._collections.delete(collectionName); + this.#saveToDiskDebounced(); + } + + clearAll() { + this._collections.clear(); + this.#saveToDiskDebounced(); + } + + addAssetImport(assetImport: string, filePath: string) { + const id = imageSrcToImportId(assetImport, filePath); + if (id) { + this.#assetImports.add(id); + // We debounce the writes to disk because addAssetImport is called for every image in every file, + // and can be called many times in quick succession by a filesystem watcher. We only want to write + // the file once, after all the imports have been added. + this.#writeAssetsImportsDebounced(); + } + } + + addAssetImports(assets: Array, filePath: string) { + assets.forEach((asset) => this.addAssetImport(asset, filePath)); + } + + addModuleImport(fileName: string) { + const id = contentModuleToId(fileName); + if (id) { + this.#moduleImports.set(fileName, id); + // We debounce the writes to disk because addAssetImport is called for every image in every file, + // and can be called many times in quick succession by a filesystem watcher. We only want to write + // the file once, after all the imports have been added. + this.#writeModulesImportsDebounced(); + } + } + + async writeAssetImports(filePath: PathLike) { + this.#assetsFile = filePath; + + if (this.#assetImports.size === 0) { + try { + await fs.writeFile(filePath, 'export default new Map();'); + } catch (err) { + throw new AstroError(AstroErrorData.UnknownFilesystemError, { cause: err }); + } + } + + if (!this.#assetsDirty && existsSync(filePath)) { + return; + } + // Import the assets, with a symbol name that is unique to the import id. The import + // for each asset is an object with path, format and dimensions. + // We then export them all, mapped by the import id, so we can find them again in the build. + const imports: Array = []; + const exports: Array = []; + this.#assetImports.forEach((id) => { + const symbol = importIdToSymbolName(id); + imports.push(`import ${symbol} from '${id}';`); + exports.push(`[${JSON.stringify(id)}, ${symbol}]`); + }); + const code = /* js */ ` +${imports.join('\n')} +export default new Map([${exports.join(', ')}]); + `; + try { + await fs.writeFile(filePath, code); + } catch (err) { + throw new AstroError(AstroErrorData.UnknownFilesystemError, { cause: err }); + } + this.#assetsDirty = false; + } + + async writeModuleImports(filePath: PathLike) { + this.#modulesFile = filePath; + + if (this.#moduleImports.size === 0) { + try { + await fs.writeFile(filePath, 'export default new Map();'); + } catch (err) { + throw new AstroError(AstroErrorData.UnknownFilesystemError, { cause: err }); + } + } + + if (!this.#modulesDirty && existsSync(filePath)) { + return; + } + + // Import the assets, with a symbol name that is unique to the import id. The import + // for each asset is an object with path, format and dimensions. + // We then export them all, mapped by the import id, so we can find them again in the build. + const lines: Array = []; + for (const [fileName, specifier] of this.#moduleImports) { + lines.push(`['${fileName}', () => import('${specifier}')]`); + } + const code = ` +export default new Map([\n${lines.join(',\n')}]); + `; + try { + await fs.writeFile(filePath, code); + } catch (err) { + throw new AstroError(AstroErrorData.UnknownFilesystemError, { cause: err }); + } + this.#modulesDirty = false; + } + + #writeAssetsImportsDebounced() { + this.#assetsDirty = true; + if (this.#assetsFile) { + if (this.#assetsSaveTimeout) { + clearTimeout(this.#assetsSaveTimeout); + } + this.#assetsSaveTimeout = setTimeout(() => { + this.#assetsSaveTimeout = undefined; + this.writeAssetImports(this.#assetsFile!); + }, SAVE_DEBOUNCE_MS); + } + } + + #writeModulesImportsDebounced() { + this.#modulesDirty = true; + if (this.#modulesFile) { + if (this.#modulesSaveTimeout) { + clearTimeout(this.#modulesSaveTimeout); + } + this.#modulesSaveTimeout = setTimeout(() => { + this.#modulesSaveTimeout = undefined; + this.writeModuleImports(this.#modulesFile!); + }, SAVE_DEBOUNCE_MS); + } + } + + #saveToDiskDebounced() { + this.#dirty = true; + // Only save to disk if it has already been saved once + if (this.#file) { + if (this.#saveTimeout) { + clearTimeout(this.#saveTimeout); + } + this.#saveTimeout = setTimeout(() => { + this.#saveTimeout = undefined; + this.writeToDisk(this.#file!); + }, SAVE_DEBOUNCE_MS); + } + } + + scopedStore(collectionName: string): ScopedDataStore { + return { + get: = Record>(key: string) => + this.get>(collectionName, key), + entries: () => this.entries(collectionName), + values: () => this.values(collectionName), + keys: () => this.keys(collectionName), + set: ({ id: key, data, body, filePath, deferredRender, digest, rendered }) => { + if (!key) { + throw new Error(`ID must be a non-empty string`); + } + const id = String(key); + if (digest) { + const existing = this.get(collectionName, id); + if (existing && existing.digest === digest) { + return false; + } + } + const entry: DataEntry = { + id, + data, + }; + // We do it like this so we don't waste space stringifying + // the fields if they are not set + if (body) { + entry.body = body; + } + if (filePath) { + if (filePath.startsWith('/')) { + throw new Error(`File path must be relative to the site root. Got: ${filePath}`); + } + entry.filePath = filePath; + } + if (digest) { + entry.digest = digest; + } + if (rendered) { + entry.rendered = rendered; + } + if (deferredRender) { + entry.deferredRender = deferredRender; + if (filePath) { + this.addModuleImport(filePath); + } + } + this.set(collectionName, id, entry); + return true; + }, + delete: (key: string) => this.delete(collectionName, key), + clear: () => this.clear(collectionName), + has: (key: string) => this.has(collectionName, key), + addAssetImport: (assetImport: string, fileName: string) => + this.addAssetImport(assetImport, fileName), + addAssetImports: (assets: Array, fileName: string) => + this.addAssetImports(assets, fileName), + addModuleImport: (fileName: string) => this.addModuleImport(fileName), + }; + } + /** + * Returns a MetaStore for a given collection, or if no collection is provided, the default meta collection. + */ + metaStore(collectionName = ':meta'): MetaStore { + const collectionKey = `meta:${collectionName}`; + return { + get: (key: string) => this.get(collectionKey, key), + set: (key: string, data: string) => this.set(collectionKey, key, data), + delete: (key: string) => this.delete(collectionKey, key), + has: (key: string) => this.has(collectionKey, key), + }; + } + + toString() { + return devalue.stringify(this._collections); + } + + async writeToDisk(filePath: PathLike) { + if (!this.#dirty) { + return; + } + try { + await fs.writeFile(filePath, this.toString()); + this.#file = filePath; + this.#dirty = false; + } catch (err) { + throw new AstroError(AstroErrorData.UnknownFilesystemError, { cause: err }); + } + } + + /** + * Attempts to load a MutableDataStore from the virtual module. + * This only works in Vite. + */ + static async fromModule() { + try { + // @ts-expect-error - this is a virtual module + const data = await import('astro:data-layer-content'); + const map = devalue.unflatten(data.default); + return MutableDataStore.fromMap(map); + } catch {} + return new MutableDataStore(); + } + + static async fromMap(data: Map>) { + const store = new MutableDataStore(); + store._collections = data; + return store; + } + + static async fromString(data: string) { + const map = devalue.parse(data); + return MutableDataStore.fromMap(map); + } + + static async fromFile(filePath: string | URL) { + try { + if (existsSync(filePath)) { + const data = await fs.readFile(filePath, 'utf-8'); + return MutableDataStore.fromString(data); + } + } catch {} + return new MutableDataStore(); + } +} + +export interface ScopedDataStore { + get: = Record>( + key: string, + ) => DataEntry | undefined; + entries: () => Array<[id: string, DataEntry]>; + set: >(opts: { + /** The ID of the entry. Must be unique per collection. */ + id: string; + /** The data to store. */ + data: TData; + /** The raw body of the content, if applicable. */ + body?: string; + /** The file path of the content, if applicable. Relative to the site root. */ + filePath?: string; + /** A content digest, to check if the content has changed. */ + digest?: number | string; + /** The rendered content, if applicable. */ + rendered?: RenderedContent; + /** + * If an entry is a deferred, its rendering phase is delegated to a virtual module during the runtime phase. + */ + deferredRender?: boolean; + }) => boolean; + values: () => Array; + keys: () => Array; + delete: (key: string) => void; + clear: () => void; + has: (key: string) => boolean; + /** + * @internal Adds asset imports to the store. This is used to track image imports for the build. This API is subject to change. + */ + addAssetImports: (assets: Array, fileName: string) => void; + /** + * @internal Adds an asset import to the store. This is used to track image imports for the build. This API is subject to change. + */ + addAssetImport: (assetImport: string, fileName: string) => void; + /** + * Adds a single asset to the store. This asset will be transformed + * by Vite, and the URL will be available in the final build. + * @param fileName + * @param specifier + * @returns + */ + addModuleImport: (fileName: string) => void; +} + +/** + * A key-value store for metadata strings. Useful for storing things like sync tokens. + */ + +export interface MetaStore { + get: (key: string) => string | undefined; + set: (key: string, value: string) => void; + has: (key: string) => boolean; + delete: (key: string) => void; +} diff --git a/packages/astro/src/content/utils.ts b/packages/astro/src/content/utils.ts index 79a37a28d02f..6d06272470d0 100644 --- a/packages/astro/src/content/utils.ts +++ b/packages/astro/src/content/utils.ts @@ -20,6 +20,7 @@ import { CONTENT_FLAGS, CONTENT_LAYER_TYPE, CONTENT_MODULE_FLAG, + DEFERRED_MODULE, IMAGE_IMPORT_PREFIX, PROPAGATED_ASSET_FLAG, } from './consts.js'; @@ -670,3 +671,10 @@ export function posixifyPath(filePath: string) { export function posixRelative(from: string, to: string) { return posixifyPath(path.relative(from, to)); } + +export function contentModuleToId(fileName: string) { + const params = new URLSearchParams(DEFERRED_MODULE); + params.set('fileName', fileName); + params.set(CONTENT_MODULE_FLAG, 'true'); + return `${DEFERRED_MODULE}?${params.toString()}`; +} diff --git a/packages/astro/src/core/dev/dev.ts b/packages/astro/src/core/dev/dev.ts index 127f34b94989..8d19356b6950 100644 --- a/packages/astro/src/core/dev/dev.ts +++ b/packages/astro/src/core/dev/dev.ts @@ -8,8 +8,8 @@ import type * as vite from 'vite'; import type { AstroInlineConfig } from '../../@types/astro.js'; import { DATA_STORE_FILE } from '../../content/consts.js'; import { globalContentLayer } from '../../content/content-layer.js'; -import { DataStore, globalDataStore } from '../../content/data-store.js'; import { attachContentServerListeners } from '../../content/index.js'; +import { MutableDataStore } from '../../content/mutable-data-store.js'; import { globalContentConfigObserver } from '../../content/utils.js'; import { telemetry } from '../../events/index.js'; import * as msg from '../messages.js'; @@ -106,19 +106,17 @@ export default async function dev(inlineConfig: AstroInlineConfig): Promise Date: Thu, 15 Aug 2024 16:52:15 +0200 Subject: [PATCH 19/30] fix: content types sync in dev (#11727) Co-authored-by: Princesseuh <3019731+Princesseuh@users.noreply.github.com> --- .changeset/ten-buckets-matter.md | 5 +++++ packages/astro/src/content/types-generator.ts | 8 +++----- packages/astro/src/core/sync/index.ts | 3 ++- 3 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 .changeset/ten-buckets-matter.md diff --git a/.changeset/ten-buckets-matter.md b/.changeset/ten-buckets-matter.md new file mode 100644 index 000000000000..b70a244a0591 --- /dev/null +++ b/.changeset/ten-buckets-matter.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes a type issue when using the Content Layer in dev diff --git a/packages/astro/src/content/types-generator.ts b/packages/astro/src/content/types-generator.ts index 973a892fa17f..faf02d95d915 100644 --- a/packages/astro/src/content/types-generator.ts +++ b/packages/astro/src/content/types-generator.ts @@ -590,11 +590,9 @@ async function writeContentFiles({ // If it's the first time, we inject types the usual way. sync() will handle creating files and references. If it's not the first time, we just override the dts content if (settings.injectedTypes.some((t) => t.filename === CONTENT_TYPES_FILE)) { - fs.promises.writeFile( - new URL(CONTENT_TYPES_FILE, settings.dotAstroDir), - typeTemplateContent, - 'utf-8', - ); + const filePath = fileURLToPath(new URL(CONTENT_TYPES_FILE, settings.dotAstroDir)); + await fs.promises.mkdir(path.dirname(filePath), { recursive: true }); + await fs.promises.writeFile(filePath, typeTemplateContent, 'utf-8'); } else { settings.injectedTypes.push({ filename: CONTENT_TYPES_FILE, diff --git a/packages/astro/src/core/sync/index.ts b/packages/astro/src/core/sync/index.ts index ce381537e2a5..aecf6c9c3d31 100644 --- a/packages/astro/src/core/sync/index.ts +++ b/packages/astro/src/core/sync/index.ts @@ -29,6 +29,7 @@ import type { Logger } from '../logger/core.js'; import { formatErrorMessage } from '../messages.js'; import { ensureProcessNodeEnv } from '../util.js'; import { writeFiles } from './write-files.js'; +import { fileURLToPath } from 'node:url'; export type SyncOptions = { /** @@ -122,7 +123,7 @@ export async function syncInternal({ }); await contentLayer.sync(); settings.timer.end('Sync content layer'); - } else if (fs.existsSync(getContentPaths(settings.config, fs).contentDir.href)) { + } else if (fs.existsSync(fileURLToPath(getContentPaths(settings.config, fs).contentDir))) { // Content is synced after writeFiles. That means references are not created // To work around it, we create a stub so the reference is created and content // sync will override the empty file From 70945dd9181e2dd021b92f3f82d66b0cd929def9 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Thu, 15 Aug 2024 16:52:26 +0200 Subject: [PATCH 20/30] refactor: enforce node prefix (#11723) --- biome.json | 10 +++++++++- package.json | 2 +- packages/astro/src/assets/endpoint/node.ts | 2 +- packages/astro/src/core/dev/dev.ts | 2 +- packages/astro/src/core/logger/vite.ts | 2 +- .../astro/src/core/preview/static-preview-server.ts | 2 +- packages/astro/src/core/routing/manifest/create.ts | 2 +- .../astro/src/vite-plugin-astro-server/response.ts | 2 +- packages/astro/test/build-readonly-file.test.js | 2 +- packages/db/src/core/integration/index.ts | 8 ++++---- packages/db/test/local-prod.test.js | 4 ++-- packages/integrations/node/src/standalone.ts | 2 +- packages/integrations/partytown/src/index.ts | 2 +- packages/integrations/sitemap/src/write-sitemap.ts | 10 +++++----- 14 files changed, 30 insertions(+), 22 deletions(-) diff --git a/biome.json b/biome.json index 2928e8f4fe3d..67e2a4620e0f 100644 --- a/biome.json +++ b/biome.json @@ -26,7 +26,15 @@ "organizeImports": { "enabled": true }, - "linter": { "enabled": false }, + "linter": { + "enabled": true, + "rules": { + "recommended": false, + "style": { + "useNodejsImportProtocol": "error" + } + } + }, "javascript": { "formatter": { "trailingCommas": "all", diff --git a/package.json b/package.json index 6958dee90d3e..850816b5e115 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "test:e2e:match": "cd packages/astro && pnpm playwright install chromium firefox && pnpm run test:e2e:match", "test:e2e:hosts": "turbo run test:hosted", "benchmark": "astro-benchmark", - "lint": "eslint . --report-unused-disable-directives", + "lint": "biome lint && eslint . --report-unused-disable-directives", "version": "changeset version && node ./scripts/deps/update-example-versions.js && pnpm install --no-frozen-lockfile && pnpm run format", "preinstall": "npx only-allow pnpm" }, diff --git a/packages/astro/src/assets/endpoint/node.ts b/packages/astro/src/assets/endpoint/node.ts index 4c50fe95fdb3..c1acc66efc15 100644 --- a/packages/astro/src/assets/endpoint/node.ts +++ b/packages/astro/src/assets/endpoint/node.ts @@ -5,7 +5,7 @@ import { fileURLToPath, pathToFileURL } from 'node:url'; // @ts-expect-error import { assetsDir, imageConfig, outDir } from 'astro:assets'; import { isRemotePath, removeQueryString } from '@astrojs/internal-helpers/path'; -import { readFile } from 'fs/promises'; +import { readFile } from 'node:fs/promises'; import * as mime from 'mrmime'; import type { APIRoute } from '../../@types/astro.js'; import { getConfiguredImageService } from '../internal.js'; diff --git a/packages/astro/src/core/dev/dev.ts b/packages/astro/src/core/dev/dev.ts index 8d19356b6950..ab1564d4e75f 100644 --- a/packages/astro/src/core/dev/dev.ts +++ b/packages/astro/src/core/dev/dev.ts @@ -2,7 +2,7 @@ import fs, { existsSync } from 'node:fs'; import type http from 'node:http'; import type { AddressInfo } from 'node:net'; import { green } from 'kleur/colors'; -import { performance } from 'perf_hooks'; +import { performance } from 'node:perf_hooks'; import { gt, major, minor, patch } from 'semver'; import type * as vite from 'vite'; import type { AstroInlineConfig } from '../../@types/astro.js'; diff --git a/packages/astro/src/core/logger/vite.ts b/packages/astro/src/core/logger/vite.ts index ed62adc8d047..f1ed49dce0d2 100644 --- a/packages/astro/src/core/logger/vite.ts +++ b/packages/astro/src/core/logger/vite.ts @@ -1,4 +1,4 @@ -import { fileURLToPath } from 'url'; +import { fileURLToPath } from 'node:url'; import stripAnsi from 'strip-ansi'; import type { LogLevel, Rollup, Logger as ViteLogger } from 'vite'; import { isAstroError } from '../errors/errors.js'; diff --git a/packages/astro/src/core/preview/static-preview-server.ts b/packages/astro/src/core/preview/static-preview-server.ts index 68ca3236b296..96afeb1b3781 100644 --- a/packages/astro/src/core/preview/static-preview-server.ts +++ b/packages/astro/src/core/preview/static-preview-server.ts @@ -1,6 +1,6 @@ import type http from 'node:http'; import { fileURLToPath } from 'node:url'; -import { performance } from 'perf_hooks'; +import { performance } from 'node:perf_hooks'; import { type PreviewServer as VitePreviewServer, preview } from 'vite'; import type { AstroSettings } from '../../@types/astro.js'; import type { Logger } from '../logger/core.js'; diff --git a/packages/astro/src/core/routing/manifest/create.ts b/packages/astro/src/core/routing/manifest/create.ts index f9c19b9ed0fd..d9a6c61b030e 100644 --- a/packages/astro/src/core/routing/manifest/create.ts +++ b/packages/astro/src/core/routing/manifest/create.ts @@ -8,7 +8,7 @@ import type { } from '../../../@types/astro.js'; import type { Logger } from '../../logger/core.js'; -import { createRequire } from 'module'; +import { createRequire } from 'node:module'; import nodeFs from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; diff --git a/packages/astro/src/vite-plugin-astro-server/response.ts b/packages/astro/src/vite-plugin-astro-server/response.ts index 2ccf1aade161..707a26e4091c 100644 --- a/packages/astro/src/vite-plugin-astro-server/response.ts +++ b/packages/astro/src/vite-plugin-astro-server/response.ts @@ -2,7 +2,7 @@ import type http from 'node:http'; import type { ErrorWithMetadata } from '../core/errors/index.js'; import type { ModuleLoader } from '../core/module-loader/index.js'; -import { Readable } from 'stream'; +import { Readable } from 'node:stream'; import { getSetCookiesFromResponse } from '../core/cookies/index.js'; import { getViteErrorPayload } from '../core/errors/dev/index.js'; import notFoundTemplate from '../template/4xx.js'; diff --git a/packages/astro/test/build-readonly-file.test.js b/packages/astro/test/build-readonly-file.test.js index bf6dd3fa4400..60b3f507be47 100644 --- a/packages/astro/test/build-readonly-file.test.js +++ b/packages/astro/test/build-readonly-file.test.js @@ -1,5 +1,5 @@ import { after, before, describe, it } from 'node:test'; -import { fileURLToPath } from 'url'; +import { fileURLToPath } from 'node:url'; import testAdapter from './test-adapter.js'; import { loadFixture } from './test-utils.js'; diff --git a/packages/db/src/core/integration/index.ts b/packages/db/src/core/integration/index.ts index 68439cfb9541..7be43c0daccb 100644 --- a/packages/db/src/core/integration/index.ts +++ b/packages/db/src/core/integration/index.ts @@ -1,11 +1,11 @@ -import { existsSync } from 'fs'; +import { existsSync } from 'node:fs'; import { parseArgs } from 'node:util'; -import { dirname } from 'path'; -import { fileURLToPath } from 'url'; +import { dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; import { type ManagedAppToken, getManagedAppTokenOrExit } from '@astrojs/studio'; import { LibsqlError } from '@libsql/client'; import type { AstroConfig, AstroIntegration } from 'astro'; -import { mkdir, writeFile } from 'fs/promises'; +import { mkdir, writeFile } from 'node:fs/promises'; import { blue, yellow } from 'kleur/colors'; import { type HMRPayload, diff --git a/packages/db/test/local-prod.test.js b/packages/db/test/local-prod.test.js index 134ee6b567bb..be67d179a3ea 100644 --- a/packages/db/test/local-prod.test.js +++ b/packages/db/test/local-prod.test.js @@ -1,7 +1,7 @@ import assert from 'node:assert/strict'; import { after, before, describe, it } from 'node:test'; -import { relative } from 'path'; -import { fileURLToPath } from 'url'; +import { relative } from 'node:path'; +import { fileURLToPath } from 'node:url'; import testAdapter from '../../astro/test/test-adapter.js'; import { loadFixture } from '../../astro/test/test-utils.js'; diff --git a/packages/integrations/node/src/standalone.ts b/packages/integrations/node/src/standalone.ts index 817ca70204fb..69db5ef2313b 100644 --- a/packages/integrations/node/src/standalone.ts +++ b/packages/integrations/node/src/standalone.ts @@ -1,4 +1,4 @@ -import https from 'https'; +import https from 'node:https'; import fs from 'node:fs'; import http from 'node:http'; import type { PreviewServer } from 'astro'; diff --git a/packages/integrations/partytown/src/index.ts b/packages/integrations/partytown/src/index.ts index bf8a6db1cbfa..9589e32a6cc1 100644 --- a/packages/integrations/partytown/src/index.ts +++ b/packages/integrations/partytown/src/index.ts @@ -1,4 +1,4 @@ -import { createRequire } from 'module'; +import { createRequire } from 'node:module'; import * as fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; diff --git a/packages/integrations/sitemap/src/write-sitemap.ts b/packages/integrations/sitemap/src/write-sitemap.ts index 8c86ae1669d2..b6a0c63c2f58 100644 --- a/packages/integrations/sitemap/src/write-sitemap.ts +++ b/packages/integrations/sitemap/src/write-sitemap.ts @@ -1,8 +1,8 @@ -import { type WriteStream, createWriteStream } from 'fs'; -import { normalize, resolve } from 'path'; -import { Readable, pipeline } from 'stream'; -import { promisify } from 'util'; -import { mkdir } from 'fs/promises'; +import { type WriteStream, createWriteStream } from 'node:fs'; +import { normalize, resolve } from 'node:path'; +import { Readable, pipeline } from 'node:stream'; +import { promisify } from 'node:util'; +import { mkdir } from 'node:fs/promises'; import replace from 'stream-replace-string'; import { SitemapAndIndexStream, SitemapStream } from 'sitemap'; From 87ce2381b6f1cc01b3532da8c09601f2118d4e43 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Thu, 15 Aug 2024 14:53:15 +0000 Subject: [PATCH 21/30] [ci] format --- packages/astro/src/assets/endpoint/node.ts | 2 +- packages/astro/src/core/dev/dev.ts | 2 +- packages/astro/src/core/preview/static-preview-server.ts | 2 +- packages/astro/src/core/routing/manifest/create.ts | 2 +- packages/astro/src/core/sync/index.ts | 2 +- packages/db/src/core/integration/index.ts | 4 ++-- packages/db/test/local-prod.test.js | 2 +- packages/integrations/node/src/standalone.ts | 2 +- packages/integrations/partytown/src/index.ts | 2 +- packages/integrations/sitemap/src/write-sitemap.ts | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/astro/src/assets/endpoint/node.ts b/packages/astro/src/assets/endpoint/node.ts index c1acc66efc15..cb3ae7806e91 100644 --- a/packages/astro/src/assets/endpoint/node.ts +++ b/packages/astro/src/assets/endpoint/node.ts @@ -1,3 +1,4 @@ +import { readFile } from 'node:fs/promises'; /* eslint-disable no-console */ import os from 'node:os'; import { isAbsolute } from 'node:path'; @@ -5,7 +6,6 @@ import { fileURLToPath, pathToFileURL } from 'node:url'; // @ts-expect-error import { assetsDir, imageConfig, outDir } from 'astro:assets'; import { isRemotePath, removeQueryString } from '@astrojs/internal-helpers/path'; -import { readFile } from 'node:fs/promises'; import * as mime from 'mrmime'; import type { APIRoute } from '../../@types/astro.js'; import { getConfiguredImageService } from '../internal.js'; diff --git a/packages/astro/src/core/dev/dev.ts b/packages/astro/src/core/dev/dev.ts index ab1564d4e75f..12b6d3b55aab 100644 --- a/packages/astro/src/core/dev/dev.ts +++ b/packages/astro/src/core/dev/dev.ts @@ -1,8 +1,8 @@ import fs, { existsSync } from 'node:fs'; import type http from 'node:http'; import type { AddressInfo } from 'node:net'; -import { green } from 'kleur/colors'; import { performance } from 'node:perf_hooks'; +import { green } from 'kleur/colors'; import { gt, major, minor, patch } from 'semver'; import type * as vite from 'vite'; import type { AstroInlineConfig } from '../../@types/astro.js'; diff --git a/packages/astro/src/core/preview/static-preview-server.ts b/packages/astro/src/core/preview/static-preview-server.ts index 96afeb1b3781..0afa34b6042e 100644 --- a/packages/astro/src/core/preview/static-preview-server.ts +++ b/packages/astro/src/core/preview/static-preview-server.ts @@ -1,6 +1,6 @@ import type http from 'node:http'; -import { fileURLToPath } from 'node:url'; import { performance } from 'node:perf_hooks'; +import { fileURLToPath } from 'node:url'; import { type PreviewServer as VitePreviewServer, preview } from 'vite'; import type { AstroSettings } from '../../@types/astro.js'; import type { Logger } from '../logger/core.js'; diff --git a/packages/astro/src/core/routing/manifest/create.ts b/packages/astro/src/core/routing/manifest/create.ts index d9a6c61b030e..df548ec8248d 100644 --- a/packages/astro/src/core/routing/manifest/create.ts +++ b/packages/astro/src/core/routing/manifest/create.ts @@ -8,8 +8,8 @@ import type { } from '../../../@types/astro.js'; import type { Logger } from '../../logger/core.js'; -import { createRequire } from 'node:module'; import nodeFs from 'node:fs'; +import { createRequire } from 'node:module'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { bold } from 'kleur/colors'; diff --git a/packages/astro/src/core/sync/index.ts b/packages/astro/src/core/sync/index.ts index aecf6c9c3d31..92b3478e344d 100644 --- a/packages/astro/src/core/sync/index.ts +++ b/packages/astro/src/core/sync/index.ts @@ -1,5 +1,6 @@ import fsMod, { existsSync } from 'node:fs'; import { performance } from 'node:perf_hooks'; +import { fileURLToPath } from 'node:url'; import { dim } from 'kleur/colors'; import { type HMRPayload, createServer } from 'vite'; import type { AstroConfig, AstroInlineConfig, AstroSettings } from '../../@types/astro.js'; @@ -29,7 +30,6 @@ import type { Logger } from '../logger/core.js'; import { formatErrorMessage } from '../messages.js'; import { ensureProcessNodeEnv } from '../util.js'; import { writeFiles } from './write-files.js'; -import { fileURLToPath } from 'node:url'; export type SyncOptions = { /** diff --git a/packages/db/src/core/integration/index.ts b/packages/db/src/core/integration/index.ts index 7be43c0daccb..c096d08af82e 100644 --- a/packages/db/src/core/integration/index.ts +++ b/packages/db/src/core/integration/index.ts @@ -1,11 +1,11 @@ import { existsSync } from 'node:fs'; -import { parseArgs } from 'node:util'; +import { mkdir, writeFile } from 'node:fs/promises'; import { dirname } from 'node:path'; import { fileURLToPath } from 'node:url'; +import { parseArgs } from 'node:util'; import { type ManagedAppToken, getManagedAppTokenOrExit } from '@astrojs/studio'; import { LibsqlError } from '@libsql/client'; import type { AstroConfig, AstroIntegration } from 'astro'; -import { mkdir, writeFile } from 'node:fs/promises'; import { blue, yellow } from 'kleur/colors'; import { type HMRPayload, diff --git a/packages/db/test/local-prod.test.js b/packages/db/test/local-prod.test.js index be67d179a3ea..6513aeb08572 100644 --- a/packages/db/test/local-prod.test.js +++ b/packages/db/test/local-prod.test.js @@ -1,6 +1,6 @@ import assert from 'node:assert/strict'; -import { after, before, describe, it } from 'node:test'; import { relative } from 'node:path'; +import { after, before, describe, it } from 'node:test'; import { fileURLToPath } from 'node:url'; import testAdapter from '../../astro/test/test-adapter.js'; import { loadFixture } from '../../astro/test/test-utils.js'; diff --git a/packages/integrations/node/src/standalone.ts b/packages/integrations/node/src/standalone.ts index 69db5ef2313b..76e672d2fc36 100644 --- a/packages/integrations/node/src/standalone.ts +++ b/packages/integrations/node/src/standalone.ts @@ -1,6 +1,6 @@ -import https from 'node:https'; import fs from 'node:fs'; import http from 'node:http'; +import https from 'node:https'; import type { PreviewServer } from 'astro'; import type { NodeApp } from 'astro/app/node'; import enableDestroy from 'server-destroy'; diff --git a/packages/integrations/partytown/src/index.ts b/packages/integrations/partytown/src/index.ts index 9589e32a6cc1..739ff0e4b9b4 100644 --- a/packages/integrations/partytown/src/index.ts +++ b/packages/integrations/partytown/src/index.ts @@ -1,5 +1,5 @@ -import { createRequire } from 'node:module'; import * as fs from 'node:fs'; +import { createRequire } from 'node:module'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; import type { PartytownConfig } from '@builder.io/partytown/integration'; diff --git a/packages/integrations/sitemap/src/write-sitemap.ts b/packages/integrations/sitemap/src/write-sitemap.ts index b6a0c63c2f58..4c189ee3c990 100644 --- a/packages/integrations/sitemap/src/write-sitemap.ts +++ b/packages/integrations/sitemap/src/write-sitemap.ts @@ -1,8 +1,8 @@ import { type WriteStream, createWriteStream } from 'node:fs'; +import { mkdir } from 'node:fs/promises'; import { normalize, resolve } from 'node:path'; import { Readable, pipeline } from 'node:stream'; import { promisify } from 'node:util'; -import { mkdir } from 'node:fs/promises'; import replace from 'stream-replace-string'; import { SitemapAndIndexStream, SitemapStream } from 'sitemap'; From 91d36fa36bc8c5ca3e27c72b85399d1eb150c872 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Thu, 15 Aug 2024 08:06:43 -0700 Subject: [PATCH 22/30] [ci] release (#11719) Co-authored-by: github-actions[bot] --- .changeset/fresh-tigers-cheat.md | 5 -- .changeset/hot-dodos-whisper.md | 7 --- .changeset/ten-buckets-matter.md | 5 -- examples/basics/package.json | 2 +- examples/blog/package.json | 2 +- examples/component/package.json | 2 +- examples/container-with-vitest/package.json | 2 +- examples/framework-alpine/package.json | 2 +- examples/framework-lit/package.json | 2 +- examples/framework-multiple/package.json | 2 +- examples/framework-preact/package.json | 2 +- examples/framework-react/package.json | 2 +- examples/framework-solid/package.json | 2 +- examples/framework-svelte/package.json | 2 +- examples/framework-vue/package.json | 2 +- examples/hackernews/package.json | 2 +- examples/integration/package.json | 2 +- examples/middleware/package.json | 2 +- examples/minimal/package.json | 2 +- examples/non-html-pages/package.json | 2 +- examples/portfolio/package.json | 2 +- examples/server-islands/package.json | 2 +- examples/ssr/package.json | 2 +- examples/starlog/package.json | 2 +- examples/toolbar-app/package.json | 2 +- examples/view-transitions/package.json | 2 +- examples/with-markdoc/package.json | 2 +- examples/with-markdown-plugins/package.json | 2 +- examples/with-markdown-shiki/package.json | 2 +- examples/with-mdx/package.json | 2 +- examples/with-nanostores/package.json | 2 +- examples/with-tailwindcss/package.json | 2 +- examples/with-vitest/package.json | 2 +- packages/astro/CHANGELOG.md | 12 +++++ packages/astro/package.json | 2 +- pnpm-lock.yaml | 60 ++++++++++----------- 36 files changed, 73 insertions(+), 78 deletions(-) delete mode 100644 .changeset/fresh-tigers-cheat.md delete mode 100644 .changeset/hot-dodos-whisper.md delete mode 100644 .changeset/ten-buckets-matter.md diff --git a/.changeset/fresh-tigers-cheat.md b/.changeset/fresh-tigers-cheat.md deleted file mode 100644 index 32dbccebd1de..000000000000 --- a/.changeset/fresh-tigers-cheat.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Prevents content layer importing node builtins in runtime diff --git a/.changeset/hot-dodos-whisper.md b/.changeset/hot-dodos-whisper.md deleted file mode 100644 index 07398058f292..000000000000 --- a/.changeset/hot-dodos-whisper.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'astro': patch ---- - -Prevent errant HTML from crashing server islands - -When an HTML minifier strips away the server island comment, the script can't correctly know where the end of the fallback content is. This makes it so that it simply doesn't remove any DOM in that scenario. This means the fallback isn't removed, but it also doesn't crash the browser. diff --git a/.changeset/ten-buckets-matter.md b/.changeset/ten-buckets-matter.md deleted file mode 100644 index b70a244a0591..000000000000 --- a/.changeset/ten-buckets-matter.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes a type issue when using the Content Layer in dev diff --git a/examples/basics/package.json b/examples/basics/package.json index ea1fe90c0839..08868cdadfba 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.14.0" + "astro": "^4.14.1" } } diff --git a/examples/blog/package.json b/examples/blog/package.json index 76f9b97fe0a6..1f8e5af6e151 100644 --- a/examples/blog/package.json +++ b/examples/blog/package.json @@ -14,6 +14,6 @@ "@astrojs/mdx": "^3.1.3", "@astrojs/rss": "^4.0.7", "@astrojs/sitemap": "^3.1.6", - "astro": "^4.14.0" + "astro": "^4.14.1" } } diff --git a/examples/component/package.json b/examples/component/package.json index 4e31293b2224..86ee213d7411 100644 --- a/examples/component/package.json +++ b/examples/component/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.14.0" + "astro": "^4.14.1" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/container-with-vitest/package.json b/examples/container-with-vitest/package.json index 0d7e206da76a..be5562e9b841 100644 --- a/examples/container-with-vitest/package.json +++ b/examples/container-with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest run" }, "dependencies": { - "astro": "^4.14.0", + "astro": "^4.14.1", "@astrojs/react": "^3.6.2", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/framework-alpine/package.json b/examples/framework-alpine/package.json index 0a48c7eeb86c..97625ebbf3ff 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.14.0" + "astro": "^4.14.1" } } diff --git a/examples/framework-lit/package.json b/examples/framework-lit/package.json index 9a9aee995dc7..592caf172d41 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.14.0", + "astro": "^4.14.1", "lit": "^3.2.0" } } diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json index 7e71917c49de..ae2bb7d5439c 100644 --- a/examples/framework-multiple/package.json +++ b/examples/framework-multiple/package.json @@ -18,7 +18,7 @@ "@astrojs/vue": "^4.5.0", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", - "astro": "^4.14.0", + "astro": "^4.14.1", "preact": "^10.23.1", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/framework-preact/package.json b/examples/framework-preact/package.json index 9d372fc0cfd6..2c962c87cb12 100644 --- a/examples/framework-preact/package.json +++ b/examples/framework-preact/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.5.1", "@preact/signals": "^1.3.0", - "astro": "^4.14.0", + "astro": "^4.14.1", "preact": "^10.23.1" } } diff --git a/examples/framework-react/package.json b/examples/framework-react/package.json index 85eebf19dcb5..eb74ea33a599 100644 --- a/examples/framework-react/package.json +++ b/examples/framework-react/package.json @@ -14,7 +14,7 @@ "@astrojs/react": "^3.6.2", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", - "astro": "^4.14.0", + "astro": "^4.14.1", "react": "^18.3.1", "react-dom": "^18.3.1" } diff --git a/examples/framework-solid/package.json b/examples/framework-solid/package.json index e6ff05289e8d..57d5dced25d1 100644 --- a/examples/framework-solid/package.json +++ b/examples/framework-solid/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/solid-js": "^4.4.1", - "astro": "^4.14.0", + "astro": "^4.14.1", "solid-js": "^1.8.20" } } diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json index 8ba82634cd64..472078dac4e7 100644 --- a/examples/framework-svelte/package.json +++ b/examples/framework-svelte/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/svelte": "^5.7.0", - "astro": "^4.14.0", + "astro": "^4.14.1", "svelte": "^4.2.18" } } diff --git a/examples/framework-vue/package.json b/examples/framework-vue/package.json index 47e1350f8b6c..b0109ba3985d 100644 --- a/examples/framework-vue/package.json +++ b/examples/framework-vue/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/vue": "^4.5.0", - "astro": "^4.14.0", + "astro": "^4.14.1", "vue": "^3.4.37" } } diff --git a/examples/hackernews/package.json b/examples/hackernews/package.json index 3995d8cc108d..0769ac6b2977 100644 --- a/examples/hackernews/package.json +++ b/examples/hackernews/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/node": "^8.3.3", - "astro": "^4.14.0" + "astro": "^4.14.1" } } diff --git a/examples/integration/package.json b/examples/integration/package.json index ee2571c17c5d..36b2da876cca 100644 --- a/examples/integration/package.json +++ b/examples/integration/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.14.0" + "astro": "^4.14.1" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/middleware/package.json b/examples/middleware/package.json index 990761c2f89f..7c028461316e 100644 --- a/examples/middleware/package.json +++ b/examples/middleware/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@astrojs/node": "^8.3.3", - "astro": "^4.14.0", + "astro": "^4.14.1", "html-minifier": "^4.0.0" }, "devDependencies": { diff --git a/examples/minimal/package.json b/examples/minimal/package.json index 27cf53e00a94..a40a78756134 100644 --- a/examples/minimal/package.json +++ b/examples/minimal/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.14.0" + "astro": "^4.14.1" } } diff --git a/examples/non-html-pages/package.json b/examples/non-html-pages/package.json index 43813bbcda64..bf00519699b2 100644 --- a/examples/non-html-pages/package.json +++ b/examples/non-html-pages/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.14.0" + "astro": "^4.14.1" } } diff --git a/examples/portfolio/package.json b/examples/portfolio/package.json index e16e5e93190f..9cff3186c2ac 100644 --- a/examples/portfolio/package.json +++ b/examples/portfolio/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.14.0" + "astro": "^4.14.1" } } diff --git a/examples/server-islands/package.json b/examples/server-islands/package.json index b4e66b951a21..09c3a1d377ca 100644 --- a/examples/server-islands/package.json +++ b/examples/server-islands/package.json @@ -17,7 +17,7 @@ "@tailwindcss/forms": "^0.5.7", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", - "astro": "^4.14.0", + "astro": "^4.14.1", "postcss": "^8.4.41", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/ssr/package.json b/examples/ssr/package.json index 5251c90c317b..a1f828779c30 100644 --- a/examples/ssr/package.json +++ b/examples/ssr/package.json @@ -14,7 +14,7 @@ "dependencies": { "@astrojs/node": "^8.3.3", "@astrojs/svelte": "^5.7.0", - "astro": "^4.14.0", + "astro": "^4.14.1", "svelte": "^4.2.18" } } diff --git a/examples/starlog/package.json b/examples/starlog/package.json index 2cff7650bdec..9d61795310c9 100644 --- a/examples/starlog/package.json +++ b/examples/starlog/package.json @@ -10,7 +10,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.14.0", + "astro": "^4.14.1", "sass": "^1.77.8", "sharp": "^0.33.3" } diff --git a/examples/toolbar-app/package.json b/examples/toolbar-app/package.json index 73537e8ab8c8..bfb0f17ecde2 100644 --- a/examples/toolbar-app/package.json +++ b/examples/toolbar-app/package.json @@ -15,6 +15,6 @@ "./app": "./dist/app.js" }, "devDependencies": { - "astro": "^4.14.0" + "astro": "^4.14.1" } } diff --git a/examples/view-transitions/package.json b/examples/view-transitions/package.json index 0e05cd1420de..dfcdf86c296e 100644 --- a/examples/view-transitions/package.json +++ b/examples/view-transitions/package.json @@ -12,6 +12,6 @@ "devDependencies": { "@astrojs/tailwind": "^5.1.0", "@astrojs/node": "^8.3.3", - "astro": "^4.14.0" + "astro": "^4.14.1" } } diff --git a/examples/with-markdoc/package.json b/examples/with-markdoc/package.json index ddf843fae7d7..b0914c2b8610 100644 --- a/examples/with-markdoc/package.json +++ b/examples/with-markdoc/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/markdoc": "^0.11.3", - "astro": "^4.14.0" + "astro": "^4.14.1" } } diff --git a/examples/with-markdown-plugins/package.json b/examples/with-markdown-plugins/package.json index 641a8cb8c18e..b84a26fd0ef2 100644 --- a/examples/with-markdown-plugins/package.json +++ b/examples/with-markdown-plugins/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/markdown-remark": "^5.2.0", - "astro": "^4.14.0", + "astro": "^4.14.1", "hast-util-select": "^6.0.2", "rehype-autolink-headings": "^7.1.0", "rehype-slug": "^6.0.0", diff --git a/examples/with-markdown-shiki/package.json b/examples/with-markdown-shiki/package.json index 71eca6318cd8..0c49f34b2a39 100644 --- a/examples/with-markdown-shiki/package.json +++ b/examples/with-markdown-shiki/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.14.0" + "astro": "^4.14.1" } } diff --git a/examples/with-mdx/package.json b/examples/with-mdx/package.json index 23a57015bdd9..80c142c438bb 100644 --- a/examples/with-mdx/package.json +++ b/examples/with-mdx/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/mdx": "^3.1.3", "@astrojs/preact": "^3.5.1", - "astro": "^4.14.0", + "astro": "^4.14.1", "preact": "^10.23.1" } } diff --git a/examples/with-nanostores/package.json b/examples/with-nanostores/package.json index f700f300dcfc..4b7009566feb 100644 --- a/examples/with-nanostores/package.json +++ b/examples/with-nanostores/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.5.1", "@nanostores/preact": "^0.5.2", - "astro": "^4.14.0", + "astro": "^4.14.1", "nanostores": "^0.11.2", "preact": "^10.23.1" } diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index 5f8e023b121d..c744d8e05149 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -14,7 +14,7 @@ "@astrojs/mdx": "^3.1.3", "@astrojs/tailwind": "^5.1.0", "@types/canvas-confetti": "^1.6.4", - "astro": "^4.14.0", + "astro": "^4.14.1", "autoprefixer": "^10.4.20", "canvas-confetti": "^1.9.3", "postcss": "^8.4.41", diff --git a/examples/with-vitest/package.json b/examples/with-vitest/package.json index 15a3f58d02b8..eb0cf46cf1e8 100644 --- a/examples/with-vitest/package.json +++ b/examples/with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest" }, "dependencies": { - "astro": "^4.14.0", + "astro": "^4.14.1", "vitest": "^2.0.5" } } diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index 8f6e75407232..e7417b655c8d 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,17 @@ # astro +## 4.14.1 + +### Patch Changes + +- [#11725](https://github.com/withastro/astro/pull/11725) [`6c1560f`](https://github.com/withastro/astro/commit/6c1560fb0d19ce659bc9f9090f8050254d5c03f3) Thanks [@ascorbic](https://github.com/ascorbic)! - Prevents content layer importing node builtins in runtime + +- [#11692](https://github.com/withastro/astro/pull/11692) [`35af73a`](https://github.com/withastro/astro/commit/35af73aace97a7cc898b9aa5040db8bc2ac62687) Thanks [@matthewp](https://github.com/matthewp)! - Prevent errant HTML from crashing server islands + + When an HTML minifier strips away the server island comment, the script can't correctly know where the end of the fallback content is. This makes it so that it simply doesn't remove any DOM in that scenario. This means the fallback isn't removed, but it also doesn't crash the browser. + +- [#11727](https://github.com/withastro/astro/pull/11727) [`3c2f93b`](https://github.com/withastro/astro/commit/3c2f93b66c6b8e9d2ab58e2cbe941c14ffab89b5) Thanks [@florian-lefebvre](https://github.com/florian-lefebvre)! - Fixes a type issue when using the Content Layer in dev + ## 4.14.0 ### Minor Changes diff --git a/packages/astro/package.json b/packages/astro/package.json index e8f53ee8f25d..2e7657517032 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "4.14.0", + "version": "4.14.1", "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.", "type": "module", "author": "withastro", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c83e577de097..5c902e1084cd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -116,7 +116,7 @@ importers: examples/basics: dependencies: astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro examples/blog: @@ -131,13 +131,13 @@ importers: specifier: ^3.1.6 version: link:../../packages/integrations/sitemap astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro examples/component: devDependencies: astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro examples/container-with-vitest: @@ -146,7 +146,7 @@ importers: specifier: ^3.6.2 version: link:../../packages/integrations/react astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro react: specifier: ^18.3.1 @@ -177,7 +177,7 @@ importers: specifier: ^3.14.1 version: 3.14.1 astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro examples/framework-lit: @@ -189,7 +189,7 @@ importers: specifier: ^0.2.1 version: 0.2.1 astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro lit: specifier: ^3.2.0 @@ -219,7 +219,7 @@ importers: specifier: ^18.3.0 version: 18.3.0 astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro preact: specifier: ^10.23.1 @@ -249,7 +249,7 @@ importers: specifier: ^1.3.0 version: 1.3.0(preact@10.23.1) astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro preact: specifier: ^10.23.1 @@ -267,7 +267,7 @@ importers: specifier: ^18.3.0 version: 18.3.0 astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro react: specifier: ^18.3.1 @@ -282,7 +282,7 @@ importers: specifier: ^4.4.1 version: link:../../packages/integrations/solid astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro solid-js: specifier: ^1.8.20 @@ -294,7 +294,7 @@ importers: specifier: ^5.7.0 version: link:../../packages/integrations/svelte astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro svelte: specifier: ^4.2.18 @@ -306,7 +306,7 @@ importers: specifier: ^4.5.0 version: link:../../packages/integrations/vue astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro vue: specifier: ^3.4.37 @@ -318,13 +318,13 @@ importers: specifier: ^8.3.3 version: link:../../packages/integrations/node astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro examples/integration: devDependencies: astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro examples/middleware: @@ -333,7 +333,7 @@ importers: specifier: ^8.3.3 version: link:../../packages/integrations/node astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro html-minifier: specifier: ^4.0.0 @@ -346,19 +346,19 @@ importers: examples/minimal: dependencies: astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro examples/non-html-pages: dependencies: astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro examples/portfolio: dependencies: astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro examples/server-islands: @@ -385,7 +385,7 @@ importers: specifier: ^18.3.0 version: 18.3.0 astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro postcss: specifier: ^8.4.41 @@ -409,7 +409,7 @@ importers: specifier: ^5.7.0 version: link:../../packages/integrations/svelte astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro svelte: specifier: ^4.2.18 @@ -418,7 +418,7 @@ importers: examples/starlog: dependencies: astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro sass: specifier: ^1.77.8 @@ -430,7 +430,7 @@ importers: examples/toolbar-app: devDependencies: astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro examples/view-transitions: @@ -442,7 +442,7 @@ importers: specifier: ^5.1.0 version: link:../../packages/integrations/tailwind astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro examples/with-markdoc: @@ -451,7 +451,7 @@ importers: specifier: ^0.11.3 version: link:../../packages/integrations/markdoc astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro examples/with-markdown-plugins: @@ -460,7 +460,7 @@ importers: specifier: ^5.2.0 version: link:../../packages/markdown/remark astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro hast-util-select: specifier: ^6.0.2 @@ -481,7 +481,7 @@ importers: examples/with-markdown-shiki: dependencies: astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro examples/with-mdx: @@ -493,7 +493,7 @@ importers: specifier: ^3.5.1 version: link:../../packages/integrations/preact astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro preact: specifier: ^10.23.1 @@ -508,7 +508,7 @@ importers: specifier: ^0.5.2 version: 0.5.2(nanostores@0.11.2)(preact@10.23.1) astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro nanostores: specifier: ^0.11.2 @@ -529,7 +529,7 @@ importers: specifier: ^1.6.4 version: 1.6.4 astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro autoprefixer: specifier: ^10.4.20 @@ -547,7 +547,7 @@ importers: examples/with-vitest: dependencies: astro: - specifier: ^4.14.0 + specifier: ^4.14.1 version: link:../../packages/astro vitest: specifier: ^2.0.5 From 391324df969db71d1c7ca25c2ed14c9eb6eea5ee Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Fri, 16 Aug 2024 00:27:08 +0800 Subject: [PATCH 23/30] Revert parseArgs change (#11733) --- .changeset/famous-dolls-grin.md | 6 ++ .changeset/wild-trainers-matter.md | 6 ++ packages/astro/package.json | 4 +- packages/astro/src/cli/check/index.ts | 2 +- packages/astro/src/cli/db/index.ts | 22 ++--- packages/astro/src/cli/flags.ts | 8 +- packages/astro/src/cli/index.ts | 37 +++----- packages/create-astro/src/actions/context.ts | 91 ++++++++----------- packages/db/package.json | 2 + .../db/src/core/cli/commands/execute/index.ts | 4 +- .../db/src/core/cli/commands/login/index.ts | 4 +- .../db/src/core/cli/commands/push/index.ts | 4 +- .../db/src/core/cli/commands/shell/index.ts | 4 +- .../db/src/core/cli/commands/verify/index.ts | 4 +- packages/db/src/core/cli/index.ts | 4 +- packages/db/src/core/cli/types.ts | 4 +- packages/db/src/core/integration/index.ts | 6 +- packages/upgrade/src/actions/context.ts | 28 +++--- packages/upgrade/test/context.test.js | 4 +- pnpm-lock.yaml | 19 ++++ 20 files changed, 131 insertions(+), 132 deletions(-) create mode 100644 .changeset/famous-dolls-grin.md create mode 100644 .changeset/wild-trainers-matter.md diff --git a/.changeset/famous-dolls-grin.md b/.changeset/famous-dolls-grin.md new file mode 100644 index 000000000000..0070ee43bfe7 --- /dev/null +++ b/.changeset/famous-dolls-grin.md @@ -0,0 +1,6 @@ +--- +'create-astro': patch +'@astrojs/db': patch +--- + +Reverts back to `arg` package for CLI argument parsing diff --git a/.changeset/wild-trainers-matter.md b/.changeset/wild-trainers-matter.md new file mode 100644 index 000000000000..daf3cd9e5323 --- /dev/null +++ b/.changeset/wild-trainers-matter.md @@ -0,0 +1,6 @@ +--- +'astro': patch +'@astrojs/db': patch +--- + +Reverts back to `yargs-parser` package for CLI argument parsing diff --git a/packages/astro/package.json b/packages/astro/package.json index 2e7657517032..6da1e12e7fe0 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -133,8 +133,8 @@ "@babel/plugin-transform-react-jsx": "^7.25.2", "@babel/traverse": "^7.25.3", "@babel/types": "^7.25.2", - "@rollup/pluginutils": "^5.1.0", "@oslojs/encoding": "^0.4.1", + "@rollup/pluginutils": "^5.1.0", "@types/babel__core": "^7.20.5", "@types/cookie": "^0.6.0", "acorn": "^8.12.1", @@ -186,6 +186,7 @@ "vitefu": "^0.2.5", "which-pm": "^3.0.0", "xxhash-wasm": "^1.0.2", + "yargs-parser": "^21.1.1", "zod": "^3.23.8", "zod-to-json-schema": "^3.23.2", "zod-to-ts": "^1.2.0" @@ -212,6 +213,7 @@ "@types/micromatch": "^4.0.9", "@types/prompts": "^2.4.9", "@types/semver": "^7.5.8", + "@types/yargs-parser": "^21.0.3", "astro-scripts": "workspace:*", "cheerio": "1.0.0", "eol": "^0.9.1", diff --git a/packages/astro/src/cli/check/index.ts b/packages/astro/src/cli/check/index.ts index 9a354c8e00a5..c93e3b2f4cff 100644 --- a/packages/astro/src/cli/check/index.ts +++ b/packages/astro/src/cli/check/index.ts @@ -8,7 +8,7 @@ export async function check(flags: Flags) { const logger = createLoggerFromFlags(flags); const getPackageOpts = { skipAsk: !!flags.yes || !!flags.y, - cwd: typeof flags.root == 'string' ? flags.root : undefined, + cwd: flags.root, }; const checkPackage = await getPackage( '@astrojs/check', diff --git a/packages/astro/src/cli/db/index.ts b/packages/astro/src/cli/db/index.ts index c6be7411bb2a..ae97e498f8c0 100644 --- a/packages/astro/src/cli/db/index.ts +++ b/packages/astro/src/cli/db/index.ts @@ -1,25 +1,20 @@ +import type { Arguments } from 'yargs-parser'; import type { AstroConfig } from '../../@types/astro.js'; import { resolveConfig } from '../../core/config/config.js'; import { apply as applyPolyfill } from '../../core/polyfill.js'; -import { type Flags, createLoggerFromFlags, flagsToAstroInlineConfig } from '../flags.js'; +import { createLoggerFromFlags, flagsToAstroInlineConfig } from '../flags.js'; import { getPackage } from '../install-package.js'; -interface YargsArguments { - _: Array; - '--'?: Array; - [argName: string]: any; -} - type DBPackage = { - cli: (args: { flags: YargsArguments; config: AstroConfig }) => unknown; + cli: (args: { flags: Arguments; config: AstroConfig }) => unknown; }; -export async function db({ positionals, flags }: { positionals: string[]; flags: Flags }) { +export async function db({ flags }: { flags: Arguments }) { applyPolyfill(); const logger = createLoggerFromFlags(flags); const getPackageOpts = { skipAsk: !!flags.yes || !!flags.y, - cwd: typeof flags.root == 'string' ? flags.root : undefined, + cwd: flags.root, }; const dbPackage = await getPackage('@astrojs/db', logger, getPackageOpts, []); @@ -35,10 +30,5 @@ export async function db({ positionals, flags }: { positionals: string[]; flags: const inlineConfig = flagsToAstroInlineConfig(flags); const { astroConfig } = await resolveConfig(inlineConfig, 'build'); - const yargsArgs: YargsArguments = { - _: positionals, - ...flags, - }; - - await cli({ flags: yargsArgs, config: astroConfig }); + await cli({ flags, config: astroConfig }); } diff --git a/packages/astro/src/cli/flags.ts b/packages/astro/src/cli/flags.ts index 59dfbf00a4bd..9d57c03166e3 100644 --- a/packages/astro/src/cli/flags.ts +++ b/packages/astro/src/cli/flags.ts @@ -1,10 +1,10 @@ -import type { parseArgs } from 'node:util'; +import type { Arguments } from 'yargs-parser'; import type { AstroInlineConfig } from '../@types/astro.js'; import { type LogOptions, Logger } from '../core/logger/core.js'; import { nodeLogDestination } from '../core/logger/node.js'; -export type ParsedArgsResult = ReturnType; -export type Flags = ParsedArgsResult['values']; +// Alias for now, but allows easier migration to node's `parseArgs` in the future. +export type Flags = Arguments; export function flagsToAstroInlineConfig(flags: Flags): AstroInlineConfig { return { @@ -20,7 +20,7 @@ export function flagsToAstroInlineConfig(flags: Flags): AstroInlineConfig { base: typeof flags.base === 'string' ? flags.base : undefined, outDir: typeof flags.outDir === 'string' ? flags.outDir : undefined, server: { - port: typeof flags.port === 'string' ? Number(flags.port) : undefined, + port: typeof flags.port === 'number' ? flags.port : undefined, host: typeof flags.host === 'string' || typeof flags.host === 'boolean' ? flags.host : undefined, open: diff --git a/packages/astro/src/cli/index.ts b/packages/astro/src/cli/index.ts index b3a819e586eb..c767569fde51 100644 --- a/packages/astro/src/cli/index.ts +++ b/packages/astro/src/cli/index.ts @@ -1,8 +1,7 @@ -import { parseArgs } from 'node:util'; /* eslint-disable no-console */ import * as colors from 'kleur/colors'; +import yargs from 'yargs-parser'; import { ASTRO_VERSION } from '../core/constants.js'; -import type { ParsedArgsResult } from './flags.js'; type CLICommand = | 'help' @@ -66,9 +65,9 @@ function printVersion() { } /** Determine which command the user requested */ -function resolveCommand(args: ParsedArgsResult): CLICommand { - const cmd = args.positionals[2] as string; - if (args.values.version) return 'version'; +function resolveCommand(flags: yargs.Arguments): CLICommand { + const cmd = flags._[2] as string; + if (flags.version) return 'version'; const supportedCommands = new Set([ 'add', @@ -98,9 +97,7 @@ function resolveCommand(args: ParsedArgsResult): CLICommand { * NOTE: This function provides no error handling, so be sure * to present user-friendly error output where the fn is called. **/ -async function runCommand(cmd: string, args: ParsedArgsResult) { - const flags = args.values; - +async function runCommand(cmd: string, flags: yargs.Arguments) { // These commands can run directly without parsing the user config. switch (cmd) { case 'help': @@ -123,7 +120,7 @@ async function runCommand(cmd: string, args: ParsedArgsResult) { // Do not track session start, since the user may be trying to enable, // disable, or modify telemetry settings. const { update } = await import('./telemetry/index.js'); - const subcommand = args.positionals[3]; + const subcommand = flags._[3]?.toString(); await update(subcommand, { flags }); return; } @@ -134,7 +131,7 @@ async function runCommand(cmd: string, args: ParsedArgsResult) { } case 'preferences': { const { preferences } = await import('./preferences/index.js'); - const [subcommand, key, value] = args.positionals.slice(3); + const [subcommand, key, value] = flags._.slice(3).map((v) => v.toString()); const exitCode = await preferences(subcommand, key, value, { flags }); return process.exit(exitCode); } @@ -154,7 +151,7 @@ async function runCommand(cmd: string, args: ParsedArgsResult) { switch (cmd) { case 'add': { const { add } = await import('./add/index.js'); - const packages = args.positionals.slice(3); + const packages = flags._.slice(3) as string[]; await add(packages, { flags }); return; } @@ -164,7 +161,7 @@ async function runCommand(cmd: string, args: ParsedArgsResult) { case 'link': case 'init': { const { db } = await import('./db/index.js'); - await db({ positionals: args.positionals, flags }); + await db({ flags }); return; } case 'dev': { @@ -205,20 +202,10 @@ async function runCommand(cmd: string, args: ParsedArgsResult) { /** The primary CLI action */ export async function cli(argv: string[]) { - const args = parseArgs({ - args: argv, - allowPositionals: true, - strict: false, - options: { - global: { type: 'boolean', short: 'g' }, - host: { type: 'string' }, // Can be boolean too, which is covered by `strict: false` - open: { type: 'string' }, // Can be boolean too, which is covered by `strict: false` - // TODO: Add more flags here - }, - }); - const cmd = resolveCommand(args); + const flags = yargs(argv, { boolean: ['global'], alias: { g: 'global' } }); + const cmd = resolveCommand(flags); try { - await runCommand(cmd, args); + await runCommand(cmd, flags); } catch (err) { const { throwAndExit } = await import('./throw-and-exit.js'); await throwAndExit(cmd, err); diff --git a/packages/create-astro/src/actions/context.ts b/packages/create-astro/src/actions/context.ts index bf1b522bd3bd..83a13eda7c94 100644 --- a/packages/create-astro/src/actions/context.ts +++ b/packages/create-astro/src/actions/context.ts @@ -1,7 +1,7 @@ import os from 'node:os'; -import { parseArgs } from 'node:util'; import { type Task, prompt } from '@astrojs/cli-kit'; import { random } from '@astrojs/cli-kit/utils'; +import arg from 'arg'; import getSeasonalData from '../data/seasonal.js'; import { getName, getVersion } from '../messages.js'; @@ -33,44 +33,47 @@ export interface Context { } export async function getContext(argv: string[]): Promise { - const args = parseArgs({ - args: argv, - allowPositionals: true, - strict: false, - options: { - template: { type: 'string' }, - ref: { type: 'string' }, - yes: { type: 'boolean', short: 'y' }, - no: { type: 'boolean', short: 'n' }, - install: { type: 'boolean' }, - 'no-install': { type: 'boolean' }, - git: { type: 'boolean' }, - 'no-git': { type: 'boolean' }, - typescript: { type: 'string' }, - 'skip-houston': { type: 'boolean' }, - 'dry-run': { type: 'boolean' }, - help: { type: 'boolean', short: 'h' }, - fancy: { type: 'boolean' }, + const flags = arg( + { + '--template': String, + '--ref': String, + '--yes': Boolean, + '--no': Boolean, + '--install': Boolean, + '--no-install': Boolean, + '--git': Boolean, + '--no-git': Boolean, + '--typescript': String, + '--skip-houston': Boolean, + '--dry-run': Boolean, + '--help': Boolean, + '--fancy': Boolean, + + '-y': '--yes', + '-n': '--no', + '-h': '--help', }, - }); + { argv, permissive: true }, + ); const packageManager = detectPackageManager() ?? 'npm'; - const projectName = args.positionals[0]; + let cwd = flags['_'][0]; let { - help, - template, - no, - yes, - install, - 'no-install': noInstall, - git, - 'no-git': noGit, - typescript, - fancy, - 'skip-houston': skipHouston, - 'dry-run': dryRun, - ref, - } = args.values; + '--help': help = false, + '--template': template, + '--no': no, + '--yes': yes, + '--install': install, + '--no-install': noInstall, + '--git': git, + '--no-git': noGit, + '--typescript': typescript, + '--fancy': fancy, + '--skip-houston': skipHouston, + '--dry-run': dryRun, + '--ref': ref, + } = flags; + let projectName = cwd; if (no) { yes = false; @@ -79,26 +82,10 @@ export async function getContext(argv: string[]): Promise { if (typescript == undefined) typescript = 'strict'; } - skipHouston = typeof skipHouston == 'boolean' ? skipHouston : undefined; skipHouston = ((os.platform() === 'win32' && !fancy) || skipHouston) ?? [yes, no, install, git, typescript].some((v) => v !== undefined); - // We use `strict: false` in `parseArgs` to allow unknown options, but Node also - // simply doesn't guarantee the types anymore, so we need to validate ourselves :( - help = !!help; - template = typeof template == 'string' ? template : undefined; - no = !!no; - yes = !!yes; - install = !!install; - noInstall = !!noInstall; - git = !!git; - noGit = !!noGit; - typescript = typeof typescript == 'string' ? typescript : undefined; - fancy = !!fancy; - dryRun = !!dryRun; - ref = typeof ref == 'string' ? ref : undefined; - const { messages, hats, ties } = getSeasonalData({ fancy }); const context: Context = { @@ -120,7 +107,7 @@ export async function getContext(argv: string[]): Promise { install: install ?? (noInstall ? false : undefined), git: git ?? (noGit ? false : undefined), typescript, - cwd: projectName, + cwd, exit(code) { process.exit(code); }, diff --git a/packages/db/package.json b/packages/db/package.json index b92e47fe6162..adc6fde648c1 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -81,11 +81,13 @@ "ora": "^8.0.1", "prompts": "^2.4.2", "strip-ansi": "^7.1.0", + "yargs-parser": "^21.1.1", "zod": "^3.23.8" }, "devDependencies": { "@types/deep-diff": "^1.0.5", "@types/prompts": "^2.4.9", + "@types/yargs-parser": "^21.0.3", "astro": "workspace:*", "astro-scripts": "workspace:*", "cheerio": "1.0.0", diff --git a/packages/db/src/core/cli/commands/execute/index.ts b/packages/db/src/core/cli/commands/execute/index.ts index 03b3d00adda2..c6c11cdbb6b9 100644 --- a/packages/db/src/core/cli/commands/execute/index.ts +++ b/packages/db/src/core/cli/commands/execute/index.ts @@ -3,6 +3,7 @@ import { getManagedAppTokenOrExit } from '@astrojs/studio'; import { LibsqlError } from '@libsql/client'; import type { AstroConfig } from 'astro'; import { green } from 'kleur/colors'; +import type { Arguments } from 'yargs-parser'; import { EXEC_DEFAULT_EXPORT_ERROR, EXEC_ERROR, @@ -15,7 +16,6 @@ import { } from '../../../integration/vite-plugin-db.js'; import { bundleFile, importBundledFile } from '../../../load-file.js'; import type { DBConfig } from '../../../types.js'; -import type { YargsArguments } from '../../types.js'; export async function cmd({ astroConfig, @@ -24,7 +24,7 @@ export async function cmd({ }: { astroConfig: AstroConfig; dbConfig: DBConfig; - flags: YargsArguments; + flags: Arguments; }) { const filePath = flags._[4]; if (typeof filePath !== 'string') { diff --git a/packages/db/src/core/cli/commands/login/index.ts b/packages/db/src/core/cli/commands/login/index.ts index 251d61e05433..61f7e0275b15 100644 --- a/packages/db/src/core/cli/commands/login/index.ts +++ b/packages/db/src/core/cli/commands/login/index.ts @@ -7,8 +7,8 @@ import { cyan } from 'kleur/colors'; import open from 'open'; import ora from 'ora'; import prompt from 'prompts'; +import type { Arguments } from 'yargs-parser'; import type { DBConfig } from '../../../types.js'; -import type { YargsArguments } from '../../types.js'; const isWebContainer = // Stackblitz heuristic @@ -21,7 +21,7 @@ export async function cmd({ }: { astroConfig: AstroConfig; dbConfig: DBConfig; - flags: YargsArguments; + flags: Arguments; }) { let session = flags.session; diff --git a/packages/db/src/core/cli/commands/push/index.ts b/packages/db/src/core/cli/commands/push/index.ts index 237f7f6ea29e..ecd101ecea79 100644 --- a/packages/db/src/core/cli/commands/push/index.ts +++ b/packages/db/src/core/cli/commands/push/index.ts @@ -1,6 +1,7 @@ import { getManagedAppTokenOrExit } from '@astrojs/studio'; import type { AstroConfig } from 'astro'; import prompts from 'prompts'; +import type { Arguments } from 'yargs-parser'; import { safeFetch } from '../../../../runtime/utils.js'; import { MIGRATION_VERSION } from '../../../consts.js'; import { type DBConfig, type DBSnapshot } from '../../../types.js'; @@ -12,7 +13,6 @@ import { getMigrationQueries, getProductionCurrentSnapshot, } from '../../migration-queries.js'; -import type { YargsArguments } from '../../types.js'; export async function cmd({ dbConfig, @@ -20,7 +20,7 @@ export async function cmd({ }: { astroConfig: AstroConfig; dbConfig: DBConfig; - flags: YargsArguments; + flags: Arguments; }) { const isDryRun = flags.dryRun; const isForceReset = flags.forceReset; diff --git a/packages/db/src/core/cli/commands/shell/index.ts b/packages/db/src/core/cli/commands/shell/index.ts index 5a6bcaa53d1b..e0a1a6086c4f 100644 --- a/packages/db/src/core/cli/commands/shell/index.ts +++ b/packages/db/src/core/cli/commands/shell/index.ts @@ -1,6 +1,7 @@ import { getManagedAppTokenOrExit } from '@astrojs/studio'; import type { AstroConfig } from 'astro'; import { sql } from 'drizzle-orm'; +import type { Arguments } from 'yargs-parser'; import { createLocalDatabaseClient, createRemoteDatabaseClient, @@ -10,7 +11,6 @@ import { DB_PATH } from '../../../consts.js'; import { SHELL_QUERY_MISSING_ERROR } from '../../../errors.js'; import type { DBConfigInput } from '../../../types.js'; import { getAstroEnv, getRemoteDatabaseUrl } from '../../../utils.js'; -import type { YargsArguments } from '../../types.js'; export async function cmd({ flags, @@ -18,7 +18,7 @@ export async function cmd({ }: { dbConfig: DBConfigInput; astroConfig: AstroConfig; - flags: YargsArguments; + flags: Arguments; }) { const query = flags.query; if (!query) { diff --git a/packages/db/src/core/cli/commands/verify/index.ts b/packages/db/src/core/cli/commands/verify/index.ts index 081c8ae3f8ec..950fb661567c 100644 --- a/packages/db/src/core/cli/commands/verify/index.ts +++ b/packages/db/src/core/cli/commands/verify/index.ts @@ -1,5 +1,6 @@ import { getManagedAppTokenOrExit } from '@astrojs/studio'; import type { AstroConfig } from 'astro'; +import type { Arguments } from 'yargs-parser'; import type { DBConfig } from '../../../types.js'; import { createCurrentSnapshot, @@ -8,7 +9,6 @@ import { getMigrationQueries, getProductionCurrentSnapshot, } from '../../migration-queries.js'; -import type { YargsArguments } from '../../types.js'; export async function cmd({ dbConfig, @@ -16,7 +16,7 @@ export async function cmd({ }: { astroConfig: AstroConfig; dbConfig: DBConfig; - flags: YargsArguments; + flags: Arguments; }) { const isJson = flags.json; const appToken = await getManagedAppTokenOrExit(flags.token); diff --git a/packages/db/src/core/cli/index.ts b/packages/db/src/core/cli/index.ts index 5d9aa10e97dd..531b016a6b77 100644 --- a/packages/db/src/core/cli/index.ts +++ b/packages/db/src/core/cli/index.ts @@ -1,13 +1,13 @@ import type { AstroConfig } from 'astro'; +import type { Arguments } from 'yargs-parser'; import { resolveDbConfig } from '../load-file.js'; import { printHelp } from './print-help.js'; -import type { YargsArguments } from './types.js'; export async function cli({ flags, config: astroConfig, }: { - flags: YargsArguments; + flags: Arguments; config: AstroConfig; }) { const args = flags._ as string[]; diff --git a/packages/db/src/core/cli/types.ts b/packages/db/src/core/cli/types.ts index 9d8aad56b78f..4294c3fb0289 100644 --- a/packages/db/src/core/cli/types.ts +++ b/packages/db/src/core/cli/types.ts @@ -1,6 +1,4 @@ -// Copy of `yargs-parser` `Arguments` type. We don't use `yargs-parser` -// in runtime anymore, but our exposed API still relies on this shape. -export interface YargsArguments { +export interface Arguments { _: Array; '--'?: Array; [argName: string]: any; diff --git a/packages/db/src/core/integration/index.ts b/packages/db/src/core/integration/index.ts index c096d08af82e..da03e71f27cb 100644 --- a/packages/db/src/core/integration/index.ts +++ b/packages/db/src/core/integration/index.ts @@ -2,7 +2,6 @@ import { existsSync } from 'node:fs'; import { mkdir, writeFile } from 'node:fs/promises'; import { dirname } from 'node:path'; import { fileURLToPath } from 'node:url'; -import { parseArgs } from 'node:util'; import { type ManagedAppToken, getManagedAppTokenOrExit } from '@astrojs/studio'; import { LibsqlError } from '@libsql/client'; import type { AstroConfig, AstroIntegration } from 'astro'; @@ -15,6 +14,7 @@ import { loadEnv, mergeConfig, } from 'vite'; +import parseArgs from 'yargs-parser'; import { AstroDbError } from '../../runtime/utils.js'; import { CONFIG_FILE_NAMES, DB_PATH } from '../consts.js'; import { EXEC_DEFAULT_EXPORT_ERROR, EXEC_ERROR } from '../errors.js'; @@ -71,8 +71,8 @@ function astroDBIntegration(): AstroIntegration { if (command === 'preview') return; let dbPlugin: VitePlugin | undefined = undefined; - const args = parseArgs({ strict: false }); - connectToStudio = !!process.env.ASTRO_INTERNAL_TEST_REMOTE || !!args.values.remote; + const args = parseArgs(process.argv.slice(3)); + connectToStudio = process.env.ASTRO_INTERNAL_TEST_REMOTE || args['remote']; if (connectToStudio) { appToken = await getManagedAppTokenOrExit(); diff --git a/packages/upgrade/src/actions/context.ts b/packages/upgrade/src/actions/context.ts index cd9028e85a54..2103a53277e2 100644 --- a/packages/upgrade/src/actions/context.ts +++ b/packages/upgrade/src/actions/context.ts @@ -1,13 +1,13 @@ import { pathToFileURL } from 'node:url'; -import { parseArgs } from 'node:util'; import { prompt } from '@astrojs/cli-kit'; +import arg from 'arg'; import detectPackageManager from 'preferred-pm'; export interface Context { help: boolean; prompt: typeof prompt; version: string; - dryRun: boolean; + dryRun?: boolean; cwd: URL; stdin?: typeof process.stdin; stdout?: typeof process.stdout; @@ -28,20 +28,22 @@ export interface PackageInfo { } export async function getContext(argv: string[]): Promise { - const args = parseArgs({ - args: argv, - allowPositionals: true, - strict: false, - options: { - 'dry-run': { type: 'boolean' }, - help: { type: 'boolean', short: 'h' }, + const flags = arg( + { + '--dry-run': Boolean, + '--help': Boolean, + + '-h': '--help', }, - }); + { argv, permissive: true }, + ); const packageManager = (await detectPackageManager(process.cwd()))?.name ?? 'npm'; - const version = args.positionals[0] ?? 'latest'; - const help = !!args.values.help; - const dryRun = !!args.values['dry-run']; + const { + _: [version = 'latest'] = [], + '--help': help = false, + '--dry-run': dryRun, + } = flags; return { help, diff --git a/packages/upgrade/test/context.test.js b/packages/upgrade/test/context.test.js index 5ba484740f89..bbc887c2ae3c 100644 --- a/packages/upgrade/test/context.test.js +++ b/packages/upgrade/test/context.test.js @@ -6,12 +6,12 @@ describe('context', () => { it('no arguments', async () => { const ctx = await getContext([]); assert.equal(ctx.version, 'latest'); - assert.equal(ctx.dryRun, false); + assert.equal(ctx.dryRun, undefined); }); it('tag', async () => { const ctx = await getContext(['beta']); assert.equal(ctx.version, 'beta'); - assert.equal(ctx.dryRun, false); + assert.equal(ctx.dryRun, undefined); }); it('dry run', async () => { const ctx = await getContext(['--dry-run']); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5c902e1084cd..48b1f14e6da1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -744,6 +744,9 @@ importers: xxhash-wasm: specifier: ^1.0.2 version: 1.0.2 + yargs-parser: + specifier: ^21.1.1 + version: 21.1.1 zod: specifier: ^3.23.8 version: 3.23.8 @@ -812,6 +815,9 @@ importers: '@types/semver': specifier: ^7.5.8 version: 7.5.8 + '@types/yargs-parser': + specifier: ^21.0.3 + version: 21.0.3 astro-scripts: specifier: workspace:* version: link:../../scripts @@ -4306,6 +4312,9 @@ importers: strip-ansi: specifier: ^7.1.0 version: 7.1.0 + yargs-parser: + specifier: ^21.1.1 + version: 21.1.1 zod: specifier: ^3.23.8 version: 3.23.8 @@ -4316,6 +4325,9 @@ importers: '@types/prompts': specifier: ^2.4.9 version: 2.4.9 + '@types/yargs-parser': + specifier: ^21.0.3 + version: 21.0.3 astro: specifier: workspace:* version: link:../astro @@ -7598,6 +7610,9 @@ packages: '@types/xml2js@0.4.14': resolution: {integrity: sha512-4YnrRemBShWRO2QjvUin8ESA41rH+9nQGLUGZV/1IDhi3SL9OhdpNC/MrulTWuptXKwhx/aDxE7toV0f/ypIXQ==} + '@types/yargs-parser@21.0.3': + resolution: {integrity: sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==} + '@typescript-eslint/eslint-plugin@8.0.1': resolution: {integrity: sha512-5g3Y7GDFsJAnY4Yhvk8sZtFfV6YNF2caLzjrRPUBzewjPCaj0yokePB4LJSobyCzGMzjZZYFbwuzbfDHlimXbQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -9479,10 +9494,12 @@ packages: libsql@0.3.19: resolution: {integrity: sha512-Aj5cQ5uk/6fHdmeW0TiXK42FqUlwx7ytmMLPSaUQPin5HKKKuUPD62MAbN4OEweGBBI7q1BekoEN4gPUEL6MZA==} + cpu: [x64, arm64, wasm32] os: [darwin, linux, win32] libsql@0.4.1: resolution: {integrity: sha512-qZlR9Yu1zMBeLChzkE/cKfoKV3Esp9cn9Vx5Zirn4AVhDWPcjYhKwbtJcMuHehgk3mH+fJr9qW+3vesBWbQpBg==} + cpu: [x64, arm64, wasm32] os: [darwin, linux, win32] lilconfig@2.1.0: @@ -13557,6 +13574,8 @@ snapshots: dependencies: '@types/node': 18.19.31 + '@types/yargs-parser@21.0.3': {} + '@typescript-eslint/eslint-plugin@8.0.1(@typescript-eslint/parser@8.0.1(eslint@9.9.0(jiti@1.21.0))(typescript@5.5.4))(eslint@9.9.0(jiti@1.21.0))(typescript@5.5.4)': dependencies: '@eslint-community/regexpp': 4.11.0 From 7c6349beca2859d22ea6a1b4b9388ad43ad8bff1 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Fri, 16 Aug 2024 00:32:53 +0800 Subject: [PATCH 24/30] Fix astro upgrade changeset (#11735) --- .changeset/famous-dolls-grin.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/famous-dolls-grin.md b/.changeset/famous-dolls-grin.md index 0070ee43bfe7..dbbe8887fa07 100644 --- a/.changeset/famous-dolls-grin.md +++ b/.changeset/famous-dolls-grin.md @@ -1,6 +1,6 @@ --- 'create-astro': patch -'@astrojs/db': patch +'@astrojs/upgrade': patch --- Reverts back to `arg` package for CLI argument parsing From 0109690c3b4103c56bce40b3193a19cf05c5f4e2 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Thu, 15 Aug 2024 09:34:37 -0700 Subject: [PATCH 25/30] [ci] release (#11734) Co-authored-by: github-actions[bot] --- .changeset/famous-dolls-grin.md | 6 -- .changeset/wild-trainers-matter.md | 6 -- examples/basics/package.json | 2 +- examples/blog/package.json | 2 +- examples/component/package.json | 2 +- examples/container-with-vitest/package.json | 2 +- examples/framework-alpine/package.json | 2 +- examples/framework-lit/package.json | 2 +- examples/framework-multiple/package.json | 2 +- examples/framework-preact/package.json | 2 +- examples/framework-react/package.json | 2 +- examples/framework-solid/package.json | 2 +- examples/framework-svelte/package.json | 2 +- examples/framework-vue/package.json | 2 +- examples/hackernews/package.json | 2 +- examples/integration/package.json | 2 +- examples/middleware/package.json | 2 +- examples/minimal/package.json | 2 +- examples/non-html-pages/package.json | 2 +- examples/portfolio/package.json | 2 +- examples/server-islands/package.json | 2 +- examples/ssr/package.json | 2 +- examples/starlog/package.json | 2 +- examples/toolbar-app/package.json | 2 +- examples/view-transitions/package.json | 2 +- examples/with-markdoc/package.json | 2 +- examples/with-markdown-plugins/package.json | 2 +- examples/with-markdown-shiki/package.json | 2 +- examples/with-mdx/package.json | 2 +- examples/with-nanostores/package.json | 2 +- examples/with-tailwindcss/package.json | 2 +- examples/with-vitest/package.json | 2 +- packages/astro/CHANGELOG.md | 6 ++ packages/astro/package.json | 2 +- packages/create-astro/CHANGELOG.md | 6 ++ packages/create-astro/package.json | 2 +- packages/db/CHANGELOG.md | 9 +++ packages/db/package.json | 2 +- packages/upgrade/CHANGELOG.md | 6 ++ packages/upgrade/package.json | 2 +- pnpm-lock.yaml | 62 ++++++++++----------- 41 files changed, 91 insertions(+), 78 deletions(-) delete mode 100644 .changeset/famous-dolls-grin.md delete mode 100644 .changeset/wild-trainers-matter.md diff --git a/.changeset/famous-dolls-grin.md b/.changeset/famous-dolls-grin.md deleted file mode 100644 index dbbe8887fa07..000000000000 --- a/.changeset/famous-dolls-grin.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'create-astro': patch -'@astrojs/upgrade': patch ---- - -Reverts back to `arg` package for CLI argument parsing diff --git a/.changeset/wild-trainers-matter.md b/.changeset/wild-trainers-matter.md deleted file mode 100644 index daf3cd9e5323..000000000000 --- a/.changeset/wild-trainers-matter.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'astro': patch -'@astrojs/db': patch ---- - -Reverts back to `yargs-parser` package for CLI argument parsing diff --git a/examples/basics/package.json b/examples/basics/package.json index 08868cdadfba..be4bf81ad1c6 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.14.1" + "astro": "^4.14.2" } } diff --git a/examples/blog/package.json b/examples/blog/package.json index 1f8e5af6e151..2b248d3a8d29 100644 --- a/examples/blog/package.json +++ b/examples/blog/package.json @@ -14,6 +14,6 @@ "@astrojs/mdx": "^3.1.3", "@astrojs/rss": "^4.0.7", "@astrojs/sitemap": "^3.1.6", - "astro": "^4.14.1" + "astro": "^4.14.2" } } diff --git a/examples/component/package.json b/examples/component/package.json index 86ee213d7411..3d2e2bead498 100644 --- a/examples/component/package.json +++ b/examples/component/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.14.1" + "astro": "^4.14.2" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/container-with-vitest/package.json b/examples/container-with-vitest/package.json index be5562e9b841..1c673234054c 100644 --- a/examples/container-with-vitest/package.json +++ b/examples/container-with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest run" }, "dependencies": { - "astro": "^4.14.1", + "astro": "^4.14.2", "@astrojs/react": "^3.6.2", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/framework-alpine/package.json b/examples/framework-alpine/package.json index 97625ebbf3ff..03cfff656dbf 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.14.1" + "astro": "^4.14.2" } } diff --git a/examples/framework-lit/package.json b/examples/framework-lit/package.json index 592caf172d41..cdb7d272a4e7 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.14.1", + "astro": "^4.14.2", "lit": "^3.2.0" } } diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json index ae2bb7d5439c..626962d02e99 100644 --- a/examples/framework-multiple/package.json +++ b/examples/framework-multiple/package.json @@ -18,7 +18,7 @@ "@astrojs/vue": "^4.5.0", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", - "astro": "^4.14.1", + "astro": "^4.14.2", "preact": "^10.23.1", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/framework-preact/package.json b/examples/framework-preact/package.json index 2c962c87cb12..d7169d6cc2e9 100644 --- a/examples/framework-preact/package.json +++ b/examples/framework-preact/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.5.1", "@preact/signals": "^1.3.0", - "astro": "^4.14.1", + "astro": "^4.14.2", "preact": "^10.23.1" } } diff --git a/examples/framework-react/package.json b/examples/framework-react/package.json index eb74ea33a599..4fbde09c6476 100644 --- a/examples/framework-react/package.json +++ b/examples/framework-react/package.json @@ -14,7 +14,7 @@ "@astrojs/react": "^3.6.2", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", - "astro": "^4.14.1", + "astro": "^4.14.2", "react": "^18.3.1", "react-dom": "^18.3.1" } diff --git a/examples/framework-solid/package.json b/examples/framework-solid/package.json index 57d5dced25d1..cc583f052e6e 100644 --- a/examples/framework-solid/package.json +++ b/examples/framework-solid/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/solid-js": "^4.4.1", - "astro": "^4.14.1", + "astro": "^4.14.2", "solid-js": "^1.8.20" } } diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json index 472078dac4e7..42a99cd2473a 100644 --- a/examples/framework-svelte/package.json +++ b/examples/framework-svelte/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/svelte": "^5.7.0", - "astro": "^4.14.1", + "astro": "^4.14.2", "svelte": "^4.2.18" } } diff --git a/examples/framework-vue/package.json b/examples/framework-vue/package.json index b0109ba3985d..1bff3df25d21 100644 --- a/examples/framework-vue/package.json +++ b/examples/framework-vue/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/vue": "^4.5.0", - "astro": "^4.14.1", + "astro": "^4.14.2", "vue": "^3.4.37" } } diff --git a/examples/hackernews/package.json b/examples/hackernews/package.json index 0769ac6b2977..bc5ee46b2c2b 100644 --- a/examples/hackernews/package.json +++ b/examples/hackernews/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/node": "^8.3.3", - "astro": "^4.14.1" + "astro": "^4.14.2" } } diff --git a/examples/integration/package.json b/examples/integration/package.json index 36b2da876cca..d8225462a805 100644 --- a/examples/integration/package.json +++ b/examples/integration/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.14.1" + "astro": "^4.14.2" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/middleware/package.json b/examples/middleware/package.json index 7c028461316e..db80ba2fe233 100644 --- a/examples/middleware/package.json +++ b/examples/middleware/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@astrojs/node": "^8.3.3", - "astro": "^4.14.1", + "astro": "^4.14.2", "html-minifier": "^4.0.0" }, "devDependencies": { diff --git a/examples/minimal/package.json b/examples/minimal/package.json index a40a78756134..129a0e1c68d6 100644 --- a/examples/minimal/package.json +++ b/examples/minimal/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.14.1" + "astro": "^4.14.2" } } diff --git a/examples/non-html-pages/package.json b/examples/non-html-pages/package.json index bf00519699b2..14750d84118e 100644 --- a/examples/non-html-pages/package.json +++ b/examples/non-html-pages/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.14.1" + "astro": "^4.14.2" } } diff --git a/examples/portfolio/package.json b/examples/portfolio/package.json index 9cff3186c2ac..22e75e1419ea 100644 --- a/examples/portfolio/package.json +++ b/examples/portfolio/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.14.1" + "astro": "^4.14.2" } } diff --git a/examples/server-islands/package.json b/examples/server-islands/package.json index 09c3a1d377ca..a3bf732943f2 100644 --- a/examples/server-islands/package.json +++ b/examples/server-islands/package.json @@ -17,7 +17,7 @@ "@tailwindcss/forms": "^0.5.7", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", - "astro": "^4.14.1", + "astro": "^4.14.2", "postcss": "^8.4.41", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/ssr/package.json b/examples/ssr/package.json index a1f828779c30..d35df0ec4c56 100644 --- a/examples/ssr/package.json +++ b/examples/ssr/package.json @@ -14,7 +14,7 @@ "dependencies": { "@astrojs/node": "^8.3.3", "@astrojs/svelte": "^5.7.0", - "astro": "^4.14.1", + "astro": "^4.14.2", "svelte": "^4.2.18" } } diff --git a/examples/starlog/package.json b/examples/starlog/package.json index 9d61795310c9..905df4a69dfe 100644 --- a/examples/starlog/package.json +++ b/examples/starlog/package.json @@ -10,7 +10,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.14.1", + "astro": "^4.14.2", "sass": "^1.77.8", "sharp": "^0.33.3" } diff --git a/examples/toolbar-app/package.json b/examples/toolbar-app/package.json index bfb0f17ecde2..d08c29bca229 100644 --- a/examples/toolbar-app/package.json +++ b/examples/toolbar-app/package.json @@ -15,6 +15,6 @@ "./app": "./dist/app.js" }, "devDependencies": { - "astro": "^4.14.1" + "astro": "^4.14.2" } } diff --git a/examples/view-transitions/package.json b/examples/view-transitions/package.json index dfcdf86c296e..7448b9ec0a8f 100644 --- a/examples/view-transitions/package.json +++ b/examples/view-transitions/package.json @@ -12,6 +12,6 @@ "devDependencies": { "@astrojs/tailwind": "^5.1.0", "@astrojs/node": "^8.3.3", - "astro": "^4.14.1" + "astro": "^4.14.2" } } diff --git a/examples/with-markdoc/package.json b/examples/with-markdoc/package.json index b0914c2b8610..1af3bc63c152 100644 --- a/examples/with-markdoc/package.json +++ b/examples/with-markdoc/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/markdoc": "^0.11.3", - "astro": "^4.14.1" + "astro": "^4.14.2" } } diff --git a/examples/with-markdown-plugins/package.json b/examples/with-markdown-plugins/package.json index b84a26fd0ef2..61f1253458f9 100644 --- a/examples/with-markdown-plugins/package.json +++ b/examples/with-markdown-plugins/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/markdown-remark": "^5.2.0", - "astro": "^4.14.1", + "astro": "^4.14.2", "hast-util-select": "^6.0.2", "rehype-autolink-headings": "^7.1.0", "rehype-slug": "^6.0.0", diff --git a/examples/with-markdown-shiki/package.json b/examples/with-markdown-shiki/package.json index 0c49f34b2a39..e1486a376a88 100644 --- a/examples/with-markdown-shiki/package.json +++ b/examples/with-markdown-shiki/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.14.1" + "astro": "^4.14.2" } } diff --git a/examples/with-mdx/package.json b/examples/with-mdx/package.json index 80c142c438bb..934959975cd8 100644 --- a/examples/with-mdx/package.json +++ b/examples/with-mdx/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/mdx": "^3.1.3", "@astrojs/preact": "^3.5.1", - "astro": "^4.14.1", + "astro": "^4.14.2", "preact": "^10.23.1" } } diff --git a/examples/with-nanostores/package.json b/examples/with-nanostores/package.json index 4b7009566feb..b8db777b4225 100644 --- a/examples/with-nanostores/package.json +++ b/examples/with-nanostores/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.5.1", "@nanostores/preact": "^0.5.2", - "astro": "^4.14.1", + "astro": "^4.14.2", "nanostores": "^0.11.2", "preact": "^10.23.1" } diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index c744d8e05149..80ba691d86c0 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -14,7 +14,7 @@ "@astrojs/mdx": "^3.1.3", "@astrojs/tailwind": "^5.1.0", "@types/canvas-confetti": "^1.6.4", - "astro": "^4.14.1", + "astro": "^4.14.2", "autoprefixer": "^10.4.20", "canvas-confetti": "^1.9.3", "postcss": "^8.4.41", diff --git a/examples/with-vitest/package.json b/examples/with-vitest/package.json index eb0cf46cf1e8..88956a94eb43 100644 --- a/examples/with-vitest/package.json +++ b/examples/with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest" }, "dependencies": { - "astro": "^4.14.1", + "astro": "^4.14.2", "vitest": "^2.0.5" } } diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index e7417b655c8d..5c93709a4b30 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,11 @@ # astro +## 4.14.2 + +### Patch Changes + +- [#11733](https://github.com/withastro/astro/pull/11733) [`391324d`](https://github.com/withastro/astro/commit/391324df969db71d1c7ca25c2ed14c9eb6eea5ee) Thanks [@bluwy](https://github.com/bluwy)! - Reverts back to `yargs-parser` package for CLI argument parsing + ## 4.14.1 ### Patch Changes diff --git a/packages/astro/package.json b/packages/astro/package.json index 6da1e12e7fe0..9fac8c9b704a 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "4.14.1", + "version": "4.14.2", "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.", "type": "module", "author": "withastro", diff --git a/packages/create-astro/CHANGELOG.md b/packages/create-astro/CHANGELOG.md index 600e9f8e63fd..19ae5f93f39c 100644 --- a/packages/create-astro/CHANGELOG.md +++ b/packages/create-astro/CHANGELOG.md @@ -1,5 +1,11 @@ # create-astro +## 4.8.3 + +### Patch Changes + +- [#11733](https://github.com/withastro/astro/pull/11733) [`391324d`](https://github.com/withastro/astro/commit/391324df969db71d1c7ca25c2ed14c9eb6eea5ee) Thanks [@bluwy](https://github.com/bluwy)! - Reverts back to `arg` package for CLI argument parsing + ## 4.8.2 ### Patch Changes diff --git a/packages/create-astro/package.json b/packages/create-astro/package.json index 79cea9ce9394..e22a738fae2a 100644 --- a/packages/create-astro/package.json +++ b/packages/create-astro/package.json @@ -1,6 +1,6 @@ { "name": "create-astro", - "version": "4.8.2", + "version": "4.8.3", "type": "module", "author": "withastro", "license": "MIT", diff --git a/packages/db/CHANGELOG.md b/packages/db/CHANGELOG.md index 046d3305ba4c..9fcc870d39ef 100644 --- a/packages/db/CHANGELOG.md +++ b/packages/db/CHANGELOG.md @@ -1,5 +1,14 @@ # @astrojs/db +## 0.13.1 + +### Patch Changes + +- [#11733](https://github.com/withastro/astro/pull/11733) [`391324d`](https://github.com/withastro/astro/commit/391324df969db71d1c7ca25c2ed14c9eb6eea5ee) Thanks [@bluwy](https://github.com/bluwy)! - Reverts back to `yargs-parser` package for CLI argument parsing + +- Updated dependencies []: + - @astrojs/studio@0.1.1 + ## 0.13.0 ### Minor Changes diff --git a/packages/db/package.json b/packages/db/package.json index adc6fde648c1..5f82fa910477 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -1,6 +1,6 @@ { "name": "@astrojs/db", - "version": "0.13.0", + "version": "0.13.1", "description": "Add libSQL and Astro Studio support to your Astro site", "license": "MIT", "repository": { diff --git a/packages/upgrade/CHANGELOG.md b/packages/upgrade/CHANGELOG.md index b0c80a869145..2156497a7909 100644 --- a/packages/upgrade/CHANGELOG.md +++ b/packages/upgrade/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/upgrade +## 0.3.3 + +### Patch Changes + +- [#11733](https://github.com/withastro/astro/pull/11733) [`391324d`](https://github.com/withastro/astro/commit/391324df969db71d1c7ca25c2ed14c9eb6eea5ee) Thanks [@bluwy](https://github.com/bluwy)! - Reverts back to `arg` package for CLI argument parsing + ## 0.3.2 ### Patch Changes diff --git a/packages/upgrade/package.json b/packages/upgrade/package.json index 3f005e1f8e3e..286a0be7813c 100644 --- a/packages/upgrade/package.json +++ b/packages/upgrade/package.json @@ -1,6 +1,6 @@ { "name": "@astrojs/upgrade", - "version": "0.3.2", + "version": "0.3.3", "type": "module", "author": "withastro", "license": "MIT", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 48b1f14e6da1..64c206e7e8f1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -116,7 +116,7 @@ importers: examples/basics: dependencies: astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro examples/blog: @@ -131,13 +131,13 @@ importers: specifier: ^3.1.6 version: link:../../packages/integrations/sitemap astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro examples/component: devDependencies: astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro examples/container-with-vitest: @@ -146,7 +146,7 @@ importers: specifier: ^3.6.2 version: link:../../packages/integrations/react astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro react: specifier: ^18.3.1 @@ -177,7 +177,7 @@ importers: specifier: ^3.14.1 version: 3.14.1 astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro examples/framework-lit: @@ -189,7 +189,7 @@ importers: specifier: ^0.2.1 version: 0.2.1 astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro lit: specifier: ^3.2.0 @@ -219,7 +219,7 @@ importers: specifier: ^18.3.0 version: 18.3.0 astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro preact: specifier: ^10.23.1 @@ -249,7 +249,7 @@ importers: specifier: ^1.3.0 version: 1.3.0(preact@10.23.1) astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro preact: specifier: ^10.23.1 @@ -267,7 +267,7 @@ importers: specifier: ^18.3.0 version: 18.3.0 astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro react: specifier: ^18.3.1 @@ -282,7 +282,7 @@ importers: specifier: ^4.4.1 version: link:../../packages/integrations/solid astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro solid-js: specifier: ^1.8.20 @@ -294,7 +294,7 @@ importers: specifier: ^5.7.0 version: link:../../packages/integrations/svelte astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro svelte: specifier: ^4.2.18 @@ -306,7 +306,7 @@ importers: specifier: ^4.5.0 version: link:../../packages/integrations/vue astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro vue: specifier: ^3.4.37 @@ -318,13 +318,13 @@ importers: specifier: ^8.3.3 version: link:../../packages/integrations/node astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro examples/integration: devDependencies: astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro examples/middleware: @@ -333,7 +333,7 @@ importers: specifier: ^8.3.3 version: link:../../packages/integrations/node astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro html-minifier: specifier: ^4.0.0 @@ -346,19 +346,19 @@ importers: examples/minimal: dependencies: astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro examples/non-html-pages: dependencies: astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro examples/portfolio: dependencies: astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro examples/server-islands: @@ -385,7 +385,7 @@ importers: specifier: ^18.3.0 version: 18.3.0 astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro postcss: specifier: ^8.4.41 @@ -409,7 +409,7 @@ importers: specifier: ^5.7.0 version: link:../../packages/integrations/svelte astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro svelte: specifier: ^4.2.18 @@ -418,7 +418,7 @@ importers: examples/starlog: dependencies: astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro sass: specifier: ^1.77.8 @@ -430,7 +430,7 @@ importers: examples/toolbar-app: devDependencies: astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro examples/view-transitions: @@ -442,7 +442,7 @@ importers: specifier: ^5.1.0 version: link:../../packages/integrations/tailwind astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro examples/with-markdoc: @@ -451,7 +451,7 @@ importers: specifier: ^0.11.3 version: link:../../packages/integrations/markdoc astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro examples/with-markdown-plugins: @@ -460,7 +460,7 @@ importers: specifier: ^5.2.0 version: link:../../packages/markdown/remark astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro hast-util-select: specifier: ^6.0.2 @@ -481,7 +481,7 @@ importers: examples/with-markdown-shiki: dependencies: astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro examples/with-mdx: @@ -493,7 +493,7 @@ importers: specifier: ^3.5.1 version: link:../../packages/integrations/preact astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro preact: specifier: ^10.23.1 @@ -508,7 +508,7 @@ importers: specifier: ^0.5.2 version: 0.5.2(nanostores@0.11.2)(preact@10.23.1) astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro nanostores: specifier: ^0.11.2 @@ -529,7 +529,7 @@ importers: specifier: ^1.6.4 version: 1.6.4 astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro autoprefixer: specifier: ^10.4.20 @@ -547,7 +547,7 @@ importers: examples/with-vitest: dependencies: astro: - specifier: ^4.14.1 + specifier: ^4.14.2 version: link:../../packages/astro vitest: specifier: ^2.0.5 @@ -9494,12 +9494,10 @@ packages: libsql@0.3.19: resolution: {integrity: sha512-Aj5cQ5uk/6fHdmeW0TiXK42FqUlwx7ytmMLPSaUQPin5HKKKuUPD62MAbN4OEweGBBI7q1BekoEN4gPUEL6MZA==} - cpu: [x64, arm64, wasm32] os: [darwin, linux, win32] libsql@0.4.1: resolution: {integrity: sha512-qZlR9Yu1zMBeLChzkE/cKfoKV3Esp9cn9Vx5Zirn4AVhDWPcjYhKwbtJcMuHehgk3mH+fJr9qW+3vesBWbQpBg==} - cpu: [x64, arm64, wasm32] os: [darwin, linux, win32] lilconfig@2.1.0: From a05095406ed67cb4490fd7dccc9464d4c771a41b Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Thu, 15 Aug 2024 13:33:54 -0400 Subject: [PATCH 26/30] Allow snapshot releases against next --- .github/workflows/snapshot-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/snapshot-release.yml b/.github/workflows/snapshot-release.yml index bee678c962a8..00ddd24a00c0 100644 --- a/.github/workflows/snapshot-release.yml +++ b/.github/workflows/snapshot-release.yml @@ -84,7 +84,7 @@ jobs: - name: Bump Package Versions id: changesets run: | - pnpm exec changeset status --output status.output.json 2>&1 + pnpm exec changeset status --since origin/next --output status.output.json 2>&1 pnpm exec changeset version --snapshot ${{ steps.getSnapshotName.outputs.result }} EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) From d8f9a8397dd1fcd6a8d2e56e4f50a41ed6dcf948 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Thu, 15 Aug 2024 13:37:09 -0400 Subject: [PATCH 27/30] Reset the preview release branch --- .github/workflows/snapshot-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/snapshot-release.yml b/.github/workflows/snapshot-release.yml index 00ddd24a00c0..bee678c962a8 100644 --- a/.github/workflows/snapshot-release.yml +++ b/.github/workflows/snapshot-release.yml @@ -84,7 +84,7 @@ jobs: - name: Bump Package Versions id: changesets run: | - pnpm exec changeset status --since origin/next --output status.output.json 2>&1 + pnpm exec changeset status --output status.output.json 2>&1 pnpm exec changeset version --snapshot ${{ steps.getSnapshotName.outputs.result }} EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) From 423614ebb6ddb76cc8d11f3e3b6ae111a4a82662 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Fri, 16 Aug 2024 12:09:20 +0800 Subject: [PATCH 28/30] Fix MDX stack trace location with frontmatter (#11717) --- .changeset/mighty-trees-teach.md | 5 +++++ packages/integrations/mdx/src/vite-plugin-mdx.ts | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/mighty-trees-teach.md diff --git a/.changeset/mighty-trees-teach.md b/.changeset/mighty-trees-teach.md new file mode 100644 index 000000000000..289a41816154 --- /dev/null +++ b/.changeset/mighty-trees-teach.md @@ -0,0 +1,5 @@ +--- +'@astrojs/mdx': patch +--- + +Fixes stack trace location when failed to parse an MDX file with frontmatter diff --git a/packages/integrations/mdx/src/vite-plugin-mdx.ts b/packages/integrations/mdx/src/vite-plugin-mdx.ts index b232d1c83fc8..7b37535d8e98 100644 --- a/packages/integrations/mdx/src/vite-plugin-mdx.ts +++ b/packages/integrations/mdx/src/vite-plugin-mdx.ts @@ -44,9 +44,10 @@ export function vitePluginMdx(mdxOptions: MdxOptions): Plugin { async transform(code, id) { if (!id.endsWith('.mdx')) return; - const { data: frontmatter, content: pageContent } = parseFrontmatter(code, id); + const { data: frontmatter, content: pageContent, matter } = parseFrontmatter(code, id); + const frontmatterLines = matter ? matter.match(/\n/g)?.join('') + '\n\n' : ''; - const vfile = new VFile({ value: pageContent, path: id }); + const vfile = new VFile({ value: frontmatterLines + pageContent, path: id }); // Ensure `data.astro` is available to all remark plugins setVfileFrontmatter(vfile, frontmatter); From 2df49a6fb4f6d92fe45f7429430abe63defeacd6 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Fri, 16 Aug 2024 09:27:21 +0200 Subject: [PATCH 29/30] feat: simplifies sync paths (#11730) --- .changeset/spicy-houses-fry.md | 5 +++++ packages/astro/src/core/sync/write-files.ts | 12 +++++------- packages/astro/test/astro-sync.test.js | 4 +--- .../test/units/dev/collections-renderentry.test.js | 5 +---- 4 files changed, 12 insertions(+), 14 deletions(-) create mode 100644 .changeset/spicy-houses-fry.md diff --git a/.changeset/spicy-houses-fry.md b/.changeset/spicy-houses-fry.md new file mode 100644 index 000000000000..41f376a3546f --- /dev/null +++ b/.changeset/spicy-houses-fry.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Simplifies path operations of `astro sync` diff --git a/packages/astro/src/core/sync/write-files.ts b/packages/astro/src/core/sync/write-files.ts index 395bd54f2b12..62f2ccb21f99 100644 --- a/packages/astro/src/core/sync/write-files.ts +++ b/packages/astro/src/core/sync/write-files.ts @@ -2,11 +2,11 @@ import type fsMod from 'node:fs'; import { dirname, relative } from 'node:path'; import { fileURLToPath } from 'node:url'; import { bold } from 'kleur/colors'; -import { normalizePath } from 'vite'; import type { AstroSettings } from '../../@types/astro.js'; import { AstroError, AstroErrorData } from '../errors/index.js'; import type { Logger } from '../logger/core.js'; import { REFERENCE_FILE } from './constants.js'; +import { normalizePath } from 'vite'; export async function writeFiles(settings: AstroSettings, fs: typeof fsMod, logger: Logger) { try { @@ -27,7 +27,7 @@ function writeInjectedTypes(settings: AstroSettings, fs: typeof fsMod) { const references: Array = []; for (const { filename, content } of settings.injectedTypes) { - const filepath = normalizePath(fileURLToPath(new URL(filename, settings.dotAstroDir))); + const filepath = fileURLToPath(new URL(filename, settings.dotAstroDir)); fs.mkdirSync(dirname(filepath), { recursive: true }); fs.writeFileSync(filepath, content, 'utf-8'); references.push(normalizePath(relative(fileURLToPath(settings.dotAstroDir), filepath))); @@ -38,17 +38,15 @@ function writeInjectedTypes(settings: AstroSettings, fs: typeof fsMod) { fs.mkdirSync(settings.dotAstroDir, { recursive: true }); } fs.writeFileSync( - normalizePath(fileURLToPath(new URL(REFERENCE_FILE, settings.dotAstroDir))), + fileURLToPath(new URL(REFERENCE_FILE, settings.dotAstroDir)), astroDtsContent, 'utf-8', ); } async function setUpEnvTs(settings: AstroSettings, fs: typeof fsMod, logger: Logger) { - const envTsPath = normalizePath(fileURLToPath(new URL('env.d.ts', settings.config.srcDir))); - const envTsPathRelativetoRoot = normalizePath( - relative(fileURLToPath(settings.config.root), envTsPath), - ); + const envTsPath = fileURLToPath(new URL('env.d.ts', settings.config.srcDir)); + const envTsPathRelativetoRoot = relative(fileURLToPath(settings.config.root), envTsPath); const relativePath = normalizePath( relative( fileURLToPath(settings.config.srcDir), diff --git a/packages/astro/test/astro-sync.test.js b/packages/astro/test/astro-sync.test.js index dfe4755d1102..bb044574fe32 100644 --- a/packages/astro/test/astro-sync.test.js +++ b/packages/astro/test/astro-sync.test.js @@ -4,7 +4,6 @@ import * as fs from 'node:fs'; import { beforeEach, describe, it } from 'node:test'; import { fileURLToPath } from 'node:url'; import ts from 'typescript'; -import { normalizePath } from 'vite'; import { loadFixture } from './test-utils.js'; const createFixture = () => { @@ -16,8 +15,7 @@ const createFixture = () => { /** * @param {string} path */ - const getExpectedPath = (path) => - normalizePath(fileURLToPath(new URL(path, astroFixture.config.root))); + const getExpectedPath = (path) => fileURLToPath(new URL(path, astroFixture.config.root)); return { /** @param {string} root */ diff --git a/packages/astro/test/units/dev/collections-renderentry.test.js b/packages/astro/test/units/dev/collections-renderentry.test.js index 9441129a7cd4..082cd6b2f78b 100644 --- a/packages/astro/test/units/dev/collections-renderentry.test.js +++ b/packages/astro/test/units/dev/collections-renderentry.test.js @@ -1,5 +1,4 @@ import * as assert from 'node:assert/strict'; -import os from 'node:os'; import { describe, it } from 'node:test'; import { fileURLToPath } from 'node:url'; import * as cheerio from 'cheerio'; @@ -9,8 +8,6 @@ import { createFsWithFallback, createRequestAndResponse, runInContainer } from ' const root = new URL('../../fixtures/content/', import.meta.url); -const _describe = os.platform() === 'win32' ? describe.skip : describe; - /** @type {typeof runInContainer} */ async function runInContainerWithContentListeners(params, callback) { return await runInContainer(params, async (container) => { @@ -19,7 +16,7 @@ async function runInContainerWithContentListeners(params, callback) { }); } -_describe('Content Collections - render()', () => { +describe('Content Collections - render()', () => { it('can be called in a page component', async () => { const fs = createFsWithFallback( { From 5f0b58fb6c656243b0f1456266f07af59834e781 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Fri, 16 Aug 2024 07:28:10 +0000 Subject: [PATCH 30/30] [ci] format --- packages/astro/src/core/sync/write-files.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/astro/src/core/sync/write-files.ts b/packages/astro/src/core/sync/write-files.ts index 62f2ccb21f99..91084c36f965 100644 --- a/packages/astro/src/core/sync/write-files.ts +++ b/packages/astro/src/core/sync/write-files.ts @@ -2,11 +2,11 @@ import type fsMod from 'node:fs'; import { dirname, relative } from 'node:path'; import { fileURLToPath } from 'node:url'; import { bold } from 'kleur/colors'; +import { normalizePath } from 'vite'; import type { AstroSettings } from '../../@types/astro.js'; import { AstroError, AstroErrorData } from '../errors/index.js'; import type { Logger } from '../logger/core.js'; import { REFERENCE_FILE } from './constants.js'; -import { normalizePath } from 'vite'; export async function writeFiles(settings: AstroSettings, fs: typeof fsMod, logger: Logger) { try {