Skip to content

Commit

Permalink
add automigration
Browse files Browse the repository at this point in the history
  • Loading branch information
ndelangen committed Jun 10, 2024
1 parent aa0e744 commit ac2ee38
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions code/lib/cli/src/automigrate/fixes/core-dependency.ts
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}`]
);
}
},
};

0 comments on commit ac2ee38

Please sign in to comment.