react-i18next-scanner 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,12 +2,14 @@ import fs from "fs/promises";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { sortObject } from "../utils/sortObject.js";
|
|
4
4
|
const DEFAULT_DYNAMIC_REPORT_DIR = path.resolve(process.cwd(), "reports/dynamic-translations");
|
|
5
|
-
export async function writeDynamicTranslationReport(report, outputDir
|
|
5
|
+
export async function writeDynamicTranslationReport(report, outputDir) {
|
|
6
6
|
if (Object.keys(report).length === 0) {
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
9
9
|
await fs.mkdir(outputDir, { recursive: true });
|
|
10
|
-
const
|
|
10
|
+
const rootReportDir = outputDir ?? "reports";
|
|
11
|
+
const reportDir = path.join(rootReportDir, "dynamic-translations");
|
|
12
|
+
const reportPath = path.join(reportDir, "dynamic-translation-usages.json");
|
|
11
13
|
const sortedReport = sortObject(report);
|
|
12
14
|
await fs.writeFile(reportPath, `${JSON.stringify(sortedReport, null, 2)}\n`, "utf-8");
|
|
13
15
|
console.log(`📝 Dynamic translation report created: ${reportPath}`);
|
package/dist/core/runInit.js
CHANGED
package/dist/core/scanner.js
CHANGED
|
@@ -12,7 +12,7 @@ import { deepVerifyUnusedKeys } from "./analysis/deepVerifyUnusedKeys.js";
|
|
|
12
12
|
export async function runScanner(config) {
|
|
13
13
|
const files = await getFiles(config.srcPaths);
|
|
14
14
|
const dynamicUsages = await detectDynamicTranslationUsages(files);
|
|
15
|
-
await writeDynamicTranslationReport(dynamicUsages);
|
|
15
|
+
await writeDynamicTranslationReport(dynamicUsages, config.outputDir);
|
|
16
16
|
const usedKeys = await extractKeysFromFiles(files);
|
|
17
17
|
const jsonData = await loadJsonKeys(config.jsonDir);
|
|
18
18
|
const result = analyzeKeys(usedKeys, jsonData);
|