35 Commits

Author SHA1 Message Date
Gaëtan Maisse
1497a4773e
fix(cli): fix computation of Angular version in sb init
`packageManager.getVersion` was fetching the latest version from npm
registry instead of checking the version installed locally.
2021-05-14 21:10:11 +02:00
Michael Shilman
37a6d3afdc
Merge pull request #13876 from storybookjs/tech/improve-cli
CLI: Don't try to add packages that are already installed
2021-02-15 08:39:52 +08:00
Michael Shilman
7bad43b0ac
Merge pull request #13717 from storybookjs/fix/cli-eslint-error
CLI: Add safe check for eslint overrides
2021-02-15 08:26:27 +08:00
Gaëtan Maisse
b0354930db
fix(cli): do not reinstall packages that were already there as deps
It mimic the behavior of Yarn 1.x when trying to install a package as dev dep but it is already a regular dep.
Example:
> warning "react-scripts" is already in "dependencies". Please remove existing entry first before adding it to "devDependencies".
>  success Saved 0 new dependencies.
2021-02-13 18:16:08 +01:00
Blaine Bublitz
354fc796e0 feat: support package versions in package strings for generators 2021-01-29 17:59:58 -07:00
Yann Braga
757454a6a7 fix(cli): add safe check for eslint overrides 2021-01-23 12:11:09 +01:00
Michael Shilman
bf0bb282b1 Merge branch 'next' into perf/esm-dist 2020-12-15 17:43:53 +08:00
Clément DUNGLER
3e9c40e5af CLI: Add overrides to CRA ESLint config 2020-12-14 22:16:42 +01:00
Norbert de Langen
0930e4d8d3
move version.json 2020-12-09 13:23:02 +01:00
Michael Shilman
79b3f27b7e Merge branch 'next' into pr/12863 2020-12-01 17:52:57 +08:00
Yue Yang
092af5b750 fix: deepscan 2020-11-04 17:08:05 +08:00
Michael Shilman
dce88aba4d CLI: Remove --no-dll from template 2020-11-04 16:33:02 +08:00
Michael Shilman
ccbe288584 Disable DLL by default in template 2020-10-30 11:15:14 +08:00
Gaëtan Maisse
4364ee66a0
fix(cli): add some dependencies to be able to run addon-docs with Yarn 2 out of the box 2020-07-12 16:16:32 +02:00
Gaëtan Maisse
c0e00c600e
feat(cli): use versions.json to get SB packages versions
Previously it used `devDep` of `package.json`. It was working but doing
so all Storybook packages had to be added to `devDep`.

Moreover, as `@storybook/react-native` was not part of the monorepo
anymore it's version was stuck to `6.0.0-alpha.0` causing a download
of `6.0.0-alpha.0` SB packages when running `yarn install`.
2020-07-11 11:10:02 +02:00
tooppaaa
872f4b0645 fix yarn 2 2020-07-05 15:02:07 +02:00
tooppaaa
86e487a395 Update CLI for angular 2020-07-05 11:11:55 +02:00
Gaëtan Maisse
9dc7c554f4
refactor: ensure dep and devDeps are always defined when retrieving package.json
Doing this just after having read the file enable us to remove duplication and unneeded calls to `writePackageJson`.
2020-06-09 08:19:12 +02:00
Gaëtan Maisse
26dd11bf60
refactor: move readPackageJson and writePackageJson in their own helper 2020-06-09 08:19:11 +02:00
Gaëtan Maisse
b0e1d93eca
refactor: create a executeCommand function and use it for every yarn or npm calls
It move the `spawnSync` usage to only a single place which is simpler to maintain.
It also simplify testing as there is no more need to mock an external dep
2020-06-09 08:19:11 +02:00
Gaëtan Maisse
f5c788b92b
refactor: update signature of runAddDeps function 2020-06-08 20:08:17 +02:00
Gaëtan Maisse
0c1a9740dc
refactor: update signature of runInstall function 2020-06-08 20:08:16 +02:00
Gaëtan Maisse
94620167cc
refactor: create function to add SB command in scripts attribute of package.json 2020-06-08 20:08:16 +02:00
Gaëtan Maisse
41dc95791b
refactor: move PackageJson.ts inside js-package-manager directory 2020-06-08 20:08:15 +02:00
Gaëtan Maisse
d4000030c3
refactor: remove usage of has_yarn 2020-06-08 20:08:15 +02:00
Gaëtan Maisse
2912bcbefe
refactor: remove unneeded params and variables
All this variables were used to check if user was running Yarn and do this accordingly.
Now we use the factory to get the "right" version of JsPackageManager instance so there is no need to worry anywhere about that.
2020-06-08 20:08:15 +02:00
Gaëtan Maisse
a23e4a0846
refactor: move latestVersion to JsPackageManager and split specific behavior in NPM, Yarn 1 and Yarn 2 classes. 2020-06-08 20:08:15 +02:00
Gaëtan Maisse
126e7e2ea8
refactor: move getVersion to JsPackageManager 2020-06-08 17:25:45 +02:00
Gaëtan Maisse
2760021aa1
refactor: move getVersions to JsPackageManager 2020-06-08 17:25:45 +02:00
Gaëtan Maisse
b6497c2fec
refactor: move getVersionedPackages to JsPackageManager 2020-06-08 17:25:44 +02:00
Gaëtan Maisse
c714aca145
refactor: move installDependencies to JsPackageManager
Also rename it to `addDependencies` (a.k.a. `yarn add`) to avoid confusion with `installDepsFromPackageJson` (a.k.a. `yarn install`).
2020-06-08 17:25:44 +02:00
Gaëtan Maisse
56de607807
refactor: move retrievePackageJson to JsPackageManager 2020-06-08 17:25:44 +02:00
Gaëtan Maisse
a858990fa6
refactor: move installDepsFromPackageJson function to JsPackageManager class and subclasses 2020-06-08 17:25:43 +02:00
Gaëtan Maisse
100ffac29c
refactor: use getRunStorybookCommand from package manager
It avoids to use a ternary expression to define the displayed string and encapsulate specific package managers behaviors in their own classes.
2020-06-08 17:25:43 +02:00
Gaëtan Maisse
ed79e5bb42
refactor: introduce a JsPackageManager abstract class and specialized subclasses for NPM, Yarn and Yarn 2.
The goal of this will be to use the Factory Pattern to encapsulate everything specific to a package manager in a single class.
Then a factory will return an instance of NPM, Yarn or Yarn 2 proxy class according to the package manager used/prefered in end project.
All CLI code will be package manager agnostic and will just call functions of JsPackageManager interface.
2020-06-08 17:25:42 +02:00