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

Build: Add text suggestions for incorrect task names #30056

Merged
merged 2 commits into from
Dec 15, 2024

Conversation

yannbf
Copy link
Member

@yannbf yannbf commented Dec 13, 2024

Closes #

What I did

Sometimes contributors or maintainers write task names wrong, so I added a bit of a suggestion when that happens, utilizing the same mechanism from the yarn build command

image

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 77.7 MB 77.7 MB 0 B 2 0%
initSize 136 MB 136 MB 0 B 2 0%
diffSize 58.4 MB 58.4 MB 0 B 2 0%
buildSize 7.24 MB 7.24 MB 0 B 1.53 0%
buildSbAddonsSize 1.88 MB 1.88 MB 0 B 1.53 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.86 MB 1.86 MB 0 B 1.37 0%
buildSbPreviewSize 0 B 0 B 0 B - -
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.93 MB 3.93 MB 0 B 1.53 0%
buildPreviewSize 3.3 MB 3.3 MB 0 B 1.48 0%
testBuildSize 0 B 0 B 0 B - -
testBuildSbAddonsSize 0 B 0 B 0 B - -
testBuildSbCommonSize 0 B 0 B 0 B - -
testBuildSbManagerSize 0 B 0 B 0 B - -
testBuildSbPreviewSize 0 B 0 B 0 B - -
testBuildStaticSize 0 B 0 B 0 B - -
testBuildPrebuildSize 0 B 0 B 0 B - -
testBuildPreviewSize 0 B 0 B 0 B - -
name before after diff z %
createTime 6.9s 6.6s -316ms -0.88 -4.8%
generateTime 19.6s 19.8s 192ms -0.62 1%
initTime 12.9s 12.9s 24ms -0.91 0.2%
buildTime 11s 8.1s -2s -981ms -0.85 -36.7%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 4.7s 5s 303ms -0.12 6%
devManagerResponsive 3.5s 3.9s 397ms 0.2 10%
devManagerHeaderVisible 657ms 601ms -56ms 0.09 -9.3%
devManagerIndexVisible 693ms 631ms -62ms -0.21 -9.8%
devStoryVisibleUncached 1.8s 1.8s 44ms 0.48 2.3%
devStoryVisible 715ms 629ms -86ms -0.24 -13.7%
devAutodocsVisible 559ms 435ms -124ms -1.22 -28.5%
devMDXVisible 564ms 423ms -141ms -1.1 -33.3%
buildManagerHeaderVisible 612ms 574ms -38ms -0.33 -6.6%
buildManagerIndexVisible 698ms 659ms -39ms -0.44 -5.9%
buildStoryVisible 563ms 527ms -36ms -0.34 -6.8%
buildAutodocsVisible 444ms 428ms -16ms -0.35 -3.7%
buildMDXVisible 529ms 441ms -88ms -0.24 -20%

Greptile Summary

Based on the provided information, I'll create a concise summary of the PR changes:

Added task name suggestion functionality to improve developer experience when incorrect task names are entered in the Storybook CLI, similar to the existing yarn build command behavior.

  • Added text matching logic in scripts/task.ts to detect invalid task names
  • Implemented findMostMatchText utility to suggest closest matching task name
  • Added error message formatting with colored output using picocolors
  • Enhanced error handling to display helpful suggestions for typos

@yannbf yannbf added build Internal-facing build tooling & test updates ci:normal labels Dec 13, 2024
@yannbf yannbf self-assigned this Dec 13, 2024
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +359 to +363
console.log(
`${picocolors.red('Error')}: ${picocolors.cyan(
taskKey
)} is not a valid task name, Did you mean ${picocolors.cyan(matchText)}?`
);
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider using logger.error() for consistency with other error logging in this file

)} is not a valid task name, Did you mean ${picocolors.cyan(matchText)}?`
);
}
process.exit(1);
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Add a newline before process.exit(1) for better error message readability

Copy link

nx-cloud bot commented Dec 13, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit dc5ba88. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

@valentinpalkovic valentinpalkovic merged commit b6a1547 into next Dec 15, 2024
55 of 58 checks passed
@valentinpalkovic valentinpalkovic deleted the yann/add-task-suggestions branch December 15, 2024 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Internal-facing build tooling & test updates ci:normal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants