refactor: use yarn (#1619)

This commit is contained in:
Himself65
2023-03-20 02:05:02 -05:00
committed by GitHub
parent f6c1423361
commit fe2d244460
33 changed files with 21642 additions and 19727 deletions

View File

@@ -24,40 +24,39 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version-file: '.nvmrc' node-version-file: '.nvmrc'
registry-url: https://npm.pkg.github.com registry-url: https://npm.pkg.github.com
scope: '@toeverything' scope: '@toeverything'
cache: 'pnpm' cache: 'yarn'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- run: node scripts/module-resolve/ci.cjs - run: node scripts/module-resolve/ci.cjs
- name: Restore cache - uses: actions/cache@v3
uses: actions/cache@v3 id: yarn-cache
with: with:
path: | path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
.next/cache key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
# 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: | restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}- ${{ runner.os }}-yarn-
- run: pnpm i --no-frozen-lockfile - run: yarn install
env: env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_GITHUB_AUTH_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.NPM_GITHUB_AUTH_TOKEN }}
- name: Lint - name: Lint
run: | run: |
pnpm lint --max-warnings=0 yarn lint --max-warnings=0
# - name: Test # - name: Test
# run: pnpm test # run: yarn test
- name: Build - name: Build
run: pnpm build run: yarn build
env: env:
NEXT_PUBLIC_FIREBASE_API_KEY: ${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }} 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_AUTH_DOMAIN: ${{ secrets.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN }}
@@ -68,7 +67,7 @@ jobs:
NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID }} NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID }}
- name: Export - name: Export
run: pnpm export run: yarn export
- name: Upload artifact - name: Upload artifact
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3

View File

@@ -23,28 +23,27 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: pnpm/action-setup@v2 - name: Use Node.js LTS
- uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version-file: '.nvmrc' node-version-file: '.nvmrc'
cache: 'pnpm' cache: 'yarn'
- name: Get yarn cache directory path
- name: Restore cache id: yarn-cache-dir-path
uses: actions/cache@v3 run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v3
id: yarn-cache
with: with:
path: | path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
apps/web/.next/cache key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
# 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: | restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}- ${{ runner.os }}-yarn-
- run: pnpm i - run: yarn install
- run: pnpm lint --max-warnings=0 - run: yarn lint --max-warnings=0
- name: Build - name: Build
run: pnpm i && pnpm build run: yarn build
env: env:
NEXT_PUBLIC_FIREBASE_API_KEY: ${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }} 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_AUTH_DOMAIN: ${{ secrets.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN }}
@@ -55,7 +54,7 @@ jobs:
NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID }} NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID }}
- name: Export - name: Export
run: pnpm export run: yarn export
- name: Upload artifact - name: Upload artifact
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
@@ -90,13 +89,22 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: pnpm/action-setup@v2 - name: Use Node.js 18
- uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: 18 node-version: 18
cache: 'pnpm' cache: 'yarn'
- run: pnpm i - name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn install
- name: Download artifact - name: Download artifact
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
@@ -106,12 +114,12 @@ jobs:
- name: Install playwright browsers - name: Install playwright browsers
run: npx playwright install chromium run: npx playwright install chromium
- name: Run playwright tests - name: Run playwright tests
run: pnpm test -- --forbid-only --shard=${{ matrix.shard }}/${{ strategy.job-total }} run: yarn test --forbid-only --shard=${{ matrix.shard }}/${{ strategy.job-total }}
env: env:
COVERAGE: true COVERAGE: true
- name: Collect code coverage report - name: Collect code coverage report
run: pnpm exec nyc report -t .nyc_output --report-dir .coverage --reporter=lcov run: yarn exec nyc report -t .nyc_output --report-dir .coverage --reporter=lcov
- name: Upload e2e test coverage results - name: Upload e2e test coverage results
uses: codecov/codecov-action@v3 uses: codecov/codecov-action@v3
@@ -138,13 +146,22 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: pnpm/action-setup@v2 - name: Use Node.js LTS
- uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version-file: '.nvmrc' node-version-file: '.nvmrc'
cache: 'pnpm' cache: 'yarn'
- run: pnpm i - name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn install
- name: Download artifact - name: Download artifact
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
@@ -152,7 +169,7 @@ jobs:
path: ./apps/web/.next path: ./apps/web/.next
- name: Unit Test - name: Unit Test
run: pnpm run test:unit:coverage run: yarn run test:unit:coverage
- name: Upload unit test coverage results - name: Upload unit test coverage results
uses: codecov/codecov-action@v3 uses: codecov/codecov-action@v3
@@ -171,33 +188,32 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: pnpm/action-setup@v2 - name: Use Node.js LTS
- uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version-file: '.nvmrc' node-version-file: '.nvmrc'
cache: 'yarn'
registry-url: https://npm.pkg.github.com registry-url: https://npm.pkg.github.com
scope: '@toeverything' scope: '@toeverything'
cache: 'pnpm' - name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: node scripts/module-resolve/ci.cjs - run: node scripts/module-resolve/ci.cjs
- name: Restore cache - run: yarn install
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') }}-
- run: pnpm i --no-frozen-lockfile
env: env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_GITHUB_AUTH_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.NPM_GITHUB_AUTH_TOKEN }}
- name: Build - name: Build
run: pnpm build run: yarn build
env: env:
NEXT_PUBLIC_FIREBASE_API_KEY: ${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }} 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_AUTH_DOMAIN: ${{ secrets.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN }}
@@ -208,7 +224,7 @@ jobs:
NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID }} NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID }}
- name: Export - name: Export
run: pnpm export run: yarn export
- name: Upload artifact - name: Upload artifact
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
@@ -286,13 +302,22 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: pnpm/action-setup@v2 - name: Use Node.js 18
- uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version-file: '.nvmrc' node-version: 18
cache: 'pnpm' cache: 'yarn'
- run: pnpm i - name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn install
- name: Download artifact - name: Download artifact
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
@@ -303,13 +328,13 @@ jobs:
run: npx playwright install chromium run: npx playwright install chromium
- name: Run e2e & unit tests - name: Run e2e & unit tests
run: | run: |
pnpm test -- --forbid-only yarn test --forbid-only
pnpm run test:unit:coverage yarn run test:unit:coverage
env: env:
COVERAGE: true COVERAGE: true
- name: Collect code coverage report - name: Collect code coverage report
run: pnpm exec nyc report -t .nyc_output --report-dir .coverage --reporter=lcov run: yarn exec nyc report -t .nyc_output --report-dir .coverage --reporter=lcov
- name: Upload e2e test coverage results - name: Upload e2e test coverage results
uses: codecov/codecov-action@v3 uses: codecov/codecov-action@v3

