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

add: config error if outDir is inside publicDir #8152

Merged
merged 4 commits into from
Aug 22, 2023

Conversation

andremralves
Copy link
Contributor

Changes

fixes #6904

image

I thought that creating a ZodError in schema would be better than throwing a new error so it works for both ssr and ssg and we just need to change one file. What do you think?

And is this message ok?

Testing

New test expecting an error message.

Docs

n/a

@changeset-bot
Copy link

changeset-bot bot commented Aug 18, 2023

🦋 Changeset detected

Latest commit: a195f87

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Aug 18, 2023
Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me since this really should be considered an invalid configuration setting! I'm cool with it not being an official Astro error with a reference page and everything.

Maybe @withastro/maintainers-docs has thoughts on the exact wording?

@ematipico ematipico merged commit 5821323 into withastro:main Aug 22, 2023
@ematipico
Copy link
Member

Sorry, I merged without checking Nate's comment.

@withastro/maintainers-docs please leave your feedback here and we will do a follow up PR

@astrobot-houston astrobot-houston mentioned this pull request Aug 22, 2023
Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the ping, @ematipico! Left a suggestion for you and @natemoo-re to look at, for your consideration!

it('Error when outDir is placed within publicDir', async () => {
const configError = await validateConfig({ outDir: './public/dist' }, process.cwd()).catch((err) => err);
expect(configError instanceof z.ZodError).to.equal(true);
expect(configError.errors[0].message).to.equal('`outDir` must not be placed inside `publicDir` to prevent an infinite loop. \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expect(configError.errors[0].message).to.equal(' The value of `outDir` must not point to a path in the `public/` folder to prevent an infinite loop. \

Something like this? Talking about putting "one configuration option inside another" isn't as clear as it could be. (At first, I was assuming this error meant that someone treated outDir as not a top-level root config..., i.e. the literal position of the config option within your .astro file.)

I think making the message explicitly refer to the value outDir can or cannot take is more helpful guidance? If "somewhere within the public folder" doesn't cover all instances given whatever might be set in publicDir, then the message could be something like:

The value of outDir must not point to a path within the folder set as publicDir to prevent an infinite loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second one sounds good to me. I can make a new PR changing the message. Should I keep the last part: "Please adjust the directory configuration and try again"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

outDir config property create infinite loop of folders
4 participants