Skip to content

Commit

Permalink
feat: #25510 add optional --no-dev option to storybook init CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-marbach_jpmc committed Apr 22, 2024
1 parent 7b2ddea commit e2f661e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions code/lib/cli/src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ command('init')
.option('-y --yes', 'Answer yes to all prompts')
.option('-b --builder <webpack5 | vite>', 'Builder library')
.option('-l --linkable', 'Prepare installation for link (contributor helper)')
.option(
'--no-dev',
'Complete the initialization of Storybook without running the Storybook dev server'
)
.action((options: CommandOptions) => {
initiate(options).catch(() => process.exit(1));
});
Expand Down
1 change: 1 addition & 0 deletions code/lib/cli/src/generators/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ export type CommandOptions = {
disableTelemetry?: boolean;
enableCrashReports?: boolean;
debug?: boolean;
dev?: boolean;
};
8 changes: 7 additions & 1 deletion code/lib/cli/src/initiate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,14 @@ export async function doInitiate(options: CommandOptions): Promise<
)
);

// the CLI option for `--dev/--no-dev` takes precedence other the automatic behavior
const shouldRunDev =
typeof options.dev === 'boolean'
? options.dev
: process.env.CI !== 'true' && process.env.IN_STORYBOOK_SANDBOX !== 'true';

return {
shouldRunDev: process.env.CI !== 'true' && process.env.IN_STORYBOOK_SANDBOX !== 'true',
shouldRunDev,
projectType,
packageManager,
storybookCommand,
Expand Down
1 change: 1 addition & 0 deletions docs/api/cli-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ Options include:
| `--debug` | Outputs more logs in the CLI to assist debugging<br/>`storybook init --debug` |
| `--disable-telemetry` | Disables Storybook's telemetry. Learn more about it [here](../configure/telemetry.md#how-to-opt-out)<br/>`storybook init --disable-telemetry` |
| `--enable-crash-reports` | Enables sending crash reports to Storybook's telemetry. Learn more about it [here](../configure/telemetry.md#crash-reports-disabled-by-default)<br/>`storybook init --enable-crash-reports` |
| `--no-dev` | Complete the initialization of Storybook without running the Storybook dev server<br/>`storybook init --no-dev` |

### `add`

Expand Down

0 comments on commit e2f661e

Please sign in to comment.