refactor(infra): directory structure (#4615)

This commit is contained in:
Joooye_34 2023-10-18 23:30:08 +08:00 committed by GitHub
parent 814d552be8
commit bed9310519
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1150 changed files with 539 additions and 584 deletions

View File

@ -7,10 +7,10 @@ affine-out
_next _next
lib lib
.eslintrc.js .eslintrc.js
packages/i18n/src/i18n-generated.ts
e2e-dist-* e2e-dist-*
static static
web-static web-static
public public
packages/sdk/src/*.d.ts packages/common/sdk/src/*.d.ts
packages/sdk/src/*.js packages/common/sdk/src/*.js
packages/frontend/i18n/src/i18n-generated.ts

View File

@ -56,26 +56,25 @@ const createPattern = packageName => [
]; ];
const allPackages = [ const allPackages = [
'packages/cli', 'packages/backend/server',
'packages/component', 'packages/frontend/component',
'packages/debug', 'packages/frontend/web',
'packages/env', 'packages/frontend/electron',
'packages/graphql', 'packages/frontend/graphql',
'packages/hooks', 'packages/frontend/hooks',
'packages/i18n', 'packages/frontend/i18n',
'packages/native', 'packages/frontend/native',
'packages/infra', 'packages/frontend/templates',
'packages/sdk', 'packages/frontend/workspace',
'packages/templates', 'packages/common/debug',
'packages/theme', 'packages/common/env',
'packages/workspace', 'packages/common/infra',
'packages/y-indexeddb', 'packages/common/sdk',
'apps/web', 'packages/common/theme',
'apps/server', 'packages/common/y-indexeddb',
'apps/electron', 'packages/plugins/copilot',
'apps/storybook', 'tools/cli',
'plugins/copilot', 'tests/storybook',
'plugins/bookmark-block',
]; ];
/** /**
@ -88,7 +87,7 @@ const config = {
version: 'detect', version: 'detect',
}, },
next: { next: {
rootDir: 'apps/web', rootDir: 'packages/frontend/core',
}, },
}, },
extends: [ extends: [
@ -223,7 +222,7 @@ const config = {
}, },
overrides: [ overrides: [
{ {
files: 'apps/server/**/*.ts', files: 'packages/backend/server/**/*.ts',
rules: { rules: {
'@typescript-eslint/consistent-type-imports': 0, '@typescript-eslint/consistent-type-imports': 0,
}, },

View File

@ -1,6 +1,6 @@
FROM openresty/openresty:1.21.4.1-0-buster FROM openresty/openresty:1.21.4.1-0-buster
WORKDIR /app WORKDIR /app
COPY ./apps/core/dist ./dist COPY ./packages/frontend/core/dist ./dist
COPY ./.github/deployment/front/nginx.conf /usr/local/openresty/nginx/conf/nginx.conf COPY ./.github/deployment/front/nginx.conf /usr/local/openresty/nginx/conf/nginx.conf
COPY ./.github/deployment/front/affine.nginx.conf /etc/nginx/conf.d/affine.nginx.conf COPY ./.github/deployment/front/affine.nginx.conf /etc/nginx/conf.d/affine.nginx.conf

View File

@ -1,6 +1,6 @@
FROM node:18-bookworm-slim FROM node:18-bookworm-slim
COPY ./apps/server /app COPY ./packages/backend/server /app
WORKDIR /app WORKDIR /app
RUN apt-get update && \ RUN apt-get update && \

43
.github/labeler.yml vendored
View File

@ -1,7 +1,7 @@
docs: docs:
- 'docs/**/*' - 'docs/**/*'
- '**/README.md' - '**/README.md'
- 'packages/templates/**/*' - 'packages/frontend/templates/**/*'
test: test:
- 'tests/**/*' - 'tests/**/*'
@ -10,40 +10,37 @@ test:
mod:dev: mod:dev:
- 'scripts/**/*' - 'scripts/**/*'
- 'packages/cli/**/*' - 'tools/cli/**/*'
- 'packages/debug/**/*' - 'packages/common/debug/**/*'
mod:plugin: mod:plugin:
- 'plugins/**/*' - 'packages/plugins/**/*'
plugin:bookmark-block:
- 'plugins/bookmark-block/**/*'
plugin:copilot: plugin:copilot:
- 'plugins/copilot/**/*' - 'packages/plugins/copilot/**/*'
mod:infra: mod:infra:
- 'packages/infra/**/*' - 'packages/common/infra/**/*'
mod:sdk: mod:sdk:
- 'packages/sdk/**/*' - 'packages/common/sdk/**/*'
mod:plugin-cli: mod:plugin-cli:
- 'packages/plugin-cli/**/*' - 'tools/plugin-cli/**/*'
mod:workspace: 'packages/workspace/**/*' mod:workspace: 'packages/frontend/workspace/**/*'
mod:i18n: 'packages/i18n/**/*' mod:i18n: 'packages/frontend/i18n/**/*'
mod:env: 'packages/env/**/*' mod:env: 'packages/common/env/**/*'
mod:hooks: 'packages/hooks/**/*' mod:hooks: 'packages/frontend/hooks/**/*'
mod:component: 'packages/component/**/*' mod:component: 'packages/frontend/component/**/*'
mod:storage: 'packages/storage/**/*' mod:storage: 'packages/backend/storage/**/*'
mod:native: 'packages/native/**/*' mod:native: 'packages/frontend/native/**/*'
mod:store: mod:store:
- '**/atoms/**/*' - '**/atoms/**/*'
@ -56,12 +53,10 @@ rust:
- '**/rust-toolchain.toml' - '**/rust-toolchain.toml'
- '**/rustfmt.toml' - '**/rustfmt.toml'
package:y-indexeddb: 'packages/y-indexeddb/**/*' package:y-indexeddb: 'packages/common/y-indexeddb/**/*'
app:core: 'apps/core/**/*' app:core: 'packages/frontend/core/**/*'
app:electron: 'apps/electron/**/*' app:electron: 'packages/frontend/electron/**/*'
app:server: 'apps/server/**/*' app:server: 'packages/backend/server/**/*'
app:docs: 'apps/docs/**/*'

View File

@ -52,7 +52,7 @@ jobs:
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: core name: core
path: ./apps/core/dist path: ./packages/frontend/core/dist
if-no-files-found: error if-no-files-found: error
build-native: build-native:
@ -72,7 +72,7 @@ jobs:
nx_token: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} nx_token: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
- name: Run tests - name: Run tests
run: yarn test run: yarn test
working-directory: ./packages/native working-directory: ./packages/frontend/native
desktop-test: desktop-test:
name: Desktop Test name: Desktop Test
@ -137,7 +137,7 @@ jobs:
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
name: core name: core
path: apps/electron/resources/web-static path: packages/frontend/electron/resources/web-static
- name: Build Desktop Layers - name: Build Desktop Layers
run: yarn workspace @affine/electron build run: yarn workspace @affine/electron build

