From 222ca3c0e3e5f60cee4c57e4439196e5f8728058 Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Thu, 15 Jun 2017 07:37:57 +1000 Subject: [PATCH 1/2] Fix bug in RN gestorybook - replace APP_NAME in the correct file - add a warning if APP_NAME cannot be found --- lib/cli/generators/REACT_NATIVE/index.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/cli/generators/REACT_NATIVE/index.js b/lib/cli/generators/REACT_NATIVE/index.js index 6e68458ddac1..a1c03a50da33 100644 --- a/lib/cli/generators/REACT_NATIVE/index.js +++ b/lib/cli/generators/REACT_NATIVE/index.js @@ -1,8 +1,9 @@ const mergeDirs = require('merge-dirs').default; -const helpers = require('../../lib/helpers'); const path = require('path'); const shell = require('shelljs'); const latestVersion = require('latest-version'); +const chalk = require('chalk'); +const helpers = require('../../lib/helpers'); module.exports = latestVersion('@storybook/react-native').then(version => { // copy all files from the template directory to project directory @@ -12,8 +13,14 @@ module.exports = latestVersion('@storybook/react-native').then(version => { const dirname = shell.ls('-d', 'ios/*.xcodeproj').stdout; const projectName = dirname && dirname.slice('ios/'.length, dirname.length - '.xcodeproj'.length - 1); - if (projectName) { - shell.sed('-i', '%APP_NAME%', projectName, 'storybook/index.js'); + if (!projectName) { + shell.sed('-i', '%APP_NAME%', projectName, 'storybook/storybook.js'); + } else { + helpers.paddedLog( + chalk.red( + 'ERR: Could not determine project name, see: https://github.com/storybooks/storybook/issues/1277' + ) + ); } const packageJson = helpers.getPackageJson(); From 07db118e0a891dc087048e673c1c56ad4e58b290 Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Thu, 15 Jun 2017 08:04:21 +1000 Subject: [PATCH 2/2] Fix typo --- lib/cli/generators/REACT_NATIVE/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cli/generators/REACT_NATIVE/index.js b/lib/cli/generators/REACT_NATIVE/index.js index a1c03a50da33..f0318e212508 100644 --- a/lib/cli/generators/REACT_NATIVE/index.js +++ b/lib/cli/generators/REACT_NATIVE/index.js @@ -13,12 +13,12 @@ module.exports = latestVersion('@storybook/react-native').then(version => { const dirname = shell.ls('-d', 'ios/*.xcodeproj').stdout; const projectName = dirname && dirname.slice('ios/'.length, dirname.length - '.xcodeproj'.length - 1); - if (!projectName) { + if (projectName) { shell.sed('-i', '%APP_NAME%', projectName, 'storybook/storybook.js'); } else { helpers.paddedLog( chalk.red( - 'ERR: Could not determine project name, see: https://github.com/storybooks/storybook/issues/1277' + 'ERR: Could not determine project name, to fix: https://github.com/storybooks/storybook/issues/1277' ) ); }