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

Refactor CLI #1840

Merged
merged 5 commits into from
Sep 15, 2017
Merged

Refactor CLI #1840

merged 5 commits into from
Sep 15, 2017

Conversation

Hypnosphi
Copy link
Member

@Hypnosphi Hypnosphi commented Sep 14, 2017

This solves a couple of issues:

  1. Currently, latest-version is used to choose which versions of packages to install. This means that new packages and features can be used in CLI templates only after becoming stable. This PR changes it so that @storybook/cli@3.3.0-alpha.1 adds "@storybook/*": "^3.3.0-alpha.1", which is future-compatible meaning that versions like 3.11.10 will still match this mask. This, for example, makes it possible to run smoke-tests (introduced in 3.3) when testing CLI
  2. Promise rejections are unhandled unless you explicitly add a catch line. See Add angular support: Storybook for Angular #1474 (comment). Here I switch it to a single handler on top level
  3. CLI tests don't test current versions of packages but install them from npm (related to 1.). I included lib/cli/test/run/* to yarn workspaces, so that after running getstorybook in all the fixtures directories, a single yarn command can install all the needed dependencies and link local @storybook/* packages. To do this, I also added a --skip-install option to CLI

@Hypnosphi Hypnosphi requested review from ndelangen and shilman and removed request for ndelangen September 14, 2017 01:58
@codecov
Copy link

codecov bot commented Sep 14, 2017

Codecov Report

Merging #1840 into release/3.3 will decrease coverage by 0.05%.
The diff coverage is 0%.

Impacted file tree graph

@@               Coverage Diff               @@
##           release/3.3    #1840      +/-   ##
===============================================
- Coverage        22.32%   22.27%   -0.06%     
===============================================
  Files              324      324              
  Lines             6319     6335      +16     
  Branches           803      809       +6     
===============================================
  Hits              1411     1411              
- Misses            4297     4305       +8     
- Partials           611      619       +8
Impacted Files Coverage Δ
lib/cli/bin/generate.js 0% <0%> (ø) ⬆️
lib/cli/lib/helpers.js 0% <0%> (ø) ⬆️
lib/cli/lib/has_yarn.js 0% <0%> (ø) ⬆️
app/react/src/server/utils.js 0% <0%> (-53.58%) ⬇️
lib/codemod/src/transforms/update-addon-info.js 51.16% <0%> (ø) ⬆️
lib/ui/src/modules/api/configs/init_api.js 40.47% <0%> (ø) ⬆️
lib/components/src/navigation/menu_link.js 0% <0%> (ø) ⬆️
app/react/src/client/preview/error_display.js 0% <0%> (ø) ⬆️
addons/knobs/src/components/types/Boolean.js 11.62% <0%> (ø) ⬆️
...res__/update-addon-info/update-addon-info.input.js 0% <0%> (ø) ⬆️
... and 27 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f199465...fee3850. Read the comment docs.

@tmeasday
Copy link
Member

tmeasday commented Sep 14, 2017

I guess what we are giving up here is that previously the user's package.json would end up looking like what they would have gotten if they ran npm install --save-dev @storybook/react themselves. This way if they have an out of date installer they will get some old version in their package.json (I appreciate the version installed will be correct).

Also when we release breaking versions users will need to update the CLI. This is probably not the worst thing.

I think this change is OK, but what do you think about the idea of fetching the latest version of a internal dep and comparing it to the devDependencies version, then installing the greater?

That would cover both use cases, no?

@Hypnosphi
Copy link
Member Author

fetching the latest version of a internal dep and comparing it to the devDependencies version, then installing the greater

Sounds good, will try

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.

This is great!


const logger = console;

export async function getVersion(packageName) {
const current = packageName === '@storybook/cli' ? version : devDependencies[packageName];
Copy link
Member

Choose a reason for hiding this comment

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

Should we check that packageName.match('@storybook') or something? Otherwise we may apply this logic to other things this package depends on.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds reasonable. I think it should be /storybook/.test(packageName) though, as there are plans to use storybook package name (@ndelangen has it)

@Hypnosphi Hypnosphi merged commit 249a3c0 into release/3.3 Sep 15, 2017
@tmeasday
Copy link
Member

Haven't had a chance to run the code yet but it LGTM

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

Successfully merging this pull request may close these issues.

2 participants