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

feat: non-interactive default behavior flags added #103

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
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,24 @@ 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 | 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 | --default-node-modules |
| Yarn cache | `yarn cache clean` | Yes | Yes | true | --keep-node-modules | --default-node-modules |
| Yarn packages | `yarn install` | No | Yes | true | --keep-node-modules | --default-node-modules |
| NPM cache | `npm cache verify` | Yes | Yes | true | --keep-node-modules | --default-node-modules |
| NPM Install | `npm ci` | Yes | Yes | true | --keep-node-modules | --default-node-modules |
| iOS build folder | `rm -rf ios/build` | Yes | Yes | false | --remove-iOS-build | --default-iOS-build |
| iOS pods folder | `rm -rf ios/Pods` | Yes | Yes | false | --remove-iOS-pods | --default-iOS-pods |
| system iOS pods cache | `pod cache clean --all` | Yes | Yes | true | --keep-system-iOS-pods-cache | --default-system-iOS-pods-cache |
| user iOS pods cache | `rm -rf ~/.cocoapods` | Yes | Yes | true | --keep-user-iOS-pods-cache | --default-user-iOS-pods-cache |
| Android build folder | `rm -rf android/build` | Yes | Yes | false | --remove-android-build | --default-android-build |
| Android clean project | `(cd android && ./gradlew clean)` | Yes | Yes | false | --clean-android-project | --default-android-project |
| Brew package | `brew update && brew upgrade` | No | Yes | true | --keep-brew | --default-brew |
| Pod packages | `pod update` | No | Yes | true | --keep-pods | --default-pods |

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

Expand Down
27 changes: 27 additions & 0 deletions source/internals/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ const checkAnswer = (answer, questionFunction, resolve) => {

const askiOS = () =>
new Promise((resolve) => {
if (args.includes('--default-iOS-build')) {
return resolve();
}
if (args.includes('--remove-iOS-build')) {
wipeiOSBuild = true;
return resolve();
Expand All @@ -80,6 +83,9 @@ const askiOS = () =>

const askiOSPods = () =>
new Promise((resolve) => {
if (args.includes('--default-iOS-pods')) {
return resolve();
}
if (args.includes('--remove-iOS-pods')) {
wipeiOSPods = true;
return resolve();
Expand All @@ -91,6 +97,9 @@ const askiOSPods = () =>

const askSystemiOSPodsCache = () =>
new Promise((resolve) => {
if (args.includes('--default-system-iOS-pods-cache')) {
return resolve();
}
if (args.includes('--keep-system-iOS-pods-cache')) {
wipeSystemiOSPodsCache = false;
return resolve();
Expand All @@ -106,6 +115,9 @@ const askSystemiOSPodsCache = () =>

const askUseriOSPodsCache = () =>
new Promise((resolve) => {
if (args.includes('--default-user-iOS-pods-cache')) {
return resolve();
}
if (args.includes('--keep-user-iOS-pods-cache')) {
wipeUseriOSPodsCache = false;
return resolve();
Expand All @@ -117,6 +129,9 @@ const askUseriOSPodsCache = () =>

const askAndroidCleanProject = () =>
new Promise((resolve) => {
if (args.includes('--default-android-project')) {
return resolve();
}
if (args.includes('--clean-android-project')) {
cleanAndroidProject = true;
return resolve();
Expand All @@ -132,6 +147,9 @@ const askAndroidCleanProject = () =>

const askAndroid = () =>
new Promise((resolve) => {
if (args.includes('--default-android-build')) {
return resolve();
}
if (args.includes('--remove-android-build')) {
wipeAndroidBuild = true;
return resolve();
Expand All @@ -143,6 +161,9 @@ const askAndroid = () =>

const askNodeModules = () =>
new Promise((resolve) => {
if (args.includes('--default-node-modules')) {
return resolve();
}
if (args.includes('--keep-node-modules')) {
wipeNodeModules = false;
return resolve();
Expand All @@ -154,6 +175,9 @@ const askNodeModules = () =>

const askBrew = () =>
new Promise((resolve) => {
if (args.includes('--default-brew')) {
return resolve();
}
if (args.includes('--keep-brew')) {
updateBrew = false;
return resolve();
Expand All @@ -165,6 +189,9 @@ const askBrew = () =>

const askUpdatePods = () =>
new Promise((resolve) => {
if (args.includes('--default-pods')) {
return resolve();
}
if (args.includes('--keep-pods')) {
updatePods = false;
return resolve();
Expand Down