diff --git a/dist/bin/storybook.js b/dist/bin/storybook.js index 292c1e3..21db030 100644 --- a/dist/bin/storybook.js +++ b/dist/bin/storybook.js @@ -1,6 +1,10 @@ #!/usr/bin/env node 'use strict'; +var _shelljs = require('shelljs'); + +var _shelljs2 = _interopRequireDefault(_shelljs); + var _commander = require('commander'); var _commander2 = _interopRequireDefault(_commander); @@ -26,4 +30,10 @@ _commander2.default.command('start [platform]').option('-h, --host ', 'hos }); }); +_commander2.default.command('run-ios').option('-a, --appname ', 'storybook application name eg. "MyAppStorybook"').option('-i, --identifier ', 'storybook application identifier eg. "org.mycompany.MyAppStorybook"').description('starts react native storybook ios simulator').action(function (env) { + _shelljs2.default.exec('react-native run-ios --scheme=' + env.appname); + _shelljs2.default.exec('xcrun simctl install booted ios/build/Build/Products/Debug-iphonesimulator/' + env.appname + '.app'); + _shelljs2.default.exec('xcrun simctl launch booted ' + env.identifier); +}); + _commander2.default.parse(process.argv); \ No newline at end of file diff --git a/package.json b/package.json index 24ee195..98cffa6 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "events": "^1.1.0", "express": "^4.14.0", "react-dom": "^15.1.0", + "shelljs": "^0.7.0", "ws": "^1.1.0" } } diff --git a/src/bin/storybook.js b/src/bin/storybook.js index 8cd381d..1008d23 100644 --- a/src/bin/storybook.js +++ b/src/bin/storybook.js @@ -1,5 +1,6 @@ #!/usr/bin/env node +import shell from 'shelljs'; import program from 'commander'; import server from '../server'; @@ -24,5 +25,16 @@ program }) }); +program + .command('run-ios') + .option('-a, --appname ', 'storybook application name eg. "MyAppStorybook"') + .option('-i, --identifier ', 'storybook application identifier eg. "org.mycompany.MyAppStorybook"') + .description('starts react native storybook ios simulator') + .action(function(env) { + shell.exec(`react-native run-ios --scheme=${env.appname}`); + shell.exec(`xcrun simctl install booted ios/build/Build/Products/Debug-iphonesimulator/${env.appname}.app`); + shell.exec(`xcrun simctl launch booted ${env.identifier}`); + }); + program .parse(process.argv);