mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-26 13:19:34 +07:00
* v2 init * chore: update eslint suppressions and package dependencies - Removed several eslint suppressions related to array sorting and reversing from eslint-suppressions.json to clean up the configuration. - Updated @lobehub/lint package version from 2.0.0-beta.6 to 2.0.0-beta.7 in package.json for improvements and bug fixes. - Made minor formatting adjustments in vitest.config.mts and various SKILL.md files for better readability and consistency. Signed-off-by: Innei <tukon479@gmail.com> * fix: clean up import statements and formatting - Removed unnecessary whitespace in replaceComponentImports.ts for improved readability. - Standardized import statements in contextEngineering.ts and createAgentExecutors.ts by adding missing spaces for consistency. Signed-off-by: Innei <tukon479@gmail.com> * chore: update eslint suppressions and clean up code formatting * 🐛 fix: use vi.hoisted for mock variable initialization Fix TDZ error in persona service test by using vi.hoisted() to ensure mock variables are available when vi.mock factory runs. --------- Signed-off-by: Innei <tukon479@gmail.com>
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
import { existsSync } from 'node:fs';
|
|
|
|
import { consola } from 'consola';
|
|
import { colors } from 'consola/utils';
|
|
import { unset } from 'es-toolkit/compat';
|
|
import { diff } from 'just-diff';
|
|
|
|
import {
|
|
entryLocaleJsonFilepath,
|
|
i18nConfig,
|
|
outputLocaleJsonFilepath,
|
|
srcDefaultLocales,
|
|
} from './const';
|
|
import { readJSON, tagWhite, writeJSONWithPrettier } from './utils';
|
|
|
|
export const genDiff = () => {
|
|
consola.start(`Remove diff analysis...`);
|
|
|
|
const resources = require(srcDefaultLocales);
|
|
const data = Object.entries(resources.default);
|
|
|
|
for (const [ns, devJSON] of data) {
|
|
const filepath = entryLocaleJsonFilepath(`${ns}.json`);
|
|
if (!existsSync(filepath)) continue;
|
|
const previousProdJSON = readJSON(filepath);
|
|
|
|
const diffResult = diff(previousProdJSON, devJSON as any);
|
|
if (diffResult.length === 0) {
|
|
consola.success(tagWhite(ns), colors.gray(filepath));
|
|
continue;
|
|
}
|
|
|
|
const clearLocals = [];
|
|
|
|
for (const locale of i18nConfig.outputLocales) {
|
|
const localeFilepath = outputLocaleJsonFilepath(locale, `${ns}.json`);
|
|
if (!existsSync(localeFilepath)) continue;
|
|
const localeJSON = readJSON(localeFilepath);
|
|
|
|
for (const item of diffResult) {
|
|
unset(localeJSON, item.path);
|
|
}
|
|
|
|
writeJSONWithPrettier(localeFilepath, localeJSON);
|
|
clearLocals.push(locale);
|
|
}
|
|
consola.info('clear', clearLocals);
|
|
consola.success(tagWhite(ns), colors.gray(filepath));
|
|
}
|
|
};
|