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

CLI: Add Server template generator #13979

Merged
merged 6 commits into from
May 31, 2021
Merged

Conversation

jonspalmer
Copy link
Contributor

@jonspalmer jonspalmer commented Feb 20, 2021

Issue: #12077

What I did

Added Cli generator support for Server

Open questions

It would be helpful to the user if the generator added a few stanzas to .storybook/preview.js to template the configuration required to point to the server backend. However, I'm a little lost as to have to arrange that. It seems like the template copying has mostly been eliminated and preview in particular gets written explicitly here: https://github.com/storybookjs/storybook/blob/next/lib/cli/src/generators/configure.ts#L18

Not sure if the intent would be to add more cases to that logic or somehow generalize the preview handling to make it simpler for apps to provide their own tweaks.

Comment on lines 5 to 6
const prefix = fse.existsSync('./src') ? '../src' : '../stories';
const stories = [`${prefix}/**/*.stories.json`];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

People could have stories in any location, correct? Maybe we should just prescribe one like we do in other generators.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplified this.

@shilman shilman removed this from the 6.2 server milestone Apr 1, 2021
@shilman shilman changed the title Support Server in cli generator CLI: Add Server template Apr 15, 2021

baseGenerator(packageManager, npmOptions, options, 'server', {
addComponents: false,
configureOptions: { stories },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't seem like this is used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reworked it a little


baseGenerator(packageManager, npmOptions, options, 'server', {
addComponents: false,
extraMain: { stories },
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated to leverage the recently added extraMain params.

@shilman shilman changed the title CLI: Add Server template CLI: Add Server template generator Apr 16, 2021
@shilman
Copy link
Member

shilman commented Apr 16, 2021

In all of our other project templates, yarn storybook should work out of the box. Currently that's not the case in this PR.

Would it be possible to:

  1. generate some simple stories
  2. generate a hello world style server (using something built in to node?)

That way everything's hooked up and the user can just remove stuff to get it working with their own server. What do you think?

@jonspalmer
Copy link
Contributor Author

@shilman I think we're in decent shape here. Did you solidify the netlify app that backs these generated samples?

@shilman
Copy link
Member

shilman commented May 30, 2021

@jonspalmer I think it's in good shape

Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@nx-cloud
Copy link

nx-cloud bot commented May 31, 2021

Nx Cloud Report

CI ran the following commands for commit 3c04dc6. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch

Status Command
#000000 nx run-many --target=prepare --all --parallel --max-parallel=15

Sent with 💌 from NxCloud.

@shilman shilman merged commit a5bc8b3 into storybookjs:next May 31, 2021
@yannbf
Copy link
Member

yannbf commented May 31, 2021

@jonspalmer @shilman the url http://storybook-server-demo.netlify.app/api resolves into a 404. Did we miss something?

@shilman
Copy link
Member

shilman commented Jun 1, 2021

@yannbf thanks! i added minimal docs and a redirect to the docs. it never actually called that URL, so it didn't matter in practice that it was a 404. but the redirect removes more opportunities for confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants