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: Add upgrade utility with version consistency check #11396

Merged
merged 2 commits into from
Jul 3, 2020

Conversation

shilman
Copy link
Member

@shilman shilman commented Jul 2, 2020

Issue: #11382 #11383

What I did

MMBP15:cra-ts shilman$ ~/projects/baseline/storybook/lib/cli/bin/index.js upgrade --prerelease
 • Checking for latest versions of '@storybook/*' packagesinfo ,Upgrading /Users/shilman/projects/testing/cra-ts/package.json
info
info  @storybook/addon-actions  ^5.3.19  →  ^6.0.0-beta.39
info  @storybook/addon-docs     ^5.3.19  →  ^6.0.0-beta.39
info  @storybook/addon-links    ^5.3.19  →  ^6.0.0-beta.39
info  @storybook/addons         ^5.3.19  →  ^6.0.0-beta.39
info  @storybook/react          ^5.3.19  →  ^6.0.0-beta.39
info
[...]
 • Installing upgrades • Preparing to install dependencies. ✓

yarn install v1.22.4
[...]

success Saved lockfile.
✨  Done in 19.71s.
. ✓
WARN Found 1 outdated packages (relative to '@storybook/[email protected]')
WARN Please make sure your packages are updated to ensure a consistent experience.
WARN - @storybook/[email protected]

How to test

cd lib/cli
yarn prepare
cd ~/my/project
~/path/to/lib/cli/bin/index.js upgrade --prerelease

Copy link
Member

@tmeasday tmeasday left a comment

Choose a reason for hiding this comment

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

Mostly looks good, although what's up with this:

WARN Found 1 outdated packages (relative to '@storybook/[email protected]')
WARN Please make sure your packages are updated to ensure a consistent experience.
WARN - @storybook/[email protected]

warnPackages(outdated);
}

if (semver.gt(latestVersion, '5.4.0')) {
Copy link
Member

Choose a reason for hiding this comment

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

Would we have to update this magic constant every release? Should we not pull it from package.json?

Copy link
Member Author

Choose a reason for hiding this comment

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

Made this more general, but maybe not in the way you had in mind

@shilman
Copy link
Member Author

shilman commented Jul 3, 2020

WARN Found 1 outdated packages (relative to '@storybook/[email protected]')
WARN Please make sure your packages are updated to ensure a consistent experience.
WARN - @storybook/[email protected]

This is a dependency of @storybook/preset-create-react-app. Will fix in the next version.

Comment on lines +3 to +22
describe.each([
['│ │ │ ├── @babel/[email protected] deduped', null],
[
'│ ├── @storybook/[email protected] extraneous',
{ package: '@storybook/theming', version: '6.0.0-beta.37' },
],
[
'├─┬ @storybook/[email protected]',
{ package: '@storybook/preset-create-react-app', version: '3.1.2' },
],
['│ ├─┬ @storybook/[email protected]', { package: '@storybook/node-logger', version: '5.3.19' }],
[
'npm ERR! peer dep missing: @storybook/react@>=5.2, required by @storybook/[email protected]',
null,
],
])('getStorybookVersion', (input, output) => {
it(input, () => {
expect(getStorybookVersion(input)).toEqual(output);
});
});
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused what this is testing

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the output of npm ls

Copy link
Member

Choose a reason for hiding this comment

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

I see.

@shilman
Copy link
Member Author

shilman commented Jul 3, 2020

NOTE: I have over 100 random storybook projects on my machine (mostly user repros). I ran sb upgrade and sb upgrade --prerelease on a few of them, and found issues in each project. So I think this will generate some support issues. But more importantly, I think it will catch a lot of problems and help people clean up their Storybook installs. Really excited about it!

@ndelangen
Copy link
Member

Perhaps some time in the future we can also automate running codemods on user's repos?

@shilman shilman merged commit b18ef1c into next Jul 3, 2020
@ndelangen ndelangen deleted the 11382-version-consistency-check branch July 3, 2020 09:12
@yannbf
Copy link
Member

yannbf commented Jul 3, 2020

Super awesome!!!!

A few ideas for the future regarding this:
1 - Mention about such command for the users here
2 - Maybe add a log after the upgrades are installed with a link to migration? Could be that certain addon is updated and maybe some api changed so people would have a direction in case there's an issue after running the command
3 - Find a way to identify the need of running codemods, and if they are available then execute them
4 - Add a flag to upgrade to --next?

@shilman
Copy link
Member Author

shilman commented Jul 3, 2020

Thanks @yannbf, great suggestions. ❤️ Will address in a follow up PR for 1 -- low-hanging. 2 & 3 are both great but future work. 4 is done and it's called --prerelease

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants