@lingual/i18n-check 0.8.0 → 0.8.1

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.
package/dist/bin/index.js CHANGED
@@ -23,7 +23,7 @@ commander_1.program
23
23
  .option("-o, --only <only...>", "define the specific checks you want to run: invalidKeys, missingKeys, unused, undefined. By default the check will validate against missing and invalid keys, i.e. --only invalidKeys,missingKeys")
24
24
  .option("-r, --reporter <style>", "define the reporting style: standard or summary")
25
25
  .option("-e, --exclude <exclude...>", "define the file(s) and/or folders(s) that should be excluded from the check")
26
- .option("-u, --unused <path>", "define the source path to find all unused and undefined keys")
26
+ .option("-u, --unused <paths...>", "define the source path(s) to find all unused and undefined keys")
27
27
  .option("--parser-component-functions <components...>", "a list of component names to parse when using the --unused option")
28
28
  .parse();
29
29
  const getCheckOptions = () => {
@@ -157,7 +157,11 @@ const main = async () => {
157
157
  const result = (0, __1.checkTranslations)(srcFiles, targetFiles, options);
158
158
  printTranslationResult(result);
159
159
  if (unusedSrcPath) {
160
- const filesToParse = (0, glob_1.globSync)(`${unusedSrcPath}/**/*.{ts,tsx}`, {
160
+ const isMultiUnusedFolders = unusedSrcPath.length > 1;
161
+ const pattern = isMultiUnusedFolders
162
+ ? `{${unusedSrcPath.join(",").trim()}}/**/*.{ts,tsx}`
163
+ : `${unusedSrcPath.join(",").trim()}/**/*.{ts,tsx}`;
164
+ const filesToParse = (0, glob_1.globSync)(pattern, {
161
165
  ignore: ["node_modules/**"],
162
166
  });
163
167
  const unusedKeys = await (0, __1.checkUnusedKeys)(srcFiles, filesToParse, options, componentFunctions);
@@ -330,6 +330,37 @@ Found undefined keys!
330
330
  │ translations/codeExamples/reacti18next/src/App.tsx │ some.key.that.is.not.defined │
331
331
  └──────────────────────────────────────────────────────┴────────────────────────────────┘
332
332
 
333
+ `);
334
+ done();
335
+ });
336
+ });
337
+ it("should find unused and undefined keys for react-i18next applications with multiple source folders", (done) => {
338
+ (0, child_process_1.exec)("node dist/bin/index.js --source en --locales translations/codeExamples/reacti18next/locales -f i18next -u translations/codeExamples/reacti18next/src translations/codeExamples/reacti18next/secondSrcFolder --parser-component-functions WrappedTransComponent", (_error, stdout, _stderr) => {
339
+ const result = stdout.split("Done")[0];
340
+ expect(result).toEqual(`i18n translations checker
341
+ Source: en
342
+ Selected format is: i18next
343
+
344
+ No missing keys found!
345
+
346
+ No invalid translations found!
347
+
348
+ Found unused keys!
349
+ ┌──────────────────────────────────────────────────────────────────────┬──────────────────┐
350
+ │ file │ key │
351
+ ├──────────────────────────────────────────────────────────────────────┼──────────────────┤
352
+ │ translations/codeExamples/reacti18next/locales/en/translation.json │ format.ebook │
353
+ │ translations/codeExamples/reacti18next/locales/en/translation.json │ nonExistentKey │
354
+ └──────────────────────────────────────────────────────────────────────┴──────────────────┘
355
+
356
+ Found undefined keys!
357
+ ┌───────────────────────────────────────────────────────────────────┬───────────────────────────────────┐
358
+ │ file │ key │
359
+ ├───────────────────────────────────────────────────────────────────┼───────────────────────────────────┤
360
+ │ translations/codeExamples/reacti18next/src/App.tsx │ some.key.that.is.not.defined │
361
+ │ translations/codeExamples/reacti18next/secondSrcFolder/Main.tsx │ another.key.that.is.not.defined │
362
+ └───────────────────────────────────────────────────────────────────┴───────────────────────────────────┘
363
+
333
364
  `);
334
365
  done();
335
366
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingual/i18n-check",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "i18n translation messages check",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",