Skip to content

Commit

Permalink
Merge pull request #4149 from storybooks/open-tab
Browse files Browse the repository at this point in the history
start-storybook: open browser tab on first compilation
  • Loading branch information
Hypnosphi committed Sep 10, 2018
2 parents 4f61a2f + c2489e0 commit a848486
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

## From version 3.3.x to 3.4.x

There are no expected breaking changes in the 3.4.x release, but 3.4 contains a major refactor to make it easier to support new frameworks, and we will document any breaking changes here if they arise.
Expand Down
6 changes: 6 additions & 0 deletions docs/src/pages/configurations/cli-options/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ Here are all those options:
-h, --host [string] Host to run Storybook
-s, --static-dir <dir-names> Directory where to load static files from, comma-separated list
-c, --config-dir [dir-name] Directory where to load Storybook configurations from
--https Serve Storybook over HTTPS. Note: You must provide your own certificate information.
--ssl-ca <ca> Provide an SSL certificate authority. (Optional with --https, required if using a self-signed certificate)
--ssl-cert <cert> Provide an SSL certificate. (Required with --https)
--ssl-key <key> Provide an SSL key. (Required with --https)
--smoke-test Exit after successful start
--ci CI mode (skip interactive prompts, don't open browser)
--quiet Suppress verbose build output

## For build-storybook
Expand Down
1 change: 1 addition & 0 deletions lib/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"interpret": "^1.1.0",
"json5": "^2.0.1",
"object.omit": "^3.0.0",
"opn": "^5.3.0",
"postcss-flexbugs-fixes": "^4.1.0",
"postcss-loader": "^3.0.0",
"prop-types": "^15.6.2",
Expand Down
7 changes: 6 additions & 1 deletion lib/core/src/server/build-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import chalk from 'chalk';
import detectFreePort from 'detect-port';
import inquirer from 'inquirer';
import { logger } from '@storybook/node-logger';
import opn from 'opn';

import storybook, { webpackValid } from './middleware';
import { parseList, getEnvConfig } from './utils';
import './config/env';
Expand Down Expand Up @@ -41,6 +43,7 @@ export async function buildDev({ packageJson, ...loadOptions }) {
.option('--ssl-cert <cert>', 'Provide an SSL certificate. (Required with --https)')
.option('--ssl-key <key>', 'Provide an SSL key. (Required with --https)')
.option('--smoke-test', 'Exit after successful start')
.option('--ci', "CI mode (skip interactive prompts, don't open browser")
.option('--quiet', 'Suppress verbose build output')
.parse(process.argv);

Expand All @@ -57,7 +60,7 @@ export async function buildDev({ packageJson, ...loadOptions }) {

const port = await getFreePort(program.port);

if (!program.smokeTest && program.port != null && port !== program.port) {
if (!program.ci && !program.smokeTest && program.port != null && port !== program.port) {
const { shouldChangePort } = await inquirer.prompt({
type: 'confirm',
default: true,
Expand Down Expand Up @@ -153,6 +156,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 if (!program.ci) {
opn(address);
}
} catch (error) {
if (error instanceof Error) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
"test": "node ./scripts/test.js",
"test-latest-cra": "npm --prefix lib/cli run test-latest-cra"
},
Expand Down

0 comments on commit a848486

Please sign in to comment.