Skip to content

Commit

Permalink
Merge pull request #25664 from storybookjs/shilman/remove-addon-api
Browse files Browse the repository at this point in the history
Core: Add preset with experimental server API
  • Loading branch information
shilman authored Jan 19, 2024
2 parents 82baec1 + 3398dfc commit b620b12
Show file tree
Hide file tree
Showing 101 changed files with 257 additions and 214 deletions.
1 change: 0 additions & 1 deletion code/frameworks/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
},
"dependencies": {
"@storybook/builder-webpack5": "workspace:*",
"@storybook/cli": "workspace:*",
"@storybook/client-logger": "workspace:*",
"@storybook/core-common": "workspace:*",
"@storybook/core-events": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const buildMock = {
};

vi.doMock('@storybook/core-server', () => buildMock);
vi.doMock('@storybook/cli', () => ({
vi.doMock('@storybook/core-common', () => ({
JsPackageManagerFactory: {
getPackageManager: () => ({
runPackageCommand: mockRunScript,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { sync as readUpSync } from 'read-pkg-up';
import { BrowserBuilderOptions, StylePreprocessorOptions } from '@angular-devkit/build-angular';

import { CLIOptions } from '@storybook/types';
import { getEnvConfig, versions } from '@storybook/cli';
import { getEnvConfig, versions } from '@storybook/core-common';
import { addToGlobalContext } from '@storybook/telemetry';

import { buildStaticStandalone, withTelemetry } from '@storybook/core-server';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ vi.doMock('find-up', () => ({ sync: () => './storybook/tsconfig.ts' }));

const mockRunScript = vi.fn();

vi.mock('@storybook/cli', () => ({
vi.mock('@storybook/core-common', () => ({
getEnvConfig: (options: any) => options,
versions: {
storybook: 'x.x.x',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { sync as findUpSync } from 'find-up';
import { sync as readUpSync } from 'read-pkg-up';

import { CLIOptions } from '@storybook/types';
import { getEnvConfig, versions } from '@storybook/cli';
import { getEnvConfig, versions } from '@storybook/core-common';
import { addToGlobalContext } from '@storybook/telemetry';
import { buildDevStandalone, withTelemetry } from '@storybook/core-server';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { runCompodoc } from './run-compodoc';

const mockRunScript = vi.fn();

vi.mock('@storybook/cli', () => ({
vi.mock('@storybook/core-common', () => ({
JsPackageManagerFactory: {
getPackageManager: () => ({
runPackageCommandSync: mockRunScript,
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/angular/src/builders/utils/run-compodoc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BuilderContext } from '@angular-devkit/architect';
import { Observable } from 'rxjs';
import * as path from 'path';
import { JsPackageManagerFactory } from '@storybook/cli';
import { JsPackageManagerFactory } from '@storybook/core-common';

const hasTsConfigArg = (args: string[]) => args.indexOf('-p') !== -1;
const hasOutputArg = (args: string[]) =>
Expand Down
6 changes: 1 addition & 5 deletions code/lib/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,9 @@
"detect-indent": "^6.1.0",
"envinfo": "^7.7.3",
"execa": "^5.0.0",
"express": "^4.17.3",
"find-up": "^5.0.0",
"fs-extra": "^11.1.0",
"get-npm-tarball-url": "^2.0.3",
"get-port": "^5.1.1",
"giget": "^1.0.0",
"globby": "^11.0.2",
"jscodeshift": "^0.15.1",
Expand All @@ -92,8 +90,7 @@
"strip-json-comments": "^3.0.1",
"tempy": "^1.0.1",
"tiny-invariant": "^1.3.1",
"ts-dedent": "^2.0.0",
"util-deprecate": "^1.0.2"
"ts-dedent": "^2.0.0"
},
"devDependencies": {
"@types/cross-spawn": "^6.0.2",
Expand All @@ -108,7 +105,6 @@
"access": "public"
},
"bundler": {
"pre": "./scripts/generate-sb-packages-versions.js",
"entries": [
"./src/generate.ts",
"./src/index.ts"
Expand Down
12 changes: 8 additions & 4 deletions code/lib/cli/src/add.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { getStorybookInfo, serverRequire } from '@storybook/core-common';
import {
getStorybookInfo,
serverRequire,
getStorybookVersion,
isCorePackage,
JsPackageManagerFactory,
type PackageManagerName,
} from '@storybook/core-common';
import { readConfig, writeConfig } from '@storybook/csf-tools';
import { isAbsolute, join } from 'path';
import SemVer from 'semver';
import dedent from 'ts-dedent';

import { JsPackageManagerFactory, type PackageManagerName } from './js-package-manager';
import { getStorybookVersion, isCorePackage } from './utils';

const logger = console;

interface PostinstallOptions {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, beforeEach, afterEach, it, expect, vi } from 'vitest';
import type { StorybookConfig } from '@storybook/types';
import type { JsPackageManager } from '../../js-package-manager';
import type { JsPackageManager } from '@storybook/core-common';
import { angularBuildersMultiproject } from './angular-builders-multiproject';
import * as helpers from '../../helpers';
import * as angularHelpers from '../../generators/ANGULAR/helpers';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { StorybookConfig } from '@storybook/types';
import { angularBuilders } from './angular-builders';
import * as helpers from '../../helpers';
import * as angularHelpers from '../../generators/ANGULAR/helpers';
import type { JsPackageManager } from '../../js-package-manager';
import type { JsPackageManager } from '@storybook/core-common';

const checkAngularBuilders = async ({
packageManager,
Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli/src/automigrate/fixes/angular-builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import prompts from 'prompts';
import type { Fix } from '../types';
import { isNxProject } from '../../helpers';
import { AngularJSON } from '../../generators/ANGULAR/helpers';
import type { JsPackageManager } from '../../js-package-manager';
import type { JsPackageManager } from '@storybook/core-common';
import { getFrameworkPackageName } from '../helpers/mainConfigFile';

interface AngularBuildersRunOptions {
Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli/src/automigrate/fixes/autodocs-true.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, afterEach, it, expect, vi } from 'vitest';
import type { StorybookConfigRaw } from '@storybook/types';
import type { PackageJson } from '../../js-package-manager';
import type { PackageJson } from '@storybook/core-common';
import { makePackageManager } from '../helpers/testing-helpers';
import { autodocsTrue } from './autodocs-true';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, afterEach, it, expect, vi } from 'vitest';

import type { StorybookConfigRaw } from '@storybook/types';
import type { PackageJson } from '../../js-package-manager';
import type { PackageJson } from '@storybook/core-common';
import { ansiRegex } from '../helpers/cleanLog';
import { makePackageManager } from '../helpers/testing-helpers';
import type { BareMdxStoriesGlobRunOptions } from './bare-mdx-stories-glob';
Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli/src/automigrate/fixes/builder-vite.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, afterEach, it, expect, vi } from 'vitest';
import type { StorybookConfigRaw } from '@storybook/types';
import { makePackageManager } from '../helpers/testing-helpers';
import type { PackageJson } from '../../js-package-manager';
import type { PackageJson } from '@storybook/core-common';
import { builderVite } from './builder-vite';

const checkBuilderVite = async ({
Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli/src/automigrate/fixes/builder-vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { dedent } from 'ts-dedent';
import { writeConfig } from '@storybook/csf-tools';

import type { Fix } from '../types';
import type { PackageJson } from '../../js-package-manager';
import type { PackageJson } from '@storybook/core-common';
import { updateMainConfig } from '../helpers/mainConfigFile';
import { getStorybookVersionSpecifier } from '../../helpers';

Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli/src/automigrate/fixes/cra5.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, afterEach, it, expect, vi } from 'vitest';
import type { StorybookConfigRaw } from '@storybook/types';
import type { JsPackageManager } from '../../js-package-manager';
import type { JsPackageManager } from '@storybook/core-common';
import { cra5 } from './cra5';

const checkCra5 = async ({
Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli/src/automigrate/fixes/eslint-plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { describe, it, expect, vi } from 'vitest';
import { dedent } from 'ts-dedent';
import * as fsExtra from 'fs-extra';
import type { PackageJson } from '../../js-package-manager';
import type { PackageJson } from '@storybook/core-common';
import { eslintPlugin } from './eslint-plugin';
import { makePackageManager } from '../helpers/testing-helpers';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { describe, afterEach, it, expect, vi } from 'vitest';

import type { StorybookConfig } from '@storybook/types';
import { incompatibleAddons } from './incompatible-addons';
import type { JsPackageManager } from '../../js-package-manager';
import type { JsPackageManager } from '@storybook/core-common';

const check = async ({
packageManager,
Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli/src/automigrate/fixes/new-frameworks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { StorybookConfig } from '@storybook/types';
import * as findUp from 'find-up';
import * as rendererHelpers from '../helpers/detectRenderer';
import { newFrameworks } from './new-frameworks';
import type { JsPackageManager } from '../../js-package-manager';
import type { JsPackageManager } from '@storybook/core-common';

vi.mock('find-up');
vi.mock('../helpers/detectRenderer', async (importOriginal) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { vi, describe, it, expect } from 'vitest';
import type { StorybookConfig } from '@storybook/types';
import { glob } from 'glob';
import { removeReactDependency } from './prompt-remove-react';
import type { JsPackageManager } from '../../js-package-manager';
import type { JsPackageManager } from '@storybook/core-common';

const check = async ({
packageManagerContent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { describe, it, expect, vi } from 'vitest';

import path from 'path';
import * as fsExtra from 'fs-extra';
import type { JsPackageManager } from '../../js-package-manager';
import type { JsPackageManager } from '@storybook/core-common';
import { RemovedAPIs, removedGlobalClientAPIs as migration } from './remove-global-client-apis';

vi.mock('fs-extra', async () => import('../../../../../__mocks__/fs-extra'));
Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli/src/automigrate/fixes/sb-binary.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest';
import type { JsPackageManager } from '../../js-package-manager';
import type { JsPackageManager } from '@storybook/core-common';
import { sbBinary } from './sb-binary';

const checkStorybookBinary = async ({
Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli/src/automigrate/fixes/sb-binary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { dedent } from 'ts-dedent';
import semver from 'semver';
import type { Fix } from '../types';
import { getStorybookVersionSpecifier } from '../../helpers';
import type { PackageJsonWithDepsAndDevDeps } from '../../js-package-manager';
import type { PackageJsonWithDepsAndDevDeps } from '@storybook/core-common';

interface SbBinaryRunOptions {
storybookVersion: string;
Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli/src/automigrate/fixes/sb-scripts.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, afterEach, it, expect, vi } from 'vitest';
import type { JsPackageManager } from '../../js-package-manager';
import type { JsPackageManager } from '@storybook/core-common';
import { getStorybookScripts, sbScripts } from './sb-scripts';

const checkSbScripts = async ({
Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli/src/automigrate/fixes/sb-scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { dedent } from 'ts-dedent';
import semver from 'semver';
import type { PackageJson } from '@storybook/types';
import type { Fix } from '../types';
import type { PackageJsonWithDepsAndDevDeps } from '../../js-package-manager';
import type { PackageJsonWithDepsAndDevDeps } from '@storybook/core-common';

interface SbScriptsRunOptions {
storybookScripts: Record<string, { before: string; after: string }>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { describe, afterEach, it, expect, vi } from 'vitest';

import type { StorybookConfig } from '@storybook/types';
import { storyshotsMigration } from './storyshots-migration';
import type { JsPackageManager } from '../../js-package-manager';
import type { JsPackageManager } from '@storybook/core-common';

const check = async ({
packageManager,
Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli/src/automigrate/fixes/vue3.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, afterEach, it, expect, vi } from 'vitest';
import type { StorybookConfig } from '@storybook/types';
import type { JsPackageManager } from '../../js-package-manager';
import type { JsPackageManager } from '@storybook/core-common';
import { vue3 } from './vue3';

const checkVue3 = async ({
Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli/src/automigrate/fixes/webpack5.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, afterEach, it, expect, vi } from 'vitest';
import type { StorybookConfig } from '@storybook/types';
import type { JsPackageManager } from '../../js-package-manager';
import type { JsPackageManager } from '@storybook/core-common';
import { webpack5 } from './webpack5';

const checkWebpack5 = async ({
Expand Down
8 changes: 4 additions & 4 deletions code/lib/cli/src/automigrate/helpers/eslintPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import fse, { readFile, readJson, writeJson } from 'fs-extra';

import { dedent } from 'ts-dedent';
import detectIndent from 'detect-indent';
import { readConfig, writeConfig } from '@storybook/csf-tools';
import prompts from 'prompts';
import chalk from 'chalk';
import type { JsPackageManager } from '../../js-package-manager';
import { paddedLog } from '../../helpers';

import { readConfig, writeConfig } from '@storybook/csf-tools';
import type { JsPackageManager } from '@storybook/core-common';
import { paddedLog } from '@storybook/core-common';

export const SUPPORTED_ESLINT_EXTENSIONS = ['js', 'cjs', 'json'];
const UNSUPPORTED_ESLINT_EXTENSIONS = ['yaml', 'yml'];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, vi, it } from 'vitest';
import { getMigrationSummary } from './getMigrationSummary';
import { FixStatus } from '../types';
import type { InstallationMetadata } from '../../js-package-manager/types';
import type { InstallationMetadata } from '@storybook/core-common';

vi.mock('boxen', () => ({
default: vi.fn((str, { title = '' }) => `${title}\n\n${str.replace(/\x1b\[[0-9;]*[mG]/g, '')}`),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import chalk from 'chalk';
import boxen from 'boxen';
import dedent from 'ts-dedent';
import type { InstallationMetadata } from '@storybook/core-common';
import type { FixSummary } from '../types';
import { FixStatus } from '../types';
import type { InstallationMetadata } from '../../js-package-manager/types';
import { getDuplicatedDepsWarnings } from '../../doctor/getDuplicatedDepsWarnings';

export const messageDivider = '\n\n';
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 @@ -11,8 +11,8 @@ import { readConfig, writeConfig as writeConfigFile } from '@storybook/csf-tools
import chalk from 'chalk';
import dedent from 'ts-dedent';
import path from 'path';
import type { JsPackageManager } from '../../js-package-manager';
import { getStorybookVersion } from '../../utils';
import type { JsPackageManager } from '@storybook/core-common';
import { getStorybookVersion } from '@storybook/core-common';

const logger = console;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
detectBuilderInfo as _getBuilderInfo,
getNextjsAddonOptions,
} from './new-frameworks-utils';
import type { JsPackageManager } from '../../js-package-manager';
import type { JsPackageManager } from '@storybook/core-common';

vi.mock('find-up');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { frameworkPackages } from '@storybook/core-common';
import type { Preset, StorybookConfigRaw } from '@storybook/types';
import findUp from 'find-up';
import type { JsPackageManager } from '../../js-package-manager';
import type { JsPackageManager } from '@storybook/core-common';
import { getBuilderPackageName, getFrameworkPackageName } from './mainConfigFile';

const logger = console;
Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli/src/automigrate/helpers/testing-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { vi } from 'vitest';
import type { JsPackageManager, PackageJson } from '../../js-package-manager';
import type { JsPackageManager, PackageJson } from '@storybook/core-common';

vi.mock('./mainConfigFile', async (importOriginal) => ({
...(await importOriginal<typeof import('./mainConfigFile')>()),
Expand Down
13 changes: 8 additions & 5 deletions code/lib/cli/src/automigrate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@ import boxen from 'boxen';
import { createWriteStream, move, remove } from 'fs-extra';
import tempy from 'tempy';
import dedent from 'ts-dedent';

import { join } from 'path';
import { getStorybookInfo, loadMainConfig } from '@storybook/core-common';
import invariant from 'tiny-invariant';
import { JsPackageManagerFactory } from '../js-package-manager';
import type { PackageManagerName } from '../js-package-manager';

import {
getStorybookInfo,
loadMainConfig,
getStorybookVersion,
JsPackageManagerFactory,
} from '@storybook/core-common';
import type { PackageManagerName } from '@storybook/core-common';

import type { Fix, FixId, FixOptions, FixSummary } from './fixes';
import { FixStatus, PreCheckFailure, allFixes } from './fixes';
import { cleanLog } from './helpers/cleanLog';
import { getMigrationSummary } from './helpers/getMigrationSummary';
import { getStorybookData } from './helpers/mainConfigFile';
import { getStorybookVersion } from '../utils';

const logger = console;
const LOG_FILE_NAME = 'migration-storybook.log';
Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli/src/automigrate/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { StorybookConfigRaw } from '@storybook/types';
import type { JsPackageManager, PackageManagerName } from '../js-package-manager';
import type { JsPackageManager, PackageManagerName } from '@storybook/core-common';

export interface CheckOptions {
packageManager: JsPackageManager;
Expand Down
Loading

0 comments on commit b620b12

Please sign in to comment.