Skip to content

Commit

Permalink
Merge pull request #22972 from storybookjs/feat/addon-onboarding
Browse files Browse the repository at this point in the history
React: Add addon-onboarding as part of init
  • Loading branch information
valentinpalkovic authored Jun 22, 2023
2 parents 3687785 + 90b779e commit dd7032b
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 4 deletions.
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

0 comments on commit dd7032b

Please sign in to comment.