Add console warning on fs.strict=false (#3464)

* chore: add warning on fs.strict=false

* chore: add changeset

Co-authored-by: Nate Moore <nate@skypack.dev>
This commit is contained in:
Ben Holmes 2022-06-01 18:32:29 -04:00 committed by GitHub
parent 5c32c7a4c3
commit 9c2ba13748
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Add warning on startup when `vite.server.fs.strict` is disabled

View file

@ -12,7 +12,6 @@ import {
} from '../../integrations/index.js';
import { createVite } from '../create-vite.js';
import { info, LogOptions, warn, warnIfUsingExperimentalSSR } from '../logger/core.js';
import { nodeLogOptions } from '../logger/node.js';
import * as msg from '../messages.js';
import { apply as applyPolyfill } from '../polyfill.js';
@ -65,6 +64,9 @@ export default async function dev(config: AstroConfig, options: DevOptions): Pro
if (currentVersion.includes('-')) {
warn(options.logging, null, msg.prerelease({ currentVersion }));
}
if (viteConfig.server?.fs?.strict === false) {
warn(options.logging, null, msg.fsStrictWarning());
}
await runHookServerStart({ config, address: devServerAddressInfo });

View file

@ -145,6 +145,10 @@ export function telemetryReset() {
)}. You may be prompted again.\n`;
}
export function fsStrictWarning() {
return yellow('⚠️ Serving with vite.server.fs.strict: false. Note that all files on your machine will be accessible to anyone on your network!')
}
export function prerelease({ currentVersion }: { currentVersion: string }) {
const tag = currentVersion.split('-').slice(1).join('-').replace(/\..*$/, '');
const badge = bgYellow(black(` ${tag} `));