i18n-validate
Advanced tools
Comparing version 0.1.0-next.41f3156.0 to 0.1.0-next.63a6b6a.0
#!/usr/bin/env node | ||
import { parseOptionsFile, log, parseFile, ValidationError, validateKey } from './chunk-W3EPKWG4.js'; | ||
import { parseOptionsFile, log, parseFile, ValidationError, validateKey } from './chunk-TQYKUNF4.js'; | ||
import process from 'node:process'; | ||
@@ -7,3 +7,3 @@ import { Command } from 'commander'; | ||
var command = new Command().version("0.1.0-next.41f3156.0").usage("[options] <file ...>").option("-c, --config <config>", "Path to the config file", "./i18n-validate.json").option("--log-level <logLevel>", "Log level", "info").option("--exclude <exclude...>", "Exclude files from parsing", "**/node_modules/**").option("--exit-on-error", "Exit immediately if an error is found", false); | ||
var command = new Command().version("0.1.0-next.63a6b6a.0").usage("[options] <file ...>").option("-c, --config <config>", "Path to the config file", "./i18n-validate.json").option("--log-level <logLevel>", "Log level", "info").option("--exclude <exclude...>", "Exclude files from parsing", "**/node_modules/**").option("--exit-on-error", "Exit immediately if an error is found", false); | ||
command.on("--help", () => { | ||
@@ -40,2 +40,3 @@ console.log(""); | ||
var errorCount = 0; | ||
var warningCount = 0; | ||
for await (const file of glob) { | ||
@@ -45,3 +46,6 @@ log(`Parsing ${file}`, "debug", options); | ||
for (const node of translationNodes) { | ||
if (!node.key || !node.namespace) { | ||
if (!node.isStaticKey) { | ||
log(new ValidationError("Dynamic keys are not supported yet. Skipping", node.path, node.positions), "warn", options); | ||
warningCount++; | ||
} else if (!node.key || !node.namespace) { | ||
log(new ValidationError("Missing translation key or namespace", node.path, node.positions), "error", options); | ||
@@ -57,6 +61,6 @@ errorCount++; | ||
if (errorCount > 0) { | ||
log(`Found ${errorCount} errors`, "error", options); | ||
log(`Found ${errorCount} errors and ${warningCount} warnings`, "info", options); | ||
process.exit(1); | ||
} else { | ||
log(`Found ${errorCount} errors`, "info", options); | ||
log(`Found ${errorCount} errors and ${warningCount} warnings`, "info", options); | ||
process.exit(0); | ||
@@ -63,0 +67,0 @@ } |
@@ -98,2 +98,3 @@ type LogLevel = 'debug' | 'error' | 'info' | 'warn'; | ||
interface TranslationNode { | ||
isStaticKey: boolean; | ||
key: string; | ||
@@ -100,0 +101,0 @@ namespace: string; |
@@ -1,3 +0,3 @@ | ||
export { ValidationError, parseFile, parseOptionsFile, validateKey } from './chunk-W3EPKWG4.js'; | ||
export { ValidationError, parseFile, parseOptionsFile, validateKey } from './chunk-TQYKUNF4.js'; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "i18n-validate", | ||
"version": "0.1.0-next.41f3156.0", | ||
"version": "0.1.0-next.63a6b6a.0", | ||
"description": "A cli tool to find invalid i18n keys, missing variables and many more", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -30,11 +30,11 @@ <div align="center"> | ||
Options: | ||
-V, --version output the version number | ||
-c, --config <config> Path to the config file (default: | ||
"./i18n-validate.json") | ||
--log-level <logLevel> Log level (default: "info") | ||
--exclude <exclude...> Exclude files from parsing (default: | ||
"**/node_modules/**") | ||
--exitOnError Exit immediately if an error is found (default: | ||
false) | ||
-h, --help display help for command | ||
-V, --version output the version number | ||
-c, --config <config> Path to the config file (default: | ||
"./i18n-validate.json") | ||
--log-level <logLevel> Log level (default: "info") | ||
--exclude <exclude...> Exclude files from parsing (default: | ||
"**/node_modules/**") | ||
--exit-on-error Exit immediately if an error is found (default: | ||
false) | ||
-h, --help display help for command | ||
@@ -59,3 +59,3 @@ Examples: | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/imranbarbhuiya/i18n-validate/.github/i18n-validate.schema.json" | ||
"$schema": "https://raw.githubusercontent.com/imranbarbhuiya/i18n-validate/main/.github/i18n-validate.schema.json" | ||
} | ||
@@ -62,0 +62,0 @@ ``` |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
38295
403