View File

@ -60,7 +60,7 @@ jobs:
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: storage.node name: storage.node
path: ./packages/storage/storage.node path: ./packages/backend/storage/storage.node
if-no-files-found: error if-no-files-found: error
server-test: server-test:
@ -117,7 +117,7 @@ jobs:
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
name: storage.node name: storage.node
path: ./apps/server path: ./packages/backend/server
- name: Run server tests - name: Run server tests
run: yarn workspace @affine/server test:coverage run: yarn workspace @affine/server test:coverage
@ -129,7 +129,7 @@ jobs:
uses: codecov/codecov-action@v3 uses: codecov/codecov-action@v3
with: with:
token: ${{ secrets.CODECOV_TOKEN }} token: ${{ secrets.CODECOV_TOKEN }}
files: ./apps/server/.coverage/lcov.info files: ./packages/backend/server/.coverage/lcov.info
flags: server-test flags: server-test
name: affine name: affine
fail_ci_if_error: false fail_ci_if_error: false
@ -188,7 +188,7 @@ jobs:
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
name: storage.node name: storage.node
path: ./apps/server path: ./packages/backend/server
- name: Run playwright tests - name: Run playwright tests
run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn workspace @affine-test/affine-cloud e2e --forbid-only run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn workspace @affine-test/affine-cloud e2e --forbid-only
@ -278,7 +278,7 @@ jobs:
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
name: storage.node name: storage.node
path: ./apps/server path: ./packages/backend/server
- name: Build Plugins - name: Build Plugins
run: yarn run build:plugins run: yarn run build:plugins

View File

@ -35,7 +35,7 @@ jobs:
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: server-dist name: server-dist
path: ./apps/server/dist path: ./packages/backend/server/dist
if-no-files-found: error if-no-files-found: error
build-core: build-core:
name: Build @affine/core name: Build @affine/core
@ -62,7 +62,7 @@ jobs:
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: core name: core
path: ./apps/core/dist path: ./packages/frontend/core/dist
if-no-files-found: error if-no-files-found: error
build-storage: build-storage:
@ -84,7 +84,7 @@ jobs:
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: storage.node name: storage.node
path: ./packages/storage/storage.node path: ./packages/backend/storage/storage.node
if-no-files-found: error if-no-files-found: error
build-docker: build-docker:
@ -101,17 +101,17 @@ jobs:
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
name: core name: core
path: ./apps/core/dist path: ./packages/frontend/core/dist
- name: Download server dist - name: Download server dist
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
name: server-dist name: server-dist
path: ./apps/server/dist path: ./packages/backend/server/dist
- name: Download storage.node - name: Download storage.node
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
name: storage.node name: storage.node
path: ./apps/server path: ./packages/backend/server
- name: Setup env - name: Setup env
run: | run: |
echo "GIT_SHORT_HASH=$(git rev-parse --short HEAD)" >> "$GITHUB_ENV" echo "GIT_SHORT_HASH=$(git rev-parse --short HEAD)" >> "$GITHUB_ENV"

View File

@ -4,13 +4,13 @@ on:
push: push:
branches: ['master'] branches: ['master']
paths: paths:
- 'packages/i18n/**' - 'packages/frontend/i18n/**'
- '.github/workflows/languages-sync.yml' - '.github/workflows/languages-sync.yml'
- '!.github/actions/setup-node/action.yml' - '!.github/actions/setup-node/action.yml'
pull_request_target: pull_request_target:
branches: ['master'] branches: ['master']
paths: paths:
- 'packages/i18n/**' - 'packages/frontend/i18n/**'
- '.github/workflows/languages-sync.yml' - '.github/workflows/languages-sync.yml'
- '!.github/actions/setup-node/action.yml' - '!.github/actions/setup-node/action.yml'
workflow_dispatch: workflow_dispatch:

View File

