chore: standardize tsconfig (#9568)
This commit is contained in:
151 files changed
+1041
-1566
No files matched your search
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "@affine-test/affine-cloud-copilot",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"e2e": "yarn playwright test"
|
||||
},
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"extends": "../../tsconfig.web.json",
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true,
|
||||
"outDir": "lib"
|
||||
"rootDir": "./e2e",
|
||||
"outDir": "./dist",
|
||||
"tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo"
|
||||
},
|
||||
"include": ["e2e"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../tests/kit"
|
||||
}
|
||||
]
|
||||
"references": [{ "path": "../kit" }]
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
import { resolve } from 'node:path';
|
||||
|
||||
import { skipOnboarding, test } from '@affine-test/kit/playwright';
|
||||
import { Path, skipOnboarding, test } from '@affine-test/kit/playwright';
|
||||
import {
|
||||
addUserToWorkspace,
|
||||
createRandomUser,
|
||||
@@ -172,7 +170,7 @@ test('can sync svg between different browsers', async ({ page, browser }) => {
|
||||
const fileChooserPromise = page.waitForEvent('filechooser');
|
||||
await page.keyboard.press('Enter', { delay: 50 });
|
||||
const fileChooser = await fileChooserPromise;
|
||||
fileChooser.setFiles(resolve(__dirname, 'logo.svg'));
|
||||
fileChooser.setFiles(Path.dir(import.meta.url).join('logo.svg').value);
|
||||
await expect(image).toBeVisible();
|
||||
|
||||
// the user should see the svg
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { resolve } from 'node:path';
|
||||
|
||||
import { test } from '@affine-test/kit/playwright';
|
||||
import { Path, test } from '@affine-test/kit/playwright';
|
||||
import {
|
||||
createRandomUser,
|
||||
deleteUser,
|
||||
@@ -72,7 +71,10 @@ test.skip('migration', async ({ page, browser }) => {
|
||||
await runPrisma(async client => {
|
||||
const sqls = (
|
||||
await readFile(
|
||||
resolve(__dirname, 'fixtures', '0.9.0-canary.9-snapshots.sql'),
|
||||
Path.dir(import.meta.url).join(
|
||||
'fixtures',
|
||||
'0.9.0-canary.9-snapshots.sql'
|
||||
).value,
|
||||
'utf-8'
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "@affine-test/affine-cloud",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"e2e": "yarn playwright test"
|
||||
},
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"extends": "../../tsconfig.web.json",
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true,
|
||||
"outDir": "lib"
|
||||
"rootDir": "./e2e",
|
||||
"outDir": "./dist",
|
||||
"tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo"
|
||||
},
|
||||
"include": ["e2e"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../tests/kit"
|
||||
}
|
||||
]
|
||||
"references": [{ "path": "../kit" }]
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "@affine-test/affine-desktop-cloud",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"e2e": "yarn playwright test"
|
||||
},
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"extends": "../../tsconfig.web.json",
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true,
|
||||
"outDir": "lib"
|
||||
"rootDir": "./e2e",
|
||||
"outDir": "./dist",
|
||||
"tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo"
|
||||
},
|
||||
"include": ["e2e"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../tests/kit"
|
||||
}
|
||||
]
|
||||
"references": [{ "path": "../kit" }]
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "@affine-test/affine-desktop",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"e2e": "DEBUG=pw:browser yarn playwright test"
|
||||
},
|
||||
|
||||
@@ -41,7 +41,7 @@ if (process.env.DEV_SERVER_URL) {
|
||||
);
|
||||
config.webServer = [
|
||||
{
|
||||
command: 'yarn run -T affine bundle -p @affine/electron --dev',
|
||||
command: 'yarn run -T affine bundle -p @affine/electron-renderer --dev',
|
||||
port: 8080,
|
||||
timeout: 120 * 1000,
|
||||
reuseExistingServer: !process.env.CI,
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"extends": "../../tsconfig.web.json",
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true,
|
||||
"outDir": "lib"
|
||||
"rootDir": "./e2e",
|
||||
"outDir": "./dist",
|
||||
"tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo"
|
||||
},
|
||||
"include": ["e2e"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../tests/kit"
|
||||
},
|
||||
{
|
||||
"path": "../../packages/frontend/electron-api"
|
||||
}
|
||||
{ "path": "../kit" },
|
||||
{ "path": "../../packages/frontend/electron-api" }
|
||||
]
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
import path from 'node:path';
|
||||
|
||||
import { test } from '@affine-test/kit/playwright';
|
||||
import { Path, test } from '@affine-test/kit/playwright';
|
||||
import { openHomePage } from '@affine-test/kit/utils/load-page';
|
||||
import {
|
||||
clickNewPageButton,
|
||||
@@ -16,6 +14,8 @@ import {
|
||||
import type { Page } from '@playwright/test';
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
const fixturesDir = Path.dir(import.meta.url).join('../../fixtures');
|
||||
|
||||
async function clickPeekViewControl(page: Page, n = 0) {
|
||||
await page.getByTestId('peek-view-control').nth(n).click();
|
||||
await page.waitForTimeout(500);
|
||||
@@ -66,10 +66,7 @@ test('attachment preview should be shown', async ({ page }) => {
|
||||
await title.click();
|
||||
await page.keyboard.press('Enter');
|
||||
|
||||
await insertAttachment(
|
||||
page,
|
||||
path.join(__dirname, '../../fixtures/lorem-ipsum.pdf')
|
||||
);
|
||||
await insertAttachment(page, fixturesDir.join('lorem-ipsum.pdf').value);
|
||||
|
||||
await page.locator('affine-attachment').first().dblclick();
|
||||
|
||||
@@ -107,10 +104,7 @@ test('attachment preview can be expanded', async ({ page }) => {
|
||||
await title.click();
|
||||
await page.keyboard.press('Enter');
|
||||
|
||||
await insertAttachment(
|
||||
page,
|
||||
path.join(__dirname, '../../fixtures/lorem-ipsum.pdf')
|
||||
);
|
||||
await insertAttachment(page, fixturesDir.join('lorem-ipsum.pdf').value);
|
||||
|
||||
await page.locator('affine-attachment').first().dblclick();
|
||||
|
||||
@@ -161,10 +155,7 @@ test('should preview PDF in embed view', async ({ page }) => {
|
||||
|
||||
await page.keyboard.press('Enter');
|
||||
|
||||
await insertAttachment(
|
||||
page,
|
||||
path.join(__dirname, '../../fixtures/lorem-ipsum.pdf')
|
||||
);
|
||||
await insertAttachment(page, fixturesDir.join('lorem-ipsum.pdf').value);
|
||||
|
||||
const attachment = page.locator('affine-attachment');
|
||||
await attachment.hover();
|
||||
@@ -271,10 +262,7 @@ test('should sync name in pdf embed view', async ({ page }) => {
|
||||
await title.click();
|
||||
await page.keyboard.press('Enter');
|
||||
|
||||
await insertAttachment(
|
||||
page,
|
||||
path.join(__dirname, '../../fixtures/lorem-ipsum.pdf')
|
||||
);
|
||||
await insertAttachment(page, fixturesDir.join('lorem-ipsum.pdf').value);
|
||||
|
||||
const attachment = page.locator('affine-attachment');
|
||||
await attachment.hover();
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { resolve } from 'node:path';
|
||||
|
||||
import { rootDir, test } from '@affine-test/kit/playwright';
|
||||
import { ProjectRoot, test } from '@affine-test/kit/playwright';
|
||||
import { openHomePage } from '@affine-test/kit/utils/load-page';
|
||||
import {
|
||||
clickNewPageButton,
|
||||
@@ -29,7 +27,7 @@ test('should create a page with a local first avatar and remove it', async ({
|
||||
await page.getByTestId('current-workspace-label').click();
|
||||
await page
|
||||
.getByTestId('upload-avatar')
|
||||
.setInputFiles(resolve(rootDir, 'tests', 'fixtures', 'blue.png'));
|
||||
.setInputFiles(ProjectRoot.join('tests', 'fixtures', 'blue.png').value);
|
||||
await page.mouse.click(0, 0);
|
||||
await page.getByTestId('workspace-name').click();
|
||||
await page
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "@affine-test/affine-local",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"e2e": "yarn playwright test"
|
||||
},
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"extends": "../../tsconfig.web.json",
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true,
|
||||
"outDir": "lib"
|
||||
"rootDir": "./e2e",
|
||||
"outDir": "./dist",
|
||||
"tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo"
|
||||
},
|
||||
"include": ["e2e"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../tests/kit"
|
||||
}
|
||||
]
|
||||
"include": ["./e2e"],
|
||||
"references": [{ "path": "../kit" }]
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "@affine-test/affine-mobile",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"e2e": "yarn playwright test"
|
||||
},
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"extends": "../../tsconfig.web.json",
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true,
|
||||
"outDir": "lib"
|
||||
"rootDir": "./e2e",
|
||||
"outDir": "./dist",
|
||||
"tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo"
|
||||
},
|
||||
"include": ["e2e"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../tests/kit"
|
||||
}
|
||||
]
|
||||
"references": [{ "path": "../kit" }]
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
lib
|
||||
@@ -4,12 +4,13 @@
|
||||
"type": "module",
|
||||
"version": "0.19.0",
|
||||
"exports": {
|
||||
"./electron": "./electron.ts",
|
||||
"./playwright": "./playwright.ts",
|
||||
"./utils/*": "./utils/*.ts",
|
||||
"./e2e-enhance/*": "./e2e-enhance/*.ts"
|
||||
"./electron": "./src/electron.ts",
|
||||
"./mobile": "./src/mobile.ts",
|
||||
"./playwright": "./src/playwright.ts",
|
||||
"./utils/*": "./src/utils/*.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@affine-tools/utils": "workspace:*",
|
||||
"@node-rs/argon2": "^2.0.2",
|
||||
"@playwright/test": "=1.49.1",
|
||||
"express": "^4.21.2",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import crypto from 'node:crypto';
|
||||
import { join, resolve } from 'node:path';
|
||||
|
||||
import { Package } from '@affine-tools/utils/workspace';
|
||||
import { expect, type Page } from '@playwright/test';
|
||||
import fs from 'fs-extra';
|
||||
import type { ElectronApplication } from 'playwright';
|
||||
@@ -9,8 +9,7 @@ import { _electron as electron } from 'playwright';
|
||||
import { test as base, testResultDir } from './playwright';
|
||||
import { removeWithRetry } from './utils/utils';
|
||||
|
||||
const projectRoot = join(__dirname, '..', '..');
|
||||
const electronRoot = join(projectRoot, 'packages/frontend/apps/electron');
|
||||
const electronRoot = new Package('@affine/electron').path;
|
||||
|
||||
function generateUUID() {
|
||||
return crypto.randomUUID();
|
||||
@@ -122,23 +121,23 @@ export const test = base.extend<{
|
||||
},
|
||||
});
|
||||
},
|
||||
// eslint-disable-next-line no-empty-pattern
|
||||
// oxlint-disable-next-line no-empty-pattern
|
||||
electronApp: async ({}, use) => {
|
||||
try {
|
||||
// a random id to avoid conflicts between tests
|
||||
const id = generateUUID();
|
||||
const dist = resolve(electronRoot, 'dist');
|
||||
const clonedDist = resolve(electronRoot, 'e2e-dist-' + id);
|
||||
const dist = electronRoot.join('dist').value;
|
||||
const clonedDist = electronRoot.join('e2e-dist-' + id).value;
|
||||
await fs.copy(dist, clonedDist);
|
||||
const packageJson = await fs.readJSON(
|
||||
resolve(electronRoot, 'package.json')
|
||||
electronRoot.join('package.json').value
|
||||
);
|
||||
// overwrite the app name
|
||||
packageJson.name = 'affine-test-' + id;
|
||||
// overwrite the path to the main script
|
||||
packageJson.main = './main.js';
|
||||
// write to the cloned dist
|
||||
await fs.writeJSON(resolve(clonedDist, 'package.json'), packageJson);
|
||||
await fs.writeJSON(clonedDist + '/package.json', packageJson);
|
||||
|
||||
const env: Record<string, string> = {};
|
||||
for (const [key, value] of Object.entries(process.env)) {
|
||||
File renamed without changes.
@@ -1,25 +1,17 @@
|
||||
import { ok } from 'node:assert';
|
||||
import crypto from 'node:crypto';
|
||||
import fs from 'node:fs';
|
||||
import path, { resolve } from 'node:path';
|
||||
import path from 'node:path';
|
||||
import process from 'node:process';
|
||||
|
||||
import { Path, ProjectRoot } from '@affine-tools/utils/path';
|
||||
import type { BrowserContext } from '@playwright/test';
|
||||
import { test as baseTest } from '@playwright/test';
|
||||
|
||||
export const rootDir = resolve(__dirname, '..', '..');
|
||||
// assert that the rootDir is the root of the project
|
||||
ok(
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
require(resolve(rootDir, 'package.json')).name.toLowerCase() ===
|
||||
'@affine/monorepo'
|
||||
);
|
||||
|
||||
export const testResultDir = resolve(rootDir, 'test-results');
|
||||
|
||||
export { Path, ProjectRoot };
|
||||
export const testResultDir = ProjectRoot.join('test-results').value;
|
||||
export const istanbulTempDir = process.env.ISTANBUL_TEMP_DIR
|
||||
? path.resolve(process.env.ISTANBUL_TEMP_DIR)
|
||||
: path.join(rootDir, '.nyc_output');
|
||||
: ProjectRoot.join('.nyc_output').value;
|
||||
|
||||
function generateUUID() {
|
||||
return crypto.randomUUID();
|
||||
@@ -54,7 +54,7 @@ export const runPrisma = async <T>(
|
||||
cb: (
|
||||
prisma: InstanceType<
|
||||
// oxlint-disable-next-line @typescript-eslint/consistent-type-imports
|
||||
typeof import('../../../packages/backend/server/node_modules/@prisma/client').PrismaClient
|
||||
typeof import('../../../../packages/backend/server/node_modules/@prisma/client').PrismaClient
|
||||
>
|
||||
) => Promise<T>
|
||||
): Promise<T> => {
|
||||
@@ -62,7 +62,7 @@ export const runPrisma = async <T>(
|
||||
PrismaClient,
|
||||
// oxlint-disable-next-line @typescript-eslint/consistent-type-imports
|
||||
} = await import(
|
||||
'../../../packages/backend/server/node_modules/@prisma/client'
|
||||
'../../../../packages/backend/server/node_modules/@prisma/client'
|
||||
);
|
||||
const client = new PrismaClient({
|
||||
datasourceUrl:
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,5 +1,4 @@
|
||||
import { join } from 'node:path';
|
||||
|
||||
import { Path } from '@affine-tools/utils/path';
|
||||
import type { Page } from '@playwright/test';
|
||||
|
||||
export async function importImage(page: Page, pathInFixtures: string) {
|
||||
@@ -17,7 +16,9 @@ export async function importImage(page: Page, pathInFixtures: string) {
|
||||
await page.keyboard.press('Enter');
|
||||
await (
|
||||
await fileChooser
|
||||
).setFiles(join(__dirname, '../../fixtures', pathInFixtures));
|
||||
).setFiles(
|
||||
Path.dir(import.meta.url).join('../../../fixtures', pathInFixtures).value
|
||||
);
|
||||
// TODO(@catsjuice): wait for image to be loaded more reliably
|
||||
await page.waitForTimeout(1000);
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,9 +1,10 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"extends": "../../tsconfig.web.json",
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"noEmit": false,
|
||||
"outDir": "lib"
|
||||
"rootDir": "./src",
|
||||
"outDir": "./dist",
|
||||
"tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo"
|
||||
},
|
||||
"include": ["./*.ts", "utils", "e2e-enhance"]
|
||||
"include": ["./src"],
|
||||
"references": [{ "path": "../../tools/utils" }]
|
||||
}
|
||||
Reference in new issue
Block a user