View File

@@ -34,14 +34,18 @@ jobs:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: pnpm/action-setup@v2 - name: Get yarn cache directory path
- uses: actions/setup-node@v3 id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v3
id: yarn-cache
with: with:
node-version: 18 path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
cache: 'pnpm' key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies - name: Install dependencies
run: yarn install run: yarn install
working-directory: apps/electron
- name: before-make - name: before-make
working-directory: apps/electron working-directory: apps/electron

View File

@@ -1,39 +0,0 @@
name: Compressed Size
on:
pull_request_target:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
registry-url: https://npm.pkg.github.com
scope: '@toeverything'
cache: 'pnpm'
- uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/apps/web/.next/cache
key: ${{ runner.os }}-affine-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: |
${{ runner.os }}-affine-${{ hashFiles('**/pnpm-lock.yaml') }}-
- name: Build
run: |
pnpm install --frozen-lockfile
pnpm run build
- uses: preactjs/compressed-size-action@v2
env:
ENABLE_DEBUG_PAGE: ''
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}'
build-script: 'export'
pattern: 'apps/web/out/**/*.{js,css,html,json}'
compression: 'brotli'

View File

@@ -26,23 +26,27 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: pnpm/action-setup@v2 - name: Get yarn cache directory path
- uses: actions/setup-node@v3 id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v3
id: yarn-cache
with: with:
node-version-file: '.nvmrc' path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
cache: 'pnpm' key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- run: pnpm i restore-keys: |
${{ runner.os }}-yarn-
- run: yarn install
- name: Check Language Key - name: Check Language Key
if: github.ref != 'refs/heads/master' if: github.ref != 'refs/heads/master'
working-directory: ./packages/i18n working-directory: ./packages/i18n
run: pnpm run sync-languages:check run: yarn run sync-languages:check
env: env:
TOLGEE_API_KEY: ${{ secrets.TOLGEE_API_KEY }} TOLGEE_API_KEY: ${{ secrets.TOLGEE_API_KEY }}
- name: Sync Languages - name: Sync Languages
if: github.ref == 'refs/heads/master' if: github.ref == 'refs/heads/master'
working-directory: ./packages/i18n working-directory: ./packages/i18n
run: pnpm run sync-languages run: yarn run sync-languages
env: env:
TOLGEE_API_KEY: ${{ secrets.TOLGEE_API_KEY }} TOLGEE_API_KEY: ${{ secrets.TOLGEE_API_KEY }}

