-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
feat(gatsby-cli): add a clean command to wipe out local dirs #9126
feat(gatsby-cli): add a clean command to wipe out local dirs #9126
Conversation
@jlengstorf if you have some time, could you check this out and chime in on any of the questions! I think this could be some nice functionality for debugging, helping people, etc. |
Per @pieh perhaps tarball the .cache directory so we can investigate further. Send this off to a REST API (or something) that we're in control of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, @DSchau! Nice work on this. I'm leaving approval to core maintainers. 😅
packages/gatsby-cli/README.md
Outdated
### Info | ||
### `clean` | ||
|
||
At the root of a Gatsby site run `gatsby clean` to wipe out `node_modules`, cache, and the `public` directory. This is useful as a last resort when your local project seems to have many issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would maybe benefit from more of an explanation on why it's a last resort. Are there other things people should try first? Where can they go for more info? How can they help improve the cache so this isn't necessary?
I don't know if we have answers, but it'd be great to include whatever we can here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great suggestion!
Are we adding the snapshot functionality here? |
@KyleAMathews I didn't add it, because I didn't know where it should go, whether we have an API in place, etc. I think the functionality is worth introducing regardless, but it'd be helpful to have some debug info to help us troubleshoot things in the future, so I'm open to releasing it as is or building in some type of API call. |
My vote would be to release this and add a follow-up issue to design the API for sending snapshots on clean. Maybe we can add that to the new GraphQL API I just launched? See gatsbyjs/api.gatsbyjs.org#11 for the new code; we could add a mutation in there to accept the snapshot and log it somewhere. |
@pieh you wanna give this a once over and maybe we can get this merged today? |
@pieh this is ready now. For those following along, this PR will:
|
Going to hold off on merging this until at least tomorrow to iron out some potential issues with Gatsby v1/v2, e.g. the info command not being present in the current version of gatsby that the CLI is being used with and several other issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good enough to get this merged, feel free to ignore the latest comments, it shouldn't block the PR to get merged
@wardpeet want to give this another once over? I scaled it back quite a bit--think it's ready and generally applicable now. @marcysutton I'll look at docs to see how to best document this feature (troubleshooting?) but let me know if you have any ideas. |
Just wanted to voice my support for @wardpeet 's comment above re: separating wiping .cache/public from also wiping node_modules. I've often needed to delete .cache (e.g. when messing with webpack config, gatsby-node.js, etc.) but I've never had to delete node_modules. I think building a command into Gatsby that wipes Gatsby's state (.cache, public) makes a lot of sense. Building a command into Gatsby that wipes someone else's (npm/yarn's) state feels... less clean? |
@DSchau for docs the "Debugging" section seems like a logical place. But I'm wondering if maybe the section should be renamed "Troubleshooting Gatsby" so we can add things like |
@marcysutton I don't have an opinion; I would just call it whatever seems like the most common / understandable way developers describe the tasks involved in the section. The reason we called it debugging was mostly because other platforms have a "debugging" section, so it is standard (doesn't mean it's the best name, though :) Here are relevant blog posts about where the current organization of the docs came from: |
@shannonbux @marcysutton see f24aa24. Happy to make any changes, I put it together pretty quickly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks awesome! One small thing — Shouldn't we exclude node_modules from this?
Co-Authored-By: DSchau <[email protected]>
Successfully published: |
Fixes #6755
This PR adds a
gatsby clean
command as a last resort when things have gone awry. We'll need to specifically document use cases when it could make sense to run this, or just emphasize that it's only to be used in certain cases.Things left to do: