diff --git a/scripts/tasks/sandbox-parts.ts b/scripts/tasks/sandbox-parts.ts index d7d90ec58f16..b1464781e9e8 100644 --- a/scripts/tasks/sandbox-parts.ts +++ b/scripts/tasks/sandbox-parts.ts @@ -7,6 +7,7 @@ import { ensureDir, ensureSymlink, existsSync, + mkdir, pathExists, readFile, readFileSync, @@ -157,6 +158,13 @@ export const init: Task['run'] = async ( extra = { type: 'react_native_web' }; } + switch (template.expected.framework) { + case '@storybook/react-native-web-vite': + await prepareReactNativeWebSandbox(cwd); + break; + default: + } + await executeCLIStep(steps.init, { cwd, optionValues: { debug, yes: true, 'skip-install': true, ...extra }, @@ -841,6 +849,14 @@ export async function setImportMap(cwd: string) { await writeJson(join(cwd, 'package.json'), packageJson, { spaces: 2 }); } +async function prepareReactNativeWebSandbox(cwd: string) { + // Make it so that RN sandboxes have stories in src/stories similar to + // other react sandboxes, for consistency. + if (!(await pathExists(join(cwd, 'src')))) { + await mkdir(join(cwd, 'src')); + } +} + async function prepareAngularSandbox(cwd: string, templateName: string) { const angularJson = await readJson(join(cwd, 'angular.json'));