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 to use npm and yarn instead of third party packages #3275

Merged
merged 2 commits into from
Mar 24, 2018
Merged

Refactor CLI to use npm and yarn instead of third party packages #3275

merged 2 commits into from
Mar 24, 2018

Conversation

felipedeboni
Copy link
Contributor

Issue: #3274 and #3060

What I did

  1. yarn remove latest-version on the lib/cli folder
  2. Created a new file lib/cli/lib/latest_version.js and used the has_yarn.js to check if yarn is actually available.
  3. yarn test on root folder.

How to test

Is this testable with jest or storyshots?
I didn't touched on tests, seems that tests are already written.

Does this need a new example in the kitchen sink apps?
No.

Does this need an update to the documentation?
No.

@danielduan you're the man to contact, so can you review if everything is fine here? If not, please let me know and I am going to fix it.

felipedeboni and others added 2 commits March 23, 2018 20:59
Usage: npm <command>

where <command> is one of:
    access, adduser, bin, bugs, c, cache, completion, config,
    ddp, dedupe, deprecate, dist-tag, docs, doctor, edit,
    explore, get, help, help-search, i, init, install,
    install-test, it, link, list, ln, login, logout, ls,
    outdated, owner, pack, ping, prefix, profile, prune,
    publish, rb, rebuild, repo, restart, root, run, run-script,
    s, se, search, set, shrinkwrap, star, stars, start, stop, t,
    team, test, token, tst, un, uninstall, unpublish, unstar,
    up, update, v, version, view, whoami

npm <command> -h     quick help on <command>
npm -l           display full usage info
npm help <term>  search for help on <term>
npm help npm     involved overview

Specify configs in the ini-formatted file:
    /Users/felipedeboni/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

npm@5.6.0 /Users/felipedeboni/.nvm/versions/node/v9.5.0/lib/node_modules/npm and yarn install v1.5.1
[1/5] Validating package.json...
[2/5] Resolving packages...
success Already up-to-date.
Done in 1.69s. instead of third party packages #3274 #3060
@Hypnosphi Hypnosphi added dependencies cli bug patch:yes Bugfix & documentation PR that need to be picked to main branch labels Mar 24, 2018
@codecov
Copy link

codecov bot commented Mar 24, 2018

Codecov Report

Merging #3275 into master will decrease coverage by 0.02%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3275      +/-   ##
==========================================
- Coverage   36.21%   36.18%   -0.03%     
==========================================
  Files         443      444       +1     
  Lines        9737     9744       +7     
  Branches      918      901      -17     
==========================================
  Hits         3526     3526              
- Misses       5635     5642       +7     
  Partials      576      576
Impacted Files Coverage Δ
lib/cli/lib/helpers.js 0% <ø> (ø) ⬆️
lib/cli/lib/latest_version.js 0% <0%> (ø)
addons/a11y/src/components/Report/RerunButton.js 0% <0%> (ø) ⬆️
lib/ui/src/modules/ui/containers/shortcuts_help.js 25% <0%> (ø) ⬆️
app/react/src/client/preview/element_check.js 67.64% <0%> (ø) ⬆️
lib/core/src/server/config/env.js 0% <0%> (ø) ⬆️
addons/info/src/components/types/PrettyPropType.js 85.71% <0%> (ø) ⬆️
lib/ui/src/modules/api/index.js 0% <0%> (ø) ⬆️
.../viewport/src/manager/components/SelectViewport.js 18.18% <0%> (ø) ⬆️
addons/actions/src/lib/util/typeReviver.js 71.42% <0%> (ø) ⬆️
... and 60 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 4e0ce5d...a164a91. Read the comment docs.

@danielduan
Copy link
Member

@Hypnosphi this is the only obvious thing that I think could cause the linked issue. You worked with the CLI quite a bit. Does this look good?

@Hypnosphi
Copy link
Member

The passing CLI tests are an extremely good sign

@Hypnosphi Hypnosphi merged commit 4bb0ff7 into storybookjs:master Mar 24, 2018
const packageManager = hasYarn() ? 'yarn' : 'npm';

export default async function latestVersion(packageName) {
const result = spawnSync(packageManager, ['info', packageName, '--json'], {
Copy link
Member

Choose a reason for hiding this comment

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

is there any reason not to use ${packageManager} info ${packageName} version?

@felipedeboni
Copy link
Contributor Author

@Hypnosphi it's just to be safe. Because I read
https ://github.com/yarnpkg/yarn/issues/4044, and it's under investigation

@Hypnosphi
Copy link
Member

Hypnosphi commented Mar 27, 2018

@felipedeboni output without version is different in the same way:

$ yarn info @storybook/react --json
{"type":"inspect","data":{...

$ npm info @storybook/react --json
{
  "name": "@storybook/react",...

@felipedeboni
Copy link
Contributor Author

@Hypnosphi, you're right. Going to open another pull request, to actually fix NPM and also change that behavior.

Do you want to check the code first? Commit

@Hypnosphi
Copy link
Member

#3297 should already have fixed this

@Hypnosphi Hypnosphi added the patch:done Patch/release PRs already cherry-picked to main/release branch label Mar 29, 2018
Hypnosphi added a commit that referenced this pull request Mar 29, 2018
Refactor CLI to use `npm` and `yarn` instead of third party packages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cli dependencies patch:done Patch/release PRs already cherry-picked to main/release branch patch:yes Bugfix & documentation PR that need to be picked to main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants