Skip to content

Add --disable-clear option#136

Merged
jasonvarga merged 11 commits into
statamic:masterfrom
simonhamp:feature/force-option
Jul 13, 2023
Merged

Add --disable-clear option#136
jasonvarga merged 11 commits into
statamic:masterfrom
simonhamp:feature/force-option

Conversation

@simonhamp

@simonhamp simonhamp commented Jun 25, 2023

Copy link
Copy Markdown
Contributor

Edit by @jesseleite:
We decided to keep default functionality and add this as opt-in functionality via --disable-clear 👍


The SSG generate method currently always destroys all files on a run... this can become problematic when you're trying to figure out why certain pages are failing if it doesn't reliably generate all pages on each run

This won't necessarily save much time yet, as it will still process all entries and other URLs and try to write the final copies to disk... but if you have other steps in your build process and don't want to always start from scratch, this allows you that flexibility

NB: This changes the default behaviour. If you want to maintain the old behaviour, you have to pass --fresh on the CLI

This is somewhat related to #135 as non-deterministic builds are tricky to manage

Keep it all consistent
Save polluting the generate method parameters. Should make merging easier
@simonhamp simonhamp changed the title Add fresh option Add fresh option Jun 25, 2023
@simonhamp simonhamp changed the title Add fresh option Add --fresh option Jun 25, 2023
@jesseleite

Copy link
Copy Markdown
Contributor

This is somewhat related to #135 as non-deterministic builds are tricky to manage

Curious what you mean here?

@simonhamp

Copy link
Copy Markdown
Contributor Author

Curious what you mean here?

Basically some of this stuff came out of me trying to use the SSG incrementally. The reason I was wanting to do that is because it was failing in ways that were hard to investigate (minimal output, especially when running multiple threads).

I needed a way for it to run deterministically multiple times without wiping everything out - that way I could eventually get it to run to completion.

(I believe my problems related specifically to rendering images in Glide - I'm using Spatie's Responsive Images addon) and it doesn't play particularly nicely with the SSG in my setup)

This PR came out of that but isn't directly related to trying to solve those issues - I think this is useful aside of those issues.

Though you may want to maintain current behaviour (where ssg:generate deletes all files in the build folders and starts from scratch every time) and the flag be the thing that prevents that... so maybe something like --gentle instead

@jesseleite

Copy link
Copy Markdown
Contributor

For sure, but after an internal discussion we want to keep clearDirectory() as default behaviour. We're definitely open to an inverse flag though, maybe something like --disable-clear?

@simonhamp

Copy link
Copy Markdown
Contributor Author

Makes sense. I'll rework this after Laracon 😉

@jesseleite jesseleite changed the title Add --fresh option Add --disable-clear option Jul 13, 2023
@jesseleite

Copy link
Copy Markdown
Contributor

All good, I gotchyoo. Just going to add a test here once #140 gets merged, as I added some basic generator test coverage over there 👍

@jesseleite jesseleite marked this pull request as draft July 13, 2023 14:18
@jesseleite jesseleite marked this pull request as ready for review July 13, 2023 18:29
@jesseleite jesseleite requested a review from jasonvarga July 13, 2023 18:42
@jasonvarga jasonvarga merged commit 87c5909 into statamic:master Jul 13, 2023
thomaskenne pushed a commit to thomaskenne/ssg that referenced this pull request Feb 10, 2024
Co-authored-by: Jesse Leite <jesseleite@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants