From b1c63c20dea8c572bf900cfc85c98e2ccb9ede9a Mon Sep 17 00:00:00 2001 From: Gearonix Date: Fri, 1 Sep 2023 23:31:04 +0300 Subject: [PATCH] chore(storybook): moved config --- libs/config/src/index.ts | 1 + libs/config/src/jest/create-jest-config.ts | 8 ++++---- libs/config/src/storybook/create-storybook-config.ts | 2 +- libs/web/ui/{.storybook => .config/storybook}/main.ts | 4 ++-- libs/web/ui/{.storybook => .config/storybook}/preview.ts | 2 +- .../storybook}/test-runner.config.ts | 0 libs/web/ui/project.json | 4 ++-- 7 files changed, 11 insertions(+), 10 deletions(-) rename libs/web/ui/{.storybook => .config/storybook}/main.ts (79%) rename libs/web/ui/{.storybook => .config/storybook}/preview.ts (80%) rename libs/web/ui/{.storybook => .config/storybook}/test-runner.config.ts (100%) diff --git a/libs/config/src/index.ts b/libs/config/src/index.ts index c3c5d527..4d959828 100644 --- a/libs/config/src/index.ts +++ b/libs/config/src/index.ts @@ -1,3 +1,4 @@ export * from './consts/client' export * from './consts/server' +export { createPreviewDefaults, createStorybookConfig } from './storybook' diff --git a/libs/config/src/jest/create-jest-config.ts b/libs/config/src/jest/create-jest-config.ts index 9a8b2ca3..6c5d6550 100644 --- a/libs/config/src/jest/create-jest-config.ts +++ b/libs/config/src/jest/create-jest-config.ts @@ -6,17 +6,17 @@ interface CreateJestConfigPayload { displayName: string } -export const createJestConfig = (payload: CreateJestConfigPayload) => { - const rootPath = resolveRootPath(payload.layer) +export const createJestConfig = (options: CreateJestConfigPayload) => { + const rootPath = resolveRootPath(options.layer) return { - displayName: payload.displayName, + displayName: options.displayName, preset: `${rootPath}/jest.preset.js`, testEnvironment: 'node', transform: { '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }] }, moduleFileExtensions: ['ts', 'tsx'], - coverageDirectory: `${rootPath}/coverage/apps/server` + coverageDirectory: `${rootPath}/coverage/apps/${options.displayName}` } } diff --git a/libs/config/src/storybook/create-storybook-config.ts b/libs/config/src/storybook/create-storybook-config.ts index 63e8dd14..4110706b 100644 --- a/libs/config/src/storybook/create-storybook-config.ts +++ b/libs/config/src/storybook/create-storybook-config.ts @@ -11,7 +11,7 @@ export const createStorybookConfig: CreateStorybookConfig = ({ viteConfigPath, viteFinal }) => ({ - stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'], + stories: ['../../src/**/*.stories.@(js|jsx|ts|tsx)'], addons: [ '@storybook/addon-essentials', '@storybook/addon-interactions', diff --git a/libs/web/ui/.storybook/main.ts b/libs/web/ui/.config/storybook/main.ts similarity index 79% rename from libs/web/ui/.storybook/main.ts rename to libs/web/ui/.config/storybook/main.ts index f40f1f26..12e3232f 100644 --- a/libs/web/ui/.storybook/main.ts +++ b/libs/web/ui/.config/storybook/main.ts @@ -1,10 +1,10 @@ -import { createStorybookConfig } from 'cg-config/src' +import { createStorybookConfig } from 'cg-config/src/storybook' import type { StorybookConfig } from '@storybook/react-vite' import { mergeConfig } from 'vite' import viteTsConfigPaths from 'vite-tsconfig-paths' const config: StorybookConfig = createStorybookConfig({ - viteConfigPath: 'libs/web/ui/vite.config.ts', + viteConfigPath: 'libs/web/ui/.config/vite.ts', viteFinal: (config: StorybookConfig): StorybookConfig => { return mergeConfig(config, { define: { diff --git a/libs/web/ui/.storybook/preview.ts b/libs/web/ui/.config/storybook/preview.ts similarity index 80% rename from libs/web/ui/.storybook/preview.ts rename to libs/web/ui/.config/storybook/preview.ts index 4b99fc7e..92104b0f 100644 --- a/libs/web/ui/.storybook/preview.ts +++ b/libs/web/ui/.config/storybook/preview.ts @@ -1,6 +1,6 @@ import { StylesDecorator, ThemeDecorator } from '@code-gear/web/shared' import { Preview } from '@storybook/react' -import { createPreviewDefaults } from '$/config' +import { createPreviewDefaults } from '@code-gear/config' const preview: Preview = createPreviewDefaults({ decorators: [StylesDecorator, ThemeDecorator] diff --git a/libs/web/ui/.storybook/test-runner.config.ts b/libs/web/ui/.config/storybook/test-runner.config.ts similarity index 100% rename from libs/web/ui/.storybook/test-runner.config.ts rename to libs/web/ui/.config/storybook/test-runner.config.ts diff --git a/libs/web/ui/project.json b/libs/web/ui/project.json index bad818cb..613d7771 100644 --- a/libs/web/ui/project.json +++ b/libs/web/ui/project.json @@ -15,7 +15,7 @@ "executor": "@nx/storybook:storybook", "options": { "port": 4400, - "configDir": "libs/web/ui/.storybook" + "configDir": "libs/web/ui/.config/storybook" }, "configurations": { "ci": { @@ -30,7 +30,7 @@ ], "options": { "outputDir": "dist/storybook/ui", - "configDir": "libs/web/ui/.storybook" + "configDir": "libs/web/ui/.config/storybook" }, "configurations": { "ci": {