Skip to content
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
1 change: 0 additions & 1 deletion code/lib/create-storybook/src/generators/ANGULAR/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ const generator: Generator<{ projectName: string }> = async (
},
'angular',
{
extraAddons: [`@storybook/addon-onboarding`],
extraPackages: [
angularVersion
? `@angular-devkit/build-angular@${angularVersion}`
Expand Down
4 changes: 1 addition & 3 deletions code/lib/create-storybook/src/generators/EMBER/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ const generator: Generator = async (packageManager, npmOptions, options) => {
npmOptions,
{ ...options, builder: CoreBuilder.Webpack5 },
'ember',
{
staticDir: 'dist',
},
{ staticDir: 'dist' },
'ember'
);
};
Expand Down
6 changes: 1 addition & 5 deletions code/lib/create-storybook/src/generators/NEXTJS/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ const generator: Generator = async (packageManager, npmOptions, options) => {
npmOptions,
{ ...options, builder: CoreBuilder.Webpack5 },
'react',
{
staticDir,
extraAddons: [`@storybook/addon-onboarding`],
webpackCompiler: ({ builder }) => undefined,
},
{ staticDir, webpackCompiler: () => undefined },
'nextjs'
);
};
Expand Down
1 change: 0 additions & 1 deletion code/lib/create-storybook/src/generators/REACT/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const generator: Generator = async (packageManager, npmOptions, options) => {
await baseGenerator(packageManager, npmOptions, options, 'react', {
extraPackages,
webpackCompiler: ({ builder }) => (builder === CoreBuilder.Webpack5 ? 'swc' : undefined),
extraAddons: [`@storybook/addon-onboarding`],
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ const generator: Generator = async (packageManager, npmOptions, options) => {
npmOptions,
options,
'react',
{
extraPackages,
extraAddons: [`@storybook/addon-onboarding`],
},
{ extraPackages },
'react-native-web-vite'
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const generator: Generator = async (packageManager, npmOptions, options) => {
// Miscellaneous dependency to add to be sure Storybook + CRA is working fine with Yarn PnP mode
extraPackages.push('prop-types');

const extraAddons = [`@storybook/preset-create-react-app`, `@storybook/addon-onboarding`];
const extraAddons = [`@storybook/preset-create-react-app`];

await baseGenerator(
packageManager,
Expand Down
1 change: 0 additions & 1 deletion code/lib/create-storybook/src/generators/VUE3/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type { Generator } from '../types';

const generator: Generator = async (packageManager, npmOptions, options) => {
await baseGenerator(packageManager, npmOptions, options, 'vue3', {
extraAddons: [`@storybook/addon-onboarding`],
extraPackages: async ({ builder }) => {
return builder === CoreBuilder.Webpack5
? ['vue-loader@^17.0.0', '@vue/compiler-sfc@^3.2.0']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type { Generator } from '../types';

const generator: Generator = async (packageManager, npmOptions, options) => {
await baseGenerator(packageManager, npmOptions, options, 'react', {
extraAddons: [`@storybook/addon-onboarding`],
webpackCompiler: ({ builder }) => (builder === CoreBuilder.Webpack5 ? 'swc' : undefined),
});
};
Expand Down
5 changes: 4 additions & 1 deletion code/lib/create-storybook/src/generators/baseGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,14 @@ export async function baseGenerator(
extraAddons.push('@chromatic-com/storybook@^4');
}

// Add @storybook/addon-docs when docs feature is selected
if (features.includes('docs')) {
extraAddons.push('@storybook/addon-docs');
}

if (features.includes('onboarding')) {
extraAddons.push('@storybook/addon-onboarding');
}

// added to main.js
const addons = [
...(compiler ? [`@storybook/addon-webpack5-compiler-${compiler}`] : []),
Expand Down
2 changes: 1 addition & 1 deletion code/lib/create-storybook/src/generators/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export type Generator<T = void> = (
commandOptions?: CommandOptions
) => Promise<T>;

export type GeneratorFeature = 'docs' | 'test';
export type GeneratorFeature = 'docs' | 'test' | 'onboarding';

export type CommandOptions = {
packageManager: PackageManagerName;
Expand Down
19 changes: 19 additions & 0 deletions code/lib/create-storybook/src/initiate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ import { currentDirectoryIsEmpty, scaffoldNewProject } from './scaffold-new-proj

const logger = console;

const ONBOARDING_PROJECT_TYPES = [
ProjectType.REACT,
ProjectType.REACT_SCRIPTS,
ProjectType.REACT_NATIVE_WEB,
ProjectType.REACT_PROJECT,
ProjectType.WEBPACK_REACT,
ProjectType.NEXTJS,
ProjectType.VUE3,
ProjectType.ANGULAR,
];

const installStorybook = async <Project extends ProjectType>(
projectType: Project,
packageManager: JsPackageManager,
Expand Down Expand Up @@ -440,12 +451,16 @@ export async function doInitiate(options: CommandOptions): Promise<
if (isInteractive) {
selectedFeatures.add('test');
}
if (newUser) {
selectedFeatures.add('onboarding');
}
}

const telemetryFeatures = {
dev: true,
docs: selectedFeatures.has('docs'),
test: selectedFeatures.has('test'),
onboarding: selectedFeatures.has('onboarding'),
};

// Check if the current directory is empty.
Expand Down Expand Up @@ -577,6 +592,10 @@ export async function doInitiate(options: CommandOptions): Promise<
}
}

if (selectedFeatures.has('onboarding') && !ONBOARDING_PROJECT_TYPES.includes(projectType)) {
selectedFeatures.delete('onboarding');
}

if (!options.skipInstall) {
await packageManager.installDependencies();
}
Expand Down
Loading