Skip to content

Commit

Permalink
feat: add sync variant (#11729)
Browse files Browse the repository at this point in the history
* feat: add `sync` variant

* fix build

* Update .changeset/afraid-apricots-develop.md

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>

---------

Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
  • Loading branch information
3 people authored Aug 28, 2024
1 parent d6611e8 commit 1c54e63
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 5 deletions.
7 changes: 7 additions & 0 deletions .changeset/afraid-apricots-develop.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion packages/astro/src/@types/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>) => AstroConfig;
addRenderer: (renderer: AstroRenderer) => void;
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/sync/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/integrations/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/db/src/core/integration/file-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion packages/db/src/core/integration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 1c54e63

Please sign in to comment.