-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(storybook): update storybook to 6.1.11
- Loading branch information
1 parent
fcfc858
commit 399ceba
Showing
4 changed files
with
110 additions
and
1 deletion.
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
51 changes: 51 additions & 0 deletions
51
packages/storybook/src/migrations/update-11-0-12/update-storybook.spec.ts
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,51 @@ | ||
import { Tree } from '@angular-devkit/schematics'; | ||
import { readJsonInTree, readWorkspace } from '@nrwl/workspace'; | ||
import { getFileContent } from '@nrwl/workspace/testing'; | ||
|
||
import { runMigration } from '../../utils/testing'; | ||
|
||
describe('Update 11-0-12', () => { | ||
let tree: Tree; | ||
|
||
beforeEach(async () => { | ||
tree = Tree.empty(); | ||
}); | ||
|
||
it('should update storybook versions if storybook is already above 6', async () => { | ||
tree.create( | ||
'package.json', | ||
JSON.stringify({ | ||
devDependencies: { | ||
'@storybook/angular': '^6.0.0', | ||
'@storybook/react': '^6.0.0', | ||
'@storybook/addon-knobs': '^6.0.0', | ||
}, | ||
}) | ||
); | ||
const result = await runMigration('update-11-0-12', {}, tree); | ||
expect( | ||
readJsonInTree(result, 'package.json').devDependencies[ | ||
'@storybook/angular' | ||
] | ||
).toBe('^6.1.11'); | ||
}); | ||
|
||
it('should not update storybook versions if storybook is below 6', async () => { | ||
tree.create( | ||
'package.json', | ||
JSON.stringify({ | ||
devDependencies: { | ||
'@storybook/angular': '^5.0.0', | ||
'@storybook/react': '^5.0.0', | ||
'@storybook/addon-knobs': '^5.0.0', | ||
}, | ||
}) | ||
); | ||
const result = await runMigration('update-11-0-12', {}, tree); | ||
expect( | ||
readJsonInTree(result, 'package.json').devDependencies[ | ||
'@storybook/angular' | ||
] | ||
).toBe('^5.0.0'); | ||
}); | ||
}); |
53 changes: 53 additions & 0 deletions
53
packages/storybook/src/migrations/update-11-0-12/update-storybook.ts
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,53 @@ | ||
import { chain, SchematicContext, Tree } from '@angular-devkit/schematics'; | ||
import { | ||
addInstallTask, | ||
checkAndCleanWithSemver, | ||
formatFiles, | ||
updateJsonInTree, | ||
} from '@nrwl/workspace'; | ||
|
||
import { gte } from 'semver'; | ||
let needsInstall = false; | ||
|
||
const maybeUpdateVersion = updateJsonInTree('package.json', (json) => { | ||
json.dependencies = json.dependencies || {}; | ||
json.devDependencies = json.devDependencies || {}; | ||
|
||
const storybookPackages = [ | ||
'@storybook/angular', | ||
'@storybook/react', | ||
'@storybook/addon-knobs', | ||
]; | ||
storybookPackages.forEach((storybookPackageName) => { | ||
if (json.dependencies[storybookPackageName]) { | ||
const version = checkAndCleanWithSemver( | ||
storybookPackageName, | ||
json.dependencies[storybookPackageName] | ||
); | ||
if (gte(version, '6.0.0')) { | ||
json.dependencies[storybookPackageName] = '^6.1.11'; | ||
needsInstall = true; | ||
} | ||
} | ||
if (json.devDependencies[storybookPackageName]) { | ||
const version = checkAndCleanWithSemver( | ||
storybookPackageName, | ||
json.devDependencies[storybookPackageName] | ||
); | ||
if (gte(version, '6.0.0')) { | ||
json.devDependencies[storybookPackageName] = '^6.1.11'; | ||
needsInstall = true; | ||
} | ||
} | ||
}); | ||
|
||
return json; | ||
}); | ||
|
||
export default function (tree: Tree, context: SchematicContext) { | ||
return chain([ | ||
maybeUpdateVersion, | ||
formatFiles(), | ||
addInstallTask({ skipInstall: !needsInstall }), | ||
]); | ||
} |
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