diff --git a/.changeset/config.json b/.changeset/config.json index 1892e1a308..6ce3b1a2ce 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -5,7 +5,7 @@ "fixed": [], "linked": [], "access": "restricted", - "baseBranch": "feat/cloud-sync", + "baseBranch": "feat/master", "updateInternalDependencies": "patch", "ignore": [] } diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000000..f80d334591 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,2 @@ +**/project.json @darkskygit +**/pnpm-lock.yaml @darkskygit diff --git a/.github/workflows/changlog.yml b/.github/workflows/changlog.yml index 6a4ced3e20..d91559cf50 100644 --- a/.github/workflows/changlog.yml +++ b/.github/workflows/changlog.yml @@ -1,8 +1,7 @@ name: Pathfinder changelog on: - push: - branches: [feat/cloud-sync, master] + workflow_dispatch: # Cancels all previous workflow runs for pull requests that have not completed. # See https://docs.github.com/en/actions/using-jobs/using-concurrency diff --git a/.github/workflows/temp_test.yml b/.github/workflows/publish.yml similarity index 52% rename from .github/workflows/temp_test.yml rename to .github/workflows/publish.yml index a1fa93bdf0..09ec455e77 100644 --- a/.github/workflows/temp_test.yml +++ b/.github/workflows/publish.yml @@ -1,10 +1,7 @@ -name: Pathfinder Check +name: Build Pathfinder Self-hosted on: - push: - branches: [feat/cloud-sync] - pull_request: - branches: [feat/cloud-sync] + workflow_dispatch: # Cancels all previous workflow runs for pull requests that have not completed. # See https://docs.github.com/en/actions/using-jobs/using-concurrency @@ -15,69 +12,12 @@ concurrency: cancel-in-progress: true jobs: - build: - name: Build on Pull Request - if: github.ref != 'refs/heads/master' + build-self-hosted: + name: Build Community + if: github.ref == 'refs/heads/master' runs-on: self-hosted environment: development - steps: - - uses: actions/checkout@v2 - - uses: pnpm/action-setup@v2 - with: - version: 'latest' - - - name: Use Node.js - uses: actions/setup-node@v2 - with: - node-version: 18.x - registry-url: https://npm.pkg.github.com - scope: '@toeverything' - cache: 'pnpm' - - - run: node scripts/module-resolve/ci.js - - - name: Restore cache - uses: actions/cache@v3 - with: - path: | - .next/cache - # Generate a new cache whenever packages or source files change. - key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} - # If source files changed but packages didn't, rebuild from a prior cache. - restore-keys: | - ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}- - - - name: Install dependencies - run: pnpm install --no-frozen-lockfile - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_GITHUB_AUTH_TOKEN }} - - - name: Build - run: pnpm build - env: - NEXT_PUBLIC_FIREBASE_API_KEY: ${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }} - NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN: ${{ secrets.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN }} - NEXT_PUBLIC_FIREBASE_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_PROJECT_ID }} - NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET: ${{ secrets.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET }} - NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID }} - NEXT_PUBLIC_FIREBASE_APP_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_APP_ID }} - NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID }} - - - name: Export - run: pnpm export - - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - path: ./packages/app/.next - - lint: - name: Lint and E2E Test - runs-on: ubuntu-latest - environment: development - needs: build - steps: - uses: actions/checkout@v2 - uses: pnpm/action-setup@v2 @@ -106,18 +46,8 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.NPM_GITHUB_AUTH_TOKEN }} - - name: Download artifact - uses: actions/download-artifact@v3 - with: - name: artifact - path: packages/app/.next/ - - - name: Lint & E2E Test - run: | - pnpm lint --max-warnings=0 - PLAYWRIGHT_BROWSERS_PATH=0 npx playwright install chromium - PLAYWRIGHT_BROWSERS_PATH=0 pnpm test - PLAYWRIGHT_BROWSERS_PATH=0 pnpm test:dc + - name: Build + run: pnpm build env: NEXT_PUBLIC_FIREBASE_API_KEY: ${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }} NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN: ${{ secrets.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN }} @@ -126,3 +56,59 @@ jobs: NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID }} NEXT_PUBLIC_FIREBASE_APP_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_APP_ID }} NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID }} + + - name: Export + run: pnpm export + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + path: ./packages/app/out + + publish-self-hosted: + name: Push Community Image + if: github.ref == 'refs/heads/master' + runs-on: ubuntu-latest + needs: build-self-hosted + + permissions: + contents: read + packages: write + + env: + REGISTRY: ghcr.io + IMAGE_NAME: 'toeverything/affine-static' + IMAGE_TAG_LATEST: abbey-wood + + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Download artifact + uses: actions/download-artifact@v3 + with: + name: artifact + path: packages/app/out/ + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: ${{ env.IMAGE_TAG_LATEST }} + + - name: Build Docker image + uses: docker/build-push-action@v3 + with: + context: . + push: true + file: ./.github/deployment/Dockerfile + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.vscode/settings.json b/.vscode/settings.json index a366193c02..166b0206c0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,5 +3,12 @@ "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnSave": true, "editor.formatOnSaveMode": "file", - "cSpell.words": ["blocksuite", "datacenter", "livedemo", "pnpm", "testid"] + "cSpell.words": [ + "blocksuite", + "datacenter", + "livedemo", + "pnpm", + "selfhosted", + "testid" + ] } diff --git a/package.json b/package.json index 624a14bee0..0b5a3def03 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "license": "MPL-2.0", "scripts": { "dev": "pnpm --filter=!@affine/app build && pnpm --filter @affine/app dev", - "dev:ac": "pnpm --filter=!@affine/app build && pnpm --filter @affine/app dev:ac", + "dev:ac": "pnpm --filter=!@affine/app build && NODE_API_SERVER=ac pnpm --filter @affine/app dev", + "dev:local": "pnpm --filter=!@affine/app build && NODE_API_SERVER=local pnpm --filter @affine/app dev", "build": " pnpm --filter=!@affine/app build && pnpm --filter!=@affine/datacenter -r build", "export": "pnpm --filter @affine/app export", "start": "pnpm --filter @affine/app start", diff --git a/packages/app/next.config.js b/packages/app/next.config.js index 20f12e5770..df91a70108 100644 --- a/packages/app/next.config.js +++ b/packages/app/next.config.js @@ -4,6 +4,32 @@ const { dependencies } = require('./package.json'); const path = require('node:path'); const printer = require('./scripts/printer').printer; +const enableDebugLocal = path.isAbsolute(process.env.LOCAL_BLOCK_SUITE ?? ''); +const EDITOR_VERSION = enableDebugLocal + ? 'local-version' + : dependencies['@blocksuite/editor']; + +const profileTarget = { + ac: '100.85.73.88:12001', + dev: '100.85.73.88:12001', + local: '127.0.0.1:3000', +}; + +const getRedirectConfig = profile => { + const target = profileTarget[profile || 'dev'] || profileTarget['dev']; + + return [ + [ + { source: '/api/:path*', destination: `http://${target}/api/:path*` }, + { + source: '/collaboration/:path*', + destination: `http://${target}/collaboration/:path*`, + }, + ], + target, + ]; +}; + /** @type {import('next').NextConfig} */ const nextConfig = { productionBrowserSourceMaps: true, @@ -16,7 +42,7 @@ const nextConfig = { CI: process.env.CI || null, VERSION: getGitVersion(), COMMIT_HASH: getCommitHash(), - EDITOR_VERSION: dependencies['@blocksuite/editor'], + EDITOR_VERSION, }, webpack: config => { config.experiments = { ...config.experiments, topLevelAwait: true }; @@ -31,30 +57,12 @@ const nextConfig = { images: { unoptimized: true, }, - // XXX not test yet rewrites: async () => { - if (process.env.NODE_API_SERVER === 'ac') { - let destinationAC = 'http://100.85.73.88:12001/api/:path*'; - printer.info('API request proxy to [AC Server] ' + destinationAC); - return [ - { - source: '/api/:path*', - destination: destinationAC, - }, - ]; - } else { - let destinationStandard = 'http://100.77.180.48:11001/api/:path*'; - printer.info( - 'API request proxy to [Standard Server] ' + destinationStandard - ); - - return [ - { - source: '/api/:path*', - destination: destinationStandard, - }, - ]; - } + const [profile, desc] = getRedirectConfig(process.env.NODE_API_SERVER); + printer.info( + `API request proxy to [${process.env.NODE_API_SERVER} Server]: ` + desc + ); + return profile; }, basePath: process.env.BASE_PATH, }; @@ -63,11 +71,25 @@ const baseDir = process.env.LOCAL_BLOCK_SUITE ?? '/'; const withDebugLocal = require('next-debug-local')( { '@blocksuite/editor': path.resolve(baseDir, 'packages', 'editor'), + '@blocksuite/blocks/models': path.resolve( + baseDir, + 'packages', + 'blocks', + 'src', + 'models' + ), + '@blocksuite/blocks/std': path.resolve( + baseDir, + 'packages', + 'blocks', + 'src', + 'std' + ), '@blocksuite/blocks': path.resolve(baseDir, 'packages', 'blocks'), '@blocksuite/store': path.resolve(baseDir, 'packages', 'store'), }, { - enable: path.isAbsolute(process.env.LOCAL_BLOCK_SUITE ?? ''), + enable: enableDebugLocal, } ); diff --git a/packages/app/package.json b/packages/app/package.json index 00b96a7fd1..3ba74e2712 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -3,7 +3,6 @@ "version": "0.3.1", "scripts": { "dev": "next dev -p 8080", - "dev:ac": "NODE_API_SERVER=ac next dev -p 8080", "build": "next build", "export": "next export", "start": "next start", @@ -11,10 +10,10 @@ }, "dependencies": { "@affine/datacenter": "workspace:*", - "@blocksuite/blocks": "0.3.1", - "@blocksuite/editor": "0.3.1", + "@blocksuite/blocks": "=0.3.1-20230106060050-1aad55d", + "@blocksuite/editor": "=0.3.1-20230106060050-1aad55d", "@blocksuite/icons": "^2.0.2", - "@blocksuite/store": "0.3.1", + "@blocksuite/store": "=0.3.1-20230106060050-1aad55d", "@emotion/css": "^11.10.0", "@emotion/react": "^11.10.4", "@emotion/server": "^11.10.0", @@ -45,7 +44,7 @@ "@types/react": "18.0.20", "@types/react-dom": "18.0.6", "@types/wicg-file-system-access": "^2020.9.5", - "chalk-next": "^6.1.5", + "chalk": "^4.1.2", "eslint": "8.22.0", "eslint-config-next": "12.3.1", "eslint-config-prettier": "^8.5.0", diff --git a/packages/app/src/components/404/index.tsx b/packages/app/src/components/404/index.tsx index e2f828ad9f..7df644bbfe 100644 --- a/packages/app/src/components/404/index.tsx +++ b/packages/app/src/components/404/index.tsx @@ -1,9 +1,10 @@ import { NotFoundTitle, PageContainer } from './styles'; - +import { useTranslation } from 'react-i18next'; export const NotfoundPage = () => { + const { t } = useTranslation(); return ( - 404 - Page Not Found + {t('404 - Page Not Found')} ); }; diff --git a/packages/app/src/components/contact-modal/index.tsx b/packages/app/src/components/contact-modal/index.tsx index a182f3e047..921b34ba65 100644 --- a/packages/app/src/components/contact-modal/index.tsx +++ b/packages/app/src/components/contact-modal/index.tsx @@ -23,7 +23,7 @@ import { StyledModalFooter, } from './style'; import bg from '@/components/contact-modal/bg.png'; - +import { useTranslation } from 'react-i18next'; const linkList = [ { icon: , @@ -51,27 +51,31 @@ const linkList = [ link: 'https://discord.gg/Arn7TqJBvG', }, ]; -const rightLinkList = [ - { - icon: , - title: 'Official Website ', - subTitle: 'AFFiNE.pro', - link: 'https://affine.pro', - }, - { - icon: , - title: 'AFFiNE Community', - subTitle: 'community.affine.pro', - link: 'https://community.affine.pro', - }, -]; type TransitionsModalProps = { open: boolean; onClose: () => void; }; -export const ContactModal = ({ open, onClose }: TransitionsModalProps) => { +export const ContactModal = ({ + open, + onClose, +}: TransitionsModalProps): JSX.Element => { + const { t } = useTranslation(); + const rightLinkList = [ + { + icon: , + title: t('Official Website'), + subTitle: 'AFFiNE.pro', + link: 'https://affine.pro', + }, + { + icon: , + title: t('AFFiNE Community'), + subTitle: 'community.affine.pro', + link: 'https://community.affine.pro', + }, + ]; return ( { })} - Get in touch! + {t('Get in touch!')} {linkList.map(({ icon, title, link }) => { return ( @@ -128,7 +132,7 @@ export const ContactModal = ({ open, onClose }: TransitionsModalProps) => { target="_blank" rel="noreferrer" > - How is AFFiNE Alpha different? + {t('How is AFFiNE Alpha different?')}

Copyright © 2022 Toeverything

diff --git a/packages/app/src/components/editor-mode-switch/index.tsx b/packages/app/src/components/editor-mode-switch/index.tsx index 8a219e4757..86a54d8606 100644 --- a/packages/app/src/components/editor-mode-switch/index.tsx +++ b/packages/app/src/components/editor-mode-switch/index.tsx @@ -15,7 +15,7 @@ import { useTheme } from '@/providers/themeProvider'; import { EdgelessIcon, PaperIcon } from './icons'; import useCurrentPageMeta from '@/hooks/use-current-page-meta'; import { usePageHelper } from '@/hooks/use-page-helper'; - +import { useTranslation } from 'react-i18next'; const PaperItem = ({ active }: { active?: boolean }) => { const { theme: { @@ -96,7 +96,7 @@ export const EditorModeSwitch = ({ setRadioItemStatus(modifyRadioItemStatus()); // eslint-disable-next-line react-hooks/exhaustive-deps }, [isHover, mode]); - + const { t } = useTranslation(); return ( } active={mode === 'page'} status={radioItemStatus.left} @@ -126,7 +126,7 @@ export const EditorModeSwitch = ({