react-i18next-scanner 0.1.9 → 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,14 +1,13 @@
1
1
  import fs from "fs/promises";
2
2
  import path from "path";
3
3
  import { sortObject } from "../utils/sortObject.js";
4
- const DEFAULT_DYNAMIC_REPORT_DIR = path.resolve(process.cwd(), "reports/dynamic-translations");
5
4
  export async function writeDynamicTranslationReport(report, outputDir) {
6
5
  if (Object.keys(report).length === 0) {
7
6
  return;
8
7
  }
9
- await fs.mkdir(outputDir, { recursive: true });
10
8
  const rootReportDir = outputDir ?? "reports";
11
9
  const reportDir = path.join(rootReportDir, "dynamic-translations");
10
+ await fs.mkdir(reportDir, { recursive: true });
12
11
  const reportPath = path.join(reportDir, "dynamic-translation-usages.json");
13
12
  const sortedReport = sortObject(report);
14
13
  await fs.writeFile(reportPath, `${JSON.stringify(sortedReport, null, 2)}\n`, "utf-8");
@@ -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
- const DEFAULT_OUTPUT_DIR = path.resolve(process.cwd(), "dynamic-translations");
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
- await fs.mkdir(outputDir, { recursive: true });
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-i18next-scanner",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "CLI tool to scan React projects for missing and unused react-i18next translation keys",
5
5
  "bin": "./dist/cli/cli.js",
6
6
  "scripts": {