mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-22 12:36:24 +08:00
feat(client): migration old package to rspack (#15068)
#### PR Dependency Tree * **PR #15068** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Upgraded Vitest across packages to 4.1.8 and bumped Tailwind PostCSS to 4.3.0 * CLI/tooling updated to support the media-capture-playground package and adjust build/dev server behavior * **Bug Fixes** * Improved workspace deletion reliability in the Electron app * **Refactor** * Simplified media capture playground build setup (build/config adjustments) * **Tests** * Made tests more robust by preserving/restoring environment state during runs <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -150,20 +150,26 @@ test('should not switch user quota if the new quota is the same as the current o
|
||||
});
|
||||
|
||||
test('should use pro plan as free for selfhost instance', async t => {
|
||||
const previousDeploymentType = env.DEPLOYMENT_TYPE;
|
||||
// @ts-expect-error DEPLOYMENT_TYPE is readonly
|
||||
env.DEPLOYMENT_TYPE = 'selfhosted';
|
||||
await using module = await createTestingModule();
|
||||
try {
|
||||
await using module = await createTestingModule();
|
||||
|
||||
const models = module.get(Models);
|
||||
const u1 = await models.user.create({
|
||||
email: 'u1@affine.pro',
|
||||
registered: true,
|
||||
});
|
||||
const models = module.get(Models);
|
||||
const u1 = await models.user.create({
|
||||
email: 'u1@affine.pro',
|
||||
registered: true,
|
||||
});
|
||||
|
||||
await models.userFeature.add(u1.id, 'free_plan_v1', 'legacy projection');
|
||||
const quota = await models.userFeature.getQuota(u1.id);
|
||||
t.snapshot(
|
||||
quota?.configs,
|
||||
'use pro plan as free plan for selfhosted instance'
|
||||
);
|
||||
await models.userFeature.add(u1.id, 'free_plan_v1', 'legacy projection');
|
||||
const quota = await models.userFeature.getQuota(u1.id);
|
||||
t.snapshot(
|
||||
quota?.configs,
|
||||
'use pro plan as free plan for selfhosted instance'
|
||||
);
|
||||
} finally {
|
||||
// @ts-expect-error DEPLOYMENT_TYPE is readonly
|
||||
env.DEPLOYMENT_TYPE = previousDeploymentType;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -327,6 +327,9 @@ test.after.always(async t => {
|
||||
});
|
||||
|
||||
test('reconciles quota states from entitlements and business tables', async t => {
|
||||
const previousDeploymentType = globalThis.env.DEPLOYMENT_TYPE;
|
||||
// @ts-expect-error test mutates env singleton for cloud entitlement semantics
|
||||
globalThis.env.DEPLOYMENT_TYPE = 'affine';
|
||||
const cases = [
|
||||
{
|
||||
name: 'owner fallback uses user entitlement and owner storage usage',
|
||||
@@ -444,10 +447,15 @@ test('reconciles quota states from entitlements and business tables', async t =>
|
||||
},
|
||||
];
|
||||
|
||||
for (const item of cases) {
|
||||
await t.context.module.initTestingDB();
|
||||
const state = await item.setup();
|
||||
await item.assert(state);
|
||||
try {
|
||||
for (const item of cases) {
|
||||
await t.context.module.initTestingDB();
|
||||
const state = await item.setup();
|
||||
await item.assert(state);
|
||||
}
|
||||
} finally {
|
||||
// @ts-expect-error restore mutable test env singleton
|
||||
globalThis.env.DEPLOYMENT_TYPE = previousDeploymentType;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/debug": "^4.1.12",
|
||||
"vitest": "^4.0.18"
|
||||
"vitest": "^4.1.8"
|
||||
},
|
||||
"version": "0.26.3"
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"devDependencies": {
|
||||
"vitest": "^4.0.18"
|
||||
"vitest": "^4.1.8"
|
||||
},
|
||||
"exports": {
|
||||
"./automation": "./src/automation.ts",
|
||||
|
||||
@@ -11,6 +11,6 @@
|
||||
"graphql": "^16.9.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vitest": "^4.0.18"
|
||||
"vitest": "^4.1.8"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
"@graphql-codegen/typescript-operations": "^5.0.9",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"prettier": "^3.7.4",
|
||||
"vitest": "^4.0.18"
|
||||
"vitest": "^4.1.8"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "gql-gen --errors-only"
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
"@testing-library/react": "^16.1.0",
|
||||
"@types/react": "^19.0.1",
|
||||
"rxjs": "^7.8.2",
|
||||
"vitest": "^4.0.18"
|
||||
"vitest": "^4.1.8"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"electron": "*",
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
"fake-indexeddb": "^6.0.0",
|
||||
"idb": "^8.0.0",
|
||||
"socket.io-client": "^4.8.3",
|
||||
"vitest": "^4.0.18"
|
||||
"vitest": "^4.1.8"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@affine/error": "workspace:*",
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@blocksuite/affine": "workspace:*",
|
||||
"vitest": "^4.0.18"
|
||||
"vitest": "^4.1.8"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@blocksuite/affine": "workspace:*"
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
"tailwind-merge": "^3.4.0",
|
||||
"tailwindcss": "^4.1.17",
|
||||
"tailwindcss-animate": "^1.0.7",
|
||||
"vitest": "^4.0.18"
|
||||
"vitest": "^4.1.8"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "affine bundle",
|
||||
|
||||
@@ -51,7 +51,6 @@
|
||||
"@sentry/esbuild-plugin": "^5.3.0",
|
||||
"@toeverything/infra": "workspace:*",
|
||||
"@types/set-cookie-parser": "^2.4.10",
|
||||
"@vitejs/plugin-react": "^5.2.0",
|
||||
"app-builder-lib": "^26.8.1",
|
||||
"builder-util-runtime": "^9.5.1",
|
||||
"cross-env": "^10.1.0",
|
||||
@@ -71,7 +70,7 @@
|
||||
"tree-kill": "^1.2.2",
|
||||
"typescript": "^5.9.3",
|
||||
"uuid": "^14.0.0",
|
||||
"vitest": "^4.0.18",
|
||||
"vitest": "^4.1.8",
|
||||
"zod": "^3.25.76"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -31,7 +31,7 @@ async function deleteWorkspaceV1(workspaceId: string) {
|
||||
try {
|
||||
await ensureSQLiteDisconnected('workspace', workspaceId);
|
||||
const basePath = await getWorkspaceBasePathV1('workspace', workspaceId);
|
||||
await fs.rmdir(basePath, { recursive: true });
|
||||
await fs.remove(basePath);
|
||||
} catch (error) {
|
||||
logger.error('deleteWorkspaceV1', error);
|
||||
}
|
||||
@@ -47,7 +47,7 @@ export async function deleteWorkspace(universalId: string) {
|
||||
const dbPath = await getSpaceDBPath(peer, type, id);
|
||||
try {
|
||||
await getDocStoragePool().disconnect(universalId);
|
||||
await fs.rmdir(path.dirname(dbPath), { recursive: true });
|
||||
await fs.remove(path.dirname(dbPath));
|
||||
} catch (e) {
|
||||
logger.error('deleteWorkspace', e);
|
||||
}
|
||||
@@ -78,7 +78,7 @@ export async function trashWorkspace(universalId: string) {
|
||||
await fs.copy(path.dirname(dbPath), movedPath, {
|
||||
overwrite: true,
|
||||
});
|
||||
await fs.rmdir(path.dirname(dbPath), { recursive: true });
|
||||
await fs.remove(path.dirname(dbPath));
|
||||
} catch (error) {
|
||||
logger.error('trashWorkspace', error);
|
||||
}
|
||||
@@ -331,7 +331,7 @@ async function importWorkspaceDb(originalPath: string) {
|
||||
export async function deleteBackupWorkspace(id: string) {
|
||||
const basePath = await getDeletedWorkspacesBasePath();
|
||||
const workspacePath = path.join(basePath, normalizeWorkspaceIdForPath(id));
|
||||
await fs.rmdir(workspacePath, { recursive: true });
|
||||
await fs.remove(workspacePath);
|
||||
logger.info(
|
||||
'deleteBackupWorkspace',
|
||||
`Deleted backup workspace: ${workspacePath}`
|
||||
|
||||
@@ -2,13 +2,11 @@
|
||||
import { resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
import react from '@vitejs/plugin-react';
|
||||
import { defineConfig } from 'vitest/config';
|
||||
|
||||
const rootDir = fileURLToPath(new URL('../../../..', import.meta.url));
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
resolve: {
|
||||
alias: {
|
||||
// prevent tests using two different sources of yjs
|
||||
|
||||
@@ -14,6 +14,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.9.3",
|
||||
"vitest": "^4.0.18"
|
||||
"vitest": "^4.1.8"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
"typescript": "^5.9.3",
|
||||
"unplugin-swc": "^1.5.9",
|
||||
"vite": "^7.2.7",
|
||||
"vitest": "^4.0.18"
|
||||
"vitest": "^4.1.8"
|
||||
},
|
||||
"version": "0.26.3"
|
||||
}
|
||||
|
||||
@@ -107,6 +107,6 @@
|
||||
"@vanilla-extract/css": "^1.17.0",
|
||||
"fake-indexeddb": "^6.0.0",
|
||||
"happy-dom": "^20.3.0",
|
||||
"vitest": "^4.0.18"
|
||||
"vitest": "^4.1.8"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,6 @@
|
||||
"@affine-tools/cli": "workspace:*",
|
||||
"@affine-tools/utils": "workspace:*",
|
||||
"glob": "^11.0.0",
|
||||
"vitest": "^4.0.18"
|
||||
"vitest": "^4.1.8"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,19 +4,18 @@
|
||||
"type": "module",
|
||||
"version": "0.26.3",
|
||||
"scripts": {
|
||||
"dev:web": "vite",
|
||||
"dev:web": "affine bundle --dev",
|
||||
"build:web": "affine bundle",
|
||||
"dev:server": "node --env-file-if-exists=.env --watch server/main.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@affine/native": "workspace:*",
|
||||
"@google/generative-ai": "^0.24.0",
|
||||
"@tailwindcss/vite": "^4.0.6",
|
||||
"@types/express": "^5.0.0",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/multer": "^2.0.0",
|
||||
"@types/react": "^19.0.8",
|
||||
"@types/react-dom": "^19.0.3",
|
||||
"@vitejs/plugin-react": "^5.2.0",
|
||||
"chokidar": "^4.0.3",
|
||||
"express": "^5.0.0",
|
||||
"express-rate-limit": "^7.1.5",
|
||||
@@ -29,8 +28,7 @@
|
||||
"socket.io": "^4.7.4",
|
||||
"socket.io-client": "^4.8.3",
|
||||
"swr": "^2.3.7",
|
||||
"tailwindcss": "^4.1.17",
|
||||
"vite": "^7.3.1"
|
||||
"tailwindcss": "^4.1.17"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/fs-extra": "^11",
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
import tailwindcss from '@tailwindcss/vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import { defineConfig } from 'vite';
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react(), tailwindcss()],
|
||||
root: './web',
|
||||
server: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:6544',
|
||||
changeOrigin: true,
|
||||
rewrite: path => path.replace(/^\/api/, ''),
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -2,12 +2,10 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Media Capture Playground</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"@affine-tools/cli": "workspace:*",
|
||||
"@affine-tools/utils": "workspace:*",
|
||||
"path-to-regexp": "^8.4.2",
|
||||
"vitest": "^4.0.18"
|
||||
"vitest": "^4.1.8"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^19.2.1",
|
||||
|
||||
@@ -14,6 +14,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^19.0.1",
|
||||
"vitest": "^4.0.18"
|
||||
"vitest": "^4.1.8"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user