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: Fix copyTemplate failures on init #22375

Merged
merged 14 commits into from
May 9, 2023
Merged

CLI: Fix copyTemplate failures on init #22375

merged 14 commits into from
May 9, 2023

Conversation

ndelangen
Copy link
Member

@ndelangen ndelangen commented May 3, 2023

Closes #22348

What I did

Add guards against projectType being an unknown value
Add guards against templateDir being a location that doesn't exist

How to test

I'm not exactly sure how to reproduce the error, but 1 way that would work for sure would be to set a projectType to a odd value in an angular project. I don't think there are any other proper values other then application and library but if there are, then that would have caused issues in the past. After this PR that should default back to application. I assume this is the correct default.

If the templateDir cannot be found at all, we'll just skip it, this MIGHT cause those storybook to fail to start or build, but that's hard to tell without a full reproduction I can follow.
...either way that would become a follow-up issue then.

@ndelangen ndelangen self-assigned this May 3, 2023
@ndelangen ndelangen added bug patch:yes Bugfix & documentation PR that need to be picked to main branch labels May 3, 2023
@ndelangen ndelangen requested a review from yannbf May 3, 2023 11:32
@@ -10,7 +10,9 @@ const generator: Generator = async (packageManager, npmOptions, options) => {
});

const templateDir = join(getCliDir(), 'templates', 'server');
Copy link
Member

Choose a reason for hiding this comment

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

We can just get rid of this block of code entirely. I just tested it out on a sample project and will be adding a telescoping PR to do it.

@shilman shilman changed the title Improve error handling for init by guarding against copyTemplate failures CLI: Fix copyTemplate failures on init May 8, 2023
@shilman shilman mentioned this pull request May 8, 2023
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. I'll let @yannbf follow up as needed but merging now since I want to get the server changes released.

@shilman shilman merged commit e421710 into next May 9, 2023
@shilman shilman deleted the norbert/fix-22348 branch May 9, 2023 08:18
shilman added a commit that referenced this pull request May 9, 2023
CLI: Fix copyTemplate failures on `init`
@shilman shilman added the patch:done Patch/release PRs already cherry-picked to main/release branch label May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
angular bug cli patch:done Patch/release PRs already cherry-picked to main/release branch patch:yes Bugfix & documentation PR that need to be picked to main branch server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

storybook init: Couldn't find template dir
2 participants