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

Fix doctor addon compatibility check #26015

Closed
vanessayuenn opened this issue Feb 13, 2024 · 0 comments · Fixed by #26219
Closed

Fix doctor addon compatibility check #26015

vanessayuenn opened this issue Feb 13, 2024 · 0 comments · Fixed by #26219
Assignees
Milestone

Comments

@vanessayuenn
Copy link
Contributor

In #25293, we changed the CLI so that sb upgrade does not upgrade any non-core packages. The previous logic of “upgrade all the core packages + addons to the latest” wasn’t a terrible heuristic, but it also wasn’t great, and falls down when we could be upgrading to any arbitrary version and not the latest.

Since sb upgrade no longer upgrades addons, any user that uses non-core addons will very likely be left in a bad state after upgrade. To address this, we call sb doctor automatically after upgrades. sb doctor's job is to look for inconsistencies in the user’s project setup, including addons that are incompatible with the current version of Storybook.

Unfortunately, the current logic for this is problematic. The list is hand-maintained, and hard-coded in the doctor command’s code, which means that (1) it is probably out of date, and (2) even when we update the list, it will probably not get patched to older versions of the CLI.

Instead of a hard-coding the list, we propose the following heuristics (or some variant thereof):

currentVersion = getCurrentVersion()

for addon in mainJs.addons:
  packageJson = readPackageJson(addon)
  for dep in storybookDeps(packageJson):
    if isIncompatible(dep, currentVersion):
      alert 'Addon ${addon}@${packageJson.version} likely incompatible'
      alert 'with Storybook ${currentVersion}.'
      alert 'Please see the addon docs: ${packageJson.homepage}'
      break
  latestVersion = getLatestVersion(addon)
  if(latestVersion > packageJson.version)
     alert 'There is a new version of ${addon} available: ${latestVersion}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants