-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env node | ||
|
||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
const exec = require('child_process'); | ||
const execSync = require('child_process').execSync; | ||
//const chalk = require('chalk'); | ||
//const prompt = require('prompt'); | ||
//const semver = require('semver'); | ||
/** | ||
* Used arguments: | ||
* -v --version - to print current version of react-native-cli and react-native dependency | ||
* if you are in a RN app folder | ||
* init - to create a new project and npm install it | ||
* --verbose - to print logs while init | ||
* --version <alternative react-native package> - override default (https://registry.npmjs.org/react-native@latest), | ||
* package to install, examples: | ||
* - "0.22.0-rc1" - A new app will be created using a specific version of React Native from npm repo | ||
* - "https://registry.npmjs.org/react-native/-/react-native-0.20.0.tgz" - a .tgz archive from any npm repo | ||
* - "/Users/home/react-native/react-native-0.22.0.tgz" - for package prepared with `npm pack`, useful for e2e tests | ||
*/ | ||
|
||
const options = require('minimist')(process.argv.slice(2)); | ||
|
||
const CLI_MODULE_PATH = () => { | ||
return path.resolve(process.cwd(), 'node_modules', 'detox', 'cli.js'); | ||
}; | ||
|
||
const DETOX_PACKAGE_JSON_PATH = () => { | ||
return path.resolve(process.cwd(), 'node_modules', 'detox', 'package.json'); | ||
}; | ||
|
||
if (options._.length === 0) { | ||
printVersionsAndExit(DETOX_PACKAGE_JSON_PATH()); | ||
} else { | ||
var cli; | ||
var cliPath = CLI_MODULE_PATH(); | ||
if (fs.existsSync(cliPath)) { | ||
cli = require(cliPath); | ||
//exec.execSync(`node ${cliPath}`); | ||
|
||
} | ||
|
||
var commands = options._; | ||
if (cli) { | ||
//cli.run(); | ||
} | ||
process.exit(); | ||
} | ||
|
||
function printVersionsAndExit(reactNativePackageJsonPath) { | ||
console.log('detox-cli: ' + require('./package.json').version); | ||
try { | ||
console.log('detox: ' + require(reactNativePackageJsonPath).version); | ||
} catch (e) { | ||
console.log('detox: n/a - detox is not installed in this project'); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"name": "detox-cli", | ||
"version": "0.0.1", | ||
"description": "detox CLI tool wrapper", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "jest" | ||
}, | ||
"bin": { | ||
"detox": "./index.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/wix/detox.git" | ||
}, | ||
"keywords": [ | ||
"detox", | ||
"cli" | ||
], | ||
"author": "Rotem Meidan <[email protected]>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/wix/detox/issues" | ||
}, | ||
"dependencies": { | ||
"minimist": "^1.2.0", | ||
"commander": "^2.9.0" | ||
}, | ||
"devDependencies": { | ||
"babel-jest": "*", | ||
"babel-plugin-transform-async-to-generator": "^6.5.0", | ||
"babel-polyfill": "*", | ||
"babel-preset-es2015": "*", | ||
"jest": "*" | ||
}, | ||
"homepage": "https://github.com/wix/detox#readme", | ||
"jest": { | ||
"verbose": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#! /usr/bin/env node | ||
|
||
const log = require('npmlog'); | ||
const program = require('commander'); | ||
|
||
program | ||
.arguments('<process>') | ||
.parse(process.argv); | ||
|
||
//console.log('server'); | ||
log.verbose('server'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#! /usr/bin/env node | ||
|
||
const log = require('npmlog'); | ||
const program = require('commander'); | ||
|
||
program | ||
.arguments('<process>') | ||
.command('server', 'starts the detox server') | ||
.option('-v, --verbose', 'verbose log ?', false) | ||
.option('--loglevel <level>', 'log level', /^(silly|verbose|info|warn|error)$/i, 'info') | ||
.parse(process.argv); | ||
|
||
log.level = setLogLevel(); | ||
|
||
function setLogLevel() { | ||
if (program.verbose) { | ||
return 'verbose'; | ||
} | ||
|
||
return program.loglevel; | ||
} | ||
|
||
log.verbose('cli'); |