View File

@@ -20,29 +20,23 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: pnpm/action-setup@v2 - name: Get yarn cache directory path
- uses: actions/setup-node@v3 id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v3
id: yarn-cache
with: with:
node-version-file: '.nvmrc' path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
cache: 'pnpm' key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- 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: | restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}- ${{ runner.os }}-yarn-
- run: pnpm i - run: yarn install
env: env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_GITHUB_AUTH_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.NPM_GITHUB_AUTH_TOKEN }}
- name: Build - name: Build
run: pnpm build run: yarn build
env: env:
NEXT_PUBLIC_FIREBASE_API_KEY: ${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }} 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_AUTH_DOMAIN: ${{ secrets.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN }}
@@ -53,7 +47,7 @@ jobs:
NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID }} NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID }}
- name: Export - name: Export
run: pnpm export run: yarn export
- name: Upload artifact - name: Upload artifact
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3

View File

@@ -1,61 +0,0 @@
name: Update block-suite version
on:
schedule:
# At 02:00 UTC
- cron: '0 2 * * *'
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
concurrency:
# The concurrency group contains the workflow name and the branch name for
# pull requests or the commit hash for any other events.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
- run: pnpm i
- name: Get old version
id: old-version
run: |
PACKAGE_VERSION=$(cat apps/web/package.json | jq '.dependencies["@blocksuite/editor"]' | tr -d '"')
echo "old-version=${PACKAGE_VERSION}" >> $GITHUB_OUTPUT
- name: Update block-suite version
run: pnpm update:core
- name: Get new version
id: new-version
run: |
PACKAGE_VERSION=$(cat apps/web/package.json | jq '.dependencies["@blocksuite/editor"]' | tr -d '"')
echo "new-version=${PACKAGE_VERSION}" >> $GITHUB_OUTPUT
# https://github.com/actions-js/push
- name: Commit push
uses: actions-js/push@master
with:
github_token: '${{ secrets.GITHUB_TOKEN }}'
message: 'chore: bump blocksuite from ${{ steps.old-version.outputs.old-version }} to ${{ steps.new-version.outputs.new-version }}'
force: true
branch: refs/heads/bot/bump-core
# see https://github.com/repo-sync/pull-request
- name: Create Pull Request
uses: repo-sync/pull-request@v2
with:
source_branch: bot/bump-core
pr_title: 'Bump blocksuite to ${{ steps.new-version.outputs.new-version }}'
pr_body: 'Please carefully check the editor functionality before merging the PR.'
github_token: ${{ secrets.GITHUB_TOKEN }}

7
.gitignore vendored
View File

@@ -1,4 +1,11 @@
# See http://help.github.com/ignore-files/ for more about ignoring files. # See http://help.github.com/ignore-files/ for more about ignoring files.
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
# compiled output # compiled output
*dist *dist

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env sh #!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh" . "$(dirname -- "$0")/_/husky.sh"
pnpm exec lint-staged yarn exec lint-staged

2
.vscode/launch.json vendored
View File

@@ -2,7 +2,7 @@
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"command": "pnpm run dev", "command": "yarn run dev",
"name": "Run Dev", "name": "Run Dev",
"request": "launch", "request": "launch",
"type": "node-terminal" "type": "node-terminal"

View File

