This commit is contained in:
lin onetwo 2025-10-31 00:10:44 +08:00
parent d481f32d3a
commit a42af638b6
9 changed files with 40 additions and 33 deletions

View file

@ -22,7 +22,7 @@ export default [
},
},
{
files: ['**/*.test.ts', '**/*.test.tsx', '**/*.spec.ts', '**/*.spec.tsx'],
files: ['**/*.test.ts', '**/*.test.tsx', '**/*.spec.ts', '**/*.spec.tsx', "*.env.d.ts"],
rules: {
'@typescript-eslint/unbound-method': 'off',
'unicorn/prevent-abbreviations': 'off',

View file

@ -222,12 +222,12 @@ AfterStep(async function(this: ApplicationWorld, { pickle, pickleStep, result })
}
}
const scenarioName = pickle.name;
// Limit scenario slug to avoid extremely long directory names
const cleanScenarioName = makeSlugPath(scenarioName, 60);
const scenarioName = pickle.name;
// Limit scenario slug to avoid extremely long directory names
const cleanScenarioName = makeSlugPath(scenarioName, 60);
// Limit step text slug to avoid excessively long filenames which can trigger ENAMETOOLONG
const cleanStepText = makeSlugPath(stepText, 80);
// Limit step text slug to avoid excessively long filenames which can trigger ENAMETOOLONG
const cleanStepText = makeSlugPath(stepText, 80);
const stepStatus = result && typeof result.status === 'string' ? result.status : 'unknown-status';
const featureDirectory = path.resolve(screenshotsDirectory, cleanScenarioName);

View file

@ -66,7 +66,7 @@ const unsafeChars = /[^\p{L}\p{N}\s\-_()]/gu;
const collapseDashes = /-+/g;
const collapseSpaces = /\s+/g;
export const makeSlugPath = (input: string | undefined, maxLength = 120) => {
let s = String(input || 'unknown').normalize('NFKC');
let s = (input || 'unknown').normalize('NFKC');
// remove dots explicitly
s = s.replace(/\./g, '');
// replace unsafe characters with dashes

View file

@ -24,8 +24,8 @@
"make": "pnpm run build:plugin && cross-env NODE_ENV=production electron-forge make",
"make:analyze": "cross-env ANALYZE=true pnpm run make",
"init:git-submodule": "git submodule update --init --recursive && git submodule update --remote",
"lint": "eslint ./src --ext js,ts,tsx,json",
"lint:fix": "eslint ./src --ext ts,tsx --fix",
"lint": "eslint ./src ./features ./scripts ./localization ./*.ts --ext js,ts,tsx,json",
"lint:fix": "eslint ./src ./features ./scripts ./localization ./*.ts --ext ts,tsx,json --fix",
"check": "tsc --noEmit --skipLibCheck",
"installType": "typesync"
},

View file

@ -1,14 +1,16 @@
/* eslint-disable @typescript-eslint/use-unknown-in-catch-callback-variable */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable no-undef */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable unicorn/prevent-abbreviations */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-call */
import esbuild from 'esbuild';
import fs from 'fs-extra';
import path from 'path';
import { fileURLToPath } from 'url';
import { rimraf } from 'rimraf';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
@ -29,7 +31,7 @@ const nativeNodeModulesPlugin = {
// New: require('nsfw/build/Release/nsfw.node')
contents = contents.replace(
/require\(['"]\.\.\/\.\.\/build\/Release\/nsfw\.node['"]\)/g,
"require('nsfw/build/Release/nsfw.node')"
"require('nsfw/build/Release/nsfw.node')",
);
return {
@ -152,7 +154,7 @@ async function buildEntryPoints(plugin, outDirs) {
outdir: outDir,
})
)
)
),
);
}

View file

@ -3,5 +3,7 @@ import { DEFAULT_FIRST_WIKI_FOLDER_PATH } from '../src/constants/paths';
try {
fs.removeSync(DEFAULT_FIRST_WIKI_FOLDER_PATH);
} catch {}
} catch {
// ignore
}
fs.mkdirpSync(DEFAULT_FIRST_WIKI_FOLDER_PATH);

View file

@ -1,4 +1,5 @@
// pnpm exec cross-env NODE_ENV=test tsx ./scripts/start-e2e-app.ts
/* eslint-disable unicorn/prevent-abbreviations */
import { spawn } from 'child_process';
import { getPackedAppPath } from '../features/supports/paths';
@ -7,16 +8,16 @@ import { getPackedAppPath } from '../features/supports/paths';
const appPath = getPackedAppPath();
console.log('Starting TidGi E2E app:', appPath);
const env = Object.assign({}, process.env, {
const environment = Object.assign({}, process.env, {
NODE_ENV: 'test',
LANG: process.env.LANG || 'zh-Hans.UTF-8',
LANGUAGE: process.env.LANGUAGE || 'zh-Hans:zh',
LC_ALL: process.env.LC_ALL || 'zh-Hans.UTF-8',
});
const child = spawn(appPath, [], { env, stdio: 'inherit' });
const child = spawn(appPath, [], { env: environment, stdio: 'inherit' });
child.on('exit', code => process.exit(code ?? 0));
child.on('error', err => {
console.error('Failed to start TidGi app:', err);
child.on('error', error => {
console.error('Failed to start TidGi app:', error);
process.exit(1);
});

View file

@ -43,8 +43,10 @@ async function main() {
});
// 防止进程退出 - 使用 setInterval 而不是空的 Promise
const keepAlive = setInterval(() => {
// 注意在 e2e 的 CleanUp 里关闭服务器
setInterval(() => {
// 每10秒输出一次状态确认服务器还在运行
console.log('Mock OpenAI 服务器仍在运行...');
}, 10000);
} catch (error) {
console.error('❌ 启动服务器失败:', error);

View file

@ -1,6 +1,6 @@
{
"exclude": ["template/**/*.js", "features/cucumber.config.js", "**/__mocks__/**/*.js"],
"include": ["src", "features", "test", "./*.*.ts", "./*.*.js", "forge.config.ts"],
"include": ["src", "features", "test", "scripts", "./*.*.ts", "./*.*.js", "forge.config.ts"],
"ts-node": {
"files": true,
"compilerOptions": {