-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { dedent } from 'ts-dedent'; | ||
import type { Fix } from '../types'; | ||
|
||
interface Options { | ||
storybookVersion: string; | ||
} | ||
|
||
/** | ||
*/ | ||
export const coreDependency: Fix<Options> = { | ||
id: 'core-dependency', | ||
|
||
versionRange: ['<8.2.0', '>=8.2.0'], | ||
|
||
async check({ packageManager, storybookVersion }) { | ||
const version = await packageManager.getInstalledVersion('@storybook/core'); | ||
|
||
if (version !== null) { | ||
return null; | ||
} | ||
|
||
return { storybookVersion }; | ||
}, | ||
|
||
prompt() { | ||
return dedent` | ||
New to Storybook 8.2: Our peerDependency structure changed. | ||
It's now required to have a direct dependency on @storybook/core in your package.json. | ||
Install @storybook/core in your project? | ||
`; | ||
}, | ||
|
||
async run({ packageManager, dryRun, skipInstall, result }) { | ||
if (!dryRun) { | ||
const packageJson = await packageManager.retrievePackageJson(); | ||
await packageManager.addDependencies( | ||
{ installAsDevDependencies: true, skipInstall, packageJson }, | ||
[`@storybook/core@^${result.storybookVersion}`] | ||
); | ||
} | ||
}, | ||
}; |