@ -67,7 +67,7 @@ jobs:
- name: Replace Version - name: Replace Version
run: ./scripts/set-version.sh ${{ needs.set-build-version.outputs.version }} run: ./scripts/set-version.sh ${{ needs.set-build-version.outputs.version }}
- name: generate-assets - name: generate-assets
working-directory: apps/electron working-directory: packages/frontend/electron
run: yarn generate-assets run: yarn generate-assets
env: env:
SENTRY_ORG: ${{ secrets.SENTRY_ORG }} SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
@ -80,7 +80,7 @@ jobs:
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: core name: core
path: apps/electron/resources/web-static path: packages/frontend/electron/resources/web-static
make-distribution: make-distribution:
environment: production environment: production
@ -133,7 +133,7 @@ jobs:
- uses: actions/download-artifact@v3 - uses: actions/download-artifact@v3
with: with:
name: core name: core
path: apps/electron/resources/web-static path: packages/frontend/electron/resources/web-static
- name: Build Plugins - name: Build Plugins
run: yarn run build:plugins run: yarn run build:plugins
@ -155,23 +155,23 @@ jobs:
if: ${{ matrix.spec.platform == 'darwin' }} if: ${{ matrix.spec.platform == 'darwin' }}
run: | run: |
mkdir -p builds mkdir -p builds
mv apps/electron/out/*/make/*.dmg ./builds/affine-${{ env.BUILD_TYPE }}-macos-${{ matrix.spec.arch }}.dmg mv packages/frontend/electron/out/*/make/*.dmg ./builds/affine-${{ env.BUILD_TYPE }}-macos-${{ matrix.spec.arch }}.dmg
mv apps/electron/out/*/make/zip/darwin/${{ matrix.spec.arch }}/*.zip ./builds/affine-${{ env.BUILD_TYPE }}-macos-${{ matrix.spec.arch }}.zip mv packages/frontend/electron/out/*/make/zip/darwin/${{ matrix.spec.arch }}/*.zip ./builds/affine-${{ env.BUILD_TYPE }}-macos-${{ matrix.spec.arch }}.zip
- name: Save artifacts (windows) - name: Save artifacts (windows)
if: ${{ matrix.spec.platform == 'win32' }} if: ${{ matrix.spec.platform == 'win32' }}
run: | run: |
mkdir -p builds mkdir -p builds
mv apps/electron/out/*/make/zip/win32/x64/AFFiNE*-win32-x64-*.zip ./builds/affine-${{ env.BUILD_TYPE }}-windows-x64.zip mv packages/frontend/electron/out/*/make/zip/win32/x64/AFFiNE*-win32-x64-*.zip ./builds/affine-${{ env.BUILD_TYPE }}-windows-x64.zip
mv apps/electron/out/*/make/squirrel.windows/x64/*.exe ./builds/affine-${{ env.BUILD_TYPE }}-windows-x64.exe mv packages/frontend/electron/out/*/make/squirrel.windows/x64/*.exe ./builds/affine-${{ env.BUILD_TYPE }}-windows-x64.exe
mv apps/electron/out/*/make/squirrel.windows/x64/*.msi ./builds/affine-${{ env.BUILD_TYPE }}-windows-x64.msi mv packages/frontend/electron/out/*/make/squirrel.windows/x64/*.msi ./builds/affine-${{ env.BUILD_TYPE }}-windows-x64.msi
mv apps/electron/out/*/make/squirrel.windows/x64/*.nupkg ./builds/affine-${{ env.BUILD_TYPE }}-windows-x64.nupkg mv packages/frontend/electron/out/*/make/squirrel.windows/x64/*.nupkg ./builds/affine-${{ env.BUILD_TYPE }}-windows-x64.nupkg
- name: Save artifacts (linux) - name: Save artifacts (linux)
if: ${{ matrix.spec.platform == 'linux' }} if: ${{ matrix.spec.platform == 'linux' }}
run: | run: |
mkdir -p builds mkdir -p builds
mv apps/electron/out/*/make/zip/linux/x64/*.zip ./builds/affine-${{ env.BUILD_TYPE }}-linux-x64.zip mv packages/frontend/electron/out/*/make/zip/linux/x64/*.zip ./builds/affine-${{ env.BUILD_TYPE }}-linux-x64.zip
mv apps/electron/out/*/make/AppImage/x64/*.AppImage ./builds/affine-${{ env.BUILD_TYPE }}-linux-x64.AppImage mv packages/frontend/electron/out/*/make/AppImage/x64/*.AppImage ./builds/affine-${{ env.BUILD_TYPE }}-linux-x64.AppImage
- name: Upload Artifact - name: Upload Artifact
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
@ -213,7 +213,7 @@ jobs:
node-version: 18 node-version: 18
- name: Generate Release yml - name: Generate Release yml
run: | run: |
node ./apps/electron/scripts/generate-yml.js node ./packages/frontend/electron/scripts/generate-yml.js
env: env:
RELEASE_VERSION: ${{ needs.set-build-version.outputs.version }} RELEASE_VERSION: ${{ needs.set-build-version.outputs.version }}
- name: Create Release Draft - name: Create Release Draft

View File

@ -14,9 +14,8 @@ on:
paths-ignore: paths-ignore:
- README.md - README.md
- .github/** - .github/**
- apps/server - packages/backend/server
- apps/docs - packages/frontend/electron
- apps/electron
- '!.github/workflows/publish-storybook.yml' - '!.github/workflows/publish-storybook.yml'
jobs: jobs:
@ -38,7 +37,7 @@ jobs:
run: yarn run build:plugins run: yarn run build:plugins
- uses: chromaui/action-next@v1 - uses: chromaui/action-next@v1
with: with:
workingDir: apps/storybook workingDir: tests/storybook
buildScriptName: build buildScriptName: build
exitOnceUploaded: true exitOnceUploaded: true
onlyChanged: false onlyChanged: false

View File

@ -54,12 +54,12 @@ jobs:
if: ${{ github.ref_type == 'tag' }} if: ${{ github.ref_type == 'tag' }}
run: | run: |
TAG_VERSION=${GITHUB_REF#refs/tags/v} TAG_VERSION=${GITHUB_REF#refs/tags/v}
PACKAGE_VERSION=$(node -p "require('./apps/electron/package.json').version") PACKAGE_VERSION=$(node -p "require('./packages/frontend/electron/package.json').version")
if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
echo "Tag version ($TAG_VERSION) does not match package.json version ($PACKAGE_VERSION)" echo "Tag version ($TAG_VERSION) does not match package.json version ($PACKAGE_VERSION)"
exit 1 exit 1
fi fi
echo "RELEASE_VERSION=$(node -p "require('./apps/electron/package.json').version")" >> $GITHUB_OUTPUT echo "RELEASE_VERSION=$(node -p "require('./packages/frontend/electron/package.json').version")" >> $GITHUB_OUTPUT
- name: generate-assets - name: generate-assets
run: yarn workspace @affine/electron generate-assets run: yarn workspace @affine/electron generate-assets
env: env:
@ -73,7 +73,7 @@ jobs:
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: core name: core
path: apps/electron/resources/web-static path: packages/frontend/electron/resources/web-static
make-distribution: make-distribution:
environment: production environment: production
@ -123,7 +123,7 @@ jobs:
- uses: actions/download-artifact@v3 - uses: actions/download-artifact@v3
with: with:
name: core name: core
path: apps/electron/resources/web-static path: packages/frontend/electron/resources/web-static
- name: Build Desktop Layers - name: Build Desktop Layers
run: yarn workspace @affine/electron build run: yarn workspace @affine/electron build
@ -146,14 +146,14 @@ jobs:
if: ${{ matrix.spec.platform == 'darwin' }} if: ${{ matrix.spec.platform == 'darwin' }}
run: | run: |
mkdir -p builds mkdir -p builds
mv apps/electron/out/*/make/*.dmg ./builds/affine-${{ env.BUILD_TYPE }}-macos-${{ matrix.spec.arch }}.dmg mv packages/frontend/electron/out/*/make/*.dmg ./builds/affine-${{ env.BUILD_TYPE }}-macos-${{ matrix.spec.arch }}.dmg
mv apps/electron/out/*/make/zip/darwin/${{ matrix.spec.arch }}/*.zip ./builds/affine-${{ env.BUILD_TYPE }}-macos-${{ matrix.spec.arch }}.zip mv packages/frontend/electron/out/*/make/zip/darwin/${{ matrix.spec.arch }}/*.zip ./builds/affine-${{ env.BUILD_TYPE }}-macos-${{ matrix.spec.arch }}.zip
- name: Save artifacts (linux) - name: Save artifacts (linux)
if: ${{ matrix.spec.platform == 'linux' }} if: ${{ matrix.spec.platform == 'linux' }}
run: | run: |
mkdir -p builds mkdir -p builds
mv apps/electron/out/*/make/zip/linux/x64/*.zip ./builds/affine-${{ env.BUILD_TYPE }}-linux-x64.zip mv packages/frontend/electron/out/*/make/zip/linux/x64/*.zip ./builds/affine-${{ env.BUILD_TYPE }}-linux-x64.zip
mv apps/electron/out/*/make/AppImage/x64/*.AppImage ./builds/affine-${{ env.BUILD_TYPE }}-linux-x64.AppImage mv packages/frontend/electron/out/*/make/AppImage/x64/*.AppImage ./builds/affine-${{ env.BUILD_TYPE }}-linux-x64.AppImage
- name: Upload Artifact - name: Upload Artifact
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
@ -200,7 +200,7 @@ jobs:
- uses: actions/download-artifact@v3 - uses: actions/download-artifact@v3
with: with:
name: core name: core
path: apps/electron/resources/web-static path: packages/frontend/electron/resources/web-static
- name: Build Plugins - name: Build Plugins
run: yarn run build:plugins run: yarn run build:plugins
@ -218,12 +218,12 @@ jobs:
- name: get all files to be signed - name: get all files to be signed
id: get_files_to_be_signed id: get_files_to_be_signed
run: | run: |
Set-Variable -Name FILES_TO_BE_SIGNED -Value ((Get-ChildItem -Path apps/electron/out -Recurse -File | Where-Object { $_.Extension -in @(".exe", ".node", ".dll", ".msi") } | ForEach-Object { '"' + $_.FullName.Replace((Get-Location).Path + '\apps\electron\out\', '') + '"' }) -join ' ') Set-Variable -Name FILES_TO_BE_SIGNED -Value ((Get-ChildItem -Path packages/frontend/electron/out -Recurse -File | Where-Object { $_.Extension -in @(".exe", ".node", ".dll", ".msi") } | ForEach-Object { '"' + $_.FullName.Replace((Get-Location).Path + '\apps\electron\out\', '') + '"' }) -join ' ')
"FILES_TO_BE_SIGNED=$FILES_TO_BE_SIGNED" >> $env:GITHUB_OUTPUT "FILES_TO_BE_SIGNED=$FILES_TO_BE_SIGNED" >> $env:GITHUB_OUTPUT
echo $FILES_TO_BE_SIGNED echo $FILES_TO_BE_SIGNED
- name: Zip artifacts for faster upload - name: Zip artifacts for faster upload
run: Compress-Archive -CompressionLevel Fastest -Path apps/electron/out/* -DestinationPath archive.zip run: Compress-Archive -CompressionLevel Fastest -Path packages/frontend/electron/out/* -DestinationPath archive.zip
- name: Save packaged artifacts for signing - name: Save packaged artifacts for signing
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
@ -266,18 +266,18 @@ jobs:
name: signed-packaged-${{ matrix.spec.platform }}-${{ matrix.spec.arch }} name: signed-packaged-${{ matrix.spec.platform }}-${{ matrix.spec.arch }}
path: . path: .
- name: unzip file - name: unzip file
run: Expand-Archive -Path signed.zip -DestinationPath apps/electron/out run: Expand-Archive -Path signed.zip -DestinationPath packages/frontend/electron/out
- name: Make squirrel.windows installer - name: Make squirrel.windows installer
run: yarn workspace @affine/electron make-squirrel --platform=${{ matrix.spec.platform }} --arch=${{ matrix.spec.arch }} run: yarn workspace @affine/electron make-squirrel --platform=${{ matrix.spec.platform }} --arch=${{ matrix.spec.arch }}
- name: Zip artifacts for faster upload - name: Zip artifacts for faster upload
run: Compress-Archive -CompressionLevel Fastest -Path apps/electron/out/${{ env.BUILD_TYPE }}/make/* -DestinationPath archive.zip run: Compress-Archive -CompressionLevel Fastest -Path packages/frontend/electron/out/${{ env.BUILD_TYPE }}/make/* -DestinationPath archive.zip
- name: get all files to be signed - name: get all files to be signed
id: get_files_to_be_signed id: get_files_to_be_signed
run: | run: |
Set-Variable -Name FILES_TO_BE_SIGNED -Value ((Get-ChildItem -Path apps/electron/out/${{ env.BUILD_TYPE }}/make -Recurse -File | Where-Object { $_.Extension -in @(".exe", ".node", ".dll", ".msi") } | ForEach-Object { '"' + $_.FullName.Replace((Get-Location).Path + '\apps\electron\out\${{ env.BUILD_TYPE }}\make\', '') + '"' }) -join ' ') Set-Variable -Name FILES_TO_BE_SIGNED -Value ((Get-ChildItem -Path packages/frontend/electron/out/${{ env.BUILD_TYPE }}/make -Recurse -File | Where-Object { $_.Extension -in @(".exe", ".node", ".dll", ".msi") } | ForEach-Object { '"' + $_.FullName.Replace((Get-Location).Path + '\apps\electron\out\${{ env.BUILD_TYPE }}\make\', '') + '"' }) -join ' ')
"FILES_TO_BE_SIGNED=$FILES_TO_BE_SIGNED" >> $env:GITHUB_OUTPUT "FILES_TO_BE_SIGNED=$FILES_TO_BE_SIGNED" >> $env:GITHUB_OUTPUT
echo $FILES_TO_BE_SIGNED echo $FILES_TO_BE_SIGNED
@ -314,14 +314,14 @@ jobs:
name: signed-installer-${{ matrix.spec.platform }}-${{ matrix.spec.arch }} name: signed-installer-${{ matrix.spec.platform }}-${{ matrix.spec.arch }}
path: . path: .
- name: unzip file - name: unzip file
run: Expand-Archive -Path signed.zip -DestinationPath apps/electron/out/${{ env.BUILD_TYPE }}/make run: Expand-Archive -Path signed.zip -DestinationPath packages/frontend/electron/out/${{ env.BUILD_TYPE }}/make
- name: Save artifacts - name: Save artifacts
run: | run: |
mkdir -p builds mkdir -p builds
mv apps/electron/out/*/make/zip/win32/x64/AFFiNE*-win32-x64-*.zip ./builds/affine-${{ env.BUILD_TYPE }}-windows-x64.zip mv packages/frontend/electron/out/*/make/zip/win32/x64/AFFiNE*-win32-x64-*.zip ./builds/affine-${{ env.BUILD_TYPE }}-windows-x64.zip
mv apps/electron/out/*/make/squirrel.windows/x64/*.exe ./builds/affine-${{ env.BUILD_TYPE }}-windows-x64.exe mv packages/frontend/electron/out/*/make/squirrel.windows/x64/*.exe ./builds/affine-${{ env.BUILD_TYPE }}-windows-x64.exe
mv apps/electron/out/*/make/squirrel.windows/x64/*.msi ./builds/affine-${{ env.BUILD_TYPE }}-windows-x64.msi mv packages/frontend/electron/out/*/make/squirrel.windows/x64/*.msi ./builds/affine-${{ env.BUILD_TYPE }}-windows-x64.msi
- name: Upload Artifact - name: Upload Artifact
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
@ -366,7 +366,7 @@ jobs:
node-version: 18 node-version: 18
- name: Generate Release yml - name: Generate Release yml
run: | run: |
node ./apps/electron/scripts/generate-yml.js node ./packages/frontend/electron/scripts/generate-yml.js
env: env:
RELEASE_VERSION: ${{ github.event.inputs.version || needs.before-make.outputs.RELEASE_VERSION }} RELEASE_VERSION: ${{ github.event.inputs.version || needs.before-make.outputs.RELEASE_VERSION }}
- name: Create Release Draft - name: Create Release Draft

View File

@ -42,7 +42,7 @@ jobs:
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: core name: core
path: ./apps/core/dist path: ./packages/frontend/core/dist
if-no-files-found: error if-no-files-found: error
build-server: build-server:
@ -61,7 +61,7 @@ jobs:
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: server-dist name: server-dist
path: ./apps/server/dist path: ./packages/backend/server/dist
if-no-files-found: error if-no-files-found: error
build-storage: build-storage:
@ -85,7 +85,7 @@ jobs:
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: storage.node name: storage.node
path: ./packages/storage/storage.node path: ./packages/backend/storage/storage.node
if-no-files-found: error if-no-files-found: error
build-docker: build-docker:
@ -102,17 +102,17 @@ jobs:
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
name: core name: core
path: ./apps/core/dist path: ./packages/frontend/core/dist
- name: Download server dist - name: Download server dist
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
name: server-dist name: server-dist
path: ./apps/server/dist path: ./packages/backend/server/dist
- name: Download storage.node - name: Download storage.node
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
name: storage.node name: storage.node
path: ./apps/server path: ./packages/backend/server
- name: Setup Git short hash - name: Setup Git short hash
run: | run: |
echo "GIT_SHORT_HASH=$(git rev-parse --short HEAD)" >> "$GITHUB_ENV" echo "GIT_SHORT_HASH=$(git rev-parse --short HEAD)" >> "$GITHUB_ENV"

View File

@ -5,7 +5,7 @@ on:
branches: branches:
- master - master
paths: paths:
- packages/workers/** - tools/workers/**
jobs: jobs:
deploy: deploy:
@ -19,4 +19,4 @@ jobs:
with: with:
apiToken: ${{ secrets.CF_API_TOKEN }} apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }} accountId: ${{ secrets.CF_ACCOUNT_ID }}
workingDirectory: 'packages/workers' workingDirectory: 'tools/workers'

View File

@ -3,8 +3,8 @@
"version": 1, "version": 1,
"list": [ "list": [
{ {
"input": "./packages/i18n/src/resources/en.json", "input": "./packages/frontend/i18n/src/resources/en.json",
"output": "./packages/i18n/src/i18n-generated", "output": "./packages/frontend/i18n/src/i18n-generated",
"parser": { "parser": {
"type": "i18next", "type": "i18next",
"contextSeparator": "$", "contextSeparator": "$",

View File

@ -2,16 +2,16 @@ yarn.lock
target target
lib lib
test-results test-results
packages/i18n/src/i18n-generated.ts
packages/graphql/src/graphql/index.ts
.next .next
out out
dist dist
.yarn .yarn
tests/affine-legacy/**/static
.github/helm .github/helm
_next _next
storybook-static storybook-static
web-static web-static
public public
apps/server/src/schema.gql packages/backend/server/src/schema.gql
packages/frontend/i18n/src/i18n-generated.ts
packages/frontend/graphql/src/graphql/index.ts
tests/affine-legacy/**/static

