react-native-cli
Advanced tools
Comparing version 0.1.3 to 0.1.4
54
index.js
@@ -10,2 +10,3 @@ #!/usr/bin/env node | ||
var spawn = require('child_process').spawn; | ||
var prompt = require("prompt"); | ||
@@ -37,3 +38,4 @@ var CLI_MODULE_PATH = function() { | ||
if (args[0] === 'init') { | ||
switch (args[0]) { | ||
case 'init': | ||
if (args[1]) { | ||
@@ -47,5 +49,6 @@ init(args[1]); | ||
} | ||
} else { | ||
break; | ||
default: | ||
console.error( | ||
'Command `%s` unrecognized.' + | ||
'Command `%s` unrecognized. ' + | ||
'Did you mean to run this inside a react-native project?', | ||
@@ -55,6 +58,7 @@ args[0] | ||
process.exit(1); | ||
break; | ||
} | ||
} | ||
function init(name) { | ||
function validatePackageName(name) { | ||
if (!name.match(/^[$A-Z_][0-9A-Z_$]*$/i)) { | ||
@@ -69,2 +73,44 @@ console.error( | ||
if (name === 'React') { | ||
console.error( | ||
'"%s" is not a valid name for a project. Please do not use the ' + | ||
'reserved word "React".', | ||
name | ||
); | ||
process.exit(1); | ||
} | ||
} | ||
function init(name) { | ||
validatePackageName(name); | ||
if (fs.existsSync(name)) { | ||
createAfterConfirmation(name) | ||
} else { | ||
createProject(name); | ||
} | ||
} | ||
function createAfterConfirmation(name) { | ||
prompt.start(); | ||
var property = { | ||
name: 'yesno', | ||
message: 'Directory ' + name + ' already exist. Continue?', | ||
validator: /y[es]*|n[o]?/, | ||
warning: 'Must respond yes or no', | ||
default: 'no' | ||
}; | ||
prompt.get(property, function (err, result) { | ||
if (result.yesno[0] === 'y') { | ||
createProject(name); | ||
} else { | ||
console.log('Project initialization canceled'); | ||
process.exit(); | ||
} | ||
}); | ||
} | ||
function createProject(name) { | ||
var root = path.resolve(name); | ||
@@ -71,0 +117,0 @@ var projectName = path.basename(root); |
{ | ||
"name": "react-native-cli", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "The ReactNative cli tools", | ||
@@ -8,3 +8,6 @@ "main": "index.js", | ||
"react-native": "index.js" | ||
}, | ||
"dependencies": { | ||
"prompt": "^0.2.14" | ||
} | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
3475
137
1
1
+ Addedprompt@^0.2.14
+ Addedarray-buffer-byte-length@1.0.1(transitive)
+ Addedasync@0.2.10(transitive)
+ Addedavailable-typed-arrays@1.0.7(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedcall-bind@1.0.7(transitive)
+ Addedcolors@0.6.2(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedcycle@1.0.3(transitive)
+ Addeddeep-equal@2.2.3(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddefine-properties@1.2.1(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-get-iterator@1.1.3(transitive)
+ Addedeyes@0.1.8(transitive)
+ Addedfor-each@0.3.3(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedfunctions-have-names@1.2.3(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-bigints@1.0.2(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedi@0.3.7(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedinternal-slot@1.0.7(transitive)
+ Addedis-arguments@1.1.1(transitive)
+ Addedis-array-buffer@3.0.4(transitive)
+ Addedis-bigint@1.0.4(transitive)
+ Addedis-boolean-object@1.1.2(transitive)
+ Addedis-callable@1.2.7(transitive)
+ Addedis-date-object@1.0.5(transitive)
+ Addedis-map@2.0.3(transitive)
+ Addedis-number-object@1.0.7(transitive)
+ Addedis-regex@1.1.4(transitive)
+ Addedis-set@2.0.3(transitive)
+ Addedis-shared-array-buffer@1.0.3(transitive)
+ Addedis-string@1.0.7(transitive)
+ Addedis-symbol@1.0.4(transitive)
+ Addedis-weakmap@2.0.2(transitive)
+ Addedis-weakset@2.0.3(transitive)
+ Addedisarray@2.0.5(transitive)
+ Addedisstream@0.1.2(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedmute-stream@0.0.8(transitive)
+ Addedncp@0.4.2(transitive)
+ Addedobject-inspect@1.13.2(transitive)
+ Addedobject-is@1.1.6(transitive)
+ Addedobject-keys@1.1.1(transitive)
+ Addedobject.assign@4.1.5(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedpkginfo@0.3.10.4.1(transitive)
+ Addedpossible-typed-array-names@1.0.0(transitive)
+ Addedprompt@0.2.14(transitive)
+ Addedread@1.0.7(transitive)
+ Addedregexp.prototype.flags@1.5.2(transitive)
+ Addedrevalidator@0.1.8(transitive)
+ Addedrimraf@2.7.1(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedset-function-name@2.0.2(transitive)
+ Addedside-channel@1.0.6(transitive)
+ Addedstack-trace@0.0.10(transitive)
+ Addedstop-iteration-iterator@1.0.0(transitive)
+ Addedutile@0.2.1(transitive)
+ Addedwhich-boxed-primitive@1.0.2(transitive)
+ Addedwhich-collection@1.0.2(transitive)
+ Addedwhich-typed-array@1.1.15(transitive)
+ Addedwinston@0.8.3(transitive)
+ Addedwrappy@1.0.2(transitive)