<commit_before>import chalk from 'chalk';
import cpy from 'cpy';
import fs from 'fs-extra';
import path from 'path';

import { logger } from '@storybook/node-logger';

import {
  loadAllPresets,
  LoadOptions,
  CLIOptions,
  BuilderOptions,
  Options,
  Builder,
} from '@storybook/core-common';
import * as managerBuilder from './manager/builder';

import { getProdCli } from './cli';
import { getPrebuiltDir } from './utils/prebuilt-manager';
import { cache } from './utils/cache';
import { copyAllStaticFiles } from './utils/copy-all-static-files';
import { getPreviewBuilder } from './utils/get-preview-builder';

export async function buildStaticStandalone(options: CLIOptions & LoadOptions & BuilderOptions) {
  /* eslint-disable no-param-reassign */
  options.configType = 'PRODUCTION';

  if (options.outputDir === '') {
    throw new Error("Won't remove current directory. Check your outputDir!");
  }

  options.outputDir = path.isAbsolute(options.outputDir)
    ? options.outputDir
    : path.join(process.cwd(), options.outputDir);
  options.configDir = path.resolve(options.configDir);
  /* eslint-enable no-param-reassign */

  const defaultFavIcon = require.resolve('./public/favicon.ico');
<commit_msg>fix(standalone): do not allow root directory as static dir<commit_after>import chalk from 'chalk';
import cpy from 'cpy';
import fs from 'fs-extra';
import path from 'path';

import { logger } from '@storybook/node-logger';

import {
  loadAllPresets,
  LoadOptions,
  CLIOptions,
  BuilderOptions,
  Options,
  Builder,
} from '@storybook/core-common';
import * as managerBuilder from './manager/builder';

import { getProdCli } from './cli';
import { getPrebuiltDir } from './utils/prebuilt-manager';
import { cache } from './utils/cache';
import { copyAllStaticFiles } from './utils/copy-all-static-files';
import { getPreviewBuilder } from './utils/get-preview-builder';

export async function buildStaticStandalone(options: CLIOptions & LoadOptions & BuilderOptions) {
  /* eslint-disable no-param-reassign */
  options.configType = 'PRODUCTION';

  if (options.outputDir === '') {
    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 = path.isAbsolute(options.outputDir)
    ? options.outputDir
    : path.join(process.cwd(), options.outputDir);
  options.configDir = path.resolve(options.configDir);
  /* eslint-enable no-param-reassign */

  const defaultFavIcon = require.resolve('./public/favicon.ico');

{'fraction_non_alphanumeric': 0.13863287250384024, 'fraction_numerical': 0.0, 'mean_word_length': 4.415800415800415, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4607754', 'n_tokens_mistral': 788, 'n_tokens_neox': 771, 'n_words': 195}