chore: standardize tsconfig (#9568)

This commit is contained in:
forehalo committed 2025-01-08 04:07:56 +00:00
1 parent 39f4b17315
commit c0ed74dfed
151 files changed
+1041 -1566

No files matched your search

-1
View File
@@ -1 +0,0 @@
lib
+5 -4
View File
@@ -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.
+6 -5
View File
@@ -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" }]
}