Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

start-storybook: open browser tab on first compilation #4149

Merged
merged 3 commits into from
Sep 10, 2018
Merged

Conversation

Hypnosphi
Copy link
Member

norbert [11:35 AM]
@hypnos next up the auto-open browser feature?

How to test

Run yarn start

@@ -153,6 +155,8 @@ Would you like to run Storybook on port ${port} instead?`,
logger.info(`Storybook started on => ${chalk.cyan(address)}\n`);
if (program.smokeTest) {
process.exit(stats.toJson().warnings.length ? 1 : 0);
} else {
opn(address);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of users are using SB dev mode in CI. I would say that this should be opt-out

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@codecov
Copy link

codecov bot commented Sep 9, 2018

Codecov Report

Merging #4149 into master will decrease coverage by 0.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4149      +/-   ##
==========================================
- Coverage   40.46%   40.45%   -0.02%     
==========================================
  Files         491      491              
  Lines        5839     5841       +2     
  Branches      792      792              
==========================================
  Hits         2363     2363              
- Misses       3088     3090       +2     
  Partials      388      388
Impacted Files Coverage Δ
lib/core/src/server/build-dev.js 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4f61a2f...c2489e0. Read the comment docs.

@@ -88,6 +88,10 @@ Storybook now uses Babel 7. There's a couple of cases when it can break with you
```
* If you're using Babel 6, make sure that you have direct dependencies on `babel-core@6` and `babel-loader@7`.

### start-storybook opens browser automatically

If you're using `start-storybook` on CI, you may need to opt out of this using the new `--ci` flag.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe check for process.env.CI too? It's set by most CI systems

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually think that ci is too limiting

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep. it would be much better to have something like BROWSER=none start-storybook. This is the same, that is used by cra or docusaurus.

@@ -53,7 +53,7 @@
"postpublish": "yarn --cwd lib/cli test -o",
"publish:alpha": "npm run publish -- --npm-tag=alpha",
"repo-dirty-check": "node ./scripts/repo-dirty-check",
"start": "npm --prefix examples/official-storybook run storybook",
"start": "yarn --cwd examples/official-storybook storybook",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this require people to have yarn installed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really, I believe this is only applicable to the storybook project itself

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this require people to have yarn installed?

You need it anyway when you contribute to storybook, see CONTRIBUTING.md

@libetl
Copy link
Member

libetl commented Sep 10, 2018

Devs restarting locally their already opened storybook will have to provide --ci, which might not be the most meaningful parameter name. WDYT ? (somethink containing 'skip' or 'browser' could be easier to understand)

@Hypnosphi
Copy link
Member Author

I don't think that opening more than one tab is so much a problem. CRA tries to solve it on OS X this using appleScript.

The problem is, it opens Google Chrome regardless of which browser user has as default. I don't think we should do it unless Google acquires us.

@libetl
Copy link
Member

libetl commented Sep 10, 2018

I have been using react-scripts and I can tell that in windows/linux, it opens a new tab for each start command issued, which can be disturbing.
Ok, so I guess the situation cannot be improved today.

@Hypnosphi Hypnosphi merged commit a848486 into master Sep 10, 2018
@Hypnosphi Hypnosphi deleted the open-tab branch September 10, 2018 09:22
@ndelangen
Copy link
Member

I think it's worth it Yes I've had like 10 tabs open with the same dev setup once.. Thats' not great, but overall I think the experience is better then not having anything opened at all.

Thanks @Hypnosphi 👍👍👍

@einarlove
Copy link

I'm on alpha.23 and it opens a new tab every time i restart storybook, regardless if I already have it open. I've used react-dev-utils/openBrowser.js before, and it uses opn like this pull-request adds, but also check with AppleScript if there is a tab already open.

@Hypnosphi
Copy link
Member Author

The problem is, it opens Google Chrome regardless of which browser user has as default. I don't think we should do it unless Google acquires us.

@ndelangen
Copy link
Member

@einarlove question:
Why do you need to restart storybook so many times?

I mean -I- do restart it all the time, so i know there are use cases. But mine is I maintain storybook's code...

I'd like to know what's yours. Perhaps you don't need to restart storybook all the time?


If you have multiple storybooks you can run them on a different port

If storybook breaks down somehow and the only fix is a restart, let's fix it?

@einarlove
Copy link

I always have it running and switching between branches might break it after a while. Suddenly there's a conflict in package.json and etc, and a restart might be required to get it up to speed again.

That's at least my experience. Maybe I'm overdoing it?

@ndelangen
Copy link
Member

Hmm, no that sounds like it could be quite common.

I guess our CLI could be smarter about broken code and recovering afterwards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants