diff --git a/CHANGELOG.prerelease.md b/CHANGELOG.prerelease.md index 7d47df14755..954ca7fc30b 100644 --- a/CHANGELOG.prerelease.md +++ b/CHANGELOG.prerelease.md @@ -1,3 +1,9 @@ +## 8.6.0-beta.7 + +- Angular: Fix @angular/platform-browser/animations never available - [#30618](https://github.com/storybookjs/storybook/pull/30618), thanks @valentinpalkovic! +- Angular: Fix @angular/platform-browser/animations never available - [#30619](https://github.com/storybookjs/storybook/pull/30619), thanks @valentinpalkovic! +- CLI: Fix peer dep issues for npm users during upgrade - [#30616](https://github.com/storybookjs/storybook/pull/30616), thanks @valentinpalkovic! + ## 8.6.0-beta.6 - CLI: Fix printing of selected features - [#30605](https://github.com/storybookjs/storybook/pull/30605), thanks @ghengeveld! diff --git a/code/frameworks/angular/src/server/framework-preset-angular-cli.ts b/code/frameworks/angular/src/server/framework-preset-angular-cli.ts index 1974e0bd501..fe148c5281d 100644 --- a/code/frameworks/angular/src/server/framework-preset-angular-cli.ts +++ b/code/frameworks/angular/src/server/framework-preset-angular-cli.ts @@ -41,7 +41,7 @@ export async function webpackFinal(baseConfig: webpack.Configuration, options: P ); try { - await import('@angular/platform-browser/animations'); + require.resolve('@angular/animations'); } catch (e) { webpackConfig.plugins.push( new WebpackIgnorePlugin({ diff --git a/code/lib/cli-storybook/src/upgrade.ts b/code/lib/cli-storybook/src/upgrade.ts index 002216ba99f..0929fc51762 100644 --- a/code/lib/cli-storybook/src/upgrade.ts +++ b/code/lib/cli-storybook/src/upgrade.ts @@ -254,36 +254,47 @@ export const doUpgrade = async ({ // GitHub Issue: https://github.com/storybookjs/storybook/issues/30306 // Solution: Remove all Storybook packages (except 'storybook') from the package.json and install them again if (packageManager.type === 'npm') { + const getPackageName = (dep: string) => { + const lastAtIndex = dep.lastIndexOf('@'); + return lastAtIndex > 0 ? dep.slice(0, lastAtIndex) : dep; + }; + + // Remove all Storybook packages except 'storybook' await packageManager.removeDependencies( - { - skipInstall: false, - }, + { skipInstall: false }, [...upgradedDependencies, ...upgradedDevDependencies] - .map((dep) => { - const lastAtIndex = dep.lastIndexOf('@'); - return lastAtIndex > 0 ? dep.slice(0, lastAtIndex) : dep; - }) - // We don't want to remove the storybook package from the package.json - // because third-party packages which we don't remove may depend on it via peer-dependency requirements + .map(getPackageName) .filter((dep) => dep !== 'storybook') ); - await packageManager.installDependencies(); + // Handle 'storybook' package separately to maintain peer dependencies + const findStorybookPackage = (deps: string[]) => + deps.find((dep) => getPackageName(dep) === 'storybook'); + + const storybookDep = findStorybookPackage(upgradedDependencies); + const storybookDevDep = findStorybookPackage(upgradedDevDependencies); + + if (storybookDep) { + await packageManager.addDependencies({ installAsDevDependencies: false }, [storybookDep]); + } + if (storybookDevDep) { + await packageManager.addDependencies({ installAsDevDependencies: true }, [storybookDevDep]); + } } + // Update all dependencies logger.info(`Updating dependencies in ${picocolors.cyan('package.json')}..`); - if (upgradedDependencies.length > 0) { - await packageManager.addDependencies( - { installAsDevDependencies: false, skipInstall: true, packageJson }, - upgradedDependencies - ); - } - if (upgradedDevDependencies.length > 0) { - await packageManager.addDependencies( - { installAsDevDependencies: true, skipInstall: true, packageJson }, - upgradedDevDependencies - ); - } + const addDeps = async (deps: string[], isDev: boolean) => { + if (deps.length > 0) { + await packageManager.addDependencies( + { installAsDevDependencies: isDev, skipInstall: true, packageJson }, + deps + ); + } + }; + + await addDeps(upgradedDependencies, false); + await addDeps(upgradedDevDependencies, true); await packageManager.installDependencies(); } diff --git a/code/package.json b/code/package.json index 2d411851ac7..fa5422fb8c6 100644 --- a/code/package.json +++ b/code/package.json @@ -303,5 +303,6 @@ "Dependency Upgrades" ] ] - } + }, + "deferredNextVersion": "8.6.0-beta.7" } diff --git a/docs/versions/next.json b/docs/versions/next.json index a6282be4137..ece80c89a9d 100644 --- a/docs/versions/next.json +++ b/docs/versions/next.json @@ -1 +1 @@ -{"version":"8.6.0-beta.6","info":{"plain":"- CLI: Fix printing of selected features - [#30605](https://github.com/storybookjs/storybook/pull/30605), thanks @ghengeveld!\n- CLI: Remove Storybook dependencies before adding re-adding them - [#30600](https://github.com/storybookjs/storybook/pull/30600), thanks @valentinpalkovic!"}} +{"version":"8.6.0-beta.7","info":{"plain":"- Angular: Fix @angular/platform-browser/animations never available - [#30618](https://github.com/storybookjs/storybook/pull/30618), thanks @valentinpalkovic!\n- Angular: Fix @angular/platform-browser/animations never available - [#30619](https://github.com/storybookjs/storybook/pull/30619), thanks @valentinpalkovic!\n- CLI: Fix peer dep issues for npm users during upgrade - [#30616](https://github.com/storybookjs/storybook/pull/30616), thanks @valentinpalkovic!"}}