From 94f4361eaba818bc01433b47908ad9ae75d90724 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Tue, 19 Dec 2023 12:51:35 +0100 Subject: [PATCH] remove the -s flag from build & dev --- code/lib/cli/src/generate.ts | 2 -- code/lib/core-server/src/build-static.ts | 19 +------------------ .../core-server/src/presets/common-preset.ts | 2 +- .../core-server/src/utils/server-statics.ts | 8 -------- 4 files changed, 2 insertions(+), 29 deletions(-) diff --git a/code/lib/cli/src/generate.ts b/code/lib/cli/src/generate.ts index 2594863f0e90..c964767da543 100644 --- a/code/lib/cli/src/generate.ts +++ b/code/lib/cli/src/generate.ts @@ -196,7 +196,6 @@ command('doctor') command('dev') .option('-p, --port ', 'Port to run Storybook', (str) => parseInt(str, 10)) .option('-h, --host ', 'Host to run Storybook') - .option('-s, --static-dir ', 'Directory where to load static files from', parseList) .option('-c, --config-dir ', 'Directory where to load Storybook configurations from') .option( '--https', @@ -251,7 +250,6 @@ command('dev') }); command('build') - .option('-s, --static-dir ', 'Directory where to load static files from', parseList) .option('-o, --output-dir ', 'Directory where to store built files') .option('-c, --config-dir ', 'Directory where to load Storybook configurations from') .option('--quiet', 'Suppress verbose build output') diff --git a/code/lib/core-server/src/build-static.ts b/code/lib/core-server/src/build-static.ts index b85932ca246d..7437ed394329 100644 --- a/code/lib/core-server/src/build-static.ts +++ b/code/lib/core-server/src/build-static.ts @@ -12,21 +12,15 @@ import { normalizeStories, resolveAddonName, } from '@storybook/core-common'; -import { ConflictingStaticDirConfigError } from '@storybook/core-events/server-errors'; -import isEqual from 'lodash/isEqual.js'; import dedent from 'ts-dedent'; import { outputStats } from './utils/output-stats'; -import { - copyAllStaticFiles, - copyAllStaticFilesRelativeToMain, -} from './utils/copy-all-static-files'; +import { copyAllStaticFilesRelativeToMain } from './utils/copy-all-static-files'; import { getBuilders } from './utils/get-builders'; import { extractStoriesJson } from './utils/stories-json'; import { extractStorybookMetadata } from './utils/metadata'; import { StoryIndexGenerator } from './utils/StoryIndexGenerator'; import { summarizeIndex } from './utils/summarizeIndex'; -import { defaultStaticDirs } from './utils/constants'; import { buildOrThrow } from './utils/build-or-throw'; export type BuildStaticStandaloneOptions = CLIOptions & @@ -41,10 +35,6 @@ export async function buildStaticStandalone(options: BuildStaticStandaloneOption throw new Error("Won't remove current directory. Check your outputDir!"); } - if (options.staticDir?.includes('/')) { - throw new Error("Won't copy root directory. Check your staticDirs!"); - } - options.outputDir = isAbsolute(options.outputDir) ? options.outputDir : join(process.cwd(), options.outputDir); @@ -131,10 +121,6 @@ export async function buildStaticStandalone(options: BuildStaticStandaloneOption build, }; - if (options.staticDir && !isEqual(staticDirs, defaultStaticDirs)) { - throw new ConflictingStaticDirConfigError(); - } - const effects: Promise[] = []; global.FEATURES = features; @@ -148,9 +134,6 @@ export async function buildStaticStandalone(options: BuildStaticStandaloneOption copyAllStaticFilesRelativeToMain(staticDirs, options.outputDir, options.configDir) ); } - if (options.staticDir) { - effects.push(copyAllStaticFiles(options.staticDir, options.outputDir)); - } const coreServerPublicDir = join( dirname(require.resolve('@storybook/core-server/package.json')), diff --git a/code/lib/core-server/src/presets/common-preset.ts b/code/lib/core-server/src/presets/common-preset.ts index 815b9cb72417..350872f38891 100644 --- a/code/lib/core-server/src/presets/common-preset.ts +++ b/code/lib/core-server/src/presets/common-preset.ts @@ -55,7 +55,7 @@ export const favicon = async ( const statics = staticDirsValue ? staticDirsValue.map((dir) => (typeof dir === 'string' ? dir : `${dir.from}:${dir.to}`)) - : options.staticDir; + : []; if (statics && statics.length > 0) { const lists = await Promise.all( diff --git a/code/lib/core-server/src/utils/server-statics.ts b/code/lib/core-server/src/utils/server-statics.ts index 386db92d143e..aa687c5bcc88 100644 --- a/code/lib/core-server/src/utils/server-statics.ts +++ b/code/lib/core-server/src/utils/server-statics.ts @@ -1,28 +1,20 @@ import { logger } from '@storybook/node-logger'; import type { Options } from '@storybook/types'; import { getDirectoryFromWorkingDir } from '@storybook/core-common'; -import { ConflictingStaticDirConfigError } from '@storybook/core-events/server-errors'; import chalk from 'chalk'; import type { Router } from 'express'; import express from 'express'; import { pathExists } from 'fs-extra'; import path, { basename, isAbsolute } from 'path'; -import isEqual from 'lodash/isEqual.js'; import { dedent } from 'ts-dedent'; -import { defaultStaticDirs } from './constants'; export async function useStatics(router: Router, options: Options) { const staticDirs = (await options.presets.apply('staticDirs')) ?? []; const faviconPath = await options.presets.apply('favicon'); - if (options.staticDir && !isEqual(staticDirs, defaultStaticDirs)) { - throw new ConflictingStaticDirConfigError(); - } - const statics = [ ...staticDirs.map((dir) => (typeof dir === 'string' ? dir : `${dir.from}:${dir.to}`)), - ...(options.staticDir || []), ]; if (statics && statics.length > 0) {