refactor: new project struct (#8199)

packages/frontend/web -> packages/frontend/apps/web
packages/frontend/mobile -> packages/frontend/apps/mobile
packages/frontend/electron -> packages/frontend/apps/electron
This commit is contained in:
EYHN 2024-09-12 07:42:57 +00:00
parent 7c4eab6cd3
commit cc5a6e6d40
No known key found for this signature in database
GPG Key ID: 46C9E26A75AB276C
291 changed files with 139 additions and 134 deletions

View File

@ -43,7 +43,9 @@ const allPackages = [
'packages/backend/server',
'packages/frontend/component',
'packages/frontend/core',
'packages/frontend/electron',
'packages/frontend/apps/electron',
'packages/frontend/apps/web',
'packages/frontend/apps/mobile',
'packages/frontend/graphql',
'packages/frontend/i18n',
'packages/frontend/native',

View File

@ -1,8 +1,8 @@
FROM openresty/openresty:1.25.3.2-0-buster
WORKDIR /app
COPY ./packages/frontend/web/dist ./dist
COPY ./packages/frontend/apps/web/dist ./dist
COPY ./packages/frontend/admin/dist ./admin
COPY ./packages/frontend/mobile/dist ./mobile
COPY ./packages/frontend/apps/mobile/dist ./mobile
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

View File

@ -1,9 +1,9 @@
FROM node:20-bookworm-slim
COPY ./packages/backend/server /app
COPY ./packages/frontend/web/dist /app/static
COPY ./packages/frontend/apps/web/dist /app/static
COPY ./packages/frontend/admin/dist /app/static/admin
COPY ./packages/frontend/mobile/dist /app/static/mobile
COPY ./packages/frontend/apps/mobile/dist /app/static/mobile
WORKDIR /app
RUN apt-get update && \

2
.github/labeler.yml vendored
View File

@ -77,7 +77,7 @@ app:core:
app:electron:
- changed-files:
- any-glob-to-any-file:
- 'packages/frontend/electron/**/*'
- 'packages/frontend/apps/electron/**/*'
app:server:
- changed-files:

View File

@ -68,7 +68,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: web
path: ./packages/frontend/web/dist
path: ./packages/frontend/apps/web/dist
if-no-files-found: error
build-admin:
@ -132,7 +132,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: mobile
path: ./packages/frontend/mobile/dist
path: ./packages/frontend/apps/mobile/dist
if-no-files-found: error
build-web-selfhost:
@ -159,7 +159,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: selfhost-web
path: ./packages/frontend/web/dist
path: ./packages/frontend/apps/web/dist
if-no-files-found: error
build-mobile-selfhost:
@ -184,7 +184,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: selfhost-mobile
path: ./packages/frontend/mobile/dist
path: ./packages/frontend/apps/mobile/dist
if-no-files-found: error
build-admin-selfhost:
@ -320,13 +320,13 @@ jobs:
uses: actions/download-artifact@v4
with:
name: web
path: ./packages/frontend/web/dist
path: ./packages/frontend/apps/web/dist
- name: Download mobile artifact
uses: actions/download-artifact@v4
with:
name: mobile
path: ./packages/frontend/mobile/dist
path: ./packages/frontend/apps/mobile/dist
- name: Download admin artifact
uses: actions/download-artifact@v4
@ -338,13 +338,13 @@ jobs:
uses: actions/download-artifact@v4
with:
name: selfhost-web
path: ./packages/frontend/web/dist/selfhost
path: ./packages/frontend/apps/web/dist/selfhost
- name: Download selfhost mobile artifact
uses: actions/download-artifact@v4
with:
name: selfhost-mobile
path: ./packages/frontend/mobile/dist/selfhost
path: ./packages/frontend/apps/mobile/dist/selfhost
- name: Download selfhost admin artifact
uses: actions/download-artifact@v4

View File

@ -313,7 +313,7 @@ jobs:
env:
DISTRIBUTION: desktop
- name: zip web
run: tar -czf dist.tar.gz --directory=packages/frontend/electron/renderer/dist .
run: tar -czf dist.tar.gz --directory=packages/frontend/apps/electron/renderer/dist .
- name: Upload web artifact
uses: actions/upload-artifact@v4
with:
@ -554,7 +554,7 @@ jobs:
- name: Download web artifact
uses: ./.github/actions/download-web
with:
path: packages/frontend/electron/resources/web-static
path: packages/frontend/apps/electron/resources/web-static
- name: Build Desktop Layers
run: yarn workspace @affine/electron build

View File

@ -67,7 +67,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: web
path: packages/frontend/electron/resources/web-static
path: packages/frontend/apps/electron/resources/web-static
make-distribution:
strategy:
@ -119,7 +119,7 @@ jobs:
- uses: actions/download-artifact@v4
with:
name: web
path: packages/frontend/electron/resources/web-static
path: packages/frontend/apps/electron/resources/web-static
- name: Build Desktop Layers
run: yarn workspace @affine/electron build
@ -146,20 +146,20 @@ jobs:
- name: signing DMG
if: ${{ matrix.spec.platform == 'darwin' }}
run: |
codesign --force --sign "Developer ID Application: TOEVERYTHING PTE. LTD." packages/frontend/electron/out/${{ env.BUILD_TYPE }}/make/AFFiNE.dmg
codesign --force --sign "Developer ID Application: TOEVERYTHING PTE. LTD." packages/frontend/apps/electron/out/${{ env.BUILD_TYPE }}/make/AFFiNE.dmg
- name: Save artifacts (mac)
if: ${{ matrix.spec.platform == 'darwin' }}
run: |
mkdir -p builds
mv packages/frontend/electron/out/*/make/*.dmg ./builds/affine-${{ needs.before-make.outputs.RELEASE_VERSION }}-${{ env.BUILD_TYPE }}-macos-${{ matrix.spec.arch }}.dmg
mv packages/frontend/electron/out/*/make/zip/darwin/${{ matrix.spec.arch }}/*.zip ./builds/affine-${{ needs.before-make.outputs.RELEASE_VERSION }}-${{ env.BUILD_TYPE }}-macos-${{ matrix.spec.arch }}.zip
mv packages/frontend/apps/electron/out/*/make/*.dmg ./builds/affine-${{ needs.before-make.outputs.RELEASE_VERSION }}-${{ env.BUILD_TYPE }}-macos-${{ matrix.spec.arch }}.dmg
mv packages/frontend/apps/electron/out/*/make/zip/darwin/${{ matrix.spec.arch }}/*.zip ./builds/affine-${{ needs.before-make.outputs.RELEASE_VERSION }}-${{ env.BUILD_TYPE }}-macos-${{ matrix.spec.arch }}.zip
- name: Save artifacts (linux)
if: ${{ matrix.spec.platform == 'linux' }}
run: |
mkdir -p builds
mv packages/frontend/electron/out/*/make/zip/linux/x64/*.zip ./builds/affine-${{ needs.before-make.outputs.RELEASE_VERSION }}-${{ env.BUILD_TYPE }}-linux-x64.zip
mv packages/frontend/electron/out/*/make/*.AppImage ./builds/affine-${{ needs.before-make.outputs.RELEASE_VERSION }}-${{ env.BUILD_TYPE }}-linux-x64.appimage
mv packages/frontend/apps/electron/out/*/make/zip/linux/x64/*.zip ./builds/affine-${{ needs.before-make.outputs.RELEASE_VERSION }}-${{ env.BUILD_TYPE }}-linux-x64.zip
mv packages/frontend/apps/electron/out/*/make/*.AppImage ./builds/affine-${{ needs.before-make.outputs.RELEASE_VERSION }}-${{ env.BUILD_TYPE }}-linux-x64.appimage
- uses: actions/attest-build-provenance@v1
if: ${{ matrix.spec.platform == 'darwin' }}
@ -221,7 +221,7 @@ jobs:
- uses: actions/download-artifact@v4
with:
name: web
path: packages/frontend/electron/resources/web-static
path: packages/frontend/apps/electron/resources/web-static
- name: Build Desktop Layers
run: yarn workspace @affine/electron build
@ -235,12 +235,12 @@ jobs:
- name: get all files to be signed
id: get_files_to_be_signed
run: |
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 + '\packages\frontend\electron\out\', '') + '"' }) -join ' ')
Set-Variable -Name FILES_TO_BE_SIGNED -Value ((Get-ChildItem -Path packages/frontend/apps/electron/out -Recurse -File | Where-Object { $_.Extension -in @(".exe", ".node", ".dll", ".msi") } | ForEach-Object { '"' + $_.FullName.Replace((Get-Location).Path + '\packages\frontend\electron\out\', '') + '"' }) -join ' ')
"FILES_TO_BE_SIGNED=$FILES_TO_BE_SIGNED" >> $env:GITHUB_OUTPUT
echo $FILES_TO_BE_SIGNED
- name: Zip artifacts for faster upload
run: Compress-Archive -CompressionLevel Fastest -Path packages/frontend/electron/out/* -DestinationPath archive.zip
run: Compress-Archive -CompressionLevel Fastest -Path packages/frontend/apps/electron/out/* -DestinationPath archive.zip
- name: Save packaged artifacts for signing
uses: actions/upload-artifact@v4
@ -287,7 +287,7 @@ jobs:
name: signed-packaged-${{ matrix.spec.platform }}-${{ matrix.spec.arch }}
path: .
- name: unzip file
run: Expand-Archive -Path signed.zip -DestinationPath packages/frontend/electron/out
run: Expand-Archive -Path signed.zip -DestinationPath packages/frontend/apps/electron/out
- name: Make squirrel.windows installer
run: yarn workspace @affine/electron make-squirrel --platform=${{ matrix.spec.platform }} --arch=${{ matrix.spec.arch }}
@ -296,12 +296,12 @@ jobs:
run: yarn workspace @affine/electron make-nsis --platform=${{ matrix.spec.platform }} --arch=${{ matrix.spec.arch }}
- name: Zip artifacts for faster upload
run: Compress-Archive -CompressionLevel Fastest -Path packages/frontend/electron/out/${{ env.BUILD_TYPE }}/make/* -DestinationPath archive.zip
run: Compress-Archive -CompressionLevel Fastest -Path packages/frontend/apps/electron/out/${{ env.BUILD_TYPE }}/make/* -DestinationPath archive.zip
- name: get all files to be signed
id: get_files_to_be_signed
run: |
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 + '\packages\frontend\electron\out\${{ env.BUILD_TYPE }}\make\', '') + '"' }) -join ' ')
Set-Variable -Name FILES_TO_BE_SIGNED -Value ((Get-ChildItem -Path packages/frontend/apps/electron/out/${{ env.BUILD_TYPE }}/make -Recurse -File | Where-Object { $_.Extension -in @(".exe", ".node", ".dll", ".msi") } | ForEach-Object { '"' + $_.FullName.Replace((Get-Location).Path + '\packages\frontend\electron\out\${{ env.BUILD_TYPE }}\make\', '') + '"' }) -join ' ')
"FILES_TO_BE_SIGNED=$FILES_TO_BE_SIGNED" >> $env:GITHUB_OUTPUT
echo $FILES_TO_BE_SIGNED
@ -335,14 +335,14 @@ jobs:
name: signed-installer-${{ matrix.spec.platform }}-${{ matrix.spec.arch }}
path: .
- name: unzip file
run: Expand-Archive -Path signed.zip -DestinationPath packages/frontend/electron/out/${{ env.BUILD_TYPE }}/make
run: Expand-Archive -Path signed.zip -DestinationPath packages/frontend/apps/electron/out/${{ env.BUILD_TYPE }}/make
- name: Save artifacts
run: |
mkdir -p builds
mv packages/frontend/electron/out/*/make/zip/win32/x64/AFFiNE*-win32-x64-*.zip ./builds/affine-${{ needs.before-make.outputs.RELEASE_VERSION }}-${{ env.BUILD_TYPE }}-windows-x64.zip
mv packages/frontend/electron/out/*/make/squirrel.windows/x64/*.exe ./builds/affine-${{ needs.before-make.outputs.RELEASE_VERSION }}-${{ env.BUILD_TYPE }}-windows-x64.exe
mv packages/frontend/electron/out/*/make/nsis.windows/x64/*.exe ./builds/affine-${{ needs.before-make.outputs.RELEASE_VERSION }}-${{ env.BUILD_TYPE }}-windows-x64.nsis.exe
mv packages/frontend/apps/electron/out/*/make/zip/win32/x64/AFFiNE*-win32-x64-*.zip ./builds/affine-${{ needs.before-make.outputs.RELEASE_VERSION }}-${{ env.BUILD_TYPE }}-windows-x64.zip
mv packages/frontend/apps/electron/out/*/make/squirrel.windows/x64/*.exe ./builds/affine-${{ needs.before-make.outputs.RELEASE_VERSION }}-${{ env.BUILD_TYPE }}-windows-x64.exe
mv packages/frontend/apps/electron/out/*/make/nsis.windows/x64/*.exe ./builds/affine-${{ needs.before-make.outputs.RELEASE_VERSION }}-${{ env.BUILD_TYPE }}-windows-x64.nsis.exe
- uses: actions/attest-build-provenance@v1
with:
@ -394,7 +394,7 @@ jobs:
node-version: 20
- name: Generate Release yml
run: |
node ./packages/frontend/electron/scripts/generate-yml.js
node ./packages/frontend/apps/electron/scripts/generate-yml.js
env:
RELEASE_VERSION: ${{ needs.before-make.outputs.RELEASE_VERSION }}
- name: Create Release Draft

View File

@ -7,6 +7,7 @@
"workspaces": [
".",
"packages/*/*",
"packages/frontend/apps/*",
"tools/*",
"docs/reference",
"tools/@types/*",

View File

@ -10,7 +10,7 @@ yarn install
yarn workspace @affine/native build
yarn dev
# in packages/frontend/electron
# in packages/frontend/apps/electron
yarn generate-assets
yarn dev # or yarn prod for production build
```

View File

@ -61,7 +61,6 @@
"fs-extra": "^11.2.0",
"glob": "^11.0.0",
"jotai": "^2.8.0",
"jotai-devtools": "^0.10.0",
"lodash-es": "^4.17.21",
"nanoid": "^5.0.7",
"react": "^18.2.0",

View File

@ -2,8 +2,8 @@
"name": "@affine/electron",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"root": "packages/frontend/electron",
"sourceRoot": "packages/frontend/electron/src",
"root": "packages/frontend/apps/electron",
"sourceRoot": "packages/frontend/apps/electron/src",
"targets": {
"build": {
"executor": "nx:run-script",

View File

@ -30,8 +30,7 @@ import {
getCurrentStore,
LifecycleService,
} from '@toeverything/infra';
import type { PropsWithChildren, ReactElement } from 'react';
import { lazy, Suspense } from 'react';
import { Suspense } from 'react';
import { RouterProvider } from 'react-router-dom';
const desktopWhiteList = [
@ -55,19 +54,6 @@ if (
const performanceI18nLogger = performanceLogger.namespace('i18n');
const cache = createEmotionCache();
const DevTools = lazy(() =>
import('jotai-devtools').then(m => ({ default: m.DevTools }))
);
const DebugProvider = ({ children }: PropsWithChildren): ReactElement => {
return (
<>
<Suspense>{process.env.DEBUG_JOTAI === 'true' && <DevTools />}</Suspense>
{children}
</>
);
};
const future = {
v7_startTransition: true,
} as const;
@ -115,19 +101,17 @@ export function App() {
<AffineContext store={getCurrentStore()}>
<Telemetry />
<CustomThemeModifier />
<DebugProvider>
<GlobalLoading />
<RouterProvider
fallbackElement={<AppFallback />}
router={router}
future={future}
/>
{environment.isWindows && (
<div style={{ position: 'fixed', right: 0, top: 0, zIndex: 5 }}>
<WindowsAppControls />
</div>
)}
</DebugProvider>
<GlobalLoading />
<RouterProvider
fallbackElement={<AppFallback />}
router={router}
future={future}
/>
{environment.isWindows && (
<div style={{ position: 'fixed', right: 0, top: 0, zIndex: 5 }}>
<WindowsAppControls />
</div>
)}
</AffineContext>
</CacheProvider>
</FrameworkRoot>

View File

@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.json",
"extends": "../../../../../tsconfig.json",
"compilerOptions": {
"composite": true,
"target": "ESNext",
@ -13,16 +13,16 @@
},
"references": [
{
"path": "../../../common/env"
"path": "../../../../common/env"
},
{
"path": "../../core"
"path": "../../../core"
},
{
"path": "../../component"
"path": "../../../component"
},
{
"path": "../../../common/infra"
"path": "../../../../common/infra"
}
],
"include": ["."],

View File

Before

Width:  |  Height:  |  Size: 249 KiB

After

Width:  |  Height:  |  Size: 249 KiB

View File

Before

Width:  |  Height:  |  Size: 195 KiB

After

Width:  |  Height:  |  Size: 195 KiB

View File

Before

Width:  |  Height:  |  Size: 761 KiB

After

Width:  |  Height:  |  Size: 761 KiB

View File

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 43 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

View File

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB

View File

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

View File

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

Before

Width:  |  Height:  |  Size: 805 KiB

After

Width:  |  Height:  |  Size: 805 KiB

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