@@ -1,5 +1,5 @@
{ {
"eslint.packageManager": "pnpm", "eslint.packageManager": "yarn",
"editor.defaultFormatter": "esbenp.prettier-vscode", "editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true, "editor.formatOnSave": true,
"editor.formatOnSaveMode": "file", "editor.formatOnSaveMode": "file",
@@ -7,7 +7,7 @@
"blocksuite", "blocksuite",
"datacenter", "datacenter",
"livedemo", "livedemo",
"pnpm", "yarn",
"jwst", "jwst",
"testid", "testid",
"octobase", "octobase",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

15
.yarnrc.yml Normal file
View File

@@ -0,0 +1,15 @@
nmMode: hardlinks-local
nodeLinker: node-modules
npmAuthToken: '${NODE_AUTH_TOKEN:-NONE}'
npmPublishAccess: public
npmPublishRegistry: 'https://registry.npmjs.org'
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: '@yarnpkg/plugin-interactive-tools'
yarnPath: .yarn/releases/yarn-3.5.0.cjs

View File

@@ -16,12 +16,12 @@
"dependencies": { "dependencies": {
"@blocksuite/blocks": "0.5.0-20230320034723-8dfc65e", "@blocksuite/blocks": "0.5.0-20230320034723-8dfc65e",
"@blocksuite/editor": "0.5.0-20230320034723-8dfc65e", "@blocksuite/editor": "0.5.0-20230320034723-8dfc65e",
"@blocksuite/icons": "2.0.17", "@blocksuite/icons": "2.0.23",
"@blocksuite/store": "0.5.0-20230320034723-8dfc65e", "@blocksuite/store": "0.5.0-20230320034723-8dfc65e",
"@emotion/react": "^11.10.6", "@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6", "@emotion/styled": "^11.10.6",
"@tauri-apps/api": "^1.2.0", "@tauri-apps/api": "^1.2.0",
"json-schema-to-typescript": "^11.0.5", "json-schema-to-typescript": "^12.0.0",
"lib0": "^0.2.69", "lib0": "^0.2.69",
"next": "=13.2.3", "next": "=13.2.3",
"react": "^18.2.0", "react": "^18.2.0",
@@ -34,13 +34,13 @@
"@types/node": "^18.15.3", "@types/node": "^18.15.3",
"@types/react": "^18.0.28", "@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11", "@types/react-dom": "^18.0.11",
"esbuild": "^0.17.8", "esbuild": "^0.17.12",
"lit": "^2.6.1", "lit": "^2.6.1",
"prettier": "2.8.4", "prettier": "2.8.5",
"rimraf": "^4.1.3", "rimraf": "^4.4.0",
"typescript": "^5.0.2", "typescript": "^5.0.2",
"typesync": "^0.10.0", "typesync": "^0.10.0",
"vite": "^4.2.0", "vite": "^4.2.0",
"zx": "^7.2.0" "zx": "^7.2.1"
} }
} }

View File

@@ -32,12 +32,11 @@
"@electron/rebuild": "^3.2.10", "@electron/rebuild": "^3.2.10",
"dts-for-context-bridge": "^0.7.1", "dts-for-context-bridge": "^0.7.1",
"electron": "23.1.4", "electron": "23.1.4",
"esbuild": "^0.17.8", "esbuild": "^0.17.12",
"zx": "^7.2.0" "zx": "^7.2.1"
}, },
"dependencies": { "dependencies": {
"cross-env": "7.0.3", "cross-env": "7.0.3",
"electron-window-state": "^5.0.3" "electron-window-state": "^5.0.3"
}, }
"packageManager": "yarn@3.4.1"
} }

File diff suppressed because it is too large Load Diff

View File

