Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

refactor(storybook): move to `apps` folder (#2901)

Alex Yang91d3b76be59f
diff --git a/.commitlintrc.json b/.commitlintrc.json
index 11287fcbdf..e368393d5f 100644
--- a/.commitlintrc.json
+++ b/.commitlintrc.json
@@ -9,6 +9,7 @@
"server",
"web",
"docs",
+ "storybook",
"component",
"workspace",
"env",
@@ -20,8 +21,7 @@
"native",
"templates",
"y-indexeddb",
- "debug",
- "theme"
+ "debug"
]
]
}
diff --git a/.eslintrc.js b/.eslintrc.js
index 8387eb09a6..2a7f180803 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -41,6 +41,7 @@ const allPackages = [
'apps/web',
'apps/server',
'apps/electron',
+ 'apps/storybook',
'plugins/copilot',
'plugins/bookmark-block',
];
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 9fb8f97131..2824188b18 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -78,7 +78,7 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: storybook
- path: ./packages/storybook/storybook-static
+ path: ./apps/storybook/storybook-static
if-no-files-found: error
build-web:
@@ -191,9 +191,9 @@ jobs:
uses: actions/download-artifact@v3
with:
name: storybook
- path: ./packages/storybook/storybook-static
+ path: ./apps/storybook/storybook-static
- name: Run storybook tests
- working-directory: ./packages/storybook
+ working-directory: ./apps/storybook
run: |
yarn exec concurrently -k -s first -n "SB,TEST" -c "magenta,blue" "yarn exec serve ./storybook-static -l 6006" "yarn exec wait-on tcp:6006 && yarn test"
@@ -232,7 +232,7 @@ jobs:
uses: actions/download-artifact@v3
with:
name: storybook
- path: ./packages/storybook/storybook-static
+ path: ./apps/storybook/storybook-static
- name: Wait for Octobase Ready
run: |
diff --git a/packages/storybook/.storybook/main.ts b/apps/storybook/.storybook/main.ts
similarity index 100%
rename from packages/storybook/.storybook/main.ts
rename to apps/storybook/.storybook/main.ts
diff --git a/packages/storybook/.storybook/preview-head.html b/apps/storybook/.storybook/preview-head.html
similarity index 100%
rename from packages/storybook/.storybook/preview-head.html
rename to apps/storybook/.storybook/preview-head.html
diff --git a/packages/storybook/.storybook/preview.tsx b/apps/storybook/.storybook/preview.tsx
similarity index 100%
rename from packages/storybook/.storybook/preview.tsx
rename to apps/storybook/.storybook/preview.tsx
diff --git a/packages/storybook/package.json b/apps/storybook/package.json
similarity index 100%
rename from packages/storybook/package.json
rename to apps/storybook/package.json
diff --git a/packages/storybook/src/stories/affine-banner.stories.tsx b/apps/storybook/src/stories/affine-banner.stories.tsx
similarity index 100%
rename from packages/storybook/src/stories/affine-banner.stories.tsx
rename to apps/storybook/src/stories/affine-banner.stories.tsx
diff --git a/packages/storybook/src/stories/affine-loading.stories.tsx b/apps/storybook/src/stories/affine-loading.stories.tsx
similarity index 100%
rename from packages/storybook/src/stories/affine-loading.stories.tsx
rename to apps/storybook/src/stories/affine-loading.stories.tsx
diff --git a/packages/storybook/src/stories/app-sidebar.stories.tsx b/apps/storybook/src/stories/app-sidebar.stories.tsx
similarity index 100%
rename from packages/storybook/src/stories/app-sidebar.stories.tsx
rename to apps/storybook/src/stories/app-sidebar.stories.tsx
diff --git a/packages/storybook/src/stories/block-suite-editor.stories.tsx b/apps/storybook/src/stories/block-suite-editor.stories.tsx
similarity index 100%
rename from packages/storybook/src/stories/block-suite-editor.stories.tsx
rename to apps/storybook/src/stories/block-suite-editor.stories.tsx
diff --git a/packages/storybook/src/stories/breadcrumbs.stories.tsx b/apps/storybook/src/stories/breadcrumbs.stories.tsx
similarity index 100%
rename from packages/storybook/src/stories/breadcrumbs.stories.tsx
rename to apps/storybook/src/stories/breadcrumbs.stories.tsx
diff --git a/packages/storybook/src/stories/button.stories.tsx b/apps/storybook/src/stories/button.stories.tsx
similarity index 100%
rename from packages/storybook/src/stories/button.stories.tsx
rename to apps/storybook/src/stories/button.stories.tsx
diff --git a/packages/storybook/src/stories/card.stories.tsx b/apps/storybook/src/stories/card.stories.tsx
similarity index 100%
rename from packages/storybook/src/stories/card.stories.tsx
rename to apps/storybook/src/stories/card.stories.tsx
diff --git a/packages/storybook/src/stories/change-log.stories.tsx b/apps/storybook/src/stories/change-log.stories.tsx
similarity index 100%
rename from packages/storybook/src/stories/change-log.stories.tsx
rename to apps/storybook/src/stories/change-log.stories.tsx
diff --git a/packages/storybook/src/stories/contact-modal.stories.tsx b/apps/storybook/src/stories/contact-modal.stories.tsx
similarity index 100%
rename from packages/storybook/src/stories/contact-modal.stories.tsx
rename to apps/storybook/src/stories/contact-modal.stories.tsx
diff --git a/packages/storybook/src/stories/datepicker.stories.tsx b/apps/storybook/src/stories/datepicker.stories.tsx
similarity index 100%
rename from packages/storybook/src/stories/datepicker.stories.tsx
rename to apps/storybook/src/stories/datepicker.stories.tsx
diff --git a/packages/storybook/src/stories/image-preview-modal.stories.tsx b/apps/storybook/src/stories/image-preview-modal.stories.tsx
similarity index 100%
rename from packages/storybook/src/stories/image-preview-modal.stories.tsx
rename to apps/storybook/src/stories/image-preview-modal.stories.tsx
diff --git a/packages/storybook/src/stories/introduction.stories.mdx b/apps/storybook/src/stories/introduction.stories.mdx
similarity index 100%
rename from packages/storybook/src/stories/introduction.stories.mdx
rename to apps/storybook/src/stories/introduction.stories.mdx
diff --git a/packages/storybook/src/stories/notification-center.stories.tsx b/apps/storybook/src/stories/notification-center.stories.tsx
similarity index 100%
rename from packages/storybook/src/stories/notification-center.stories.tsx
rename to apps/storybook/src/stories/notification-center.stories.tsx
diff --git a/packages/storybook/src/stories/onboarding-modal.stories.tsx b/apps/storybook/src/stories/onboarding-modal.stories.tsx
similarity index 100%
rename from packages/storybook/src/stories/onboarding-modal.stories.tsx
rename to apps/storybook/src/stories/onboarding-modal.stories.tsx
diff --git a/packages/storybook/src/stories/page-detail-skeleton.stories.tsx b/apps/storybook/src/stories/page-detail-skeleton.stories.tsx
similarity index 100%
rename from packages/storybook/src/stories/page-detail-skeleton.stories.tsx
rename to apps/storybook/src/stories/page-detail-skeleton.stories.tsx
diff --git a/packages/storybook/src/stories/page-list.stories.tsx b/apps/storybook/src/stories/page-list.stories.tsx
similarity index 100%
rename from packages/storybook/src/stories/page-list.stories.tsx
rename to apps/storybook/src/stories/page-list.stories.tsx
diff --git a/packages/storybook/src/stories/share-menu.stories.tsx b/apps/storybook/src/stories/share-menu.stories.tsx
similarity index 98%
rename from packages/storybook/src/stories/share-menu.stories.tsx
rename to apps/storybook/src/stories/share-menu.stories.tsx
index ced478bbab..6e222a8884 100644
--- a/packages/storybook/src/stories/share-menu.stories.tsx
+++ b/apps/storybook/src/stories/share-menu.stories.tsx
@@ -3,7 +3,7 @@ import {
PublicLinkDisableModal,
StyledDisableButton,
} from '@affine/component/share-menu';
-import { ShareMenu } from '@affine/component/share-menu/share-menu';
+import { ShareMenu } from '@affine/component/share-menu';
import type {
AffineLegacyCloudWorkspace,
LocalWorkspace,
diff --git a/packages/storybook/src/stories/switch.stories.tsx b/apps/storybook/src/stories/switch.stories.tsx
similarity index 100%
rename from packages/storybook/src/stories/switch.stories.tsx
rename to apps/storybook/src/stories/switch.stories.tsx
diff --git a/packages/storybook/src/stories/workspace-avatar.stories.tsx b/apps/storybook/src/stories/workspace-avatar.stories.tsx
similarity index 100%
rename from packages/storybook/src/stories/workspace-avatar.stories.tsx
rename to apps/storybook/src/stories/workspace-avatar.stories.tsx
diff --git a/packages/storybook/src/stories/workspace-list.stories.tsx b/apps/storybook/src/stories/workspace-list.stories.tsx
similarity index 100%
rename from packages/storybook/src/stories/workspace-list.stories.tsx
rename to apps/storybook/src/stories/workspace-list.stories.tsx
diff --git a/packages/storybook/tsconfig.json b/apps/storybook/tsconfig.json
similarity index 50%
rename from packages/storybook/tsconfig.json
rename to apps/storybook/tsconfig.json
index fa67cb8cca..4f4ebce10d 100644
--- a/packages/storybook/tsconfig.json
+++ b/apps/storybook/tsconfig.json
@@ -2,17 +2,22 @@
"extends": "../../tsconfig.json",
"include": ["./src"],
"compilerOptions": {
+ // Workaround for storybook build
+ "baseUrl": "../..",
"composite": true,
"noEmit": false,
"outDir": "lib",
- "paths": {
- "@affine/component": ["../component/src"],
- "@affine/component/*": ["../component/src/components/*"]
- }
+ "types": ["react/experimental"]
},
"references": [
{
- "path": "../component"
+ "path": "../../packages/component"
+ },
+ {
+ "path": "../../packages/env"
+ },
+ {
+ "path": "../../packages/workspace"
},
{
"path": "./tsconfig.node.json"
diff --git a/packages/storybook/tsconfig.node.json b/apps/storybook/tsconfig.node.json
similarity index 83%
rename from packages/storybook/tsconfig.node.json
rename to apps/storybook/tsconfig.node.json
index 69d90ecad8..080da0ce30 100644
--- a/packages/storybook/tsconfig.node.json
+++ b/apps/storybook/tsconfig.node.json
@@ -13,9 +13,9 @@
"include": [".storybook/**/*"],
"exclude": ["lib"],
"references": [
- { "path": "../i18n" },
+ { "path": "../../packages/i18n" },
{
- "path": "../env"
+ "path": "../../packages/env"
}
]
}
diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.json
index 447a319486..d33bf2be10 100644
--- a/apps/web/tsconfig.json
+++ b/apps/web/tsconfig.json
@@ -15,7 +15,8 @@
"jsx": "preserve",
"jsxImportSource": "@emotion/react",
"incremental": true,
- "experimentalDecorators": true
+ "experimentalDecorators": true,
+ "types": ["react/experimental"]
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "src/types/types.d.ts"],
"exclude": ["node_modules"],
diff --git a/nx.json b/nx.json
index ca3dad2165..a152d02631 100644
--- a/nx.json
+++ b/nx.json
@@ -32,7 +32,7 @@
"{projectRoot}/node_modules/.cache",
"{projectRoot}/target",
"{workspaceRoot}/apps/web/.next",
- "{workspaceRoot}/packages/storybook/storybook-static",
+ "{workspaceRoot}/apps/storybook/storybook-static",
"{workspaceRoot}/packages/i18n/src/i18n-generated.ts",
"{workspaceRoot}/packages/native/affine.*.node",
"{workspaceRoot}/affine.db",
diff --git a/package.json b/package.json
index 3183da27f5..c5027b5b2d 100644
--- a/package.json
+++ b/package.json
@@ -22,7 +22,7 @@
"build:storybook": "nx build @affine/storybook",
"build:plugins": "./apps/electron/scripts/plugins/build-plugins.mjs",
"start:web": "yarn workspace @affine/web start",
- "start:storybook": "yarn exec serve packages/storybook/storybook-static -l 6006",
+ "start:storybook": "yarn exec serve apps/storybook/storybook-static -l 6006",
"serve:test-static": "yarn exec serve tests/fixtures --cors -p 8081",
"lint": "eslint . --ext .js,mjs,.ts,.tsx --cache",
"lint:fix": "yarn lint --fix",
diff --git a/tsconfig.json b/tsconfig.json
index c472f93a2f..45d8ff2ecb 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -96,6 +96,9 @@
{
"path": "./apps/server"
},
+ {
+ "path": "./apps/storybook"
+ },
// Top level packages
{
"path": "./packages/infra"
diff --git a/yarn.lock b/yarn.lock
index de065ca34a..476c7cce41 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -426,9 +426,9 @@ __metadata:
languageName: unknown
linkType: soft
-"@affine/storybook@workspace:packages/storybook":
+"@affine/storybook@workspace:apps/storybook":
version: 0.0.0-use.local
- resolution: "@affine/storybook@workspace:packages/storybook"
+ resolution: "@affine/storybook@workspace:apps/storybook"
dependencies:
"@affine/component": "workspace:*"
"@affine/i18n": "workspace:*"