-
-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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
Support shorthand scoped templates #8298
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great @kevin940726! Are you able to add any tests for this?
@mrmckeb Sure! I was trying to do so too, but couldn’t find an appropriate place to put those tests. Should I create e2e tests? Any recommended example? |
You could create an E2E test... but those are quite flimsy right now. Perhaps for now we'll leave it, and we'll cover this as we rewrite tests towards v4. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great overall, just a few minor thoughts on the comments - let me know what you think.
// @SCOPE/cra-template | ||
// cra-template-NAME | ||
// @SCOPE/cra-template-NAME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above... :)
Co-Authored-By: Brody McKee <mrmckeb@users.noreply.github.com>
58d7580
to
cb007f4
Compare
@mrmckeb That definitely makes them clearer 👍! Just updated :) |
I've tagged this for 3.3.1, as I don't think it's worth delaying this for v3.4 - and we could argue that it is a bug that it doesn't work this way already. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, tested each case using that code and it works.
Thanks @heyimalex! Merging now @kevin940726 - great work. |
Continue from #7991. Allow
@scope
shorthand for template package name.The motivation comes from storybookjs/storybook#9327 (comment), where when library authors want to provide cra template under their scoped name, typing
--template @storybook/cra-template
every time seems tedious. Instead, it'd be better if the users can just type--template @storybook
to use the template@storybook/cra-template
. Since@
is not a valid character for npm package name, it should be backward-compatible.Tests
To list all the possible combinations.
--template cra-template
cra-template
--template cra-template-typescript
cra-template-typescript
--template typescript
cra-template-typescript
--template @scope/cra-template-typescript
@scope/cra-template-typescript
--template @scope/typescript
@scope/cra-template-typescript
--template @scope
(Added)@scope/cra-template
This PR also fixes a bug (?) when users provided
--template cra-templates
would still downloadcra-templates
while it should becra-template-cra-templates
, as templates should be prefixed bycra-template-
, judging from the doc. We can instead allow the other way around though if that makes more sense.Pinging @mrmckeb as we mentioned it in the issue before :)