@@ -57,7 +57,7 @@ const nextConfig = {
experimental: { experimental: {
swcPlugins: [ swcPlugins: [
process.env.COVERAGE === 'true' && ['swc-plugin-coverage-instrument', {}], process.env.COVERAGE === 'true' && ['swc-plugin-coverage-instrument', {}],
['@swc-jotai/debug-label', {}], // ['@swc-jotai/debug-label', {}],
// ['@swc-jotai/react-refresh', {}], // ['@swc-jotai/react-refresh', {}],
].filter(Boolean), ].filter(Boolean),
}, },

View File

@@ -24,34 +24,33 @@
"@emotion/server": "^11.10.0", "@emotion/server": "^11.10.0",
"@emotion/styled": "^11.10.6", "@emotion/styled": "^11.10.6",
"@mui/material": "^5.11.13", "@mui/material": "^5.11.13",
"cmdk": "^0.1.22", "cmdk": "^0.2.0",
"css-spring": "^4.1.0", "css-spring": "^4.1.0",
"dayjs": "^1.11.7", "dayjs": "^1.11.7",
"jotai": "^2.0.3", "jotai": "^2.0.3",
"jotai-devtools": "^0.2.0",
"lit": "^2.6.1", "lit": "^2.6.1",
"lottie-web": "^5.10.2", "lottie-web": "^5.10.2",
"next-themes": "^0.2.1", "next-themes": "^0.2.1",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-is": "^18.2.0", "react-is": "^18.2.0",
"swr": "^2.0.4", "swr": "^2.1.0",
"y-indexeddb": "^9.0.9", "y-indexeddb": "^9.0.9",
"y-protocols": "^1.0.5", "y-protocols": "^1.0.5",
"yjs": "^13.5.50", "yjs": "^13.5.50",
"zod": "^3.21.3" "zod": "^3.21.4"
}, },
"devDependencies": { "devDependencies": {
"@perfsee/webpack": "^1.3.0", "@perfsee/webpack": "^1.5.0",
"@redux-devtools/extension": "^3.2.5", "@redux-devtools/extension": "^3.2.5",
"@swc-jotai/debug-label": "^0.0.6", "@swc-jotai/debug-label": "^0.0.9",
"@swc-jotai/react-refresh": "^0.0.4", "@swc-jotai/react-refresh": "^0.0.7",
"@types/react": "^18.0.28", "@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11", "@types/react-dom": "^18.0.11",
"@types/webpack-env": "^1.18.0", "@types/webpack-env": "^1.18.0",
"dotenv": "^16.0.3", "dotenv": "^16.0.3",
"eslint": "^8.36.0", "eslint": "^8.36.0",
"eslint-config-next": "^13.2.3", "eslint-config-next": "^13.2.4",
"next": "=13.2.3", "next": "=13.2.3",
"next-debug-local": "^0.1.5", "next-debug-local": "^0.1.5",
"next-router-mock": "^0.9.2", "next-router-mock": "^0.9.2",

View File

@@ -5,12 +5,11 @@ import { createI18n, I18nextProvider } from '@affine/i18n';
import type { EmotionCache } from '@emotion/cache'; import type { EmotionCache } from '@emotion/cache';
import { CacheProvider } from '@emotion/react'; import { CacheProvider } from '@emotion/react';
import { Provider } from 'jotai'; import { Provider } from 'jotai';
import { useAtomsDebugValue } from 'jotai-devtools';
import type { AppProps } from 'next/app'; import type { AppProps } from 'next/app';
import Head from 'next/head'; import Head from 'next/head';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import type { ReactElement } from 'react'; import type { ReactElement } from 'react';
import React, { memo, Suspense, useEffect, useMemo } from 'react'; import React, { Suspense, useEffect, useMemo } from 'react';
import { jotaiStore } from '../atoms'; import { jotaiStore } from '../atoms';
import { AffineErrorBoundary } from '../components/affine/affine-error-eoundary'; import { AffineErrorBoundary } from '../components/affine/affine-error-eoundary';
@@ -30,11 +29,6 @@ type AppPropsWithLayout = AppProps & {
const EmptyLayout = (page: ReactElement) => page; const EmptyLayout = (page: ReactElement) => page;
const DebugAtoms = memo(function DebugAtoms() {
useAtomsDebugValue();
return null;
});
const clientSideEmotionCache = createEmotionCache(); const clientSideEmotionCache = createEmotionCache();
const helmetContext = {}; const helmetContext = {};
@@ -58,7 +52,6 @@ const App = function App({
return ( return (
<CacheProvider value={emotionCache}> <CacheProvider value={emotionCache}>
<I18nextProvider i18n={i18n}> <I18nextProvider i18n={i18n}>
<DebugAtoms />
<MessageCenter /> <MessageCenter />
<AffineErrorBoundary router={useRouter()}> <AffineErrorBoundary router={useRouter()}>
<Suspense fallback={<PageLoading key="RootPageLoading" />}> <Suspense fallback={<PageLoading key="RootPageLoading" />}>

View File

@@ -27,7 +27,7 @@ pnpm dev:app
## Build ## Build
To build the desktop client application, run `pnpm build:app` in `apps/desktop`. To build the desktop client application, run `yarn build:app` in `apps/desktop`.
Once the build is complete, you can find the paths to the binaries in the terminal output. Once the build is complete, you can find the paths to the binaries in the terminal output.
``` ```

View File

@@ -4,26 +4,29 @@
"private": true, "private": true,
"author": "toeverything", "author": "toeverything",
"license": "MPL-2.0", "license": "MPL-2.0",
"workspaces": [
"apps/*",
"packages/*"
],
"scripts": { "scripts": {
"dev": "pnpm --filter @affine/app dev", "dev": "yarn workspace @affine/app dev",
"dev:ac": "NODE_API_SERVER=ac pnpm --filter @affine/app dev", "dev:ac": "NODE_API_SERVER=ac yarn workspace @affine/app dev",
"dev:local": "NODE_API_SERVER=local pnpm --filter @affine/app dev", "dev:local": "NODE_API_SERVER=local yarn workspace @affine/app dev",
"dev:app": "pnpm --filter @affine/electron dev:app", "dev:app": "yarn workspace @affine/electron dev:app",
"build": "pnpm --filter @affine/app build", "build": "yarn workspace @affine/app build",
"build:client": "pnpm --filter @affine/client-app build:app", "build:client": "yarn workspace @affine/client-app build:app",
"build:storybook": "pnpm -r build-storybook", "build:storybook": "yarn workspace @affine/component build-storybook",
"export": "pnpm --filter @affine/app export", "export": "yarn workspace @affine/app export",
"start": "pnpm --filter @affine/app start", "start": "yarn workspace @affine/app start",
"lint": "eslint . --ext .js,mjs,.ts,.tsx", "lint": "eslint . --ext .js,mjs,.ts,.tsx",
"lint:fix": "pnpm lint --fix", "lint:fix": "yarn lint --fix",
"test": "playwright test", "test": "playwright test",
"test:coverage": "COVERAGE=true pnpm test -- --forbid-only", "test:coverage": "COVERAGE=true yarn test --forbid-only",
"test:unit": "vitest --run", "test:unit": "vitest --run",
"test:unit:ui": "vitest --ui", "test:unit:ui": "vitest --ui",
"test:unit:coverage": "vitest run --coverage", "test:unit:coverage": "vitest run --coverage",
"postinstall": "husky install", "postinstall": "husky install",
"notify": "node scripts/notify.mjs", "notify": "node scripts/notify.mjs"
"update:core": "pnpm up '@blocksuite/*@nightly' !@blocksuite/icons -r"
}, },
"lint-staged": { "lint-staged": {
"*": "prettier --write --ignore-unknown", "*": "prettier --write --ignore-unknown",
@@ -38,7 +41,7 @@
"@typescript-eslint/eslint-plugin": "^5.55.0", "@typescript-eslint/eslint-plugin": "^5.55.0",
"@typescript-eslint/parser": "^5.55.0", "@typescript-eslint/parser": "^5.55.0",
"@vitejs/plugin-react": "^3.1.0", "@vitejs/plugin-react": "^3.1.0",
"@vitest/coverage-istanbul": "^0.28.5", "@vitest/coverage-istanbul": "^0.29.3",
"@vitest/ui": "^0.29.3", "@vitest/ui": "^0.29.3",
"eslint": "^8.36.0", "eslint": "^8.36.0",
"eslint-config-prettier": "^8.7.0", "eslint-config-prettier": "^8.7.0",
@@ -53,28 +56,13 @@
"husky": "^8.0.3", "husky": "^8.0.3",
"lint-staged": "^13.2.0", "lint-staged": "^13.2.0",
"nyc": "^15.1.0", "nyc": "^15.1.0",
"prettier": "^2.8.4", "prettier": "^2.8.5",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"typescript": "^5.0.2", "typescript": "^5.0.2",
"vite": "^4.2.0", "vite": "^4.2.0",
"vitest": "^0.28.5", "vitest": "^0.29.3",
"vitest-fetch-mock": "^0.2.2" "vitest-fetch-mock": "^0.2.2"
}, },
"pnpm": { "packageManager": "yarn@3.5.0"
"patchedDependencies": {
"@tauri-apps/api@1.2.0": "patches/@tauri-apps__api@1.2.0.patch"
},
"overrides": {
"react-is": "^18.2.0",
"@storybook/addons": "^7.0.0-rc.1",
"@storybook/api": "^7.0.0-rc.1",
"@storybook/components": "^7.0.0-rc.1",
"@storybook/core-events": "^7.0.0-rc.1",
"@storybook/global": "^5.0.0",
"@storybook/theming": "^7.0.0-rc.1",
"jest-mock": "^29.5.0"
}
},
"packageManager": "pnpm@7.28.0"
} }

View File

@@ -39,7 +39,7 @@
"@storybook/addon-interactions": "7.0.0-rc.1", "@storybook/addon-interactions": "7.0.0-rc.1",
"@storybook/addon-links": "7.0.0-rc.1", "@storybook/addon-links": "7.0.0-rc.1",
"@storybook/builder-vite": "7.0.0-rc.1", "@storybook/builder-vite": "7.0.0-rc.1",
"@storybook/jest": "0.0.11-next.0", "@storybook/jest": "0.0.10",
"@storybook/react": "7.0.0-rc.1", "@storybook/react": "7.0.0-rc.1",
"@storybook/react-vite": "7.0.0-rc.1", "@storybook/react-vite": "7.0.0-rc.1",
"@storybook/test-runner": "0.10.0-next.11", "@storybook/test-runner": "0.10.0-next.11",
@@ -47,7 +47,7 @@
"@types/react": "^18.0.28", "@types/react": "^18.0.28",
"@types/react-dom": "18.0.11", "@types/react-dom": "18.0.11",
"@vitejs/plugin-react": "^3.1.0", "@vitejs/plugin-react": "^3.1.0",
"jest-mock": "^28.1.3", "jest-mock": "^29.5.0",
"storybook": "7.0.0-rc.1", "storybook": "7.0.0-rc.1",
"storybook-dark-mode-v7": "3.0.0-alpha.0", "storybook-dark-mode-v7": "3.0.0-alpha.0",
"typescript": "^5.0.2", "typescript": "^5.0.2",

View File

@@ -1,75 +0,0 @@
import type { GetBlob, PutBlob } from '../ipc/types/blob';
import type {
GetDocumentParameter,
GetDocumentResponse,
YDocumentUpdate,
} from '../ipc/types/document';
import type { CreateUser, GetUserParameters, User } from '../ipc/types/user';
import type {
CreateWorkspace,
CreateWorkspaceResult,
GetWorkspace,
GetWorkspaceResult,
GetWorkspaces,
GetWorkspacesResult,
} from '../ipc/types/workspace';
export const updateYDocument = async (parameters: YDocumentUpdate) =>
await true;
export const getYDocument = async (
parameters: GetDocumentParameter
): Promise<GetDocumentResponse> =>
await {
updates: [],
};
export const createWorkspace = async (
parameters: CreateWorkspace
): Promise<CreateWorkspaceResult> => await { id: 'xxx', name: 'xxx' };
export const getWorkspaces = async (
parameters: GetWorkspaces
): Promise<GetWorkspacesResult> =>
await {
workspaces: [],
};
export const getWorkspace = async (
parameters: GetWorkspace
): Promise<GetWorkspaceResult> =>
await {
workspace: {
created_at: 0,
id: '',
member_count: 1,
public: true,
type: 0,
},
};
export const putBlob = async (parameters: PutBlob): Promise<string> =>
await 'path/xxx';
export const getBlob = async (parameters: GetBlob): Promise<number[]> =>
await [];
/**
* This will create a private workspace too.
* @returns
*/
export const createUser = async (parameters: CreateUser): Promise<User> =>
await {
created_at: 0,
id: '1',
email: 'xxx@xxx.xxx',
name: 'xxx',
};
export const getUser = async (parameters: GetUserParameters): Promise<User> =>
await {
created_at: 0,
id: '1',
email: 'xxx@xxx.xxx',
name: 'xxx',
};

View File

@@ -1,55 +0,0 @@
import 'fake-indexeddb/auto';
import { describe, expect, test } from 'vitest';
import { MessageCenter } from '../../../message';
import { WorkspaceUnitCollection } from '../../../workspace-unit-collection';
import { TauriIPCProvider } from '..';
import * as ipcMethods from './mock-apis';
describe('tauri-ipc provider', async () => {
const workspaceMetaCollection = new WorkspaceUnitCollection();
const provider = new TauriIPCProvider({
workspaces: workspaceMetaCollection.createScope(),
messageCenter: new MessageCenter(),
});
provider.init(ipcMethods);
const workspaceName = 'workspace-test';
let workspaceId: string | undefined;
test('create workspace', async () => {
const workspaceUnit = await provider.createWorkspace({
name: workspaceName,
});
workspaceId = workspaceUnit?.id;
expect(workspaceMetaCollection.workspaces.length).toEqual(1);
expect(workspaceMetaCollection.workspaces[0].name).toEqual(workspaceName);
});
test('workspace list', async () => {
const workspacesMetaCollection1 = new WorkspaceUnitCollection();
const provider1 = new TauriIPCProvider({
workspaces: workspacesMetaCollection1.createScope(),
messageCenter: new MessageCenter(),
});
provider1.init(ipcMethods);
await provider1.getUserInfo();
await provider1.loadWorkspaces();
expect(workspacesMetaCollection1.workspaces.length).toEqual(0);
await provider1.createWorkspace({
name: workspaceName,
});
expect(workspacesMetaCollection1.workspaces[0].name).toEqual(workspaceName);
expect(workspacesMetaCollection1.workspaces[0].id).toEqual(workspaceId);
});
test('update workspace', async () => {
await provider.updateWorkspaceMeta(workspaceId!, {
name: '1111',
});
expect(workspaceMetaCollection.workspaces[0].name).toEqual('1111');
});
});

View File

@@ -6,7 +6,7 @@
"next": "=13.2.3", "next": "=13.2.3",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"zod": "^3.21.3" "zod": "^3.21.4"
}, },
"dependencies": { "dependencies": {
"@blocksuite/global": "0.5.0-20230320034723-8dfc65e", "@blocksuite/global": "0.5.0-20230320034723-8dfc65e",

View File

@@ -17,7 +17,7 @@
"scripts": { "scripts": {
"build": "tsc --project ./tsconfig.json", "build": "tsc --project ./tsconfig.json",
"sync-languages": "NODE_OPTIONS=--experimental-fetch ts-node-esm src/scripts/sync.ts", "sync-languages": "NODE_OPTIONS=--experimental-fetch ts-node-esm src/scripts/sync.ts",
"sync-languages:check": "pnpm run sync-languages --check", "sync-languages:check": "yarn run sync-languages --check",
"download-resources": "NODE_OPTIONS=--experimental-fetch ts-node-esm src/scripts/download.ts" "download-resources": "NODE_OPTIONS=--experimental-fetch ts-node-esm src/scripts/download.ts"
}, },
"keywords": [], "keywords": [],
@@ -35,7 +35,7 @@
"@types/node": "^18.15.3", "@types/node": "^18.15.3",
"@types/prettier": "^2.7.2", "@types/prettier": "^2.7.2",
"next": "=13.2.3", "next": "=13.2.3",
"prettier": "^2.8.4", "prettier": "^2.8.5",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"typescript": "^5.0.2" "typescript": "^5.0.2"

View File

@@ -91,7 +91,7 @@ const main = async () => {
console.log('Generating meta data...'); console.log('Generating meta data...');
const code = `// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. const code = `// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
// Run \`pnpm run download-resources\` to regenerate. // Run \`yarn run download-resources\` to regenerate.
// To overwrite this, please overwrite download.ts script. // To overwrite this, please overwrite download.ts script.
${availableLanguages ${availableLanguages
.map( .map(

File diff suppressed because one or more lines are too long

View File

@@ -56,7 +56,7 @@ const config: PlaywrightTestConfig = {
}, },
}, },
{ {
command: 'pnpm build && pnpm start -p 8080', command: 'yarn build && yarn start -p 8080',
port: 8080, port: 8080,
timeout: 120 * 1000, timeout: 120 * 1000,
reuseExistingServer: !process.env.CI, reuseExistingServer: !process.env.CI,

14299
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +0,0 @@
packages:
# apps folder for multiple platform clients
- 'apps/*'
- '!apps/electron'
- '!apps/desktop'
# all packages in direct subdirs of packages/
- 'packages/*'

20645
yarn.lock Normal file

File diff suppressed because it is too large Load Diff