From 1c54e633274ad47f6c83c9a16f375f0caa983fbe Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Wed, 28 Aug 2024 12:16:06 +0100 Subject: [PATCH] feat: add `sync` variant (#11729) * feat: add `sync` variant * fix build * Update .changeset/afraid-apricots-develop.md Co-authored-by: Sarah Rainsberger --------- Co-authored-by: Florian Lefebvre Co-authored-by: Sarah Rainsberger --- .changeset/afraid-apricots-develop.md | 7 +++++++ packages/astro/src/@types/astro.ts | 2 +- packages/astro/src/core/sync/index.ts | 2 +- packages/astro/src/integrations/hooks.ts | 2 +- packages/db/src/core/integration/file-url.ts | 2 +- packages/db/src/core/integration/index.ts | 2 +- 6 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 .changeset/afraid-apricots-develop.md diff --git a/.changeset/afraid-apricots-develop.md b/.changeset/afraid-apricots-develop.md new file mode 100644 index 000000000000..acf897149ff9 --- /dev/null +++ b/.changeset/afraid-apricots-develop.md @@ -0,0 +1,7 @@ +--- +'astro': minor +--- + +Adds a new variant `sync` for the `astro:config:setup` hook's `command` property. This value is set when calling the command `astro sync`. + +If your integration previously relied on knowing how many variants existed for the `command` property, you must update your logic to account for this new option. diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 19bbe480623d..50afa1423f2d 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -3316,7 +3316,7 @@ declare global { export interface IntegrationHooks { 'astro:config:setup': (options: { config: AstroConfig; - command: 'dev' | 'build' | 'preview'; + command: 'dev' | 'build' | 'preview' | 'sync'; isRestart: boolean; updateConfig: (newConfig: DeepPartial) => AstroConfig; addRenderer: (renderer: AstroRenderer) => void; diff --git a/packages/astro/src/core/sync/index.ts b/packages/astro/src/core/sync/index.ts index 3df81846ece1..d5bdfe3f99c0 100644 --- a/packages/astro/src/core/sync/index.ts +++ b/packages/astro/src/core/sync/index.ts @@ -57,7 +57,7 @@ export default async function sync( } let settings = await createSettings(astroConfig, inlineConfig.root); settings = await runHookConfigSetup({ - command: 'build', + command: 'sync', settings, logger, }); diff --git a/packages/astro/src/integrations/hooks.ts b/packages/astro/src/integrations/hooks.ts index aa62572ee83a..3b15e0d97ee2 100644 --- a/packages/astro/src/integrations/hooks.ts +++ b/packages/astro/src/integrations/hooks.ts @@ -121,7 +121,7 @@ export async function runHookConfigSetup({ fs = fsMod, }: { settings: AstroSettings; - command: 'dev' | 'build' | 'preview'; + command: 'dev' | 'build' | 'preview' | 'sync'; logger: Logger; isRestart?: boolean; fs?: typeof fsMod; diff --git a/packages/db/src/core/integration/file-url.ts b/packages/db/src/core/integration/file-url.ts index 72e49004ee09..76ce70cb9836 100644 --- a/packages/db/src/core/integration/file-url.ts +++ b/packages/db/src/core/integration/file-url.ts @@ -12,7 +12,7 @@ async function copyFile(toDir: URL, fromUrl: URL, toUrl: URL) { export function fileURLIntegration(): AstroIntegration { const fileNames: string[] = []; - function createVitePlugin(command: 'build' | 'preview' | 'dev'): VitePlugin { + function createVitePlugin(command: 'build' | 'preview' | 'dev' | 'sync'): VitePlugin { let referenceIds: string[] = []; return { name: '@astrojs/db/file-url', diff --git a/packages/db/src/core/integration/index.ts b/packages/db/src/core/integration/index.ts index de8eb6169246..263fa250a1b9 100644 --- a/packages/db/src/core/integration/index.ts +++ b/packages/db/src/core/integration/index.ts @@ -58,7 +58,7 @@ function astroDBIntegration(): AstroIntegration { inProgress: false, }; - let command: 'dev' | 'build' | 'preview'; + let command: 'dev' | 'build' | 'preview' | 'sync'; let output: AstroConfig['output'] = 'server'; return { name: 'astro:db',