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 wipe system gradle cache #110

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,25 @@ Or add it as a script to your `package.json`

This is a combination of the commands suggested in the React Native documentation plus others.

| State Type | Command | In `clean-project-auto`? | Optional? | Default? | Option Flag |
| ------------------------- | --------------------------------- | ------------------------ | --------- | -------- | ---------------------------- |
| React-native cache | `rm -rf $TMPDIR/react-*` | Yes | No | true | |
| Metro bundler cache | `rm -rf $TMPDIR/metro-*` | Yes | No | true | |
| Watchman cache | `watchman watch-del-all` | Yes | No | true | |
| NPM modules | `rm -rf node_modules` | Yes | Yes | true | --keep-node-modules |
| Yarn cache | `yarn cache clean` | Yes | Yes | true | --keep-node-modules |
| Yarn packages | `yarn install` | No | Yes | true | --keep-node-modules |
| NPM cache | `npm cache verify` | Yes | Yes | true | --keep-node-modules |
| NPM Install | `npm ci` | Yes | Yes | true | --keep-node-modules |
| iOS build folder | `rm -rf ios/build` | Yes | Yes | false | --remove-iOS-build |
| iOS pods folder | `rm -rf ios/Pods` | Yes | Yes | false | --remove-iOS-pods |
| system iOS pods cache | `pod cache clean --all` | Yes | Yes | true | --keep-system-iOS-pods-cache |
| user iOS pods cache | `rm -rf ~/.cocoapods` | Yes | Yes | true | --keep-user-iOS-pods-cache |
| Android build folder | `rm -rf android/build` | Yes | Yes | false | --remove-android-build |
| Android clean project | `(cd android && ./gradlew clean)` | Yes | Yes | false | --clean-android-project |
| Brew package | `brew update && brew upgrade` | No | Yes | true | --keep-brew |
| Pod packages | `pod update` | No | Yes | true | --keep-pods |
| State Type | Command | In `clean-project-auto`? | Optional? | Default? | Option Flag |
| --------------------------- | --------------------------------- | ------------------------ | --------- | -------- | ---------------------------- |
| React-native cache | `rm -rf $TMPDIR/react-*` | Yes | No | true | |
| Metro bundler cache | `rm -rf $TMPDIR/metro-*` | Yes | No | true | |
| Watchman cache | `watchman watch-del-all` | Yes | No | true | |
| NPM modules | `rm -rf node_modules` | Yes | Yes | true | --keep-node-modules |
| Yarn cache | `yarn cache clean` | Yes | Yes | true | --keep-node-modules |
| Yarn packages | `yarn install` | No | Yes | true | --keep-node-modules |
| NPM cache | `npm cache verify` | Yes | Yes | true | --keep-node-modules |
| NPM Install | `npm ci` | Yes | Yes | true | --keep-node-modules |
| iOS build folder | `rm -rf ios/build` | Yes | Yes | false | --remove-iOS-build |
| iOS pods folder | `rm -rf ios/Pods` | Yes | Yes | false | --remove-iOS-pods |
| system iOS pods cache | `pod cache clean --all` | Yes | Yes | true | --keep-system-iOS-pods-cache |
| user iOS pods cache | `rm -rf ~/.cocoapods` | Yes | Yes | true | --keep-user-iOS-pods-cache |
| Android build folder | `rm -rf android/build` | Yes | Yes | false | --remove-android-build |
| Android clean project | `(cd android && ./gradlew clean)` | Yes | Yes | false | --clean-android-project |
| Android system gradle cache | `rm -rf ~/.gradle/caches` | Yes | Yes | false | --keep-system-gradle-cache |
| Brew package | `brew update && brew upgrade` | No | Yes | true | --keep-brew |
| Pod packages | `pod update` | No | Yes | true | --keep-pods |

Example: `./node_modules/.bin/react-native-clean-project --remove-iOS-build`

Expand Down
21 changes: 21 additions & 0 deletions source/internals/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ let wipeiOSPods = false;
let wipeSystemiOSPodsCache = true;
let wipeUseriOSPodsCache = true;
let wipeAndroidBuild = false;
let wipeSystemGradleCache = false;
let wipeNodeModules = true;
let updateBrew = true;
let updatePods = true;
Expand All @@ -37,6 +38,9 @@ const getWipeUseriOSPodsCache = () => {
const getWipeAndroidBuild = () => {
return wipeAndroidBuild;
};
const getWipeSystemGradleCache = () => {
return wipeSystemGradleCache;
};
const getWipeNodeModules = () => {
return wipeNodeModules;
};
Expand Down Expand Up @@ -130,6 +134,21 @@ const askAndroidCleanProject = () =>
});
});

const askWipeSystemGradleCache = () =>
new Promise((resolve) => {
if (args.includes('--keep-system-gradle-cache')) {
wipeSystemGradleCache = false;
return resolve();
}
return askQuestion('Clean system gradle cache? (Y/n) ', (answer) => {
wipeSystemGradleCache = checkAnswer(
answer,
askWipeSystemGradleCache,
resolve
);
});
});

const askAndroid = () =>
new Promise((resolve) => {
if (args.includes('--remove-android-build')) {
Expand Down Expand Up @@ -181,13 +200,15 @@ module.exports = {
getWipeSystemiOSPodsCache,
getWipeUseriOSPodsCache,
getWipeAndroidBuild,
getWipeSystemGradleCache,
getWipeNodeModules,
getUpdateBrew,
getUpdatePods,
askiOS,
askiOSPods,
askSystemiOSPodsCache,
askUseriOSPodsCache,
askWipeSystemGradleCache,
askUpdatePods,
askAndroid,
askAndroidCleanProject,
Expand Down
6 changes: 6 additions & 0 deletions source/internals/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ const tasks = {
command: '(cd android && ./gradlew clean)',
args: []
},
wipeSystemGradleCache: {
name: 'wipe system gradle cache',
command: 'rm',
args: ['-rf', '~/.gradle/caches']
},
watchmanCacheClear: {
name: 'watchman cache clear (if watchman is installed)',
command: 'watchman watch-del-all || true',
Expand Down Expand Up @@ -95,6 +100,7 @@ const autoTasks = [
tasks.watchmanCacheClear,
tasks.wipeTempCaches,
tasks.cleanAndroidProject,
tasks.wipeSystemGradleCache,
tasks.wipeNodeModules,
tasks.yarnCacheClean,
tasks.npmCacheVerify,
Expand Down