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

Indexer: Improve locating stories with specials chars in path #22110

Open
wants to merge 13 commits into
base: next
Choose a base branch
from

Conversation

jankoritak
Copy link

@jankoritak jankoritak commented Apr 15, 2023

Closes #21636

What I did

  • Altered StoryIndexGenerator.ts not to treat this.options.workingDir as a glob. This allows the absolute part of the path to contain special glob characters without breaking the match.
  • The problem and proposed solution are described inside of the issue.
  • Note: As we're altering how we treat the local/absolute portion of the path, I'm unsure whether there is a way to test this.

How to test

  1. Insert a directory with a special character (e.g. Special (1)) in your path that contains a repository with a storybook.
  2. Run the storybook linked to the next branch.
  3. Verify that the stories are not loading (the storybook does not find any)
  4. Run the storybook linked to this branch.
  5. Verify that the stories are loaded.

Checklist

  • Make sure your changes are tested (stories and/or unit, integration, or end-to-end tests)
  • Make sure to add/update documentation regarding your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Maintainers

  • If this PR should be tested against many or all sandboxes,
    make sure to add the ci:merged or ci:daily GH label to it.
  • Make sure this PR contains one of the labels below.

["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]

@jankoritak jankoritak changed the title 21636 fix locating stories with specials chars in path 21636: Fix locating stories with specials chars in path Apr 16, 2023
const fullGlob = slash(path.join(specifier.directory, specifier.files));
const files = await glob(
fullGlob,
// Do not treat workingDir path as a glob pattern
Copy link
Member

Choose a reason for hiding this comment

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

What does this mean?

Copy link
Author

Choose a reason for hiding this comment

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

It means that with cwd, we're now treating only path.join(specifier.directory, specifier.files) as glob. In case the comment brings more confusion than value, I'm happy to remove it.

Copy link
Member

Choose a reason for hiding this comment

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

OK, I see now.

Would I need to do the same here:
#22186

https://github.com/storybookjs/storybook/pull/22186/files

Copy link
Author

Choose a reason for hiding this comment

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

I'd say yes, in case there are special chars in the path, they won't match without it.

@jankoritak
Copy link
Author

Hi @shilman, anything I can do to help push this PR toward a merge?

@shilman
Copy link
Member

shilman commented Apr 29, 2023

@jankoritak Sorry for the delay. I'll make some time to review with @ndelangen this coming week.

@supryan
Copy link

supryan commented May 9, 2023

Thank you all for your hard work on this issue, this is currently impacting me. Hopefully a merge is around the corner!

@ndelangen
Copy link
Member

@jankoritak this PR I referenced got merged: #22186

Would you be able to apply the fixes from this PR on that part of the codebase as well?
I'll update the branch for you.

@jankoritak
Copy link
Author

@jankoritak this PR I referenced got merged: #22186

Would you be able to apply the fixes from this PR on that part of the codebase as well? I'll update the branch for you.

@ndelangen Sure, I'll look into it. Thanks for the update.

@ndelangen
Copy link
Member

@JReinhold or @valentinpalkovic Is either of you able to determine if this is still something we need going forwards?

@valentinpalkovic
Copy link
Contributor

This Pr's fix seems reasonable.

@ndelangen
Copy link
Member

@jankoritak could you resolve the merge conflicts?

@jankoritak
Copy link
Author

@jankoritak could you resolve the merge conflicts?

Hey @ndelangen, will do. I forgot about this PR, my bad!

);

const files = await glob(fullGlob, commonGlobOptions(fullGlob));
Copy link
Member

Choose a reason for hiding this comment

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

Do we end up calling glob() twice?

@shilman
Copy link
Member

shilman commented Nov 20, 2023

@ndelangen please take another look!

@ndelangen ndelangen changed the title 21636: Fix locating stories with specials chars in path Indexer: Improve locating stories with specials chars in path Nov 22, 2023
@ndelangen
Copy link
Member

@jankoritak I updated the branch, looks like CI found some problems, are you interested in fixing up this PR?

@jankoritak
Copy link
Author

@jankoritak I updated the branch, looks like CI found some problems, are you interested in fixing up this PR?

@ndelangen I am. However, I'm swamped at the moment. Would you guys be open to waiting for a couple more weeks till I find time to fine-tune the PR? In case this is a no-go for you, lemme know.

@ndelangen
Copy link
Member

That's not a problem, as a heads-up to you:
The 7.6 release (should go out next week) will likely be the last 7.x release, and we'll be focussing on the 8.0 release soon.
So there might be more merge conflict incoming.
I'll help you when it comes to that though, just ping me for assistance.

@ndelangen ndelangen removed their assignment Nov 28, 2023
@JReinhold
Copy link
Contributor

I think some merging has gone bad, as this now does const files = glob(...) twice right after each other.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
7 participants