Skip to content

Commit

Permalink
Build: Add extra dependencies for linked stories
Browse files Browse the repository at this point in the history
  • Loading branch information
shilman committed Sep 11, 2022
1 parent ce2a156 commit bc436e1
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions scripts/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { babelParse } from '../code/lib/csf-tools/src/babelParse';
import TEMPLATES from '../code/lib/cli/src/repro-templates';
import { servePackages } from './utils/serve-packages';
import { filterExistsInCodeDir, codeDir } from './utils/filterExistsInCodeDir';
import { JsPackageManagerFactory } from '../code/lib/cli/src/js-package-manager';

type Template = keyof typeof TEMPLATES;
const templates: Template[] = Object.keys(TEMPLATES) as any;
Expand Down Expand Up @@ -316,6 +317,23 @@ function workspacePath(type: string, packageName: string, workspaces: Workspace[
return workspace.location;
}

function addExtraDependencies({
cwd,
dryRun,
debug,
}: {
cwd: string;
dryRun: boolean;
debug: boolean;
}) {
const extraDeps = ['@storybook/jest'];
if (debug) console.log('🎁 Adding extra deps', extraDeps);
if (!dryRun) {
const packageManager = JsPackageManagerFactory.getPackageManager(false, cwd);
packageManager.addDependencies({ installAsDevDependencies: true }, extraDeps);
}
}

export async function sandbox(optionValues: OptionValues<typeof options>) {
const { template, forceDelete, forceReuse, dryRun, debug, fromLocalRepro } = optionValues;

Expand Down Expand Up @@ -457,6 +475,9 @@ export async function sandbox(optionValues: OptionValues<typeof options>) {
);
}

// Some addon stories require extra dependencies
addExtraDependencies({ cwd, dryRun, debug });

await addPackageScripts({
cwd,
scripts: {
Expand Down

0 comments on commit bc436e1

Please sign in to comment.