react-i18next-scanner 0.1.8 → 0.1.10
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.
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import fs from "fs/promises";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { sortObject } from "../utils/sortObject.js";
|
|
4
|
-
|
|
5
|
-
export async function writeDynamicTranslationReport(report, outputDir = DEFAULT_DYNAMIC_REPORT_DIR) {
|
|
4
|
+
export async function writeDynamicTranslationReport(report, outputDir) {
|
|
6
5
|
if (Object.keys(report).length === 0) {
|
|
7
6
|
return;
|
|
8
7
|
}
|
|
9
|
-
|
|
10
|
-
const
|
|
8
|
+
const rootReportDir = outputDir ?? "reports";
|
|
9
|
+
const reportDir = path.join(rootReportDir, "dynamic-translations");
|
|
10
|
+
await fs.mkdir(reportDir, { recursive: true });
|
|
11
|
+
const reportPath = path.join(reportDir, "dynamic-translation-usages.json");
|
|
11
12
|
const sortedReport = sortObject(report);
|
|
12
13
|
await fs.writeFile(reportPath, `${JSON.stringify(sortedReport, null, 2)}\n`, "utf-8");
|
|
13
14
|
console.log(`📝 Dynamic translation report created: ${reportPath}`);
|
|
@@ -3,8 +3,7 @@ import fs from "fs/promises";
|
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { addKey } from "../utils/addKey.js";
|
|
5
5
|
import { sortObject } from "../utils/sortObject.js";
|
|
6
|
-
|
|
7
|
-
export async function writePossiblyDynamicallyUsedReport(keysByFile, jsonFiles, outputDir = DEFAULT_OUTPUT_DIR) {
|
|
6
|
+
export async function writePossiblyDynamicallyUsedReport(keysByFile, jsonFiles, outputDir) {
|
|
8
7
|
const reportDataByFile = {};
|
|
9
8
|
for (const file of jsonFiles) {
|
|
10
9
|
const possibleKeys = keysByFile[file.filePath] ?? [];
|
|
@@ -26,7 +25,9 @@ export async function writePossiblyDynamicallyUsedReport(keysByFile, jsonFiles,
|
|
|
26
25
|
if (Object.keys(reportDataByFile).length === 0) {
|
|
27
26
|
return;
|
|
28
27
|
}
|
|
29
|
-
|
|
28
|
+
const rootReportDir = outputDir ?? "reports";
|
|
29
|
+
const reportDir = path.join(rootReportDir, "possibly-dynamically-used");
|
|
30
|
+
await fs.mkdir(reportDir, { recursive: true });
|
|
30
31
|
const reportPath = path.join(outputDir, "possibly-dynamically-used.json");
|
|
31
32
|
await fs.writeFile(reportPath, `${JSON.stringify(sortObject(reportDataByFile), null, 2)}\n`, "utf-8");
|
|
32
33
|
console.log(`📝 Possibly dynamically used 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);
|