mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
build: fix nx.json (#2951)
This commit is contained in:
20
.github/workflows/build.yml
vendored
20
.github/workflows/build.yml
vendored
@@ -153,8 +153,11 @@ jobs:
|
|||||||
uses: ./.github/actions/setup-rust
|
uses: ./.github/actions/setup-rust
|
||||||
with:
|
with:
|
||||||
target: 'x86_64-unknown-linux-gnu'
|
target: 'x86_64-unknown-linux-gnu'
|
||||||
|
- name: Build Storage
|
||||||
|
run: yarn build:storage
|
||||||
- name: Run server tests
|
- name: Run server tests
|
||||||
run: yarn nx test:coverage @affine/server
|
run: yarn test:coverage
|
||||||
|
working-directory: apps/server
|
||||||
env:
|
env:
|
||||||
CARGO_TARGET_DIR: '${{ github.workspace }}/target'
|
CARGO_TARGET_DIR: '${{ github.workspace }}/target'
|
||||||
DATABASE_URL: postgresql://affine:affine@localhost:5432/affine
|
DATABASE_URL: postgresql://affine:affine@localhost:5432/affine
|
||||||
@@ -358,7 +361,7 @@ jobs:
|
|||||||
run: yarn run build:plugins
|
run: yarn run build:plugins
|
||||||
|
|
||||||
- name: Build Desktop Layers
|
- name: Build Desktop Layers
|
||||||
run: yarn nx build @affine/electron
|
run: yarn workspace @affine/electron build
|
||||||
|
|
||||||
- name: Download static resource artifact
|
- name: Download static resource artifact
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
@@ -404,21 +407,14 @@ jobs:
|
|||||||
name: Unit Test
|
name: Unit Test
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
environment: development
|
environment: development
|
||||||
services:
|
|
||||||
octobase:
|
|
||||||
image: ghcr.io/toeverything/cloud-self-hosted:nightly-latest
|
|
||||||
ports:
|
|
||||||
- 3000:3000
|
|
||||||
env:
|
|
||||||
SIGN_KEY: 'test123'
|
|
||||||
RUST_LOG: 'debug'
|
|
||||||
JWST_DEV: '1'
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: ./.github/actions/setup-node
|
uses: ./.github/actions/setup-node
|
||||||
|
|
||||||
|
- name: Build Infra
|
||||||
|
run: yarn run build:infra
|
||||||
|
|
||||||
- name: Unit Test
|
- name: Unit Test
|
||||||
run: yarn nx test:coverage @affine/monorepo
|
run: yarn nx test:coverage @affine/monorepo
|
||||||
|
|
||||||
|
|||||||
2
.github/workflows/nightly-build.yml
vendored
2
.github/workflows/nightly-build.yml
vendored
@@ -130,7 +130,7 @@ jobs:
|
|||||||
run: yarn run build:plugins
|
run: yarn run build:plugins
|
||||||
|
|
||||||
- name: Build Desktop Layers
|
- name: Build Desktop Layers
|
||||||
run: yarn nx build @affine/electron
|
run: yarn workspace @affine/electron build
|
||||||
|
|
||||||
- name: Signing By Apple Developer ID
|
- name: Signing By Apple Developer ID
|
||||||
if: ${{ matrix.spec.platform == 'darwin' }}
|
if: ${{ matrix.spec.platform == 'darwin' }}
|
||||||
|
|||||||
2
.github/workflows/release-desktop-app.yml
vendored
2
.github/workflows/release-desktop-app.yml
vendored
@@ -130,7 +130,7 @@ jobs:
|
|||||||
run: yarn run build:plugins
|
run: yarn run build:plugins
|
||||||
|
|
||||||
- name: Build Desktop Layers
|
- name: Build Desktop Layers
|
||||||
run: yarn nx build @affine/electron
|
run: yarn workspace @affine/electron build
|
||||||
|
|
||||||
- name: Signing By Apple Developer ID
|
- name: Signing By Apple Developer ID
|
||||||
if: ${{ matrix.spec.platform == 'darwin' }}
|
if: ${{ matrix.spec.platform == 'darwin' }}
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
/**
|
|
||||||
* @vitest-environment happy-dom
|
|
||||||
*/
|
|
||||||
import {
|
|
||||||
getLoginStorage,
|
|
||||||
isExpired,
|
|
||||||
loginResponseSchema,
|
|
||||||
parseIdToken,
|
|
||||||
setLoginStorage,
|
|
||||||
} from '@affine/workspace/affine/login';
|
|
||||||
import user1 from '@affine-test/fixtures/built-in-user1.json';
|
|
||||||
import { renderHook } from '@testing-library/react';
|
|
||||||
import { afterEach, describe, expect, test } from 'vitest';
|
|
||||||
|
|
||||||
import { useAffineRefreshAuthToken } from '../../../hooks/affine/use-affine-refresh-auth-token';
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
localStorage.clear();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('AFFiNE workspace', () => {
|
|
||||||
test('Provider', async () => {
|
|
||||||
expect(getLoginStorage()).toBeNull();
|
|
||||||
const data = await fetch('http://127.0.0.1:3000/api/user/token', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
type: 'DebugLoginUser',
|
|
||||||
email: user1.email,
|
|
||||||
password: user1.password,
|
|
||||||
}),
|
|
||||||
}).then(r => r.json());
|
|
||||||
loginResponseSchema.parse(data);
|
|
||||||
setLoginStorage({
|
|
||||||
// expired token that already expired
|
|
||||||
token:
|
|
||||||
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2ODA4MjE0OTQsImlkIjoiaFd0dkFoM1E3SGhiWVlNeGxyX1I0IiwibmFtZSI6ImRlYnVnMSIsImVtYWlsIjoiZGVidWcxQHRvZXZlcnl0aGluZy5pbmZvIiwiYXZhdGFyX3VybCI6bnVsbCwiY3JlYXRlZF9hdCI6MTY4MDgxNTcxMTAwMH0.fDSkbM-ovmGD21sKYSTuiqC1dTiceOfcgIUfI2dLsBk',
|
|
||||||
// but refresh is still valid
|
|
||||||
refresh: data.refresh,
|
|
||||||
});
|
|
||||||
const hook = renderHook(() => useAffineRefreshAuthToken(1));
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
||||||
const userData = parseIdToken(getLoginStorage()?.token as string);
|
|
||||||
expect(userData).not.toBeNull();
|
|
||||||
expect(isExpired(userData)).toBe(false);
|
|
||||||
hook.unmount();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
/**
|
|
||||||
* @vitest-environment node
|
|
||||||
*/
|
|
||||||
import { loginResponseSchema } from '@affine/workspace/affine/login';
|
|
||||||
import type { affineApis as API } from '@affine/workspace/affine/shared';
|
|
||||||
import { beforeAll, describe, expect, it, vi } from 'vitest';
|
|
||||||
|
|
||||||
let affineApis: typeof API;
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
|
||||||
// @ts-expect-error
|
|
||||||
globalThis.window = undefined;
|
|
||||||
affineApis = (await import('@affine/workspace/affine/shared')).affineApis;
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('apis', () => {
|
|
||||||
it('should defined', async () => {
|
|
||||||
expect(affineApis).toBeDefined();
|
|
||||||
expect(affineApis).toBe(globalThis.AFFINE_APIS);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('login mock user', async () => {
|
|
||||||
const setItem = vi.fn((key: string, value: unknown) => {
|
|
||||||
expect(key).toBe('affine-login-v2');
|
|
||||||
expect(value).toBeTypeOf('string');
|
|
||||||
loginResponseSchema.parse(JSON.parse(value as string));
|
|
||||||
});
|
|
||||||
vi.stubGlobal('localStorage', {
|
|
||||||
setItem,
|
|
||||||
});
|
|
||||||
expect(globalThis.AFFINE_DEBUG).toBeDefined();
|
|
||||||
expect(globalThis.AFFINE_DEBUG.loginMockUser1).toBeTypeOf('function');
|
|
||||||
expect(globalThis.AFFINE_DEBUG.loginMockUser2).toBeTypeOf('function');
|
|
||||||
await (globalThis.AFFINE_DEBUG.loginMockUser1 as () => Promise<unknown>)();
|
|
||||||
await (globalThis.AFFINE_DEBUG.loginMockUser2 as () => Promise<unknown>)();
|
|
||||||
expect(setItem).toBeCalledTimes(2);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
26
nx.json
26
nx.json
@@ -34,13 +34,11 @@
|
|||||||
"{projectRoot}/out",
|
"{projectRoot}/out",
|
||||||
"{projectRoot}/node_modules/.cache",
|
"{projectRoot}/node_modules/.cache",
|
||||||
"{projectRoot}/target",
|
"{projectRoot}/target",
|
||||||
"{workspaceRoot}/apps/web/.next",
|
|
||||||
"{workspaceRoot}/apps/storybook/storybook-static",
|
"{workspaceRoot}/apps/storybook/storybook-static",
|
||||||
"{workspaceRoot}/packages/i18n/src/i18n-generated.ts",
|
"{workspaceRoot}/packages/i18n/src/i18n-generated.ts",
|
||||||
"{workspaceRoot}/packages/native/affine.*.node",
|
"{workspaceRoot}/packages/native/*.node",
|
||||||
"{workspaceRoot}/packages/storage/*.node",
|
"{workspaceRoot}/packages/storage/*.node",
|
||||||
"{workspaceRoot}/affine.db",
|
"{workspaceRoot}/affine.db"
|
||||||
"{workspaceRoot/apps/electron/dist"
|
|
||||||
],
|
],
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
@@ -85,7 +83,6 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"e2e": {
|
"e2e": {
|
||||||
"dependsOn": ["^build"],
|
|
||||||
"outputs": ["{workspaceRoot}/.nyc_output", "{projectRoot}/test-results"],
|
"outputs": ["{workspaceRoot}/.nyc_output", "{projectRoot}/test-results"],
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
@@ -97,7 +94,6 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"e2e:coverage": {
|
"e2e:coverage": {
|
||||||
"dependsOn": ["^build"],
|
|
||||||
"outputs": ["{workspaceRoot}/.nyc_output", "{projectRoot}/test-results"],
|
"outputs": ["{workspaceRoot}/.nyc_output", "{projectRoot}/test-results"],
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
@@ -109,28 +105,34 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"test": {
|
"test": {
|
||||||
|
"outputs": ["{workspaceRoot}/.nyc_output"],
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
"env": "ENABLE_PRELOADING"
|
"env": "ENABLE_PRELOADING"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"env": "COVERAGE"
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"dependsOn": ["^build"]
|
|
||||||
},
|
},
|
||||||
"test:ui": {
|
"test:ui": {
|
||||||
|
"outputs": ["{workspaceRoot}/.nyc_output"],
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
"env": "ENABLE_PRELOADING"
|
"env": "ENABLE_PRELOADING"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"env": "COVERAGE"
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"dependsOn": ["^build"]
|
|
||||||
},
|
},
|
||||||
"test:coverage": {
|
"test:coverage": {
|
||||||
|
"outputs": ["{workspaceRoot}/.nyc_output"],
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
"env": "ENABLE_PRELOADING"
|
"env": "ENABLE_PRELOADING"
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"dependsOn": ["^build"]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"generators": {
|
"generators": {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
"dev:plugins": "./apps/electron/scripts/plugins/dev-plugins.mjs",
|
"dev:plugins": "./apps/electron/scripts/plugins/dev-plugins.mjs",
|
||||||
"build": "yarn nx build @affine/web",
|
"build": "yarn nx build @affine/web",
|
||||||
"build:electron": "yarn nx build @affine/electron",
|
"build:electron": "yarn nx build @affine/electron",
|
||||||
|
"build:storage": "yarn nx run-many -t build -p @affine/storage",
|
||||||
"build:infra": "yarn nx run-many -t build -p plugin-infra infra",
|
"build:infra": "yarn nx run-many -t build -p plugin-infra infra",
|
||||||
"build:plugins": "yarn nx run-many -t build -p @affine/bookmark-block",
|
"build:plugins": "yarn nx run-many -t build -p @affine/bookmark-block",
|
||||||
"build:storybook": "yarn nx build @affine/storybook",
|
"build:storybook": "yarn nx build @affine/storybook",
|
||||||
|
|||||||
Reference in New Issue
Block a user