From 1c5424b7babd6ccefa9785d01892fc4bf80a4cd8 Mon Sep 17 00:00:00 2001 From: Valentin Palkovic Date: Fri, 12 Jul 2024 16:28:08 +0200 Subject: [PATCH] Upgrade: Install/Add Storybook dependencies the default way With this change we are respecting the user's setting related to how dependencies should be saved to the package.json. The default behaviour is adding a caret to dependencies when added to the package.json. People can override this behaviour by defining them in, for example, a `save-exact=true` setting in their .npmrc file. --- code/lib/cli/src/upgrade.ts | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/code/lib/cli/src/upgrade.ts b/code/lib/cli/src/upgrade.ts index 30866dac64ba..d886c71b20fa 100644 --- a/code/lib/cli/src/upgrade.ts +++ b/code/lib/cli/src/upgrade.ts @@ -229,18 +229,7 @@ export const doUpgrade = async ({ // only upgrade packages that are in the monorepo return dependency in versions; }) as Array; - return monorepoDependencies.map((dependency) => { - let char = '^'; - if (isCLIOutdated) { - char = ''; - } - if (isCanary) { - char = ''; - } - /* add ^ modifier to the version if this is the latest stable or prerelease version - example outputs: @storybook/react@^8.0.0 */ - return `${dependency}@${char}${versions[dependency]}`; - }); + return monorepoDependencies.map((dependency) => `${dependency}@${versions[dependency]}`); }; const upgradedDependencies = toUpgradedDependencies(packageJson.dependencies); @@ -249,17 +238,16 @@ export const doUpgrade = async ({ logger.info(`Updating dependencies in ${chalk.cyan('package.json')}..`); if (upgradedDependencies.length > 0) { await packageManager.addDependencies( - { installAsDevDependencies: false, skipInstall: true, packageJson }, + { installAsDevDependencies: false, packageJson }, upgradedDependencies ); } if (upgradedDevDependencies.length > 0) { await packageManager.addDependencies( - { installAsDevDependencies: true, skipInstall: true, packageJson }, + { installAsDevDependencies: true, packageJson }, upgradedDevDependencies ); } - await packageManager.installDependencies(); } // AUTOMIGRATIONS