feat: add --skip-sync to dev and prod

This commit is contained in:
bholmesdev 2023-02-06 09:52:15 -05:00
parent a99f5a9301
commit 28658936ad
4 changed files with 22 additions and 6 deletions

View file

@ -84,6 +84,7 @@ export interface CLIFlags {
port?: number;
config?: string;
drafts?: boolean;
skipSync?: boolean;
}
export interface BuildConfig {

View file

@ -59,6 +59,7 @@ function printAstroHelp() {
['--base <pathname>', 'Specify your project base.'],
['--verbose', 'Enable verbose logging.'],
['--silent', 'Disable all logging.'],
['--skip-sync', 'Skip automatic content type generation.'],
['--version', 'Show the version number and exit.'],
['--help', 'Show this help message.'],
],
@ -203,7 +204,12 @@ async function runCommand(cmd: string, flags: yargs.Arguments) {
case 'build': {
const { default: build } = await import('../core/build/index.js');
return await build(settings, { ...flags, logging, telemetry });
return await build(settings, {
mode: flags.mode,
skipSync: flags['skip-sync'],
logging,
telemetry,
});
}
case 'check': {

View file

@ -23,6 +23,7 @@ import { getTimeStat } from './util.js';
export interface BuildOptions {
mode?: RuntimeMode;
skipSync?: boolean;
logging: LogOptions;
telemetry: AstroTelemetry;
}
@ -38,6 +39,7 @@ class AstroBuilder {
private settings: AstroSettings;
private logging: LogOptions;
private mode: RuntimeMode = 'production';
private skipSync: boolean = false;
private origin: string;
private routeCache: RouteCache;
private manifest: ManifestData;
@ -47,6 +49,9 @@ class AstroBuilder {
if (options.mode) {
this.mode = options.mode;
}
if (options.skipSync) {
this.skipSync = options.skipSync;
}
this.settings = settings;
this.logging = options.logging;
this.routeCache = new RouteCache(this.logging);
@ -81,11 +86,13 @@ class AstroBuilder {
);
await runHookConfigDone({ settings: this.settings, logging });
if (!this.skipSync) {
const { sync } = await import('../sync/index.js');
const syncRet = await sync(this.settings, { logging, fs });
if (syncRet !== 0) {
return process.exit(syncRet);
}
}
return { viteConfig };
}

View file

@ -72,7 +72,9 @@ export default async function dev(
warn(options.logging, null, msg.fsStrictWarning());
}
if (!options.flags?.['skip-sync']) {
await attachContentServerListeners(restart.container);
}
return {
address: devServerAddressInfo,