react-native-cli
Advanced tools
Comparing version 0.1.7 to 0.1.8
72
index.js
@@ -86,7 +86,12 @@ #!/usr/bin/env node | ||
if (args[1]) { | ||
var verbose = process.argv.indexOf('--verbose') >= 0; | ||
init(args[1], verbose); | ||
var logLevel = ''; | ||
if (process.argv.indexOf('--verbose') >= 0) { | ||
logLevel = 'verbose'; | ||
} else if (process.argv.indexOf('--debug') >= 0) { | ||
logLevel = 'debug'; | ||
} | ||
init(args[1], logLevel); | ||
} else { | ||
console.error( | ||
'Usage: react-native init <ProjectName> [--verbose]' | ||
'Usage: react-native init <ProjectName> [--debug|--verbose]' | ||
); | ||
@@ -127,13 +132,13 @@ process.exit(1); | ||
function init(name, verbose) { | ||
function init(name, logLevel) { | ||
validatePackageName(name); | ||
if (fs.existsSync(name)) { | ||
createAfterConfirmation(name, verbose); | ||
createAfterConfirmation(name, logLevel); | ||
} else { | ||
createProject(name, verbose); | ||
createProject(name, logLevel); | ||
} | ||
} | ||
function createAfterConfirmation(name, verbose) { | ||
function createAfterConfirmation(name, logLevel) { | ||
prompt.start(); | ||
@@ -143,3 +148,3 @@ | ||
name: 'yesno', | ||
message: 'Directory ' + name + ' already exist. Continue?', | ||
message: 'Directory ' + name + ' already exists. Continue?', | ||
validator: /y[es]*|n[o]?/, | ||
@@ -152,3 +157,3 @@ warning: 'Must respond yes or no', | ||
if (result.yesno[0] === 'y') { | ||
createProject(name, verbose); | ||
createProject(name, logLevel); | ||
} else { | ||
@@ -161,3 +166,3 @@ console.log('Project initialization canceled'); | ||
function createProject(name, verbose) { | ||
function createProject(name, logLevel) { | ||
var root = path.resolve(name); | ||
@@ -180,3 +185,3 @@ var projectName = path.basename(root); | ||
scripts: { | ||
start: 'react-native start' | ||
start: 'node node_modules/react-native/local-cli/cli.js start' | ||
} | ||
@@ -189,27 +194,16 @@ }; | ||
if (verbose) { | ||
runVerbose(root, projectName); | ||
} else { | ||
run(root, projectName); | ||
} | ||
run(root, projectName, logLevel); | ||
} | ||
function run(root, projectName) { | ||
exec('npm install --save react-native', function(e, stdout, stderr) { | ||
if (e) { | ||
console.log(stdout); | ||
console.error(stderr); | ||
console.error('`npm install --save react-native` failed'); | ||
process.exit(1); | ||
} | ||
checkNodeVersion(); | ||
var cli = require(CLI_MODULE_PATH()); | ||
cli.init(root, projectName); | ||
}); | ||
} | ||
function runVerbose(root, projectName) { | ||
var proc = spawn('npm', ['install', '--verbose', '--save', 'react-native'], {stdio: 'inherit'}); | ||
function run(root, projectName, logLevel) { | ||
var args = ['install', '--save']; | ||
if (logLevel === 'verbose') { | ||
args.push('--verbose'); | ||
} | ||
args.push('react-native'); | ||
var spawnArgs = {}; | ||
if (logLevel === 'debug' || logLevel === 'verbose') { | ||
spawnArgs = {stdio: 'inherit'}; | ||
} | ||
var proc = spawn('npm', args, spawnArgs); | ||
proc.on('close', function (code) { | ||
@@ -221,2 +215,4 @@ if (code !== 0) { | ||
checkNodeVersion(); | ||
cli = require(CLI_MODULE_PATH()); | ||
@@ -245,6 +241,10 @@ cli.init(root, projectName); | ||
if (process.argv.indexOf('-v') >= 0 || process.argv.indexOf('--version') >= 0) { | ||
var pjson = require('./package.json'); | ||
console.log(pjson.version); | ||
console.log('react-native-cli: ' + require('./package.json').version); | ||
try { | ||
console.log('react-native: ' + require(REACT_NATIVE_PACKAGE_JSON_PATH()).version); | ||
} catch (e) { | ||
console.log('react-native: n/a - not inside a React Native project directory') | ||
} | ||
process.exit(); | ||
} | ||
} |
{ | ||
"name": "react-native-cli", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"license" : "BSD-3-Clause", | ||
"description": "The React Native CLI tools", | ||
@@ -9,2 +10,6 @@ "main": "index.js", | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/facebook/react-native.git" | ||
}, | ||
"scripts": { | ||
@@ -11,0 +16,0 @@ "test": "mocha" |
@@ -109,1 +109,13 @@ ## Running CLI with local modifications | ||
See the [nvm guide](https://github.com/creationix/nvm#usage) for more info. | ||
### Alternative workflow | ||
If you don't want to install Sinopia you could still test changes done on the cli by creating a sample project and installing your checkout of `react-native` on that project instead of downloading it from npm. The simplest way to do this is by: | ||
$ npm init AwesomeProject | ||
$ cd AwesomeProject | ||
$ npm install $REACT_NATIVE_GITHUB | ||
Note that `REACT_NATIVE_GITHUB` should point to the directory where you have a checkout. | ||
Also, if the changes you're making get triggered when running `react-native init AwesomeProject` you will want to tweak the global installed `react-native-cli` library to install the local checkout instead of downloading the module from npm. To do so just change this [line](https://github.com/facebook/react-native/blob/master/react-native-cli/index.js#L191) and refer the local checkout instead. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
11188
0
213
121
5