From ed1ca53236c3360929fa46af7e31fe8c8d7a1fbc Mon Sep 17 00:00:00 2001 From: forehalo Date: Thu, 19 Dec 2024 18:24:09 +0800 Subject: [PATCH] chore: update commands --- .devcontainer/build.sh | 4 +- .devcontainer/devcontainer.json | 3 +- .github/actions/build-rust/action.yml | 2 +- .github/actions/copilot-test/action.yml | 2 +- .github/actions/server-test-env/action.yml | 6 +-- .github/workflows/build-images.yml | 10 ++-- .github/workflows/build-test.yml | 36 ++++++------- .github/workflows/copilot-test.yml | 4 +- .github/workflows/pr-title-lint.yml | 2 +- .github/workflows/release-desktop.yml | 14 ++--- .github/workflows/release-mobile.yml | 12 ++--- docs/BUILDING.md | 4 +- docs/building-desktop-client-app.md | 10 ++-- docs/developing-server.md | 2 +- package.json | 2 +- packages/backend/server/README.md | 2 +- packages/backend/server/package.json | 21 ++------ packages/frontend/apps/android/README.md | 6 +-- packages/frontend/apps/electron/README.md | 2 +- packages/frontend/apps/ios/README.md | 10 ++-- tools/scripts/src/run.ts | 59 +++++++++------------- tools/scripts/src/webpack/html-plugin.ts | 16 ++++-- 22 files changed, 107 insertions(+), 122 deletions(-) diff --git a/.devcontainer/build.sh b/.devcontainer/build.sh index 097273e020d13..47940963b8748 100644 --- a/.devcontainer/build.sh +++ b/.devcontainer/build.sh @@ -9,7 +9,7 @@ corepack prepare yarn@stable --activate yarn install # Build Server Dependencies -yarn workspace @affine/server-native build +yarn affine @affine/server-native build # Create database -yarn workspace @affine/server prisma db push +yarn affine @affine/server prisma db push diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 40d84f828a074..191a02c0e95e5 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -21,6 +21,5 @@ } }, "updateContentCommand": "bash ./.devcontainer/build.sh", - "postCreateCommand": "bash ./.devcontainer/setup-user.sh", - "postStartCommand": ["yarn dev", "yarn workspace @affine/server dev"] + "postCreateCommand": "bash ./.devcontainer/setup-user.sh" } diff --git a/.github/actions/build-rust/action.yml b/.github/actions/build-rust/action.yml index 3a36e64050f11..36103e18b0e52 100644 --- a/.github/actions/build-rust/action.yml +++ b/.github/actions/build-rust/action.yml @@ -46,6 +46,6 @@ runs: - name: Build shell: bash run: | - yarn workspace ${{ inputs.package }} build --target ${{ inputs.target }} --use-napi-cross + yarn affine ${{ inputs.package }} build --target ${{ inputs.target }} --use-napi-cross env: DEBUG: 'napi:*' diff --git a/.github/actions/copilot-test/action.yml b/.github/actions/copilot-test/action.yml index 6c89bbde3971f..a9c95250621f4 100644 --- a/.github/actions/copilot-test/action.yml +++ b/.github/actions/copilot-test/action.yml @@ -3,7 +3,7 @@ description: 'Run Copilot E2E Test' inputs: script: description: 'Script to run' - default: 'yarn workspace @affine-test/affine-cloud-copilot e2e --forbid-only' + default: 'yarn affine @affine-test/affine-cloud-copilot e2e --forbid-only' required: false openai-key: description: 'OpenAI secret key' diff --git a/.github/actions/server-test-env/action.yml b/.github/actions/server-test-env/action.yml index 22bfe52172c37..5e8959fc4a8d6 100644 --- a/.github/actions/server-test-env/action.yml +++ b/.github/actions/server-test-env/action.yml @@ -18,6 +18,6 @@ runs: env: NODE_ENV: test run: | - yarn workspace @affine/server exec prisma generate - yarn workspace @affine/server exec prisma db push - yarn workspace @affine/server data-migration run + yarn affine @affine/server prisma generate + yarn affine @affine/server prisma db push + yarn affine @affine/server data-migration run diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml index 326fc85803d14..25a70f9ab8f86 100644 --- a/.github/workflows/build-images.yml +++ b/.github/workflows/build-images.yml @@ -27,7 +27,7 @@ jobs: electron-install: false extra-flags: workspaces focus @affine/server - name: Build Server - run: yarn workspace @affine/server build + run: yarn affine @affine/server build - name: Upload server dist uses: actions/upload-artifact@v4 with: @@ -47,7 +47,7 @@ jobs: - name: Setup Node.js uses: ./.github/actions/setup-node - name: Build Core - run: yarn workspace @affine/web build + run: yarn affine @affine/web build env: R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }} R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} @@ -80,7 +80,7 @@ jobs: - name: Setup Node.js uses: ./.github/actions/setup-node - name: Build Admin - run: yarn workspace @affine/admin build + run: yarn affine @affine/admin build env: R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }} R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} @@ -112,7 +112,7 @@ jobs: - name: Setup Node.js uses: ./.github/actions/setup-node - name: Build Mobile - run: yarn workspace @affine/mobile build + run: yarn affine @affine/mobile build env: R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }} R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} @@ -257,7 +257,7 @@ jobs: yarn workspaces focus @affine/server --production - name: Generate Prisma client - run: yarn workspace @affine/server prisma generate + run: yarn affine @affine/server prisma generate - name: Setup Version id: version diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 6a22f9bf073aa..43b99df4d534b 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -89,7 +89,7 @@ jobs: electron-install: false full-cache: true - name: Run i18n codegen - run: yarn workspace @affine/i18n build + run: yarn affine @affine/i18n build - name: Run ESLint run: yarn lint:eslint --max-warnings=0 - name: Run Prettier @@ -132,7 +132,7 @@ jobs: full-cache: true - name: Run playwright tests - run: yarn workspace @affine-test/affine-local e2e --forbid-only --shard=${{ matrix.shard }}/${{ strategy.job-total }} + run: yarn affine @affine-test/affine-local e2e --forbid-only --shard=${{ matrix.shard }}/${{ strategy.job-total }} - name: Upload test results if: ${{ failure() }} @@ -162,7 +162,7 @@ jobs: full-cache: true - name: Run playwright tests - run: yarn workspace @affine-test/affine-mobile e2e --forbid-only --shard=${{ matrix.shard }}/${{ strategy.job-total }} + run: yarn affine @affine-test/affine-mobile e2e --forbid-only --shard=${{ matrix.shard }}/${{ strategy.job-total }} - name: Upload test results if: ${{ failure() }} @@ -341,7 +341,7 @@ jobs: uses: ./.github/actions/server-test-env - name: Run server tests - run: yarn workspace @affine/server test:coverage + run: yarn affine @affine/server test:coverage env: CARGO_TARGET_DIR: '${{ github.workspace }}/target' COPILOT_OPENAI_API_KEY: 'use_fake_openai_api_key' @@ -444,7 +444,7 @@ jobs: - name: Run server tests if: ${{ steps.check-blocksuite-update.outputs.skip != 'true' || steps.apifilter.outputs.changed == 'true' }} - run: yarn workspace @affine/server test:copilot:coverage --forbid-only + run: yarn affine @affine/server test:copilot:coverage --forbid-only env: CARGO_TARGET_DIR: '${{ github.workspace }}/target' COPILOT_OPENAI_API_KEY: ${{ secrets.COPILOT_OPENAI_API_KEY }} @@ -534,7 +534,7 @@ jobs: if: ${{ steps.check-blocksuite-update.outputs.skip != 'true' || steps.e2efilter.outputs.changed == 'true' }} uses: ./.github/actions/copilot-test with: - script: yarn workspace @affine-test/affine-cloud-copilot e2e --forbid-only --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} + script: yarn affine @affine-test/affine-cloud-copilot e2e --forbid-only --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} openai-key: ${{ secrets.COPILOT_OPENAI_API_KEY }} fal-key: ${{ secrets.COPILOT_FAL_API_KEY }} @@ -551,19 +551,19 @@ jobs: matrix: tests: - name: 'Server E2E Test 1/3' - script: yarn workspace @affine-test/affine-cloud e2e --forbid-only --shard=1/3 + script: yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=1/3 - name: 'Server E2E Test 2/3' - script: yarn workspace @affine-test/affine-cloud e2e --forbid-only --shard=2/3 + script: yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=2/3 - name: 'Server E2E Test 3/3' - script: yarn workspace @affine-test/affine-cloud e2e --forbid-only --shard=3/3 + script: yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=3/3 - name: 'Server Desktop E2E Test' script: | - yarn workspace @affine/electron build:dev + yarn affine @affine/electron build:dev # Workaround for Electron apps failing to initialize on Ubuntu 24.04 due to AppArmor restrictions # Disables unprivileged user namespaces restriction to allow Electron apps to run # Reference: https://github.com/electron/electron/issues/42510 sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 - xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn workspace @affine-test/affine-desktop-cloud e2e + xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn affine @affine-test/affine-desktop-cloud e2e needs: - build-server-native - build-native @@ -693,7 +693,7 @@ jobs: - name: Run unit tests if: ${{ matrix.spec.test }} shell: bash - run: yarn workspace @affine/electron vitest + run: yarn affine @affine/electron vitest - name: Download web artifact uses: ./.github/actions/download-web @@ -701,7 +701,7 @@ jobs: path: packages/frontend/apps/electron/resources/web-static - name: Build Desktop Layers - run: yarn workspace @affine/electron build + run: yarn affine @affine/electron build - name: Run desktop tests if: ${{ matrix.spec.os == 'ubuntu-latest' }} @@ -710,11 +710,11 @@ jobs: # Disables unprivileged user namespaces restriction to allow Electron apps to run # Reference: https://github.com/electron/electron/issues/42510 sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 - xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn workspace @affine-test/affine-desktop e2e + xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn affine @affine-test/affine-desktop e2e - name: Run desktop tests if: ${{ matrix.spec.test && matrix.spec.os != 'ubuntu-latest' }} - run: yarn workspace @affine-test/affine-desktop e2e + run: yarn affine @affine-test/affine-desktop e2e - name: Make bundle (macOS) if: ${{ matrix.spec.target == 'aarch64-apple-darwin' }} @@ -722,7 +722,7 @@ jobs: SKIP_BUNDLE: true SKIP_WEB_BUILD: true HOIST_NODE_MODULES: 1 - run: yarn workspace @affine/electron package --platform=darwin --arch=arm64 + run: yarn affine @affine/electron package --platform=darwin --arch=arm64 - name: Make Bundle (Linux) run: | @@ -732,7 +732,7 @@ jobs: flatpak update # some flatpak deps need git protocol.file.allow git config --global protocol.file.allow always - yarn workspace @affine/electron make --platform=linux --arch=x64 + yarn affine @affine/electron make --platform=linux --arch=x64 if: ${{ matrix.spec.target == 'x86_64-unknown-linux-gnu' }} env: SKIP_WEB_BUILD: 1 @@ -741,7 +741,7 @@ jobs: - name: Output check if: ${{ matrix.spec.os == 'macos-14' && matrix.spec.arch == 'arm64' }} run: | - yarn workspace @affine/electron exec node --loader ts-node/esm/transpile-only ./scripts/macos-arm64-output-check.ts + yarn affine @affine/electron exec node --loader ts-node/esm/transpile-only ./scripts/macos-arm64-output-check.ts - name: Upload test results if: ${{ failure() }} diff --git a/.github/workflows/copilot-test.yml b/.github/workflows/copilot-test.yml index 6f3cc8156fc6f..e330ca49f615a 100644 --- a/.github/workflows/copilot-test.yml +++ b/.github/workflows/copilot-test.yml @@ -82,7 +82,7 @@ jobs: uses: ./.github/actions/server-test-env - name: Run server tests - run: yarn workspace @affine/server test:copilot:coverage --forbid-only + run: yarn affine @affine/server test:copilot:coverage --forbid-only env: CARGO_TARGET_DIR: '${{ github.workspace }}/target' COPILOT_OPENAI_API_KEY: ${{ secrets.COPILOT_OPENAI_API_KEY }} @@ -147,7 +147,7 @@ jobs: - name: Run Copilot E2E Test ${{ matrix.shardIndex }}/${{ matrix.shardTotal }} uses: ./.github/actions/copilot-test with: - script: yarn workspace @affine-test/affine-cloud-copilot e2e --forbid-only --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} + script: yarn affine @affine-test/affine-cloud-copilot e2e --forbid-only --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} openai-key: ${{ secrets.COPILOT_OPENAI_API_KEY }} fal-key: ${{ secrets.COPILOT_FAL_API_KEY }} diff --git a/.github/workflows/pr-title-lint.yml b/.github/workflows/pr-title-lint.yml index a6a6790fd2eaa..3b1bd78231468 100644 --- a/.github/workflows/pr-title-lint.yml +++ b/.github/workflows/pr-title-lint.yml @@ -28,4 +28,4 @@ jobs: - name: Check PR title env: TITLE: ${{ github.event.pull_request.title }} - run: echo "$TITLE" | yarn workspace @affine/commitlint-config commitlint -g ./.commitlintrc.json + run: echo "$TITLE" | yarn affine @affine/commitlint-config commitlint -g ./.commitlintrc.json diff --git a/.github/workflows/release-desktop.yml b/.github/workflows/release-desktop.yml index 2a9b32ca0adb3..dfbef224bc6d8 100644 --- a/.github/workflows/release-desktop.yml +++ b/.github/workflows/release-desktop.yml @@ -52,7 +52,7 @@ jobs: - name: Setup @sentry/cli uses: ./.github/actions/setup-sentry - name: generate-assets - run: yarn workspace @affine/electron generate-assets + run: yarn affine @affine/electron generate-assets env: SENTRY_ORG: ${{ secrets.SENTRY_ORG }} SENTRY_PROJECT: 'affine' @@ -122,7 +122,7 @@ jobs: path: packages/frontend/apps/electron/resources/web-static - name: Build Desktop Layers - run: yarn workspace @affine/electron build + run: yarn affine @affine/electron build - name: Signing By Apple Developer ID if: ${{ matrix.spec.platform == 'darwin' }} @@ -142,7 +142,7 @@ jobs: git config --global protocol.file.allow always - name: make - run: yarn workspace @affine/electron make --platform=${{ matrix.spec.platform }} --arch=${{ matrix.spec.arch }} + run: yarn affine @affine/electron make --platform=${{ matrix.spec.platform }} --arch=${{ matrix.spec.arch }} env: SKIP_WEB_BUILD: 1 HOIST_NODE_MODULES: 1 @@ -237,10 +237,10 @@ jobs: path: packages/frontend/apps/electron/resources/web-static - name: Build Desktop Layers - run: yarn workspace @affine/electron build + run: yarn affine @affine/electron build - name: package - run: yarn workspace @affine/electron package --platform=${{ matrix.spec.platform }} --arch=${{ matrix.spec.arch }} + run: yarn affine @affine/electron package --platform=${{ matrix.spec.platform }} --arch=${{ matrix.spec.arch }} env: SKIP_WEB_BUILD: 1 HOIST_NODE_MODULES: 1 @@ -315,10 +315,10 @@ jobs: 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 }} + run: yarn affine @affine/electron make-squirrel --platform=${{ matrix.spec.platform }} --arch=${{ matrix.spec.arch }} - name: Make nsis.windows installer - run: yarn workspace @affine/electron make-nsis --platform=${{ matrix.spec.platform }} --arch=${{ matrix.spec.arch }} + run: yarn affine @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/apps/electron/out/${{ env.BUILD_TYPE }}/make/* -DestinationPath archive.zip diff --git a/.github/workflows/release-mobile.yml b/.github/workflows/release-mobile.yml index 19a6ce1ccb829..e600c2116b13e 100644 --- a/.github/workflows/release-mobile.yml +++ b/.github/workflows/release-mobile.yml @@ -68,7 +68,7 @@ jobs: - name: Setup @sentry/cli uses: ./.github/actions/setup-sentry - name: Build Mobile - run: yarn workspace @affine/ios build + run: yarn affine @affine/ios build env: PUBLIC_PATH: '/' MIXPANEL_TOKEN: ${{ secrets.MIXPANEL_TOKEN }} @@ -101,7 +101,7 @@ jobs: - name: Setup @sentry/cli uses: ./.github/actions/setup-sentry - name: Build Mobile - run: yarn workspace @affine/android build + run: yarn affine @affine/android build env: PUBLIC_PATH: '/' MIXPANEL_TOKEN: ${{ secrets.MIXPANEL_TOKEN }} @@ -138,7 +138,7 @@ jobs: hard-link-nm: false enableScripts: false - name: Cap sync - run: yarn workspace @affine/ios cap sync + run: yarn affine @affine/ios cap sync - name: Signing By Apple Developer ID uses: apple-actions/import-codesign-certs@v3 id: import-codesign-certs @@ -194,7 +194,7 @@ jobs: with: targets: 'aarch64-linux-android' - name: Cap sync - run: yarn workspace @affine/android cap sync + run: yarn affine @affine/android cap sync - uses: actions/setup-python@v5 with: python-version: '3.12' @@ -216,13 +216,13 @@ jobs: - name: Auto increment version code id: bump if: ${{ env.BUILD_TARGET == 'distribution' }} - run: yarn workspace @affine/playstore-auto-bump bump + run: yarn affine @affine/playstore-auto-bump bump env: GOOGLE_APPLICATION_CREDENTIALS: ${{ steps.auth.outputs.credentials_file_path }} - name: Build run: | echo -n "${{ env.AFFINE_ANDROID_SIGN_KEYSTORE }}" | base64 --decode > packages/frontend/apps/android/affine.keystore - yarn workspace @affine/android cap build android + yarn affine @affine/android cap build android env: AFFINE_ANDROID_KEYSTORE_PASSWORD: ${{ secrets.AFFINE_ANDROID_KEYSTORE_PASSWORD }} AFFINE_ANDROID_KEYSTORE_ALIAS_PASSWORD: ${{ secrets.AFFINE_ANDROID_KEYSTORE_ALIAS_PASSWORD }} diff --git a/docs/BUILDING.md b/docs/BUILDING.md index 110bba4d6bd99..59dfc6c73e6c3 100644 --- a/docs/BUILDING.md +++ b/docs/BUILDING.md @@ -87,13 +87,13 @@ 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) ``` -yarn workspace @affine/native build +yarn affine @affine/native build ``` ### Build Server Dependencies ```sh -yarn workspace @affine/server-native build +yarn affine @affine/server-native build ``` ## Testing diff --git a/docs/building-desktop-client-app.md b/docs/building-desktop-client-app.md index f7d631e1a6e8e..c73f3ec3f7b8f 100644 --- a/docs/building-desktop-client-app.md +++ b/docs/building-desktop-client-app.md @@ -46,7 +46,7 @@ Please refer to `Build Native Dependencies` section in [BUILDING.md](./BUILDING. On Mac & Linux ```shell -BUILD_TYPE=canary yarn workspace @affine/electron generate-assets +BUILD_TYPE=canary yarn affine @affine/electron generate-assets ``` On Windows (powershell) @@ -90,7 +90,7 @@ yarn install Note: you need to comment out `osxSign` and `osxNotarize` in `forge.config.js` to skip signing and notarizing the app. ```shell -BUILD_TYPE=canary SKIP_WEB_BUILD=1 HOIST_NODE_MODULES=1 yarn workspace @affine/electron make +BUILD_TYPE=canary SKIP_WEB_BUILD=1 HOIST_NODE_MODULES=1 yarn affine @affine/electron make ``` #### Windows @@ -101,9 +101,9 @@ Making the windows installer is a bit different. Right now we provide two instal $env:BUILD_TYPE="canary" $env:SKIP_WEB_BUILD=1 $env:HOIST_NODE_MODULES=1 -yarn workspace @affine/electron package -yarn workspace @affine/electron make-squirrel -yarn workspace @affine/electron make-nsis +yarn affine @affine/electron package +yarn affine @affine/electron make-squirrel +yarn affine @affine/electron make-nsis ``` Once the build is complete, you can find the paths to the binaries in the terminal output. diff --git a/docs/developing-server.md b/docs/developing-server.md index c85491017067d..19f85cbba68d0 100644 --- a/docs/developing-server.md +++ b/docs/developing-server.md @@ -18,7 +18,7 @@ docker compose -f ./.docker/dev/compose.yml up -d ```sh # build native -yarn workspace @affine/server-native build +yarn affine @affine/server-native build ``` ## Prepare dev environment diff --git a/package.json b/package.json index 17ab671b9e8dc..8149c41d862cc 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ }, "scripts": { "affine": "yarn workspace @affine-tools/scripts affine", - "af": "yarn workspace @affine-tools/scripts af", + "af": "yarn workspace @affine-tools/scripts affine", "dev": "yarn affine dev", "build": "yarn affine build", "lint:eslint": "cross-env NODE_OPTIONS=\"--max-old-space-size=8192\" eslint --report-unused-disable-directives-severity=off . --cache", diff --git a/packages/backend/server/README.md b/packages/backend/server/README.md index e2aafea95b3e1..57ae0868afeb0 100644 --- a/packages/backend/server/README.md +++ b/packages/backend/server/README.md @@ -11,7 +11,7 @@ yarn ### Build Native binding ```bash -yarn workspace @affine/server-native build +yarn affine @affine/server-native build ``` ### Run server diff --git a/packages/backend/server/package.json b/packages/backend/server/package.json index 8c985603380ee..5bf5442ec017f 100644 --- a/packages/backend/server/package.json +++ b/packages/backend/server/package.json @@ -9,15 +9,14 @@ }, "scripts": { "build": "tsc", - "start": "node --loader ts-node/esm/transpile-only.mjs ./src/index.ts", "dev": "nodemon ./src/index.ts", "test": "ava --concurrency 1 --serial", "test:copilot": "ava \"tests/**/copilot-*.spec.ts\"", "test:coverage": "c8 ava --concurrency 1 --serial", "test:copilot:coverage": "c8 ava --timeout=5m \"tests/**/copilot-*.spec.ts\"", - "postinstall": "prisma generate", - "data-migration": "NODE_ENV=script node --loader ts-node/esm/transpile-only.mjs ./src/data/index.ts", - "predeploy": "yarn prisma migrate deploy && node --import ./scripts/register.js ./dist/data/index.js run" + "data-migration": "NODE_ENV=script node ./src/data/index.ts", + "predeploy": "yarn prisma migrate deploy && node --import ./scripts/register.js ./dist/data/index.js run", + "postinstall": "prisma generate" }, "dependencies": { "@apollo/server": "^4.11.2", @@ -119,10 +118,7 @@ }, "workerThreads": false, "nodeArguments": [ - "--trace-sigint", - "--loader", - "ts-node/esm/transpile-only.mjs", - "--es-module-specifier-resolution=node" + "--trace-sigint" ], "watchMode": { "ignoreChanges": [ @@ -139,7 +135,6 @@ "./src/prelude.ts" ], "environmentVariables": { - "TS_NODE_PROJECT": "./tests/tsconfig.json", "NODE_ENV": "test", "MAILER_HOST": "0.0.0.0", "MAILER_PORT": "1025", @@ -152,12 +147,6 @@ }, "nodemonConfig": { "exec": "node", - "script": "./src/index.ts", - "nodeArgs": [ - "--loader", - "ts-node/esm.mjs", - "--es-module-specifier-resolution=node" - ], "ignore": [ "**/__tests__/**", "**/dist/**", @@ -166,8 +155,6 @@ "env": { "NODE_ENV": "development", "AFFINE_SERVER_EXTERNAL_URL": "http://localhost:8080", - "TS_NODE_TRANSPILE_ONLY": true, - "TS_NODE_PROJECT": "./tsconfig.json", "DEBUG": "affine:*", "FORCE_COLOR": true, "DEBUG_COLORS": true diff --git a/packages/frontend/apps/android/README.md b/packages/frontend/apps/android/README.md index 4ff2a00916d50..6d64273332825 100644 --- a/packages/frontend/apps/android/README.md +++ b/packages/frontend/apps/android/README.md @@ -5,6 +5,6 @@ AFFiNE Android app. ## Build - yarn install -- BUILD_TYPE=canary PUBLIC_PATH="/" yarn workspace @affine/android build -- yarn workspace @affine/android cap sync -- yarn workspace @affine/android cap open android +- BUILD_TYPE=canary PUBLIC_PATH="/" yarn affine @affine/android build +- yarn affine @affine/android cap sync +- yarn affine @affine/android cap open android diff --git a/packages/frontend/apps/electron/README.md b/packages/frontend/apps/electron/README.md index 0ac1c7a9e6f0e..22d848dafa769 100644 --- a/packages/frontend/apps/electron/README.md +++ b/packages/frontend/apps/electron/README.md @@ -7,7 +7,7 @@ To run AFFiNE Desktop Client Application locally, run the following commands: ```sh # in repo root yarn install -yarn workspace @affine/native build +yarn affine @affine/native build yarn dev # in packages/frontend/apps/electron diff --git a/packages/frontend/apps/ios/README.md b/packages/frontend/apps/ios/README.md index b8fcf843a26be..0fd8b5c5475c5 100644 --- a/packages/frontend/apps/ios/README.md +++ b/packages/frontend/apps/ios/README.md @@ -5,9 +5,9 @@ AFFiNE iOS app. ## Build - `yarn install` -- `BUILD_TYPE=canary PUBLIC_PATH="/" yarn workspace @affine/ios build` -- `yarn workspace @affine/ios cap sync` -- `yarn workspace @affine/ios cap open ios` +- `BUILD_TYPE=canary PUBLIC_PATH="/" yarn affine @affine/ios build` +- `yarn affine @affine/ios cap sync` +- `yarn affine @affine/ios cap open ios` ## Live Reload @@ -16,5 +16,5 @@ AFFiNE iOS app. - `yarn install` - `yarn dev` - select `ios` for the "Distribution" option -- `yarn workspace @affine/ios sync:dev` -- `yarn workspace @affine/ios cap open ios` +- `yarn affine @affine/ios sync:dev` +- `yarn affine @affine/ios cap open ios` diff --git a/tools/scripts/src/run.ts b/tools/scripts/src/run.ts index dc747d8794c7e..d9ae32f6879e8 100644 --- a/tools/scripts/src/run.ts +++ b/tools/scripts/src/run.ts @@ -5,7 +5,6 @@ import type { PackageName } from '@affine-tools/utils/workspace'; import { Option, PackageCommand } from './command'; interface RunScriptOptions { - ignoreMissingScript?: boolean; includeDependencies?: boolean; waitDependencies?: boolean; } @@ -54,53 +53,45 @@ export class RunCommand extends PackageCommand { validator: this.packageNameValidator, }); - script = Option.String({ required: true }); + args = Option.Proxy({ name: 'args', required: 1 }); async execute() { - await this.run(this.package, this.script, { + await this.run(this.package, this.args, { includeDependencies: this.deps, waitDependencies: true, }); } - async run(name: PackageName, script: string, opts: RunScriptOptions = {}) { - opts = { includeDependencies: false, ignoreMissingScript: false, ...opts }; + async run(name: PackageName, args: string[], opts: RunScriptOptions = {}) { + opts = { includeDependencies: false, ...opts }; const pkg = this.workspace.getPackage(name); - const scriptToRun = pkg.scripts[script]; + const script = args[0]; + const pkgScript = pkg.scripts[script]; - if (!scriptToRun) { - if (!opts.ignoreMissingScript) { - throw new Error( - `Script '${script}' is not found in ${pkg.join('package.json')} of package '${name}'. ` + if (pkgScript && pkgScript.startsWith('affine ')) { + if (opts.includeDependencies) { + this.logger.info( + `Running [${script}] script in dependencies of ${pkg.name}...` ); - } - - return; - } - if (opts.includeDependencies) { - this.logger.info( - `Running [${script}] script in dependencies of ${pkg.name}...` - ); - - await Promise.all( - pkg.deps.map(dep => { - this.logger.info(`Running [${script}] script in ${dep.name}...`); - return this.run(dep.name, script, { - ...opts, - // the dependency may not have the script - ignoreMissingScript: true, - }); - }) - ); - } + await Promise.all( + pkg.deps.map(dep => { + this.logger.info(`Running [${script}] script in ${dep.name}...`); + return this.run(dep.name, args, opts); + }) + ); + } - this.logger.info(`Running [${script}] script in ${pkg.name}...`); - if (scriptToRun.startsWith('affine ')) { - await this.cli.run([...scriptToRun.split(' ').slice(1), '-p', pkg.name]); + this.logger.info(`Running [${script}] script in ${pkg.name}...`); + await this.cli.run([ + ...pkgScript.split(' ').slice(1), + ...args.slice(1), + '-p', + pkg.name, + ]); } else { - await execAsync(name, `yarn run ${script}`, { + await execAsync(name, ['yarn', 'run', ...args], { cwd: pkg.path.value, env: { NODE_OPTIONS: `--experimental-specifier-resolution=node --import=${currentDir.join('../loader.js')}`, diff --git a/tools/scripts/src/webpack/html-plugin.ts b/tools/scripts/src/webpack/html-plugin.ts index 6fbde625dada1..677d3979f7b53 100644 --- a/tools/scripts/src/webpack/html-plugin.ts +++ b/tools/scripts/src/webpack/html-plugin.ts @@ -11,13 +11,21 @@ import webpack from 'webpack'; import type { BuildFlags } from './types.js'; -export const getPublicPath = (flags: BuildFlags) => { +export const getPublicPath = ( + flags: BuildFlags, + BUILD_CONFIG: BUILD_CONFIG_TYPE +) => { const { BUILD_TYPE } = process.env; if (typeof process.env.PUBLIC_PATH === 'string') { return process.env.PUBLIC_PATH; } - if (flags.mode === 'development') { + if ( + flags.mode === 'development' || + BUILD_CONFIG.distribution === 'desktop' || + BUILD_CONFIG.distribution === 'ios' || + BUILD_CONFIG.distribution === 'android' + ) { return '/'; } @@ -55,7 +63,7 @@ function getHTMLPluginOptions( flags: BuildFlags, BUILD_CONFIG: BUILD_CONFIG_TYPE ) { - const publicPath = getPublicPath(flags); + const publicPath = getPublicPath(flags, BUILD_CONFIG); const cdnOrigin = publicPath.startsWith('/') ? undefined : new URL(publicPath).origin; @@ -96,7 +104,7 @@ export function createHTMLPlugins( flags: BuildFlags, BUILD_CONFIG: BUILD_CONFIG_TYPE ): WebpackPluginInstance[] { - const publicPath = getPublicPath(flags); + const publicPath = getPublicPath(flags, BUILD_CONFIG); const globalErrorHandler = [ 'js/global-error-handler.js', readFileSync(currentDir.join('./error-handler.js').toString(), 'utf-8'),