New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-clean-project

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-clean-project - npm Package Compare versions

Comparing version 3.2.0 to 3.2.1

.prettierrc

20

CONTRIBUTING.md

@@ -10,10 +10,10 @@ # Contributing

1. Ensure any install or build dependencies are removed before the end of the layer when doing a
build.
2. Update the README.md with details of changes to the interface, this includes new environment
variables, exposed ports, useful file locations and container parameters.
3. Increase the version numbers in any examples files and the README.md to the new version that this
Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
do not have permission to do that, you may request the second reviewer to merge it for you.
1. Ensure any install or build dependencies are removed before the end of the layer when doing a
build.
1. Update the README.md with details of changes to the interface, this includes new environment
variables, exposed ports, useful file locations and container parameters.
1. Increase the version numbers in any examples files and the README.md to the new version that this
Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
1. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
do not have permission to do that, you may request the second reviewer to merge it for you.

@@ -27,3 +27,3 @@ ## Commit guidelines

```
```text
<type>(<scope>): <subject>

@@ -124,3 +124,3 @@ <BLANK LINE>

### Scope
### Code of Conduct Scope

@@ -127,0 +127,0 @@ This Code of Conduct applies both within project spaces and in public spaces

@@ -134,3 +134,3 @@ // For a detailed explanation regarding each configuration property, visit:

// The test environment that will be used for testing
testEnvironment: 'node'
testEnvironment: 'node',

@@ -150,5 +150,3 @@ // Options that will be passed to the testEnvironment

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
// "/node_modules/"
// ],
testPathIgnorePatterns: ['/node_modules/', '/example/']

@@ -155,0 +153,0 @@ // The regexp pattern or array of patterns that Jest uses to detect test files