View File

@ -29,15 +29,7 @@
"[typescriptreact]": { "[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode" "editor.defaultFormatter": "esbenp.prettier-vscode"
}, },
"vitest.include": [ "vitest.include": ["packages/**/*.spec.ts", "packages/**/*.spec.tsx"],
"packages/**/*.spec.ts",
"packages/**/*.spec.tsx",
"apps/web/**/*.spec.ts",
"apps/web/**/*.spec.tsx",
"apps/electron/src/**/*.spec.ts",
"tests/unit/**/*.spec.ts",
"tests/unit/**/*.spec.tsx"
],
"rust-analyzer.check.extraEnv": { "rust-analyzer.check.extraEnv": {
"DATABASE_URL": "sqlite:affine.db" "DATABASE_URL": "sqlite:affine.db"
} }

View File

@ -1,9 +1,9 @@
[workspace] [workspace]
resolver = "2" resolver = "2"
members = [ members = [
"./packages/native", "./packages/frontend/native",
"./packages/native/schema", "./packages/frontend/native/schema",
"./packages/storage", "./packages/backend/storage",
] ]
[profile.dev.package.sqlx-macros] [profile.dev.package.sqlx-macros]

View File

@ -2,7 +2,7 @@ Copyright (c) 2022-present TOEVERYTHING PTE. LTD. and its affiliates.
Portions of this software are licensed as follows: Portions of this software are licensed as follows:
- All content that resides under the "apps/server" directory of this repository, if that directory exists, is licensed under the license defined in "apps/server/LICENSE". - All content that resides under the "packages/backend/server" directory of this repository, if that directory exists, is licensed under the license defined in "packages/backend/server/LICENSE".
- All third party components incorporated into the AFFiNE Software are licensed under the original license provided by the owner of the applicable component. - All third party components incorporated into the AFFiNE Software are licensed under the original license provided by the owner of the applicable component.
- Content outside of the above mentioned directories or restrictions above is available under the "MIT" license as defined in "LICENSE-MIT". - Content outside of the above mentioned directories or restrictions above is available under the "MIT" license as defined in "LICENSE-MIT".

