From 35ec49b93ff55074882b286b94b5f905bf8bd627 Mon Sep 17 00:00:00 2001 From: Farnabaz Date: Tue, 4 Aug 2020 17:59:46 +0430 Subject: [PATCH 1/4] feat(cli): support `--output-dir` & `--quiet` flags --- src/cli.ts | 15 +++++++++++---- src/index.ts | 3 ++- src/types.d.ts | 2 ++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/cli.ts b/src/cli.ts index c2467ab3..0634a08f 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -8,9 +8,14 @@ import { start, build } from './index' export const usage = 'nuxt storybook [`dev`|`build`] [`dir`]' function _run () { - const args = arg({}) + const args = arg({ + '--output-dir': String, + '-o': '--output-dir', + '--quiet': Boolean + }) + const { _, ...flags } = args - let [mode, _dir] = args._ + let [mode, _dir] = _ if (!_dir && fs.existsSync(mode)) { _dir = mode || '.' mode = 'dev' @@ -25,12 +30,14 @@ function _run () { case 'build': return build({ rootDir, - mode + mode, + ...flags }) case 'dev': return start({ rootDir, - mode + mode, + ...flags }) default: logger.error(`Command "${mode}" not found`) diff --git a/src/index.ts b/src/index.ts index 18e38f55..8a3004d8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -43,6 +43,7 @@ async function getStorybookConfig (options: StorybookOptions) { nuxtBuilder, nuxtWebpackConfig, nuxtStorybookConfig, + ...options, frameworkPresets: [ ...vueOptions.frameworkPresets, require.resolve('./preset') @@ -62,7 +63,7 @@ async function buildNuxt (options: StorybookOptions) { ssr: false, buildDir, build: { - corejs: '3', + corejs: 3, extractCSS: false } }, diff --git a/src/types.d.ts b/src/types.d.ts index 71696846..562d2545 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -10,4 +10,6 @@ export interface WebpackExtras { export interface StorybookOptions { rootDir: string; mode: string; + outputDir?: string; + quiet?: boolean; } From 456fbc948853dbd554245d8a80d0d4a6fb0581e2 Mon Sep 17 00:00:00 2001 From: Farnabaz Date: Tue, 4 Aug 2020 19:07:49 +0430 Subject: [PATCH 2/4] add `--static-dir` flag --- src/cli.ts | 2 ++ src/index.ts | 2 +- src/types.d.ts | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cli.ts b/src/cli.ts index 0634a08f..ea7ad280 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -9,6 +9,8 @@ export const usage = 'nuxt storybook [`dev`|`build`] [`dir`]' function _run () { const args = arg({ + '--static-dir': String, + '-s': '--static-dir', '--output-dir': String, '-o': '--output-dir', '--quiet': Boolean diff --git a/src/index.ts b/src/index.ts index 8a3004d8..4135b3b3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -63,7 +63,7 @@ async function buildNuxt (options: StorybookOptions) { ssr: false, buildDir, build: { - corejs: 3, + corejs: '3', extractCSS: false } }, diff --git a/src/types.d.ts b/src/types.d.ts index 562d2545..26b6ef6f 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -11,5 +11,6 @@ export interface StorybookOptions { rootDir: string; mode: string; outputDir?: string; + staticDir?: string; quiet?: boolean; } From e5b7d6f4ed0b97f249e9756170aee9b16194e8b0 Mon Sep 17 00:00:00 2001 From: Farnabaz Date: Tue, 4 Aug 2020 20:39:03 +0430 Subject: [PATCH 3/4] add port, host, ci and smoke-test --- src/cli.ts | 8 +++++++- src/types.d.ts | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/cli.ts b/src/cli.ts index ea7ad280..48ebdc89 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -13,7 +13,13 @@ function _run () { '-s': '--static-dir', '--output-dir': String, '-o': '--output-dir', - '--quiet': Boolean + '--quiet': Boolean, + '--smoke-test': Boolean, + '--ci': Boolean, + '--port': Number, + '-p': '--port', + '--host': String, + '-h': '--host' }) const { _, ...flags } = args diff --git a/src/types.d.ts b/src/types.d.ts index 26b6ef6f..09859200 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -13,4 +13,8 @@ export interface StorybookOptions { outputDir?: string; staticDir?: string; quiet?: boolean; + smokeTest?: Boolean; + ci?: Boolean; + port?: Number; + host?: String; } From e901756271b70b216c386dfb59a1d2df32ce36b6 Mon Sep 17 00:00:00 2001 From: Farnabaz Date: Tue, 4 Aug 2020 20:54:59 +0430 Subject: [PATCH 4/4] chore(docs): add CLI options --- docs/content/en/commands.md | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/docs/content/en/commands.md b/docs/content/en/commands.md index f5e420d6..c7085007 100644 --- a/docs/content/en/commands.md +++ b/docs/content/en/commands.md @@ -29,7 +29,18 @@ To start Storybook in development environment: -By default, it will start the development server on [http://localhost:3003](http://localhost:3003), you can configure the port in the [options](/options#port). +By default, it will start the development server on [http://localhost:3003](http://localhost:3003), you can configure the port in the [options](/options#port) or with CLI options. + +### CLI Options +Development command have some options you can pass to alter storybook behaviors. +``` +-p, --port [number] Port to run Storybook. +-h, --host [string] Host to run Storybook +-s, --static-dir Directory where to load static files from, comma-separated list. By default it loads Nuxt static dir +--smoke-test Exit after successful start +--ci CI mode (skip interactive prompts, don't open browser) +--quiet Suppress verbose build output +``` ## Export @@ -52,4 +63,12 @@ Export your Storybook into a static web application to deploy it to GitHub pages -This command will output a `storybook-static/` directory. +By default this command will output a `storybook-static/` directory. See command option to change output directory. + +### CLI Options +Build command have some options you can pass to alter storybook behaviors. +``` +-s, --static-dir Directory where to load static files from, comma-separated list. By default it loads Nuxt static dir +-o, --output-dir [dir-name] Directory where to store built files +--quiet +```