Skip to content

Commit

Permalink
Merge pull request #22502 from storybookjs/feat/generate-files-later-…
Browse files Browse the repository at this point in the history
…in-init

CLI: Improve steps in storybook init
  • Loading branch information
yannbf authored Jun 13, 2023
2 parents 421b066 + e833b90 commit b50aa50
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions code/lib/cli/src/generators/baseGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,17 +277,17 @@ export async function baseGenerator(
);
}

const packages = [
const allPackages = [
'storybook',
getExternalFramework(rendererId) ? undefined : `@storybook/${rendererId}`,
...frameworkPackages,
...addonPackages,
...extraPackages,
]
.filter(Boolean)
.filter(
(packageToInstall) => !installedDependencies.has(getPackageDetails(packageToInstall)[0])
);
].filter(Boolean);

const packages = [...new Set(allPackages)].filter(
(packageToInstall) => !installedDependencies.has(getPackageDetails(packageToInstall)[0])
);

logger.log();
const versionedPackagesSpinner = ora({
Expand All @@ -299,30 +299,6 @@ export async function baseGenerator(
);
versionedPackagesSpinner.succeed();

await fse.ensureDir(`./${storybookConfigFolder}`);

if (addMainFile) {
await configureMain({
framework: { name: frameworkInclude, options: options.framework || {} },
storybookConfigFolder,
docs: { autodocs: 'tag' },
addons: pnp ? addons.map(wrapForPnp) : addons,
extensions,
language,
...(staticDir ? { staticDirs: [path.join('..', staticDir)] } : null),
...extraMain,
...(type !== 'framework'
? {
core: {
builder: builderInclude,
},
}
: {}),
});
}

await configurePreview({ frameworkPreviewParts, storybookConfigFolder, language, rendererId });

const depsToInstall = [...versionedPackages];

// Add basic babel config for a select few frameworks that need it, if they do not have a babel config file already
Expand Down Expand Up @@ -385,6 +361,30 @@ export async function baseGenerator(
addDependenciesSpinner.succeed();
}

await fse.ensureDir(`./${storybookConfigFolder}`);

if (addMainFile) {
await configureMain({
framework: { name: frameworkInclude, options: options.framework || {} },
storybookConfigFolder,
docs: { autodocs: 'tag' },
addons: pnp ? addons.map(wrapForPnp) : addons,
extensions,
language,
...(staticDir ? { staticDirs: [path.join('..', staticDir)] } : null),
...extraMain,
...(type !== 'framework'
? {
core: {
builder: builderInclude,
},
}
: {}),
});
}

await configurePreview({ frameworkPreviewParts, storybookConfigFolder, language, rendererId });

if (addScripts) {
await stopIfExiting(async () =>
packageManager.addStorybookCommandInScripts({
Expand Down

0 comments on commit b50aa50

Please sign in to comment.