View File

@ -110,9 +110,9 @@ If you have questions, you are welcome to contact us. One of the best places to
| Name | | | | Name | | |
| ----------------------------------------------------------------------------------------------- | --------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | | ----------------------------------------------------------------------------------------------- | --------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| [@toeverything/component](https://github.com/toeverything/design/tree/main/packages/components) | Toeverything Shared Component Resources | | | [@toeverything/component](https://github.com/toeverything/design/tree/main/packages/components) | Toeverything Shared Component Resources | |
| [@affine/component](packages/component) | AFFiNE Component Resources | [![](https://img.shields.io/codecov/c/github/toeverything/affine?style=flat-square)](https://affine-storybook.vercel.app/) | | [@affine/component](packages/frontend/component) | AFFiNE Component Resources | [![](https://img.shields.io/codecov/c/github/toeverything/affine?style=flat-square)](https://affine-storybook.vercel.app/) |
| [@toeverything/y-indexeddb](packages/y-indexeddb) | IndexedDB database adapter for Yjs | [![](https://img.shields.io/npm/dm/@toeverything/y-indexeddb?style=flat-square&color=eee)](https://www.npmjs.com/package/@toeverything/y-indexeddb) | | [@toeverything/y-indexeddb](packages/common/y-indexeddb) | IndexedDB database adapter for Yjs | [![](https://img.shields.io/npm/dm/@toeverything/y-indexeddb?style=flat-square&color=eee)](https://www.npmjs.com/package/@toeverything/y-indexeddb) |
| [@toeverything/theme](packages/theme) | AFFiNE theme | [![](https://img.shields.io/npm/dm/@toeverything/theme?style=flat-square&color=eee)](https://www.npmjs.com/package/@toeverything/theme) | | [@toeverything/theme](packages/common/theme) | AFFiNE theme | [![](https://img.shields.io/npm/dm/@toeverything/theme?style=flat-square&color=eee)](https://www.npmjs.com/package/@toeverything/theme) |
## Plugins ## Plugins
@ -120,8 +120,8 @@ If you have questions, you are welcome to contact us. One of the best places to
> >
> (Currently, the plugin system is under heavy development. You will see the plugin system in the canary release.) > (Currently, the plugin system is under heavy development. You will see the plugin system in the canary release.)
- [@affine/sdk](./packages/sdk) - SDK for developing plugins - [@affine/sdk](./packages/common/sdk) - SDK for developing plugins
- [@affine/plugin-cli](./packages/plugin-cli) - CLI for developing plugins - [@affine/plugin-cli](./tools/plugin-cli) - CLI for developing plugins
| Official Plugin | Description | Status | | Official Plugin | Description | Status |
| ----------------------------------------------------- | ----------------------------------------- | ------ | | ----------------------------------------------------- | ----------------------------------------- | ------ |

View File

@ -1,29 +0,0 @@
# Apps structure
> This is the structure of the `apps` directory.
## docs
AFFiNE Developer Documentation using [waku](https://github.com/dai-shi/waku).
## electron
> `core` needs to be built before electron.
AFFiNE Desktop (macOS, Linux and Windows Distribution) using [Electron](https://www.electronjs.org/).
## server
Server using [Nest.js](https://nestjs.com/).
## storybook
Storybook using [Storybook](https://storybook.js.org/).
## prototype
AFFiNE Prototype using [React.js](https://reactjs.org/) + [Vite](https://vitejs.dev/).
## core
AFFiNE Core Application using [React.js](https://reactjs.org/) + [Webpack](https://webpack.js.org/).

View File

@ -59,7 +59,7 @@ yarn install
### Build Native Dependencies ### Build Native Dependencies
Run the following script. It will build the native module at [`/packages/native`](/packages/native) and build Node.js binding using [NAPI.rs](https://napi.rs/). Run the following script. It will build the native module at [`/packages/frontend/native`](/packages/frontend/native) and build Node.js binding using [NAPI.rs](https://napi.rs/).
This could take a while if you build it for the first time. This could take a while if you build it for the first time.
Note: use `strip` from system instead of `binutils` if you are running MacOS. [see problem here](https://github.com/toeverything/AFFiNE/discussions/2840) Note: use `strip` from system instead of `binutils` if you are running MacOS. [see problem here](https://github.com/toeverything/AFFiNE/discussions/2840)

View File

@ -22,10 +22,10 @@ To run AFFiNE Desktop Client Application locally, run the following commands:
yarn install yarn install
yarn dev yarn dev
# in packages/native # in packages/frontend/native
yarn build yarn build
# in apps/electron # in packages/frontend/electron
yarn dev yarn dev
``` ```
@ -33,7 +33,7 @@ Now you should see the Electron app window popping up shortly.
## Build ## Build
To build the desktop client application, run `yarn make` in `apps/electron`. To build the desktop client application, run `yarn make` in `packages/frontend/electron`.
Note: you may want to comment out `osxSign` and `osxNotarize` in `forge.config.js` to avoid signing and notarizing the app. Note: you may want to comment out `osxSign` and `osxNotarize` in `forge.config.js` to avoid signing and notarizing the app.
@ -41,7 +41,7 @@ Once the build is complete, you can find the paths to the binaries in the termin
``` ```
Finished 2 bundles at: Finished 2 bundles at:
Artifacts available at: <affine-repo>/apps/electron/out/make Artifacts available at: <affine-repo>/packages/frontend/electron/out/make
``` ```
## CI ## CI

View File

@ -14,21 +14,13 @@ For the debugging purpose, you might need use local OctoBase on port 3000.
The codebase is organized as follows: The codebase is organized as follows:
- `apps/` contains the source code for the different entry points of the project. - `packages/` contains all code running in production.
- `web/` contains the source code for the web app. - `backend/` contains backend code, more information from <https://github.com/toeverything/OctoBase>.
- `electron/` contains the source code for the Electron app. - `frontend/` contains frontend code, including the web app, the electron app and business libraries.
- `server/` backend side for AFFiNE, see <https://github.com/toeverything/OctoBase> instead. - `plugins/` contains all build-in plugins.
- `packages/` contains the source code for all the packages in the repo. - `common` contains the isomorphic code or basic libraries without business.
- `cli` contains the source code for the CLI. Development only. - `tools/` contains tools to help developing or CI, not used in production.
- `component` contains the source code for the UI component library. - `tests/` contains testings across different libraries, including e2e testings and integration testings.
- `debug` contains the source code for the debug helper.
- `env` contains the source code for the environment setup.
- `hooks` contains the source code for the custom React hooks.
- `i18n` contains the source code for the internationalization.
- `jotai` contains the source code for the Jotai store atoms.
- `octobase-node` contains the source code for the OctoBase Node.js binding using Rust.
- `templates` contains the source code for the templates.
- `workspace` contains the source code for the workspace related code.
### `@affine/env` ### `@affine/env`
@ -50,7 +42,7 @@ Current we have two workspace plugin:
- Each workspace plugin has its state and is isolated from other workspace plugins. - Each workspace plugin has its state and is isolated from other workspace plugins.
- The workspace plugin is responsible for its own state management, data persistence, synchronization, data backup and recovery. - The workspace plugin is responsible for its own state management, data persistence, synchronization, data backup and recovery.
For the workspace API, see [types.ts](../../packages/workspace/src/type.ts). For the workspace API, see [types.ts](../../packages/frontend/workspace/src/type.ts).
### `@affine/component` ### `@affine/component`

View File

@ -47,7 +47,7 @@ postgres=# \du
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {} postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
``` ```
### Set the following config to `apps/server/.env` ### Set the following config to `packages/backend/server/.env`
``` ```
DATABASE_URL="postgresql://affine:affine@localhost:5432/affine" DATABASE_URL="postgresql://affine:affine@localhost:5432/affine"

View File

@ -6,20 +6,13 @@
"license": "MIT", "license": "MIT",
"workspaces": [ "workspaces": [
".", ".",
"apps/*", "packages/*/*",
"plugins/*", "tools/*",
"packages/*", "!tools/@types",
"packages/@types/*", "tools/@types/*",
"tests/fixtures", "tests/*",
"tests/kit", "!tests/affine-legacy",
"tests/affine-legacy/*", "tests/affine-legacy/*"
"tests/affine-local",
"tests/affine-migration",
"tests/affine-desktop",
"tests/affine-desktop-cloud",
"tests/affine-plugin",
"tests/affine-prototype",
"tests/affine-cloud"
], ],
"engines": { "engines": {
"node": ">=18.16.1 <19.0.0" "node": ">=18.16.1 <19.0.0"
@ -34,7 +27,7 @@
"build:plugins": "yarn nx run-many -t build --projects=tag:plugin", "build:plugins": "yarn nx run-many -t build --projects=tag:plugin",
"build:storybook": "yarn nx build @affine/storybook", "build:storybook": "yarn nx build @affine/storybook",
"start:web-static": "yarn workspace @affine/core static-server", "start:web-static": "yarn workspace @affine/core static-server",
"start:storybook": "yarn exec serve apps/storybook/storybook-static -l 6006", "start:storybook": "yarn exec serve tests/storybook/storybook-static -l 6006",
"serve:test-static": "yarn exec serve tests/fixtures --cors -p 8081", "serve:test-static": "yarn exec serve tests/fixtures --cors -p 8081",
"lint:eslint": "eslint . --ext .js,mjs,.ts,.tsx --cache", "lint:eslint": "eslint . --ext .js,mjs,.ts,.tsx --cache",
"lint:eslint:fix": "yarn lint:eslint --fix", "lint:eslint:fix": "yarn lint:eslint --fix",
@ -46,7 +39,7 @@
"test:ui": "vitest --ui", "test:ui": "vitest --ui",
"test:coverage": "vitest run --coverage", "test:coverage": "vitest run --coverage",
"notify": "node scripts/notify.mjs", "notify": "node scripts/notify.mjs",
"circular": "madge --circular --ts-config ./tsconfig.json ./apps/core/src/pages/**/*.tsx ./apps/core/src/index.tsx ./apps/electron/src/*/index.ts", "circular": "madge --circular --ts-config ./tsconfig.json ./packages/frontend/core/src/pages/**/*.tsx ./packages/frontend/core/src/index.tsx ./packages/frontend/electron/src/*/index.ts",
"typecheck": "tsc -b tsconfig.json --diagnostics", "typecheck": "tsc -b tsconfig.json --diagnostics",
"postinstall": "node ./scripts/check-version.mjs && yarn i18n-codegen gen && yarn husky install" "postinstall": "node ./scripts/check-version.mjs && yarn i18n-codegen gen && yarn husky install"
}, },

Some files were not shown because too many files have changed in this diff Show More