Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gatsby-cli): add a clean command to wipe out local dirs (#9126)
* feat: add a clean command to the CLI * chore: minor tweak * chore: lint * refactor: move info to separate command; re-use in clean * chore: fix lint error * feat: add options including --no-install * chore: fix typo * docs: update readme with defaults * chore: bump to node 6; not node 4 requirement * chore: update readme * chore: update crlf * chore: mrege * chore: add clean command (drop info command) * fix: reduce reliance on certain gatsby version * chore: the env-info command is removed * chore: remove option from command handler * chore: remove info separate file * chore: remove node_modules and install from clean command * chore: add a plugin comment * docs: add a debugging cache doc * chore: tweak dir * chore: Update packages/gatsby-cli/src/create-cli.js Co-Authored-By: DSchau <DSchau@users.noreply.github.com>
- Loading branch information
1 parent
6b09fe4
commit 5807936
Showing
7 changed files
with
95 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
title: Debugging Cache Issues | ||
--- | ||
|
||
There can be certain scenarios in which the Gatsby caching mechanism appears to fail, which leads to issues like: | ||
|
||
- Content not appearing when it should | ||
- Changes to plugin source code not appearing to be invoked appropriately | ||
|
||
and more! If you've found yourself writing a script like: | ||
|
||
```json:title=package.json | ||
{ | ||
"scripts": { | ||
"clean": "rm -rf .cache" | ||
} | ||
} | ||
``` | ||
|
||
consider utilizing the `gatsby clean` command which will help to resolve caching issues for you. | ||
|
||
First - make sure the version of `gatsby` specified in your `package.json` dependencies is _at least_ `2.1.1`, and then make the following change to `package.json`: | ||
|
||
```json:title=package.json | ||
{ | ||
"scripts": { | ||
"clean": "gatsby clean" | ||
} | ||
} | ||
``` | ||
|
||
Now when you issues arise that seem to be related to caching, you can use `npm run clean` to wipe out the cache and start from a fresh slate. | ||
|
||
_Note: If you find yourself using this command regularly, consider helping us out and [responding to our Github Issue][github-issue] with clear reproduction steps._ | ||
|
||
[github-issue]: https://github.com/gatsbyjs/gatsby/issues/11747 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,5 @@ | |
}, | ||
"yargs": { | ||
"boolean-negation": false | ||
}, | ||
"gitHead": "5bd5aebe066b9875354a81a4b9ed98722731c465" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const fs = require(`fs-extra`) | ||
const path = require(`path`) | ||
|
||
module.exports = async function clean(args) { | ||
const { directory, report } = args | ||
|
||
const directories = [`.cache`, `public`] | ||
|
||
report.info(`Deleting ${directories.join(`, `)}`) | ||
|
||
await Promise.all( | ||
directories.map(dir => fs.remove(path.join(directory, dir))) | ||
) | ||
|
||
report.info(`Successfully deleted directories`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters