Repository: withastro/astro
File: packages/astro/src/core/sync/index.ts (TypeScript)

Code before:
	isDev: boolean;
}) {
	const dataStore = getDataStoreFile(settings, isDev);
	if (fs.existsSync(dataStore)) {
		logger.debug('content', 'clearing data store');
		await fs.promises.rm(dataStore, { force: true });
		logger.warn('content', 'data store cleared (force)');
	}
}

/**
 * Generates TypeScript types for all Astro modules. This sets up a `src/env.d.ts` file for type inferencing,
 * and defines the `astro:content` module for the Content Collections API.
 *
 * @experimental The JavaScript API is experimental
 */
export async function syncInternal({
	mode,
	logger,
	fs = fsMod,
	settings,
	skip,
	force,
	manifest,
}: SyncOptions): Promise<void> {
	const isDev = mode === 'development';
	if (force) {
		await clearContentLayerCache({ settings, logger, fs, isDev });
	}

	const timerStart = performance.now();

	if (!skip?.content) {
		await syncContentCollections(settings, { mode, fs, logger, manifest });
		settings.timer.start('Sync content layer');
		let store: MutableDataStore | undefined;
		try {
			const dataStoreFile = getDataStoreFile(settings, isDev);
			store = await MutableDataStore.fromFile(dataStoreFile);
		} catch (err: any) {
			logger.error('content', err.message);
		}
		if (!store) {
			logger.error('content', 'Failed to load content store');
			return;
		}
		const contentLayer = globalContentLayer.init({
			settings,
			logger,
			store,
		});

Review comment (suggestion):
Double checking if this is correct. In Astro, you can also technically do `astro build --devOutput` to get the development build. Do we want `isDev` `true` in that case?

The `mode` here is typed as `string` because end-users can name it anything in practice. e.g. `astro build --mode staging` or `astro build --mode staging --devOutput`.

Maybe passing the `runtimeMode` from `build()` would be more accurate for `isDev`.

Code after:
	logger: Logger;
	fs?: typeof fsMod;
	isDev: boolean;
}) {
	const dataStore = getDataStoreFile(settings, isDev);
	if (fs.existsSync(dataStore)) {
		logger.debug('content', 'clearing data store');
		await fs.promises.rm(dataStore, { force: true });
		logger.warn('content', 'data store cleared (force)');
	}
}

/**
 * Generates TypeScript types for all Astro modules. This sets up a `src/env.d.ts` file for type inferencing,
 * and defines the `astro:content` module for the Content Collections API.
 *
 * @experimental The JavaScript API is experimental
 */
export async function syncInternal({
	mode,
	logger,
	fs = fsMod,
	settings,
	skip,
	force,
	manifest,
	command,
}: SyncOptions): Promise<void> {
	const isDev = command === 'dev';
	if (force) {
		await clearContentLayerCache({ settings, logger, fs, isDev });
	}

	const timerStart = performance.now();

	if (!skip?.content) {
		await syncContentCollections(settings, { mode, fs, logger, manifest });
		settings.timer.start('Sync content layer');
		let store: MutableDataStore | undefined;
		try {
			const dataStoreFile = getDataStoreFile(settings, isDev);
			store = await MutableDataStore.fromFile(dataStoreFile);
		} catch (err: any) {
			logger.error('content', err.message);
		}
		if (!store) {
			logger.error('content', 'Failed to load content store');
			return;
		}
		const contentLayer = globalContentLayer.init({
			settings,