{
"name": "react-native-clean-project",
"version": "3.2.0",
"version": "3.2.1",
"engines": {

@@ -11,2 +11,4 @@ "node": ">=8.9.0"

"scripts": {
"dev-init": "npx react-native init example && pushd example && npm i react-native-clean-project && popd",
"dev-sync": "cp -R package.json source react-native.config.js example/node_modules/react-native-clean-project/",
"test": "jest",

@@ -32,4 +34,11 @@ "lint": "eslint . --fix"

"eslint": "5.2.0",
"jest": "^24.8.0"
"eslint-config-prettier": "4.3.0",
"eslint-plugin-node": "9.0.1",
"eslint-plugin-prettier": "3.1.0",
"jest": "24.8.0",
"prettier": "1.17.1"
},
"rnpm": {
"plugin": "./source/plugin.js"
}
}

@@ -15,4 +15,13 @@ # React Native Clean Project

To run on your console, just run:
### React-Native CLI plugin
This module is automatically detected as a plugin by the standard `react-native` command, adding new sub-commands:
* `react-native clean-project-auto` - fully automated project state clean: like a freshly-cloned, never-started repo
* `react-native clean-project` - interactive project state clean: choose types of react-native state to clean
### Direct execution
For complete control (including using command-line arguments to non-interactively fine-tune what state is cleaned):
`./node_modules/.bin/react-native-clean-project`

@@ -22,3 +31,3 @@

```
```json
"scripts": {

@@ -31,22 +40,19 @@ "clean": "react-native-clean-project"

This is a combination of the commands suggested in the React Native documentation plus others. They are:
This is a combination of the commands suggested in the React Native documentation plus others.
1. `rm -rf ios/build` (optional)
2. `rm -rf android/build` (optional)
3. `watchman watch-del-all`
4. `rm -rf $TMPDIR/react-*`
5. `rm -rf $TMPDIR/metro-*`
6. `brew update` (optional)
7. `brew upgrade` (optional)
8. `rm -rf node_modules` (optional)
9. `yarn cache clean`
10. `yarn install`
| 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 |
| 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 |
| Android build folder | `rm -rf android/build` | Yes | Yes | false | --remove-android-build |
| Brew package | `brew update && brew upgrade` | No | Yes | true | --keep-brew |
| Pod packages | `pod update` | No | Yes | true | --keep-pods |
Command line arguments available for CI's:
- `--remove-iOS-build`
- `--remove-android-build`
- `--keep-node-modules`
- `--keep-brew`
Example: `./node_modules/.bin/react-native-clean-project --remove-iOS-build`

@@ -64,3 +70,3 @@

- **Pedro Madruga** - _Initial work and maintenance_ - [pmadruga](https://github.com/pmadruga)
* **Pedro Madruga** - _Initial work and maintenance_ - [pmadruga](https://github.com/pmadruga)

@@ -67,0 +73,0 @@ See also the list of [contributors](https://github.com/pmadruga/react-native-clean-project/graphs/contributors) who participated in this project.

#!/usr/bin/env node
/* eslint-disable no-console */
const options = require('./internals/options');
const { executeTask } = require('./internals/executor');
const { tasks } = require('./internals/tasks');
const { spawn } = require('child_process');
const { createInterface } = require('readline');
const tasksList = {
wipeiOSBuildFolder: {
name: 'wipe iOS build folder',
command: 'rm',
args: ['-rf', 'ios/build']
},
wipeAndroidBuildFolder: {
name: 'wipe android build folder',
command: 'rm',
args: ['-rf', 'android/build']
},
watchmanCacheClear: {
name: 'watchman cache clear',
command: 'watchman',
args: ['watch-del-all']
},
wipeTempCaches: {
name: 'wipe temporary caches',
command: 'rm',
args: ['-rf', '$TMPDIR/react-*', '$TMPDIR/metro-*']
},
brewUpdate: {
name: 'brew update',
command: 'brew',
args: ['update']
},
brewUpgrade: {
name: 'brew upgrade',
command: 'brew',
args: ['upgrade']
},
wipeNodeModules: {
name: 'wipe node_modules',
command: 'rm',
args: ['-rf', 'node_modules', '$TMPDIR/react-*', '$TMPDIR/metro-*']
},
yarnCacheClean: {
name: 'yarn cache clean',
command: 'yarn',
args: ['cache', 'clean']
},
yarnInstall: {
name: 'yarn install',
command: 'yarn',
args: ['install']
}
};
function elapsedTime (startTime) {
const precision = 0;
const elapsed = process.hrtime(startTime)[1] / 1000000;
const secondCount = process.hrtime(startTime)[0];
const millisecondCount = elapsed.toFixed(precision);
if (secondCount > 0) return `${secondCount}s`;
return `${millisecondCount}ms`;
}
function executeTask (task) {
return new Promise((resolve, reject) => {
const startTime = process.hrtime();
const spawnedTask = spawn(task.command, task.args);
spawnedTask.stderr.on('data', data => {
console.log(`Error running ${task.name}: ${data}`);
});
spawnedTask.on('error', error => {
console.log(`❌ Command execution failed with error: ${error.message}`);
reject();
});
spawnedTask.on('exit', code => {
if (code !== 0) {
console.log(`❌ Command execution failed with code: ${code}`);
reject();
} else {
console.log(
`✅ ${task.name} task has finished running in ${elapsedTime(
startTime
)}.`
);
resolve(code);
}
});
});
}
const rlInterface = createInterface({
input: process.stdin,
output: process.stdout
});
// Possible arguments: --remove-iOS-build --remove-android-build --keep-node-modules
const args = process.argv.slice(2);
// Defaults
let wipeiOSBuild = false;
let wipeAndroidBuild = false;
let wipeNodeModules = true;
let updateBrew = true;
const askQuestion = (question, callback) => {
rlInterface.question(question, answer => {
callback(answer);
});
};
const checkAnswer = (answer, questionFunction, resolve) => {
if (answer === 'Y') {
resolve();
return true;
} else if (answer === 'n') {
resolve();
return false;
}
console.log("🚫 Please select 'Y' for yes, or 'n' for no.");
questionFunction().then(() => resolve());
return false;
};
const askiOS = () =>
new Promise(resolve => {
if (args.includes('--remove-iOS-build')) {
wipeiOSBuild = true;
return resolve();
options
.askiOS()
.then(options.askiOSPods)
.then(options.askUpdatePods)
.then(options.askAndroid)
.then(options.askNodeModules)
.then(options.askBrew)
.then(() => {
options.rlInterface.close();
if (options.getWipeiOSBuild()) {
executeTask(tasks.wipeiOSBuildFolder);
}
return askQuestion('Wipe iOS build folder? (Y/n) ', answer => {
wipeiOSBuild = checkAnswer(answer, askiOS, resolve);
});
});
const askAndroid = () =>
new Promise(resolve => {
if (args.includes('--remove-android-build')) {
wipeAndroidBuild = true;
return resolve();
if (options.getWipeiOSPods()) {
executeTask(tasks.wipeiOSPodsFolder);
}
return askQuestion('Wipe android build folder? (Y/n) ', answer => {
wipeAndroidBuild = checkAnswer(answer, askAndroid, resolve);
});
});
const askNodeModules = () =>
new Promise(resolve => {
if (args.includes('--keep-node-modules')) {
wipeNodeModules = false;
return resolve();
if (options.getWipeAndroidBuild()) {
executeTask(tasks.wipeAndroidBuildFolder);
}
return askQuestion('Wipe node_modules folder? (Y/n) ', answer => {
wipeNodeModules = checkAnswer(answer, askNodeModules, resolve);
});
});
const askBrew = () =>
new Promise(resolve => {
if (args.includes('--keep-brew')) {
updateBrew = false;
return resolve();
executeTask(tasks.watchmanCacheClear);
executeTask(tasks.wipeTempCaches);
if (options.getUpdateBrew()) {
executeTask(tasks.brewUpdate)
.then(code => {
if (code === 0) {
executeTask(tasks.brewUpgrade);
}
})
.catch(() => {
console.log(
"❌ Skipping task 'brew upgrade' because there was an error with 'brew update'"
);
});
}
return askQuestion('Update brew? (Y/n) ', answer => {
updateBrew = checkAnswer(answer, askBrew, resolve);
});
});
askiOS()
.then(askAndroid)
.then(askNodeModules)
.then(askBrew)
.then(() => {
rlInterface.close();
if (wipeiOSBuild) executeTask(tasksList.wipeiOSBuildFolder);
if (wipeAndroidBuild) executeTask(tasksList.wipeAndroidBuildFolder);
executeTask(tasksList.watchmanCacheClear);
executeTask(tasksList.wipeTempCaches);
if (updateBrew) executeTask(tasksList.brewUpdate)
.then(code => {
if (code === 0) {
executeTask(tasksList.brewUpgrade);
}
})
.catch(() => {
console.log(
"❌ Skipping task 'brew upgrade' because there was an error with 'brew update'"
);
});
if (wipeNodeModules) {
executeTask(tasksList.wipeNodeModules)
.then(() => executeTask(tasksList.yarnCacheClean))
.then(() => executeTask(tasksList.yarnInstall))
if (options.getWipeNodeModules()) {
executeTask(tasks.wipeNodeModules)
.then(() => executeTask(tasks.yarnCacheClean))
.then(() => executeTask(tasks.npmCacheVerify))
.then(() => executeTask(tasks.yarnInstall))
.then(() => options.getUpdatePods() && executeTask(tasks.updatePods))
.catch(() => {
console.log(
"❌ Skipping tasks 'yarn cache clean' and 'yarn install' because there was an error with wiping the node_modules folder"
'❌ Examine output - error in either yarn cache clean, yarn install, or pod update'
);

@@ -203,3 +52,1 @@ });

});
module.exports = { tasksList };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc