diff --git a/code/lib/cli/src/generate.ts b/code/lib/cli/src/generate.ts index 242ba2ea2b61..a3175e5d0b54 100644 --- a/code/lib/cli/src/generate.ts +++ b/code/lib/cli/src/generate.ts @@ -12,7 +12,7 @@ import { parseList, getEnvConfig, JsPackageManagerFactory, versions } from '@sto import type { CommandOptions } from './generators/types'; import { initiate } from './initiate'; import { add } from './add'; -import { remove } from './remove'; +import { removeAddon as remove } from '@storybook/core-common'; import { migrate } from './migrate'; import { upgrade, type UpgradeOptions } from './upgrade'; import { sandbox } from './sandbox'; diff --git a/code/lib/core-common/package.json b/code/lib/core-common/package.json index 9428355fe679..aa431de62d95 100644 --- a/code/lib/core-common/package.json +++ b/code/lib/core-common/package.json @@ -45,6 +45,7 @@ }, "dependencies": { "@storybook/core-events": "workspace:*", + "@storybook/csf-tools": "workspace:*", "@storybook/node-logger": "workspace:*", "@storybook/types": "workspace:*", "@types/find-cache-dir": "^3.2.1", diff --git a/code/lib/core-common/src/index.ts b/code/lib/core-common/src/index.ts index bda9f8789f67..b827aae44d81 100644 --- a/code/lib/core-common/src/index.ts +++ b/code/lib/core-common/src/index.ts @@ -26,6 +26,7 @@ export * from './utils/log-config'; export * from './utils/normalize-stories'; export * from './utils/paths'; export * from './utils/readTemplate'; +export * from './utils/remove'; export * from './utils/resolve-path-in-sb-cache'; export * from './utils/symlinks'; export * from './utils/template'; diff --git a/code/lib/cli/src/remove.ts b/code/lib/core-common/src/utils/remove.ts similarity index 80% rename from code/lib/cli/src/remove.ts rename to code/lib/core-common/src/utils/remove.ts index 276d1a83c61a..0c9af135aa39 100644 --- a/code/lib/cli/src/remove.ts +++ b/code/lib/core-common/src/utils/remove.ts @@ -1,8 +1,8 @@ -import { getStorybookInfo } from '@storybook/core-common'; -import { readConfig, writeConfig } from '@storybook/csf-tools'; import dedent from 'ts-dedent'; - -import { JsPackageManagerFactory, type PackageManagerName } from '@storybook/core-common'; +import { readConfig, writeConfig } from '@storybook/csf-tools'; +import type { PackageManagerName } from '../js-package-manager'; +import { JsPackageManagerFactory } from '../js-package-manager'; +import { getStorybookInfo } from './get-storybook-info'; const logger = console; @@ -12,7 +12,10 @@ const logger = console; * Usage: * - sb remove @storybook/addon-links */ -export async function remove(addon: string, options: { packageManager: PackageManagerName }) { +export async function removeAddon( + addon: string, + options: { packageManager?: PackageManagerName } = {} +) { const { packageManager: pkgMgr } = options; const packageManager = JsPackageManagerFactory.getPackageManager({ force: pkgMgr }); diff --git a/code/lib/core-server/src/presets/common-preset.ts b/code/lib/core-server/src/presets/common-preset.ts index db67ca08bb47..4e0c183ea7c1 100644 --- a/code/lib/core-server/src/presets/common-preset.ts +++ b/code/lib/core-server/src/presets/common-preset.ts @@ -7,6 +7,7 @@ import { getPreviewBodyTemplate, getPreviewHeadTemplate, loadEnvs, + removeAddon, } from '@storybook/core-common'; import type { CLIOptions, @@ -160,6 +161,12 @@ const optionalEnvToBoolean = (input: string | undefined): boolean | undefined => return undefined; }; +// eslint-disable-next-line @typescript-eslint/naming-convention +export const experimental_serverAPI = (extension: Record) => ({ + ...extension, + removeAddon, +}); + /** * If for some reason this config is not applied, the reason is that * likely there is an addon that does `export core = () => ({ someConfig })`, diff --git a/code/yarn.lock b/code/yarn.lock index 7b63b39971b4..658e3dd2ca3c 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -5169,7 +5169,6 @@ __metadata: "@angular/platform-browser": "npm:^17.0.5" "@angular/platform-browser-dynamic": "npm:^17.0.5" "@storybook/builder-webpack5": "workspace:*" - "@storybook/cli": "workspace:*" "@storybook/client-logger": "workspace:*" "@storybook/core-common": "workspace:*" "@storybook/core-events": "workspace:*" @@ -5545,6 +5544,7 @@ __metadata: resolution: "@storybook/core-common@workspace:lib/core-common" dependencies: "@storybook/core-events": "workspace:*" + "@storybook/csf-tools": "workspace:*" "@storybook/node-logger": "workspace:*" "@storybook/types": "workspace:*" "@types/find-cache-dir": "npm:^3.2.1" diff --git a/scripts/release/version.ts b/scripts/release/version.ts index c56d7afa5b54..53365fd2d499 100644 --- a/scripts/release/version.ts +++ b/scripts/release/version.ts @@ -125,7 +125,7 @@ const bumpCodeVersion = async (nextVersion: string) => { const bumpVersionSources = async (currentVersion: string, nextVersion: string) => { const filesToUpdate = [ path.join(CODE_DIR_PATH, 'lib', 'manager-api', 'src', 'version.ts'), - path.join(CODE_DIR_PATH, 'lib', 'cli', 'src', 'versions.ts'), + path.join(CODE_DIR_PATH, 'lib', 'core-common', 'src', 'versions.ts'), ]; console.log(`🤜 Bumping versions in...:\n ${chalk.cyan(filesToUpdate.join('\n '))}`);