Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run integration config hook on astro sync #6238

Merged
merged 5 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cold-spoons-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fix: run integration setup hooks during `astro sync`
4 changes: 2 additions & 2 deletions packages/astro/src/cli/check/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ interface Result {
export async function check(settings: AstroSettings, { logging }: { logging: LogOptions }) {
console.log(bold('astro check'));

const { sync } = await import('../sync/index.js');
const syncRet = await sync(settings, { logging, fs });
const { syncCli } = await import('../../core/sync/index.js');
const syncRet = await syncCli(settings, { logging, fs });
// early exit on sync failure
if (syncRet === 1) return syncRet;

Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ async function runCommand(cmd: string, flags: yargs.Arguments) {
}

case 'sync': {
const { sync } = await import('./sync/index.js');
const { syncCli } = await import('../core/sync/index.js');

const ret = await sync(settings, { logging, fs });
const ret = await syncCli(settings, { logging, fs });
return process.exit(ret);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class AstroBuilder {
);
await runHookConfigDone({ settings: this.settings, logging });

const { sync } = await import('../../cli/sync/index.js');
const { sync } = await import('../sync/index.js');
const syncRet = await sync(this.settings, { logging, fs });
if (syncRet !== 0) {
return process.exit(syncRet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,31 @@ import { createServer } from 'vite';
import type { AstroSettings } from '../../@types/astro';
import { createContentTypesGenerator } from '../../content/index.js';
import { globalContentConfigObserver } from '../../content/utils.js';
import { getTimeStat } from '../../core/build/util.js';
import { createVite } from '../../core/create-vite.js';
import { AstroError, AstroErrorData } from '../../core/errors/index.js';
import { info, LogOptions } from '../../core/logger/core.js';
import { getTimeStat } from '../build/util.js';
import { createVite } from '../create-vite.js';
import { runHookConfigSetup } from '../../integrations/index.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
import { info, LogOptions } from '../logger/core.js';
import { setUpEnvTs } from '../../vite-plugin-inject-env-ts/index.js';

type ProcessExit = 0 | 1;

export async function syncCli(
settings: AstroSettings,
{ logging, fs }: { logging: LogOptions; fs: typeof fsMod }
): Promise<ProcessExit> {
const resolvedSettings = await runHookConfigSetup({
settings,
logging,
command: 'build',
});
return sync(resolvedSettings, { logging, fs });
}

export async function sync(
settings: AstroSettings,
{ logging, fs }: { logging: LogOptions; fs: typeof fsMod }
): Promise<0 | 1> {
): Promise<ProcessExit> {
const timerStart = performance.now();
// Needed to load content config
const tempViteServer = await createServer(
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/test/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import fs from 'fs';
import os from 'os';
import stripAnsi from 'strip-ansi';
import { fileURLToPath } from 'url';
import { sync } from '../dist/cli/sync/index.js';
import { sync } from '../dist/core/sync/index.js';
import build from '../dist/core/build/index.js';
import { openConfig } from '../dist/core/config/config.js';
import { createSettings } from '../dist/core/config/index.js';
Expand Down