Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React: Add addon-onboarding as part of init #22972

Merged
merged 7 commits into from
Jun 22, 2023
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
11 changes: 10 additions & 1 deletion code/lib/cli/src/generators/NEXTJS/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@ import { baseGenerator } from '../baseGenerator';
import type { Generator } from '../types';

const generator: Generator = async (packageManager, npmOptions, options) => {
await baseGenerator(packageManager, npmOptions, options, 'react', undefined, 'nextjs');
await baseGenerator(
packageManager,
npmOptions,
options,
'react',
{
extraAddons: ['@storybook/addon-onboarding'],
},
'nextjs'
);
};

export default generator;
1 change: 1 addition & 0 deletions code/lib/cli/src/generators/REACT/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const generator: Generator = async (packageManager, npmOptions, options) => {

await baseGenerator(packageManager, npmOptions, options, 'react', {
extraPackages,
extraAddons: ['@storybook/addon-onboarding'],
});
};

Expand Down
5 changes: 4 additions & 1 deletion code/lib/cli/src/generators/REACT_SCRIPTS/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ const generator: Generator = async (packageManager, npmOptions, options) => {
}

const version = versions['@storybook/preset-create-react-app'];
const extraAddons = [`@storybook/preset-create-react-app@${version}`];
const extraAddons = [
`@storybook/preset-create-react-app@${version}`,
'@storybook/addon-onboarding',
];

if (!isCra5OrHigher) {
throw new Error(dedent`
Expand Down
4 changes: 3 additions & 1 deletion code/lib/cli/src/generators/WEBPACK_REACT/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { baseGenerator } from '../baseGenerator';
import type { Generator } from '../types';

const generator: Generator = async (packageManager, npmOptions, options) => {
await baseGenerator(packageManager, npmOptions, options, 'react');
await baseGenerator(packageManager, npmOptions, options, 'react', {
extraAddons: ['@storybook/addon-onboarding'],
});
};

export default generator;
22 changes: 21 additions & 1 deletion code/lib/cli/src/initiate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,32 @@ async function doInitiate(options: CommandOptions, pkg: PackageJson): Promise<vo
logger.log('\nRunning Storybook');

try {
const isReactWebProject =
projectType === ProjectType.REACT_SCRIPTS ||
projectType === ProjectType.REACT ||
projectType === ProjectType.WEBPACK_REACT ||
projectType === ProjectType.REACT_PROJECT ||
projectType === ProjectType.NEXTJS;

const flags = [];

// npm needs extra -- to pass flags to the command
if (packageManager.type === 'npm') {
flags.push('--');
}

if (isReactWebProject) {
flags.push('--initial-path=/onboarding');
}

flags.push('--quiet');

// instead of calling 'dev' automatically, we spawn a subprocess so that it gets
// executed directly in the user's project directory. This avoid potential issues
// with packages running in npxs' node_modules
packageManager.runPackageCommandSync(
storybookCommand.replace(/^yarn /, ''),
['--quiet'],
flags,
undefined,
'inherit'
);
Expand Down
4 changes: 4 additions & 0 deletions scripts/verdaccio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ packages:
access: $all
publish: $all
proxy: npmjs
'@storybook/addon-onboarding':
access: $all
publish: $all
proxy: npmjs
'@storybook/mdx1-csf':
access: $all
publish: $all
Expand Down