Skip to content

Commit

Permalink
Core: Add removeAdd server preset
Browse files Browse the repository at this point in the history
  • Loading branch information
shilman committed Jan 19, 2024
1 parent 966e56d commit 642d34f
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion code/lib/cli/src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
1 change: 1 addition & 0 deletions code/lib/core-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions code/lib/core-common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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 });
Expand Down
7 changes: 7 additions & 0 deletions code/lib/core-server/src/presets/common-preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
getPreviewBodyTemplate,
getPreviewHeadTemplate,
loadEnvs,
removeAddon,
} from '@storybook/core-common';
import type {
CLIOptions,
Expand Down Expand Up @@ -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<string, Function>) => ({
...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 })`,
Expand Down
2 changes: 1 addition & 1 deletion code/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:*"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 642d34f

Please sign in to comment.