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

Allow passing both buildScriptName and storybookBuildDir #934

Conversation

woutervanvliet
Copy link
Contributor

Allows passing both --storybook-build-dir and --build-script-name

Solves #933

@ghengeveld
Copy link
Member

Hi Wouter, thanks for working on a fix for this!

I'm okay with your proposed change to allow --storybook-build-dir whilst buildScriptName is set in your chromatic.config.json. However, the original reason we had this restriction was to avoid confusion over which one gets priority. I propose the following solution:

  • Rather than checking singularOpts against the final (combined) options object, check it against configuration (JSON), optionsFromFlags (flags / GitHub Action args) and extraOptions (Node API args) individually. This would allow overriding configuration using a flag or API arg, while preventing any misconfiguration or bad combination of flags/args.
  • Print a warning when this happens.

Are you comfortable / willing to make this change?

@woutervanvliet
Copy link
Contributor Author

Thanks for the input - I've reluctantly updated my PR, because I'm not sure I entirely agree. So here are a few followup questions:

  • Am I right to assume that the presence of the buildScriptName configuration, regardless of where it comes from, doesn't actually have any effect - until the chromatic cli decides that a build is necessary because no build dir was specified?
  • Am I also right to assume that build script name, when not specified, defaults to "build-storybook", and as such always can be considered to be specified?

If both answers are yes, than I don't think assumption that combining buildScriptName and storybookBuildDir in configuration and/or command line arguments in any way should indicate a potential mistake, and I think my latest commit should be reverted.

And if my assumptions are not entirely correct, please check if my change reflects your intention.

@ghengeveld
Copy link
Member

  • Am I right to assume that the presence of the buildScriptName configuration, regardless of where it comes from, doesn't actually have any effect - until the chromatic cli decides that a build is necessary because no build dir was specified?

Almost. The buildScriptName is also used to infer configDir and staticDir options from its flags. This is relevant for proper functioning of TurboSnap, even if storybookBuildDir is also specified. In that case it won't build Storybook but it'll assume the prebuilt Storybook used the same buildScriptName flags.

  • Am I also right to assume that build script name, when not specified, defaults to "build-storybook", and as such always can be considered to be specified?

Yes, although we'll still check if that script actually exists in your package.json.

If both answers are yes, than I don't think assumption that combining buildScriptName and storybookBuildDir in configuration and/or command line arguments in any way should indicate a potential mistake, and I think my latest commit should be reverted.

After giving this some more thought, I think that's valid. There is actually a valid reason to have both a buildScriptName and a storybookBuildDir (for configDir/staticDir inference), so combining these may not necessarily be a mistake.

@ghengeveld ghengeveld added release Auto: Create a `latest` release when merged minor Auto: Increment the minor version when merged labels Mar 20, 2024
Copy link

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for 85478071
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (8547807) Report Missing Report Missing Report Missing
Head commit (366f809) 8445 6640 78.63%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#934) 0 0 ∅ (not applicable)

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

You may notice some variations in coverage metrics with the latest Coverage engine update. For more details, visit the documentation

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@ghengeveld ghengeveld added this pull request to the merge queue Mar 20, 2024
@ghengeveld ghengeveld removed this pull request from the merge queue due to a manual request Mar 20, 2024
@ghengeveld ghengeveld changed the title Allow passing both build script and directory Allow passing both buildScriptName and storybookBuildDir Mar 20, 2024
@ghengeveld ghengeveld added this pull request to the merge queue Mar 20, 2024
Merged via the queue into chromaui:main with commit d28bcb5 Mar 20, 2024
28 of 36 checks passed
@ghengeveld
Copy link
Member

🚀 PR was released in v11.2.0 🚀

@ghengeveld ghengeveld added the released Verdict: This issue/pull request has been released label Mar 20, 2024
@woutervanvliet
Copy link
Contributor Author

Thanks

@ghengeveld
Copy link
Member

Thanks for helping out @woutervanvliet !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor Auto: Increment the minor version when merged release Auto: Create a `latest` release when merged released Verdict: This issue/pull request has been released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants