diff --git a/lib/cli/src/NpmOptions.ts b/lib/cli/src/NpmOptions.ts index f397f5f2f7a..1f211414462 100644 --- a/lib/cli/src/NpmOptions.ts +++ b/lib/cli/src/NpmOptions.ts @@ -1,5 +1,4 @@ export type NpmOptions = { - useYarn: boolean; skipInstall?: boolean; installAsDevDependencies?: boolean; }; diff --git a/lib/cli/src/add.ts b/lib/cli/src/add.ts index 9232a7753ed..a1b3ac47aee 100644 --- a/lib/cli/src/add.ts +++ b/lib/cli/src/add.ts @@ -9,26 +9,17 @@ import { JsPackageManager, JsPackageManagerFactory } from './js-package-manager' const logger = console; export const storybookAddonScope = '@storybook/addon-'; -const isAddon = async ( - packageManager: JsPackageManager, - name: string, - npmOptions: { - useYarn: boolean; - } -) => { +const isAddon = async (packageManager: JsPackageManager, name: string) => { try { - await packageManager.latestVersion(npmOptions, name); + await packageManager.latestVersion(name); return true; } catch (e) { return false; } }; -const isStorybookAddon = async ( - packageManager: JsPackageManager, - name: string, - npmOptions: { useYarn: boolean } -) => isAddon(packageManager, `${storybookAddonScope}${name}`, npmOptions); +const isStorybookAddon = async (packageManager: JsPackageManager, name: string) => + isAddon(packageManager, `${storybookAddonScope}${name}`); export const getPackageName = (addonName: string, isOfficialAddon: boolean) => isOfficialAddon ? storybookAddonScope + addonName : addonName; @@ -162,9 +153,9 @@ export async function add( const packageManager = JsPackageManagerFactory.getPackageManager(options.useNpm); const addonCheckDone = commandLog(`Verifying that ${addonName} is an addon`); - const isOfficialAddon = await isStorybookAddon(packageManager, addonName, npmOptions); + const isOfficialAddon = await isStorybookAddon(packageManager, addonName); if (!isOfficialAddon) { - if (!(await isAddon(packageManager, addonName, npmOptions))) { + if (!(await isAddon(packageManager, addonName))) { addonCheckDone(`The provided package was not a Storybook addon: ${addonName}.`); return; } diff --git a/lib/cli/src/generators/ANGULAR/index.ts b/lib/cli/src/generators/ANGULAR/index.ts index 03218076719..608101c0581 100644 --- a/lib/cli/src/generators/ANGULAR/index.ts +++ b/lib/cli/src/generators/ANGULAR/index.ts @@ -32,7 +32,7 @@ async function addDependencies( packages.push('@storybook/addon-docs'); } - const versionedPackages = await packageManager.getVersionedPackages(npmOptions, ...packages); + const versionedPackages = await packageManager.getVersionedPackages(...packages); const packageJson = packageManager.retrievePackageJson(); @@ -45,7 +45,7 @@ async function addDependencies( writePackageJson(packageJson); - const babelDependencies = await getBabelDependencies(packageManager, npmOptions, packageJson); + const babelDependencies = await getBabelDependencies(packageManager, packageJson); packageManager.addDependencies({ ...npmOptions, packageJson }, [ ...versionedPackages, diff --git a/lib/cli/src/generators/AURELIA/index.ts b/lib/cli/src/generators/AURELIA/index.ts index 76aaa17f5f8..76afc978e2d 100644 --- a/lib/cli/src/generators/AURELIA/index.ts +++ b/lib/cli/src/generators/AURELIA/index.ts @@ -46,7 +46,7 @@ const generator: Generator = async ( packages.push('@storybook/addon-docs'); } - const versionedPackages = await packageManager.getVersionedPackages(npmOptions, ...packages); + const versionedPackages = await packageManager.getVersionedPackages(...packages); const packageJson = packageManager.retrievePackageJson(); packageJson.dependencies = packageJson.dependencies || {}; packageJson.devDependencies = packageJson.devDependencies || {}; @@ -55,7 +55,7 @@ const generator: Generator = async ( packageJson.scripts['build-storybook'] = 'build-storybook'; writePackageJson(packageJson); addStorybookExcludeGlobToTsConfig(); - const babelDependencies = await getBabelDependencies(packageManager, npmOptions, packageJson); + const babelDependencies = await getBabelDependencies(packageManager, packageJson); packageManager.addDependencies({ ...npmOptions, packageJson }, [ ...versionedPackages, ...babelDependencies, diff --git a/lib/cli/src/generators/EMBER/index.ts b/lib/cli/src/generators/EMBER/index.ts index 4ce0b152100..c698d21394b 100644 --- a/lib/cli/src/generators/EMBER/index.ts +++ b/lib/cli/src/generators/EMBER/index.ts @@ -10,7 +10,6 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) actionsVersion, addonsVersion, ] = await packageManager.getVersions( - npmOptions, '@storybook/ember', // babel-plugin-ember-modules-api-polyfill is a peerDep of @storybook/ember 'babel-plugin-ember-modules-api-polyfill', @@ -38,7 +37,7 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) writePackageJson(packageJson); - const babelDependencies = await getBabelDependencies(packageManager, npmOptions, packageJson); + const babelDependencies = await getBabelDependencies(packageManager, packageJson); packageManager.addDependencies({ ...npmOptions, packageJson }, [ `@storybook/ember@${storybookVersion}`, diff --git a/lib/cli/src/generators/HTML/index.ts b/lib/cli/src/generators/HTML/index.ts index 38b304ed5b9..4f502dfcde2 100755 --- a/lib/cli/src/generators/HTML/index.ts +++ b/lib/cli/src/generators/HTML/index.ts @@ -5,7 +5,7 @@ import { Generator } from '../Generator'; const generator: Generator = async (packageManager, npmOptions, { storyFormat }) => { const packages = ['@storybook/html', '@storybook/addon-actions', '@storybook/addon-links']; - const versionedPackages = await packageManager.getVersionedPackages(npmOptions, ...packages); + const versionedPackages = await packageManager.getVersionedPackages(...packages); if (storyFormat === StoryFormat.MDX) { packages.push('@storybook/addon-docs'); } @@ -23,7 +23,7 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) writePackageJson(packageJson); - const babelDependencies = await getBabelDependencies(packageManager, npmOptions, packageJson); + const babelDependencies = await getBabelDependencies(packageManager, packageJson); packageManager.addDependencies({ ...npmOptions, packageJson }, [ ...versionedPackages, diff --git a/lib/cli/src/generators/MARIONETTE/index.ts b/lib/cli/src/generators/MARIONETTE/index.ts index a2ea776f3a6..71fc48b1095 100644 --- a/lib/cli/src/generators/MARIONETTE/index.ts +++ b/lib/cli/src/generators/MARIONETTE/index.ts @@ -4,7 +4,7 @@ import { writePackageJson, getBabelDependencies } from '../../helpers'; import { Generator } from '../Generator'; const generator: Generator = async (packageManager, npmOptions) => { - const storybookVersion = await packageManager.getVersion(npmOptions, '@storybook/marionette'); + const storybookVersion = await packageManager.getVersion('@storybook/marionette'); fse.copySync(path.resolve(__dirname, 'template/'), '.', { overwrite: true }); const packageJson = packageManager.retrievePackageJson(); @@ -18,7 +18,7 @@ const generator: Generator = async (packageManager, npmOptions) => { writePackageJson(packageJson); - const babelDependencies = await getBabelDependencies(packageManager, npmOptions, packageJson); + const babelDependencies = await getBabelDependencies(packageManager, packageJson); packageManager.addDependencies({ ...npmOptions, packageJson }, [ `@storybook/marionette@${storybookVersion}`, diff --git a/lib/cli/src/generators/MARKO/index.ts b/lib/cli/src/generators/MARKO/index.ts index 3fd43a39eb0..584675033a2 100644 --- a/lib/cli/src/generators/MARKO/index.ts +++ b/lib/cli/src/generators/MARKO/index.ts @@ -7,7 +7,6 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) addonActionVersion, addonKnobsVersion, ] = await packageManager.getVersions( - npmOptions, '@storybook/marko', '@storybook/addon-actions', '@storybook/addon-knobs' @@ -26,7 +25,7 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) writePackageJson(packageJson); - const babelDependencies = await getBabelDependencies(packageManager, npmOptions, packageJson); + const babelDependencies = await getBabelDependencies(packageManager, packageJson); packageManager.addDependencies({ ...npmOptions, packageJson }, [ `@storybook/marko@${storybookVersion}`, diff --git a/lib/cli/src/generators/METEOR/index.ts b/lib/cli/src/generators/METEOR/index.ts index a8aab312975..18bffe046b0 100644 --- a/lib/cli/src/generators/METEOR/index.ts +++ b/lib/cli/src/generators/METEOR/index.ts @@ -15,7 +15,6 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) presetEnvVersion, presetReactVersion, ] = await packageManager.getVersions( - npmOptions, '@storybook/react', '@storybook/addon-actions', '@storybook/addon-links', @@ -68,7 +67,7 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) writePackageJson(packageJson); - const babelDependencies = await getBabelDependencies(packageManager, npmOptions, packageJson); + const babelDependencies = await getBabelDependencies(packageManager, packageJson); // add react packages. const dependencies = []; diff --git a/lib/cli/src/generators/MITHRIL/index.ts b/lib/cli/src/generators/MITHRIL/index.ts index eab1d199b97..edb5c89e18e 100644 --- a/lib/cli/src/generators/MITHRIL/index.ts +++ b/lib/cli/src/generators/MITHRIL/index.ts @@ -9,7 +9,6 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) knobsVersion, addonsVersion, ] = await packageManager.getVersions( - npmOptions, '@storybook/mithril', '@storybook/addon-actions', '@storybook/addon-links', @@ -30,7 +29,7 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) writePackageJson(packageJson); - const babelDependencies = await getBabelDependencies(packageManager, npmOptions, packageJson); + const babelDependencies = await getBabelDependencies(packageManager, packageJson); packageManager.addDependencies({ ...npmOptions, packageJson }, [ `@storybook/mithril@${storybookVersion}`, diff --git a/lib/cli/src/generators/PREACT/index.ts b/lib/cli/src/generators/PREACT/index.ts index 21dbd67c47f..2ec2c956ed8 100644 --- a/lib/cli/src/generators/PREACT/index.ts +++ b/lib/cli/src/generators/PREACT/index.ts @@ -8,7 +8,6 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) linksVersion, addonsVersion, ] = await packageManager.getVersions( - npmOptions, '@storybook/preact', '@storybook/addon-actions', '@storybook/addon-links', @@ -28,7 +27,7 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) writePackageJson(packageJson); - const babelDependencies = await getBabelDependencies(packageManager, npmOptions, packageJson); + const babelDependencies = await getBabelDependencies(packageManager, packageJson); packageManager.addDependencies({ ...npmOptions, packageJson }, [ `@storybook/preact@${storybookVersion}`, diff --git a/lib/cli/src/generators/RAX/index.ts b/lib/cli/src/generators/RAX/index.ts index 44056461ee3..8eabdeaf5d9 100644 --- a/lib/cli/src/generators/RAX/index.ts +++ b/lib/cli/src/generators/RAX/index.ts @@ -9,7 +9,6 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) addonsVersion, latestRaxVersion, ] = await packageManager.getVersions( - npmOptions, '@storybook/rax', '@storybook/addon-actions', '@storybook/addon-links', @@ -41,7 +40,7 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) writePackageJson(packageJson); - const babelDependencies = await getBabelDependencies(packageManager, npmOptions, packageJson); + const babelDependencies = await getBabelDependencies(packageManager, packageJson); packageManager.addDependencies({ ...npmOptions, packageJson }, [ `@storybook/rax@${storybookVersion}`, diff --git a/lib/cli/src/generators/REACT/index.ts b/lib/cli/src/generators/REACT/index.ts index 3874aff4eab..8dd954481fe 100644 --- a/lib/cli/src/generators/REACT/index.ts +++ b/lib/cli/src/generators/REACT/index.ts @@ -13,7 +13,7 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) packages.push('@storybook/addon-docs'); } - const versionedPackages = await packageManager.getVersionedPackages(npmOptions, ...packages); + const versionedPackages = await packageManager.getVersionedPackages(...packages); copyTemplate(__dirname, storyFormat); @@ -28,7 +28,7 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) writePackageJson(packageJson); - const babelDependencies = await getBabelDependencies(packageManager, npmOptions, packageJson); + const babelDependencies = await getBabelDependencies(packageManager, packageJson); packageManager.addDependencies({ ...npmOptions, packageJson }, [ ...versionedPackages, diff --git a/lib/cli/src/generators/REACT_NATIVE/index.ts b/lib/cli/src/generators/REACT_NATIVE/index.ts index c695f0a0bba..4938527b8e9 100644 --- a/lib/cli/src/generators/REACT_NATIVE/index.ts +++ b/lib/cli/src/generators/REACT_NATIVE/index.ts @@ -17,7 +17,6 @@ export default async ( actionsVersion, linksVersion, ] = await packageManager.getVersions( - npmOptions, '@storybook/react-native', '@storybook/addons', '@storybook/addon-actions', @@ -74,7 +73,7 @@ export default async ( writePackageJson(packageJson); - const babelDependencies = await getBabelDependencies(packageManager, npmOptions, packageJson); + const babelDependencies = await getBabelDependencies(packageManager, packageJson); packageManager.addDependencies({ ...npmOptions, packageJson }, [ ...devDependencies, diff --git a/lib/cli/src/generators/REACT_SCRIPTS/index.ts b/lib/cli/src/generators/REACT_SCRIPTS/index.ts index 5a65d5b13ad..67fadf36e82 100644 --- a/lib/cli/src/generators/REACT_SCRIPTS/index.ts +++ b/lib/cli/src/generators/REACT_SCRIPTS/index.ts @@ -17,7 +17,7 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) packages.push('@storybook/addon-docs'); } - const versionedPackages = await packageManager.getVersionedPackages(npmOptions, ...packages); + const versionedPackages = await packageManager.getVersionedPackages(...packages); copyTemplate(__dirname, storyFormat); @@ -38,7 +38,7 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) writePackageJson(packageJson); - const babelDependencies = await getBabelDependencies(packageManager, npmOptions, packageJson); + const babelDependencies = await getBabelDependencies(packageManager, packageJson); packageManager.addDependencies({ ...npmOptions, packageJson }, [ ...versionedPackages, diff --git a/lib/cli/src/generators/RIOT/index.ts b/lib/cli/src/generators/RIOT/index.ts index b6e5107b74c..26229895616 100644 --- a/lib/cli/src/generators/RIOT/index.ts +++ b/lib/cli/src/generators/RIOT/index.ts @@ -9,7 +9,6 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) addonsVersion, tagLoaderVersion, ] = await packageManager.getVersions( - npmOptions, '@storybook/riot', '@storybook/addon-actions', '@storybook/addon-links', @@ -42,7 +41,7 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) writePackageJson(packageJson); - const babelDependencies = await getBabelDependencies(packageManager, npmOptions, packageJson); + const babelDependencies = await getBabelDependencies(packageManager, packageJson); packageManager.addDependencies({ ...npmOptions, packageJson }, [ ...dependencies, diff --git a/lib/cli/src/generators/SFC_VUE/index.ts b/lib/cli/src/generators/SFC_VUE/index.ts index b6b8985bdf1..90b109fbe95 100644 --- a/lib/cli/src/generators/SFC_VUE/index.ts +++ b/lib/cli/src/generators/SFC_VUE/index.ts @@ -12,7 +12,7 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) if (storyFormat === StoryFormat.MDX) { packages.push('@storybook/addon-docs'); } - const versionedPackages = await packageManager.getVersionedPackages(npmOptions, ...packages); + const versionedPackages = await packageManager.getVersionedPackages(...packages); copyTemplate(__dirname, storyFormat); @@ -27,7 +27,7 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) writePackageJson(packageJson); - const babelDependencies = await getBabelDependencies(packageManager, npmOptions, packageJson); + const babelDependencies = await getBabelDependencies(packageManager, packageJson); packageManager.addDependencies({ ...npmOptions, packageJson }, [ ...versionedPackages, diff --git a/lib/cli/src/generators/SVELTE/index.ts b/lib/cli/src/generators/SVELTE/index.ts index bb340b260d7..3b2accf677b 100644 --- a/lib/cli/src/generators/SVELTE/index.ts +++ b/lib/cli/src/generators/SVELTE/index.ts @@ -10,7 +10,6 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) svelte, svelteLoader, ] = await packageManager.getVersions( - npmOptions, '@storybook/svelte', '@storybook/addon-actions', '@storybook/addon-links', @@ -32,7 +31,7 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) writePackageJson(packageJson); - const babelDependencies = await getBabelDependencies(packageManager, npmOptions, packageJson); + const babelDependencies = await getBabelDependencies(packageManager, packageJson); packageManager.addDependencies({ ...npmOptions, packageJson }, [ `@storybook/svelte@${storybookVersion}`, diff --git a/lib/cli/src/generators/UPDATE_PACKAGE_ORGANIZATIONS/index.ts b/lib/cli/src/generators/UPDATE_PACKAGE_ORGANIZATIONS/index.ts index 209fd8835bd..7ee89a19427 100644 --- a/lib/cli/src/generators/UPDATE_PACKAGE_ORGANIZATIONS/index.ts +++ b/lib/cli/src/generators/UPDATE_PACKAGE_ORGANIZATIONS/index.ts @@ -11,12 +11,11 @@ async function updatePackage( packageManager: JsPackageManager, devDependencies: PackageJson['devDependencies'], oldName: string, - newName: string, - npmOptions: NpmOptions + newName: string ) { if (devDependencies[oldName]) { delete devDependencies[oldName]; - devDependencies[newName] = await packageManager.getVersion(npmOptions, newName); + devDependencies[newName] = await packageManager.getVersion(newName); } } @@ -25,7 +24,6 @@ async function updatePackageJson(packageManager: JsPackageManager, npmOptions: N const { devDependencies } = packageJson; const [actionsVersion, linksVersion] = await packageManager.getVersions( - npmOptions, '@storybook/addon-actions', '@storybook/addon-links' ); @@ -36,7 +34,7 @@ async function updatePackageJson(packageManager: JsPackageManager, npmOptions: N await Promise.all( Object.keys(packageNames).map((oldName) => { const newName = packageNames[oldName]; - return updatePackage(packageManager, devDependencies, oldName, newName, npmOptions); + return updatePackage(packageManager, devDependencies, oldName, newName); }) ); @@ -46,7 +44,7 @@ async function updatePackageJson(packageManager: JsPackageManager, npmOptions: N writePackageJson(packageJson); - const babelDependencies = await getBabelDependencies(packageManager, npmOptions, packageJson); + const babelDependencies = await getBabelDependencies(packageManager, packageJson); if (babelDependencies.length > 0) { packageManager.addDependencies({ ...npmOptions, packageJson }, babelDependencies); diff --git a/lib/cli/src/generators/VUE/index.ts b/lib/cli/src/generators/VUE/index.ts index c6de37a9ddd..86899a4fe06 100644 --- a/lib/cli/src/generators/VUE/index.ts +++ b/lib/cli/src/generators/VUE/index.ts @@ -18,7 +18,7 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) if (storyFormat === StoryFormat.MDX) { packages.push('@storybook/addon-docs'); } - const versionedPackages = await packageManager.getVersionedPackages(npmOptions, ...packages); + const versionedPackages = await packageManager.getVersionedPackages(...packages); copyTemplate(__dirname, storyFormat); @@ -37,7 +37,7 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) addToDevDependenciesIfNotPresent( packageJson, '@babel/core', - await packageManager.getVersion(npmOptions, '@babel/core') + await packageManager.getVersion('@babel/core') ); } @@ -47,7 +47,7 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) writePackageJson(packageJson); - const babelDependencies = await getBabelDependencies(packageManager, npmOptions, packageJson); + const babelDependencies = await getBabelDependencies(packageManager, packageJson); packageManager.addDependencies({ ...npmOptions, packageJson }, [ ...versionedPackages, ...babelDependencies, diff --git a/lib/cli/src/generators/WEB-COMPONENTS/index.ts b/lib/cli/src/generators/WEB-COMPONENTS/index.ts index ec44d1b22b7..721d88e7522 100755 --- a/lib/cli/src/generators/WEB-COMPONENTS/index.ts +++ b/lib/cli/src/generators/WEB-COMPONENTS/index.ts @@ -12,7 +12,7 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) 'lit-html', ]; - const versionedPackages = await packageManager.getVersionedPackages(npmOptions, ...packages); + const versionedPackages = await packageManager.getVersionedPackages(...packages); fse.copySync(path.resolve(__dirname, 'template/'), '.', { overwrite: true }); @@ -31,7 +31,7 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) writePackageJson(packageJson); - const babelDependencies = await getBabelDependencies(packageManager, npmOptions, packageJson); + const babelDependencies = await getBabelDependencies(packageManager, packageJson); packageManager.addDependencies({ ...npmOptions, packageJson }, [ ...versionedPackages, diff --git a/lib/cli/src/generators/WEBPACK_REACT/index.ts b/lib/cli/src/generators/WEBPACK_REACT/index.ts index c29d4b5f53b..433015afdd3 100644 --- a/lib/cli/src/generators/WEBPACK_REACT/index.ts +++ b/lib/cli/src/generators/WEBPACK_REACT/index.ts @@ -12,7 +12,7 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) if (storyFormat === StoryFormat.MDX) { packages.push('@storybook/addon-docs'); } - const versionedPackages = await packageManager.getVersionedPackages(npmOptions, ...packages); + const versionedPackages = await packageManager.getVersionedPackages(...packages); copyTemplate(__dirname, storyFormat); @@ -27,7 +27,7 @@ const generator: Generator = async (packageManager, npmOptions, { storyFormat }) writePackageJson(packageJson); - const babelDependencies = await getBabelDependencies(packageManager, npmOptions, packageJson); + const babelDependencies = await getBabelDependencies(packageManager, packageJson); packageManager.addDependencies({ ...npmOptions, packageJson }, [ ...versionedPackages, diff --git a/lib/cli/src/has_yarn.ts b/lib/cli/src/has_yarn.ts index b427eb1ee9d..c58706cb101 100644 --- a/lib/cli/src/has_yarn.ts +++ b/lib/cli/src/has_yarn.ts @@ -14,13 +14,3 @@ export function hasYarn() { } return false; } - -export function hasYarn2() { - const yarnVersion = sync('yarn', ['--version']) - // @ts-ignore - .output.toString('utf8') - .replace(/,/g, '') - .replace(/"/g, ''); - - return !/^1\.+/.test(yarnVersion); -} diff --git a/lib/cli/src/helpers.ts b/lib/cli/src/helpers.ts index 8af17a88dab..862dd9adf41 100644 --- a/lib/cli/src/helpers.ts +++ b/lib/cli/src/helpers.ts @@ -8,7 +8,6 @@ import stripJsonComments from 'strip-json-comments'; import { StoryFormat } from './project_types'; import { PackageJson } from './PackageJson'; -import { NpmOptions } from './NpmOptions'; import { JsPackageManager } from './js-package-manager'; const logger = console; @@ -125,7 +124,6 @@ export function codeLog(codeLines: string[], leftPadAmount?: number) { /** * Detect if any babel dependencies need to be added to the project - * @param {Object} npmOptions Passed along to `latestVersion` and `getVersion` * @param {Object} packageJson The current package.json so we can inspect its contents * @returns {Array} Contains the packages and versions that need to be installed * @example @@ -138,7 +136,6 @@ export function codeLog(codeLines: string[], leftPadAmount?: number) { */ export async function getBabelDependencies( packageManager: JsPackageManager, - npmOptions: NpmOptions, packageJson: PackageJson ) { const dependenciesToAdd = []; @@ -149,12 +146,11 @@ export async function getBabelDependencies( if (!babelCoreVersion) { if (!packageJson.dependencies['@babel/core'] && !packageJson.devDependencies['@babel/core']) { - const babelCoreInstallVersion = await packageManager.getVersion(npmOptions, '@babel/core'); + const babelCoreInstallVersion = await packageManager.getVersion('@babel/core'); dependenciesToAdd.push(`@babel/core@${babelCoreInstallVersion}`); } } else { const latestCompatibleBabelVersion = await packageManager.latestVersion( - npmOptions, 'babel-core', babelCoreVersion ); @@ -166,7 +162,6 @@ export async function getBabelDependencies( if (!packageJson.dependencies['babel-loader'] && !packageJson.devDependencies['babel-loader']) { const babelLoaderInstallVersion = await packageManager.getVersion( - npmOptions, 'babel-loader', babelLoaderVersion ); diff --git a/lib/cli/src/initiate.ts b/lib/cli/src/initiate.ts index 694049ae076..4ddc76d5fa3 100644 --- a/lib/cli/src/initiate.ts +++ b/lib/cli/src/initiate.ts @@ -2,7 +2,6 @@ import { UpdateNotifier, IPackage } from 'update-notifier'; import chalk from 'chalk'; import inquirer from 'inquirer'; import { detect, isStorybookInstalled, detectLanguage } from './detect'; -import { hasYarn } from './has_yarn'; import { installableProjectTypes, ProjectType, @@ -50,7 +49,6 @@ const installStorybook = (projectType: ProjectType, options: CommandOptions): Pr const packageManager = JsPackageManagerFactory.getPackageManager(options.useNpm); const npmOptions: NpmOptions = { - useYarn: Boolean(options.useNpm !== true) && hasYarn(), installAsDevDependencies: true, skipInstall: options.skipInstall, }; diff --git a/lib/cli/src/js-package-manager/JsPackageManager.ts b/lib/cli/src/js-package-manager/JsPackageManager.ts index ffa9898e165..8d0f5103293 100644 --- a/lib/cli/src/js-package-manager/JsPackageManager.ts +++ b/lib/cli/src/js-package-manager/JsPackageManager.ts @@ -4,7 +4,6 @@ import chalk from 'chalk'; import { gt, satisfies } from '@storybook/semver'; import { commandLog, writePackageJson } from '../helpers'; import { PackageJson } from '../PackageJson'; -import { NpmOptions } from '../NpmOptions'; const logger = console; // Cannot be `import` as it's not under TS root dir @@ -108,16 +107,12 @@ export abstract class JsPackageManager { /** * Return an array of strings matching following format: `@` * - * @param npmOptions * @param packageNames */ - public getVersionedPackages( - npmOptions: NpmOptions, - ...packageNames: string[] - ): Promise { + public getVersionedPackages(...packageNames: string[]): Promise { return Promise.all( packageNames.map( - async (packageName) => `${packageName}@${await this.getVersion(npmOptions, packageName)}` + async (packageName) => `${packageName}@${await this.getVersion(packageName)}` ) ); } @@ -126,18 +121,13 @@ export abstract class JsPackageManager { * Return an array of string standing for the latest version of the input packages. * To be able to identify which version goes with which package the order of the input array is keep. * - * @param npmOptions * @param packageNames */ - public getVersions(npmOptions: NpmOptions, ...packageNames: string[]): Promise { - return Promise.all(packageNames.map((packageName) => this.getVersion(npmOptions, packageName))); + public getVersions(...packageNames: string[]): Promise { + return Promise.all(packageNames.map((packageName) => this.getVersion(packageName))); } - public async getVersion( - npmOptions: NpmOptions, - packageName: string, - constraint?: string - ): Promise { + public async getVersion(packageName: string, constraint?: string): Promise { let current; if (packageName === '@storybook/cli') { current = storybookCLIVersion; @@ -147,7 +137,7 @@ export abstract class JsPackageManager { let latest; try { - latest = await this.latestVersion(npmOptions, packageName, constraint); + latest = await this.latestVersion(packageName, constraint); } catch (e) { if (current) { logger.warn(`\n ${chalk.yellow(e.message)}`); @@ -169,16 +159,10 @@ export abstract class JsPackageManager { * Get the latest version of the package available on npmjs.com. * If constraint is set then it returns a version satisfying it, otherwise the latest version available is returned. * - * @param npmOptions Object containing a `useYarn: boolean` attribute * @param packageName Name of the package * @param constraint Version range to use to constraint the returned version */ - public async latestVersion( - // @ts-ignore - npmOptions: { useYarn: boolean }, - packageName: string, - constraint?: string - ): Promise { + public async latestVersion(packageName: string, constraint?: string): Promise { if (!constraint) { return this.runGetVersions(packageName, false); }