react-native-component
Advanced tools
+1
-1
@@ -11,3 +11,3 @@ #!/usr/bin/env node | ||
| .option('-p, --path [value]', 'Path of new component', '') | ||
| .version('0.1.0', '-v, --version') | ||
| .version('0.1.8', '-v, --version') | ||
| .parse(process.argv); | ||
@@ -14,0 +14,0 @@ |
+9
-13
@@ -1,13 +0,11 @@ | ||
| const path = require('path'); | ||
| const { copyFile, removeFile, replaceFile } = require('./utils'); | ||
| const { copyFile, replaceFile } = require('./utils'); | ||
| const GENERIC_STATELESS_COMPONENT_PATH = './lib/genericStateless.js'; | ||
| const GENERIC_STATELESS_COMPONENT_PATH_TMP = './lib/genericStatelessTmp.js'; | ||
| const GENERIC_COMPONENT_PATH = './lib/generic.js'; | ||
| const GENERIC_COMPONENT_PATH_TMP = './lib/genericTmp.js'; | ||
| const GENERIC_COMPONENT_STYLES_PATH = './lib/styles.js'; | ||
| const GENERIC_REGEXP = 'GenericComponent'; | ||
| const GENERIC_STATELESS_COMPONENT_PATH = '/genericStateless.js'; | ||
| const GENERIC_COMPONENT_PATH = '/generic.js'; | ||
| const GENERIC_COMPONENT_STYLES_PATH = '/styles.js'; | ||
| const createComponent = function(name, newPath, stateless) { | ||
| let created = true; | ||
| let indexNewPath = `${name}/index.js`; | ||
| let indexNewPath =`${name}/index.js`; | ||
| let stylesNewPath = `${name}/styles.js`; | ||
@@ -24,11 +22,9 @@ | ||
| const componentPath = stateless ? GENERIC_STATELESS_COMPONENT_PATH : GENERIC_COMPONENT_PATH; | ||
| const componentPathTmp = stateless ? GENERIC_STATELESS_COMPONENT_PATH_TMP : GENERIC_COMPONENT_PATH_TMP; | ||
| created = created && copyFile(componentPath, componentPathTmp); | ||
| created = created && replaceFile(componentPathTmp, /GenericComponent/g, name); | ||
| created = created && copyFile(componentPathTmp, indexNewPath); | ||
| created = created && replaceFile(componentPath, GENERIC_REGEXP, name); | ||
| created = created && copyFile(componentPath, indexNewPath); | ||
| created = created && copyFile(GENERIC_COMPONENT_STYLES_PATH, stylesNewPath); | ||
| return created && removeFile(componentPathTmp); | ||
| return created && replaceFile(componentPath, name, GENERIC_REGEXP); | ||
| }; | ||
| exports.createComponent = createComponent; |
+6
-16
@@ -0,1 +1,2 @@ | ||
| const path = require('path'); | ||
| const fse = require('fs-extra'); | ||
@@ -5,5 +6,5 @@ const replace = require('replace-in-file'); | ||
| const copyFile = function (src, dest) { | ||
| const copyFile = async function (src, dest) { | ||
| try { | ||
| fse.copySync(src, dest); | ||
| fse.copySync(path.join(__dirname, src), dest); | ||
| return true; | ||
@@ -16,16 +17,6 @@ } catch (err) { | ||
| const removeFile = function (src) { | ||
| try { | ||
| fse.removeSync(src); | ||
| return true; | ||
| } catch (err) { | ||
| console.log(colors.red(err)); | ||
| return false; | ||
| } | ||
| }; | ||
| const replaceFile = function(files, from, to) { | ||
| const replaceFile = async function(files, from, to) { | ||
| const options = { | ||
| files, | ||
| from, | ||
| files: path.join(__dirname, files), | ||
| from: new RegExp(from, 'g'), | ||
| to | ||
@@ -47,3 +38,2 @@ }; | ||
| copyFile, | ||
| removeFile, | ||
| replaceFile, | ||
@@ -50,0 +40,0 @@ printMessage, |
+1
-1
| { | ||
| "name": "react-native-component", | ||
| "version": "0.1.7", | ||
| "version": "0.1.8", | ||
| "description": "Generate skeletons for react native components", | ||
@@ -5,0 +5,0 @@ "main": "./lib/fileHandler.js", |
+4
-3
@@ -11,5 +11,6 @@ # react-native-component | ||
| ``` | ||
| |- ComponentName | ||
| |--- generic.js | ||
| |--- styles.js | ||
| . | ||
| ├── ComponentName | ||
| ├── index.js | ||
| ├── styles.js | ||
| ``` | ||
@@ -16,0 +17,0 @@ |
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
57
1.79%6644
-4.95%110
-10.57%