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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
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.


## 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",
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

"test": "node ./scripts/test.js",
"test-latest-cra": "npm --prefix lib/cli run test-latest-cra"
},
Expand Down