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

Core: Remove the -s flag from build & dev #25266

Merged
merged 1 commit into from
Dec 21, 2023
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
2 changes: 0 additions & 2 deletions code/lib/cli/src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ command('doctor')
command('dev')
.option('-p, --port <number>', 'Port to run Storybook', (str) => parseInt(str, 10))
.option('-h, --host <string>', 'Host to run Storybook')
.option('-s, --static-dir <dir-names>', 'Directory where to load static files from', parseList)
.option('-c, --config-dir <dir-name>', 'Directory where to load Storybook configurations from')
.option(
'--https',
Expand Down Expand Up @@ -251,7 +250,6 @@ command('dev')
});

command('build')
.option('-s, --static-dir <dir-names>', 'Directory where to load static files from', parseList)
.option('-o, --output-dir <dir-name>', 'Directory where to store built files')
.option('-c, --config-dir <dir-name>', 'Directory where to load Storybook configurations from')
.option('--quiet', 'Suppress verbose build output')
Expand Down
19 changes: 1 addition & 18 deletions code/lib/core-server/src/build-static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 &
Expand All @@ -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);
Expand Down Expand Up @@ -131,10 +121,6 @@ export async function buildStaticStandalone(options: BuildStaticStandaloneOption
build,
};

if (options.staticDir && !isEqual(staticDirs, defaultStaticDirs)) {
throw new ConflictingStaticDirConfigError();
}

const effects: Promise<void>[] = [];

global.FEATURES = features;
Expand All @@ -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')),
Expand Down
2 changes: 1 addition & 1 deletion code/lib/core-server/src/presets/common-preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 0 additions & 8 deletions code/lib/core-server/src/utils/server-statics.ts
Original file line number Diff line number Diff line change
@@ -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<string>('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) {
Expand Down
Loading