Support shorthand scoped templates #8298
Merged
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
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 :)