From f5c29e7bfb3d84c35fced12812a6c0b1d6c0f8a2 Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Thu, 16 Feb 2023 18:16:34 +0100 Subject: [PATCH] skip sb-binary automigration in nx projects --- code/lib/cli/src/automigrate/fixes/sb-binary.test.ts | 11 +++++++++++ code/lib/cli/src/automigrate/fixes/sb-binary.ts | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/code/lib/cli/src/automigrate/fixes/sb-binary.test.ts b/code/lib/cli/src/automigrate/fixes/sb-binary.test.ts index a3d68cf6dfa..70b019c737d 100644 --- a/code/lib/cli/src/automigrate/fixes/sb-binary.test.ts +++ b/code/lib/cli/src/automigrate/fixes/sb-binary.test.ts @@ -23,6 +23,17 @@ describe('storybook-binary fix', () => { }); describe('sb >= 7.0', () => { + it('should no-op in NX projects', async () => { + const packageJson = { + dependencies: { '@storybook/react': '^7.0.0', '@nrwl/storybook': '^15.7.1' }, + }; + await expect( + checkStorybookBinary({ + packageJson, + }) + ).resolves.toBeFalsy(); + }); + it('should add storybook dependency if not present', async () => { const packageJson = { dependencies: { diff --git a/code/lib/cli/src/automigrate/fixes/sb-binary.ts b/code/lib/cli/src/automigrate/fixes/sb-binary.ts index 91f647ba7a5..4f7c3cd1828 100644 --- a/code/lib/cli/src/automigrate/fixes/sb-binary.ts +++ b/code/lib/cli/src/automigrate/fixes/sb-binary.ts @@ -40,7 +40,8 @@ export const sbBinary: Fix = { `); } - if (semver.lt(storybookCoerced, '7.0.0')) { + // Nx provides their own binary, so we don't need to do anything + if (allDeps['@nrwl/storybook'] || semver.lt(storybookCoerced, '7.0.0')) { return null; }