Skip to content

Commit

Permalink
move core-server
Browse files Browse the repository at this point in the history
  • Loading branch information
ndelangen committed Jun 7, 2024
1 parent 6247c5f commit b7f8950
Show file tree
Hide file tree
Showing 201 changed files with 172 additions and 314 deletions.
2 changes: 1 addition & 1 deletion code/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ ember-output
!.eslintrc-markdown.js
!.storybook
core/assets
lib/core-server/src/utils/__search-files-tests__
lib/core/src/core-server/utils/__search-files-tests__
2 changes: 1 addition & 1 deletion code/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ module.exports = {
{
// these packages use pre-bundling, dependencies will be bundled, and will be in devDepenencies
files: ['frameworks/**/*', 'builders/**/*', 'deprecated/**/*', 'renderers/**/*'],
excludedFiles: ['frameworks/angular/**/*', 'frameworks/ember/**/*', 'lib/core-server/**/*'],
excludedFiles: ['frameworks/angular/**/*', 'frameworks/ember/**/*', 'core/**/*'],
rules: {
'import/no-extraneous-dependencies': [
'error',
Expand Down
File renamed without changes
50 changes: 49 additions & 1 deletion code/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@
"import": "./dist/client-logger/index.js",
"require": "./dist/client-logger/index.cjs"
},
"./dist/core-server": {
"types": "./dist/core-server/index.d.ts",
"import": "./dist/core-server/index.js",
"require": "./dist/core-server/index.cjs"
},
"./dist/core-server/presets/common-preset": {
"import": "./dist/core-server/presets/common-preset.js",
"require": "./dist/core-server/presets/common-preset.cjs"
},
"./dist/core-server/presets/common-manager": {
"import": "./dist/core-server/presets/common-manager.js"
},
"./dist/core-server/presets/common-override-preset": {
"import": "./dist/core-server/presets/common-override-preset.js",
"require": "./dist/core-server/presets/common-override-preset.cjs"
},
"./dist/core-events": {
"types": "./dist/core-events/index.d.ts",
"import": "./dist/core-events/index.js",
Expand Down Expand Up @@ -156,6 +172,18 @@
"dist/client-logger": [
"./dist/client-logger/index.d.ts"
],
"dist/core-server": [
"./dist/core-server/index.d.ts"
],
"dist/core-server/presets/common-preset": [
"./dist/core-server/presets/common-preset.d.ts"
],
"dist/core-server/presets/common-manager": [
"./dist/core-server/presets/common-manager.d.ts"
],
"dist/core-server/presets/common-override-preset": [
"./dist/core-server/presets/common-override-preset.d.ts"
],
"dist/core-events": [
"./dist/core-events/index.d.ts"
],
Expand Down Expand Up @@ -248,11 +276,14 @@
"util": "^0.12.4"
},
"devDependencies": {
"@aw-web-design/x-default-browser": "1.4.126",
"@babel/core": "^7.24.4",
"@babel/generator": "^7.24.4",
"@babel/parser": "^7.24.4",
"@babel/preset-react": "^7.24.1",
"@babel/traverse": "^7.24.1",
"@babel/types": "^7.24.0",
"@discoveryjs/json-ext": "^0.5.3",
"@emotion/cache": "^11.11.0",
"@emotion/is-prop-valid": "^1.2.2",
"@emotion/react": "^11.11.4",
Expand All @@ -266,11 +297,15 @@
"@radix-ui/react-slot": "^1.0.2",
"@storybook/core": "workspace:*",
"@storybook/csf": "^0.1.7",
"@storybook/docs-mdx": "3.1.0-next.0",
"@storybook/global": "^5.0.0",
"@storybook/icons": "^1.2.5",
"@storybook/test": "workspace:*",
"@tanstack/react-virtual": "^3.3.0",
"@testing-library/react": "^14.0.0",
"@types/compression": "^1.7.0",
"@types/detect-port": "^1.3.0",
"@types/diff": "^5.0.9",
"@types/doctrine": "^0.0.3",
"@types/ejs": "^3.1.1",
"@types/find-cache-dir": "^5.0.0",
Expand All @@ -288,22 +323,30 @@
"@types/react-transition-group": "^4",
"@types/semver": "^7.3.4",
"@types/util-deprecate": "^1.0.0",
"@types/ws": "^8",
"@vitest/utils": "^1.3.1",
"@yarnpkg/esbuild-plugin-pnp": "^3.0.0-rc.10",
"@yarnpkg/fslib": "2.10.3",
"@yarnpkg/libzip": "2.3.0",
"ansi-to-html": "^0.7.2",
"assert": "^2.1.0",
"babel-plugin-react-docgen": "4.2.1",
"better-opn": "^3.0.2",
"boxen": "^7.1.1",
"browser-dtector": "^3.4.0",
"camelcase": "^8.0.0",
"chai": "^4.4.1",
"chalk": "^5.3.0",
"cli-table3": "^0.6.1",
"compression": "^1.7.4",
"copy-to-clipboard": "^3.3.1",
"cross-spawn": "^7.0.3",
"css": "^3.0.0",
"deep-object-diff": "^1.1.0",
"dequal": "^2.0.2",
"detect-package-manager": "^3.0.2",
"detect-port": "^1.3.0",
"diff": "^5.2.0",
"doctrine": "^3.0.0",
"downshift": "^9.0.4",
"ejs": "^3.1.10",
Expand All @@ -319,6 +362,7 @@
"fs-extra": "^11.1.0",
"fuse.js": "^3.6.1",
"glob": "^10.0.0",
"globby": "^14.0.1",
"handlebars": "^4.7.7",
"js-yaml": "^4.1.0",
"lazy-universal-dotenv": "^4.0.0",
Expand All @@ -328,12 +372,14 @@
"mock-fs": "^5.2.0",
"nanoid": "^4.0.2",
"npmlog": "^7.0.0",
"open": "^8.4.0",
"picomatch": "^2.3.0",
"pkg-dir": "^8.0.0",
"polished": "^4.2.2",
"prettier": "^3.2.5",
"pretty-hrtime": "^1.0.3",
"process": "^0.11.10",
"prompts": "^2.4.0",
"qs": "^6.10.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand All @@ -360,7 +406,9 @@
"unique-string": "^3.0.0",
"use-resize-observer": "^9.1.0",
"util": "^0.12.4",
"util-deprecate": "^1.0.2"
"util-deprecate": "^1.0.2",
"watchpack": "^2.2.0",
"ws": "^8.2.3"
},
"publishConfig": {
"access": "public"
Expand Down
5 changes: 5 additions & 0 deletions code/core/scripts/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ export const getEntries = (cwd: string) => {
define('src/node-logger/index.ts', ['node'], true),
define('src/client-logger/index.ts', ['browser', 'node'], true),

define('src/core-server/index.ts', ['node'], true),
define('src/core-server/presets/common-preset.ts', ['node'], false),
define('src/core-server/presets/common-manager.ts', ['browser'], false),
define('src/core-server/presets/common-override-preset.ts', ['node'], false),

define('src/core-events/index.ts', ['browser', 'node'], true),
define('src/manager-errors.ts', ['browser'], true),
define('src/preview-errors.ts', ['browser', 'node'], true),
Expand Down
1 change: 1 addition & 0 deletions code/core/scripts/prep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { globalsModuleInfoMap } from '../src/manager/globals-module-info';

import pkg from '../package.json';
import { generateSourceFiles } from './helpers/sourcefiles';
import { assert } from 'node:console';

const flags = process.argv.slice(2);
const cwd = process.cwd();
Expand Down
2 changes: 1 addition & 1 deletion code/core/src/common/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default {
'@storybook/components': '8.2.0-alpha.6',
'@storybook/core-common': '8.2.0-alpha.6',
'@storybook/core-events': '8.2.0-alpha.6',
'@storybook/core-server': '8.2.0-alpha.6',
'@storybook/csf-tools': '8.2.0-alpha.6',
'@storybook/docs-tools': '8.2.0-alpha.6',
'@storybook/instrumenter': '8.2.0-alpha.6',
Expand Down Expand Up @@ -61,7 +62,6 @@ export default {
sb: '8.2.0-alpha.6',
storybook: '8.2.0-alpha.6',
'@storybook/codemod': '8.2.0-alpha.6',
'@storybook/core-server': '8.2.0-alpha.6',
'@storybook/core-webpack': '8.2.0-alpha.6',
'@storybook/csf-plugin': '8.2.0-alpha.6',
'@storybook/react-dom-shim': '8.2.0-alpha.6',
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export async function buildDevStandalone(
let presets = await loadAllPresets({
corePresets,
overridePresets: [
require.resolve('@storybook/core-server/dist/presets/common-override-preset'),
require.resolve('@storybook/core/dist/core-server/presets/common-override-preset'),
],
...options,
isCritical: true,
Expand Down Expand Up @@ -151,15 +151,15 @@ export async function buildDevStandalone(
// Load second pass: all presets are applied in order
presets = await loadAllPresets({
corePresets: [
require.resolve('@storybook/core-server/dist/presets/common-preset'),
require.resolve('@storybook/core/dist/core-server/presets/common-preset'),
...(managerBuilder.corePresets || []),
...(previewBuilder.corePresets || []),
...(resolvedRenderer ? [resolvedRenderer] : []),
...corePresets,
],
overridePresets: [
...(previewBuilder.overridePresets || []),
require.resolve('@storybook/core-server/dist/presets/common-override-preset'),
require.resolve('@storybook/core/dist/core-server/presets/common-override-preset'),
],
...options,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ export async function buildStaticStandalone(options: BuildStaticStandaloneOption
logger.info('=> Loading presets');
let presets = await loadAllPresets({
corePresets: [
require.resolve('@storybook/core-server/dist/presets/common-preset'),
require.resolve('@storybook/core/dist/core-server/presets/common-preset'),
...corePresets,
],
overridePresets: [
require.resolve('@storybook/core-server/dist/presets/common-override-preset'),
require.resolve('@storybook/core/dist/core-server/presets/common-override-preset'),
],
isCritical: true,
...options,
Expand All @@ -76,15 +76,15 @@ export async function buildStaticStandalone(options: BuildStaticStandaloneOption
: undefined;
presets = await loadAllPresets({
corePresets: [
require.resolve('@storybook/core-server/dist/presets/common-preset'),
require.resolve('@storybook/core/dist/core-server/presets/common-preset'),
...(managerBuilder.corePresets || []),
...(previewBuilder.corePresets || []),
...(resolvedRenderer ? [resolvedRenderer] : []),
...corePresets,
],
overridePresets: [
...(previewBuilder.overridePresets || []),
require.resolve('@storybook/core-server/dist/presets/common-override-preset'),
require.resolve('@storybook/core/dist/core-server/presets/common-override-preset'),
],
...options,
build,
Expand Down Expand Up @@ -121,8 +121,8 @@ export async function buildStaticStandalone(options: BuildStaticStandaloneOption
}

const coreServerPublicDir = join(
dirname(require.resolve('@storybook/core-server/package.json')),
'public'
dirname(require.resolve('@storybook/core/package.json')),
'assets/browser'
);
effects.push(copy(coreServerPublicDir, options.outputDir));

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ import { initCreateNewStoryChannel } from '../server-channel/create-new-story-ch
const interpolate = (string: string, data: Record<string, string> = {}) =>
Object.entries(data).reduce((acc, [k, v]) => acc.replace(new RegExp(`%${k}%`, 'g'), v), string);

const defaultFavicon = require.resolve('@storybook/core-server/public/favicon.svg');
const defaultFavicon = join(
dirname(require.resolve('@storybook/core/package.json')),
'/assets/browser/favicon.svg'
);

export const staticDirs: PresetPropertyFn<'staticDirs'> = async (values = []) => [
...defaultStaticDirs,
Expand Down Expand Up @@ -278,5 +281,5 @@ export const tags = async (existing: any) => {
};

export const managerEntries = async (existing: any, options: Options) => {
return [require.resolve('./common-manager'), ...(existing || [])];
return ['@storybook/core/dist/core-server/presets/common-manager', ...(existing || [])];
};
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { expect, vi, it } from 'vitest';

import { join } from 'path';
import { dirname, join } from 'node:path';
import * as fs from 'fs-extra';
import { logger } from '@storybook/core/dist/node-logger';
import * as m from './common-preset';

const defaultFavicon = require.resolve('@storybook/core-server/public/favicon.svg');
const defaultFavicon = join(
dirname(require.resolve('@storybook/core/package.json')),
'/assets/browser/favicon.svg'
);

const createPath = (...p: string[]) => join(process.cwd(), ...p);
const createOptions = (locations: string[]): Parameters<typeof m.favicon>[1] => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { sync as readUpSync } from 'read-pkg-up';
import { readPackageUpSync } from 'read-pkg-up';
import { buildStaticStandalone } from './build-static';
import { buildDevStandalone } from './build-dev';

async function build(options: any = {}, frameworkOptions: any = {}) {
const { mode = 'dev' } = options;
const packageJson = readUpSync({ cwd: __dirname })?.packageJson;
const packageJson = readPackageUpSync({ cwd: __dirname })?.packageJson;

const commonOptions = {
...options,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# src/ignored.js
!src/node_modules
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import fetch from 'node-fetch';
import chalk from 'chalk';
import { colors } from '@storybook/core/dist/node-logger';
import semver from 'semver';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { logger } from '@storybook/core/dist/node-logger';
import {
getIncompatibleStorybookPackages,
getIncompatiblePackagesSummary,
} from '../../../cli/src/doctor/getIncompatibleStorybookPackages';
} from '../../../../lib/cli/src/doctor/getIncompatibleStorybookPackages';

export const warnOnIncompatibleAddons = async (currentStorybookVersion: string) => {
const incompatiblePackagesList = await getIncompatibleStorybookPackages({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { telemetry } from '@storybook/core/dist/telemetry';
import { findConfigFile } from '@storybook/core/dist/common';
import type { CoreConfig, Options } from '@storybook/core/dist/types';
import { printConfig, readConfig } from '@storybook/core/dist/csf-tools';
import fetch from 'node-fetch';
import type { Channel } from '@storybook/core/dist/channels';
import type { WhatsNewCache, WhatsNewData } from '@storybook/core/dist/core-events';
import {
Expand Down
File renamed without changes.
47 changes: 47 additions & 0 deletions code/deprecated/core-server/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "@storybook/core-server",
"version": "8.2.0-alpha.6",
"description": "Storybook framework-agnostic API",
"keywords": [
"storybook"
],
"homepage": "https://github.com/storybookjs/storybook/tree/next/code/lib/core-server",
"bugs": {
"url": "https://github.com/storybookjs/storybook/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"directory": "code/lib/core-server"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/storybook"
},
"license": "MIT",
"sideEffects": false,
"exports": {
".": {
"types": "./shim.d.ts",
"import": "./shim.mjs",
"require": "./shim.js"
},
"./package.json": "./package.json"
},
"main": "./shim.js",
"module": "./shim.mjs",
"types": "./shim.d.ts",
"files": [
"README.md",
"*.js",
"*.mjs",
"*.cjs",
"*.d.ts"
],
"peerDependencies": {
"@storybook/core": "workspace:*"
},
"publishConfig": {
"access": "public"
}
}
2 changes: 2 additions & 0 deletions code/deprecated/core-server/shim.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from '@storybook/core/dist/core-server';
export type * from '@storybook/core/dist/core-server';
1 change: 1 addition & 0 deletions code/deprecated/core-server/shim.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@storybook/core/dist/core-server');
1 change: 1 addition & 0 deletions code/deprecated/core-server/shim.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@storybook/core/dist/core-server';
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/core-server": "workspace:*",
"@storybook/core-webpack": "workspace:*",
"@storybook/global": "^5.0.0",
"@types/node": "^18.0.0",
Expand Down
Loading

0 comments on commit b7f8950

Please sign in to comment.