Skip to content

Commit

Permalink
Update name of getStorybookVersion to getCoercedStorybookVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinpalkovic committed Jan 29, 2024
1 parent 7987e76 commit 731531e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
5 changes: 3 additions & 2 deletions code/lib/cli/src/add.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
getStorybookInfo,
serverRequire,
getStorybookVersion,
getCoercedStorybookVersion,
isCorePackage,
JsPackageManagerFactory,
type PackageManagerName,
Expand Down Expand Up @@ -107,8 +107,9 @@ export async function add(
// add to package.json
const isStorybookAddon = addonName.startsWith('@storybook/');
const isAddonFromCore = isCorePackage(addonName);
const storybookVersion = await getStorybookVersion(packageManager);
const storybookVersion = await getCoercedStorybookVersion(packageManager);
const version = versionSpecifier || (isAddonFromCore ? storybookVersion : latestVersion);

const addonWithVersion = SemVer.valid(version)
? `${addonName}@^${version}`
: `${addonName}@${version}`;
Expand Down
4 changes: 2 additions & 2 deletions code/lib/cli/src/automigrate/helpers/mainConfigFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import chalk from 'chalk';
import dedent from 'ts-dedent';
import path from 'path';
import type { JsPackageManager } from '@storybook/core-common';
import { getStorybookVersion } from '@storybook/core-common';
import { getCoercedStorybookVersion } from '@storybook/core-common';

const logger = console;

Expand Down Expand Up @@ -93,7 +93,7 @@ export const getStorybookData = async ({
configDir: configDirFromScript,
previewConfig: previewConfigPath,
} = getStorybookInfo(packageJson, userDefinedConfigDir);
const storybookVersion = await getStorybookVersion(packageManager);
const storybookVersion = await getCoercedStorybookVersion(packageManager);

const configDir = userDefinedConfigDir || configDirFromScript || '.storybook';

Expand Down
4 changes: 2 additions & 2 deletions code/lib/cli/src/automigrate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import invariant from 'tiny-invariant';
import {
getStorybookInfo,
loadMainConfig,
getStorybookVersion,
getCoercedStorybookVersion,
JsPackageManagerFactory,
} from '@storybook/core-common';
import type { PackageManagerName } from '@storybook/core-common';
Expand Down Expand Up @@ -156,7 +156,7 @@ export async function runFixes({
userSpecifiedConfigDir
);

const storybookVersion = await getStorybookVersion(packageManager);
const storybookVersion = await getCoercedStorybookVersion(packageManager);

if (!storybookVersion) {
logger.info(dedent`
Expand Down
5 changes: 2 additions & 3 deletions code/lib/core-common/src/utils/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ describe('UTILS', () => {
describe.each([
['@storybook/react', true],
['@storybook/node-logger', true],
['@storybook/addon-info', true],
['@storybook/something-random', true],
['@storybook/preset-create-react-app', false],
['@storybook/linter-config', false],
['@storybook/design-system', false],
['@storybook/addon-styling', false],
['@storybook/addon-styling-webpack', false],
['@storybook/addon-webpack5-compiler-swc', false],
['@storybook/addon-webpack5-compiler-babel', false],
['@nx/storybook', false],
['@nrwl/storybook', false],
])('isCorePackage', (input, output) => {
Expand Down
3 changes: 2 additions & 1 deletion code/lib/core-common/src/utils/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { join } from 'path';
import tempy from 'tempy';
import { rendererPackages } from './get-storybook-info';
import type { JsPackageManager } from '../js-package-manager';
import versions from '../versions';

export function parseList(str: string): string[] {
return str
Expand All @@ -12,7 +13,7 @@ export function parseList(str: string): string[] {
.filter((item) => item.length > 0);
}

export async function getStorybookVersion(packageManager: JsPackageManager) {
export async function getCoercedStorybookVersion(packageManager: JsPackageManager) {
const packages = (
await Promise.all(
Object.keys(rendererPackages).map(async (pkg) => ({
Expand Down

0 comments on commit 731531e

Please sign in to comment.